Wednesday, April 15, 2015

Subtle defect with Raspberry Pi NTSC video output

I've known about this Raspberry Pi NTSC defect for a long time.  The reason I haven't reported it is because I have been too lazy to provide a way to reproduce the defect.  Unfortunately, reproducing the defect requires an oscilloscope but otherwise it is something most anyone should be able to do.

Tools used to reproduce defect:
- LM1881
- Rigol DS1054Z oscilloscope
- Raspberry Pi B+ with Raspbian dated 2015-02-16
- A specially crafted PNG file
- The 'fbi' program

First, let's talk about why I am using an LM1881.  I am using it as a trigger for the scope so that I can get a consistent stable view of the problem.  To make sure everyone is on the same page, here is a part of the datasheet that defines the "field" pin:

So when the field pin is high, an "odd" field is starting, when the field pin is low, an "even" field is starting.  Also, in NTSC land, odd means the top field and even means the bottom field.  This is kind of backward from how computer science geeks think of things, because we think that the first item in a list is 0 which is an even number.  But in NTSC land, the first line is 1, not 0.  For this reason, I will refer to the fields as odd/top and even/bottom to avoid confusion.

Here is the specially crafted PNG file that I made.  It is almost black except for the top 3 and bottom 3 lines:

The resolution is 640x480, the 480 part being the crucial part here to match NTSC's 480 lines.
The top and bottom lines are solid white.  The second and second to last lines are grey (7f7f7f) and the third and third to last lines are solid white but only go halfway across the screen.  I chose these lines so they could be easily identified on a scope.

To reproduce the problem, I booted the raspberry pi in NTSC mode (with a TV plugged in so I could see).  I then ran the command "fbi rpi_ntsc_test.png" and pressed 'V' to disable the status bar once the image was displayed.  I then hooked one scope probe up to the NTSC signal and the other scope probe up to the "field" (odd/even) pin of the LM1881.

Here are the results with comments:

Conclusion: At the very least, the fields are currently being reversed in this iteration of raspbian and the pi (B+).  There may be additional problems since the first visible line according to NTSC does not line up with what the Pi is doing (see my notes in the PNG files).

In the past, I observed potentially different issues on earlier revs of the pi which are not important to note anymore.

No comments:

Post a Comment