Contribute
Register

Fixing Brightness with Custom EDID

Joined
Jul 26, 2013
Messages
190
Motherboard
Sony VAIO VPCSA
CPU
i5-2430 2.40GHz/HM67
Graphics
Radeon HD 6630M / Intel HD 3000
Mac
iMac
Mobile Phone
iOS
As you probably know, Sierra 10.12.4 changed something which broke brightness settings for most people. Although RehabMan's solution works for most people, it doesn't work for people like me who must inject EDID by Custom EDID either with DSDT or Clover. As RehabMan points out, this is necessary for some laptops such as Fujitsu and Sony.

So if you are using Custom EDID for your current configuration, you must also inject Apple ProductID to your Custom EDID and follow RehabMan's guide afterwards.

- Save below script to `edidparser.rb`
- Open terminal and run `ruby edidparser.rb` from the folder that you saved this script file.
- Script will read your current EDID from the system and will print out patched ID for you. It will inform you for every step it makes.

Clover
===
If you are using Clover for Custom EDID, use the output of screen colored Green and paste it to Clover's config.plist/Graphics/EDID/Custom/

DSDT
===
If you are using DSDT to inject your custom EDID, find your EDID patch in your DSDT probably something with

AAPL00,override-no-edid or AAPL00,override-no-connect and change it with script result.

Script uses 0x9C7C as product ID which is a ID from MacBook Pro. If you want to change the product id, edit the script and change line 60 and 61.

After injecting productID with this way, you will have working brightness controls. However, if you don't follow RehabMan's guide, you will not get full brightness. Therefore you *MUST* follow his guide after you successfully injected product id to your custom EDID.

Ruby:
#!/usr/bin/ruby

  BLACK   = 30
  RED     = 31
  GREEN   = 32
  YELLOW  = 33
  BLUE    = 34
  MAGENTA = 35
  CYAN    = 36
  WHITE   = 37

def color(src,color=RED)
    src =  "\e[#{color}m" + src + "\e[0m"
end

bytes = []
if ARGV.count == 0
    puts color("Reading EDID from SYSTEM")
    begin
    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
  rescue Exception => bang
    puts "Can't Read EDID from SYSTEM. Make sure you have Rename GFX0 to IGPU patches applied."
    puts "Error Details: "
    puts bang
    puts bang.backtrace.join("\n")
    exit
  end
