KWorld Global TV Terminator

From MythTV Official Wiki
Revision as of 12:17, 22 October 2008 by Meaje (talk | contribs) (General)

Jump to: navigation, search

General

(Version: VS-LTV7131RF) This (very inexpensive) card has been successfully set up on FC6 and FC8. Also has an FM tuner and an IR receiver and remote. The MSI TV@nywhere Plus PCI is nearly identical to the KWorld Global TV Terminator. I have also found that the KWorld TV Studio Terminator is also compatible with these directions.

Card information:

# lspci -v
06:02.0 Multimedia controller: Philips Semiconductors SAA7133/SAA7135 Video Broadcast Decoder (rev d1)
        Subsystem: Philips Semiconductors Unknown device 0000
        Flags: bus master, medium devsel, latency 32, IRQ 18
        Memory at 50004800 (32-bit, non-prefetchable) [size=2K]
        Capabilities: [40] Power Management version 2

-Or (KWorld TV Studio Terminator):
# lspci -v
00:08.0 Multimedia controller: Philips Semiconductors SAA7133/SAA7135 Video Broadcast Decoder (rev d0)
        Flags: bus master, medium devsel, latency 64, IRQ 24
        Memory at fbfff800 (32-bit, non-prefetchable) [size=2K]
        Capabilities: [40] Power Management version 2
        Kernel modules: saa7134

Audio capture device information:

# arecord -l
card 1: SAA7134 [SAA7134], device 0: SAA7134 PCM [SAA7134 PCM]
  Subdevices: 0/1
  Subdevice #0: subdevice #0

Assuming your soundcard is card 0 add the following to /etc/modprobe.conf (or /etc/modprobe.d/saa7134). This code block will auto install the saa7134 modules as sound card 1, (allowing the video to fall where it may usually /dev/video0). This means that to access the audio input stream you would select /dev/dsp1 as your audio input:

options saa7134 card=65 tuner=54
alias snd-card-1 saa7134-alsa
options snd-card-1 index=1
install saa7134 /sbin/modprobe --ignore-install saa7134; \
        /sbin/modprobe saa7134-alsa
remove saa7134-alsa { /usr/sbin/alsactl store SAA7134 >/dev/null 2>&1 || : ; }; \
        /sbin/modprobe -r --ignore-remove saa7134-alsa
# ---------
# Use the above if you don't need DVB or the below if you do need DVB
# NOTE: DO NOT USE BOTH THE ABOVE AND BELOW PICK ONE! YOU HAVE BEEN WARNED!
# ---------
# Changes made 2008/10/22 by meaje based on mythtv.org/wiki/index.php/KWorld_Global_TV_Terminator
# - modifications to autoinstall the dvb modules as well -> meaje
options saa7134 card=65 tuner=54 i2c_scan=1
alias snd-card-1 saa7134-alsa
options snd-card-1 index=1
install saa7134 /sbin/modprobe --ignore-install saa7134; \
        /sbin/modprobe saa7134-alsa
remove saa7134 /sbin/modprobe -r saa7134-alsa; \
        /sbin/modprobe -r --ignore-remove saa7134
install saa7134-alsa /sbin/modprobe --ignore-install saa7134-alsa; \
        { /usr/sbin/alsactl restore SAA7134 >/dev/null 2>&1 || : ; }; \
        /sbin/modprobe saa7134-dvb
remove saa7134-alsa { /usr/sbin/alsactl store SAA7134 >/dev/null 2>&1 || : ; }; \
        /sbin/modprobe -r saa7134-dvb; \
        /sbin/modprobe -r --ignore-remove saa7134-alsa

Use v4lctl to display/set the card attributes: Note this may not work for users who are using v4l2-ctl as the output has changed. If you find yourself using v4l2-ctl try using the '--all' switch to see the output but be warned that things are not formatted the same. - meaje 2008-10-22

