1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Chapter&#160;15.&#160;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&#160;II.&#160;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&#160;15.&#160;Kernel Demux API</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="net_fcalls.html">Prev</a>&#160;</td><th width="60%" align="center">Part&#160;II.&#160;LINUX DVB API</th><td width="20%" align="right">&#160;<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&#160;15.&#160;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, /&#8902; Received Ok &#8902;/
9   DMX_LENGTH_ERROR, /&#8902; Incorrect length &#8902;/
10   DMX_OVERRUN_ERROR, /&#8902; Receiver ring buffer overrun &#8902;/
11   DMX_CRC_ERROR, /&#8902; Incorrect CRC &#8902;/
12   DMX_FRAME_ERROR, /&#8902; Frame alignment error &#8902;/
13   DMX_FIFO_ERROR, /&#8902; Receiver FIFO overrun &#8902;/
14   DMX_MISSED_ERROR /&#8902; Receiver missed packet &#8902;/
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 /&#8902;--------------------------------------------------------------------------&#8902;/
18 /&#8902; TS packet reception &#8902;/
19 /&#8902;--------------------------------------------------------------------------&#8902;/
20
21 /&#8902; TS filter type for set_type() &#8902;/
22
23 #define TS_PACKET       1   /&#8902; send TS packets (188 bytes) to callback (default) &#8902;/
24 #define TS_PAYLOAD_ONLY 2   /&#8902; in case TS_PACKET is set, only send the TS
25				payload (&lt;=184 bytes per packet) to callback &#8902;/
26 #define TS_DECODER      4   /&#8902; send stream to built-in decoder (if present) &#8902;/
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,   /&#8902; also send packets to audio decoder (if it exists) &#8902;/
32	 DMX_TS_PES_VIDEO,   /&#8902; ... &#8902;/
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; /&#8902; Set to non-zero when filtering in progress &#8902;/
43	 struct dmx_demux_s&#8902; parent; /&#8902; Back-pointer &#8902;/
44	 void&#8902; priv; /&#8902; Pointer to private data of the API client &#8902;/
45	 int (&#8902;set) (struct dmx_ts_feed_s&#8902; feed,
46		     __u16 pid,
47		     size_t callback_length,
48		     size_t circular_buffer_size,
49		     int descramble,
50		     struct timespec timeout);
51	 int (&#8902;start_filtering) (struct dmx_ts_feed_s&#8902; feed);
52	 int (&#8902;stop_filtering) (struct dmx_ts_feed_s&#8902; feed);
53	 int (&#8902;set_type) (struct dmx_ts_feed_s&#8902; 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 /&#8902;--------------------------------------------------------------------------&#8902;/
61 /&#8902; PES packet reception (not supported yet) &#8902;/
62 /&#8902;--------------------------------------------------------------------------&#8902;/
63
64 typedef struct dmx_pes_filter_s {
65	 struct dmx_pes_s&#8902; parent; /&#8902; Back-pointer &#8902;/
66	 void&#8902; priv; /&#8902; Pointer to private data of the API client &#8902;/
67 } dmx_pes_filter_t;
68</pre><pre class="programlisting">
69 typedef struct dmx_pes_feed_s {
70	 int is_filtering; /&#8902; Set to non-zero when filtering in progress &#8902;/
71	 struct dmx_demux_s&#8902; parent; /&#8902; Back-pointer &#8902;/
72	 void&#8902; priv; /&#8902; Pointer to private data of the API client &#8902;/
73	 int (&#8902;set) (struct dmx_pes_feed_s&#8902; feed,
74		     __u16 pid,
75		     size_t circular_buffer_size,
76		     int descramble,
77		     struct timespec timeout);
78	 int (&#8902;start_filtering) (struct dmx_pes_feed_s&#8902; feed);
79	 int (&#8902;stop_filtering) (struct dmx_pes_feed_s&#8902; feed);
80	 int (&#8902;allocate_filter) (struct dmx_pes_feed_s&#8902; feed,
81				 dmx_pes_filter_t&#8902;&#8902; filter);
82	 int (&#8902;release_filter) (struct dmx_pes_feed_s&#8902; feed,
83				dmx_pes_filter_t&#8902; 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&#8902; parent; /&#8902; Back-pointer &#8902;/
90	 void&#8902; priv; /&#8902; Pointer to private data of the API client &#8902;/
91 } dmx_section_filter_t;
92</pre><pre class="programlisting">
93 struct dmx_section_feed_s {
94	 int is_filtering; /&#8902; Set to non-zero when filtering in progress &#8902;/
95	 struct dmx_demux_s&#8902; parent; /&#8902; Back-pointer &#8902;/
96	 void&#8902; priv; /&#8902; Pointer to private data of the API client &#8902;/
97	 int (&#8902;set) (struct dmx_section_feed_s&#8902; feed,
98		     __u16 pid,
99		     size_t circular_buffer_size,
100		     int descramble,
101		     int check_crc);
102	 int (&#8902;allocate_filter) (struct dmx_section_feed_s&#8902; feed,
103				 dmx_section_filter_t&#8902;&#8902; filter);
104	 int (&#8902;release_filter) (struct dmx_section_feed_s&#8902; feed,
105				dmx_section_filter_t&#8902; filter);
106	 int (&#8902;start_filtering) (struct dmx_section_feed_s&#8902; feed);
107	 int (&#8902;stop_filtering) (struct dmx_section_feed_s&#8902; feed);
108 };
109 typedef struct dmx_section_feed_s dmx_section_feed_t;
110
111 /&#8902;--------------------------------------------------------------------------&#8902;/
112 /&#8902; Callback functions &#8902;/
113 /&#8902;--------------------------------------------------------------------------&#8902;/
114
115 typedef int (&#8902;dmx_ts_cb) ( __u8 &#8902; buffer1,
116			    size_t buffer1_length,
117			    __u8 &#8902; buffer2,
118			    size_t buffer2_length,
119			    dmx_ts_feed_t&#8902; source,
120			    dmx_success_t success);
121
122 typedef int (&#8902;dmx_section_cb) ( __u8 &#8902; buffer1,
123				 size_t buffer1_len,
124				 __u8 &#8902; buffer2,
125				 size_t buffer2_len,
126				 dmx_section_filter_t &#8902; source,
127				 dmx_success_t success);
128
129 typedef int (&#8902;dmx_pes_cb) ( __u8 &#8902; buffer1,
130			     size_t buffer1_len,
131			     __u8 &#8902; buffer2,
132			     size_t buffer2_len,
133			     dmx_pes_filter_t&#8902; source,
134			     dmx_success_t success);
135
136 /&#8902;--------------------------------------------------------------------------&#8902;/
137 /&#8902; DVB Front-End &#8902;/
138 /&#8902;--------------------------------------------------------------------------&#8902;/
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, /&#8902; DVB-ASI interface &#8902;/
147	 DMX_MEMORY_FE
148 } dmx_frontend_source_t;
149
150 typedef struct {
151	 /&#8902; The following char&#8902; fields point to NULL terminated strings &#8902;/
152	 char&#8902; id;                    /&#8902; Unique front-end identifier &#8902;/
153	 char&#8902; vendor;                /&#8902; Name of the front-end vendor &#8902;/
154	 char&#8902; model;                 /&#8902; Name of the front-end model &#8902;/
155	 struct list_head connectivity_list; /&#8902; List of front-ends that can
156						be connected to a particular
157						demux &#8902;/
158	 void&#8902; priv;     /&#8902; Pointer to private data of the API client &#8902;/
159	 dmx_frontend_source_t source;
160 } dmx_frontend_t;
161
162 /&#8902;--------------------------------------------------------------------------&#8902;/
163 /&#8902; MPEG-2 TS Demux &#8902;/
164 /&#8902;--------------------------------------------------------------------------&#8902;/
165
166 /&#8902;
167  &#8902; Flags OR'ed in the capabilites field of struct dmx_demux_s.
168  &#8902;/
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    /&#8902; write() available &#8902;/
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 /&#8902;
180  &#8902; DMX_FE_ENTRY(): Casts elements in the list of registered
181  &#8902; front-ends from the generic type struct list_head
182  &#8902; to the type &#8902; dmx_frontend_t
183  &#8902;.
184 &#8902;/
185
186 #define DMX_FE_ENTRY(list) list_entry(list, dmx_frontend_t, connectivity_list)
187
188 struct dmx_demux_s {
189	 /&#8902; The following char&#8902; fields point to NULL terminated strings &#8902;/
190	 char&#8902; id;                    /&#8902; Unique demux identifier &#8902;/
191	 char&#8902; vendor;                /&#8902; Name of the demux vendor &#8902;/
192	 char&#8902; model;                 /&#8902; Name of the demux model &#8902;/
193	 __u32 capabilities;          /&#8902; Bitfield of capability flags &#8902;/
194	 dmx_frontend_t&#8902; frontend;    /&#8902; Front-end connected to the demux &#8902;/
195	 struct list_head reg_list;   /&#8902; List of registered demuxes &#8902;/
196	 void&#8902; priv;                  /&#8902; Pointer to private data of the API client &#8902;/
197	 int users;                   /&#8902; Number of users &#8902;/
198	 int (&#8902;open) (struct dmx_demux_s&#8902; demux);
199	 int (&#8902;close) (struct dmx_demux_s&#8902; demux);
200	 int (&#8902;write) (struct dmx_demux_s&#8902; demux, const char&#8902; buf, size_t count);
201	 int (&#8902;allocate_ts_feed) (struct dmx_demux_s&#8902; demux,
202				  dmx_ts_feed_t&#8902;&#8902; feed,
203				  dmx_ts_cb callback);
204	 int (&#8902;release_ts_feed) (struct dmx_demux_s&#8902; demux,
205				 dmx_ts_feed_t&#8902; feed);
206	 int (&#8902;allocate_pes_feed) (struct dmx_demux_s&#8902; demux,
207				   dmx_pes_feed_t&#8902;&#8902; feed,
208				   dmx_pes_cb callback);
209	 int (&#8902;release_pes_feed) (struct dmx_demux_s&#8902; demux,
210				  dmx_pes_feed_t&#8902; feed);
211	 int (&#8902;allocate_section_feed) (struct dmx_demux_s&#8902; demux,
212				       dmx_section_feed_t&#8902;&#8902; feed,
213				       dmx_section_cb callback);
214	 int (&#8902;release_section_feed) (struct dmx_demux_s&#8902; demux,
215				      dmx_section_feed_t&#8902; feed);
216	 int (&#8902;descramble_mac_address) (struct dmx_demux_s&#8902; demux,
217					__u8&#8902; buffer1,
218					size_t buffer1_length,
219					__u8&#8902; buffer2,
220					size_t buffer2_length,
221					__u16 pid);
222	 int (&#8902;descramble_section_payload) (struct dmx_demux_s&#8902; demux,
223					    __u8&#8902; buffer1,
224					    size_t buffer1_length,
225					    __u8&#8902; buffer2, size_t buffer2_length,
226					    __u16 pid);
227	 int (&#8902;add_frontend) (struct dmx_demux_s&#8902; demux,
228			      dmx_frontend_t&#8902; frontend);
229	 int (&#8902;remove_frontend) (struct dmx_demux_s&#8902; demux,
230				 dmx_frontend_t&#8902; frontend);
231	 struct list_head&#8902; (&#8902;get_frontends) (struct dmx_demux_s&#8902; demux);
232	 int (&#8902;connect_frontend) (struct dmx_demux_s&#8902; demux,
233				  dmx_frontend_t&#8902; frontend);
234	 int (&#8902;disconnect_frontend) (struct dmx_demux_s&#8902; demux);
235
236
237	 /&#8902; added because js cannot keep track of these himself &#8902;/
238	 int (&#8902;get_pes_pids) (struct dmx_demux_s&#8902; demux, __u16 &#8902;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 /&#8902;
243  &#8902; DMX_DIR_ENTRY(): Casts elements in the list of registered
244  &#8902; demuxes from the generic type struct list_head&#8902; to the type dmx_demux_t
245  &#8902;.
246  &#8902;/
247
248 #define DMX_DIR_ENTRY(list) list_entry(list, dmx_demux_t, reg_list)
249
250 int dmx_register_demux (dmx_demux_t&#8902; demux);
251 int dmx_unregister_demux (dmx_demux_t&#8902; demux);
252 struct list_head&#8902; 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>&#160;</td><td width="20%" align="center"><a accesskey="u" href="dvbapi.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="demux_directory_api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">DVB net Function Calls&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Demux Directory API</td></tr></table></div></body></html>
254