3.3.Digital TV Demux kABI¶
3.3.1.Digital TV Demux¶
The Kernel Digital TV Demux kABI defines a driver-internal interface forregistering low-level, hardware specific driver to a hardware independentdemux layer. It is only of interest for Digital TV device driver writers.The header file for this kABI is nameddemux.h and located ininclude/media.
The demux kABI should be implemented for each demux in the system. It isused to select the TS source of a demux and to manage the demux resources.When the demux client allocates a resource via the demux kABI, it receivesa pointer to the kABI of that resource.
Each demux receives its TS input from a DVB front-end or from memory, asset via this demux kABI. In a system with more than one front-end, the kABIcan be used to select one of the DVB front-ends as a TS source for a demux,unless this is fixed in the HW platform.
The demux kABI only controls front-ends regarding to their connections withdemuxes; the kABI used to set the other front-end parameters, such astuning, are defined via the Digital TV Frontend kABI.
The functions that implement the abstract interface demux should be definedstatic or module private and registered to the Demux core for externalaccess. It is not necessary to implement every function in the structdmx_demux. For example, a demux interface might support Section filtering,but not PES filtering. The kABI client is expected to check the value of anyfunction pointer before calling the function: the value ofNULL meansthat the function is not available.
Whenever the functions of the demux API modify shared data, thepossibilities of lost update and race condition problems should beaddressed, e.g. by protecting parts of code with mutexes.
Note that functions called from a bottom half context must not sleep.Even a simple memory allocation without usingGFP_ATOMIC can result in akernel thread being put to sleep if swapping is needed. For example, theLinux Kernel calls the functions of a network device interface from abottom half context. Thus, if a demux kABI function is called from networkdevice code, the function must not sleep.
3.3.2.Demux Callback API¶
This kernel-space API comprises the callback functions that deliver filtereddata to the demux client. Unlike the other DVB kABIs, these functions areprovided by the client and called from the demux code.
The function pointers of this abstract interface are not packed into astructure as in the other demux APIs, because the callback functions areregistered and used independent of each other. As an example, it is possiblefor the API client to provide several callback functions for receiving TSpackets and no callbacks for PES packets or sections.
The functions that implement the callback API need not be re-entrant: whena demux driver calls one of these functions, the driver is not allowed tocall the function again before the original call returns. If a callback istriggered by a hardware interrupt, it is recommended to use the Linuxbottom half mechanism or start a tasklet instead of making the callbackfunction call directly from a hardware interrupt.
This mechanism is implemented bydmx_ts_cb() anddmx_section_cb()callbacks.
3.3.3.Digital TV Demux device registration functions and data structures¶
- enumdmxdev_type¶
type of demux filter type.
Constants
DMXDEV_TYPE_NONEno filter set.
DMXDEV_TYPE_SECsection filter.
DMXDEV_TYPE_PESProgram Elementary Stream (PES) filter.
- enumdmxdev_state¶
state machine for the dmxdev.
Constants
DMXDEV_STATE_FREEindicates that the filter is freed.
DMXDEV_STATE_ALLOCATEDindicates that the filter was allocatedto be used.
DMXDEV_STATE_SETindicates that the filter parameters are set.
DMXDEV_STATE_GOindicates that the filter is running.
DMXDEV_STATE_DONEindicates that a packet was already filteredand the filter is now disabled.Set only if
DMX_ONESHOT. Seedmx_sct_filter_params.DMXDEV_STATE_TIMEDOUTIndicates a timeout condition.
- structdmxdev_feed¶
digital TV dmxdev feed
Definition:
struct dmxdev_feed { u16 pid; struct dmx_ts_feed *ts; struct list_head next;};Members
pidProgram ID to be filtered
tspointer to
structdmx_ts_feednextstructlist_headpointing to the next feed.
- structdmxdev_filter¶
digital TV dmxdev filter
Definition:
struct dmxdev_filter { union { struct dmx_section_filter *sec; } filter; union { struct list_head ts; struct dmx_section_feed *sec; } feed; union { struct dmx_sct_filter_params sec; struct dmx_pes_filter_params pes; } params; enum dmxdev_type type; enum dmxdev_state state; struct dmxdev *dev; struct dvb_ringbuffer buffer; struct dvb_vb2_ctx vb2_ctx; struct mutex mutex; struct timer_list timer; int todo; u8 secheader[3];};Members
filtera
uniondescribinga dmxdev filter.Currently used only for section filters.filter.seca
structdmx_section_filterpointer.For section filter only.feeda
uniondescribinga dmxdev feed.Depending on the filter type, it can be eitherfeed.ts orfeed.sec.feed.tsa
structlist_headlist.For TS and PES feeds.feed.seca
structdmx_section_feedpointer.For section feed only.paramsa
uniondescribingdmxdev filter parameters.Depending on the filter type, it can be eitherparams.sec orparams.pes.params.seca
structdmx_sct_filter_paramsembedded struct.For section filter only.params.pesa
structdmx_pes_filter_paramsembedded struct.For PES filter only.typetype of the dmxdev filter, as defined by
enumdmxdev_type.statestate of the dmxdev filter, as defined by
enumdmxdev_state.devpointer to
structdmxdev.bufferan embedded
structdvb_ringbufferbuffer.vb2_ctxcontrol struct for VB2 handler
mutexprotects the access to
structdmxdev_filter.timerstructtimer_listembedded timer, used to check forfeed timeouts.Only for section filter.todoindex for thesecheader.Only for section filter.
secheaderbuffer cache to parse the section header.Only for section filter.
- structdmxdev¶
Describes a digital TV demux device.
Definition:
struct dmxdev { struct dvb_device *dvbdev; struct dvb_device *dvr_dvbdev; struct dmxdev_filter *filter; struct dmx_demux *demux; int filternum; int capabilities; unsigned int may_do_mmap:1; unsigned int exit:1;#define DMXDEV_CAP_DUPLEX 1; struct dmx_frontend *dvr_orig_fe; struct dvb_ringbuffer dvr_buffer;#define DVR_BUFFER_SIZE (10*188*1024); struct dvb_vb2_ctx dvr_vb2_ctx; struct mutex mutex; spinlock_t lock;};Members
dvbdevpointer to
structdvb_deviceassociated withthe demux device node.dvr_dvbdevpointer to
structdvb_deviceassociated withthe dvr device node.filterpointer to
structdmxdev_filter.demuxpointer to
structdmx_demux.filternumnumber of filters.
capabilitiesdemux capabilities as defined by
enumdmx_demux_caps.may_do_mmapflag used to indicate if the device may do mmap.
exitflag to indicate that the demux is being released.
dvr_orig_fepointer to
structdmx_frontend.dvr_bufferembedded
structdvb_ringbufferfor DVB output.dvr_vb2_ctxcontrol struct for VB2 handler
mutexprotects the usage of this structure.
lockprotects access to
dmxdev->filter->data.
- intdvb_dmxdev_init(structdmxdev*dmxdev,structdvb_adapter*adap)¶
initializes a digital TV demux and registers both demux and DVR devices.
Parameters
structdmxdev*dmxdevpointer to
structdmxdev.structdvb_adapter*adappointer to
structdvb_adapter.
Parameters
structdmxdev*dmxdevpointer to
structdmxdev.
3.3.4.High-level Digital TV demux interface¶
- enumdvb_dmx_filter_type¶
type of demux feed.
Constants
DMX_TYPE_TSfeed is in TS mode.
DMX_TYPE_SECfeed is in Section mode.
- enumdvb_dmx_state¶
state machine for a demux filter.
Constants
DMX_STATE_FREEindicates that the filter is freed.
DMX_STATE_ALLOCATEDindicates that the filter was allocatedto be used.
DMX_STATE_READYindicates that the filter is readyto be used.
DMX_STATE_GOindicates that the filter is running.
- structdvb_demux_filter¶
Describes a DVB demux section filter.
Definition:
struct dvb_demux_filter { struct dmx_section_filter filter; u8 maskandmode[DMX_MAX_FILTER_SIZE]; u8 maskandnotmode[DMX_MAX_FILTER_SIZE]; bool doneq; struct dvb_demux_filter *next; struct dvb_demux_feed *feed; int index; enum dvb_dmx_state state; enum dvb_dmx_filter_type type;};Members
filterSection filter as defined by
structdmx_section_filter.maskandmodelogical
andbit mask.maskandnotmodelogical
andnotbit mask.doneqflag that indicates when a filter is ready.
nextpointer to the next section filter.
feedstructdvb_demux_feedpointer.indexindex of the used demux filter.
statestate of the filter as described by
enumdvb_dmx_state.typetype of the filter as describedby
enumdvb_dmx_filter_type.
- structdvb_demux_feed¶
describes a DVB field
Definition:
struct dvb_demux_feed { union { struct dmx_ts_feed ts; struct dmx_section_feed sec; } feed; union { dmx_ts_cb ts; dmx_section_cb sec; } cb; struct dvb_demux *demux; void *priv; enum dvb_dmx_filter_type type; enum dvb_dmx_state state; u16 pid; ktime_t timeout; struct dvb_demux_filter *filter; u32 buffer_flags; enum ts_filter_type ts_type; enum dmx_ts_pes pes_type; int cc; bool pusi_seen; u16 peslen; struct list_head list_head; unsigned int index;};Members
feeda
uniondescribinga digital TV feed.Depending on the feed type, it can be eitherfeed.ts orfeed.sec.feed.tsa
structdmx_ts_feedpointer.For TS feed only.feed.seca
structdmx_section_feedpointer.For section feed only.cba
uniondescribingdigital TV callbacks.Depending on the feed type, it can be eithercb.ts orcb.sec.cb.tsa
dmx_ts_cb()calback function pointer.For TS feed only.cb.seca
dmx_section_cb()callback function pointer.For section feed only.demuxpointer to
structdvb_demux.privprivate data that can optionally be used by a DVB driver.
typetype of the filter, as defined by
enumdvb_dmx_filter_type.statestate of the filter as defined by
enumdvb_dmx_state.pidPID to be filtered.
timeoutfeed timeout.
filterpointer to
structdvb_demux_filter.buffer_flagsBuffer flags used to report discontinuity users via DVBmemory mapped API, as defined by
enumdmx_buffer_flags.ts_typetype of TS, as defined by
enumts_filter_type.pes_typetype of PES, as defined by
enumdmx_ts_pes.ccMPEG-TS packet continuity counter
pusi_seenif true, indicates that a discontinuity was detected.it is used to prevent feeding of garbage from previous section.
peslenlength of the PES (Packet Elementary Stream).
list_headhead for the list of digital TV demux feeds.
indexa unique index for each feed. Can be used as hardwarepid filter index.
- structdvb_demux¶
represents a digital TV demux
Definition:
struct dvb_demux { struct dmx_demux dmx; void *priv; int filternum; int feednum; int (*start_feed)(struct dvb_demux_feed *feed); int (*stop_feed)(struct dvb_demux_feed *feed); int (*write_to_decoder)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); u32 (*check_crc32)(struct dvb_demux_feed *feed, const u8 *buf, size_t len); void (*memcopy)(struct dvb_demux_feed *feed, u8 *dst, const u8 *src, size_t len); int users;#define MAX_DVB_DEMUX_USERS 10; struct dvb_demux_filter *filter; struct dvb_demux_feed *feed; struct list_head frontend_list; struct dvb_demux_feed *pesfilter[DMX_PES_OTHER]; u16 pids[DMX_PES_OTHER];#define DMX_MAX_PID 0x2000; struct list_head feed_list; u8 tsbuf[204]; int tsbufp; struct mutex mutex; spinlock_t lock; uint8_t *cnt_storage; ktime_t speed_last_time; uint32_t speed_pkts_cnt;};Members
dmxembedded
structdmx_demuxwith demux capabilitiesand callbacks.privprivate data that can optionally be used bya DVB driver.
filternummaximum amount of DVB filters.
feednummaximum amount of DVB feeds.
start_feedcallback routine to be called in order to starta DVB feed.
stop_feedcallback routine to be called in order to stopa DVB feed.
write_to_decodercallback routine to be called if the feed is TS andit is routed to an A/V decoder, when a new TS packetis received.Used only on av7110-av.c.
check_crc32callback routine to check CRC. If not initialized,dvb_demux will use an internal one.
memcopycallback routine to memcopy received data.If not initialized, dvb_demux will default to
memcpy().userscounter for the number of demux opened file descriptors.Currently, it is limited to 10 users.
filterpointer to
structdvb_demux_filter.feedpointer to
structdvb_demux_feed.frontend_liststructlist_headwith frontends used by the demux.pesfilterarray of
structdvb_demux_feedwith the PES typesthat will be filtered.pidslist of filtered program IDs.
feed_liststructlist_headwith feeds.tsbuftemporary buffer used internally to store TS packets.
tsbufptemporary buffer index used internally.
mutexpointer to
structmutexused to protect feed setlogic.lockpointer to
spinlock_t, used to protect buffer handling.cnt_storagebuffer used for TS/TEI continuity check.
speed_last_timektime_tused for TS speed check.speed_pkts_cntpackets count used for TS speed check.
Parameters
structdvb_demux*demuxstructdvb_demuxto be initialized.
Description
Before being able to register a digital TV demux struct, driversshould call this routine. On its typical usage, some fields shouldbe initialized at the driver before calling it.
A typical usecase is:
dvb->demux.dmx.capabilities = DMX_TS_FILTERING | DMX_SECTION_FILTERING | DMX_MEMORY_BASED_FILTERING;dvb->demux.priv = dvb;dvb->demux.filternum = 256;dvb->demux.feednum = 256;dvb->demux.start_feed = driver_start_feed;dvb->demux.stop_feed = driver_stop_feed;ret = dvb_dmx_init(&dvb->demux);if (ret < 0) return ret;
Parameters
structdvb_demux*demuxstructdvb_demuxto be released.
Description
The DVB core internally allocates data atdemux. This routinereleases those data. Please notice that thestructitelf is notreleased, as it can be embedded on other structs.
- voiddvb_dmx_swfilter_packets(structdvb_demux*demux,constu8*buf,size_tcount)¶
use dvb software filter for a buffer with multiple MPEG-TS packets with 188 bytes each.
Parameters
structdvb_demux*demuxpointer to
structdvb_demuxconstu8*bufbuffer with data to be filtered
size_tcountnumber of MPEG-TS packets with size of 188.
Description
The routine will discard a DVB packet that don’t start with 0x47.
Use this routine if the DVB demux fills MPEG-TS buffers that arealready aligned.
NOTE
Thebuf size should have size equal tocount*188.
- voiddvb_dmx_swfilter(structdvb_demux*demux,constu8*buf,size_tcount)¶
use dvb software filter for a buffer with multiple MPEG-TS packets with 188 bytes each.
Parameters
structdvb_demux*demuxpointer to
structdvb_demuxconstu8*bufbuffer with data to be filtered
size_tcountnumber of MPEG-TS packets with size of 188.
Description
If a DVB packet doesn’t start with 0x47, it will seek for the firstbyte that starts with 0x47.
Use this routine if the DVB demux fill buffers that may not start witha packet start mark (0x47).
NOTE
Thebuf size should have size equal tocount*188.
- voiddvb_dmx_swfilter_204(structdvb_demux*demux,constu8*buf,size_tcount)¶
use dvb software filter for a buffer with multiple MPEG-TS packets with 204 bytes each.
Parameters
structdvb_demux*demuxpointer to
structdvb_demuxconstu8*bufbuffer with data to be filtered
size_tcountnumber of MPEG-TS packets with size of 204.
Description
If a DVB packet doesn’t start with 0x47, it will seek for the firstbyte that starts with 0x47.
Use this routine if the DVB demux fill buffers that may not start witha packet start mark (0x47).
NOTE
Thebuf size should have size equal tocount*204.
- voiddvb_dmx_swfilter_raw(structdvb_demux*demux,constu8*buf,size_tcount)¶
make the raw data available to userspace without filtering
Parameters
structdvb_demux*demuxpointer to
structdvb_demuxconstu8*bufbuffer with data
size_tcountnumber of packets to be passed. The actual size of each packetdepends on the
dvb_demux->feed->cb.ts logic.
Description
Use it if the driver needs to deliver the raw payload to userspace withoutpassing through the kernel demux. That is meant to support somedelivery systems that aren’t based on MPEG-TS.
This function relies ondvb_demux->feed->cb.ts to actually handle thebuffer.
3.3.5.Driver-internal low-level hardware specific driver demux interface¶
- enumts_filter_type¶
filter type bitmap for dmx_ts_feed.
set()
Constants
TS_PACKETSend TS packets (188 bytes) to callback (default).
TS_PAYLOAD_ONLYIn case TS_PACKET is set, only send the TS payload(<=184 bytes per packet) to callback
TS_DECODERSend stream to built-in decoder (if present).
TS_DEMUXIn case TS_PACKET is set, send the TS to the demuxdevice, not to the dvr device
- structdmx_ts_feed¶
Structure that contains a TS feed filter
Definition:
struct dmx_ts_feed { int is_filtering; struct dmx_demux *parent; void *priv; int (*set)(struct dmx_ts_feed *feed, u16 pid, int type, enum dmx_ts_pes pes_type, ktime_t timeout); int (*start_filtering)(struct dmx_ts_feed *feed); int (*stop_filtering)(struct dmx_ts_feed *feed);};Members
is_filteringSet to non-zero when filtering in progress
parentpointer to
structdmx_demuxprivpointer to private data of the API client
setsets the TS filter
start_filteringstarts TS filtering
stop_filteringstops TS filtering
Description
A TS feed is typically mapped to a hardware PID filter on the demux chip.Using this API, the client can set the filtering properties to start/stopfiltering TS packets on a particular TS feed.
- structdmx_section_filter¶
Structure that describes a section filter
Definition:
struct dmx_section_filter { u8 filter_value[DMX_MAX_FILTER_SIZE]; u8 filter_mask[DMX_MAX_FILTER_SIZE]; u8 filter_mode[DMX_MAX_FILTER_SIZE]; struct dmx_section_feed *parent; void *priv;};Members
filter_valueContains up to 16 bytes (128 bits) of the TS section headerthat will be matched by the section filter
filter_maskContains a 16 bytes (128 bits) filter mask with the bitsspecified byfilter_value that will be used on the filtermatch logic.
filter_modeContains a 16 bytes (128 bits) filter mode.
parentBack-pointer to
structdmx_section_feed.privPointer to private data of the API client.
Description
Thefilter_mask controls which bits offilter_value are compared withthe section headers/payload. On a binary value of 1 in filter_mask, thecorresponding bits are compared. The filter only accepts sections that areequal to filter_value in all the tested bit positions.
- structdmx_section_feed¶
Structure that contains a section feed filter
Definition:
struct dmx_section_feed { int is_filtering; struct dmx_demux *parent; void *priv; int check_crc; int (*set)(struct dmx_section_feed *feed, u16 pid, int check_crc); int (*allocate_filter)(struct dmx_section_feed *feed, struct dmx_section_filter **filter); int (*release_filter)(struct dmx_section_feed *feed, struct dmx_section_filter *filter); int (*start_filtering)(struct dmx_section_feed *feed); int (*stop_filtering)(struct dmx_section_feed *feed);};Members
is_filteringSet to non-zero when filtering in progress
parentpointer to
structdmx_demuxprivpointer to private data of the API client
check_crcIf non-zero, check the CRC values of filtered sections.
setsets the section filter
allocate_filterThis function is used to allocate a section filter onthe demux. It should only be called when no filteringis in progress on this section feed. If a filter cannotbe allocated, the function fails with -ENOSPC.
release_filterThis function releases all the resources of apreviously allocated section filter. The functionshould not be called while filtering is in progresson this section feed. After calling this function,the caller should not try to dereference the filterpointer.
start_filteringstarts section filtering
stop_filteringstops section filtering
Description
A TS feed is typically mapped to a hardware PID filter on the demux chip.Using this API, the client can set the filtering properties to start/stopfiltering TS packets on a particular TS feed.
- dmx_ts_cb¶
Typedef: DVB demux TS filter callback function prototype
Syntax
intdmx_ts_cb(constu8*buffer1,size_tbuffer1_length,constu8*buffer2,size_tbuffer2_length,structdmx_ts_feed*source,u32*buffer_flags)
Parameters
constu8*buffer1Pointer to the start of the filtered TS packets.
size_tbuffer1_lengthLength of the TS data in buffer1.
constu8*buffer2Pointer to the tail of the filtered TS packets, or NULL.
size_tbuffer2_lengthLength of the TS data in buffer2.
structdmx_ts_feed*sourceIndicates which TS feed is the source of the callback.
u32*buffer_flagsAddress where buffer flags are stored. Those areused to report discontinuity users via DVBmemory mapped API, as defined by
enumdmx_buffer_flags.
Description
This function callback prototype, provided by the client of the demux API,is called from the demux code. The function is only called when filteringon a TS feed has been enabled using thestart_filtering() function atthedmx_demux.Any TS packets that match the filter settings are copied to a circularbuffer. The filtered TS packets are delivered to the client using thiscallback function.It is expected that thebuffer1 andbuffer2 callback parameters point toaddresses within the circular buffer, but other implementations are alsopossible. Note that the called party should not try to free the memorythebuffer1 andbuffer2 parameters point to.
When this function is called, thebuffer1 parameter typically points tothe start of the first undelivered TS packet within a circular buffer.Thebuffer2 buffer parameter is normally NULL, except when the receivedTS packets have crossed the last address of the circular buffer and“wrapped” to the beginning of the buffer. In the latter case thebuffer1parameter would contain an address within the circular buffer, while thebuffer2 parameter would contain the first address of the circular buffer.The number of bytes delivered with this function (i.e.buffer1_length +buffer2_length) is usually equal to the value of callback_length parametergiven in theset() function, with one exception: if a timeout occurs beforereceiving callback_length bytes of TS data, any undelivered packets areimmediately delivered to the client by calling this function. The timeoutduration is controlled by theset() function in the TS Feed API.
If a TS packet is received with errors that could not be fixed by theTS-level forward error correction (FEC), the Transport_error_indicatorflag of the TS packet header should be set. The TS packet should not bediscarded, as the error can possibly be corrected by a higher layerprotocol. If the called party is slow in processing the callback, itis possible that the circular buffer eventually fills up. If this happens,the demux driver should discard any TS packets received while the bufferis full and return -EOVERFLOW.
The type of data returned to the callback can be selected by thedmx_ts_feed.**set** function. The type parameter decides if the rawTS packet (TS_PACKET) or just the payload (TS_PACKET|TS_PAYLOAD_ONLY)should be returned. If additionally the TS_DECODER bit is set the streamwill also be sent to the hardware MPEG decoder.
0, on success;
-EOVERFLOW, on buffer overflow.
- dmx_section_cb¶
Typedef: DVB demux TS filter callback function prototype
Syntax
intdmx_section_cb(constu8*buffer1,size_tbuffer1_len,constu8*buffer2,size_tbuffer2_len,structdmx_section_filter*source,u32*buffer_flags)
Parameters
constu8*buffer1Pointer to the start of the filtered section, e.g.within the circular buffer of the demux driver.
size_tbuffer1_lenLength of the filtered section data inbuffer1,including headers and CRC.
constu8*buffer2Pointer to the tail of the filtered section data,or NULL. Useful to handle the wrapping of acircular buffer.
size_tbuffer2_lenLength of the filtered section data inbuffer2,including headers and CRC.
structdmx_section_filter*sourceIndicates which section feed is the source of thecallback.
u32*buffer_flagsAddress where buffer flags are stored. Those areused to report discontinuity users via DVBmemory mapped API, as defined by
enumdmx_buffer_flags.
Description
This function callback prototype, provided by the client of the demux API,is called from the demux code. The function is only called whenfiltering of sections has been enabled using the functiondmx_ts_feed.**start_filtering**. When the demux driver has received acomplete section that matches at least one section filter, the clientis notified via this callback function. Normally this function is calledfor each received section; however, it is also possible to delivermultiple sections with one callback, for example when the system loadis high. If an error occurs while receiving a section, thisfunction should be called with the corresponding error type set in thesuccess field, whether or not there is data to deliver. The Section Feedimplementation should maintain a circular buffer for received sections.However, this is not necessary if the Section Feed API is implemented asa client of the TS Feed API, because the TS Feed implementation thenbuffers the received data. The size of the circular buffer can beconfigured using thedmx_ts_feed.**set** function in the Section Feed API.If there is no room in the circular buffer when a new section is received,the section must be discarded. If this happens, the value of the successparameter should be DMX_OVERRUN_ERROR on the next callback.
- enumdmx_frontend_source¶
Used to identify the type of frontend
Constants
DMX_MEMORY_FEThe source of the demux is memory. It means thatthe MPEG-TS to be filtered comes from userspace,via write() syscall.
DMX_FRONTEND_0The source of the demux is a frontend connectedto the demux.
- structdmx_frontend¶
Structure that lists the frontends associated with a demux
Definition:
struct dmx_frontend { struct list_head connectivity_list; enum dmx_frontend_source source;};Members
connectivity_listList of front-ends that can be connected to aparticular demux;
sourceType of the frontend.
Description
- FIXME: this structure should likely be replaced soon by some
media-controller based logic.
- enumdmx_demux_caps¶
MPEG-2 TS Demux capabilities bitmap
Constants
DMX_TS_FILTERINGset if TS filtering is supported;
DMX_SECTION_FILTERINGset if section filtering is supported;
DMX_MEMORY_BASED_FILTERINGset if write() available.
Description
Those flags are OR’ed in thedmx_demux.capabilities field
- DMX_FE_ENTRY¶
DMX_FE_ENTRY(list)
Casts elements in the list of registered front-ends from the generic type
structlist_headto the type *structdmx_frontend
Parameters
listlist of
structdmx_frontend
- structdmx_demux¶
Structure that contains the demux capabilities and callbacks.
Definition:
struct dmx_demux { enum dmx_demux_caps capabilities; struct dmx_frontend *frontend; void *priv; int (*open)(struct dmx_demux *demux); int (*close)(struct dmx_demux *demux); int (*write)(struct dmx_demux *demux, const char __user *buf, size_t count); int (*allocate_ts_feed)(struct dmx_demux *demux, struct dmx_ts_feed **feed, dmx_ts_cb callback); int (*release_ts_feed)(struct dmx_demux *demux, struct dmx_ts_feed *feed); int (*allocate_section_feed)(struct dmx_demux *demux, struct dmx_section_feed **feed, dmx_section_cb callback); int (*release_section_feed)(struct dmx_demux *demux, struct dmx_section_feed *feed); int (*add_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend); int (*remove_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend); struct list_head *(*get_frontends)(struct dmx_demux *demux); int (*connect_frontend)(struct dmx_demux *demux, struct dmx_frontend *frontend); int (*disconnect_frontend)(struct dmx_demux *demux); int (*get_pes_pids)(struct dmx_demux *demux, u16 *pids);};Members
capabilitiesBitfield of capability flags.
frontendFront-end connected to the demux
privPointer to private data of the API client
openThis function reserves the demux for use by the caller and, ifnecessary, initializes the demux. When the demux is no longer needed,the functionclose should be called. It should be possible formultiple clients to access the demux at the same time. Thus, thefunction implementation should increment the demux usage count whenopen is called and decrement it whenclose is called.Thedemux function parameter contains a pointer to the demux API andinstance data.It returns:0 on success;-EUSERS, if maximum usage count was reached;-EINVAL, on bad parameter.
closeThis function reserves the demux for use by the caller and, ifnecessary, initializes the demux. When the demux is no longer needed,the functionclose should be called. It should be possible formultiple clients to access the demux at the same time. Thus, thefunction implementation should increment the demux usage count whenopen is called and decrement it whenclose is called.Thedemux function parameter contains a pointer to the demux API andinstance data.It returns:0 on success;-ENODEV, if demux was not in use (e. g. no users);-EINVAL, on bad parameter.
writeThis function provides the demux driver with a memory buffercontaining TS packets. Instead of receiving TS packets from the DVBfront-end, the demux driver software will read packets from memory.Any clients of this demux with active TS, PES or Section filters willreceive filtered data via the Demux callback API (see 0). The functionreturns when all the data in the buffer has been consumed by the demux.Demux hardware typically cannot read TS from memory. If this is thecase, memory-based filtering has to be implemented entirely in software.Thedemux function parameter contains a pointer to the demux API andinstance data.Thebuf function parameter contains a pointer to the TS data inkernel-space memory.Thecount function parameter contains the length of the TS data.It returns:0 on success;-ERESTARTSYS, if mutex lock was interrupted;-EINTR, if a signal handling is pending;-ENODEV, if demux was removed;-EINVAL, on bad parameter.
allocate_ts_feedAllocates a new TS feed, which is used to filter the TSpackets carrying a certain PID. The TS feed normally corresponds to ahardware PID filter on the demux chip.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefeed function parameter contains a pointer to the TS feed API andinstance data.Thecallback function parameter contains a pointer to the callbackfunction for passing received TS packet.It returns:0 on success;-ERESTARTSYS, if mutex lock was interrupted;-EBUSY, if no more TS feeds is available;-EINVAL, on bad parameter.
release_ts_feedReleases the resources allocated withallocate_ts_feed.Any filtering in progress on the TS feed should be stopped beforecalling this function.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefeed function parameter contains a pointer to the TS feed API andinstance data.It returns:0 on success;-EINVAL on bad parameter.
allocate_section_feedAllocates a new section feed, i.e. a demux resourcefor filtering and receiving sections. On platforms with hardwaresupport for section filtering, a section feed is directly mapped tothe demux HW. On other platforms, TS packets are first PID filtered inhardware and a hardware section filter then emulated in software. Thecaller obtains an API pointer of type dmx_section_feed_t as an outparameter. Using this API the caller can set filtering parameters andstart receiving sections.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefeed function parameter contains a pointer to the TS feed API andinstance data.Thecallback function parameter contains a pointer to the callbackfunction for passing received TS packet.It returns:0 on success;-EBUSY, if no more TS feeds is available;-EINVAL, on bad parameter.
release_section_feedReleases the resources allocated withallocate_section_feed, including allocated filters. Any filtering inprogress on the section feed should be stopped before calling thisfunction.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefeed function parameter contains a pointer to the TS feed API andinstance data.It returns:0 on success;-EINVAL, on bad parameter.
add_frontendRegisters a connectivity between a demux and a front-end,i.e., indicates that the demux can be connected via a call toconnect_frontend to use the given front-end as a TS source. Theclient of this function has to allocate dynamic or static memory forthe frontend structure and initialize its fields before calling thisfunction. This function is normally called during the driverinitialization. The caller must not free the memory of the frontend
structbeforesuccessfully callingremove_frontend.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefrontend function parameter contains a pointer to the front-endinstance data.It returns:0 on success;-EINVAL, on bad parameter.remove_frontendIndicates that the given front-end, registered by a calltoadd_frontend, can no longer be connected as a TS source by thisdemux. The function should be called when a front-end driver or a demuxdriver is removed from the system. If the front-end is in use, thefunction fails with the return value of -EBUSY. After successfullycalling this function, the caller can free the memory of the frontendstruct if it was dynamically allocated before theadd_frontendoperation.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefrontend function parameter contains a pointer to the front-endinstance data.It returns:0 on success;-ENODEV, if the front-end was not found,-EINVAL, on bad parameter.
get_frontendsProvides the APIs of the front-ends that have beenregistered for this demux. Any of the front-ends obtained with thiscall can be used as a parameter forconnect_frontend. The includefile demux.h contains the macro
DMX_FE_ENTRY()for converting anelement of the generic type structlist_head* to the typestructdmx_frontend. The caller must not free the memory of any ofthe elements obtained via this function call.The **demux* function parameter contains a pointer to the demux API andinstance data.It returns astructlist_headpointer to the list of front-endinterfaces, or NULL in the case of an empty list.connect_frontendConnects the TS output of the front-end to the input ofthe demux. A demux can only be connected to a front-end registered tothe demux with the functionadd_frontend. It may or may not bepossible to connect multiple demuxes to the same front-end, dependingon the capabilities of the HW platform. When not used, the front-endshould be released by callingdisconnect_frontend.Thedemux function parameter contains a pointer to the demux API andinstance data.Thefrontend function parameter contains a pointer to the front-endinstance data.It returns:0 on success;-EINVAL, on bad parameter.
disconnect_frontendDisconnects the demux and a front-end previouslyconnected by aconnect_frontend call.Thedemux function parameter contains a pointer to the demux API andinstance data.It returns:0 on success;-EINVAL on bad parameter.
get_pes_pidsGet the PIDs for DMX_PES_AUDIO0, DMX_PES_VIDEO0,DMX_PES_TELETEXT0, DMX_PES_SUBTITLE0 and DMX_PES_PCR0.Thedemux function parameter contains a pointer to the demux API andinstance data.Thepids function parameter contains an array with five u16 elementswhere the PIDs will be stored.It returns:0 on success;-EINVAL on bad parameter.