Configure Your TV Card on Linux

Linux can be used not only for computing, but also for watching TV. For this, the basic requirement is to have administrator rights on the system. All the necessary commands to configure the TV card of Unix should be launched as root from sudo. In this article we will show you how!

Configure Your TV Card on Linux

The first step is to install a TV card via the BTTV module. After this, find the appropriate software to watch TV, as it is needed for TV time installation. The final step is to configure the remote control, which in turn is supported through a lirc module.

Lirc modules can be quite complicated sometimes, and it is advisable to install it through a module assistant or by researching the relevant material from the lirc website. After this, one can easily configure the buttons with lirc and start watching your favourite television shows on Linux.

This FAQ is for people using Debian and other distributions which are based on it (Ubuntu, Xandros etc). Most of the following commands will require administrator rights and should be launched as root or via sudo.

This FAQ was made for the Winfast TV 2000 XP card on Debian Lenny and a Leadtek Y0400046 remote control.

Step1: Card Installation

The BTTV module used for this map is provided directly by the linux-image package. Just configure it according to the model of the TV card. To do this we create/fix /etc/modprobe.d/bttv and put in:

options bttv radio=0 card=34 tuner=24 gbuffers=8

Warning: This is specific to the TV card.

So that the module is loaded at startup it also alters /etc/modules by adding in the BTTV module. You can already load the BTTV module by typing:

modprobe bttv

Step 2: TVTime Installation

There are several programs you can use to watch TV in Linux. Sub TVTime seems to work without any problems. To install it:

aptitude update

aptitude safe-upgrade

aptitude install tvtime

Now you have to launch TVTime to scan the TV channels. If the tuner and card are properly configured this should not be a problem. Below is a possible configuration that may work for you:

Video source: TV

Sound Mode: pal-i

Standard received: secam

Step 3: Remote control configuration

Configuring the remote through lirc can be quite complicated for beginners. A common mistake is to reference a module that no longer exists on modern kernels: lirc_gpio

Lirc Installation

Start by installing the module that will allow you to manage the remote. It is advisable to go through the Module Assistant, and archives available on the lirc website to help you.

aptitude install module-assistant lirc-modules-source lirc-x

module-assistant

In the interface module wizard, choose lirc-modules-source (Get, Build, Install). If everything went well, everything should have installed properly.

Check this is the case by making sure the card is visible when you type the command:

cat /proc/bus/input/devices

You should be given information about the card, for example:

...

I: Bus=0001 Vendor=107d Product=6606 Version=0001

N: Name="bttv IR (card=34)"

P: Phys=pci-0000:01:07.0/ir0

S: Sysfs=/class/input/input6

U: Uniq=

H: Handlers=kbd event6

B: EV=100003

B: KEY=10afc336 2150a48 0 0 0 404 80010007 80000190 4801 1e0000 4400 100000 10000ffc

...

Then use the following code:

lircd -d /dev/input/event6 -H dev/input

This command creates the device /dev/lircd to be used by lircd to receive signals from the remote.

Then correct the file /etc/lirc/hardwareonf so as to have:

#Chosen Remote Control

REMOTE="Winfast TV2000/XP (card=34)"

# Arguments which will be used when launching lircd

LIRCD_ARGS=""

#Don't start lircmd even if there seems to be a good config file

#START_LIRCMD=false

#Try to load appropriate kernel modules

LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.

DRIVER="dev/input"

# If DEVICE is set to /dev/lirc and devfs is in use /dev/lirc/0 will be

# automatically used instead

DEVICE="/dev/input/event6"

MODULES=""

# Default configuration files for your hardware if any

LIRCD_CONF="/etc/lirc/lircdonf"

LIRCMD_CONF=""

Make sure you make any necessary changes to the variables according to the hardware you are using. Then launch lirc:

/etc/init.d/lirc restart

First Test

At this stage it is usually possible to begin to recover the signals from the remote with the IRW. This program can be launched by user. While running, you can press the buttons on the remote control to retrieve the IDs of keys that will be used in lirc configuration files. These identifiers depend on the remote. Here is an example of what you may get by pressing "channel +", "finetune +", "8", "6" and "5":

(mando@aldur) (~) $ irw

0000000080010192 00 CH_UP Leadtek-RM0010

000000008001004e 00 FINETUNE+ Leadtek-RM0010

0000000080010009 00 8 Leadtek-RM0010

0000000080010007 00 6 Leadtek-RM0010

0000000080010006 00 5 Leadtek-RM0010

Configure Lirc

You can download ready-made files to configure most available remotes, meaning you don't have to do all this yourself. You can find an archive of files you can use to fill /etc/lirc/lircdonf here.

Here is how the file for Y0400052 looks:

#/etc/lirc/lircdonf

# Please make this file available to others

# by sending it to

#

# this config file was automatically generated

