Final hacked up version to be published
parent
ef5df68b05
commit
774545ac05
|
@ -46,7 +46,7 @@ uint8_t edidbuf[] = {
|
||||||
0x01, 0x1d, 0x80, 0xd0, 0x72, 0x1c, 0x16, 0x20, 0x10, 0x2c, 0x25, 0x80,
|
0x01, 0x1d, 0x80, 0xd0, 0x72, 0x1c, 0x16, 0x20, 0x10, 0x2c, 0x25, 0x80,
|
||||||
0xc4, 0x8e, 0x21, 0x00, 0x00, 0x9e, 0x56, 0x5e, 0x00, 0xa0, 0xa0, 0xa0,
|
0xc4, 0x8e, 0x21, 0x00, 0x00, 0x9e, 0x56, 0x5e, 0x00, 0xa0, 0xa0, 0xa0,
|
||||||
0x29, 0x50, 0x30, 0xa7*/
|
0x29, 0x50, 0x30, 0xa7*/
|
||||||
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x34, 0xa9, 0x76, 0xd0,
|
/* 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x34, 0xa9, 0x76, 0xd0,
|
||||||
0x11, 0x00, 0x46, 0x14, 0x00, 0x11, 0x01, 0x03, 0x80, 0x00, 0x00, 0x78,
|
0x11, 0x00, 0x46, 0x14, 0x00, 0x11, 0x01, 0x03, 0x80, 0x00, 0x00, 0x78,
|
||||||
0x0a, 0x69, 0xbe, 0xa6, 0x57, 0x53, 0xa6, 0x23, 0x0c, 0x48, 0x55, 0x00,
|
0x0a, 0x69, 0xbe, 0xa6, 0x57, 0x53, 0xa6, 0x23, 0x0c, 0x48, 0x55, 0x00,
|
||||||
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||||
|
@ -67,12 +67,33 @@ uint8_t edidbuf[] = {
|
||||||
0xc4, 0x8e, 0x21, 0x00, 0x00, 0x1e, 0x01, 0x1d, 0x00, 0xbc, 0x52, 0xd0,
|
0xc4, 0x8e, 0x21, 0x00, 0x00, 0x1e, 0x01, 0x1d, 0x00, 0xbc, 0x52, 0xd0,
|
||||||
0x1e, 0x20, 0xb8, 0x28, 0x55, 0x40, 0xc4, 0x8e, 0x21, 0x00, 0x00, 0x1e,
|
0x1e, 0x20, 0xb8, 0x28, 0x55, 0x40, 0xc4, 0x8e, 0x21, 0x00, 0x00, 0x1e,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x56
|
0x00, 0x00, 0x00, 0x56*/
|
||||||
|
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x4c, 0x2d, 0x49, 0x05,
|
||||||
|
0x30, 0x34, 0x47, 0x4d, 0x1c, 0x14, 0x01, 0x03, 0x80, 0x10, 0x09, 0x78,
|
||||||
|
0x2a, 0xee, 0x9d, 0xa3, 0x54, 0x47, 0x99, 0x26, 0x0f, 0x47, 0x4a, 0xbf,
|
||||||
|
0xef, 0x80, 0xa9, 0x40, 0x81, 0x80, 0x81, 0x40, 0x71, 0x4f, 0x01, 0x01,
|
||||||
|
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x3a, 0x80, 0x18, 0x71, 0x38,
|
||||||
|
0x2d, 0x40, 0x58, 0x2c, 0x45, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e,
|
||||||
|
0x66, 0x21, 0x50, 0xb0, 0x51, 0x00, 0x1b, 0x30, 0x40, 0x70, 0x36, 0x00,
|
||||||
|
0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x17,
|
||||||
|
0x4b, 0x1a, 0x51, 0x11, 0x00, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
|
||||||
|
0x00, 0x00, 0x00, 0xfc, 0x00, 0x48, 0x61, 0x63, 0x6b, 0x41, 0x56, 0x0a,
|
||||||
|
0x20, 0x20, 0x0a, 0x20, 0x20, 0x20, 0x01, 0xbf, 0x02, 0x03, 0x21, 0xf1,
|
||||||
|
0x4d, 0x90, 0x04, 0x13, 0x05, 0x14, 0x03, 0x07, 0x12, 0x16, 0x1f, 0x20,
|
||||||
|
0x21, 0x22, 0x23, 0x09, 0x07, 0x07, 0x83, 0x01, 0x00, 0x00, 0x66, 0x03,
|
||||||
|
0x0c, 0x00, 0x10, 0x00, 0x80, 0x01, 0x1d, 0x80, 0xd0, 0x72, 0x1c, 0x16,
|
||||||
|
0x20, 0x10, 0x2c, 0x25, 0x80, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x9e, 0x01,
|
||||||
|
0x1d, 0x80, 0x18, 0x71, 0x1c, 0x16, 0x20, 0x58, 0x2c, 0x25, 0x00, 0xa0,
|
||||||
|
0x5a, 0x00, 0x00, 0x00, 0x9e, 0x01, 0x1d, 0x00, 0xbc, 0x52, 0xd0, 0x1e,
|
||||||
|
0x20, 0xb8, 0x28, 0x55, 0x40, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x1e, 0x01,
|
||||||
|
0x1d, 0x00, 0x72, 0x51, 0xd0, 0x1e, 0x20, 0x6e, 0x28, 0x55, 0x00, 0xa0,
|
||||||
|
0x5a, 0x00, 0x00, 0x00, 0x1e, 0x8c, 0x0a, 0xd0, 0x90, 0x20, 0x40, 0x31,
|
||||||
|
0x20, 0x0c, 0x40, 0x55, 0x00, 0xa0, 0x5a, 0x00, 0x00, 0x00, 0x18, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0xed
|
||||||
};
|
};
|
||||||
|
|
||||||
class EP9442Matrix {
|
class EP9442Matrix {
|
||||||
Timer pollTimer;
|
Timer pollTimer;
|
||||||
bool initialized = false;
|
|
||||||
enum reg49_sel { PRIMARY=0, SECONDARY };
|
enum reg49_sel { PRIMARY=0, SECONDARY };
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -107,6 +128,7 @@ class EP9442Matrix {
|
||||||
|
|
||||||
if ((err = Wire.endTransmission()) != 0) {
|
if ((err = Wire.endTransmission()) != 0) {
|
||||||
debugf("i2c: write %02x:%02x = %02x - error %02x", addr, reg, value, err);
|
debugf("i2c: write %02x:%02x = %02x - error %02x", addr, reg, value, err);
|
||||||
|
errcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
@ -117,6 +139,7 @@ class EP9442Matrix {
|
||||||
Wire.write(reg);
|
Wire.write(reg);
|
||||||
if (Wire.endTransmission(false) != 0) {
|
if (Wire.endTransmission(false) != 0) {
|
||||||
debugf("transmission end failed?");
|
debugf("transmission end failed?");
|
||||||
|
errcnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wire.requestFrom((int) addr, (int) cnt);
|
Wire.requestFrom((int) addr, (int) cnt);
|
||||||
|
@ -125,11 +148,17 @@ class EP9442Matrix {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
bool initialized = false;
|
||||||
|
int errcnt = 0;
|
||||||
|
|
||||||
EP9442Matrix() { }
|
EP9442Matrix() { }
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
uint8_t err;
|
uint8_t err;
|
||||||
|
|
||||||
|
errcnt = 0;
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
Wire.begin(4, 5);
|
Wire.begin(4, 5);
|
||||||
Wire.setClock(300000);
|
Wire.setClock(300000);
|
||||||
Wire.setClockStretchLimit(5*230);
|
Wire.setClockStretchLimit(5*230);
|
||||||
|
@ -177,7 +206,7 @@ public:
|
||||||
delay(50);
|
delay(50);
|
||||||
digitalWrite(0, HIGH);
|
digitalWrite(0, HIGH);
|
||||||
// ...let it boot
|
// ...let it boot
|
||||||
pollTimer.initializeMs(9000, TimerDelegate(&EP9442Matrix::finalizeInit, this)).start();
|
pollTimer.initializeMs(9000, TimerDelegate(&EP9442Matrix::finalizeInit, this)).startOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
void finalizeInit() {
|
void finalizeInit() {
|
||||||
|
@ -200,7 +229,7 @@ public:
|
||||||
debugf("done");
|
debugf("done");
|
||||||
|
|
||||||
Serial.println("Init end");
|
Serial.println("Init end");
|
||||||
pollTimer.initializeMs(1000, TimerDelegate(&EP9442Matrix::pollStatus, this)).start();
|
//pollTimer.initializeMs(1000, TimerDelegate(&EP9442Matrix::pollStatus, this)).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void testOut2() {
|
void testOut2() {
|
||||||
|
@ -264,7 +293,6 @@ public:
|
||||||
// portStatus[4];
|
// portStatus[4];
|
||||||
|
|
||||||
struct rx_port_status rxPortStatus(int port) {
|
struct rx_port_status rxPortStatus(int port) {
|
||||||
struct rx_port_status portStatus;
|
|
||||||
Serial.printf("RX Port %d: ", port);
|
Serial.printf("RX Port %d: ", port);
|
||||||
i2cWrite(0x65, 0x07, port);
|
i2cWrite(0x65, 0x07, port);
|
||||||
uint8_t status = i2cRead(0x65, 0x07);
|
uint8_t status = i2cRead(0x65, 0x07);
|
||||||
|
@ -283,10 +311,43 @@ public:
|
||||||
Serial.printf("%02x ", i2cRead(0x65, 0x0e));
|
Serial.printf("%02x ", i2cRead(0x65, 0x0e));
|
||||||
Serial.printf("%02x] \r\n", i2cRead(0x65, 0x0f));
|
Serial.printf("%02x] \r\n", i2cRead(0x65, 0x0f));
|
||||||
|
|
||||||
|
struct rx_port_status portStatus;
|
||||||
portStatus.online = status & 0x80;
|
portStatus.online = status & 0x80;
|
||||||
|
|
||||||
return portStatus;
|
return portStatus;
|
||||||
}
|
}
|
||||||
|
struct tx_port_status {};
|
||||||
|
|
||||||
|
struct tx_port_status txPortStatus(int port) {
|
||||||
|
Serial.printf("TX Port %d: ", port);
|
||||||
|
i2cWrite(0x65, 0x07, port << 2);
|
||||||
|
|
||||||
|
uint8_t status = i2cRead(0x65, 0x08);
|
||||||
|
if (status & 0x80) Serial.printf("mute ");
|
||||||
|
if (status & 0x02) Serial.printf("enc_opt ");
|
||||||
|
|
||||||
|
uint8_t status3 = i2cRead(0x65, 0x09);
|
||||||
|
if (status3 & 0x04) Serial.printf("rsen ");
|
||||||
|
|
||||||
|
uint8_t status4 = i2cRead(0x65, 0x0f);
|
||||||
|
if (status4 & 0x01) Serial.printf("enc ");
|
||||||
|
if (status4 & 0x02) Serial.printf("ri_rdy ");
|
||||||
|
if (status4 & 0x10) Serial.printf("rptr ");
|
||||||
|
|
||||||
|
uint8_t status5 = i2cRead(0x65, 0x0e);
|
||||||
|
if (status5 & 0x01) Serial.printf("hdmi ");
|
||||||
|
i2cWrite(0x65, 0x0e, status5 | 0x01);
|
||||||
|
|
||||||
|
Serial.printf("[%02x ", i2cRead(0x65, 0x07));
|
||||||
|
Serial.printf("%02x ", i2cRead(0x65, 0x08));
|
||||||
|
Serial.printf("%02x ", i2cRead(0x65, 0x09));
|
||||||
|
Serial.printf("%02x ", i2cRead(0x65, 0x0a));
|
||||||
|
Serial.printf("%02x ", i2cRead(0x65, 0x0e));
|
||||||
|
Serial.printf("%02x]\r\n", i2cRead(0x65, 0x0f));
|
||||||
|
|
||||||
|
struct tx_port_status portStatus;
|
||||||
|
return portStatus;
|
||||||
|
}
|
||||||
|
|
||||||
void pollStatus() {
|
void pollStatus() {
|
||||||
debugf("0x43: %02x", i2cRead(0x64, 0x43));
|
debugf("0x43: %02x", i2cRead(0x64, 0x43));
|
||||||
|
@ -294,6 +355,7 @@ public:
|
||||||
i2cWrite(0x64, 0x45, 0x15);
|
i2cWrite(0x64, 0x45, 0x15);
|
||||||
debugf("0x44: %02x", i2cRead(0x64, 0x44));
|
debugf("0x44: %02x", i2cRead(0x64, 0x44));
|
||||||
debugf("0x45: %02x", i2cRead(0x64, 0x45));
|
debugf("0x45: %02x", i2cRead(0x64, 0x45));
|
||||||
|
|
||||||
for (int port = 0; port < 4; port++) {
|
for (int port = 0; port < 4; port++) {
|
||||||
rxPortStatus(port);
|
rxPortStatus(port);
|
||||||
/*if (portStatus[port].online != status & 0x80) {
|
/*if (portStatus[port].online != status & 0x80) {
|
||||||
|
@ -303,31 +365,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int port = 0; port < 2; port++) {
|
for (int port = 0; port < 2; port++) {
|
||||||
Serial.printf("TX Port %d: ", port);
|
txPortStatus(port);
|
||||||
i2cWrite(0x65, 0x07, port << 2);
|
|
||||||
|
|
||||||
uint8_t status = i2cRead(0x65, 0x08);
|
|
||||||
if (status & 0x80) Serial.printf("mute ");
|
|
||||||
if (status & 0x02) Serial.printf("enc_opt ");
|
|
||||||
|
|
||||||
uint8_t status3 = i2cRead(0x65, 0x09);
|
|
||||||
if (status3 & 0x04) Serial.printf("rsen ");
|
|
||||||
|
|
||||||
uint8_t status4 = i2cRead(0x65, 0x0f);
|
|
||||||
if (status4 & 0x01) Serial.printf("enc ");
|
|
||||||
if (status4 & 0x02) Serial.printf("ri_rdy ");
|
|
||||||
if (status4 & 0x10) Serial.printf("rptr ");
|
|
||||||
|
|
||||||
uint8_t status5 = i2cRead(0x65, 0x0e);
|
|
||||||
if (status5 & 0x01) Serial.printf("hdmi ");
|
|
||||||
i2cWrite(0x65, 0x0e, status5 | 0x01);
|
|
||||||
|
|
||||||
Serial.printf("[%02x ", i2cRead(0x65, 0x07));
|
|
||||||
Serial.printf("%02x ", i2cRead(0x65, 0x08));
|
|
||||||
Serial.printf("%02x ", i2cRead(0x65, 0x09));
|
|
||||||
Serial.printf("%02x ", i2cRead(0x65, 0x0a));
|
|
||||||
Serial.printf("%02x ", i2cRead(0x65, 0x0e));
|
|
||||||
Serial.printf("%02x]\r\n", i2cRead(0x65, 0x0f));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,6 +423,7 @@ public:
|
||||||
|
|
||||||
class MatrixEndpoint: public Endpoint {
|
class MatrixEndpoint: public Endpoint {
|
||||||
EP9442Matrix matrix;
|
EP9442Matrix matrix;
|
||||||
|
Timer pollTimer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MatrixEndpoint() : Endpoint("matrix") { }
|
MatrixEndpoint() : Endpoint("matrix") { }
|
||||||
|
@ -394,6 +433,7 @@ public:
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
matrix.init();
|
matrix.init();
|
||||||
|
pollTimer.initializeMs(1000, TimerDelegate(&MatrixEndpoint::pollStatus, this)).start();
|
||||||
//matrix.init();
|
//matrix.init();
|
||||||
//matrix.testOut2();
|
//matrix.testOut2();
|
||||||
//matrix.init();
|
//matrix.init();
|
||||||
|
@ -410,6 +450,33 @@ public:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
struct EP9442Matrix::rx_port_status rx_ports[4];
|
||||||
|
|
||||||
|
void pollStatus() {
|
||||||
|
if (matrix.errcnt > 10) {
|
||||||
|
matrix.init();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (not matrix.initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
static bool firstPoll = true;
|
||||||
|
|
||||||
|
debugf("Polling...");
|
||||||
|
matrix.pollStatus();
|
||||||
|
|
||||||
|
for (int port = 0; port < 4; port++) {
|
||||||
|
struct EP9442Matrix::rx_port_status status = matrix.rxPortStatus(port);
|
||||||
|
|
||||||
|
debugf("status: %d %d", rx_ports[port].online, status.online);
|
||||||
|
if (rx_ports[port].online != status.online || firstPoll) {
|
||||||
|
notify("rx" + String(port) + "_online", (status.online == true) ? "true" : "false");
|
||||||
|
}
|
||||||
|
rx_ports[port] = status;
|
||||||
|
}
|
||||||
|
firstPoll = false;
|
||||||
|
}
|
||||||
|
|
||||||
EndpointResult onValue(String property, String value) {
|
EndpointResult onValue(String property, String value) {
|
||||||
if (property == "sourceA") {
|
if (property == "sourceA") {
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
exec xxd -i /sys/devices/pci0000:00/0000:00:02.0/drm/card0/card0-HDMI-A-2/edid
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mosquitto_pub -h sound.waw.hackerspace.pl -t "iot/$2/matrix/edid$3/set" -m "$(xxd -c256 -p $1)"
|
Loading…
Reference in New Issue