DVB

From SlackWiki
Revision as of 02:53, 1 January 2014 by Count Zero (talk | contribs) (Removing a piece of spam I missed on first undo.)
Jump to navigation Jump to search


Introduction

I've been a big fan of tv tuner cards for almost as long as I've been in to computers. As soon as my dad bought an HDTV, I knew I had to have it, and the first chance I had was to buy the ATI HDTV Wonder card for my computer. Sure, the picture can be bad sometimes because you are grabbing the signal out of the air with an unamplified antenna, but it is well worth it. When I finally decided to make the jump to Linux a few months ago, I researched ahead of time if it was possible to use my card in Linux, and to my surprise I could. Let me note that it did take me a few months of on and off work to get it running since I was pretty much learning Linux from scratch along the way. The biggest pitfalls I ran in to was the lack of a complete HOWTO to lead me through the steps from start to finish and the lack of a large DVB/HDTV user community to ask for help when I ran in to trouble. I hope that this tutorial gets rid of those two pitfalls and lets you get your HDTV card working without any trouble.

Kernel Configuration

I'm not sure which kernel exactly began including the necesary modules for the ATI HDTV Wonder card, but I do know that kernel versions 2.6.15 and up have them. In order to use the ATI HDTV Wonder, you need to enable the correct modules in the kernel. You need to enable I2C and the cx88 DVB modules under Device Drivers. If you are new to building your own kernel, see Kernel26Compilation

snipped from my .config

#
# I2C support
#
CONFIG_I2C=m
CONFIG_I2C_CHARDEV=m

#
# I2C Algorithms
#
CONFIG_I2C_ALGOBIT=m

#
# Video For Linux
#

#
# Video Adapters
#
CONFIG_VIDEO_CX88=m
CONFIG_VIDEO_CX88_ALSA=m
CONFIG_VIDEO_CX88_DVB=m
CONFIG_VIDEO_CX88_DVB_ALL_FRONTENDS=n
CONFIG_VIDEO_CX88_VP3054=m
#
# Digital Video Broadcasting Devices
#
CONFIG_DVB=y
CONFIG_DVB_CORE=m

#
# ATSC (North American/Korean Terresterial DTV) frontends
#
CONFIG_DVB_NXT200X=m

If you are a less advanced user, it won't hurt anything if you select everything that might remotely deal with DVB as a Module (hit `M`). When you are done, save the configuration and compile the kernel. Before you reboot, you need to download the firmware for the card.

Firmware

Make sure you are in /usr/src/linux

# pwd
/usr/src/linux

There is a script provided that will download the appropriate firmware driver for you. First, make it executable, then run it.

# chmod +x Documentation/dvb/get_dvb_firmware
# ./Documentation/dvb/get_dvb_firmware nxt2004

Then the firmware file needs to be copied to the directory where hotplug will find it. On Slackware, this directory is /lib/firmware

# cp dvb-fe-nxt2004.fw /lib/firmware

Now you can reboot in to your new kernel, and your card should be automatically recognized. You can check to see if the modules loaded with lsmod

$ lsmod | grep cx88
cx88_dvb                8964  0
cx8802                  8068  1 cx88_dvb
cx88xx                 54180  2 cx88_dvb,cx8802
ir_common               7812  1 cx88xx
btcx_risc               3848  2 cx8802,cx88xx
tveeprom               12304  1 cx88xx
cx88_vp3054_i2c         3456  1 cx88_dvb
i2c_algo_bit            7432  2 cx88xx,cx88_vp3054_i2c
mt352                   5380  1 cx88_dvb
or51132                 8324  1 cx88_dvb
video_buf_dvb           4228  1 cx88_dvb
video_buf              15364  4 cx88_dvb,cx8802,cx88xx,video_buf_dvb
nxt200x                11524  1 cx88_dvb
cx24123                 7684  1 cx88_dvb
lgdt330x                6684  1 cx88_dvb
cx22702                 5252  1 cx88_dvb
i2c_core               15248  15 nvidia,w83627hf,eeprom,i2c_isa,i2c_nforce2,cx88_dvb,cx88xx,tveeprom,i2c_algo_bit,mt352,or51132,nxt200x,cx24123,lgdt330x,cx22702
dvb_pll                 9220  4 cx88_dvb,or51132,nxt200x,cx22702

DVB Apps

All that we are really interested in with DVB Apps is scan and azap. I created a SlackBuild script that will create a package from the dvb apps cvs. To use the SlackBuild script, you will first need to create a temporary directory to house the relevant components and then you will need to get the sources from the dvb apps CVS. If you are new to SlackBuild scripts, check out the SlackBuild_Scripts tutorial. You will log in to the cvs with an empty password.

$ mkdir ~/dvb-apps-build
$ cd ~/dvb-apps-build
$ cvs -d :pserver:anonymous@cvs.linuxtv.org:/cvs/linuxtv login
$ cvs -z3 -d :pserver:anonymous@cvs.linuxtv.org:/cvs/linuxtv co dvb-apps

Udev Rules

By default, my udev would not create the correct devices nodes, so I found these rules on a website which fixed the problem. I can not remember what site I found them on at the moment, but I will be sure to give credit to that site when I find it again. You will need to create or edit the file /etc/udev/rules.d/010_local.rules and place this information in it:

