TBS5980 (aka TBS Qbox CI)

From LinuxTVWiki
Jump to navigation Jump to search

The Qbox DVB-S2 CI USB2.0, as the name suggests, is a DVB-S2 USB 2.0 adapter from TurboSight. It has been on the market since early 2011. The company has no distribution network, but their products can be ordered online. Shipping of my device to Western Europe took less than three days.

The Qbox DVB-S2 CI is supported under Linux. The minimum required kernel version is (yet) unknown, the driver requires DVB version 5.1.

The Qbox CI switched on. The CAM module has not been inserted

Overview/Features

  • USB 2.0 interface (B-connector)
  • Inputs: Antenna (F-connector), remote and CI-slot
  • Separate power supply: 7.5V, 3.5A
  • Indication LED, mostly red, sometimes blue, meaning yet unknown.
  • CCM mode support ONLY (NO support for VCM and ACM modes used by a lot of DVB-S2 multistream Free TV channels with Eutelsat 5 West A (5°W) satellite)

Components Used

Other Images

Identification

lsusb output:

# lsusb -v
Bus 001 Device 009: ID 734c:5980 TBS Technologies China 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x734c TBS Technologies China
  idProduct          0x5980 
  bcdDevice            0.00
  iManufacturer           1 TBS-Tech
  iProduct                2 DVBS2BOX
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)

Making it Work

The device is actively supported to run under Linux. Every few months the driver gets updated, and the company actively supports users through a forum. By downloading, compiling and installing the drivers and firmware, the device works (at least, in my distro, Fedora 14 x86-64). Together with the manufacturer-supplied source code for scanning and zapping (slightly modified versions of scan-s2 and szap-s2) DVB-S2 reception works. Newer versions of szap and scan work just as well.

Firmware

The driver software package contains the firmware file: dvb-usb-tbsqbox-id5980.fw. Just install it in /lib/firmware.

Drivers

For linux with x86 or X86-64 CPU

Available here from TBS website. Look for the TBS5980 driver. Latest update: 29/12/2015. Apart from the firmware file, there is no closed-source object code included in the software. All code has been released under GPLv2.

For compiling and installing the Open-source drivers or the Closed-source drivers, see TBS driver installation.

For Linux with ARM CPU in Raspberry PI

WARNING : THIS INSTALLATION PROCESS IS A DRAFT, IT IS NOT FINISH YET. THIS WARNING MESSAGE WILL BE REMOVE WHEN THE INSTALLATION PROCESS WILL BE FULL

The open source driver is available here. Some instructions above are taken from http://www.satelliteguys.us/xen/threads/hobbyist-open-source-satellite-receiver-raspberry-pi-2-instructions-and-tips.348466/#post-3652518 but a lot of steps for installing and compiling are missing from this link.

You mustn't use the remote control because it use a lot of of CPU power.

Building the Open Source Driver

These instructions are taken from satelliteguys.us forum and Raspberry PI official website:

Compilation and Installation process with :
-Hardware : Raspberry Pi 2
-Operating System : Raspbian in NOOBS Version 1.9.1 Full and with the Release date: 2016-05-10

  • Check your Linux kernel release :
uname -r
  4.4.9-v7+

Note the major and minor kernel release number, here 4.4.

  • Update the package list available in distro repositories and then update the package installed on your system :
sudo apt-get update
sudo apt-get upgrade
  • Install the packages required to compile the TBS driver for Raspberry PI in his ARM CPU :
sudo apt-get install patchutils
sudo apt-get install bc
sudo apt-get install libncurses5-dev
sudo apt-get install git
sudo cpan Proc::processTable
 CPAN.pm requires configuration, but most of it can be done automatically.
 If you answer 'no' below, you will enter an interactive dialog for each
 configuration option instead.
 Would you like to configure as much as possible automatically? [yes] yes
  • Get the Linux kernel sources for Raspbian and then next the open source TBS driver

Note you must get the kernel sources for raspberry pi with the same release number than the release number in the output of the previously used uname command, here 4.4 for the file rpi-4.4.y.tar.gz.

sudo su - root
ls /etc/modprobe.d/
  fbdev-blacklist.conf  ipv6.conf  libpisock9.conf  raspi-blacklist.conf
cd /usr/src
wget https://github.com/raspberrypi/linux/archive/rpi-4.4.y.tar.gz
tar xzvf rpi-4.4.y.tar.gz
ls /usr/src/linux-rpi-4.4.y
cd /root
git clone --depth=1 https://github.com/ljalves/linux_media.git -b latest ./media
  • Copy driver sources into kernel source directories

