Skip to content

Instantly share code, notes, and snippets.

@tubaterry
Created May 7, 2020 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tubaterry/07708b7c6f4640b0ef5d5c9239fbda9a to your computer and use it in GitHub Desktop.
Save tubaterry/07708b7c6f4640b0ef5d5c9239fbda9a to your computer and use it in GitHub Desktop.
ROG PG27UQ with YUV modes edited out of the EDID
<?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">
<dict>
<key>DisplayProductID</key>
<integer>10144</integer>
<key>DisplayProductName</key>
<string>ROG PG27U</string>
<key>DisplayVendorID</key>
<integer>1715</integer>
<key>IODisplayEDID</key>
<data>
AP///////wAGs6AnU4kAACUdAQOAPCJ4Ipuxr04ztSYLUFQhCAABAQEBAQEBAQEBAQEB
AQEBCOgAMPJwWoCwWIoAVlAhAAAeAAAA/wAjQVNNVjFCbmFFYkhkAAAA/QAYPB6HPAEK
ICAgICAgAAAA/ABST0cgUEcyN1UKICAgASsCAz3BTBAfBBMDEgFdXl9gYSMJBwGDAQAA
bQMMABAAMHggEGADAgFn2F3EAXiAAOMFwADiAGrmBgUBj3cDAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
sA==
</data>
<key>DisplayIsTV</key>
<false/>
<key>SwitchResX backuped settings</key>
<dict>
<key>DisplayProductID</key>
<integer>10144</integer>
<key>DisplayVendorID</key>
<integer>1715</integer>
</dict>
<key>dspc</key>
<array>
<data>
OtAAoPBwPoAwIDUAAAAAAAAa
</data>
</array>
<key>trng</key>
<data>
OPqp5P5/AAAA2PZr/38AAHD5qeT+fwAAimcXCwEAAAB9BUgAAAAAAABGwyMAAAAALwBm
AHIALgBtAGEAZAByABgAAAB4AAAAMHUAAFgPAgBoAHIAZQBzAHgALgBhAHAAcAAtADYA
MQAwADUANQA4ADAAOAAxADYAOQAwAC4AcABsAGkAcwB0AHQAgTX/fwAAZgByAC4AbQBh
AGQAcgBhAHUALgBzAHcAaQB0AGMAaAByAGUAcwB4AC4AYQBwAHAALQA2ADEAMAA1ADUA
OAAwADgAMQA2ADkAMAAuAHAAbABpAHMAdAAAAM2HgTX/fwAAAAAAAAAANECANBwDAGAA
ABtVOnf/fwAA8Le6AABgAACw+Knk/n8AAFwAAAAAAAAAcwDStKAXdcoA4TyL/38AAPC3
ugAAYAAA
</data>
</dict>
</plist>
@tubaterry
Copy link
Author

How to trick MacOS Catalina into stop using YUV (YUV444, YUV222, YUV420?) colorspaces on your fancy new monitor and stick with RGB, because there's no way to pick and I guess they assume you're a video editor?

Purpose:

To stop getting headaches from blurry text.

Non-pissbaby purpose: Get 4k @ 60Hz working on the ASUS ROG PG27UQ, and get MacOS to use RGB colorspace instead of YUV4:4:4

Original references:

https://www.mathewinkson.com/2013/03/force-rgb-mode-in-mac-os-x-to-fix-the-picture-quality-of-an-external-monitor

https://spin.atomicobject.com/2018/08/24/macbook-pro-external-monitor-display-problem/

The ruby script (and others based off it) make some assumptions that don't work for this monitor, so they mangle the shit out of the EDID, preventing you from using the thing. Also none of the instructions tell you what's happening.

Fun info:

Apple has a series of Override files for a bunch of displays that don't quite work as intended when left as defaults. (Either bad EDID info or no EDID info, usually)

You can semi-easily create your own.

Instructions:

