Wednesday, August 27, 2008

Wednesday

Put some instructions up for people wanting to try out the Pinnacle driver work without having to wait for the commit (see previous post).

More Kaffeine4 work tonight. Sent Christoph the info he asked for to debug the errors I saw with ATSC scanning. Then I just went ahead and isolated the problem and submitted a patch (the code wasn't checking the Transport Error Indicator field).

Also got a better understanding how the parser works. It turns up it looks like crap because it's generated output based on an XML file. A banner at the top of the file making clear it was generated source could have avoided some confusion.

Started looking at how to get the Extended Channel name working, and sent a request to get some additional files checked in that are missing from source control.

Pinnacle 801e support for those who can't wait for the merge

Update (11-08-2008): Please DO NOT FOLLOW THE STEPS HERE. The changes have been merged into the v4l-dvb codebase (including the fix for the thermal bug). Please go to this site for updated instructions:

http://www.linuxtv.org/wiki/index.php/Pinnacle_PCTV_HD_Pro_Stick_(801e)

Thanks,

Devin
====

I got a couple of comments from people who would like to try out the new Pinnacle PCTV HD 801e support. The changes basically fall into two categories:

* Fixes for the dib0700 i2c code so the xc5000 works
* A device profile for the Pinnacle 801e

The dib0700 i2c fixes affect all devices, so a patch providing these fixes has been sent out for review. Because we don't want to break any existing devices, we couldn't just check it all in. Once those are verified by other maintainers, the plan is to then check in the 801e support.

For those of you who "just want it to work and don't want to wait" for it to be merged, you can get your device to work by downloading the following patch and applying it to the latest v4l-dvb hg.

Here's what you have to do. This assumes you have at some point you have built the v4l-dvb codebase and are confident that you have the kernel headers installed and the other v4l-dvb build prerequisites have been met.

hg clone http://linuxtv.org/hg/v4l-dvb
cd v4l-dvb
wget http://devinheitmueller.com/801e/pinnacle_801e_support.patch
patch -p1 < pinnacle_801e_support.patch
make
wget http://devinheitmueller.com/801e/dvb-usb-dib0700-1.20.fw
wget http://www.steventoth.net/linux/xc5000/HVR-12x0-14x0-17x0_1_25_25271_WHQL.zip
wget http://www.steventoth.net/linux/xc5000/extract.sh
sh extract.sh
make install
cp dvb-fe-xc5000-1.1.fw /lib/firmware
cp dvb-usb-dib0700-1.20.fw /lib/firmware

Then reboot. These instructions were tested on Ubuntu 8.04, building as root. If you're not comfortable with that, run the last three commands with "sudo" in front of them.

If the above steps look too complicated, wait a week or two and it will hopefully be in the main repository by then.

Now for the disclaimers:

  • No guarantees or warranties that the code will work
  • Don't hold me responsible if your PC, Pinnacle tuner, our house catch on fire.
  • This is not a final patch, and the i2c code in particular could potentially interfere with other dib0700 devices (if you have any)
  • There is no analog support yet.
  • Tuning is a little slower than I would like (less than one second but still...). I'm working on this.

Have fun. If you have problems, feel free to comment on this post.

Also, I would be interested to know if the Pinnacle PCTV USB that is not the "Pro" edition also has an 801e USB ID (since I'm using the "Pro"). If any of you have one, let me know.

Tuesday, August 26, 2008

Kaffeine for KDE4

The author of the KDE4 port for Kaffeine asked me to do some testing on the ATSC scanning support (they don't use ATSC in Europe). While it took me a couple of weeks to find the cycles, I finally got KDE4 and the dev environment setup, I built the new version of Kaffeine from source, and what do I find?

My entire ATSC PSIP and scanning implementation from Kaffeine 0.8.7 got scrapped and rewritten from scratch.

Now, I'm a big fan of refactoring, and I recognize that there were a couple of code reuse issues because I wasn't familiarized with the DVB code in Kaffeine. But scrap the entire implementation?

Worse, I took a look at the actual code, and it doesn't excite me. The parser extracts data from arbitrary offsets, it extracts the bare minimum of information required to "work", and apparently the notion of constants is nowhere to be found.

I love little gems like this:

length = (((at(30) & 0x3) << 8) | at(31)) + 32;

Or this:

bool isHidden() const
{
return ((at(26) & 0x10) != 0);
}


Do you know what "26" is? Or why it's being anded with 0x10?

The parser in 0.8.7 at least made a point to document to death where the stuff came from. The parsing was annotated with comments like "// See ATSC A/65C Sec 6.3.1 Table 6.7" so you knew exactly where to look in the spec.

I guess it's a bit hard not to take it personally since I invested a good bit of time in it. Also the new version is obviously a work in progress and perhaps it's premature to judge.

What to do now? I guess I can take the new implementation and improve the quality until it is closer to the 0.8.7 code. I can simply do nothing (it does "work" after all), although I'm going to be pretty screwed if I ever want to add functionality like the program guide support.

Also, I don't want to do any more work on the KDE3 version of Kaffeine if it's all going to be scrapped and rewritten anyway.

The upside is if I want to contribute, it's a target rich environment. The sound doesn't work. It doesn't tune right most of the time. It crashes on exit.

What's up with Google

You don't appreciate how important email is until you can't reach it. I haven't been able to get to Gmail for the last half hour from two different providers. DNS and ping look ok, but no TCP connections.

Now I'm having trouble even reaching www.google.com.

Weird.

Monday, August 25, 2008

Pinnacle PCTV HD Pro 801e Works!

Isolated the final problems with my Linux driver for the Pinnacle 801e. Cleaned up the changes and submitted the patch to Mauro for kernel inclusion.

In the end, I found a bug in xc5000 tuner driver which caused i2c failures to drop silently, a bug in dib0700's i2c implementation that took i2c reads and treated them as writes, I implemented a new i2c API for v1.20 of the Dibcom firmware, and extended the driver to disable master mode at capture startup to work properly with the s5h1411 demodulator.

Not bad for what totaled up to be six or seven night's work over three weeks. Let's just say that's WAY faster than my HVR-950 support.

The only downside is I managed to get everything working before I had a chance to take Steven Toth's suggestion and build my own i2c bus analyzer out of an old printer cable and two diodes.

ATSC seems to be working great. No other dib0700 devices support analog, so this will likely require some infrastructure changes. Part of me wonders whether anybody even cares about analog support. Most people are buying these new devices to take advantage of ATSC or else they would still be using their old capture devices.

On a separate note, I ordered the fiberscope today I need to inspect the ductwork in my building. Will hopefully get to the bottom of the ventilation problem and my bathroom vent will start working.

Sunday, August 24, 2008

Pinnacle PCTV HD Pro i2c now working

After going back and forth with the authors of the dib0700 and xc5000 drivers, it looks like I got the i2c interface working properly. azap is reporting tuner lock, but it looks like there is some issue with the interface between the tuner and the demodulator, since I am not actually getting the video stream (probably an improperly set if_khz).

If I can get the digital side working, I am hoping to deliver patches for xc5000 and dib0700 later this week.

Spent the weekend with Victoria in New York. Went to Central Park on Saturday night. Saw Tropic Thunder this afternoon.

Wednesday, August 20, 2008

Bermuda pictures



By popular demand, here are the pictures from my and Victoria's trip to Bermuda:

http://pics.livejournal.com/devinjh/gallery/00016fkw

Tuesday, August 19, 2008

Abandoned ashes

I ran across the following article tonight on CNN:

http://www.cnn.com/2008/LIVING/personal/08/19/problem.of.unclaimed.ashes.ap/index.html

I remember when the funeral director called me to pickup my father's ashes. He was very insistent that I come that very same day. When I arrived at the funeral home, I mentioned to him that I thought it was a bit strange that he was so insistent, saying:

"Of course I'm going to pick them up. It's not like I'm going to just leave them there."

To which he replied, "Let me show you something..."

The old man escorted me down into the dimly lit basement, and in the back of the room were rows of freestanding shelves from the floor to the ceiling. There were hundreds of small cardboard boxes on the shelves, each with a white sticker bearing a name and date of death. He pointed out that the smaller boxes were the ashes of children.

Who the fuck leaves behind the remains of their child?

It's kind of morbid I suppose but I can still picture the man standing beside the shelves in that basement, a caretaker for the unwanted remains...

Monday, August 18, 2008

Ugh.

So my efforts to setup VirtualBox on my MacBook were going great until I actually tried capturing off my USB device. Apparently VirtualBox's USB support isn't really designed to handle a 20Mbps datastream (although they claim USB 2.0 support).

It figures though that I don't figure this out until I spent the time to install VirtualBox, download/install Ubuntu 8.04, download/install KDE4, download/install all the updates, build V4L from source, build Kaffeine 0.87 from source, and then I was able to attempt a ATSC scan.

Ugh.

Oh, and water is pouring out of my air conditioner onto my hardwood floor. I guess the condensation pan filled up. I wiped up the mess and put a plastic garbage can under the A/C to catch the water.

Went to my CoOp board meeting tonight after work.

Thursday, August 14, 2008

More Pinnacle PCTV HD frustrations...

Continued to debug my xc5000/dib0700 i2c problem today. Didn't hear back from Patrick Boettcher on the i2c problem I found, so I didn't even bring up the more intermittent failure I am now trying to debug.

Confirmed that the xc5000 firmware provided in Steven Toth's driver is 100% identical to the code being uploaded via the windows driver (binary diff'd). I really wish I knew what it meant when i2c write requests returned a status of "-32". Continues to piss me off since if I had the datasheet I wouldn't be fumbling around and wasting my day off trying to reverse engineer the device behavior.

To add the the weirdness, it turns out I don't see the xc5000 tuner being set to the target frequency **ANYWHERE** in the Windows SniffUSB trace. Yeah, how the hell does the tuner know what channel to go to if the message isn't in the trace? It has me seriously worried that there might be a bug in the sniffer tool. Either that, or there is some other command for adjusting the tuner, perhaps through the demodulator. I have traced every single i2c call made to address 0x64, and all I am getting in the trace are the commands to load the firmware. I am not seeing any register reads or writes at all.

I also uncovered a bug in mrec's usbreplay tool, which was causing it to not be able to parse my traces. It turns up the offsets into the lines are all hard-coded, and if you have a timestamp large enough to add an extra digit, the file cannot be parsed. I can fix it but it was just faster for me to pass the capture file through sed and truncate off the leading digit.

Right before I left for vacation, Christoph contacted me about the progress he made on his KDE4 port of Kaffeine, and he wants me to debug the ATSC scanning. I want to do it, but I've just got too many projects in the hopper. And in this case, I would actually have to setup a Linux box with KDE4, whereas right now I'm running a hacked up version of KDE 3.5.

There just aren't enough hours in the day. It's a little frustrating to have the entire day off from work, and in the end I didn't get *anything* working.

I guess that's not completely true. I did get the the new hard drive installed in my MacBook, and got Leopard installed so I'm back up and running.

I wonder if anybody I know has a digital oscilloscope with enough buffer to do i2c capture... Or better yet, an actual i2c bus analyzer. They're 300 bucks, which is cheap for lab equipment, but way outside my budget...

Bermuda recap

Got back from Bermuda yesterday. Had lots of fun:

Sat on the beach in Grotto Bay
Went exploring the Crystal Caves
Went snorkeling and saw lots of fish
Walked around Hamilton and checked out Victoria Park
Scuba trip got canceled due to the weather
Stole sausage from the breakfast buffet to feed the stray cat
Went to the top of Gibbs Hill Lighthouse
Visited Horseshoe Bay (Pink beaches, yay!)
Relaxed and drank sprite by the pool

All in all, a nice laid back vacation.

Will get the pictures uploaded this weekend.

Friday, August 8, 2008

Bermuda

Victoria and I are off to Bermuda tomorrow for a few days. Will be good to get away and relax a bit.

Bermuda is not in the Caribbean. It's in the North Atlantic Ocean. Many people seem to not realize it's only a couple of hours away. For some reason Wikipedia clearly states that it's in the North Atlantic Ocean, but then at the bottom it's categorized in "Countries and territories of the Caribbean".

Don't be surprised if I don't answer emails until Thursday.

No laptop. No cellphone. Peace and quiet.

Where in the World is Carmen Santiago?

Or in this case where is the package I ordered from NewEgg a couple of days ago?

The downside of online tracking for companies like UPS is that you can see *exactly* how your package gets from point A to point B. This is can be pretty embarrassing sometimes.

Check out the route my package has taken so far to get from California to New York City:

BALDWIN PARK, CA
ONTARIO, CA (so far so good...)
NEWARK, NJ (getting close now...)
DALLAS/FT. WORTH A/P, TX (uh, what?)
NEWARK, NJ (almost there...)
PHILADELPHIA, PA (Doh!)

If you want to see for yourself, just click the URL below:
http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=1ZW098R41225142131&track.x=0&track.y=0

Don't get me wrong, it's not late yet. But still you have to admit that's a bit strange.

Thursday, August 7, 2008

Pinnacle PCTV HD Pro Stick tuning problem isolated

After going back and forth in email with the Linux xc5000 driver author this morning, I did some more testing tonight after getting home from work and I isolated the problem.

I don't think anybody cares about the gory details, but in short it ended up being an incompatibility between xc5000.c and dib0700_core.c in terms of how i2c read messages are passed. The result is i2c read messages get sent onto the USB bus as i2c write messages and then the caller is surprised when the call returns as successful but the output buffer is unchanged.

Wow, that was a pain in the ass.

I also found a fairly minor bug in the xc5000 driver where it reports some write calls as successful even when they fail.

I won't be able to do a patch before I go on vacation, but I will email the author of the dib0700 driver and I should be able to get the digital support working after I get back.

Wednesday, August 6, 2008

More progress

Made some more progress in reverse engineering the Pinnacle PCTV HD Pro Stick. I broke out an oscilloscope and with the help of the publicly available datasheets for the CX25843, CS5340, and someone kind enough to tell me where the reset pin was on the xc5000, I traced out a bunch of the GPIOs for the various components. Still some more analysis to do, but I'm making progress.

Wow, my eyes don't work as well as they used to. Even with my magnifying visor, I still had trouble tracing out the PCB. I think I've still got one of those benchmount magnifier/light contraptions in my father's basement. I should see if it's still there...

Updated the wiki page with the GPIO and i2c findings from the last couple of nights' work:

http://www.linuxtv.org/wiki/index.php/Pinnacle_PCTV_HD_Pro_Stick_(801e)

I still haven't tracked down why the xc5000 didn't respond to i2c commands after loading the firmware. Will have to see if I can figure that out tomorrow.

More work on Pinnacle PCTV HD Pro USB stick (801e)

I woke up a bit early this morning, and managed to figure out I had mapped out the xc5000 to the wrong i2c address (Doh!). Fixed that and now the device is detected and the firmware loads successfully.

Now it's failing on the first i2c command to set an xc5000 register (even if I put a extended sleep after the reset). Perhaps I have the xc5000 reset pin mapped to the wrong GPIO as well, and so the pin isn't being pulled low. Strange though, since I had to put a 10ms sleep after I did the reset, which shouldn't have been necessary if I wasn't actually tied to the xc5000 reset pin. If I had the damn pinout to the xc5000, I could just put my scope on the reset pin and scan through the GPIOs (since I confirmed every active GPIO is in output mode).

Digital support
* dib0700 - working
* s5h1411 - working
* xc5000 - 50% there

Analog support
* cx25843 - not started
* xc5000 (analog) - not started

I should update the LinuxTV wiki page with the i2c and GPIO mappings I have found.

Tuesday, August 5, 2008

Too much to do, too little time

I've been a bit busy lately...

  • The hard drive in my MacBook decided it no longer deserved to live. Ordered a replacement on NewEgg tonight for $65.00. Fortunately I backed everything up a couple of weeks ago before installing Leopard.
  • I *almost* got the Linux driver working for my Pinnacle PCTV HD Pro USB stick, except the xc5000 is either stuck in reset or not answering i2c commands for some other unknown reason.
  • I'm not making any progress in updating my em28xx driver to power down the tuner when idle (been too busy to work on it)
  • My Kaffeine ATSC closed captioning support is working except for some timing bug that only occasionally renders the CC in the wrong order (like once every ten or fifteen seconds)
  • I suspect there's a thermal problem with the ATI TV Wonder 600 support I added a couple of weeks ago to be pushed upstream to the Linux kernel. I need to get it isolated before the kernel goes out (Tonight I ordered one of the devices so I can debug the issue).
  • I haven't really even *started* the work for Kaffeine's ATSC program guide support
  • Did I mention I have to pay my taxes before I go off to Bermuda on Saturday? And no, I'm not trying to evade extradition or anything...