Digital TV (DVB, ATSC) on FreeBSD: A small guide

nox@

Developer
I just started writing this up, comments welcome! :)

Drivers:

There are at least three driver ports for digital TV providing the /dev/dvb api:

- multimedia/cx88 provides the /dev/dvb api for a few CX2388x-based PCI(e) DVB-T and ATSC tuners, see http://corona.homeunix.net/cx88wiki

- multimedia/sms1xxx-kmod provides the /dev/dvb api for a few Siano-based DVB tuners, see http://contribs.martymac.org

- multimedia/webcamd runs Linux v4l/dvb drivers in FreeBSD userland to access a lot of different USB DVB-T/T2/C/S/S2 and ATSC tuners, see http://wiki.freebsd.org/WebcamCompat for tuners people tested on FreeBSD and the linuxtv wiki for (incomplete) lists of more USB tuners that have good chances of working:
http://www.linuxtv.org/wiki/index.php/DVB-T_USB_Devices
http://www.linuxtv.org/wiki/index.php/DVB-T2_USB_Devices
http://www.linuxtv.org/wiki/index.php/DVB-S2_USB_Devices
http://www.linuxtv.org/wiki/index.php/DVB-S_USB_Devices
http://www.linuxtv.org/wiki/index.php/DVB-C_USB_Devices
http://www.linuxtv.org/wiki/index.php/ATSC_USB_Devices

To use webcamd:

Many tuners need firmware files, put them in /boot/modules. (See also http://wiki.freebsd.org/WebcamCompat and http://linuxtv.org/wiki/index.php/Firmware#Acquiring_the_Firmware.)
Then install the webcamd port, add your user to the webcamd group (and log it back in), make sure cuse4bsd.ko gets loaded (add it to /boot/loader.conf), add webcamd_enable="YES" to /etc/rc.conf, and plug in the tuner. Now you should see device nodes like /dev/dvb/adapter0/demux0, /dev/dvb/adapter0/dvr0 and /dev/dvb/adapter0/frontend0. If the tuner has a CI slot (for decoding crypted channels) you should also get /dev/dvb/adapter0/ca0. (I think for crypted channels you need VDR or maybe MythTV, and of course the right CAM and smartcard.)

You can build the webcamd port with the DEBUG knob and start it manually on a root shell with "-d x.y -H" to see log messages by the Linux drivers in case there are problems (run usbconfig as root to find the usbus x and device y the tuner is on.)

Some tuners need webcamd run with "-m dvb-usb-init.force_pid_filter_usage=1" to receive clean streams (you can put that in webcamd_flags in /etc/rc.conf), tho that breaks some methods of channel scanning like multimedia/w_scan and the scanning in multimedia/kaffeine so you need to restart webcamd (for example by re-plugging the tuner) with webcamd_flags commented out for the duration of the scan.

Receiving TV, now that you have /dev/dvb nodes:

- The easy (GUI) way: multimedia/kaffeine (This looks for the /dev/dvb nodes via hald which I think currently only works for webcamd when it's started with -H; and it should now also work for the cx88 drivers that meanwhile know about hald too.)

To use kaffeine for digital TV install the port, make sure hald and dbus are running and webcamd was started with -H (should be default), start kaffeine, select "Configure television", click on "Update scan data over the Internet", select your tuner and region (or satellite details), then select "Channels" and start a scan. If the scan finished without finding channels (and it's not the antenna setup) then check for missing firmware files and that webcamd isn't run with "-m dvb-usb-init.force_pid_filter_usage=1", see above for how to get logs from webcamd.
One you have setup your channel list (for example "copy filtered" w/o filters will copy all the found channels, then click "OK"), you can select "Digital Television" from the main menu and zap to your channels.

- The 'minimal' way: multimedia/w_scan and multimedia/mplayer

If you want to use mplayer make sure it's built with the V4L knob enabled and that you have a ~/.mplayer/channels.conf file. To get one you can use w_scan with 'scan' channels.conf type, i.e. that's -X . See the w_scan homepage http://wirbel.htpc-forum.de/w_scan/index_en.html for options and examples.

Once you have a channels.conf you can try: $ mplayer [url=dvb://]dvb://[/url]<channelname>

- The 'full-featured'/automated/networked way: multimedia/vdr and related ports:

This has its own page on the FreeBSD wiki: http://wiki.freebsd.org/VDR (and it's what I prefer. :) )

- The alternative 'full-featured'/automated/networked way: multimedia/mythtv and related ports:

This is probably preferred for ATSC. It has a page on the FreeBSD wiki too: http://wiki.freebsd.org/MythTV

Note there was a bug in the Linux dvb drivers used by webcamd < 3.9.0.1 affecting mythtv-setup, if that happens to you (symptom is a failed FE_GET_INFO ioctl) just update your webcamd port.

- Others:

There are more apps that can receive from /dev/dvb like vlc, xine, etc (some people even use Linux binaries like SageTV via the Linuxolator and multimedia/linux_dvbwrapper-kmod), but from what I tested VDR works best, closely followed by current kaffeine.
 
XBMC can be used for DVB too...

Btw you can also use XBMC to watch digital TV, currently that's via multimedia/xbmc-pvr using VDR backend as explained on the VDR wiki page http://wiki.freebsd.org/VDR, but once XMBC mainline 12.0 gets released PVR support will be merged there too so the main multimedia/xbmc port probably will be updated later to support it also. First using VDR as backend, but work has also started on porting tvheadend so maybe that can be used as PVR backend for XBMC later too.

Just thought I'd mention... :)
Juergen
 
Webcamd 3.9.0.1 now in ports

I just committed Hans' webcamd update so the MythTV bug should be history now...

(And there are a few more rtl28xxu-based tuners working for DVB among other things.)

Enjoy, :)
Juergen
 
Hi,
With wecamd 3.9.0.1 I could get my Hauppauge wintv-hvr-930c working for dvb-c and
dvb-t. I did not(yet) get analogue tv working.
To get the wintv-hvr-930c working, the webcamd port has to be reconfigured to build the
drxk module as well.
I used this http://lists.freebsd.org/pipermail/freebsd-multimedia/2012-March/012899.html post to know how to reconfigure the port to build more modules.
I use mencoder for recording and mplayer for playback and liveTV, unfortunatly no HW acceleration for my AMD zacate :(.
@ nox and hps : thx for all the efforts

regards,
Jan
 
Hello All,
Do you have any recommendations for a US-based (time warner)digital cable system dvb/atsc tuner card? I would like to use it on a network PVR using MythTV or VDR on an FreeBSD 9 box and view the content using a Raspberry Pi XBMC elsewhere on the network. An internal card would be preferable, but if USB is easier, that would be a consideration. Thank you.
P
 
patmcevoy said:
Hello All,
Do you have any recommendations for a US-based (time warner)digital cable system dvb/atsc tuner card? I would like to use it on a network PVR using MythTV or VDR on an FreeBSD 9 box and view the content using a Raspberry Pi XBMC elsewhere on the network. An internal card would be preferable, but if USB is easier, that would be a consideration. Thank you.
P
I'm not sure about https://en.wikipedia.org/wiki/QAM_(television) support (which afaik you need for U.S. cable) for PCI cards supported by multimedia/cx88 (see the list at http://corona.homeunix.net/cx88wiki/Overview/SupportedCards), but the one USB ATSC/QAM tuner listed on the wiki (https://wiki.freebsd.org/WebcamCompat), PCTV 801e SE, did work for cable channels transmitted in the clear for at least one guy too (QAM256, yes this isn't noted in the wiki yet), and it also seems to be not very expensive.

HTH, :)
Juergen
 
jandegr1 said:
Hi,
With wecamd 3.9.0.1 I could get my Hauppauge wintv-hvr-930c working for dvb-c and
dvb-t. I did not(yet) get analogue tv working.
To get the wintv-hvr-930c working, the webcamd port has to be reconfigured to build the
drxk module as well.
I used this http://lists.freebsd.org/pipermail/freebsd-multimedia/2012-March/012899.html post to know how to reconfigure the port to build more modules.
I use mencoder for recording and mplayer for playback and liveTV, unfortunatly no HW acceleration for my AMD zacate :(.
@ nox and hps : thx for all the efforts

regards,
Jan
You are welcome! :)

I just commited Hans' update to webcamd 3.9.0.4 that now also builds the drxk driver by default, do you want to test your tuner with 3.9.0.4 and send me an entry for the wiki? See here: https://wiki.freebsd.org/WebcamCompat#DVB.2FATSC

Thanx!
Juergen
 
nox@ said:
Btw you can also use XBMC to watch digital TV, currently that's via multimedia/xbmc-pvr using VDR backend as explained on the VDR wiki page http://wiki.freebsd.org/VDR, but once XMBC mainline 12.0 gets released PVR support will be merged there too so the main multimedia/xbmc port probably will be updated later to support it also. First using VDR as backend, but work has also started on porting tvheadend so maybe that can be used as PVR backend for XBMC later too.

Just thought I'd mention... :)
Juergen
This has finally happened, decke committed the multimedia/tvheadend and multimedia/xbmc-addon-pvr ports and I updated the multimedia/vdr-plugin-vnsiserver port so you now can use multimedia/xbmc with either tvheadend or VDR via the pvr.hts and pvr.vdr.vnsi addons installed by multimedia/xbmc-addon-pvr, respectively.

Note tvheadend needs the latest version of multimedia/cuse4bsd-kmod with kqueue(2) support, and like multimedia/w_scan and multimedia/kaffeine it cannot scan muxes when webcamd is run with "-m dvb-usb-init.force_pid_filter_usage=1" so it may not be the best solution for tuners that need that parameter to receive clean streams.

[Edit:] I forgot to mention that I also needed to set "Full mux reception" to "On" for tvheadend, or it wouldn't scan.

Enjoy, :)

Juergen
 
Have me moved on in the last seven years?
Most of these receivers will be USB devices these days. Store the firmware files for your device in /boot/modules. Then plug it in to see if webcamd will pick it up. If so, run multimedia/w_scan2 to produce a station list for your area. After that you can use mplayer or mpv (better) to watch tv. It should not be that difficult.

However, I have to change the webcamd source to make my CINERGY TC2 Stick TS Aggregator work. There are different USB devices out there that report the same vid:pid.
 
That list looks quite old indeed, mine from 2018 is not listed. I know numerous additions were made to multimedia/webcamd since 2015. If you want to know if a particular device is supported, you can grep the sources for its vendorID and productID. Run usbconfig -d <ugen...> dump_all_desc to find those ID's after plugging it in.
 
Webcamd is no longer maintained due to the passing away of HPS@.

That is a huge blow to DTV on FreeBSD.

The work that guy has in FreeBSD video is very useful. I hope it doesn't rot away.

Expect breakage. Much of this needs v4l.

That said the Conexant CX88 port at the very top here still works fine. PCI Cards only.
Docs are offline but the owner is responsive. I will attempt to contact him.
multimedia/cx88
 
Do I need multimedia/webcamd to bring this device to life?
Let's have a look.

# cd /usr/ports/multimedia/webcamd && make patch
This will give a subdirectory named 'work' that contains the sources including BSD patches. Now let's grep:

# grep -iR 048d:9006
This gives: ./work/webcamd-5.17.1.2/media_tree/Documentation/admin-guide/media/dvb-usb-af9035-cardlist.rst: - 048d:9006.
This is a good sign, but documentation is of course utterly useless, we're not here to rtfm. Let's try vendor ID 048d alone.

# grep -iR 048d
Lots of output now, with an interesting one: ./work/webcamd-5.17.1.2/media_tree/include/media/dvb-usb-ids.h:#define USB_VID_ITETECH 0x048d
The C language uses "#define" to give a name to a value. Here it gives the name USB_VID_ITETECH to hex value 048d, which is your vendor ID or VID. It tells us that in the C sources the name USB_VID_ITETECH will be used instead of hex value 048d. So let's grep for that name.

# grep -iR USB_VID_ITETECH
Five lines of output now,including this one: ./work/webcamd-5.17.1.2/media_tree/drivers/media/usb/dvb-usb-v2/af9035.c: { DVB_USB_DEVICE(USB_VID_ITETECH, USB_PID_ITETECH_IT9135_9006,
So we found the vendor. I don't see a hex value 0x9006 here, but I'm inclined to think there could be another #define with name USB_PID_ITETECH_IT9135_9006.

# grep -iR USB_PID_ITETECH_IT9135_9006
./work/webcamd-5.17.1.2/media_tree/include/media/dvb-usb-ids.h:#define USB_PID_ITETECH_IT9135_9006 0x9006

Nice. Time to clean up. make clean

Back to your question. It looks like multimedia/webcamd will happily swallow your device, but whether it will bring it to life remains to be seen. A few years ago many DVB broadcasters in Europe switched from video encoding H264 to H265, which rendered quite a few DVB-receivers useless. Don't know if yours is one of those. Another possible issue is that your device may need additional firmware (.fw files) in /boot/modules to work. You can start with multimedia/webcamd to find out.
 
Much appreciated. Looks like you have set me quite a bit of homework for the weekend.

I'm delving into uncharterred territory, but it's good to learn :).
 
Tieks , I tried following your suggestion and spent the best part of an hour building webcamd and managed to resolve several errors along the way but could manage to get a clean compile. However, following your investigate work, thought that support for my adapter already may already exist in the latest pkg, so I thought I'd see if my device actually did anything using the latest pkg.

I came across an interesting guide by vermaden which included how to set up webcamd


Unfortunately I can't get the webcamd service to start, and not sure if it produces a log or has a debug flag.
 
I came across an interesting guide by [FONT=monospace]vermaden[/FONT] which included how to set up webcamd
That's a useful link. A few remarks in addition to it. First, you can check if cuse.ko is indeed loaded (from /boot/loader.conf) with command kldstat. It should be listed in its output.

In his text vermaden refers to device entries /dev/video*. Those are entries made available by webcamd for a USB camera. For a DVB receiver you need entries like these:
Code:
/dev/dvb/adapterN/demuxN
/dev/dvb/adapterN/dvrN
/dev/dvb/adapterN/frontendN
To get these entries you may have to produce a webcamd_N_flags line in /etc/rc.conf the way vermaden describes. Also see man webcamd or file /usr/local/etc/rc.d/webcamd for that.

Once you have the right entries under /dev/dvb, you need to check the permissions. Adding your user(s) to the webcamd group should be enough.

Depending on the application(s) you plan to use (pwcview won't work with a DVB receiver) you may need a channels.conf. Port multimedia/w_scan2 can produce it.

You said you've spent the best part of an hour, so far without success. Don't worry, there will be a whole xmas holiday soon. :)
 
That's a useful link. A few remarks in addition to it. First, you can check if cuse.ko is indeed loaded (from /boot/loader.conf) with command kldstat. It should be listed in its output.

It does look like a very useful guide, and I'll study it carefully to get a much better understanding of webcamd's capabilities. It was written over two years ago, and one or two things may have changed. I didn't load cuse.ko myself although I found it was loaded somehow. No idea what it is for.


In his text vermaden refers to device entries /dev/video*. Those are entries made available by webcamd for a USB camera. For a DVB receiver you need entries like these:
Code:
/dev/dvb/adapterN/demuxN
/dev/dvb/adapterN/dvrN
/dev/dvb/adapterN/frontendN
To get these entries you may have to produce a webcamd_N_flags line in /etc/rc.conf the way vermaden describes. Also see man webcamd or file /usr/local/etc/rc.d/webcamd for that.

Once you have the right entries under /dev/dvb, you need to check the permissions. Adding your user(s) to the webcamd group should be enough.

Depending on the application(s) you plan to use (pwcview won't work with a DVB receiver) you may need a channels.conf. Port multimedia/w_scan2 can produce it.

At the moment I'm not even sure if the device is actually functional, let alone supported in FreeBSD, so I thought I'd first find out if LibreELEC

is able to use it, but I'm unable to locate the appropriate KODI PVR client, so I'll need find some Linux program which actually supports it.

This looked useful:-

https://linux-hardware.org/index.php?id=usb:048d-9006 in fact I should have started off by doing a direct look up from the output of the USB ID from lsusb. I note that usbconfig does not provide this.

The above page also includes a BSD link so I'm not sure whether to give up now... although I think I'll buy a new TV dongle, one which out to work with FreeBSD.

You said you've spent the best part of an hour, so far without success. Don't worry, there will be a whole xmas holiday soon. :)

I guess I won't get bored :)...
 
Back
Top