<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Chapter 15. Kernel Demux API</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="pt02.html" title="Part II. LINUX DVB API" /><link rel="prev" href="ch14.html" title="Chapter 14. DVB Network API" /><link rel="next" href="ch15s02.html" title="Demux Directory API" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 15. Kernel Demux API</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch14.html">Prev</a> </td><th width="60%" align="center">Part II. LINUX DVB API</th><td width="20%" align="right"> <a accesskey="n" href="ch15s02.html">Next</a></td></tr></table><hr /></div><div class="chapter" title="Chapter 15. Kernel Demux API"><div class="titlepage"><div><div><h2 class="title"><a id="dvb_kdapi"></a>Chapter 15. Kernel Demux API</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ch15.html#kernel_demux_data_types">Kernel Demux Data Types</a></span></dt><dd><dl><dt><span class="section"><a href="ch15.html#dmx_success_t">dmx_success_t</a></span></dt><dt><span class="section"><a href="ch15.html#ts_filter_types">TS filter types</a></span></dt><dt><span class="section"><a href="ch15.html#dmx_ts_pes_t">dmx_ts_pes_t</a></span></dt><dt><span class="section"><a href="ch15.html#demux_demux_t">demux_demux_t</a></span></dt><dt><span class="section"><a href="ch15.html#demux_directory">Demux directory</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s02.html">Demux Directory API</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s02.html#id2873402">dmx_register_demux()</a></span></dt><dt><span class="section"><a href="ch15s02.html#id2873550">dmx_unregister_demux()</a></span></dt><dt><span class="section"><a href="ch15s02.html#id2873700">dmx_get_demuxes()</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s03.html">Demux API</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s03.html#kdapi_fopen">open()</a></span></dt><dt><span class="section"><a href="ch15s03.html#kdapi_fclose">close()</a></span></dt><dt><span class="section"><a href="ch15s03.html#kdapi_fwrite">write()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2874357">allocate_ts_feed()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2874557">release_ts_feed()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2874700">allocate_section_feed()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2874907">release_section_feed()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2875051">descramble_mac_address()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2875295">descramble_section_payload()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2875576">add_frontend()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2875781">remove_frontend()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2875951">get_frontends()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2876073">connect_frontend()</a></span></dt><dt><span class="section"><a href="ch15s03.html#id2876249">disconnect_frontend()</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s04.html">Demux Callback API</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s04.html#id2876413">dmx_ts_cb()</a></span></dt><dt><span class="section"><a href="ch15s04.html#id2876755">dmx_section_cb()</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s05.html">TS Feed API</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s05.html#id2877022">set()</a></span></dt><dt><span class="section"><a href="ch15s05.html#id2877284">start_filtering()</a></span></dt><dt><span class="section"><a href="ch15s05.html#id2877410">stop_filtering()</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s06.html">Section Feed API</a></span></dt><dt><span class="section"><a href="ch15s07.html">set()</a></span></dt><dt><span class="section"><a href="ch15s08.html">allocate_filter()</a></span></dt><dt><span class="section"><a href="ch15s09.html">release_filter()</a></span></dt><dt><span class="section"><a href="ch15s10.html">start_filtering()</a></span></dt><dt><span class="section"><a href="ch15s11.html">stop_filtering()</a></span></dt></dl></div><p>The kernel demux API defines a driver-internal interface for registering low-level, hardware specific driver to a hardware independent demux layer. It is only of interest for DVB device driver writers. The header file for this API is named <span class="tt">demux.h</span> and located in <span class="tt">drivers/media/dvb/dvb-core</span>. </p><p>Maintainer note: This section must be reviewed. It is probably out of date. </p><div class="section" title="Kernel Demux Data Types"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="kernel_demux_data_types"></a>Kernel Demux Data Types</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="ch15.html#dmx_success_t">dmx_success_t</a></span></dt><dt><span class="section"><a href="ch15.html#ts_filter_types">TS filter types</a></span></dt><dt><span class="section"><a href="ch15.html#dmx_ts_pes_t">dmx_ts_pes_t</a></span></dt><dt><span class="section"><a href="ch15.html#demux_demux_t">demux_demux_t</a></span></dt><dt><span class="section"><a href="ch15.html#demux_directory">Demux directory</a></span></dt></dl></div><div class="section" title="dmx_success_t"><div class="titlepage"><div><div><h3 class="title"><a id="dmx_success_t"></a>dmx_success_t</h3></div></div></div><pre class="programlisting"> typedef enum { DMX_OK = 0, /⋆ Received Ok ⋆/ DMX_LENGTH_ERROR, /⋆ Incorrect length ⋆/ DMX_OVERRUN_ERROR, /⋆ Receiver ring buffer overrun ⋆/ DMX_CRC_ERROR, /⋆ Incorrect CRC ⋆/ DMX_FRAME_ERROR, /⋆ Frame alignment error ⋆/ DMX_FIFO_ERROR, /⋆ Receiver FIFO overrun ⋆/ DMX_MISSED_ERROR /⋆ Receiver missed packet ⋆/ } dmx_success_t; </pre></div><div class="section" title="TS filter types"><div class="titlepage"><div><div><h3 class="title"><a id="ts_filter_types"></a>TS filter types</h3></div></div></div><pre class="programlisting"> /⋆--------------------------------------------------------------------------⋆/ /⋆ TS packet reception ⋆/ /⋆--------------------------------------------------------------------------⋆/ /⋆ TS filter type for set_type() ⋆/ #define TS_PACKET 1 /⋆ send TS packets (188 bytes) to callback (default) ⋆/ #define TS_PAYLOAD_ONLY 2 /⋆ in case TS_PACKET is set, only send the TS payload (<=184 bytes per packet) to callback ⋆/ #define TS_DECODER 4 /⋆ send stream to built-in decoder (if present) ⋆/ </pre></div><div class="section" title="dmx_ts_pes_t"><div class="titlepage"><div><div><h3 class="title"><a id="dmx_ts_pes_t"></a>dmx_ts_pes_t</h3></div></div></div><p>The structure </p><pre class="programlisting"> typedef enum { DMX_TS_PES_AUDIO, /⋆ also send packets to audio decoder (if it exists) ⋆/ DMX_TS_PES_VIDEO, /⋆ ... ⋆/ DMX_TS_PES_TELETEXT, DMX_TS_PES_SUBTITLE, DMX_TS_PES_PCR, DMX_TS_PES_OTHER, } dmx_ts_pes_t; </pre><p>describes the PES type for filters which write to a built-in decoder. The correspond (and should be kept identical) to the types in the demux device. </p><pre class="programlisting"> struct dmx_ts_feed_s { int is_filtering; /⋆ Set to non-zero when filtering in progress ⋆/ struct dmx_demux_s⋆ parent; /⋆ Back-pointer ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ int (⋆set) (struct dmx_ts_feed_s⋆ feed, __u16 pid, size_t callback_length, size_t circular_buffer_size, int descramble, struct timespec timeout); int (⋆start_filtering) (struct dmx_ts_feed_s⋆ feed); int (⋆stop_filtering) (struct dmx_ts_feed_s⋆ feed); int (⋆set_type) (struct dmx_ts_feed_s⋆ feed, int type, dmx_ts_pes_t pes_type); }; typedef struct dmx_ts_feed_s dmx_ts_feed_t; </pre><pre class="programlisting"> /⋆--------------------------------------------------------------------------⋆/ /⋆ PES packet reception (not supported yet) ⋆/ /⋆--------------------------------------------------------------------------⋆/ typedef struct dmx_pes_filter_s { struct dmx_pes_s⋆ parent; /⋆ Back-pointer ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ } dmx_pes_filter_t; </pre><pre class="programlisting"> typedef struct dmx_pes_feed_s { int is_filtering; /⋆ Set to non-zero when filtering in progress ⋆/ struct dmx_demux_s⋆ parent; /⋆ Back-pointer ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ int (⋆set) (struct dmx_pes_feed_s⋆ feed, __u16 pid, size_t circular_buffer_size, int descramble, struct timespec timeout); int (⋆start_filtering) (struct dmx_pes_feed_s⋆ feed); int (⋆stop_filtering) (struct dmx_pes_feed_s⋆ feed); int (⋆allocate_filter) (struct dmx_pes_feed_s⋆ feed, dmx_pes_filter_t⋆⋆ filter); int (⋆release_filter) (struct dmx_pes_feed_s⋆ feed, dmx_pes_filter_t⋆ filter); } dmx_pes_feed_t; </pre><pre class="programlisting"> typedef struct { __u8 filter_value [DMX_MAX_FILTER_SIZE]; __u8 filter_mask [DMX_MAX_FILTER_SIZE]; struct dmx_section_feed_s⋆ parent; /⋆ Back-pointer ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ } dmx_section_filter_t; </pre><pre class="programlisting"> struct dmx_section_feed_s { int is_filtering; /⋆ Set to non-zero when filtering in progress ⋆/ struct dmx_demux_s⋆ parent; /⋆ Back-pointer ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ int (⋆set) (struct dmx_section_feed_s⋆ feed, __u16 pid, size_t circular_buffer_size, int descramble, int check_crc); int (⋆allocate_filter) (struct dmx_section_feed_s⋆ feed, dmx_section_filter_t⋆⋆ filter); int (⋆release_filter) (struct dmx_section_feed_s⋆ feed, dmx_section_filter_t⋆ filter); int (⋆start_filtering) (struct dmx_section_feed_s⋆ feed); int (⋆stop_filtering) (struct dmx_section_feed_s⋆ feed); }; typedef struct dmx_section_feed_s dmx_section_feed_t; /⋆--------------------------------------------------------------------------⋆/ /⋆ Callback functions ⋆/ /⋆--------------------------------------------------------------------------⋆/ typedef int (⋆dmx_ts_cb) ( __u8 ⋆ buffer1, size_t buffer1_length, __u8 ⋆ buffer2, size_t buffer2_length, dmx_ts_feed_t⋆ source, dmx_success_t success); typedef int (⋆dmx_section_cb) ( __u8 ⋆ buffer1, size_t buffer1_len, __u8 ⋆ buffer2, size_t buffer2_len, dmx_section_filter_t ⋆ source, dmx_success_t success); typedef int (⋆dmx_pes_cb) ( __u8 ⋆ buffer1, size_t buffer1_len, __u8 ⋆ buffer2, size_t buffer2_len, dmx_pes_filter_t⋆ source, dmx_success_t success); /⋆--------------------------------------------------------------------------⋆/ /⋆ DVB Front-End ⋆/ /⋆--------------------------------------------------------------------------⋆/ typedef enum { DMX_OTHER_FE = 0, DMX_SATELLITE_FE, DMX_CABLE_FE, DMX_TERRESTRIAL_FE, DMX_LVDS_FE, DMX_ASI_FE, /⋆ DVB-ASI interface ⋆/ DMX_MEMORY_FE } dmx_frontend_source_t; typedef struct { /⋆ The following char⋆ fields point to NULL terminated strings ⋆/ char⋆ id; /⋆ Unique front-end identifier ⋆/ char⋆ vendor; /⋆ Name of the front-end vendor ⋆/ char⋆ model; /⋆ Name of the front-end model ⋆/ struct list_head connectivity_list; /⋆ List of front-ends that can be connected to a particular demux ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ dmx_frontend_source_t source; } dmx_frontend_t; /⋆--------------------------------------------------------------------------⋆/ /⋆ MPEG-2 TS Demux ⋆/ /⋆--------------------------------------------------------------------------⋆/ /⋆ ⋆ Flags OR'ed in the capabilites field of struct dmx_demux_s. ⋆/ #define DMX_TS_FILTERING 1 #define DMX_PES_FILTERING 2 #define DMX_SECTION_FILTERING 4 #define DMX_MEMORY_BASED_FILTERING 8 /⋆ write() available ⋆/ #define DMX_CRC_CHECKING 16 #define DMX_TS_DESCRAMBLING 32 #define DMX_SECTION_PAYLOAD_DESCRAMBLING 64 #define DMX_MAC_ADDRESS_DESCRAMBLING 128 </pre></div><div class="section" title="demux_demux_t"><div class="titlepage"><div><div><h3 class="title"><a id="demux_demux_t"></a>demux_demux_t</h3></div></div></div><pre class="programlisting"> /⋆ ⋆ DMX_FE_ENTRY(): Casts elements in the list of registered ⋆ front-ends from the generic type struct list_head ⋆ to the type ⋆ dmx_frontend_t ⋆. ⋆/ #define DMX_FE_ENTRY(list) list_entry(list, dmx_frontend_t, connectivity_list) struct dmx_demux_s { /⋆ The following char⋆ fields point to NULL terminated strings ⋆/ char⋆ id; /⋆ Unique demux identifier ⋆/ char⋆ vendor; /⋆ Name of the demux vendor ⋆/ char⋆ model; /⋆ Name of the demux model ⋆/ __u32 capabilities; /⋆ Bitfield of capability flags ⋆/ dmx_frontend_t⋆ frontend; /⋆ Front-end connected to the demux ⋆/ struct list_head reg_list; /⋆ List of registered demuxes ⋆/ void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ int users; /⋆ Number of users ⋆/ int (⋆open) (struct dmx_demux_s⋆ demux); int (⋆close) (struct dmx_demux_s⋆ demux); int (⋆write) (struct dmx_demux_s⋆ demux, const char⋆ buf, size_t count); int (⋆allocate_ts_feed) (struct dmx_demux_s⋆ demux, dmx_ts_feed_t⋆⋆ feed, dmx_ts_cb callback); int (⋆release_ts_feed) (struct dmx_demux_s⋆ demux, dmx_ts_feed_t⋆ feed); int (⋆allocate_pes_feed) (struct dmx_demux_s⋆ demux, dmx_pes_feed_t⋆⋆ feed, dmx_pes_cb callback); int (⋆release_pes_feed) (struct dmx_demux_s⋆ demux, dmx_pes_feed_t⋆ feed); int (⋆allocate_section_feed) (struct dmx_demux_s⋆ demux, dmx_section_feed_t⋆⋆ feed, dmx_section_cb callback); int (⋆release_section_feed) (struct dmx_demux_s⋆ demux, dmx_section_feed_t⋆ feed); int (⋆descramble_mac_address) (struct dmx_demux_s⋆ demux, __u8⋆ buffer1, size_t buffer1_length, __u8⋆ buffer2, size_t buffer2_length, __u16 pid); int (⋆descramble_section_payload) (struct dmx_demux_s⋆ demux, __u8⋆ buffer1, size_t buffer1_length, __u8⋆ buffer2, size_t buffer2_length, __u16 pid); int (⋆add_frontend) (struct dmx_demux_s⋆ demux, dmx_frontend_t⋆ frontend); int (⋆remove_frontend) (struct dmx_demux_s⋆ demux, dmx_frontend_t⋆ frontend); struct list_head⋆ (⋆get_frontends) (struct dmx_demux_s⋆ demux); int (⋆connect_frontend) (struct dmx_demux_s⋆ demux, dmx_frontend_t⋆ frontend); int (⋆disconnect_frontend) (struct dmx_demux_s⋆ demux); /⋆ added because js cannot keep track of these himself ⋆/ int (⋆get_pes_pids) (struct dmx_demux_s⋆ demux, __u16 ⋆pids); }; typedef struct dmx_demux_s dmx_demux_t; </pre></div><div class="section" title="Demux directory"><div class="titlepage"><div><div><h3 class="title"><a id="demux_directory"></a>Demux directory</h3></div></div></div><pre class="programlisting"> /⋆ ⋆ DMX_DIR_ENTRY(): Casts elements in the list of registered ⋆ demuxes from the generic type struct list_head⋆ to the type dmx_demux_t ⋆. ⋆/ #define DMX_DIR_ENTRY(list) list_entry(list, dmx_demux_t, reg_list) int dmx_register_demux (dmx_demux_t⋆ demux); int dmx_unregister_demux (dmx_demux_t⋆ demux); struct list_head⋆ dmx_get_demuxes (void); </pre></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch14.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="pt02.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch15s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 14. DVB Network API </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Demux Directory API</td></tr></table></div></body></html>