Note : As of 6/6/2016, the following files below are the same in /root/media/drivers/ and /usr/src/linux-rpi-4.4.y/drivers folders, except for stv090x.c, stv090x.h . These files in /root/media/drivers/ are patched and have an adding for lock led hooks to the stv090x, stv0288, cx24116 and tda10071 frontends. Similar code already exists in the stv0900 frontend. source code patch.
For the file technisat-usb2.c, the line .count = 4 are replaced by .count = 8.
Note 2 : As of 6/6/2016, tbs-qbox2ci.c and tbs-qbox2ci.h files, for the TBS 5980 driver, are only available in /root/media/drivers/ from https://github.com/ljalves/linux_media.git repositories.

cp /root/media/drivers/media/dvb-frontends/stv6110x.c /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stv6110x.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stv6110x_priv.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stv6110x_reg.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends

.

cp /root/media/drivers/media/dvb-frontends/stv090x.c /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stv090x.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stv090x_priv.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stv090x_reg.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends

.

cp /root/media/drivers/media/dvb-frontends/stb6100.c /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stb6100.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stb6100_proc.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends
cp /root/media/drivers/media/dvb-frontends/stb6100_cfg.h /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends

.

cp /root/media/drivers/media/usb/dvb-usb/technisat-usb2.c /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb

.

cp /root/media/drivers/media/usb/dvb-usb/tbs-qbox2ci.c /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb
cp /root/media/drivers/media/usb/dvb-usb/tbs-qbox2ci.h /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb
  • Remove the old modules if they exist so the new ones will get made
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv6110x.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv6110x.ko
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv6110x.mod.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv6110x.mod.c

.

rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv090x.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv090x.ko
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv090x.mod.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stv090x.mod.c

.

rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stb6100.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stb6100.ko
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stb6100.mod.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/dvb-frontends/stb6100.mod.c

.

rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/tbs-qbox2ci.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/tbs-qbox2ci.ko
rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/tbs-qbox2ci.mod.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/tbs-qbox2ci.mod.c

.

rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/technisat-usb2.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/technisat-usb2.ko
rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/technisat-usb2.mod.o
rm /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/technisat-usb2.mod.c

  • Patching the kernel source code :

There are 3 patchs to apply to fix several problems.

Patch 1 : To avoid the following error :

 CC [M]  drivers/media/dvb-frontends/stv090x.o
drivers/media/dvb-frontends/stv090x.c:3738:54: error: unknown type name ‘fe_sec_tone_mode_t’
 static int stv090x_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
                                                     ^
drivers/media/dvb-frontends/stv090x.c:3828:63: error: unknown type name ‘fe_sec_mini_cmd_t’
 static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst)
                                                              ^
drivers/media/dvb-frontends/stv090x.c:4920:24: error: ‘stv090x_send_diseqc_burst’ undeclared here (not in a function)
 .diseqc_send_burst  = stv090x_send_diseqc_burst,
                       ^
drivers/media/dvb-frontends/stv090x.c:4922:16: error: ‘stv090x_set_tone’ undeclared here (not in a function)
 .set_tone   = stv090x_set_tone,
               ^
drivers/media/dvb-frontends/stv090x.c: In function ‘stv090x_attach’:
drivers/media/dvb-frontends/stv090x.c:4991:3: error: implicit declaration of function ‘stv090x_send_diseqc_burst’ [-Werror=implicit-function-declaration]
  stv090x_send_diseqc_burst(&state->frontend, SEC_MINI_A);
  ^
cc1: some warnings being treated as errors
scripts/Makefile.build:264: recipe for target 'drivers/media/dvb-frontends/stv090x.o' failed

In the file media/drivers/media/dvb-frontends/stv090x.c , you must replace the line 3735

static int stv090x_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)

by

static int stv090x_set_tone(struct dvb_frontend *fe, enum fe_sec_tone_mode tone)

and the line 3825

static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst)

by

static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, enum fe_sec_mini_cmd burst)

or if you to use the command patch :

# diff -Naur /opt/raspberry-kernel/media/drivers/media/dvb-frontends/stv090x.c drivers/media/dvb-frontends/stv090x.c
--- /opt/raspberry-kernel/media/drivers/media/dvb-frontends/stv090x.c   2016-06-03 21:27:46.089160190 +0200
+++ drivers/media/dvb-frontends/stv090x.c       2016-06-06 20:50:22.982381627 +0200
@@ -3735,7 +3735,7 @@
       return 0;
}

-static int stv090x_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
+static int stv090x_set_tone(struct dvb_frontend *fe, enum fe_sec_tone_mode tone)
{
       struct stv090x_state *state = fe->demodulator_priv;
       u32 reg;
@@ -3825,7 +3825,7 @@
       return -1;
}

