# DVB-T dongle



## balanga (Dec 15, 2017)

How do I find out if there is support for a particular DVB-T TV dongle?

`lsusb` shows:-

```
Bus /dev/usb Device /dev/ugen1.3: ID 048d:9006 Integrated Technology Express, Inc. IT9135 BDA Afatech DVB-T HDTV Dongle
```
Presumably if it was supported it would show up when running `pciconf -lv`...

I am able to use it with LibreElec on a Raspberry Pi. How would I go about using it on FreeBSD?


----------



## Phishfry (Dec 15, 2017)

I really think it has to be supported in this list to work:
https://wiki.freebsd.org/WebcamCompat

These dvb devices are complex with 3 layers of chips. MPEG/Tuner/Frontend
The driver has to support all three.. I had luck with PCIe cards on cx88 dvb driver but not with USB WINTV HVR-950Q(In webcamd list too)
Apparently WinTV HVR950Q has different hardware 'revisions'.


----------



## balanga (Dec 15, 2017)

Phishfry said:


> I really think it has to be supported in this list to work:
> https://wiki.freebsd.org/WebcamCompat



The last entry under DVB/ATC lists:


```
External USB DVB-T adapter

ITE Technologies

DVB-T TV Stick (identifies as "ITE Technologies, Inc." "DVB-T TV Stick")

0x048d:0x9006

webcamd(8)

DVB

FreeBSD

w_scan, VDR

Requires firmware dvb-usb-it9135-01.fw; dual tuner, second tuner now tested and seems to be working, remote not working
```

which suggests it might work....  How would I go about installing the required firmware?


----------



## balanga (Dec 15, 2017)

After copying 
http://palosaari.fi/linux/v4l-dvb/firmware/IT9135/ITE_3.25.0.0/dvb-usb-it9135-01.fw 
and 
http://palosaari.fi/linux/v4l-dvb/firmware/IT9135/ITE_3.25.0.0/dvb-usb-it9135-02.fw 
to 
/boot/modules as per https://wiki.freebsd.org/WebcamCompat 
and installing multimedia/webcamd I still don't have a /dev/dvb....

Any ideas what I've overlooked?


----------



## Phishfry (Dec 15, 2017)

Do you have cuse(3) loading on boot? 
I put cuse_load="YES" in loader.conf


----------



## balanga (Dec 15, 2017)

`cat loader.conf`

```
fuse_load="YES"
#i915kms_load="YES"
#kern.vt.fb.default_mode="1024x768"
umodem_load="YES"
if_cdce_load="YES"
kern.cam.scsi_delay=15000
u3g_load="YES"
cuse_load="YES"
```


----------



## Phishfry (Dec 16, 2017)

Also make sure you install these ports/packages:
multimedia/v4l_compat
multimedia/libv4l

You should install the firmware into the /boot/modules/ directory

https://gist.github.com/dreamcat4/32fac8eb6f5db515b68d

tingo has a write-up too:
https://sites.google.com/site/tingox/terratec_h7_freebsd


----------



## balanga (Dec 16, 2017)

Phishfry said:


> Do you have cuse(3) loading on boot?
> I put cuse_load="YES" in loader.conf



I have that line in /boot/loader.conf but cuse does not seem to load.

When I run `webcamd -d ugen0.3` I get:-

```
webcamd: Could not open /dev/cuse. Did you kldload cuse4bsd?
```
After running `kldload cuse` and then `webcamd -d ugen0.3` I get

```
Attached to ugen0.3[0]
webcamd: Cannot find USB device
```
`usbconfig -d ugen0.3` shows:-

```
ugen0.3: <USB Deivce ITE Technologies, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
```

I don't suppose the USB device can't be found because it is described as USB *Deivce* .... (just clutching at straws...)

Should the device show up when I run `pciconf -lv`? I don't see it.


----------



## hselasky@ (Dec 17, 2017)

Hi, If webcamd doesn't find it, the driver is likely not present in the code or maybe it is not compiled by default. You can try to grep the idVendor and idProduct values from the device descriptor in the webcamd sources. --HPS


----------



## balanga (Dec 17, 2017)

balanga said:


> `usbconfig -d ugen0.3` shows:-
> 
> ```
> ugen0.3: <USB Deivce ITE Technologies, Inc.> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (500mA)
> ...



After attaching the dongle to a Raspberry Pi running LibreELEC the output from `usb-devices` via `ssh` I get the following:-

```
T:  Bus=01 Lev=02 Prnt=02 Port=02 Cnt=03 Dev#=  8 Spd=480 MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=048d ProdID=9006 Rev=02.00
S:  Manufacturer=ITE Technologies, Inc.
S:  Product=USB Deivce
C:  #Ifs= 2 Cfg#= 1 Atr=80 MxPwr=500mA
I:  If#= 0 Alt= 0 #EPs= 4 Cls=ff(vend.) Sub=00 Prot=00 Driver=dvb_usb_af9035
I:  If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=01 Driver=usbhid
```

If I log in to thde TVHeadend Server, it identifies the TV Adapter as Afatech AF9033 (DVB-T)

and I see the files 
demux0     dvr0       frontend0  net0

under /dev/dvb/adapter0.

How would Linux identify the name of the adapter? The VID/PID is 048d:9006 but no name appears when running `usb-devices` (under Linux).

It seems that Linux uses a dvb_usb_af9035 driver, presumably this is chosen based on the VID/PID. What would be the equivalent on FreeBSD?


----------



## balanga (Dec 17, 2017)

hselasky@ said:


> Hi, If webcamd doesn't find it, the driver is likely not present in the code or maybe it is not compiled by default. You can try to grep the idVendor and idProduct values from the device descriptor in the webcamd sources. --HPS



I would try running `grep` if I had any idea as to where to find a list of the VID/PID values. I looked at the source but it's like searching for a needle in a haystack...


----------



## hselasky@ (Dec 18, 2017)

CONFIG_DVB_USB_AF9035=y  and  code location is media_tree/drivers/media/usb/dvb-usb-v2/af9035.c 

Try to have a look there.


----------



## balanga (Dec 18, 2017)

After inserting the same dongle in my ThinkPad T420 it seems to work!

I can't see what I may have done differently....


----------



## hselasky@ (Dec 18, 2017)

If the usbconfig tells the same about the device, maybe "webcamd_enable=YES" is not in your /etc/rc.conf ?


----------



## balanga (Dec 18, 2017)

hselasky@ said:


> If the usbconfig tells the same about the device, maybe "webcamd_enable=YES" is not in your /etc/rc.conf ?



I took out "webcamd_and enable=YES" to get a clearer idea as to what was happening been starting it manually specified the USB device to use on the command line.

I'll see if can get it working on my other computer now that I have a clearer idea as to how things work. It does seem fairly complicated getting all this working.


----------

