1<html><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.78.1"><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API"><link rel="up" href="dvbapi.html" title="Part II. LINUX DVB API"><link rel="prev" href="net_fcalls.html" title="DVB net Function Calls"><link rel="next" href="demux_directory_api.html" title="Demux Directory API"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><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="net_fcalls.html">Prev</a> </td><th width="60%" align="center">Part II. LINUX DVB API</th><td width="20%" align="right"> <a accesskey="n" href="demux_directory_api.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="dvb_kdapi"></a>Chapter 15. Kernel Demux API</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="dvb_kdapi.html#kernel_demux_data_types">Kernel Demux Data Types</a></span></dt><dd><dl><dt><span class="section"><a href="dvb_kdapi.html#dmx_success_t">dmx_success_t</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#ts_filter_types">TS filter types</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#dmx_ts_pes_t">dmx_ts_pes_t</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#demux_demux_t">demux_demux_t</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#demux_directory">Demux directory</a></span></dt></dl></dd><dt><span class="section"><a href="demux_directory_api.html">Demux Directory API</a></span></dt><dd><dl><dt><span class="section"><a href="demux_directory_api.html#idp1130738388">dmx_register_demux()</a></span></dt><dt><span class="section"><a href="demux_directory_api.html#idp1130747228">dmx_unregister_demux()</a></span></dt><dt><span class="section"><a href="demux_directory_api.html#idp1130756212">dmx_get_demuxes()</a></span></dt></dl></dd><dt><span class="section"><a href="demux_api.html">Demux API</a></span></dt><dd><dl><dt><span class="section"><a href="demux_api.html#kdapi_fopen">open()</a></span></dt><dt><span class="section"><a href="demux_api.html#kdapi_fclose">close()</a></span></dt><dt><span class="section"><a href="demux_api.html#kdapi_fwrite">write()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130795524">allocate_ts_feed()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130807564">release_ts_feed()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130816124">allocate_section_feed()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130828540">release_section_feed()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130837164">descramble_mac_address()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130851812">descramble_section_payload()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130868660">add_frontend()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130880988">remove_frontend()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130891156">get_frontends()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130898500">connect_frontend()</a></span></dt><dt><span class="section"><a href="demux_api.html#idp1130909076">disconnect_frontend()</a></span></dt></dl></dd><dt><span class="section"><a href="demux_callback_api.html">Demux Callback API</a></span></dt><dd><dl><dt><span class="section"><a href="demux_callback_api.html#idp1130918892">dmx_ts_cb()</a></span></dt><dt><span class="section"><a href="demux_callback_api.html#idp1130939420">dmx_section_cb()</a></span></dt></dl></dd><dt><span class="section"><a href="ts_feed_api.html">TS Feed API</a></span></dt><dd><dl><dt><span class="section"><a href="ts_feed_api.html#idp1130955484">set()</a></span></dt><dt><span class="section"><a href="ts_feed_api.html#idp1130971196">start_filtering()</a></span></dt><dt><span class="section"><a href="ts_feed_api.html#idp1130978764">stop_filtering()</a></span></dt></dl></dd><dt><span class="section"><a href="section_feed_api.html">Section Feed API</a></span></dt><dt><span class="section"><a href="kdapi_set.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, 2hardware specific driver to a hardware independent demux layer. It is only of interest for 3DVB device driver writers. The header file for this API is named <span class="tt">demux.h</span> and located in 4<span class="tt">drivers/media/dvb-core</span>. 5</p><p>Maintainer note: This section must be reviewed. It is probably out of date. 6</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="kernel_demux_data_types"></a>Kernel Demux Data Types</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="dvb_kdapi.html#dmx_success_t">dmx_success_t</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#ts_filter_types">TS filter types</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#dmx_ts_pes_t">dmx_ts_pes_t</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#demux_demux_t">demux_demux_t</a></span></dt><dt><span class="section"><a href="dvb_kdapi.html#demux_directory">Demux directory</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="dmx_success_t"></a>dmx_success_t</h3></div></div></div><pre class="programlisting"> 7 typedef enum { 8 DMX_OK = 0, /⋆ Received Ok ⋆/ 9 DMX_LENGTH_ERROR, /⋆ Incorrect length ⋆/ 10 DMX_OVERRUN_ERROR, /⋆ Receiver ring buffer overrun ⋆/ 11 DMX_CRC_ERROR, /⋆ Incorrect CRC ⋆/ 12 DMX_FRAME_ERROR, /⋆ Frame alignment error ⋆/ 13 DMX_FIFO_ERROR, /⋆ Receiver FIFO overrun ⋆/ 14 DMX_MISSED_ERROR /⋆ Receiver missed packet ⋆/ 15 } dmx_success_t; 16</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="ts_filter_types"></a>TS filter types</h3></div></div></div><pre class="programlisting"> 17 /⋆--------------------------------------------------------------------------⋆/ 18 /⋆ TS packet reception ⋆/ 19 /⋆--------------------------------------------------------------------------⋆/ 20 21 /⋆ TS filter type for set_type() ⋆/ 22 23 #define TS_PACKET 1 /⋆ send TS packets (188 bytes) to callback (default) ⋆/ 24 #define TS_PAYLOAD_ONLY 2 /⋆ in case TS_PACKET is set, only send the TS 25 payload (<=184 bytes per packet) to callback ⋆/ 26 #define TS_DECODER 4 /⋆ send stream to built-in decoder (if present) ⋆/ 27</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="dmx_ts_pes_t"></a>dmx_ts_pes_t</h3></div></div></div><p>The structure 28</p><pre class="programlisting"> 29 typedef enum 30 { 31 DMX_TS_PES_AUDIO, /⋆ also send packets to audio decoder (if it exists) ⋆/ 32 DMX_TS_PES_VIDEO, /⋆ ... ⋆/ 33 DMX_TS_PES_TELETEXT, 34 DMX_TS_PES_SUBTITLE, 35 DMX_TS_PES_PCR, 36 DMX_TS_PES_OTHER, 37 } dmx_ts_pes_t; 38</pre><p>describes the PES type for filters which write to a built-in decoder. The correspond (and 39should be kept identical) to the types in the demux device. 40</p><pre class="programlisting"> 41 struct dmx_ts_feed_s { 42 int is_filtering; /⋆ Set to non-zero when filtering in progress ⋆/ 43 struct dmx_demux_s⋆ parent; /⋆ Back-pointer ⋆/ 44 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 45 int (⋆set) (struct dmx_ts_feed_s⋆ feed, 46 __u16 pid, 47 size_t callback_length, 48 size_t circular_buffer_size, 49 int descramble, 50 struct timespec timeout); 51 int (⋆start_filtering) (struct dmx_ts_feed_s⋆ feed); 52 int (⋆stop_filtering) (struct dmx_ts_feed_s⋆ feed); 53 int (⋆set_type) (struct dmx_ts_feed_s⋆ feed, 54 int type, 55 dmx_ts_pes_t pes_type); 56 }; 57 58 typedef struct dmx_ts_feed_s dmx_ts_feed_t; 59</pre><pre class="programlisting"> 60 /⋆--------------------------------------------------------------------------⋆/ 61 /⋆ PES packet reception (not supported yet) ⋆/ 62 /⋆--------------------------------------------------------------------------⋆/ 63 64 typedef struct dmx_pes_filter_s { 65 struct dmx_pes_s⋆ parent; /⋆ Back-pointer ⋆/ 66 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 67 } dmx_pes_filter_t; 68</pre><pre class="programlisting"> 69 typedef struct dmx_pes_feed_s { 70 int is_filtering; /⋆ Set to non-zero when filtering in progress ⋆/ 71 struct dmx_demux_s⋆ parent; /⋆ Back-pointer ⋆/ 72 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 73 int (⋆set) (struct dmx_pes_feed_s⋆ feed, 74 __u16 pid, 75 size_t circular_buffer_size, 76 int descramble, 77 struct timespec timeout); 78 int (⋆start_filtering) (struct dmx_pes_feed_s⋆ feed); 79 int (⋆stop_filtering) (struct dmx_pes_feed_s⋆ feed); 80 int (⋆allocate_filter) (struct dmx_pes_feed_s⋆ feed, 81 dmx_pes_filter_t⋆⋆ filter); 82 int (⋆release_filter) (struct dmx_pes_feed_s⋆ feed, 83 dmx_pes_filter_t⋆ filter); 84 } dmx_pes_feed_t; 85</pre><pre class="programlisting"> 86 typedef struct { 87 __u8 filter_value [DMX_MAX_FILTER_SIZE]; 88 __u8 filter_mask [DMX_MAX_FILTER_SIZE]; 89 struct dmx_section_feed_s⋆ parent; /⋆ Back-pointer ⋆/ 90 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 91 } dmx_section_filter_t; 92</pre><pre class="programlisting"> 93 struct dmx_section_feed_s { 94 int is_filtering; /⋆ Set to non-zero when filtering in progress ⋆/ 95 struct dmx_demux_s⋆ parent; /⋆ Back-pointer ⋆/ 96 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 97 int (⋆set) (struct dmx_section_feed_s⋆ feed, 98 __u16 pid, 99 size_t circular_buffer_size, 100 int descramble, 101 int check_crc); 102 int (⋆allocate_filter) (struct dmx_section_feed_s⋆ feed, 103 dmx_section_filter_t⋆⋆ filter); 104 int (⋆release_filter) (struct dmx_section_feed_s⋆ feed, 105 dmx_section_filter_t⋆ filter); 106 int (⋆start_filtering) (struct dmx_section_feed_s⋆ feed); 107 int (⋆stop_filtering) (struct dmx_section_feed_s⋆ feed); 108 }; 109 typedef struct dmx_section_feed_s dmx_section_feed_t; 110 111 /⋆--------------------------------------------------------------------------⋆/ 112 /⋆ Callback functions ⋆/ 113 /⋆--------------------------------------------------------------------------⋆/ 114 115 typedef int (⋆dmx_ts_cb) ( __u8 ⋆ buffer1, 116 size_t buffer1_length, 117 __u8 ⋆ buffer2, 118 size_t buffer2_length, 119 dmx_ts_feed_t⋆ source, 120 dmx_success_t success); 121 122 typedef int (⋆dmx_section_cb) ( __u8 ⋆ buffer1, 123 size_t buffer1_len, 124 __u8 ⋆ buffer2, 125 size_t buffer2_len, 126 dmx_section_filter_t ⋆ source, 127 dmx_success_t success); 128 129 typedef int (⋆dmx_pes_cb) ( __u8 ⋆ buffer1, 130 size_t buffer1_len, 131 __u8 ⋆ buffer2, 132 size_t buffer2_len, 133 dmx_pes_filter_t⋆ source, 134 dmx_success_t success); 135 136 /⋆--------------------------------------------------------------------------⋆/ 137 /⋆ DVB Front-End ⋆/ 138 /⋆--------------------------------------------------------------------------⋆/ 139 140 typedef enum { 141 DMX_OTHER_FE = 0, 142 DMX_SATELLITE_FE, 143 DMX_CABLE_FE, 144 DMX_TERRESTRIAL_FE, 145 DMX_LVDS_FE, 146 DMX_ASI_FE, /⋆ DVB-ASI interface ⋆/ 147 DMX_MEMORY_FE 148 } dmx_frontend_source_t; 149 150 typedef struct { 151 /⋆ The following char⋆ fields point to NULL terminated strings ⋆/ 152 char⋆ id; /⋆ Unique front-end identifier ⋆/ 153 char⋆ vendor; /⋆ Name of the front-end vendor ⋆/ 154 char⋆ model; /⋆ Name of the front-end model ⋆/ 155 struct list_head connectivity_list; /⋆ List of front-ends that can 156 be connected to a particular 157 demux ⋆/ 158 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 159 dmx_frontend_source_t source; 160 } dmx_frontend_t; 161 162 /⋆--------------------------------------------------------------------------⋆/ 163 /⋆ MPEG-2 TS Demux ⋆/ 164 /⋆--------------------------------------------------------------------------⋆/ 165 166 /⋆ 167 ⋆ Flags OR'ed in the capabilites field of struct dmx_demux_s. 168 ⋆/ 169 170 #define DMX_TS_FILTERING 1 171 #define DMX_PES_FILTERING 2 172 #define DMX_SECTION_FILTERING 4 173 #define DMX_MEMORY_BASED_FILTERING 8 /⋆ write() available ⋆/ 174 #define DMX_CRC_CHECKING 16 175 #define DMX_TS_DESCRAMBLING 32 176 #define DMX_SECTION_PAYLOAD_DESCRAMBLING 64 177 #define DMX_MAC_ADDRESS_DESCRAMBLING 128 178</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="demux_demux_t"></a>demux_demux_t</h3></div></div></div><pre class="programlisting"> 179 /⋆ 180 ⋆ DMX_FE_ENTRY(): Casts elements in the list of registered 181 ⋆ front-ends from the generic type struct list_head 182 ⋆ to the type ⋆ dmx_frontend_t 183 ⋆. 184 ⋆/ 185 186 #define DMX_FE_ENTRY(list) list_entry(list, dmx_frontend_t, connectivity_list) 187 188 struct dmx_demux_s { 189 /⋆ The following char⋆ fields point to NULL terminated strings ⋆/ 190 char⋆ id; /⋆ Unique demux identifier ⋆/ 191 char⋆ vendor; /⋆ Name of the demux vendor ⋆/ 192 char⋆ model; /⋆ Name of the demux model ⋆/ 193 __u32 capabilities; /⋆ Bitfield of capability flags ⋆/ 194 dmx_frontend_t⋆ frontend; /⋆ Front-end connected to the demux ⋆/ 195 struct list_head reg_list; /⋆ List of registered demuxes ⋆/ 196 void⋆ priv; /⋆ Pointer to private data of the API client ⋆/ 197 int users; /⋆ Number of users ⋆/ 198 int (⋆open) (struct dmx_demux_s⋆ demux); 199 int (⋆close) (struct dmx_demux_s⋆ demux); 200 int (⋆write) (struct dmx_demux_s⋆ demux, const char⋆ buf, size_t count); 201 int (⋆allocate_ts_feed) (struct dmx_demux_s⋆ demux, 202 dmx_ts_feed_t⋆⋆ feed, 203 dmx_ts_cb callback); 204 int (⋆release_ts_feed) (struct dmx_demux_s⋆ demux, 205 dmx_ts_feed_t⋆ feed); 206 int (⋆allocate_pes_feed) (struct dmx_demux_s⋆ demux, 207 dmx_pes_feed_t⋆⋆ feed, 208 dmx_pes_cb callback); 209 int (⋆release_pes_feed) (struct dmx_demux_s⋆ demux, 210 dmx_pes_feed_t⋆ feed); 211 int (⋆allocate_section_feed) (struct dmx_demux_s⋆ demux, 212 dmx_section_feed_t⋆⋆ feed, 213 dmx_section_cb callback); 214 int (⋆release_section_feed) (struct dmx_demux_s⋆ demux, 215 dmx_section_feed_t⋆ feed); 216 int (⋆descramble_mac_address) (struct dmx_demux_s⋆ demux, 217 __u8⋆ buffer1, 218 size_t buffer1_length, 219 __u8⋆ buffer2, 220 size_t buffer2_length, 221 __u16 pid); 222 int (⋆descramble_section_payload) (struct dmx_demux_s⋆ demux, 223 __u8⋆ buffer1, 224 size_t buffer1_length, 225 __u8⋆ buffer2, size_t buffer2_length, 226 __u16 pid); 227 int (⋆add_frontend) (struct dmx_demux_s⋆ demux, 228 dmx_frontend_t⋆ frontend); 229 int (⋆remove_frontend) (struct dmx_demux_s⋆ demux, 230 dmx_frontend_t⋆ frontend); 231 struct list_head⋆ (⋆get_frontends) (struct dmx_demux_s⋆ demux); 232 int (⋆connect_frontend) (struct dmx_demux_s⋆ demux, 233 dmx_frontend_t⋆ frontend); 234 int (⋆disconnect_frontend) (struct dmx_demux_s⋆ demux); 235 236 237 /⋆ added because js cannot keep track of these himself ⋆/ 238 int (⋆get_pes_pids) (struct dmx_demux_s⋆ demux, __u16 ⋆pids); 239 }; 240 typedef struct dmx_demux_s dmx_demux_t; 241</pre></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="demux_directory"></a>Demux directory</h3></div></div></div><pre class="programlisting"> 242 /⋆ 243 ⋆ DMX_DIR_ENTRY(): Casts elements in the list of registered 244 ⋆ demuxes from the generic type struct list_head⋆ to the type dmx_demux_t 245 ⋆. 246 ⋆/ 247 248 #define DMX_DIR_ENTRY(list) list_entry(list, dmx_demux_t, reg_list) 249 250 int dmx_register_demux (dmx_demux_t⋆ demux); 251 int dmx_unregister_demux (dmx_demux_t⋆ demux); 252 struct list_head⋆ dmx_get_demuxes (void); 253</pre></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="net_fcalls.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="dvbapi.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="demux_directory_api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">DVB net Function Calls </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> 254