Contribute
Register

[Guide] Laptop backlight control using AppleBacklightFixup.kext

Yes. I don't know maybe you read it before I edited it. My last paragraph on that post "Another confirmation: ...." mentions that everything is working as it should. My only concern is maybe color is little bit washed out. I am not so sure. But besides color everything is working as in 10.12.3

So... for the "working as it should" configuration, attach "Problem Reporting" files.
Also attach native EDID, so we can see clearly what you changed in EDID.

With a clear idea of what your solution is, we may be able to come up with a generic solution, or at least add some relevant instructions to post #1.
 
Last edited:
You likely forgot to install "RC scripts" when you installed Clover.
It is important for working NVRAM when using EmuVariableUefi-64.efi.
No, I did not forget to install scripts.
Nvram.plist updates on every shutdown. Sierra is ignoring the information.
 
No, I did not forget to install scripts.
Nvram.plist updates on every shutdown. Sierra is ignoring the information.

NVRAM debugging is off-topic.
But you might have old data in native NVRAM...
Your version of Clover could also have bugged NVRAM implementation.
You should check your Clover bootlog.
Open a separate topic if you wish to discuss NVRAM issues.
 
I found partial solution. It is working but not with full brightness. As you guessed, it is related to EDID. I used your patches and vanilla AppleBacklight

I patched my EDID and changed below values and fixed its checksum with the help of a app named FixEDID.

Manufacturer name: APP
Model: A014
Serial Number: 0
Build Week : 10
Buid Year: 2012

Even though brightness was not the highest, sliders and function keys worked to increase and decrease the brightness. I think EDID maybe holds the key. For a reference, My old EDID had below values

Manufacturer name: SNY
Model: 6FA
Serial Number: D
Build Week : <EMPTY>
Buid Year: <EMPTY>

Another confirmation: I deleted your kext, .aml file and just changed EDID with above values, fixed checksum and everything is working as before. I am 100% sure now that EDID has an important role for this. I attached one python file for anybody who wants to change EDID file and calculate checksum. I think maybe clover can do this otherwise it will be very hard to maintain.
Do you mind elaborating on the EDID patches? How do you patch EDID?
 
I have brightness keys working now with this solution, but brightness level is alway full after power on.
Nvram.plist have backlight-level data stored. Don´t know why it is not loaded.

same here on my xps 13 9350
 
So... for the "working as it should" configuration, attach "Problem Reporting" files.
Also attach native EDID, so we can see clearly what you changed in EDID.

With a clear idea of what your solution is, we may be able to come up with a generic solution, or at least add some relevant instructions to post #1.


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/
 
Last edited:
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/
I injected your EDID and boom *black screen*, guess it's not a generic solution.
 
I injected your EDID and boom *black screen*, guess it's not a generic solution.
Just change model part from 8-20. Then calculate checksum and fix last byte.
 
Back
Top