XO 4 HDMI Debug

From OLPC
Revision as of 05:08, 4 December 2012 by Wad (talk | contribs) (→‎Video Init)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Some notes for testing the HDMI Interface of the XO-4 laptop.

Setup

If you have access to Q7B05 or later, you can install it on the test laptop and avoid the older setup which required Linux involvement to setup HDMI.

Older Setup

Start with an XO-4 laptop running the latest firmware ( Q7B04 ). It should have a second serial port connected. You will want to download the following two pieces of software and place them on a USB stick:

Install the zImage file as /boot/vmlinuz using the following OFW command:

ok copy u:\zImhdmi int:\boot\vmlinuz

Type y when it asks if it is OK to overwrite the existing file.

Boot Linux. Then mount the USB key and install hdmi_ctl into the local directory:

mount /dev/sda1 /mnt
cp /mnt/hdmi_ctl .
chmod a+x hdmi_ctl

Video Init

If using OFW q7b05 or later, you can initialize the HDMI output using one of the following three commands:

ok> 720p
ok> 1080p
ok> d# 640 d# 480 " start-hdmi" $call-screen

A list of the supported resolutions is available in the OFW source code.

Using Linux

At this point, you can initialize HDMI output from within Linux:

./hdmi_ctl

When this starts, you can set video output at a particular resolution using:

>> sv 14

That will select 720p on your HDMI monitor. "sv 24" will get you 1080p, "sv 25" will get 640x480.

Patching CForth

In order to manipulate the video parameters in real time, we use a second serial port connected to CForth running on the security processor. It must be enabled by holding down the "rotate" key while booting. Then start ofw using the command:

ok dbg ofw

The following forth commands need to be downloaded (over the second serial port):

: w1 20b000 + io! ;  : r1 20b000 + io@ ;
: video-on 104 r1 44 w1  fc r1 3c w1  f4 r1 34 w1  80 r1 100 or 80 w1  ;
alias v video-on
: +hdmi  20bc00 +  ;
: hdmi!  +hdmi io!  ;
: hdmi@  +hdmi io@  ;
: hdmi-i!  ( b reg# -- )  swap  0 hdmi!  h# 8000.0000 or 4 hdmi!  ;
: hdmi-i@  ( reg# -- b )  h# 4000.0000 or 4 hdmi!  0 hdmi@  ;
alias r hdmi@  alias w hdmi!   alias ii hdmi-i!   alias ir hdmi-i@
: access-phy  h# 20 hdmi@  1 or  h# 20 hdmi!  ;
alias phy access-phy
: access-3d  h# 20 hdmi@  1 invert and  h# 20 hdmi!  ;
alias 3d access-3d

And these allow for easier manipulation of the PHY0 and PHY1 registers:

6 value damp  5 value eamp  2 value cp
: phy0
   damp o# 1111 *
   eamp o# 11110000 * or
   cp h# 55000000 * or
   8 w
; 
0 value ajd  1 value svtx  9 value idrv  
: phy1
   ajd  h# f0000000 *
   svtx o# 1111 * d# 16 lshift  or
   idrv h# 1111 *  or
   h# c w
;

These will need to be downloaded again after turning the laptop off.

You can use these patches to manipulate the PHY registers by typing:

phy phy0 phy1

Display some video using

v

Changing PHY Settings

You must rerun CForth register settings after using hdmi_ctl, 720p, or 1080p. After changing the resolution with hdmi_ctl, you must re-run:

phy phy0 phy1

In order to change a value, change the associated variable and then re-write the related register. To change DAMP to 3:

3 to damp phy0

To change IDRV to 4:

4 to idrv phy1

Note: There is hysteresis in the PHY circuit. Once you pass a certain threshold, you can't return simply by reducing the value. If you are close to a critical point, increasing a parameter by 1 may result in a change such that then reducing that parameter by 1 doesn't restore us to the same output. In many cases, the parameter must be reduced by 3 then increased by 2 o restore the same output.

Docs