Skip to content

Instantly share code, notes, and snippets.

@BugRoger
Created May 5, 2013 10:57
Show Gist options
  • Save BugRoger/5520488 to your computer and use it in GitHub Desktop.
Save BugRoger/5520488 to your computer and use it in GitHub Desktop.
Patch and Overwrite Display Settings. Let's Dell Monitors be recognized as RGB mode displays instead of TVs... -.-
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
puts 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
@Dochartaigh
Copy link

Hi. I have this same / similar issue on my Apple / Mac, that when in HDR mode my HDR-compatible external monitor tinges everything a dull, muted, gray color. Whites are especially noticeable - they're simply not white, they're grey. Turn HDR off and everything is PERFECT again (you know, besides not being able to watch HDR content...). Also, guess what? Booting my Mac to Windows/Boot Camp on the SAME COMPUTER (same cables/screen, everything) and the issue is FIXED - this is solely a macOS issue, seemingly going ALL the way back to Catalina...

YOU HAVE TO REPORT THIS TO APPLE FOR THEM TO FIX IT. Apple support, and their engineering teams have NO RECORD OF THIS ISSUE!!! You have to contact them through their support chat or a phone call (posting here does nothing tbh). FYI, Apple support told me you can start an Official Apple Support ticket even if your computer isn't in the 1-year warranty, or 3-year AppleCare period (just as long as you're using their newest OS, Ventura). I found this all out today since this problem persists on my brand new Mac mini M2 Pro, and when I contacted them they told me all the above (and also told me it was a good idea to post to everybody on the Apple forums and tell them to report this so it gets on their radar, and hopefully gets fixed!!!).

For my particular case, I've tried TWO HDR-compatible Macs (2018 MacBook Pro 15", 2023 Mac mini M2 Pro). Multiple HDMI 2.0 and HDMI 2.1 CERTIFIED HDMI cables. Multiple monitors / 4K TV's (three different brands) and the problem persists... and when Windows 10 is fine on the (Intel based Mac I tested at least) it's a fact it's NOT the hardware, it's a macOS issue. Other articles surmise that the 'Mac outputs incorrect YPbPr colour', since when you manually (though a programming-esque type GitHub-documented process) change it to output RGB the problem is fixed...

Anyway, with my support ticket to Apple they wanted a video or screenshot of this issue... which it's nearly impossible to capture this on video since my iPhone auto-white balances and/or increases brightness for a darker image (so I can't capture just how much darker the HDR image is to the naked eye, and how all my whites are now gray with HDR turned on)... so I literally took my professional X-Rite Colorimeter and took readings with HCFR display calibration software to show them (all live on video) the very large difference between HDR enabled, and disabled. Literally proved that HDR (in the macOS itself) is HALF as bright as SDR... when it should be the complete opposite... I'll report back if there is a fix... but I'm not hopeful... this has been reported THOUSANDS of times all over the net since Catalina in 2019 and it's still not fixed... and somehow Apple says they've never even heard of this issue... (and Apple won't even let me give them links to non-apple websites to show all these people with this same issue... even the sites where they developed a possible fix for it...).

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