@WayneWWW
Do you know why DP can’t get EDID through I2C
int open_i2c_dev(int i2cbus) {
int i2cfile;
char filename[128];
unsigned long funcs;
sprintf(filename, “/dev/i2c-%d”, i2cbus);
i2cfile = open(filename, O_RDWR);
printf(“i2cfile %d\r\n”,i2cfile);
if (i2cfile < 0 && errno == ENOENT) {
filename[8] = ‘/’;
i2cfile = open(filename, O_RDWR);
}
if (errno == EACCES) {
printf(“Permission denied opening i2c. Run as root!\n”);
i2cfile = -2;
}
if (i2cfile >=0) {
if (ioctl(i2cfile, I2C_FUNCS, &funcs) < 0) {
perror("ioctl I2C_FUNCS");
i2cfile=-3;
}
if (!(funcs & (I2C_FUNC_SMBUS_READ_BYTE_DATA))) {
printf("No byte reading on this bus...\n");
i2cfile=-4;
}
if (ioctl(i2cfile, I2C_SLAVE, 0X50) < 0) {
perror("Problem requesting slave address");
i2cfile=-5;
}
}
return i2cfile;
}
int main()
{
int i2cfile,i2cbus=0;
unsigned char block[256];
int j,ret;
for (i2cfile = open_i2c_dev(i2cbus);i2cfile >= 0 || i2cfile < -3;i2cbus++,i2cfile = open_i2c_dev(i2cbus))
{
if (i2cbus > 8)
return 0;
if (i2cfile < -3)
return -1;
ret = i2c_smbus_read_byte_data(i2cfile, 0);
if (ret < 0) {
printf("No EDID on bus %i\n", i2cbus);
goto closeFile;
}
else {
printf("ok %i\n", i2cbus);
}
if (i2cfile >=0) {//no matter how many times, >=0 still looks really angry.
for (j=0;j<128;j++)
{
block[j] = i2c_smbus_read_byte_data(i2cfile, j);
printf("%x ",block[j]);
}
}
closeFile:
close(i2cfile);
}
return 0;
}
Result:
i2cfile 3
No EDID on bus 0
i2cfile 3
No EDID on bus 1
i2cfile 3
ok 2
1 0 fc 0 78 d 0 0 4 46 0 0 0 0 0 0 0 0 0 0 36 39 39 2d 31 33 34 34 38 2d 30 30 30 30 2d 34 30 30 20 46 2e 30 0 0 0 0 0 0 0 0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ab 30 ec 4b 4 0 31 34 32 33 32 31 39 31 30 38 30 30 32 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
i2cfile 3
No EDID on bus 3
i2cfile 3
No EDID on bus 4
i2cfile 3
No EDID on bus 5
i2cfile 3
No EDID on bus 6
i2cfile 3
No EDID on bus 7
i2cfile 3
No EDID on bus 8
i2cfile -1
It seems that I2C-2 can get some data, but this data is not the EDID I need.