Saturday, May 21, 2005

I should have learned.. One should trust IVTV magic.

Ok, it has been a while since my last post. The reason for this is that I have been slightly depressed. The reason for this is that we decided to buy another TV card.. one never learns.

The card we ended up buying was an analog PVR-150 card from Hauppauge. This is similar to the one we already got, but with two major differences:
* There is no TV out, and therefore only an MPEG2 encoding chip.
* The MPEG2 encoding chip on the board is a new CX23416 chip.

A new chip makes it harder. Chris Kennedy is working on support for this chip in the unstable branch of the IVTV driver project, and the support seems to work pretty well. The problem is that the kernel module for the encoder chip on this board does not play nicelly with the module for the encode on the PVR-350 card we had working.

So, on the ivtv-devel list, there were lots of setups floating around suggesting that the saa7127 module should be hindred to attach to the PVR-150 card with a i2c_enable=1,-1 argument and the cx25840 should be made to play nice with a corresponding i2c_enable=-1,1 argument. In addition, there were a lot of posts suggesting that one should supply a cardtype=2,6 argument manually, to tell the ivtv module that this did, indeed, regard a PVR-350 card as #0 and PVR-150 card as #1.
I listned to all of these adviced, and I ended up with a very large modules.conf, without me getting the results I whanted.

What I got was that I found a setting that enabled me to tune on both tuners with if I physically changed the slots they used, and thereby the order in which they were initiallized. This wshould have gven me a clue to the solution, but it didn't. The backside of this setup was that could not get any kind of screen output. Not even a flicker on the screen! The framebuffer attached ok, but
X was transported into void (without even an error message).
In the original card order, I could use everything on the PVR-350 card, but every attempt of getting data from the video1 device (for the PVR-150 card) resulted in a I/O error. I could tune ok though..

I spent a good portion of a week trying different settings and module load order. Nothing.
However, yesterdayt I got to a stage where I could tune both cards ang get good data from both cards, but this time in the original PVR-350 - PVR-150 card order. I was happy for a while, until I realised the TV out problem came with successful tuning. All of a sudden, I could not get TV out even with the 350 card in the first slot.

Today, I got to thinking about my first attempts of setting the PVR-350 card up. In that case, supplying less options had done the trick. Also, I noticed that there was a difference in the behaviour of the two encoding modules: saa7127 grabbed everyting in sight, but cx25840 acctually respected the i2c_enable arguments I supplied. But, the cx25840 dd not load it's firmware properly if autoloaded by ivtv. This is when I decided to remove everything until I got to the setting that worked for the single PVR-350 card, and just loading cx25840 before it.
After havng tested a coulple of variants, I found one that acctually worked! With this load order, I could tune both tuners and get TV OUT!
Here is the successful setup:

mythtv root # cat /etc/modules.d/ivtv
alias char-major-81 videodev
alias char-major-81-0 ivtv
alias char-major-81-1 ivtv
alias char-major-61 lirc_i2c

The modules are loaded by:
mythtv root # cat /etc/modules.autoload.d/kernel-2.6

tda9887 pal=B
cx25840 i2c_enable=-1,1

ivtv ivtv_std=2 tda9887=0
ivtv-fb
lirc_dev
lirc_i2c

Simple. Trust the force! Also, there should be good dose of black magic*!

Now the whole faily is happy and dancing to MythTV music



*[For those that do not understand the pun, the cx25840 has an option 'no_black_magic' which should not be set.. :-)]