Saa713x devices: Generic SAA7134 Card Installation

From LinuxTVWiki
Revision as of 20:10, 11 June 2010 by Zebob (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To properly setup your saa7134-based tuner you need

  • SAA7134-based tvtuner
  • Not very old Linux (2.6.10 for analog card, 2.6.12 for dvb and hybrid card)
  • Some experience with setting linux programs and so on

Drivers compilation

In old good days it was very easy - you ought to checkout cvs, make and make install. Now it's a bit more complicated, but I suspect it should not stop you in the beginning. I would recommend you to use latest kernel like 2.6.16 or build mercurial development tree. It's actually more stable than kernel version. You can find instructions here [1], you can just receive latest tarball from web.

Then you need to run make. Problems may appear on this stage. For example, you may miss kernel development headers and need to install kernel-devel package or you have pretty outdated compiler and so on. Every trouble is often easily solvable moreover if you are familar with C. But feel free to ask for help.

Then you should run make install command from root. As a result the modules required like saa7134.ko will be copied to /lib/modules/your_kernel_version/drivers/media/video/.

To make remote work properly, please check that you have event interface enabled, it's enabled in most distributions by default.

Device Drivers => Input device support => Event interface <M>

Drivers probing

You should have the following lines in modprobe.conf

alias char-major-81 videodev
alias char-major-81-0 saa7134

This may be enough for the card to be deteced automatically. If not, recent kernels can use the i2c bus to improve hardware detection. Load the module with the following option:

modprobe saa7134 i2c_scan=1

If this produces the desired result, add it to your modules configuration setup to make it permanent. This setup differs by distribution. In Debian-based systems running the 2.6 kernel, add the option information to a file (typically called saa7134) in /etc/modprobe.d, for instance by issuing the following:

echo "options saa7134 i2c_scan=1" > /etc/modprobe.d/saa7134.conf

In Red Hat type systems, use the /etc/modules.d directory:

echo "options saa7134 i2c_scan=1" > /etc/modules.d/saa7134.conf

and run modules-update. Monitor your dmesg file on the next boot to verify that all cards are configured correctly.

Some cards and tuners may require manual configuration. For instance, tda9887 users may want to experiment with secam and pal options to correcly pass tvnorm to tuner and port options that may affect reception quality

options tda9887 secam=d port2=0 port1=1

If you'd like to get sound directly off the card (DMA transfer), load either the saa7134-alsa or the saa7134-oss module separately. The old oss=1 parameter isn't needed anymore.

Then you need to check that drivers are loaded properly. When you run command dmesg, it should have lines like:

Nov 15 14:39:18 shadow kernel: saa7134[0]: found at 0000:01:09.0, rev: 1, irq: 5, latency: 32, mmio: 0xea001000
Nov 15 14:39:18 shadow kernel: saa7134[0]: subsystem: 1461:9715, board: Avermedia AVerTV Studio 307 [card=45,autodetected]
Nov 15 14:39:18 shadow kernel: saa7134[0]: board init: gpio is 0
Nov 15 14:39:18 shadow kernel: saa7134[0]: registered input device for IR
Nov 15 14:39:18 shadow kernel: saa7134[0]: i2c eeprom 00: 61 14 15 97 ff ff ff ff ff ff ff ff ff ff ff ff
Nov 15 14:39:18 shadow kernel: saa7134[0]: i2c eeprom 10: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Nov 15 14:39:18 shadow kernel: saa7134[0]: i2c eeprom 20: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Nov 15 14:39:18 shadow kernel: saa7134[0]: i2c eeprom 30: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
Nov 15 14:39:18 shadow kernel: tuner: chip found at addr 0xc2 i2c-bus saa7134[0]
Nov 15 14:39:18 shadow kernel: tuner: type set to 51 (Philips PAL/SECAM_D (FM 1256 I-H3)) by saa7134[0]
Nov 15 14:39:18 shadow kernel: tda9885/6/7: chip found @ 0x86
Nov 15 14:39:18 shadow kernel: saa7134[0]: registered device video0 [v4l2]
Nov 15 14:39:18 shadow kernel: saa7134[0]: registered device vbi0
Nov 15 14:39:18 shadow kernel: saa7134[0]: registered device radio0
Nov 15 14:39:20 shadow kernel: saa7134[0]/audio: audio carrier scan failed, using 5.500 MHz [default]

Probably other messages are pointing you that you have troubles with drivers. Sometimes there are unresolved symbols. In that case you should return to compilation stage and try to fix that problem.

TvTime usage

For tv watching I prefer tvtime. You can also use mplayer or xawtv or whatever you like. But you can try tvtime also. Just download latest version from http://tvtime.net, build and install it.

After start tvtime will show you "No signal", thus select Input configuration/Television Standart/<your standard>, for example Secam. Select Channel Management/Frequency table/<Your country>. The with arrow keys increase volume label and choose channel. Channels that aren't received still shows "No signal". If your reception is bad you may try to remove signal detection. To do that in Channel management select Disable signal detection. You can also run autoscanning

Another very often problem is missed sound. It may be related to small "Line-in" volume level. By default it's muted, try to unmute it. You can test sound with headphones directly connected to tuner card.

Radio setup

There are many programs that work with radio. You can try kradio или gnomeradio even simply fmtools.

Radio is stereo by default, you can switch it to mono, the only problem is that this feature is not well supported in userspace yet.

Remote setup

Lirc setup is quite straight process, you can search lirc site for docs. You need to download at least lirc-0.7.0 from http://www.lirc.org, unpack it and build:


./configure --with-driver=any --prefix=/usr --sysconfdir=/etc && make && make install


p.s: On newers versions, the first step is execute

./setup.sh

1 Driver Configuration => For the Pinnacle ones, option "4 Other other serial port devices", For the others, option "5 TV Card".

Save the configuration and run make && make install.


Then in system config dir create a file lircd.conf(http://nshmyrev.narod.ru/aver/lircd.conf) and run lircd on system init. For example, you can place the following script in init.d (http://nshmyrev.narod.ru/aver/lircd). Please take care about the following - saa7134 module should be loaded before lircd (modprobe command) and lircd should start with option that sets the device that saa7134 creates saa7134 (in my case it's /dev/input/event3, because /dev/input/event0, /dev/input/event1 is a mouse, /dev/input/event2 - keyboard). You can run the command to find your actual layout

cat /proc/bus/input/devices

The you need to include in user session small program irexec -d (user-space daemon that will run actual commands) and create a config file .lircrc in home dir, for example this (http://nshmyrev.narod.ru/aver/lircrc)

I'll say a bit about udev setup. Sometimes input events are created in arbitrary order, then you use usb devices and hotplug keyboards. For example, usb joystick may be used and removed sometimes. First of all you need to find, where is the device for remote input, then try to investigate what udev thinks about that

For example, you get the following:

sergey@sergey:~$ udevinfo -a -p `udevinfo -q path -n /dev/input/event5`
udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.
device '/sys/class/input/event5' has major:minor 13:69
 looking at class device '/sys/class/input/event5':
   SYSFS{dev}="13:69"
follow the class device's "device"
 looking at the device chain at '/sys/devices/pci0000:00/0000:00:1e.0/0000:02:01.0':
   BUS="pci"
   ID="0000:02:01.0"
   SYSFS{class}="0x048000"
   SYSFS{device}="0x7130"
   SYSFS{irq}="21"
   SYSFS{local_cpus}="1"
   SYSFS{modalias}="pci:v00001131d00007130sv00001461sd00002115bc04sc80i00"
   SYSFS{subsystem_device}="0x2115"
   SYSFS{subsystem_vendor}="0x1461"
   SYSFS{vendor}="0x1131"

then you can use SYSFS{vendor}. On Debian Linux udev rules are held in /etc/udev/rules.d. There we create a new file, for example 10.local with the following content

KERNEL=="event*",SYSFS{vendor}=="0x1331",SYMLINK="irremote"

After that we restart udev

/etc/init.d/udev restart

And thus we get a symlink remote in /dev that shows the exact location of remote. This works only on newer kernels like 2.6.14

Using remote directly

Remote input is just an ordinary keyboard, with quite specific keys. You can try to use it without lirc with usual keybindings. Nobody did it, so some more info is very appreciated

The ideology is that keypress is passed to X server and needs to be processed as a usual keypress. The only problem is quite exotic keys. To create workaround, you probably need to setup xkb to make it generate real keycodes from scancodes that X server receives.