Showing posts with label OSX. Show all posts
Showing posts with label OSX. Show all posts

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

Sunday, January 02, 2011

Snow Leopard theme for Windows 7 (by sagorpirbd)

Download and installation instructions here: Snow Leopard for Windows 7 theme by sagorpirbd
If you run into problems with the free-activator (just click the advertisement) or just want to see what's in there beforehand, you can extract the files yourself.
Extract "Snow Leopard for Win7 Setup.exe" using a RAR-extractor. The password is snhgqzsdhbktin7
Here's a batch file (put in "System Files") to help replacing the system files:

@echo off
SETLOCAL ENABLEEXTENSIONS
if exist backup goto :SKIPBACKUP

:BACKUP
mkdir backup
copy "%windir%\Explorer.exe" backup
copy "%windir%\System32\Shell32.dll" backup
copy "%windir%\System32\ExplorerFrame.dll" backup
copy "%windir%\System32\OobeFldr.dll" backup
pause

:SKIPBACKUP
call :REPLACE "explorer\64 BIT\explorer.exe" "%windir%\Explorer.exe"
call :REPLACE "shell32.dll\64 BIT\shell32.dll" "%windir%\System32\Shell32.dll"
call :REPLACE "ExplorerFrame.dll\64 BIT\ExplorerFrame.dll" "%windir%\System32\ExplorerFrame.dll"
call :REPLACE "Welcome Center\64 BIT\OobeFldr.dll" "%windir%\System32\OobeFldr.dll"
pause
goto :EOF

:REPLACE
echo --- From %~1 to %~2 ---
if not exist "%~1" goto :ERROR
takeown /F "%~2"
Icacls "%~2" /grant Administrators:F
rename "%~2" "%~nx2.old"
copy "%~1" "%~2"
sleep 5
fc /B "%~1" "%~2" || echo ------------- %~2 mismatch ---------------
exit /B

:ERROR
echo Could not find source file!
pause 

There is also a program called "leftsider" which puts the control icons of a window on the left side, just like on a real Mac.

Tuesday, July 20, 2010

Static ARP script for OSX

For security reasons, you may wish to set a static ARP entry for your gateway. This script automates this step. Note that this doesn't prevent DHCP or MAC spoofing however.
The script runs whenever a network connection is made or broken by using the launchd feature to check a path for changes. In this case, I used resolv.conf.
The scripts determines the default gateway IP address and then keep trying to find the corresponding MAC address in the ARP table. Then it sets up the static ARP entry.
Two files are needed: one launchd configuration file and a shell script file. You need to give execute rights on the shell script with chmod +x. Copy the files in place and rename/edit the filenames. You need to restart to make the configuration active.

The contents of /Users/darkfader/static-arp.sh:

#!/bin/bash
# if the resolv.conf file was deleted, create an empty one to enable file watch again
touch /var/run/resolv.conf
while true; do
        IP=$(netstat -rn | grep -m 1 default | tr -s ' ' | cut -d' ' -f 2)
        if [ "$IP" == "" ]; then
                exit 0
        fi
        MAC=$(arp -an | grep -m 1 $IP | tr -s ' ' | cut -d' ' -f 4)
        if [ "$MAC" == "" ]; then
                sleep 1
                continue
        fi
        arp -S $IP $MAC
        exit 0
done

The contents of /Library/LaunchDaemons/net.darkfader.static-arp.plist:

<?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>Label</key>
        <string>net.darkfader.static-arp</string>
        <key>ProgramArguments</key>
        <array>
                <string>/Users/darkfader/static-arp.sh</string>
        </array>
        <key>QueueDirectories</key>
        <array/>
        <key>WatchPaths</key>
        <array>
                <string>/var/run/resolv.conf</string>
        </array>
</dict>
</plist>