-static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t burst)
+static int stv090x_send_diseqc_burst(struct dvb_frontend *fe, enum fe_sec_mini_cmd burst)
{
       struct stv090x_state *state = fe->demodulator_priv;
       u32 reg, idle = 0, fifo_full = 1;


Patch 2 : To avoid the following error :

CC [M]  drivers/media/usb/dvb-usb/technisat-usb2.o
drivers/media/usb/dvb-usb/technisat-usb2.c:456:3: error: unknown type name ‘fe_sec_voltage_t’
  fe_sec_voltage_t voltage)
  ^
drivers/media/usb/dvb-usb/technisat-usb2.c: In function ‘technisat_usb2_frontend_attach’:
drivers/media/usb/dvb-usb/technisat-usb2.c:554:40: error: ‘technisat_usb2_set_voltage’ undeclared (first use in this function)
   a->fe_adap[0].fe->ops.set_voltage = technisat_usb2_set_voltage;
                                       ^
drivers/media/usb/dvb-usb/technisat-usb2.c:554:40: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.build:258: recipe for target 'drivers/media/usb/dvb-usb/technisat-usb2.o' failed
make[4]: *** [drivers/media/usb/dvb-usb/technisat-usb2.o] Error 1
scripts/Makefile.build:403: recipe for target 'drivers/media/usb/dvb-usb' failed

In the file drivers/media/usb/dvb-usb/technisat-usb2.c , you must replace the line 456

 fe_sec_voltage_t voltage)

by

enum fe_sec_voltage voltage)

Patch 3 : To avoid the following error :

 CC [M]  drivers/media/usb/dvb-usb/tbs-qbox2ci.o
drivers/media/usb/dvb-usb/tbs-qbox2ci.c:504:2: error: unknown field ‘set_lock_led’ specified in initializer
 .set_lock_led = tbsqbox2ci_led_ctrl,
 ^
drivers/media/usb/dvb-usb/tbs-qbox2ci.c:504:2: warning: initialization from incompatible pointer type
drivers/media/usb/dvb-usb/tbs-qbox2ci.c:504:2: warning: (near initialization for ‘earda_config.tuner_set_bbgain’)
drivers/media/usb/dvb-usb/tbs-qbox2ci.c:559:7: error: unknown type name ‘fe_sec_voltage_t’
      fe_sec_voltage_t voltage)
      ^
drivers/media/usb/dvb-usb/tbs-qbox2ci.c: In function ‘tbsqbox2ci_frontend_attach’:
drivers/media/usb/dvb-usb/tbs-qbox2ci.c:591:38: error: ‘tbsqbox2ci_set_voltage’ undeclared (first use in this function)
   d->fe_adap->fe->ops.set_voltage = tbsqbox2ci_set_voltage;
                                     ^
drivers/media/usb/dvb-usb/tbs-qbox2ci.c:591:38: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.build:258: recipe for target 'drivers/media/usb/dvb-usb/tbs-qbox2ci.o' failed
make[4]: *** [drivers/media/usb/dvb-usb/tbs-qbox2ci.o] Error 1
scripts/Makefile.build:403: recipe for target 'drivers/media/usb/dvb-usb' failed

In the file drivers/media/usb/dvb-usb/tbs-qbox2ci.c , you must replace the line 559

fe_sec_voltage_t voltage)

by

enum fe_sec_voltage voltage)

  • Add information about a new driver in the first configuration file for compiling

Make additions to Makefiles and Kconfigs so system will process the code The <tab> means remove the <tab> and then hit the tab key, you are trying to format the additions to look like whats already there. Same with <2 spaces> Add the following to the /usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/Kconfig file at the end

config DVB_USB_TBSQBOX2CI
<tab>tristate "TurboSight QBOX2 CI DVB-S2 USB2.0 support"
<tab>depends on DVB_USB
<tab>select DVB_PLL if MEDIA_SUBDRV_AUTOSELECT
<tab>select DVB_STV090x if MEDIA_SUBDRV_AUTOSELECT
<tab>select DVB_STB6100 if MEDIA_SUBDRV_AUTOSELECT
<tab>help
<tab><2 spaces>Say Y here to support the TurboSight QBOX2 CI DVB-S USB2.0 receivers
  • Add information about a new driver in the second configuration file for compiling

Add to the end of/usr/src/linux-rpi-4.4.y/drivers/media/usb/dvb-usb/Makefile before the first ccflags-y statement

dvb-usb-tbsqbox2ci-objs := tbs-qbox2ci.o
obj-$(CONFIG_DVB_USB_TBSQBOX2CI) += dvb-usb-tbsqbox2ci.o
  • Add information about a new driver in the third configuration file for compiling

Edit the /usr/src/linux-rpi-4.4.y/arch/arm/configs/bcm2709_defconfig file and under the line CONFIG_DVB_USB_TECHNISAT_USB2=m, add the line

CONFIG_DVB_USB_TBSQBOX2CI=m
  • If exist, back up the .config file
cp /usr/src/linux-rpi-4.4.y/.config /usr/src/linux-rpi-4.4.y/.config.tbs2ci.bak
  • Compiling for Raspberry PI 1 with the Raspberry Pi 1 (or Compute Module) Default Build Configuration
cd /usr/src/linux-rpi-4.4.y
export KERNEL=kernel
make bcmrpi_defconfig
make
  • Compiling for Raspberry PI 2 or 3 with the Raspberry Pi 2/3 Default Build Configuration
cd /usr/src/linux-rpi-4.4.y
export KERNEL=kernel7
make bcm2709_defconfig
make -j4
  • Save the current headers and modules files :
mv /lib/modules/4.4.9+ /lib/modules/4.4.9+.bak
mv /lib/modules/4.4.9-v7+ /lib/modules/4.4.9-v7+.bak
make modules
make modules_install
make headers_install
  • Select the new kernel with TBS5980 support

Make sure you backup your old /boot/kernel.img

cp arch/arm/boot/zImage /boot/kerneltbsci.img
nano /boot/config.txt
 #add the following:
 kernel=kerneltbsci.img
  • Install the firmware file required by TBS5980 driver

Go to http://www.tbsdtv.com/products/tbs5980-dvb-s2-ci-tv-tuner-usb.html, tab Download, download the linux driver in the zip archive, get the dvb-usb-tbsqbox-id5980.fw file and copy it /lib/firmware

cd /usr/src
mkdir tbs5980-firmware
cd tbs5980-firmware
wget http://www.tbsdtv.com/download/document/common/tbs-linux-sources_v151229.zip
unzip tbs-linux-sources_v151229.zip
cp dvb-usb-tbsqbox-id5980.fw /lib/firmware
  • Avoid high CPU usage :

source: In order to avoid a high CPU usage, you should disable the IR receiver: In /etc/modprobe.d/options add the line :

options dvb_usb disable_rc_polling=1
  • Reboot
shutdown -r now
  • Check information about TBS 5980 in kernel log :
dmesg | grep 5980
dmesg | grep TBS

Sample Kernel Output

The kernel outputs the information below, CAM module inserted (with module verbosity wide open):

# dmesg
[18814.387092] usb 1-7: new high speed USB device using ehci_hcd and address 9
[18814.502322] usb 1-7: New USB device found, idVendor=734c, idProduct=5980
[18814.502334] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[18814.502343] usb 1-7: Product: DVBS2BOX
[18814.502349] usb 1-7: Manufacturer: TBS-Tech
[18814.684522] dvb-usb: found a 'TBS Qbox DVB-S2 CI USB2.0' in cold state, will try to load a firmware
[18814.688745] dvb-usb: downloading firmware from file 'dvb-usb-tbsqbox-id5980.fw'
[18814.691532] tbsqbox2ci: start downloading TBSQBOX2CI firmware
[18814.810199] dvb-usb: found a 'TBS Qbox DVB-S2 CI USB2.0' in warm state.
[18814.810330] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[18814.810751] DVB: registering new adapter (TBS Qbox DVB-S2 CI USB2.0)
[18815.048073] dvb-usb: MAC address: xx:xx:xx:xx:xx:xx (edited by me)
[18815.048077] 
[18815.050881] stv090x_attach: Create New Internal Structure!
[18815.156679] stv090x_attach: Attaching STV0903 demodulator(1) Cut=0x30
[18815.156689] tbsqbox2ci: Attached stv0903!
[18815.156692] 
[18815.157478] tbsqbox2ci: CI initialized.
[18815.157488] DVB: registering adapter 0 frontend 0 (STV090x Multistandard)...
[18815.157590] stb6100_attach: Attaching STB6100 
[18815.159811] input: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:1d.7/usb1/1-7/input/input12
[18815.159952] dvb-usb: schedule remote query interval to 150 msecs.
[18815.159961] dvb-usb: TBS Qbox DVB-S2 CI USB2.0 successfully initialized and connected.
[18815.160051] usbcore: registered new interface driver tbsqbox2ci
[18861.422201] tbsqbox2ci: CI enabled.
[18861.422211] dvb_ca adapter 0: DVB CAM detected and initialised successfully

To get maximum verbosity, relevant parts of /etc/modprobe.d/modprobe.conf were set as follows:

options dvb_usb debug=511
options dvb_usb_tbsqbox2ci debug=3
options stb6100 verbose=3
options stv090x verbose=3

Remote Control Support

The device comes with a remote, but that has not been tested yet. Tbsdtv forum members complain about poor interoperability with LIRC.

External Links

Issues

Remote control needs further research.

CAM support is underway. So far, the astoncrypt v1.07 has been tested. Before this can be finalized, a working smartcard is required. Haven't got one yet ;-).

Network support has not been addressed yet.