Thursday, June 07, 2012

EDID

This post is about Extended Display Identification Data.
It's the information your monitor or TV sends to your PC or media player to let it know what video/audio formats are supported. Most of the time it's correct and everything works like you want it to. There are several reasons to modify or override the EDID data coming from your TV/monitor via the DDC2B protocol (I2C address 0x50 and 0x30).
  • Get higher refreshrates than 60Hz.
  • Solve ghosting or other quirks in 3D interlaced/checkerboard mode.
  • Tell attached equipment to pass DTS audio. Your TV often does not know that your audio receiver can handle DTS.
First, some fiddling with OSX to retrieve EDID data from attached display:


IORegistryExplorer
ioreg -l | grep -5 IODisplayEDID
IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/P0P2@1/IOPCI2PCIBridge/GFX0@0/ATY,Cattail@1/ATIFramebufferNI/display0/AppleDisplay

Returns some long number...
00ffffffffffff001e6d01000101010101150103801009780aee91a3544c99260f5054a10800714f8180010101010101010101010101023a801871382d40582c4500a05a0000001e1b2150a051001e3048883500a05a0000001c000000fd003a3e1e5310000a202020202020000000fc004c472054560a2020202020202001e2020337f14e101f8413051403021220212215012615075009570778030c001000b82d20c00e01400a3c08101810981058103810e3050301011d8018711c1620582c2500a05a0000009e011d007251d01e206e285500a05a0000001e023a801871382d40582c4500a05a0000001e00000000000000000000000000000000000031

Save that to EDID.txt or something and look at the details with edid-decode.
cat EDID.txt | xxd -r -p | ./edid-decode

Now we want to tinker with it! There are some options to do that.

Phoenix EDID Designer (Windows, yuck)This program accepts only files in a special format, so we need to convert it somehow.

cat EDID.txt | xxd -r -p | (echo 'EDID BYTES:';\
echo '0x   00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F';\
echo '    ------------------------------------------------';\
xxd -g 1 -c 16 | sed -E 's/00000(..): (.{47}).*/\1 | \2/g'\
) | tr abcdef ABCEDF | sed 's/$'"/`printf '\r'`/g" > conv.dat

Compare the exported raw data with original:
cat EDID.txt | xxd -r -p | ./edid-decode > left.txt
cat exported.raw | ./edid-decode > right.txt
diff left.txt right.txt

The new data will show:
EDID block does NOT conform to EDID 1.3!
Missing monitor ranges
That's too bad!

010 Editor

I made a template file for 010 Editor, which is a nifty binary editor.
Download the template here.
Somehow they did not put the CRC fixing script (.1sc extension) there, but it's quite short:

file.checksum = -Checksum(CHECKSUM_SUM8, startof(file), startof(file.checksum) - startof(file));
local int i;
for (i=0; exists(file.extensions[i]); i++) file.extensions[i].checksum = -Checksum(CHECKSUM_SUM8, startof(file.extensions[i]), 127);



That's pretty neat uh?

Create EDID override file for OS X (method 1)

Assuming you have saved the modified exported.raw, generate a hex dump like so:


xxd -ps exported.raw

Create a plist file (without extension) and open with XCode or Property List Editor.
/System/Library/Displays/Overrides/DisplayVendorID-1e6d/DisplayProductID-1
The VID/PID in the directory/filename are in unpadded lowercase hexadecimal format.

DisplayProductName String "My modified display name"
DisplayProductID Number 1 (displayed in decimal)
DisplayVendorID Number 7789 (displayed in decimal)
IODisplayEDID Data <00ffffff...> (paste the data between brackets)

Create EDID override file for OS X (method 2)

Paste the result of
(echo -n '<data>'; (cat exported.raw | base64 | tr -d '\n'); echo '</data>')
into the override file (see method 1) where you can use the following as a base:

<?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>1</integer>
    <key>DisplayProductName</key>
    <string>My modified display name</string>
    <key>DisplayVendorID</key>
    <integer>7789</integer>
    <key>IODisplayEDID</key>
    <data>AP///////wAdbgEAAQEBAQEVAQOAEAl4Ct2Ro1RMmSYPUFShCABxT4GAAQEBAQEBAQEBAQEBAjqAGHE4LkBYLEUAoFoAAAAdAjqAGHE4LkBYLEUAoFoAAAA8AAAAEAA6PR1TEAAKICAgICAgAAAAEABMRyBUVgogICAgICAgAco=</data>
</dict>
</plist>

todo...

Somehow, the resolution went back to 960x540 (HiDPI) whenever I change the EDID and replug my video connector.
Also, I have to find out how to reprogram my LG TV with new EDID data. There is some option in the service menu, but haven't looked how to do it yet.
It's nice that I can override EDID data in OS X, but I cannot override it on my PS3 for example. Thus, I need the optical audio output if I want DTS.

Links:
Video timing calculator
EDID 1.3 data format