Watching TV on the XO 1.5 with a USB TV Tuner

A while ago, I got a crazy cheap ATI TV Wonder HD 600 USB TV Tuner from Woot for $20.  They’re still on Amazon for almost $50.  The original XO doesn’t even come close to having the horsepower to use it, but the XO 1.5 does.

Now why in the world would you want to watch TV on the XO?  Say the power goes out as a hurricane blows through, so your internet is down.  And you can’t find the batteries for your radio!  Well, get out your XO and watch your local weatherman freak out.  Or if a thunderstorm knocks out the power in the middle of the big football game, you’re not completely SOL.


Of course, you have to compile modules into the kernel.  I tried with 2.6.31 and it didn’t work, but a bit of research later I found out that it should work with later kernels.  Luckily you can get 2.6.35 from the git repository now.

git clone git://dev.laptop.org/olpc-2.6
cd olpc-2.6
git checkout origin/olpc-2.6.35

When I did up the config, I enabled the following modules.  How did I know which modules?  Well, I plugged the USB TV Tuner into my desktop and did lsmod to see what it was using.  Once I figured that out, I used xconfig, as it’s very easy to search and browse around.

Search for “dvb”
Enable “DVB For Linux” and “Support for various USB DVB devices”

Search for “em28xx” and enable:
Empia EM28xx USB video capture support
Empia EM29xx ALSA audio module
DVB/ATSC Support for em28xx based TV cards
Search for “2028” and enable “XCeive xc2028/xc3028 tuners”
Search for “5150” and enable “Texas Instruments TVP5150 video decoder”
Make sure “Video for Linux” is enabled as a module

Compile and install the kernel like usual.  You’ll also need the firmware linked from this page:

http://linuxtv.org/wiki/index.php/ATI/AMD_TV_Wonder_HD_600_USB

cd /lib/firmware
wget http://steventoth.net/linux/hvr1400/xc3028L-v36.fw

I’m using the mplayer I compiled for the XO 1.5 beforehand.  The only other dependency is:

yum install dvb-apps

So you’ve got all that and have booted into your custom 2.6.35 kernel.  If the XO 1.5 stalls booting, power it off, then power it back on while holding down the checkmark button.

Here’s what lsmod should give you when you plug in the TV tuner:

[olpc@192 ~]$ lsmod
Module                  Size  Used by
em28xx_dvb              4980  0
tda10023                5551  1 em28xx_dvb
zl10353                 5769  1 em28xx_dvb
lgdt330x                6534  1 em28xx_dvb
dvb_core               73123  2 em28xx_dvb,lgdt330x
em28xx_alsa             5487  0
tuner                  14221  1
tuner_xc2028           15854  2 em28xx_dvb,tuner
tvp5150                13279  1
em28xx                 72432  2 em28xx_dvb,em28xx_alsa
videobuf_vmalloc        3448  1 em28xx
tveeprom                9825  1 em28xx
fuse                   55004  2
xt_tcpudp               1903  3
iptable_filter          1040  1
ip_tables               7748  1 iptable_filter
x_tables               11658  3 xt_tcpudp,iptable_filter,ip_tables
uinput                  5920  1
via_camera             12914  0
v4l2_common            11909  4 tuner,tvp5150,em28xx,via_camera
videodev               34750  5 tuner,tvp5150,em28xx,via_camera,v4l2_common
v4l1_compat            12454  1 videodev
videobuf_dma_sg         6811  1 via_camera
videobuf_core          11770  4 em28xx,videobuf_vmalloc,via_camera,videobuf_dma_sg
mousedev                8370  0
psmouse                21485  0
serio_raw               3788  0
libertas_sdio           7341  0
libertas               70143  1 libertas_sdio
cfg80211              116798  1 libertas

And here are the device nodes it creates:

[olpc@192 ~]$ ls /dev/dvb/adapter0/
demux0  dvr0  frontend0  net0

Before you can watch TV, you’ll need to create your channel list.  This is for US broadcast stations.  Make sure to do this as the olpc user.

scandvb /usr/share/dvb-apps/atsc/us-NTSC-center-frequencies-8VSB > /home/olpc/channels.conf

You’ll get a bunch of “tuning failed!!” messages as it goes through all the frequencies.  This will also take several minutes.  Hopefully you’ll be able to pick up some channels.

[olpc@192 ~]$ cat channels.conf
WVTMDT:213000000:8VSB:49:52:3
WVTMRTV:213000000:8VSB:65:68:4
WTTO-CW:557000000:8VSB:49:52:3
WIAT-HD:569000000:8VSB:49:52:1
WIAT-DT:569000000:8VSB:65:68:2
WIAT WX:569000000:8VSB:81:84:3
WABM-HD:605000000:8VSB:49:52:3
WBRC:689000000:8VSB:49:52:3

Not too bad!  But I live at the base of Red Mountain where most of the area’s transmitters are located.  I took this picture from my backyard.

tv_transmitters

I’ve already set up my /home/olpc/.mplayer/config

[olpc@192 ~]$ cat /home/olpc/.mplayer/config
[default]
vo=sdl
ao=alsa
framedrop=1
lavdopts=skiploopfilter=all:fast=1 #DVD playback crashes with this

I copy channels.conf into /home/olpc/.mplayer so mplayer can see it.  I’m ready to watch TV!

mplayer -cache 8192 dvb://WBRC

Oh, look, here’s our crazy local weatherman wearing a ridiculous bow tie.

