1059b1c5bSMauro Carvalho Chehab.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
254f38fcaSMauro Carvalho Chehab
354f38fcaSMauro Carvalho Chehab.. _dvb_introdution:
454f38fcaSMauro Carvalho Chehab
554f38fcaSMauro Carvalho Chehab************
654f38fcaSMauro Carvalho ChehabIntroduction
754f38fcaSMauro Carvalho Chehab************
854f38fcaSMauro Carvalho Chehab
954f38fcaSMauro Carvalho Chehab
1054f38fcaSMauro Carvalho Chehab.. _requisites:
1154f38fcaSMauro Carvalho Chehab
1254f38fcaSMauro Carvalho ChehabWhat you need to know
1354f38fcaSMauro Carvalho Chehab=====================
1454f38fcaSMauro Carvalho Chehab
1554f38fcaSMauro Carvalho ChehabThe reader of this document is required to have some knowledge in the
1654f38fcaSMauro Carvalho Chehabarea of digital video broadcasting (Digital TV) and should be familiar with
1754f38fcaSMauro Carvalho Chehabpart I of the MPEG2 specification ISO/IEC 13818 (aka ITU-T H.222), i.e
1854f38fcaSMauro Carvalho Chehabyou should know what a program/transport stream (PS/TS) is and what is
1954f38fcaSMauro Carvalho Chehabmeant by a packetized elementary stream (PES) or an I-frame.
2054f38fcaSMauro Carvalho Chehab
2154f38fcaSMauro Carvalho ChehabVarious Digital TV standards documents are available for download at:
2254f38fcaSMauro Carvalho Chehab
2354f38fcaSMauro Carvalho Chehab- European standards (DVB): http://www.dvb.org and/or http://www.etsi.org.
2454f38fcaSMauro Carvalho Chehab- American standards (ATSC): https://www.atsc.org/standards/
2554f38fcaSMauro Carvalho Chehab- Japanese standards (ISDB): http://www.dibeg.org/
2654f38fcaSMauro Carvalho Chehab
2754f38fcaSMauro Carvalho ChehabIt is also necessary to know how to access Linux devices and how to
2854f38fcaSMauro Carvalho Chehabuse ioctl calls. This also includes the knowledge of C or C++.
2954f38fcaSMauro Carvalho Chehab
3054f38fcaSMauro Carvalho Chehab
3154f38fcaSMauro Carvalho Chehab.. _history:
3254f38fcaSMauro Carvalho Chehab
3354f38fcaSMauro Carvalho ChehabHistory
3454f38fcaSMauro Carvalho Chehab=======
3554f38fcaSMauro Carvalho Chehab
3654f38fcaSMauro Carvalho ChehabThe first API for Digital TV cards we used at Convergence in late 1999 was an
3754f38fcaSMauro Carvalho Chehabextension of the Video4Linux API which was primarily developed for frame
3854f38fcaSMauro Carvalho Chehabgrabber cards. As such it was not really well suited to be used for Digital
3954f38fcaSMauro Carvalho ChehabTV cards and their new features like recording MPEG streams and filtering
4054f38fcaSMauro Carvalho Chehabseveral section and PES data streams at the same time.
4154f38fcaSMauro Carvalho Chehab
4254f38fcaSMauro Carvalho ChehabIn early 2000, Convergence was approached by Nokia with a proposal for a new
4354f38fcaSMauro Carvalho Chehabstandard Linux Digital TV API. As a commitment to the development of terminals
4454f38fcaSMauro Carvalho Chehabbased on open standards, Nokia and Convergence made it available to all
4554f38fcaSMauro Carvalho ChehabLinux developers and published it on https://linuxtv.org in September
4654f38fcaSMauro Carvalho Chehab2000. With the Linux driver for the Siemens/Hauppauge DVB PCI card,
4754f38fcaSMauro Carvalho ChehabConvergence provided a first implementation of the Linux Digital TV API.
4854f38fcaSMauro Carvalho ChehabConvergence was the maintainer of the Linux Digital TV API in the early
4954f38fcaSMauro Carvalho Chehabdays.
5054f38fcaSMauro Carvalho Chehab
5154f38fcaSMauro Carvalho ChehabNow, the API is maintained by the LinuxTV community (i.e. you, the reader
5254f38fcaSMauro Carvalho Chehabof this document). The Linux  Digital TV API is constantly reviewed and
5354f38fcaSMauro Carvalho Chehabimproved together with the improvements at the subsystem's core at the
5454f38fcaSMauro Carvalho ChehabKernel.
5554f38fcaSMauro Carvalho Chehab
5654f38fcaSMauro Carvalho Chehab
5754f38fcaSMauro Carvalho Chehab.. _overview:
5854f38fcaSMauro Carvalho Chehab
5954f38fcaSMauro Carvalho ChehabOverview
6054f38fcaSMauro Carvalho Chehab========
6154f38fcaSMauro Carvalho Chehab
6254f38fcaSMauro Carvalho Chehab
6354f38fcaSMauro Carvalho Chehab.. _stb_components:
6454f38fcaSMauro Carvalho Chehab
6554f38fcaSMauro Carvalho Chehab.. kernel-figure:: dvbstb.svg
6654f38fcaSMauro Carvalho Chehab    :alt:   dvbstb.svg
6754f38fcaSMauro Carvalho Chehab    :align: center
6854f38fcaSMauro Carvalho Chehab
6954f38fcaSMauro Carvalho Chehab    Components of a Digital TV card/STB
7054f38fcaSMauro Carvalho Chehab
7154f38fcaSMauro Carvalho ChehabA Digital TV card or set-top-box (STB) usually consists of the
7254f38fcaSMauro Carvalho Chehabfollowing main hardware components:
7354f38fcaSMauro Carvalho Chehab
7454f38fcaSMauro Carvalho ChehabFrontend consisting of tuner and digital TV demodulator
7554f38fcaSMauro Carvalho Chehab   Here the raw signal reaches the digital TV hardware from a satellite dish or
7654f38fcaSMauro Carvalho Chehab   antenna or directly from cable. The frontend down-converts and
7754f38fcaSMauro Carvalho Chehab   demodulates this signal into an MPEG transport stream (TS). In case
7854f38fcaSMauro Carvalho Chehab   of a satellite frontend, this includes a facility for satellite
7954f38fcaSMauro Carvalho Chehab   equipment control (SEC), which allows control of LNB polarization,
8054f38fcaSMauro Carvalho Chehab   multi feed switches or dish rotors.
8154f38fcaSMauro Carvalho Chehab
8254f38fcaSMauro Carvalho ChehabConditional Access (CA) hardware like CI adapters and smartcard slots
8354f38fcaSMauro Carvalho Chehab   The complete TS is passed through the CA hardware. Programs to which
8454f38fcaSMauro Carvalho Chehab   the user has access (controlled by the smart card) are decoded in
8554f38fcaSMauro Carvalho Chehab   real time and re-inserted into the TS.
8654f38fcaSMauro Carvalho Chehab
8754f38fcaSMauro Carvalho Chehab   .. note::
8854f38fcaSMauro Carvalho Chehab
8954f38fcaSMauro Carvalho Chehab      Not every digital TV hardware provides conditional access hardware.
9054f38fcaSMauro Carvalho Chehab
9154f38fcaSMauro Carvalho ChehabDemultiplexer which filters the incoming Digital TV MPEG-TS stream
9254f38fcaSMauro Carvalho Chehab   The demultiplexer splits the TS into its components like audio and
9354f38fcaSMauro Carvalho Chehab   video streams. Besides usually several of such audio and video
9454f38fcaSMauro Carvalho Chehab   streams it also contains data streams with information about the
9554f38fcaSMauro Carvalho Chehab   programs offered in this or other streams of the same provider.
9654f38fcaSMauro Carvalho Chehab
9754f38fcaSMauro Carvalho ChehabAudio and video decoder
9854f38fcaSMauro Carvalho Chehab   The main targets of the demultiplexer are audio and video
9954f38fcaSMauro Carvalho Chehab   decoders. After decoding, they pass on the uncompressed audio and
10054f38fcaSMauro Carvalho Chehab   video to the computer screen or to a TV set.
10154f38fcaSMauro Carvalho Chehab
10254f38fcaSMauro Carvalho Chehab   .. note::
10354f38fcaSMauro Carvalho Chehab
10454f38fcaSMauro Carvalho Chehab      Modern hardware usually doesn't have a separate decoder hardware, as
10554f38fcaSMauro Carvalho Chehab      such functionality can be provided by the main CPU, by the graphics
10654f38fcaSMauro Carvalho Chehab      adapter of the system or by a signal processing hardware embedded on
10754f38fcaSMauro Carvalho Chehab      a Systems on a Chip (SoC) integrated circuit.
10854f38fcaSMauro Carvalho Chehab
10954f38fcaSMauro Carvalho Chehab      It may also not be needed for certain usages (e.g. for data-only
110*c11669f7SMauro Carvalho Chehab      uses like "internet over satellite").
11154f38fcaSMauro Carvalho Chehab
11254f38fcaSMauro Carvalho Chehab:ref:`stb_components` shows a crude schematic of the control and data
11354f38fcaSMauro Carvalho Chehabflow between those components.
11454f38fcaSMauro Carvalho Chehab
11554f38fcaSMauro Carvalho Chehab
11654f38fcaSMauro Carvalho Chehab
11754f38fcaSMauro Carvalho Chehab.. _dvb_devices:
11854f38fcaSMauro Carvalho Chehab
11954f38fcaSMauro Carvalho ChehabLinux Digital TV Devices
12054f38fcaSMauro Carvalho Chehab========================
12154f38fcaSMauro Carvalho Chehab
12254f38fcaSMauro Carvalho ChehabThe Linux Digital TV API lets you control these hardware components through
12354f38fcaSMauro Carvalho Chehabcurrently six Unix-style character devices for video, audio, frontend,
12454f38fcaSMauro Carvalho Chehabdemux, CA and IP-over-DVB networking. The video and audio devices
12554f38fcaSMauro Carvalho Chehabcontrol the MPEG2 decoder hardware, the frontend device the tuner and
12654f38fcaSMauro Carvalho Chehabthe Digital TV demodulator. The demux device gives you control over the PES
12754f38fcaSMauro Carvalho Chehaband section filters of the hardware. If the hardware does not support
12854f38fcaSMauro Carvalho Chehabfiltering these filters can be implemented in software. Finally, the CA
12954f38fcaSMauro Carvalho Chehabdevice controls all the conditional access capabilities of the hardware.
13054f38fcaSMauro Carvalho ChehabIt can depend on the individual security requirements of the platform,
13154f38fcaSMauro Carvalho Chehabif and how many of the CA functions are made available to the
13254f38fcaSMauro Carvalho Chehabapplication through this device.
13354f38fcaSMauro Carvalho Chehab
13454f38fcaSMauro Carvalho ChehabAll devices can be found in the ``/dev`` tree under ``/dev/dvb``. The
13554f38fcaSMauro Carvalho Chehabindividual devices are called:
13654f38fcaSMauro Carvalho Chehab
13754f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/audioM``,
13854f38fcaSMauro Carvalho Chehab
13954f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/videoM``,
14054f38fcaSMauro Carvalho Chehab
14154f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/frontendM``,
14254f38fcaSMauro Carvalho Chehab
14354f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/netM``,
14454f38fcaSMauro Carvalho Chehab
14554f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/demuxM``,
14654f38fcaSMauro Carvalho Chehab
14754f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/dvrM``,
14854f38fcaSMauro Carvalho Chehab
14954f38fcaSMauro Carvalho Chehab-  ``/dev/dvb/adapterN/caM``,
15054f38fcaSMauro Carvalho Chehab
151*c11669f7SMauro Carvalho Chehabwhere ``N`` enumerates the Digital TV cards in a system starting from 0, and
15254f38fcaSMauro Carvalho Chehab``M`` enumerates the devices of each type within each adapter, starting
153*c11669f7SMauro Carvalho Chehabfrom 0, too. We will omit the "``/dev/dvb/adapterN/``\ " in the further
15454f38fcaSMauro Carvalho Chehabdiscussion of these devices.
15554f38fcaSMauro Carvalho Chehab
15654f38fcaSMauro Carvalho ChehabMore details about the data structures and function calls of all the
15754f38fcaSMauro Carvalho Chehabdevices are described in the following chapters.
15854f38fcaSMauro Carvalho Chehab
15954f38fcaSMauro Carvalho Chehab
16054f38fcaSMauro Carvalho Chehab.. _include_files:
16154f38fcaSMauro Carvalho Chehab
16254f38fcaSMauro Carvalho ChehabAPI include files
16354f38fcaSMauro Carvalho Chehab=================
16454f38fcaSMauro Carvalho Chehab
16554f38fcaSMauro Carvalho ChehabFor each of the Digital TV devices a corresponding include file exists. The
16654f38fcaSMauro Carvalho ChehabDigital TV API include files should be included in application sources with a
16754f38fcaSMauro Carvalho Chehabpartial path like:
16854f38fcaSMauro Carvalho Chehab
16954f38fcaSMauro Carvalho Chehab
17054f38fcaSMauro Carvalho Chehab.. code-block:: c
17154f38fcaSMauro Carvalho Chehab
17254f38fcaSMauro Carvalho Chehab	#include <linux/dvb/ca.h>
17354f38fcaSMauro Carvalho Chehab
17454f38fcaSMauro Carvalho Chehab	#include <linux/dvb/dmx.h>
17554f38fcaSMauro Carvalho Chehab
17654f38fcaSMauro Carvalho Chehab	#include <linux/dvb/frontend.h>
17754f38fcaSMauro Carvalho Chehab
17854f38fcaSMauro Carvalho Chehab	#include <linux/dvb/net.h>
17954f38fcaSMauro Carvalho Chehab
18054f38fcaSMauro Carvalho Chehab
18154f38fcaSMauro Carvalho ChehabTo enable applications to support different API version, an additional
18254f38fcaSMauro Carvalho Chehabinclude file ``linux/dvb/version.h`` exists, which defines the constant
18354f38fcaSMauro Carvalho Chehab``DVB_API_VERSION``. This document describes ``DVB_API_VERSION 5.10``.
184