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