#create correct dvb devices
KERNEL=="dvb0.dvr*",        NAME="dvb/adapter0/dvr%n"
KERNEL=="dvb0.demux*",      NAME="dvb/adapter0/demux%n"
KERNEL=="dvb0.frontend*",   NAME="dvb/adapter0/frontend%n"
KERNEL=="dvb0.audio*",      NAME="dvb/adapter0/audio%n"
KERNEL=="dvb0.ca*",         NAME="dvb/adapter0/ca%n"
KERNEL=="dvb0.osd*",        NAME="dvb/adapter0/osd%n"
KERNEL=="dvb0.net*",        NAME="dvb/adapter0/net%n"
KERNEL=="dvb0.video*",      NAME="dvb/adapter0/video%n"

Scanning for Channels

Once dvb-apps is installed, you can see if everything is working correctly. First, you need to create the ~/.azap directory, then you need to create your channels.conf file. Since my ATI HDTVWonder uses an antenna to grab channels, I used the us-NTSC-center-frequencies-8VSB database file.

$ mkdir ~/.azap
$ touch ~/.azap/channels.conf
$ scan /usr/local/share/dvb/scan/atsc/us-NTSC-center-frequencies-8VSB > ~/.azap/channels.conf

This will take some time and it will give you a lot of "tuning failed" messages, but if it is successful, you will see something like this when it is done:

dumping lists (12 services)
WJZ-DT:617000000:8VSB:49:52:1
WNUV High Def:629000000:8VSB:49:52:3
WNUV - The Tube:629000000:8VSB:65:68:4
Same as the Tube:629000000:8VSB:81:84:5
FOX45 HDTV:665000000:8VSB:49:52:3
FOX45 Digital Television:665000000:8VSB:65:68:4
WMAR-Radar SD-3:701000000:8VSB:81:84:5
WMAR-SD2:701000000:8VSB:65:68:4
WMAR-HD:701000000:8VSB:49:52:3
WMAR-TV:701000000:8VSB:0:0:65535
WBALDT:743000000:8VSB:49:52:1
WBALSD:743000000:8VSB:65:68:2
Done.

You can edit that file to remove channels as you please. If you want to use MPlayer for output, copy the channels.conf over to ~/.mplayer, and, likewise, ~/.xine for using Xine. You can substitute symlinks if you are more comfortable with that, too. Once the file is in ~/.azap, you can test the channels by running something similar to:

$ azap -r WBALDT
using '/dev/dvb/adapter0/frontend0' and '/dev/dvb/adapter0/demux0'
tuning to 743000000 Hz
video pid 0x0031, audio pid 0x0034
status 1f | signal 9fb0 | snr 5c32 | ber 00000000 | unc 0000007f | FE_HAS_LOCK
status 1f | signal fbf0 | snr df58 | ber 00000060 | unc 00000000 | FE_HAS_LOCK
status 1f | signal fc20 | snr de9c | ber 00000008 | unc 00000000 | FE_HAS_LOCK
status 1f | signal fb50 | snr db7c | ber 00000018 | unc 00000000 | FE_HAS_LOCK
status 1f | signal fc70 | snr dc66 | ber 00000028 | unc 00000000 | FE_HAS_LOCK

Hit CTRL+C after a few lines to exit out. Those lines above show that everything is working alright. You can also check that everything is o.k. with dmesg:

$ dmesg
...
nxt2004: Waiting for firmware upload (dvb-fe-nxt2004.fw)...
nxt2004: Waiting for firmware upload(2)...
nxt2004: Firmware upload complete
cx88[0]/2: queue is empty - first active
cx88[0]/2: cx8802_start_dma w: 0, h: 0, f: 2
cx88[0]/2: setting the interrupt mask
cx88[0]/2: [f53b9b80/0] cx8802_buf_queue - first active
cx88[0]/2: cx8802_restart_queue
cx88[0]/2: cx8802_restart_queue: queue is empty

Setting up MPlayer

According to the MPlayer website, the configuration script should detect your DVB card and compile DVB support automatically. That did not work for me. The configure script could not find my dvb include directory, so i had to specify it when I ran configure. I edited Rob Workman's SlackBuild script [[1]] to allow for DVB support to be compiled. Here is the configure options I used, the rest of the script was left untouched:

./configure \
  --prefix=/usr \
  --confdir=/etc/mplayer \
  --enable-gui \
  --enable-menu \
  --enable-dvb \
  --with-dvbincdir=/usr/src/linux/include \
  --enable-xmms \
  --with-codecsdir=$CODECSDIR \
  --with-win32libdir=$CODECSDIR 

Notice the "--enable-dvb" and "--with-dvbincdir" options. Once I specified those, everything ran fine. Once MPlayer is compiled correctly and installed, make sure you place a copy of channels.conf in ~/.mplayer. When you are done that, you can run MPlayer by either specifying the device or by specifying the channel:

$ mplayer /dev/dvb/adapter0/dvr0

or

$ mplayer dvb://WMARHD

GMPlayer is a GTK frontend that gets installed with MPlayer and can also be used for DVB, but I have not figured out how to get a DVB option in the menus yet. When I figure it out, I will update this accordingly. Right now, you can launch gmplayer using the same lines above by simply substituting mplayer with gmplayer.

Setting up Xine

According to everything I have read about Xine, it is supposed to compile automatically with DVB support. However, I still can not get it to view my DVB stream. As soon as I figure out how to make it work, I will update this page accordingly.

Resources

http://www.mythtv.org/wiki/index.php/ATI_HDTV_Wonder

http://www.mythtv.org/wiki/index.php/Adding_QAM_Channels_For_HDTV_Tuner_Cards

http://www.mythtv.org/wiki/index.php/Dvb_Apps

http://www.linuxtv.org/