else
    puts color("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 : " + color(("%d bytes" % bytes.length),GREEN)
edid=bytes[8..20]
if edid[0] >> 7 != 0
   puts color("This EDID is corrupted")
else
   first = (edid[0] &  0b01111100) >> 2
   second = ((edid[0] &  0b00000011) << 3) + ((edid[1] &  0b11100000) >> 5)
   third = edid[1] &  0b00011111
  puts "=====Original EDID Data START======"
   puts "Manufacturer: " + color((first+64).chr + (second+64).chr + (third+64).chr)
   puts "Product Code:  " + color(("%02X%02X" % [edid[3], edid[2]]), BLUE)
   puts "Serial Number: " + color(("%d" % (edid[4] + (edid[5] << 8) + (edid[6] << 16) + (edid[7] << 24))), GREEN)
  puts "Week of Manufacture: " + color(("%d" % edid[8]),RED)
   puts "Year of Manufacture: " + color(("%d" % (edid[9] + 1990)),BLUE)
end

checksum = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts "Calculated checksum: " + color(("0x%x" % checksum),GREEN)
puts "Original checksum: "   + color(("0x%x" % bytes[127]),RED)
puts "=====Original EDID Data END======"

puts "=====Creating Fixed EDID====="

puts "Setting Manufacturer to " + color("APP",BLUE)
bytes[8] = 06
bytes[9] = 16

puts "Setting Product Code to " + color("9C7C",RED)
bytes[10] = 0x7C
bytes[11] = 0x9C

puts "Setting Serial to " + color("0",GREEN)
bytes[12] = 0
bytes[13] = 0
bytes[14] = 0
bytes[15] = 0

puts "Setting Week of Manufacture to " + color("10",BLUE)
bytes[16] = 10

puts "Setting Year of Manufacture to " + color("2012",RED)
bytes[17] = 22

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

bytes[127] = checksum
puts "Fixed EDID for Clover:" + color(("\n#{bytes.map{|b|"%02X"%b}.join}"),GREEN)
puts "Fixed EDID for DSDT: (Insert to Brightness Fix patch)"
byte_number = 0
line_size = 8
puts  color("\"AAPL00,override-no-edid\",")
puts color(( "Buffer "), MAGENTA) +  color(("(0x%2X)" % bytes.length),BLUE) + "\n{"

while byte_number < bytes.length

if (bytes.length - byte_number) >= line_size
    characters = bytes[byte_number..(byte_number+line_size-1)]
else
    characters = bytes[byte_number..bytes.length]
end
    puts color(("#{characters.map{|b|sprintf("0x%02X, ",b) }.join}"),BLUE)
    byte_number +=line_size
end
puts "}\n"
 
Last edited:
Joined
Sep 8, 2017
Messages
15
Motherboard
VAIO Fit 15E (Clover)
CPU
i5-4200U
Graphics
HD 4400, GT740M, 1366x768
Mobile Phone
Android, iOS
How do I "Save below script to `edidparser.rb". What is the script below?

Also, i can't find the EDID in mi System DSDT. Please help, i have all day trying to solve this :C

I have added my DSDT as a .dsl, it fails to save as .aml

EDIT: I think i got it. I found your file( https://github.com/tosbaha/Sony-SA-DSDT-Patches/tree/ea9487f8d95c6300eaf4e719f0a76a2ccbfc42a3) but when I try to open it this shows:
"
Cesars-iMac:Downloads cesar$ ruby edidparser.rb
Reading EDID from SYSTEM
Can't Read EDID from SYSTEM. Make sure you have Rename GFX0 to IGPU patches applied.
Error Details:
undefined method `[]' for nil:NilClass
edidparser.rb:21:in `<main>'
"

I belive i do have the patch that is asking me for:
Captura de pantalla 2018-03-09 a la(s) 21.16.59.png
 

Attachments

Last edited:
Joined
Sep 8, 2017
Messages
15
Motherboard
VAIO Fit 15E (Clover)
CPU
i5-4200U
Graphics
HD 4400, GT740M, 1366x768
Mobile Phone
Android, iOS
How do I "Save below script to `edidparser.rb". What is the script below?

Also, i can't find the EDID in mi System DSDT. Please help, i have all day trying to solve this :C

I have added my DSDT as a .dsl, it fails to save as .aml

EDIT: I think i got it. I found your file( https://github.com/tosbaha/Sony-SA-DSDT-Patches/tree/ea9487f8d95c6300eaf4e719f0a76a2ccbfc42a3) but when I try to open it this shows:
"
Cesars-iMac:Downloads cesar$ ruby edidparser.rb
Reading EDID from SYSTEM
Can't Read EDID from SYSTEM. Make sure you have Rename GFX0 to IGPU patches applied.
Error Details:
undefined method `[]' for nil:NilClass
edidparser.rb:21:in `<main>'
"

I belive i do have the patch that is asking me for:
View attachment 318296
UPDATE: I manage to fix it with out this patch even tho I also have a Sony XD. Feel free to erase my comments.
 
Last edited:

RehabMan

Moderator
Joined
May 3, 2012
Messages
192,055
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
UPDATE: I manage to fix it with out this patch even tho I also have a Sony XD. Feel free to erase my comments.
For the benefit of others with the same issue, you should explain what you did to fix your problem.
 
Joined
Sep 8, 2017
Messages
15
Motherboard
VAIO Fit 15E (Clover)
CPU
i5-4200U
Graphics
HD 4400, GT740M, 1366x768
Mobile Phone
Android, iOS

Attachments

RehabMan

Moderator
Joined
May 3, 2012
Messages
192,055
Motherboard
Intel DH67BL
CPU
Core i7-2600K
Graphics
Intel HD 3000
Mac
MacBook Air
Mobile Phone
iOS
I don't know why it worked synce my computer is a Sony VAIO too.
Not really surprising.
Different Sony models may use different screens/different backlight control methods.
 
Top