[root@sandbox ~]# v4lctl list
attribute  | type   | current | default | comment
-----------+--------+---------+---------+-------------------------------------
norm       | choice | NTSC    | PAL     | PAL PAL-BG PAL-I PAL-DK NTSC SECAM PAL-M PAL-Nc PAL-60
input      | choice | Televis | Televis | Television Composite1 S-Video
audio mode | choice | mono    | mono    | mono stereo lang1 lang2
bright     | int    |     127 |     128 | range is 0 => 255
contrast   | int    |      67 |      68 | range is 0 => 127
color      | int    |      63 |      64 | range is 0 => 127
hue        | int    |       0 |       0 | range is -128 => 127
volume     | int    |      12 |       0 | range is -15 => 15
mute       | bool   | off     | off     |
Mirror     | bool   | off     | off     |
Invert     | bool   | off     | off     |
y offset o | int    |       0 |       0 | range is 0 => 128
y offset e | int    |       0 |       0 | range is 0 => 128
automute   | bool   | on      | on      |

-- v4l2-ctl (New Format Output) --
# v4l2-ctl -all
Driver Info:
        Driver name   : saa7134
        Card type     : V-Stream Studio TV Terminator
        Bus info      : PCI:0000:00:08.0
        Driver version: 526
        Capabilities  : 0x05010015
                Video Capture
                Video Overlay
                VBI Capture
                Tuner
                Read/Write
                Streaming
Format Video Capture:
        Width/Height  : 720/576
        Pixel Format  : BGR3
        Field         : Interlaced
        Bytes per Line: 2160
        Size Image    : 1244160
        Colorspace    : Unknown (00000000)
Format Video Overlay:
        Left/Top    : 0/0
        Width/Height: 0/0
        Field       : Any
        Chroma Key  : 0x00000000
        Global Alpha: 0x00
        Clip Count  : 0
        Clip Bitmap : No
Format VBI Capture:
        Sampling Rate   : 27000000 Hz
        Offset          : 256 samples (9.48148e-06 secs after leading edge)
        Samples per Line: 2048
        Sample Format   : GREY
        Start 1st Field : 7
        Count 1st Field : 16
        Start 2nd Field : 319
        Count 2nd Field : 16
Framebuffer Format:
        Capability    : Clipping List
        Flags         : 
        Width         : 0
        Height        : 0
        Pixel Format  : 
        Bytes per Line: 0
        Size image    : 0
        Colorspace    : Unknown (00000000)
Crop Capability Video Capture:
        Bounds      : Left 0, Top 46, Width 720, Height 578
        Default     : Left 0, Top 48, Width 720, Height 576
        Pixel Aspect: 54/59
Crop: Left 0, Top 48, Width 720, Height 576
Video input : 0 (Television)
Audio input : 0 (audio)
Frequency: 0 (0.000000 MHz)
Video Standard = 0x000000ff
        PAL-B/B1/G/H/I/D/D1/K
Tuner:
        Capabilities         : 62.5 kHz multi-standard stereo lang1 lang2 
        Frequency range      : 0.0 MHz - 268435455.9 MHz
        Signal strength      : 0%
        Current audio mode   : mono
        Available subchannels: mono 

If you setup saa7134-alsa as card 1 you will refer to it as /dev/dsp1 in mythtv-setup when setting up the capture card.

+-------------+-------------+----------+--------------+----------------+
| videodevice | audiodevice | cardtype | defaultinput | audioratelimit |
+-------------+-------------+----------+--------------+----------------+
| /dev/video0 | /dev/dsp1   | V4L      | Television   |          32000 |
+-------------+-------------+----------+--------------+----------------+

Remote

The remote has 36 buttons of which 32 send unique codes. The remote is not fully supported in the kernel but the knowledge exists on how to get it working by patching the kernel. It is apparently a combined GPIO/i2c remote and a patch has been posted to the v4l mailing list and modified a few times for similar remotes (see Henry Wong patch). There are changes needed in the ir-kbd-i2c and saa7134 modules. Here is a full description on how I got the remote working with Fedora 7 and the 2.6.22 kernel: Terminator Remote Kernel Patch Fedora HOWTO

Here are alternative versions of Henry Wong's patch: Ubuntu Feisty Ubuntu Hardy (kernel 2.6.24) Debian Etch

Problems

Video but no sound? You may need to turn the volume up on the capture. Assuming /dev/dsp1 again run the following command:

