Contribute
Register

[Guide] Laptop backlight control using AppleBacklightFixup.kext

Just change model part from 8-20. Then calculate checksum and fix last byte.
Could you elaborate a little bit on "calculate checksum and fix last byte"?
 
- Copy 8-17 bytes from my fixed EDID. (0 first byte as in programs)
- change your original EDID data bytes with those fixed one
- Save that EDID to file name fixed_edid
- Save my ruby script to same folder as edidparser.rb
- open terminal and Go to that folder and issue following command
Code:
ruby edidparser.rb fixed_edid
- script will give you calculated checksum
- change last byte of your fixed EDID with calculated checksum
- check again original checksum and calculated checksum is same
- Inject fixed EDID.

I injected my EDID with both DSDT and Clover.

EDIT:
I wrote better version of this script. You can run either directly or with your original EDID text file and it will print out fixed EDID for you.
Ruby:
#!/usr/bin/ruby
bytes = []
if ARGV.count == 0
    puts "Reading EDID from SYSTEM"
    data=`ioreg -l -w0 -d0 -r -c AppleBacklightDisplay`
    edid_hex=data.match(/IODisplayEDID.*?<([a-z0-9]+)>/i)[1]
    vendorid=data.match(/DisplayVendorID.*?([0-9]+)/i)[1].to_i
    productid=data.match(/DisplayProductID.*?([0-9]+)/i)[1].to_i
    puts "found display: vendorid #{vendorid}, productid #{productid}, EDID:\n#{edid_hex}"
    bytes=edid_hex.scan(/../).map{|x|Integer("0x#{x}")}.flatten
else
    puts "Reading EDID from FILE"
    file = ARGV.first
    edid_hex = File.read(file)
    bytes=edid_hex.scan(/../).map{|x|Integer("0x#{x}")}.flatten
end
puts "EDID Length : %d bytes" % bytes.length
edid=bytes[8..20]
if edid[0] >> 7 != 0
   puts "This EDID is corrupted"
else
   first = (edid[0] &  0b01111100) >> 2
   second = ((edid[0] &  0b00000011) << 3) + ((edid[1] &  0b11100000) >> 5)
   third = edid[1] &  0b00011111
   puts "Manufacturer: " + (first+64).chr + (second+64).chr + (third+64).chr
   puts "Product Code:  %02X%02X" % [edid[3], edid[2]]
   puts "Serial Number: %d" % (edid[4] + (edid[5] << 8) + (edid[6] << 16) + (edid[7] << 24))
    puts "Week of Manufacture: %d" % edid[8]
   puts "Year of Manufacture: %d" % (edid[9] + 1990)
end

checksum = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts "Calculated checksum: 0x%x" % checksum
puts "Original checksum: 0x%x" % bytes[127]

puts "Creating fixed EDID"
puts "Setting Manufacurer to APP"
bytes[8] = 06
bytes[9] = 16

puts "Setting Product Code to A014"
bytes[10] = 0x14
bytes[11] = 0xA0

puts "Setting Serial to 0"
bytes[12] = 0
bytes[13] = 0
bytes[14] = 0
bytes[15] = 0

puts "Setting Week of Manufacture to 10"
bytes[16] = 10

puts "Setting Year of Manufacture to 2012"
bytes[17] = 22

checksum = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts "Calculated checksum: 0x%x" % checksum
puts "Original checksum: 0x%x" % bytes[127]

puts "Fixing checksum"
bytes[127] = checksum
puts "Fixed EDID:\n#{bytes.map{|b|"%02X"%b}.join}"
 
