Create a gist now

Instantly share code, notes, and snippets.

A script to fix EDID problems on external monitors in Mac OS. Source: http://embdev.net/topic/284710

patch-edid.rb

A script to fix EDID problems on external monitors in Mac OS.

  1. Connect the problem monitor.

  2. Download this script into your /System/Library/Displays/Overrides (note: this file is only writeable by root, so some commands require sudo).

    cd /System/Library/Displays/Overrides
    sudo curl -O https://gist.github.com/ejdyksen/8302862/raw/patch-edid.rb
    
  3. Run the script we just downloaded (as root again). This creates a new display override plist.

    sudo ruby patch-edid.rb
    
  4. Disconnect and reconnect the monitor.

Source: http://embdev.net/topic/284710

#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
#
# Update 2013-06-24: added -w0 option to prevent truncated lines
require 'base64'
data=`ioreg -l -w0 -d0 -r -c AppleDisplay`
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
puts "Setting color support to RGB 4:4:4 only"
bytes[24] &= ~(0b11000)
puts "Number of extension blocks: #{bytes[126]}"
puts "removing extension block"
bytes = bytes[0..127]
bytes[126] = 0
bytes[127] = (0x100-(bytes[0..126].reduce(:+) % 256)) % 256
puts
puts "Recalculated checksum: 0x%x" % bytes[127]
puts "new EDID:\n#{bytes.map{|b|"%02X"%b}.join}"
Dir.mkdir("DisplayVendorID-%x" % vendorid) rescue nil
f = File.open("DisplayVendorID-%x/DisplayProductID-%x" % [vendorid, productid], 'w')
f.write '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">'
f.write "
<dict>
<key>DisplayProductName</key>
<string>Display with forced RGB mode (EDID override)</string>
<key>IODisplayEDID</key>
<data>#{Base64.encode64(bytes.pack('C*'))}</data>
<key>DisplayVendorID</key>
<integer>#{vendorid}</integer>
<key>DisplayProductID</key>
<integer>#{productid}</integer>
</dict>
</plist>"
f.close
@chiehchu

how about roll back?

@PrfsrX

Anybody?... Would also love a roll back :)

@unknownzerx

Will it work on El Capitan? With rootless...

@0x62ash