Use SwitchResX to get this monitor set up initially, then copy this gist to
/System/Library/Displays/Contents/Resources/Overrides/DisplayVendorID-6b3/DisplayYearManufacture-2019-DisplayWeekManufacture-37

(SwitchResX not strictly necessary, it's just the easiest way to set up custom resolutions)

This sets up a display override file for the monitor in question. You can do it manually:

  • ioreg -lw0 | grep IODisplayPrefsKey will spit out some display IDs. You're looking for the last section: "AppleDisplay-[someID]-[someID]". If you've got one display this is easy (or in my case I've got two refurb HPs so it's just a process of elimination for the ASUS monitor lol
  • Down below, I use my own monitor as the example, but based on the IODisplayPrefsKey, your filename will look something like:
  • /System/Library/Displays/Contents/REsources/Overrides/DisplayVendorID-[first ID from above]/DisplayProductID-[second ID value from above]

( Your own DisplayProductID-XXXX override plist needs only the following keys: DisplayProductID, DisplayVendorID, and IODisplayEDID )

To edit the EDID:

  • Use the EDID wiki entry for reference https://en.wikipedia.org/wiki/Extended_Display_Identification_Data
  • We're looking for references to colorspaces
    ** We want to remove the YCrCb capabilities from the standard EDID Header - Byte 24, bits 4 and 3.
    ** "4:4:4 in deep color modes" is another one, Byte 6, bit 3 of the HDMI Vendor Specific Data Block
    *** This is potentially in a variable location, but it's not far after 03 0C 00 (little-endian bytes)
  • base64 decode the IODisplayEDID data into a hex editor (pbpaste | base64 -d | pbcopy then open Hex Fiend and paste lol)
  • Use http://www.edidreader.com/ to verify there are no active YUV 4:4:4 or 4:2:2 references (uncheck add hex prefix)
  • As the wiki entry says, there are two checksums you'll have to compute. Throw this into a bash file:
string_to_checksum="00 11 22 33"
for current_byte in $string_to_checksum; do
    current_dec_val=`hextodec $current_byte`
    let total=$total+$current_dec_val
  done
  echo $total
  echo "$total % 256" | bc
  echo "obase=16;ibase=10;$total % 256" | bc
  • string_to_checksum is two strings: bytes 0 through 127 and 128 through 255

  • paste the first half into string_to_checksum

  • fuck with the last byte until the last output is 0 (A valid EDID checksum is sum of all 128 bytes % 256 == 0)

  • repeat for the second half

  • Throw the results into the EDID Reader web app until you get valid checksums in both the Header Information and Extension Header Information sections.

  • Once your checksums are good, paste the full 256-byte EDID thing back into Hex Fiend and save as a file.

  • cat edid_hex | base64 | pbcopy

  • paste that shit back into the IODisplayEDID section, replacing what's there. The differences should be minor and it should stay the same length. (cuz you only changed like 3-5 bytes from the original)

  • Remount root rw with sudo mount -uw /

  • Copy this file to sudo cp DisplayYearManufacture-2019-DisplayWeekManufacture-37 /System/Library/Displays/Contents/Resources/Overrides/DisplayVendorID-6b3/DisplayYearManufacture-2019-DisplayWeekManufacture-37

  • Reboot

Notes:

  • I wanna be clever and clean this up more but this is annoying enough already

Additional Modeline notes for PG27UQ in 4k@60hz if it gets lost:

PowerStrip timing parameters:
3840x2160=3840,48,32,80,2160,3,5,54,533063,5

Generic timing details for 3840x2160:
HFP=48 HSW=32 HBP=80 kHz=133 VFP=3 VSW=5 VBP=54 Hz=59

VESA detailed timing details:
PClk=533.06 H.Active=3840 H.Blank=160 H.Offset=32 HSW=32 V.Active=2160 V.Blank=62 V.Offset=3 VSW=5

# XFree86 modeline parameters:
Modeline "3840x2160" 533.062 3840 3888 3920 4000 2160 2163 2168 2222 +hsync -vsync

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