[root@sandbox ~]# alsamixer -c 1

Not working in MythTV? Try it with mplayer. If this works (you may need to modify device, chanlist, adevice, or norm) then you have MythTV misconfigured somehow.

mplayer tv://"insert channel" -tv driver=v4l2:device=/dev/video0:chanlist=us-cable:alsa:\
adevice=hw.1,0:amode=1:audiorate=32000:forceaudio:volume=100:immediatemode=0:norm=NTSC

HOWTO with Mythdora

This is a How To for setting this card up in MythDora(specifically 4.0). Much of this was taken from the wiki already and this is just here to make it easier to decipher which commands should be used and also to show that it works when hardware shopping. It was written on 08/03/07.

Video

Uses the saa7134 driver, which will automatically be loaded by Mythdora, but you need to pass the parameters card=65 tuner=54 when the module is loaded. To do this automatically, create a file called saa7134 in /etc/modprobe.d/ with the following contents:

options saa7134 card=65 tuner=54

Now every time the module is loaded, it will be passed these parameters.

You should now see your card show up in the Mythtv setup of capture cards.

I am not certain that this is correct, but I used it as a V4L capture card and it worked.

Audio

Unlike Knoppmyth Mythdora uses the saa7134-alsa module. However it usually starts with the volume turned all the way down. Use the fix below to adjust the sound of the card:

This is assuming the audio of the card is /dev/dsp1 (if not change the 1 at the end to the card number) again run the following command:

[root@sandbox ~]# alsamixer -c 1

Finally to get sound working you may need to go into Utilities/Setup> Setup> General and on the 3rd page you will see info on how your sound is output from Mythtv. Make sure it is using the right soundcard and you may also have to change the Passthrough to the Alsa option.

HOWTO with KnoppMyth

This is a mini HOWTO for getting the video, audio, and remote of the KWorld Global TV Terminator working with KnoppMyth (specifially, version 5E50). The information may be useful to other distributions. It was created on Feb 20, 2007.

Video

Uses the saa7134 driver, which will automatically be loaded by KnoppMyth, but you need to pass the parameters card=65 tuner=54 when the module is loaded. To do this automatically, create a file called saa7134 in /etc/modprobe.d/ with the following contents:

options saa7134 card=65 tuner=54

Now everytime the module is loaded, it will be passed these parameters.

That's it for video. You should now see your card show up in the KnoppMyth setup of capture cards.

Audio

A lot of the documentation I found said to use the saa7134-alsa module for sound; this module is not loaded by KnoppMyth by default, and I found that when I loaded it, it caused a kernel panic.

However, there is another module that provides sound for the saa7134 and that is saa7134-oss. This module worked great for me.

Loading this module should create /dev/dsp1 (or a higher number if another device is already using /dev/dsp1). You need to tell KnoppMyth to use this audio device in the capture card setup.

By default, the sound may be muted, the volume may be too low, and automute may be on (not sure what effect automute has). In order to ensure these settings allow sound to come through, you need to use the video4linux 2 control utility (v4l2-ctl) to change them:

# v4l2-ctl --set-ctrl=mute=0
# v4l2-ctl --set-ctrl=volume=10
# v4l2-ctl --set-ctrl=automute=0

This should be it to get audio working, but you'll probably want these steps to be taken every time the computer boots. To do this, I placed the following lines in /etc/init.d/rc.local (after the line ". /lib/lsb/init-functions"):

modprobe saa7134-oss
v4l2-ctl --set-ctrl=mute=0
v4l2-ctl --set-ctrl=volume=10
v4l2-ctl --set-ctrl=automute=0

and then added rc.local to the system startup by issuing the command:

# update-rc.d rc.local defaults

Remote

The remote is the most difficult piece to get to work. It requires patching the kernel.

In order to do this, you need to download the kernel source, which can be found at ftp://knoppmyth.net/R5/linux-source-2.6.18-chw-13_2.6.18-chw-13-10.00.Custom_all.deb

Install it with:

# dpkg -i linux-source-2.6.18-chw-13_2.6.18-chw-13-10.00.Custom_all.deb

This will create a .tar.bz2 file containing the source in /usr/src/ . Untar this file.

