Pages

Saturday, November 17, 2012

Scanning and playing DVB-T

I found a USB DVB-T adapter in my USB spare box and I thought it would be a more or less nice idea to check if it is still running. Since I haven't watch TV in years that could be interesting.The first thing I did was to plug in the adapter and check for firmware messages:

# dmesg| grep firm
[ 4501.549255] dvb-usb: found a 'Afatech AF9015 DVB-T USB2.0 stick' in cold state, will try to load a firmware
[ 4501.550498] dvb-usb: did not find the firmware file. (dvb-usb-af9015.fw) Please see linux/Documentation/dvb/ for more details on firmware-problems. (-2)


The message above shows clearly that a firmware is missing. So I downloaded one from the internet:

# wget -c "http://www.otit.fi/~crope/v4l-dvb/af9015/af9015_firmware_cutter/firmware_files/4.95.0/dvb-usb-af9015.fw"

And moved it to /lib/firmware:

# mv dvb-usb-af9015.fw /lib/firmware/

Then I unplugged the adapter and plugged it back in. Running dmesg shows a lot more messages now, at the end the adapter was successfully initialized. I just had to be a little patient, uploading the firmware took 10-20 seconds:

# dmesg
...
[ 4858.906211] usb 1-4: new high-speed USB device number 5 using ehci_hcd
[ 4859.025797] usb 1-4: New USB device found, idVendor=15a4, idProduct=9016
[ 4859.025808] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 4859.025815] usb 1-4: Product: DVB-T
[ 4859.025820] usb 1-4: Manufacturer: Afatech
[ 4859.419482] dvb-usb: found a 'Afatech AF9015 DVB-T USB2.0 stick' in cold state, will try to load a firmware
[ 4889.453328] dvb-usb: downloading firmware from file 'dvb-usb-af9015.fw'
[ 4889.522190] dvb-usb: found a 'Afatech AF9015 DVB-T USB2.0 stick' in warm state.
[ 4889.522304] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[ 4889.522678] DVB: registering new adapter (Afatech AF9015 DVB-T USB2.0 stick)
[ 4889.541267] af9013: firmware version:4.95.0.0
[ 4889.548668] DVB: registering adapter 0 frontend 0 (Afatech AF9013 DVB-T)...
[ 4889.565710] MT2060: successfully identified (IF1 = 1220)
[ 4890.001722] Registered IR keymap rc-empty
[ 4890.001913] input: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:12.2/usb1/1-4/rc/rc0/input11
[ 4890.002305] rc0: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:12.2/usb1/1-4/rc/rc0
[ 4890.002312] dvb-usb: schedule remote query interval to 500 msecs.
[ 4890.002320] dvb-usb: Afatech AF9015 DVB-T USB2.0 stick successfully initialized and connected.


Also a few dvb devices showed up:

# ls /dev/dvb/adapter0/
demux0  dvr0  frontend0  net0


Next I needed to scan for some channels. For that I needed to download the dvb-apps package:

# cd /usr/src
# wget -c "http://linuxtv.org/hg/dvb-apps/archive/tip.tar.gz"
...


Extract and compile it:

# tar xf tip.tar.gz
# cd dvb-apps-*
# make && make install


After everything was compiled I started to scan for channels. I picked a terrestrial transmitters file from /usr/share/dvb/dvb-t/ for my current location and started to scan:

# scan /usr/share/dvb/dvb-t/uk-Mendip > channels.conf
scanning /usr/share/dvb/dvb-t/uk-Mendip
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
...


If any channels were found, then they will be stored in the channels.conf file (stdout). The messages that are displayed (stderr) are informational only (channel tuning etc). If you're really lazy then search on the internet for an appropiate channel file.
After the channel file was generated, I copied it to my users mplayer directory:

# cp channels.conf /home/user/.mplayer/

As user I can start mplayer now and watching TV:

$ mplayer dvb://"Channel"
MPlayer 1.1-4.7.1 (C) 2000-2012 MPlayer Team

Playing dvb://Channel.
dvb_tune Freq: 530000000
TS file format detected.
VIDEO MPEG2(pid=545) AUDIO MPA(pid=546) NO SUBS (yet)!  PROGRAM N. 0
VIDEO:  MPEG2  720x576  (aspect 3)  25.000 fps  15000.0 kbps (1875.0 kbyte/s)


I have learned one lesson from this: TV still is boring!

Links:
http://www.linuxtv.org