162306a36Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 262306a36Sopenharmony_ci 362306a36Sopenharmony_ci.. _dvb_introdution: 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci************ 662306a36Sopenharmony_ciIntroduction 762306a36Sopenharmony_ci************ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci.. _requisites: 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciWhat you need to know 1362306a36Sopenharmony_ci===================== 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciThe reader of this document is required to have some knowledge in the 1662306a36Sopenharmony_ciarea of digital video broadcasting (Digital TV) and should be familiar with 1762306a36Sopenharmony_cipart I of the MPEG2 specification ISO/IEC 13818 (aka ITU-T H.222), i.e 1862306a36Sopenharmony_ciyou should know what a program/transport stream (PS/TS) is and what is 1962306a36Sopenharmony_cimeant by a packetized elementary stream (PES) or an I-frame. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciVarious Digital TV standards documents are available for download at: 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci- European standards (DVB): http://www.dvb.org and/or http://www.etsi.org. 2462306a36Sopenharmony_ci- American standards (ATSC): https://www.atsc.org/standards/ 2562306a36Sopenharmony_ci- Japanese standards (ISDB): http://www.dibeg.org/ 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciIt is also necessary to know how to access Linux devices and how to 2862306a36Sopenharmony_ciuse ioctl calls. This also includes the knowledge of C or C++. 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci.. _history: 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciHistory 3462306a36Sopenharmony_ci======= 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ciThe first API for Digital TV cards we used at Convergence in late 1999 was an 3762306a36Sopenharmony_ciextension of the Video4Linux API which was primarily developed for frame 3862306a36Sopenharmony_cigrabber cards. As such it was not really well suited to be used for Digital 3962306a36Sopenharmony_ciTV cards and their new features like recording MPEG streams and filtering 4062306a36Sopenharmony_ciseveral section and PES data streams at the same time. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciIn early 2000, Convergence was approached by Nokia with a proposal for a new 4362306a36Sopenharmony_cistandard Linux Digital TV API. As a commitment to the development of terminals 4462306a36Sopenharmony_cibased on open standards, Nokia and Convergence made it available to all 4562306a36Sopenharmony_ciLinux developers and published it on https://linuxtv.org in September 4662306a36Sopenharmony_ci2000. With the Linux driver for the Siemens/Hauppauge DVB PCI card, 4762306a36Sopenharmony_ciConvergence provided a first implementation of the Linux Digital TV API. 4862306a36Sopenharmony_ciConvergence was the maintainer of the Linux Digital TV API in the early 4962306a36Sopenharmony_cidays. 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciNow, the API is maintained by the LinuxTV community (i.e. you, the reader 5262306a36Sopenharmony_ciof this document). The Linux Digital TV API is constantly reviewed and 5362306a36Sopenharmony_ciimproved together with the improvements at the subsystem's core at the 5462306a36Sopenharmony_ciKernel. 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ci.. _overview: 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ciOverview 6062306a36Sopenharmony_ci======== 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci.. _stb_components: 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci.. kernel-figure:: dvbstb.svg 6662306a36Sopenharmony_ci :alt: dvbstb.svg 6762306a36Sopenharmony_ci :align: center 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci Components of a Digital TV card/STB 7062306a36Sopenharmony_ci 7162306a36Sopenharmony_ciA Digital TV card or set-top-box (STB) usually consists of the 7262306a36Sopenharmony_cifollowing main hardware components: 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciFrontend consisting of tuner and digital TV demodulator 7562306a36Sopenharmony_ci Here the raw signal reaches the digital TV hardware from a satellite dish or 7662306a36Sopenharmony_ci antenna or directly from cable. The frontend down-converts and 7762306a36Sopenharmony_ci demodulates this signal into an MPEG transport stream (TS). In case 7862306a36Sopenharmony_ci of a satellite frontend, this includes a facility for satellite 7962306a36Sopenharmony_ci equipment control (SEC), which allows control of LNB polarization, 8062306a36Sopenharmony_ci multi feed switches or dish rotors. 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ciConditional Access (CA) hardware like CI adapters and smartcard slots 8362306a36Sopenharmony_ci The complete TS is passed through the CA hardware. Programs to which 8462306a36Sopenharmony_ci the user has access (controlled by the smart card) are decoded in 8562306a36Sopenharmony_ci real time and re-inserted into the TS. 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_ci .. note:: 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ci Not every digital TV hardware provides conditional access hardware. 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ciDemultiplexer which filters the incoming Digital TV MPEG-TS stream 9262306a36Sopenharmony_ci The demultiplexer splits the TS into its components like audio and 9362306a36Sopenharmony_ci video streams. Besides usually several of such audio and video 9462306a36Sopenharmony_ci streams it also contains data streams with information about the 9562306a36Sopenharmony_ci programs offered in this or other streams of the same provider. 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciAudio and video decoder 9862306a36Sopenharmony_ci The main targets of the demultiplexer are audio and video 9962306a36Sopenharmony_ci decoders. After decoding, they pass on the uncompressed audio and 10062306a36Sopenharmony_ci video to the computer screen or to a TV set. 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_ci .. note:: 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_ci Modern hardware usually doesn't have a separate decoder hardware, as 10562306a36Sopenharmony_ci such functionality can be provided by the main CPU, by the graphics 10662306a36Sopenharmony_ci adapter of the system or by a signal processing hardware embedded on 10762306a36Sopenharmony_ci a Systems on a Chip (SoC) integrated circuit. 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_ci It may also not be needed for certain usages (e.g. for data-only 11062306a36Sopenharmony_ci uses like "internet over satellite"). 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ci:ref:`stb_components` shows a crude schematic of the control and data 11362306a36Sopenharmony_ciflow between those components. 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci.. _dvb_devices: 11862306a36Sopenharmony_ci 11962306a36Sopenharmony_ciLinux Digital TV Devices 12062306a36Sopenharmony_ci======================== 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_ciThe Linux Digital TV API lets you control these hardware components through 12362306a36Sopenharmony_cicurrently six Unix-style character devices for video, audio, frontend, 12462306a36Sopenharmony_cidemux, CA and IP-over-DVB networking. The video and audio devices 12562306a36Sopenharmony_cicontrol the MPEG2 decoder hardware, the frontend device the tuner and 12662306a36Sopenharmony_cithe Digital TV demodulator. The demux device gives you control over the PES 12762306a36Sopenharmony_ciand section filters of the hardware. If the hardware does not support 12862306a36Sopenharmony_cifiltering these filters can be implemented in software. Finally, the CA 12962306a36Sopenharmony_cidevice controls all the conditional access capabilities of the hardware. 13062306a36Sopenharmony_ciIt can depend on the individual security requirements of the platform, 13162306a36Sopenharmony_ciif and how many of the CA functions are made available to the 13262306a36Sopenharmony_ciapplication through this device. 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ciAll devices can be found in the ``/dev`` tree under ``/dev/dvb``. The 13562306a36Sopenharmony_ciindividual devices are called: 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci- ``/dev/dvb/adapterN/audioM``, 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci- ``/dev/dvb/adapterN/videoM``, 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci- ``/dev/dvb/adapterN/frontendM``, 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci- ``/dev/dvb/adapterN/netM``, 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci- ``/dev/dvb/adapterN/demuxM``, 14662306a36Sopenharmony_ci 14762306a36Sopenharmony_ci- ``/dev/dvb/adapterN/dvrM``, 14862306a36Sopenharmony_ci 14962306a36Sopenharmony_ci- ``/dev/dvb/adapterN/caM``, 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ciwhere ``N`` enumerates the Digital TV cards in a system starting from 0, and 15262306a36Sopenharmony_ci``M`` enumerates the devices of each type within each adapter, starting 15362306a36Sopenharmony_cifrom 0, too. We will omit the "``/dev/dvb/adapterN/``\ " in the further 15462306a36Sopenharmony_cidiscussion of these devices. 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ciMore details about the data structures and function calls of all the 15762306a36Sopenharmony_cidevices are described in the following chapters. 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci.. _include_files: 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ciAPI include files 16362306a36Sopenharmony_ci================= 16462306a36Sopenharmony_ci 16562306a36Sopenharmony_ciFor each of the Digital TV devices a corresponding include file exists. The 16662306a36Sopenharmony_ciDigital TV API include files should be included in application sources with a 16762306a36Sopenharmony_cipartial path like: 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci.. code-block:: c 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ci #include <linux/dvb/ca.h> 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ci #include <linux/dvb/dmx.h> 17562306a36Sopenharmony_ci 17662306a36Sopenharmony_ci #include <linux/dvb/frontend.h> 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ci #include <linux/dvb/net.h> 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ciTo enable applications to support different API version, an additional 18262306a36Sopenharmony_ciinclude file ``linux/dvb/version.h`` exists, which defines the constant 18362306a36Sopenharmony_ci``DVB_API_VERSION``. This document describes ``DVB_API_VERSION 5.10``. 184