2013-01-17

generating AF9035/AF9033/IT9135 driver code

Hacking with the AF9035/AF9033/IT9135


I have been quite busy many weeks and due to that this blog has been silent. It doesn't mean I haven't done Kernel coding, instead I have used some time for hacking my AF9035/AF9033 drivers. There is now support for dual mode (dual tuners, twin tuners) and also support for devices having FC0012 RF-tuner. Those are already merged into +LinuxTV master and going for the Kernel 3.9. I also split out RF-tuner (to own driver module) from the existing IT9135 driver and now AF9035/AF9033 supports also newer IT9135 devices. Difference between AF9035 and IT9135 is integration of RF-tuner, whilst USB-interface and DVB-T demodulator remains same. IT9135 RF-tuner separation is not 100% ready. Development driver could be found from my Git tree at http://git.linuxtv.org/anttip/media_tree.git

The script!

I did small script to generate af9033 driver C-code from the USB capture I took from the working Windows machine. This is what I actually do about every time when I start making new driver. Take simple USB sniff, generate code, copy & paste that code to the Linux driver until you get picture. Then start implementing register by register correctly until you are happy with the driver.


AF9035/AF9033 driver is still missing few used RF-tuners. I hope releasing that script encourages someone having non-supported hardware to fix it! Patched are welcome, as well are the unsupported AF9035 devices...

Here is the example of script input and output.

input (from the USB sniffer + parser.pl):
002106:  OUT: 000002 ms 030407 ms BULK[00002] >>> 0c 90 01 5e 01 02 00 00 f7 15 01 fa 05
002107:  OUT: 000000 ms 030409 ms BULK[00081] <<< 04 5e 00 a1 ff
002108:  OUT: 000000 ms 030409 ms BULK[00002] >>> 0f 80 01 5f 04 02 00 00 00 25 00 00 60 00 f9 9a
002109:  OUT: 000079 ms 030409 ms BULK[00081] <<< 04 5f 00 a0 ff

ouput (C-code, could be pasted directly to the af9035/af9033 driver):
// 002106:  OUT: 000002 ms 030407 ms BULK[00002] >>> 0c 90 01 5e 01 02 00 00 f7 15 01 fa 05
ret = af9033_wr_regs(state, 0x90f715, "\x01", 1); // generated
// 002107:  OUT: 000000 ms 030409 ms BULK[00081] <<< 04 5e 00 a1 ff
// 002108:  OUT: 000000 ms 030409 ms BULK[00002] >>> 0f 80 01 5f 04 02 00 00 00 25 00 00 60 00 f9 9a
ret = af9033_wr_regs(state, 0x800025, "\x00\x00\x60\x00", 4); // generated
// 002109:  OUT: 000079 ms 030409 ms BULK[00081] <<< 04 5f 00 a0 ff