^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Digital TV Demux kABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) ---------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) Digital TV Demux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) ~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) The Kernel Digital TV Demux kABI defines a driver-internal interface for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) registering low-level, hardware specific driver to a hardware independent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) demux layer. It is only of interest for Digital TV device driver writers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) The header file for this kABI is named ``demux.h`` and located in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) ``include/media``.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) The demux kABI should be implemented for each demux in the system. It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) used to select the TS source of a demux and to manage the demux resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) When the demux client allocates a resource via the demux kABI, it receives
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) a pointer to the kABI of that resource.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) Each demux receives its TS input from a DVB front-end or from memory, as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) set via this demux kABI. In a system with more than one front-end, the kABI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) can be used to select one of the DVB front-ends as a TS source for a demux,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unless this is fixed in the HW platform.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) The demux kABI only controls front-ends regarding to their connections with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) demuxes; the kABI used to set the other front-end parameters, such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) tuning, are devined via the Digital TV Frontend kABI.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) The functions that implement the abstract interface demux should be defined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) static or module private and registered to the Demux core for external
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) access. It is not necessary to implement every function in the struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) :c:type:`dmx_demux`. For example, a demux interface might support Section filtering,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) but not PES filtering. The kABI client is expected to check the value of any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) function pointer before calling the function: the value of ``NULL`` means
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) that the function is not available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) Whenever the functions of the demux API modify shared data, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) possibilities of lost update and race condition problems should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) addressed, e.g. by protecting parts of code with mutexes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Note that functions called from a bottom half context must not sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) Even a simple memory allocation without using ``GFP_ATOMIC`` can result in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) kernel thread being put to sleep if swapping is needed. For example, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) Linux Kernel calls the functions of a network device interface from a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) bottom half context. Thus, if a demux kABI function is called from network
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) device code, the function must not sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) Demux Callback API
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) ~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) This kernel-space API comprises the callback functions that deliver filtered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) data to the demux client. Unlike the other DVB kABIs, these functions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) provided by the client and called from the demux code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) The function pointers of this abstract interface are not packed into a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) structure as in the other demux APIs, because the callback functions are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) registered and used independent of each other. As an example, it is possible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) for the API client to provide several callback functions for receiving TS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) packets and no callbacks for PES packets or sections.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) The functions that implement the callback API need not be re-entrant: when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) a demux driver calls one of these functions, the driver is not allowed to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) call the function again before the original call returns. If a callback is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) triggered by a hardware interrupt, it is recommended to use the Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) bottom half mechanism or start a tasklet instead of making the callback
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) function call directly from a hardware interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) This mechanism is implemented by :c:func:`dmx_ts_cb()` and :c:func:`dmx_section_cb()`
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) callbacks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) Digital TV Demux device registration functions and data structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .. kernel-doc:: include/media/dmxdev.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) High-level Digital TV demux interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) .. kernel-doc:: include/media/dvb_demux.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) Driver-internal low-level hardware specific driver demux interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) .. kernel-doc:: include/media/demux.h