On El Capitan (disabled rootless) after patching I got acid colors.
So Im using apple default profiles for my Asus VX239 with terrible font smoothing :(

@mirfilip

No it won't work with El Capitan. /System/Library/Displays/Overrides doesn't exist and cannot be created or modified even by sudo.

I wonder if turning off SIP and adding this path to excluded paths in /System/Library/Sandbox/rootless.conf. Anyone tried that?

EDIT: Just turned off rootless, patch obviously still works as expected. Also, it's worth to new overrides path to excluded paths in rootless cfg.

@aocana

not works for my asus vx239
:-(

@serefacet

Not works for my asus vx239 too . I nearly try all kinds of these solutions , DELL and Samsung Monitors seems ok , but I have no solution on asus vx239. Any help is appreciated.

@nooks

Not work in Mac mini 2009 with VGA display

+-o AppleDisplay  <class AppleDisplay, id 0x1000048fa, registered, matched, active, busy 0 (0 ms), retain 8>
    {
      "IOClass" = "AppleDisplay"
      "CFBundleIdentifier" = "com.apple.iokit.IOGraphicsFamily"
      "IOProviderClass" = "IODisplayConnect"
      "DisplayProductID" = 1815
      "IOPowerManagement" = {"CapabilityFlags"=49152,"MaxPowerState"=3,"CurrentPowerState"=3}
      "IODisplayPrefsKey" = "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/IGPU@2/AppleIntelFramebuffer@1/display0/AppleDisplay-756e6b6e-717"
      "IODisplayParameters" = {"bgsc"={"min"=0,"max"=65536,"value"=65536},"pscn"={"min"=8800,"max"=10000,"value"=10000},"rgsc"={"min"=0,"max"=65536,"value"=65536},"cmod"={"min"=0,"max"=4096,"value"=1},"ggsc"={"min"=0,"max"=65536,"value"=65536},"cyuv"={"min"=0,"max"=268435456,"value"=268435456},"vblm"={"min"=0,"max"=196608,"value"=65536},"gsc "={"min"=0,"max"=65536,"value"=65536},"colr"={"min"=0,"max"=18446744073709551615,"value"=257}}
      "IOProbeScore" = 2000
      "IOMatchCategory" = "IODefaultMatchCategory"
      "IODisplayConnectFlags" = <00000000>
      "DisplayVendorID" = 1970170734
      "DisplaySerialNumber" = 0
    }
@maurei

Maybe you want to update this topic with the following relevant information:

  1. In El Capitan
    /System/Library/Displays/Overrides
    is now located at
    /System/Library/Displays/Contents/Resources/Overrides

  2. Even with sudo, any write operations will not be permitted. To fix this, reboot in recovery mode (cmd+r during reboot), under utils, open up the terminal. Do csrutil disable. Reboot, and run the script in the relocated folder.

@martystack

Thanks Maurei for the update.

And if ANYONE is interested in why it doesn't work in OSX El Captain, it is because...

OS X 10.11 « El Capitan » introduces a feature called « System Integrity Protection », aka « SIP » or « rootless » . A lot has been said about this feature on several information media.

Because of this SwitchResX isn't working without overriding the SIP- Maurei explained the work around.

You can read more on this issue here:
http://www.madrau.com/support/support/srx_1011.html

@oliviergilloire

Hi

OS X El Capitan, did all of the above (csrutil disable, root enabled) but the ruby patch-edid.rb just doesn't output anything (no error message, no output on terminal...)

macpro:Overrides root# ruby patch-edid.rb
macpro:Overrides root#
No command line output whatsoever?

The command "ioreg -l -w0 -d0 -r -c AppleDisplay" properly works though and outputs the below:

+-o AppleDisplay
{
"IOClass" = "AppleDisplay"
"CFBundleIdentifier" = "com.apple.iokit.IOGraphicsFamily"
"IOProviderClass" = "IODisplayConnect"
"DisplayProductID" = 16540
"IODisplayEDID" = <00ffffffffffff0090ac9c404c37303231170104b5351e783a1df5ae4f35b3250d5054000000010101010101010101010101010101014dd000a0f0703e80302035000f282100001a000000ff0030303030303030303030303030000000fc0044454c4c20555032343134510a000000fd001d4b1f8c36000a20202020202000cc>
"IODisplayPrefsKey" = "IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/GFXB@3/IOPP/GFX2@0/ATY,KaniS@5/AMDFramebufferSI/display0/AppleDisplay-90ac-409c"
"IOPowerManagement" = {"CapabilityFlags"=49152,"MaxPowerState"=3,"CurrentPowerState"=3}
"IOProbeScore" = 2000
"IODisplayParameters" = {"bgsc"={"min"=0,"max"=65536,"value"=65536},"pscn"={"min"=10000,"max"=10000,"value"=10000},"rgsc"={"min"=0,"max"=65536,"value"=65536},"thrm"={"min"=0,"max"=120,"value"=51},"cmod"={"min"=0,"max"=4096,"value"=1},"ggsc"={"min"=0,"max"=65536,"value"=65536},"cyuv"={"min"=0,"max"=268435456,"value"=268435456},"dith"={"min"=0,"max"=1,"value"=0},"vblm"={"min"=0,"max"=196608,"value"=65536},"gsc "={"min"=0,"max"=65536,"value"=65536},"colr"={"min"=0,"max"=268439825,"value"=268439553}}
"IOMatchCategory" = "IODefaultMatchCategory"
"AppleDisplayType" = 2
"IODisplayAttributes" = {"IODisplayAttributes"=<676174760000000073676c6600000000726c6f630100000063706220040000006364670080808000676c666400000000>}
"AppleSense" = 37119
"IODisplayConnectFlags" =
"DisplayVendorID" = 37036
"DisplaySerialNumber" = 842020684
}

What could be wrong here?

@donald-jackson

May I ask potentially a different question? I have an external GPU with HDMI 2.0 which works running YCBR 4:4:4 when in Bootcamp but I can't seem to force it to do so in OS X. How can I modify this script to force the only mode available to YCBR 4:4:4 (rather than RGB) as this is in fact a TV. Attached is what I currently get (no custom resolutions, only the HDMI pixel clock patch).
screenshot 2016-03-01 09 28 34

@ojczeo

Awesome, thanks for sharing!

@cheynewallace

Twice now, this script has saved me from basically having to throw away a monitor. After a recent upgrade to El Capitan I thought It was all over, thanks also to @maurei for the info regarding the new file location. Never would of found that

@davidbdeath

Is there a way to use this to force 10Bit? My display supports it but even after running the patch my Mac doesn't.

@A1ex5andr

Made my day for second time now ))
Though it took a while for me to make it work on a same MBP 13 but with a new monitor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment