18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci.. _dvb_introdution: 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci************ 68c2ecf20Sopenharmony_ciIntroduction 78c2ecf20Sopenharmony_ci************ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci.. _requisites: 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ciWhat you need to know 138c2ecf20Sopenharmony_ci===================== 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciThe reader of this document is required to have some knowledge in the 168c2ecf20Sopenharmony_ciarea of digital video broadcasting (Digital TV) and should be familiar with 178c2ecf20Sopenharmony_cipart I of the MPEG2 specification ISO/IEC 13818 (aka ITU-T H.222), i.e 188c2ecf20Sopenharmony_ciyou should know what a program/transport stream (PS/TS) is and what is 198c2ecf20Sopenharmony_cimeant by a packetized elementary stream (PES) or an I-frame. 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ciVarious Digital TV standards documents are available for download at: 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci- European standards (DVB): http://www.dvb.org and/or http://www.etsi.org. 248c2ecf20Sopenharmony_ci- American standards (ATSC): https://www.atsc.org/standards/ 258c2ecf20Sopenharmony_ci- Japanese standards (ISDB): http://www.dibeg.org/ 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ciIt is also necessary to know how to access Linux devices and how to 288c2ecf20Sopenharmony_ciuse ioctl calls. This also includes the knowledge of C or C++. 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci.. _history: 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciHistory 348c2ecf20Sopenharmony_ci======= 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciThe first API for Digital TV cards we used at Convergence in late 1999 was an 378c2ecf20Sopenharmony_ciextension of the Video4Linux API which was primarily developed for frame 388c2ecf20Sopenharmony_cigrabber cards. As such it was not really well suited to be used for Digital 398c2ecf20Sopenharmony_ciTV cards and their new features like recording MPEG streams and filtering 408c2ecf20Sopenharmony_ciseveral section and PES data streams at the same time. 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciIn early 2000, Convergence was approached by Nokia with a proposal for a new 438c2ecf20Sopenharmony_cistandard Linux Digital TV API. As a commitment to the development of terminals 448c2ecf20Sopenharmony_cibased on open standards, Nokia and Convergence made it available to all 458c2ecf20Sopenharmony_ciLinux developers and published it on https://linuxtv.org in September 468c2ecf20Sopenharmony_ci2000. With the Linux driver for the Siemens/Hauppauge DVB PCI card, 478c2ecf20Sopenharmony_ciConvergence provided a first implementation of the Linux Digital TV API. 488c2ecf20Sopenharmony_ciConvergence was the maintainer of the Linux Digital TV API in the early 498c2ecf20Sopenharmony_cidays. 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ciNow, the API is maintained by the LinuxTV community (i.e. you, the reader 528c2ecf20Sopenharmony_ciof this document). The Linux Digital TV API is constantly reviewed and 538c2ecf20Sopenharmony_ciimproved together with the improvements at the subsystem's core at the 548c2ecf20Sopenharmony_ciKernel. 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci.. _overview: 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciOverview 608c2ecf20Sopenharmony_ci======== 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci.. _stb_components: 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci.. kernel-figure:: dvbstb.svg 668c2ecf20Sopenharmony_ci :alt: dvbstb.svg 678c2ecf20Sopenharmony_ci :align: center 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci Components of a Digital TV card/STB 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ciA Digital TV card or set-top-box (STB) usually consists of the 728c2ecf20Sopenharmony_cifollowing main hardware components: 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ciFrontend consisting of tuner and digital TV demodulator 758c2ecf20Sopenharmony_ci Here the raw signal reaches the digital TV hardware from a satellite dish or 768c2ecf20Sopenharmony_ci antenna or directly from cable. The frontend down-converts and 778c2ecf20Sopenharmony_ci demodulates this signal into an MPEG transport stream (TS). In case 788c2ecf20Sopenharmony_ci of a satellite frontend, this includes a facility for satellite 798c2ecf20Sopenharmony_ci equipment control (SEC), which allows control of LNB polarization, 808c2ecf20Sopenharmony_ci multi feed switches or dish rotors. 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ciConditional Access (CA) hardware like CI adapters and smartcard slots 838c2ecf20Sopenharmony_ci The complete TS is passed through the CA hardware. Programs to which 848c2ecf20Sopenharmony_ci the user has access (controlled by the smart card) are decoded in 858c2ecf20Sopenharmony_ci real time and re-inserted into the TS. 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci .. note:: 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci Not every digital TV hardware provides conditional access hardware. 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ciDemultiplexer which filters the incoming Digital TV MPEG-TS stream 928c2ecf20Sopenharmony_ci The demultiplexer splits the TS into its components like audio and 938c2ecf20Sopenharmony_ci video streams. Besides usually several of such audio and video 948c2ecf20Sopenharmony_ci streams it also contains data streams with information about the 958c2ecf20Sopenharmony_ci programs offered in this or other streams of the same provider. 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ciAudio and video decoder 988c2ecf20Sopenharmony_ci The main targets of the demultiplexer are audio and video 998c2ecf20Sopenharmony_ci decoders. After decoding, they pass on the uncompressed audio and 1008c2ecf20Sopenharmony_ci video to the computer screen or to a TV set. 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci .. note:: 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci Modern hardware usually doesn't have a separate decoder hardware, as 1058c2ecf20Sopenharmony_ci such functionality can be provided by the main CPU, by the graphics 1068c2ecf20Sopenharmony_ci adapter of the system or by a signal processing hardware embedded on 1078c2ecf20Sopenharmony_ci a Systems on a Chip (SoC) integrated circuit. 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci It may also not be needed for certain usages (e.g. for data-only 1108c2ecf20Sopenharmony_ci uses like “internet over satellite”). 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci:ref:`stb_components` shows a crude schematic of the control and data 1138c2ecf20Sopenharmony_ciflow between those components. 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci.. _dvb_devices: 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ciLinux Digital TV Devices 1208c2ecf20Sopenharmony_ci======================== 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ciThe Linux Digital TV API lets you control these hardware components through 1238c2ecf20Sopenharmony_cicurrently six Unix-style character devices for video, audio, frontend, 1248c2ecf20Sopenharmony_cidemux, CA and IP-over-DVB networking. The video and audio devices 1258c2ecf20Sopenharmony_cicontrol the MPEG2 decoder hardware, the frontend device the tuner and 1268c2ecf20Sopenharmony_cithe Digital TV demodulator. The demux device gives you control over the PES 1278c2ecf20Sopenharmony_ciand section filters of the hardware. If the hardware does not support 1288c2ecf20Sopenharmony_cifiltering these filters can be implemented in software. Finally, the CA 1298c2ecf20Sopenharmony_cidevice controls all the conditional access capabilities of the hardware. 1308c2ecf20Sopenharmony_ciIt can depend on the individual security requirements of the platform, 1318c2ecf20Sopenharmony_ciif and how many of the CA functions are made available to the 1328c2ecf20Sopenharmony_ciapplication through this device. 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ciAll devices can be found in the ``/dev`` tree under ``/dev/dvb``. The 1358c2ecf20Sopenharmony_ciindividual devices are called: 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/audioM``, 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/videoM``, 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/frontendM``, 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/netM``, 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/demuxM``, 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/dvrM``, 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci- ``/dev/dvb/adapterN/caM``, 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ciwhere ``N`` enumerates the Digital TV cards in a system starting from 0, and 1528c2ecf20Sopenharmony_ci``M`` enumerates the devices of each type within each adapter, starting 1538c2ecf20Sopenharmony_cifrom 0, too. We will omit the “``/dev/dvb/adapterN/``\ ” in the further 1548c2ecf20Sopenharmony_cidiscussion of these devices. 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ciMore details about the data structures and function calls of all the 1578c2ecf20Sopenharmony_cidevices are described in the following chapters. 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci.. _include_files: 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ciAPI include files 1638c2ecf20Sopenharmony_ci================= 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ciFor each of the Digital TV devices a corresponding include file exists. The 1668c2ecf20Sopenharmony_ciDigital TV API include files should be included in application sources with a 1678c2ecf20Sopenharmony_cipartial path like: 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci.. code-block:: c 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci #include <linux/dvb/ca.h> 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci #include <linux/dvb/dmx.h> 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci #include <linux/dvb/frontend.h> 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci #include <linux/dvb/net.h> 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci 1818c2ecf20Sopenharmony_ciTo enable applications to support different API version, an additional 1828c2ecf20Sopenharmony_ciinclude file ``linux/dvb/version.h`` exists, which defines the constant 1838c2ecf20Sopenharmony_ci``DVB_API_VERSION``. This document describes ``DVB_API_VERSION 5.10``. 184