1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #ifndef __LINUX_MEDIA_H
21 #define __LINUX_MEDIA_H
22
23 #ifndef __KERNEL__
24 #include <stdint.h>
25 #endif
26 #include <linux/ioctl.h>
27 #include <linux/types.h>
28
29 struct media_device_info {
30 char driver[16];
31 char model[32];
32 char serial[40];
33 char bus_info[32];
34 __u32 media_version;
35 __u32 hw_revision;
36 __u32 driver_version;
37 __u32 reserved[31];
38 };
39
40
41
42
43
44
45
46
47
48
49
50
51 #define MEDIA_ENT_F_BASE 0x00000000
52 #define MEDIA_ENT_F_OLD_BASE 0x00010000
53 #define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000
54
55
56
57
58
59 #define MEDIA_ENT_F_UNKNOWN MEDIA_ENT_F_BASE
60
61
62
63
64
65
66 #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
67
68
69
70
71 #define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 0x00001)
72 #define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 0x00002)
73 #define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 0x00003)
74 #define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 0x00004)
75
76
77
78
79 #define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
80 #define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 0x01001)
81 #define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 0x01002)
82 #define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003)
83
84
85
86
87 #define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
88 #define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
89 #define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
90
91
92
93
94
95
96
97
98
99
100
101 #define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
102
103
104
105
106
107
108
109 #define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 0x02001)
110 #define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 0x02002)
111
112
113
114
115 #define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 0x03001)
116 #define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 0x03002)
117 #define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003)
118
119
120
121
122 #define MEDIA_ENT_F_PROC_VIDEO_COMPOSER (MEDIA_ENT_F_BASE + 0x4001)
123 #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER (MEDIA_ENT_F_BASE + 0x4002)
124 #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV (MEDIA_ENT_F_BASE + 0x4003)
125 #define MEDIA_ENT_F_PROC_VIDEO_LUT (MEDIA_ENT_F_BASE + 0x4004)
126 #define MEDIA_ENT_F_PROC_VIDEO_SCALER (MEDIA_ENT_F_BASE + 0x4005)
127 #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006)
128 #define MEDIA_ENT_F_PROC_VIDEO_ENCODER (MEDIA_ENT_F_BASE + 0x4007)
129 #define MEDIA_ENT_F_PROC_VIDEO_DECODER (MEDIA_ENT_F_BASE + 0x4008)
130
131
132
133
134 #define MEDIA_ENT_F_VID_MUX (MEDIA_ENT_F_BASE + 0x5001)
135 #define MEDIA_ENT_F_VID_IF_BRIDGE (MEDIA_ENT_F_BASE + 0x5002)
136
137
138
139
140 #define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
141 #define MEDIA_ENT_F_DV_DECODER (MEDIA_ENT_F_BASE + 0x6001)
142 #define MEDIA_ENT_F_DV_ENCODER (MEDIA_ENT_F_BASE + 0x6002)
143
144
145 #define MEDIA_ENT_FL_DEFAULT (1 << 0)
146 #define MEDIA_ENT_FL_CONNECTOR (1 << 1)
147
148
149 #define MEDIA_ENT_ID_FLAG_NEXT (1U << 31)
150
151 struct media_entity_desc {
152 __u32 id;
153 char name[32];
154 __u32 type;
155 __u32 revision;
156 __u32 flags;
157 __u32 group_id;
158 __u16 pads;
159 __u16 links;
160
161 __u32 reserved[4];
162
163 union {
164
165 struct {
166 __u32 major;
167 __u32 minor;
168 } dev;
169
170 #if !defined(__KERNEL__)
171
172
173
174
175
176
177
178
179
180
181
182 struct {
183 __u32 card;
184 __u32 device;
185 __u32 subdevice;
186 } alsa;
187
188
189
190
191
192
193 struct {
194 __u32 major;
195 __u32 minor;
196 } v4l;
197 struct {
198 __u32 major;
199 __u32 minor;
200 } fb;
201 int dvb;
202 #endif
203
204
205
206 __u8 raw[184];
207 };
208 };
209
210 #define MEDIA_PAD_FL_SINK (1 << 0)
211 #define MEDIA_PAD_FL_SOURCE (1 << 1)
212 #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
213
214 struct media_pad_desc {
215 __u32 entity;
216 __u16 index;
217 __u32 flags;
218 __u32 reserved[2];
219 };
220
221 #define MEDIA_LNK_FL_ENABLED (1 << 0)
222 #define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
223 #define MEDIA_LNK_FL_DYNAMIC (1 << 2)
224
225 #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
226 # define MEDIA_LNK_FL_DATA_LINK (0 << 28)
227 # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
228
229 struct media_link_desc {
230 struct media_pad_desc source;
231 struct media_pad_desc sink;
232 __u32 flags;
233 __u32 reserved[2];
234 };
235
236 struct media_links_enum {
237 __u32 entity;
238
239 struct media_pad_desc __user *pads;
240
241 struct media_link_desc __user *links;
242 __u32 reserved[4];
243 };
244
245
246
247 #define MEDIA_INTF_T_DVB_BASE 0x00000100
248 #define MEDIA_INTF_T_V4L_BASE 0x00000200
249
250
251
252 #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
253 #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
254 #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
255 #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
256 #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
257
258 #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
259 #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
260 #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
261 #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
262 #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
263 #define MEDIA_INTF_T_V4L_TOUCH (MEDIA_INTF_T_V4L_BASE + 5)
264
265 #define MEDIA_INTF_T_ALSA_BASE 0x00000300
266 #define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE)
267 #define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
268 #define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
269
270 #if defined(__KERNEL__)
271
272
273
274
275
276
277
278
279
280 #define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 0x30001)
281 #define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 0x30002)
282 #define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 0x30003)
283
284 #endif
285
286
287
288
289
290
291
292
293
294
295
296 #define MEDIA_V2_ENTITY_HAS_FLAGS(media_version) \
297 ((media_version) >= ((4 << 16) | (19 << 8) | 0))
298
299 struct media_v2_entity {
300 __u32 id;
301 char name[64];
302 __u32 function;
303 __u32 flags;
304 __u32 reserved[5];
305 } __attribute__ ((packed));
306
307
308 struct media_v2_intf_devnode {
309 __u32 major;
310 __u32 minor;
311 } __attribute__ ((packed));
312
313 struct media_v2_interface {
314 __u32 id;
315 __u32 intf_type;
316 __u32 flags;
317 __u32 reserved[9];
318
319 union {
320 struct media_v2_intf_devnode devnode;
321 __u32 raw[16];
322 };
323 } __attribute__ ((packed));
324
325
326
327
328
329
330
331 #define MEDIA_V2_PAD_HAS_INDEX(media_version) \
332 ((media_version) >= ((4 << 16) | (19 << 8) | 0))
333
334 struct media_v2_pad {
335 __u32 id;
336 __u32 entity_id;
337 __u32 flags;
338 __u32 index;
339 __u32 reserved[4];
340 } __attribute__ ((packed));
341
342 struct media_v2_link {
343 __u32 id;
344 __u32 source_id;
345 __u32 sink_id;
346 __u32 flags;
347 __u32 reserved[6];
348 } __attribute__ ((packed));
349
350 struct media_v2_topology {
351 __u64 topology_version;
352
353 __u32 num_entities;
354 __u32 reserved1;
355 __u64 ptr_entities;
356
357 __u32 num_interfaces;
358 __u32 reserved2;
359 __u64 ptr_interfaces;
360
361 __u32 num_pads;
362 __u32 reserved3;
363 __u64 ptr_pads;
364
365 __u32 num_links;
366 __u32 reserved4;
367 __u64 ptr_links;
368 } __attribute__ ((packed));
369
370
371
372 #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
373 #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
374 #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
375 #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
376 #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
377 #define MEDIA_IOC_REQUEST_ALLOC _IOR ('|', 0x05, int)
378
379
380
381
382
383 #define MEDIA_REQUEST_IOC_QUEUE _IO('|', 0x80)
384 #define MEDIA_REQUEST_IOC_REINIT _IO('|', 0x81)
385
386 #ifndef __KERNEL__
387
388
389
390
391
392
393
394
395
396 #define MEDIA_ENT_TYPE_SHIFT 16
397 #define MEDIA_ENT_TYPE_MASK 0x00ff0000
398 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
399
400 #define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_F_OLD_BASE | \
401 MEDIA_ENT_SUBTYPE_MASK)
402
403 #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
404 #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
405 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_F_OLD_BASE + 2)
406 #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_F_OLD_BASE + 3)
407 #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_F_OLD_BASE + 4)
408
409 #define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
410 #define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
411 #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
412 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
413 #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
414 #define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
415 #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
416 #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
417
418 #define MEDIA_ENT_F_DTV_DECODER MEDIA_ENT_F_DV_DECODER
419
420
421
422
423
424
425
426
427
428
429 #define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3)
430 #define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)
431 #define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
432 #define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6)
433 #define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
434
435
436 #define MEDIA_API_VERSION ((0 << 16) | (1 << 8) | 0)
437
438 #endif
439
440 #endif