xotv
Since WBRC is the local Fox affiliate, I can change its line in channels.conf to

FOX:689000000:8VSB:49:52:3

…so I don’t have to remember the station call letters:

mplayer -cache 8192 dvb://FOX

This will use almost all of the XO 1.5’s CPU, so don’t plan on doing anything else while you’re watching TV.  And while playback is decent enough, it’s still going to be kinda jerky at times.

A couple of the HD channels here don’t want to play at the correct aspect ratio.  I started them up like this:

mplayer -cache 8192 -monitoraspect 3:4 dvb://CBS

Then maximized and restored the mplayer window to make the stream look pretty much OK.  You might have to drag the window down a bit as well.

If you want to take screenshots of the TV broadcast, add this to the mplayer command and you can hit “s” to take a screenshot to the current working directory.

-vf screenshot

Here’s a screenshot of our local Labor Day weekend forecast.  Apparently we’re supposed to “eat outside” on Saturday.  I’ll see if I can’t have lunch out on the porch, then.

eat_outside
Noted Issues:

Audio level is very low.  Run alsamixer as root (!?!) to max it up.

The camera doesn’t work, as the TV tuner takes over /dev/video0  Not sure if it’s due to the 2.6.35 kernel or compiling the TV tuner support.

Switching between Sugar and Gnome gives the message:
/bin/sh:  /sys/devices/platform/dcon/freeze: no such file or directory
… And there’s no dcon directory
Hit enter to get to a console, then “halt -p” and boot back up into Sugar or Gnome with the power and checkmark buttons.

A ZyDAS Wifi Adapter, an XO 1.5, and Kismet

Really, the main reason you’d want to use an external wifi adapter on the XO is so you can use the XO as a portable kismet machine.  The XO’s native wifi doesn’t support monitor mode.  I’ve got a cheapo ZyDAS wifi adaptor I got from Overstock.com a couple of years ago and luckily it works under Linux.  And on the XO with a bit of kernel mucking.


When you’re doing up your kernel config, enable these modules in this order:

cfg80211
mac80211
zd1211rw

Get the firmware from here:  http://sourceforge.net/projects/zd1211/files/

Extract the tarball and copy everything that starts with zd1211 into /lib/firmware/zd1211

Go into /etc/kismet/kismet.conf and edit the source to

source=zd1211,wlan0,ZyDAS USB

Change the log file directory in /etc/kismet/kismet.conf to /home/olpc/kismet cause otherwise it fusses about permissions for some reason.  Creating /var/log/kismet didn’t work for me.

mkdir /home/olpc/kismet
chmod 777 /home/olpc/kismet

Now root can

kismet

Here’s your proof!
kismet-xo

Compiling the XO 1.5 Kernel on an F11 Desktop

I tried, but couldn’t get this to work on the XO 1.5 itself.  But that gave me the impetus to finally get my dual boot Ubuntu Lucid / F11 machine sorted out.

As we all know, compiling a kernel takes a lot of dependencies and getting all those is usually the most time consuming part at first.  Once you get that covered, see what I did to compile and install a kernel on the XO 1.5 after the jump.


Make sure you do this as a normal user so you don’t accidentally hose something on your host machine.

Get the kernel source:

git clone git://dev.laptop.org/olpc-2.6
cd olpc-2.6
git checkout origin/olpc-2.6.31

Create your new config.  I like xconfig, but you can always use menuconfig instead.

make clean distclean
make xo_1.5_defconfig
make xconfig

I don’t know if all this is necessary, but I did this anyway cause I didn’t want to waste a bunch of compilation time just in case:

mv arch/x86/configs/xo_1.5_defconfig arch/x86/configs/xo_1.5_defconfig.original
cp .config arch/x86/configs/xo_1.5_defconfig
make clean distclean
make xo_1.5_defconfig

And finally:

make xo_1_5-kernel-rpm

This takes awhile, of course.  When it’s done, you’ll find the rpms in olpc/RPMS/i586.  Take these two over to the XO 1.5 and install them:

rpm -ivh kernel-firmware…rpm
rpm -ivh kernel…i586.rpm

Some stuff to do to get it to boot:

Go into /boot and make sure the initrd.img and vmlinuz symlinks were created correctly.

cd /boot
ls -lh

If you don’t do this, the XO 1.5 won’t boot into the new kernel

rsync –delete-before -av /boot/ /bootpart/boot/

While still in /boot, copy the new initrd and vmlinuz to /versions/pristine/NN/boot.  Replace the elipses with your kernel version and NN with your build version.

cp initrd…DIRTY.img vmlinuz…DIRTY.img /versions/pristine/NN/boot

Make your symlinks:

cd /versions/pristine/NN/boot
rm initrd.img vmlinuz
ln -sf initrd…DIRTY.img initrd.img
ln -sf vmlinuz…DIRTY.img vmlinuz

Reboot and you should see that lovely DIRTY kernel when you do uname -a

Dual Boot Ubuntu Lucid and F11

Here’s how I got this working:

Install Ubuntu like normal

Boot with a Live CD and use gparted to resize the Ubuntu partition, making a new partition with room for Fedora.  I went ahead and formatted it as ext3 in gparted.

Install Fedora on the partition you just created.  Install the boot loader on the Fedora partition.

After the Fedora install reboot, it’ll go into Ubuntu

sudo update-grub2

Now your grub menu will show Ubuntu and Fedora entries