Last edited:
Followed this guide as best as I could and I still cannot adjust brightness. :(
 

Attachments

  • CLOVER.zip
    1.7 MB · Views: 76
  • RehabMan.zip
    59.6 KB · Views: 79
  • TerminalOutput.zip
    1.1 KB · Views: 73
  • Chad’s MacBook ProIOReg.zip
    566 KB · Views: 69
Original EDID
Code:
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x4D, 0xD9, 0xFA, 0x06, 0x0D, 0x00, 0x00, 0x00,
0x00, 0x0C, 0x01, 0x03, 0x80, 0x1D, 0x10, 0xFF,
0x2F, 0x00, 0x00, 0xA0, 0x57, 0x49, 0x9B, 0x26,
0x10, 0x48, 0x4F, 0x00, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x27,
0x40, 0xB8, 0x60, 0x84, 0x23, 0x30, 0x1E, 0x1E,
0x11, 0x00, 0x25, 0xA5, 0x10, 0x00, 0x00, 0x18,
0x7A, 0x23, 0x40, 0x2C, 0x61, 0x84, 0x38, 0x30,
0x1E, 0x3C, 0x14, 0x00, 0x25, 0xA5, 0x10, 0x00,
0x00, 0x18, 0x62, 0x1C, 0x40, 0x2C, 0x61, 0x84,
0x38, 0x30, 0x1E, 0x3C, 0x14, 0x00, 0x25, 0xA5,
0x10, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40
Patched EDID
Code:
0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
0x06, 0x10, 0x14, 0xA0, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x16, 0x01, 0x03, 0x80, 0x1D, 0x10, 0xFF,
0x2F, 0x00, 0x00, 0xA0, 0x57, 0x49, 0x9B, 0x26,
0x10, 0x48, 0x4F, 0x00, 0x00, 0x00, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0E, 0x27,
0x40, 0xB8, 0x60, 0x84, 0x23, 0x30, 0x1E, 0x1E,
0x11, 0x00, 0x25, 0xA5, 0x10, 0x00, 0x00, 0x18,
0x7A, 0x23, 0x40, 0x2C, 0x61, 0x84, 0x38, 0x30,
0x1E, 0x3C, 0x14, 0x00, 0x25, 0xA5, 0x10, 0x00,
0x00, 0x18, 0x62, 0x1C, 0x40, 0x2C, 0x61, 0x84,
0x38, 0x30, 0x1E, 0x3C, 0x14, 0x00, 0x25, 0xA5,
0x10, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x95


original_EDID
Code:
00FFFFFFFFFFFF004DD9FA060D000000000C0103801D10FF2F0000A057499B2610484F000000010101010101010101010101010101010E2740B8608423301E1E110025A5100000187A23402C618438301E3C140025A510000018621C402C618438301E3C140025A5100000180000000000000000000000000000000000000040

patched_EDID
Code:
00FFFFFFFFFFFF00061014A0000000000A160103801D10FF2F0000A057499B2610484F000000010101010101010101010101010101010E2740B8608423301E1E110025A5100000187A23402C618438301E3C140025A510000018621C402C618438301E3C140025A5100000180000000000000000000000000000000000000095

According to EDID 1.3 data format bytes 8-20 gives information about manufacturer and serial of device.
I changed mine from Sony to Apple and also changed product code and dates. I haven't tested yet maybe not all properties are needed. If you create two text files with above content, you can see how EDID is parsed.

Code:
$ ruby edidparser.rb original_EDID
EDID Length : 128 bytes
Manufacturer: SNY
Product Code:  06FA
Serial Number: 13
Week of Manufacture: 0
Year of Manufacture: 2002
Calculated checksum: 0x40
Original checksum: 0x40

$ ruby edidparser.rb patched_EDID
EDID Length : 128 bytes
Manufacturer: APP
Product Code:  A014
Serial Number: 0
Week of Manufacture: 10
Year of Manufacture: 2012
Calculated checksum: 0x95
Original checksum: 0x95

Basically I changed bytes from 8-20 to original MacBook Pro display EDID data. My working reporting files also linked here. I also added very simple basic ruby code to test EDID data
EDID file must be a textfile which shouldn't have any comma etc. Basically after you change your EDID, you must calculate checksum and change the 128th byte. If your monitor is recent, it can have 256 or more Bytes of EDID data.Don't be alarmed.

Basic Ruby Code for EDID Parser

Ruby:
#!/usr/bin/ruby
bytes = []
if ARGV.count == 0
    puts "Reading EDID from SYSTEM"
    data=`ioreg -l -w0 -d0 -r -c AppleBacklightDisplay`
    edid_hex=data.match(/IODisplayEDID.*?<([a-z0-9]+)>/i)[1]
    vendorid=data.match(/DisplayVendorID.*?([0-9]+)/i)[1].to_i
    productid=data.match(/DisplayProductID.*?([0-9]+)/i)[1].to_i
    puts "found display: vendorid #{vendorid}, productid #{productid}, EDID:\n#{edid_hex}"
    bytes=edid_hex.scan(/../).map{|x|Integer("0x#{x}")}.flatten
else
    puts "Reading EDID from FILE"
    file = ARGV.first
    edid_hex = File.read(file)
    bytes=edid_hex.scan(/../).map{|x|Integer("0x#{x}")}.flatten
end
puts "EDID Length : %d bytes" % bytes.length
edid=bytes[8..20]
if edid[0] >> 7 != 0
   puts "This EDID is corrupted"
else
   first = (edid[0] &  0b01111100) >> 2
   second = ((edid[0] &  0b00000011) << 3) + ((edid[1] &  0b11100000) >> 5)
   third = edid[1] &  0b00011111
   puts "Manufacturer: " + (first+64).chr + (second+64).chr + (third+64).chr
   puts "Product Code:  %02X%02X" % [edid[3], edid[2]]
   puts "Serial Number: %d" % (edid[4] + (edid[5] << 8) + (edid[6] << 16) + (edid[7] << 24))
   puts "Week of Manufacture: %d" % edid[8]
   puts "Year of Manufacture: %d" % (edid[9] + 1990)
end

checksum = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts "Calculated checksum: 0x%x" % checksum
puts "Original checksum: 0x%x" % bytes[127]

If you run this ruby script without any argument, you can see your original EDID.
Problem reporting files: https://www.tonymacx86.com/attachments/archive-zip.246040/

It seems likely that changing the EDID has no effect.
The real effect of your changes is caused by removing the patches, injector kext, etc, which causes AppleBacklight.kext to use the "Default" profile.
Try with native EDID, but no patches to change the AppleBacklight profile (eg. like you have now).
Report result.
Note: There is no 'a104' display-id in AppleBacklight.kext Info.plist, so it will always get Default without an injector kext.
It would be interesting to know if changing the display-id (in EDID like you have) changes which profile you get (FxxT vs. FxxP). Testing that would require an injector with the a104 in it (refer to my previous upload and modify accordingly).
 
I injected your EDID and boom *black screen*, guess it's not a generic solution.

You should not expect to use a foreign EDID...
You must extract your own, then make the changes to your own EDID.
 
Followed this guide as best as I could and I still cannot adjust brightness. :(

Follow the ProBook guide. Use the 'beta' branch.
 
It seems likely that changing the EDID has no effect.
The real effect of your changes is caused by removing the patches, injector kext, etc, which causes AppleBacklight.kext to use the "Default" profile.
Try with native EDID, but no patches to change the AppleBacklight profile (eg. like you have now).
Report result.
Note: There is no 'a104' display-id in AppleBacklight.kext Info.plist, so it will always get Default without an injector kext.
It would be interesting to know if changing the display-id (in EDID like you have) changes which profile you get (FxxT vs. FxxP). Testing that would require an injector with the a104 in it (refer to my previous upload and modify accordingly).

Confirmed once again. I changed EDID in DSDT and Clover config to back to my previous one and again slider is there but no effect on brightness. I uploaded both configuration. Changing only DSDT and clover config fixes the issue. Only change in DSDT and clover config is EDID patch.

PS: What value can you suggest for display-id ? I have 1600x900 Intel300 as you see on my profile. I can try to patch it with values you suggest and report it back.
 

Attachments

  • Archive.zip
    1 MB · Views: 83
Confirmed once again. I changed EDID in DSDT and Clover config to back to my previous one and again slider is there but no effect on brightness. I uploaded both configuration. Changing only DSDT and clover config fixes the issue. Only change in DSDT and clover config is EDID patch.

PS: What value can you suggest for display-id ? I have 1600x900 Intel300 as you see on my profile. I can try to patch it with values you suggest and report it back.

Both of these ioreg files show injected EDID. Why?
My suggestion was to test with native EDID.

I think we have gotten off track here. The real question is to find out why FxxPxxxx is chosen instead of FxxTxxxx.
 
Last edited:
Both of these ioreg files show injected EDID. Why?
My suggestion was to test with native EDID.

Without injected edid my laptop doesn't boot. EDID is extracted from windows and linux and confirmed same. However with the patch I mentioned, it is working as in 10.12.3 I know it may sound strange but that is the way it is. Please comment on a value that I should change for product code(display id) maybe without kext we can force profile load.
 
Without injected edid my laptop doesn't boot. EDID is extracted from windows and linux and confirmed same. However with the patch I mentioned, it is working as in 10.12.3 I know it may sound strange but that is the way it is. Please comment on a value that I should change for product code(display id) maybe without kext we can force profile load.

Is your laptop using eDP instead of LVDS?
Supported display-ids can be seen in the Info.plist for AppleBacklight.kext. You should look at only those profiles that are FxxPxxxx. Keep in mind you'll need to change the _UID to match as well, depending on which one you want to try.
 
Back
Top