Now you'll need to apply some patches.

The heavy lifting is done by a patch by Henry Wong. I've modified it so that it applies cleanly to the kernel source we are working with. I've broken it into 5 parts:

KWorld_Global_TV_Terminator remote_control_part1.patch

KWorld_Global_TV_Terminator remote_control_part2.patch

KWorld_Global_TV_Terminator remote_control_part3.patch

KWorld_Global_TV_Terminator remote_control_part4.patch

KWorld_Global_TV_Terminator remote_control_part5.patch

You can apply these by cd'ing to the /usr/src/linux-source-2.6.18-chw-13 directory and running:

# patch -p1 < remote_control_part1.patch
# patch -p1 < remote_control_part2.patch
# patch -p1 < remote_control_part3.patch
# patch -p1 < remote_control_part4.patch
# patch -p1 < remote_control_part5.patch

This patch is successful in getting events delivered from the remote control. However, they always had the same keycode on my system and were thus useless.

In order to fix this, I wrote a patch which is a total hack. It results in a remote control that mostly works. Some buttons don't work and keypresses don't always register, but it's usable. You can find the patch here:

KWorld_Global_TV_Terminator rc_hack.patch

Note that this patch hacks part of the infrared subsystem, so you may want to be especially wary of using it if you have other infrared devices.

Apply this patch the same way you did the other patches:

# patch -p1 < rc_hack.patch

Now you'll need to recompile the kernel modules, but before you do this, you should backup your current modules (located in /lib/modules/2.6.18-chw-13). One way to do this is to move this directory to 2.6.18-chw-13.old . That way, restoring the modules is simply a matter of renaming it back.

Now go into /usr/src/linux-source-2.6.18-chw-13 and type "make menuconfig".

Scoll down and select "load an alternate configuration file".

Specify the file "/boot/config-2.6.18-chw-13".

Save and exit.

Compile the modules and install them in /lib/modules/2.6.18-chw-13 by typing "make modules && make modules_install".

Now run "depmod" to generate symbol information in the /lib/modules/2.6.18-chw-13 directory.

Go ahead and reboot. The modules important to the remote control should be automatically loaded by KnoppMyth.

If everything goes well you should be able to open a terminal, press the 1 key on your remote and see a 1 appear in the terminal (make sure that num lock is on).

You'll now have the following keys working and generating the following X keycodes:

power 222
scan 229
mute 160
recall 133
stop 232
play 179
<< 234
function 158
>> 233
vol+ 176
vol- 174
minimize 175
1 87
2 88
3 89
4 83
5 84
6 85
7 79
8 80
9 81
0 90
+ 86

In order for mythtv to make sense of these keys, you'll want to use xmodmap to map the keycodes to well-known keysyms. To do this, you need to create a file called /home/mythtv/.Xmodmap and you need to run "xmodmap /home/mythtv/.Xmodmap" every time X starts.

My .Xmodmap looks like this:

! power
keycode 222 = F1
! scan
keycode 229 = F2
! mute
keycode 160 = F3
! recall
keycode 133 = F4
! stop
keycode 232 = F5
! play
keycode 179 = F6
! <<
keycode 234 = F7
! function
keycode 158 = F8
! >>
keycode 233 = F9
! vol+
keycode 176 = F10
! vol-
keycode 174 = F11
! min
!keycode 175 = F12
keycode 175 = Return

! keypad
keycode 81 = 9
keycode 80 = 8
keycode 79 = 7
keycode 85 = 6
keycode 84 = 5
keycode 83 = 4
keycode 89 = 3
keycode 88 = 2
keycode 87 = 1
keycode 90 = 0
! plus
keycode 86 = equal

To get xmodmap to run every time X starts, I added the following line to /home/mythtv/.fluxbox/apps after the line "[startup] {xset -dpms s off}":

[startup] {xmodmap ~/.Xmodmap}

Now restart X to get the new mappings to load (ctrl-alt-backspace should do the trick).

mythtv should recognize the keys as if you pressed the corresponding key on the keyboard (Utilities/Setup->Edit Keys is where you bind keys to functions in mythtv BTW).

Resources