0

During my experiments I accidentally ruined the EDID in the internal display of my old MBP15 (late 2011, with disabled GPU). (I learned that with IOreg command). I need to edit just the first three bytes of the EDID to reverse it back. There are some snippets on the web to read the EDID, but there are none to write it back (at least for the Intel platform). I have some difficulties with IOI2CRequest structure. What makes things even more complicated is the code to iterate through i2c devices, that works flawlessly on a good mbp, but doesn't work properly on the damaged one.

I tried this code:

int main(int argc, char** argv) {
    for (NSScreen* screen in NSScreen.screens) {
        printf("gotta!\r\n");
        CGDirectDisplayID displayID = [[screen.deviceDescription objectForKey:@"NSScreenNumber"] unsignedIntValue];
//        if (CGDisplayIsBuiltin(displayID)) {
                        printf("True!\r\n");
  //                      continue;
    //    };
        printf("Okay, if\r\n");
        io_service_t framebuffer = 0;
        CGSServiceForDisplayNumber(displayID, &framebuffer);
printf("zero\r\n");
        if (framebuffer == 0) return 1;
printf("one\r\n");
        IOI2CRequest request = {};
        UInt8 data[256] = {};

        request.sendAddress = 0xA0;
        request.sendTransactionType = kIOI2CSimpleTransactionType;
        request.sendBuffer = (vm_address_t)data;
        request.sendBytes = 0x01;

        data[0] = 0x00;
        request.replyAddress = 0xA1;
        request.replyTransactionType = kIOI2CSimpleTransactionType;
        request.replyBuffer = (vm_address_t)data;
        request.replyBytes = sizeof(data);
printf("two\r\n");
        if (!FramebufferI2CRequest(framebuffer, &request)) return 1;
printf("three\r\n");

it just prints 'gotta!', 'True!', 'Okay, if', 'zero' and then stops, which basically means that framebuffer = 0 (probably because the system believes it has no connected displays).

UPD: I printfed %d displayID and framebuffer, here are the results: framebuffer=0 displayid=1104977153

Is there a way to perform IOFBCopyI2CInterfaceForBus call with the unknown framebuffer? How many I2C devices are there on the MBP's i2c bus? I can fin the right one by iterating all of them and then dumping and parsing the data (at least I know what I am looking for)

Serjio M
  • 1
  • 1

0 Answers0