This post tries to summarise how to configure the tv tuner’s remote control to be used with tv time on Ubuntu 11.04. My TV Tuner is an AverMedia AVerTV Studio 507 (m507) board just like this one.

The difficulty to configure it comes from a couple of issues:

  1. tvtime is a very old application (apparently it was last updated on 2005). It has few patches (as version 1.0.2 delivered with Ubuntu 11.04) which makes it play with Alsa. It still works, but the tutorials / configuration files are out of date and won’t work by default.
  2. some remote control buttons are by default mapped to a multimedia key (for example the Power button on the remote brings the “Shutdown” popup instead of starting / stopping the tv tuner application). But once lirc configured, the remote control keys will be routed through lirc instead of the default mapping.

One advantage is that the tuner works as is with kernel version 2.6.38 that comes bundled with Ubuntu. TV time should show a crystal clear image, but there’s a lot of work to get it to respond to the remote control buttons.

a) Configuring saa7314 module

The first thing to do is to activate the correct module with the correct options. In my case, the values from /etc/modprobe.d/options.conf are:

The most important thing to notice is that you might not get your card set up properly since the documents are again out of date. TV Time showed a perfect image using card=157 tuner=38 argument but apparently, the remote keys were not detected, and this stopped progress for a while. It was actually until I read the source code of the module that I discovered that GPIO support for saa7314 module was activated only for card=102 (although according to the documentation, 157 is the value for my card).

Once proper arguments are given (card=102 and ir_debug = 1) that I got the remote keys apparing in dmesg:

This is mandatory to appear, if you don’t have these logs (push a remote button, then issue dmesg and check at the end, you should see two lines for each button – which mean a press and a release for that button).

If you have those appearing in dmesg, the volume / mute / number buttons should work already in TV Time. However, as you will notice, CHANNEL_UP / CHANNEL_DOWN keys do not work (since there’s no X11 mapping for them, they are specific to a TV viewing application for example). Also, the Power button will in fact trigger the “Shutdown” popup in Ubuntu (which will eventually shut the system down).

A couple of observations here:

  1. The volume / mute work using the system volume and there are nice popups indicating the action (like you would be using the multimedia keys on a real keyboard). Unfortunately once the routing will be done from lirc the volume stops to work.
  2. The sound should work in TV Time (if it doesn’t there are few options: “tvtime --mixer=hw:0/Line” or “tvtime --mixer=default/Line“. If these still don’t make it work you need to remove the .tvtime folder and recreate the channels (sometimes tvtime screws up the configuration)

If sound works and remote keys appear in dmesg, then this step is done.

b) Identify /dev/input/eventX source for the remote

To identify which event source it is used by the remote sensor, you need to:

and watch for saa7314 in the output. Beneath it, the Handlers say event5 so that will be the event source. In my case it is 5, but that number will probably be different in your case.

To test that it works, execute the command below and then start pushing remote buttons. You should get buttons like shown below:

c) installing lirc

First you need the latest lirc version installed. If you don’t have it, run the install command below, otherwise, lirc needs to be reconfigured with “dpkg-reconfigure lirc"

During installation, you will be asked to choose the “Remote Control configuration”. Make sure you select “Linux input layer (/dev/input/eventX)” option, then continue installation / reconfiguration.

On the “Custom event interface for your dev/input device” window, you should select the “…event-ir” value:

lirc dev/input event-ir

lirc dev/input event-ir

Lirc will restart automatically.

To check that remote control buttons are detected now via LIRC, you need to run the command below and watch for output:

One thing to notice is also the remote key/button names: KEY_VOLUMEUP, KEY_CHANNEL_DOWN, etc .. These values are needed on the last step, configuring irexec with .lircrc file.

d) irexec with .lircrc file

TVTime is controlled using two additional programs:

  1. irexec – which can trigger a program based on a remote button press
  2. tvtime-command – which sends a TVTime command to tvtime

A sample ~/.lircrc file is attached here.

You need to put this file into your home folder.

The next step is to run irexec as a daemon. It will interpret .lircrc file and send the according commands. irexec must be executed as the user the commands (not as root). Once you login to your session, you need to:

Few things to notice about the .lircrc file provided above:

  1. it enables the KEY_ZOOM (named “Full screen” on remote) to simulate key ‘F’ in tvtime, by sending the command TOGGLE_FULLSCREEN to tvtime:
  2. It enables the KEY_VIDEO (named “Source” on the remote) to switch between the aspect ratio (4:3 to 16:9 and viceversa) useful for landscape LCD / LED screens:
  3. Most important is that the volume keys / mute keys are NOT sent to tvtime, but to the X11 server (and thus the volume up / down popup work!). This is done by faking the multimedia keys Volume Up / Volume Down / Mute keys:

To fake the system volume up / down keys, I used a program xsendkeycode which you have to install using command:

This program will simulate a keypress by using the given raw key code. 1 and 0 means key is pressed, then key is released. To find out the raw key code, the current key mapping has to be investigated:

As you can see, the XF86AudioLowerVolume has raw key code 123 on my system, XF86AudioRaiseVolume has raw key code 122 and XF86AudioMute has 121.

You need to update .lircrc file to match the values from your system, in case they are different.

The sample .lircrc configuration file from TVTime website is also wrong as it assumes some remote button key names (POWER, 1, 2 …) which do not exist. They are now named KEY_POWER, KEY_1, KEY_2 etc… To find out what remote command button names are used by lirc / irexec, execute irw as described at point c).

TVTime also supports various other commands, to find them all:

Thus, if you want to add support for brightness down, just add a new block into .lircrc file:

which, when you will press the red key on the remote (it has two black arrows pointing left) it will actually trigger brightness down in TVTime.

e) run irexec at login time

To have irexec executed at login time, just go to System -> Preferences -> Startup Applications and click Add:

irexec at startup / login

irexec at startup / login


This took me some figuring out since there are lots of outdated documentation, configuration files and tutorials out there. If you have any comments, please do not hesitate to post the. The trouble is that given the amount of systems, mappings, versions, etc, it is probably very difficult to make it work as on Windows (where everything worked flawless). Ubuntu still has a lot of catching up to do to bring true multimedia experience without any command line fiddling etc.

But now I have a fully working remote control.