# using lirc-0.8.3-CVS(dev/input) on Sat Jan 12 17:04:54 2008

#

# contributed by: Mike Treichler

#

# brand: LeadTek

# model no. of remote control: Y0400046 (bundled with Winfast 2000XP Deluxe)

# devices being controlled by this remote: LeadTek Winfast 2000XP Deluxe

# brand: Leadtek

# model: Y0400052 (bundeled with Winfast PVR2000 TV-card)

#

# Note: Only CH_UP, CH_DOWN, VOL_UP and VOL_DOWN will repeat. This

# seems to be a limitation of the remote control.

begin remote

name Leadtek-RM0010

bits 16

eps 30

aeps 100

one 0 0

zero 0 0

pre_data_bits 16

pre_data 0x8001

gap 423871

toggle_bit_mask 0x0

begin codes

POWER 0x0074

MTS 0x0188

TV/FM 0x0182

VIDEO 0x0189

DISPLAY 0x0166

CH_UP 0x0192

CH_DOWN 0x0193

VOL_DOWN 0x0072

VOL_UP 0x0073

FULLSCREEN 0x0174

TELETEXT 0x0184

SLEEP 0x008E

BOSSKEY 0x0163

MUTE 0x0071

RED 0x018E

GREEN 0x018F

YELLOW 0x0190

BLUE 0x0191

1 0x0002

2 0x0003

3 0x0004

4 0x0005

5 0x0006

6 0x0007

7 0x0008

8 0x0009

9 0x000A

0 0x000B

. 0x0034

FINETUNE+ 0x004E

FINETUNE- 0x004A

PIP 0x00E2

ENTER 0x001C

RECALL 0x0195

BACK 0x019C

PLAY 0x00A4

NEXT 0x0197

TIMESHIFTING 0x0169

STOP 0x0080

REC 0x00A7

SNAPSHOT 0x00EA

end codes

end remote

If you are feeling confident, you may want to make some adjustments to your file. This often necessary, however.

Configure the behavior of buttons

At this stage the key codes are properly associated with identifiers, but there is still more to do. We must now intercept these events with either irexec, or irxevent, and transmit to them to the software. This is done with rules that define what will happen when you press a particular key. Remember:

- Irexec allows you to run a command shell

- Irxevent can launch the equivalent of an action on the keyboard

Example

These two rules are equivalent. They allow you to press the F key in TVTime to go into full screen mode.

a) with irxevent:

begin

prog = irxevent

button = FULLSCREEN

config = Key f tvtime

end

b) with irexec:

begin

prog = irexec

button = FULLSCREEN

config = tvtime-command TOGGLE_FULLSCREEN

end

These rules are usually in ~/.lircrc. You can also put them in /etc/lirc/lircrc to allow them to share all the profiles of the machine. To do this:

ln-s /etc/lirc/lircrc ~/.lircrc

Here is an example of how the completed file may look:

begin

prog = irexec

button = CH_DOWN

config = tvtime-command CHANNEL_DOWN

end

begin

prog = irexec

button = CH_UP

config = tvtime-command CHANNEL_UP

end

begin

prog = irexec

button = VOL_DOWN

config = tvtime-command MIXER_DOWN

end

begin

prog = irexec

button = VOL_UP

config = tvtime-command MIXER_UP

end

begin

prog = irexec

button = FULLSCREEN

config = tvtime-command TOGGLE_FULLSCREEN

end

begin

prog = irexec

button = 1

config = tvtime-command CHANNEL_1

end

begin

prog = irexec

button = 2

config = tvtime-command CHANNEL_2

end

begin

prog = irexec

button = 3

config = tvtime-command CHANNEL_3

end

begin

prog = irexec

button = 4

config = tvtime-command CHANNEL_4

end

begin

prog = irexec

button = 5

config = tvtime-command CHANNEL_5

end

begin

prog = irexec

button = 6

config = tvtime-command CHANNEL_6

end

begin

prog = irexec

button = 7

config = tvtime-command CHANNEL_7

end

begin

prog = irexec

button = 8

config = tvtime-command CHANNEL_8

end

begin

prog = irexec

button = 9

config = tvtime-command CHANNEL_9

end

begin

prog = irexec

button = 0

config = tvtime-command CHANNEL_0

end

Once you have finished this, run the following code:

irxevent -d /etc/lirc/lircrc

irexec -d /etc/lirc/lircrc

Autorun

To avoid unnecessary hassle every time you restart, you can set irxevent and irexec to run automatically whenever you switch on your machine. For example, in KDE, just create a file ~/.kde/Autostart/remote.sh and type in:

#! /bin/sh

irxevent-d /etc/lirc/lircrc

irexec-d /etc/lirc/lircrc

Then add the execution rights:

chmod u + x ~ /.kde/Autostart/remote.sh

For more details see the Ubuntu forums.

Leave A Comment