Commit | Line | Data |
---|---|---|
140d8816 LP |
1 | /* |
2 | * Multimedia device API | |
3 | * | |
4 | * Copyright (C) 2010 Nokia Corporation | |
5 | * | |
6 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | |
7 | * Sakari Ailus <sakari.ailus@iki.fi> | |
8 | * | |
9 | * This program is free software; you can redistribute it and/or modify | |
10 | * it under the terms of the GNU General Public License version 2 as | |
11 | * published by the Free Software Foundation. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | */ | |
22 | ||
23 | #ifndef __LINUX_MEDIA_H | |
24 | #define __LINUX_MEDIA_H | |
25 | ||
b3b7a9f1 MCC |
26 | #ifndef __KERNEL__ |
27 | #include <stdint.h> | |
28 | #endif | |
140d8816 LP |
29 | #include <linux/ioctl.h> |
30 | #include <linux/types.h> | |
31 | #include <linux/version.h> | |
32 | ||
33 | #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0) | |
34 | ||
35 | struct media_device_info { | |
36 | char driver[16]; | |
37 | char model[32]; | |
38 | char serial[40]; | |
39 | char bus_info[32]; | |
40 | __u32 media_version; | |
41 | __u32 hw_revision; | |
42 | __u32 driver_version; | |
43 | __u32 reserved[31]; | |
44 | }; | |
45 | ||
1651333b LP |
46 | #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) |
47 | ||
b50bde4e MCC |
48 | /* |
49 | * Initial value to be used when a new entity is created | |
50 | * Drivers should change it to something useful | |
51 | */ | |
4ca72efa | 52 | #define MEDIA_ENT_F_UNKNOWN 0x00000000 |
b50bde4e | 53 | |
32fdc0e1 | 54 | /* |
4ca72efa | 55 | * Base number ranges for entity functions |
32fdc0e1 | 56 | * |
4ca72efa MCC |
57 | * NOTE: those ranges and entity function number are phased just to |
58 | * make it easier to maintain this file. Userspace should not rely on | |
59 | * the ranges to identify a group of function types, as newer | |
60 | * functions can be added with any name within the full u32 range. | |
32fdc0e1 | 61 | */ |
4ca72efa MCC |
62 | #define MEDIA_ENT_F_BASE 0x00000000 |
63 | #define MEDIA_ENT_F_OLD_BASE 0x00010000 | |
64 | #define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000 | |
32fdc0e1 MCC |
65 | |
66 | /* | |
4ca72efa | 67 | * DVB entities |
32fdc0e1 | 68 | */ |
58402b6e HV |
69 | #define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 0x00001) |
70 | #define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 0x00002) | |
71 | #define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 0x00003) | |
72 | #define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 0x00004) | |
fa17b46a | 73 | |
b50bde4e | 74 | /* |
1f452240 | 75 | * I/O entities |
4ca72efa | 76 | */ |
58402b6e HV |
77 | #define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 0x01001) |
78 | #define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 0x01002) | |
79 | #define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003) | |
4ca72efa | 80 | |
06131932 MCC |
81 | /* |
82 | * Analog TV IF-PLL decoders | |
83 | * | |
84 | * It is a responsibility of the master/bridge drivers to create links | |
85 | * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER. | |
86 | */ | |
87294e9d HV |
87 | #define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 0x02001) |
88 | #define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 0x02002) | |
8c755c29 | 89 | |
7a2eba12 SK |
90 | /* |
91 | * Audio Entity Functions | |
92 | */ | |
64bd1971 HV |
93 | #define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 0x03001) |
94 | #define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 0x03002) | |
95 | #define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003) | |
7a2eba12 | 96 | |
4ca72efa | 97 | /* |
1f452240 | 98 | * Connectors |
4ca72efa | 99 | */ |
1f452240 | 100 | /* It is a responsibility of the entity drivers to add connectors and links */ |
93125094 MCC |
101 | #ifdef __KERNEL__ |
102 | /* | |
103 | * For now, it should not be used in userspace, as some | |
104 | * definitions may change | |
105 | */ | |
106 | ||
58402b6e HV |
107 | #define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 0x30001) |
108 | #define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 0x30002) | |
109 | #define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 0x30003) | |
4ca72efa | 110 | |
93125094 MCC |
111 | #endif |
112 | ||
4ca72efa MCC |
113 | /* |
114 | * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and | |
115 | * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility | |
116 | * with the legacy v1 API.The number range is out of range by purpose: | |
117 | * several previously reserved numbers got excluded from this range. | |
118 | * | |
b50bde4e MCC |
119 | * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, |
120 | * in order to preserve backward compatibility. | |
d1b9da2d | 121 | * Drivers must change to the proper subdev type before |
b50bde4e MCC |
122 | * registering the entity. |
123 | */ | |
4ca72efa MCC |
124 | |
125 | #define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1) | |
126 | ||
127 | #define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1) | |
128 | #define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2) | |
129 | #define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3) | |
130 | #define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4) | |
b3109d66 | 131 | /* |
06131932 MCC |
132 | * It is a responsibility of the master/bridge drivers to add connectors |
133 | * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners | |
134 | * may require the usage of separate I2C chips to decode analog TV signals, | |
135 | * when the master/bridge chipset doesn't have its own TV standard decoder. | |
136 | * On such cases, the IF-PLL staging is mapped via one or two entities: | |
137 | * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER. | |
b3109d66 | 138 | */ |
4ca72efa MCC |
139 | #define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5) |
140 | ||
141 | #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE | |
49a11518 | 142 | |
b2cd2744 | 143 | #if !defined(__KERNEL__) || defined(__NEED_MEDIA_LEGACY_API) |
4ca72efa MCC |
144 | |
145 | /* | |
146 | * Legacy symbols used to avoid userspace compilation breakages | |
147 | * | |
148 | * Those symbols map the entity function into types and should be | |
149 | * used only on legacy programs for legacy hardware. Don't rely | |
150 | * on those for MEDIA_IOC_G_TOPOLOGY. | |
151 | */ | |
1651333b LP |
152 | #define MEDIA_ENT_TYPE_SHIFT 16 |
153 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 | |
154 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | |
155 | ||
b2cd2744 MCC |
156 | /* End of the old subdev reserved numberspace */ |
157 | #define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_T_DEVNODE | \ | |
158 | MEDIA_ENT_SUBTYPE_MASK) | |
159 | ||
4ca72efa MCC |
160 | #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE |
161 | #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L | |
1651333b LP |
162 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) |
163 | #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) | |
32fdc0e1 | 164 | #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) |
4ca72efa MCC |
165 | |
166 | #define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN | |
167 | #define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L | |
168 | #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN | |
169 | #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR | |
170 | #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH | |
171 | #define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS | |
172 | #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER | |
173 | #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER | |
4376679a | 174 | #endif |
32fdc0e1 | 175 | |
49a11518 | 176 | /* Entity flags */ |
1651333b | 177 | #define MEDIA_ENT_FL_DEFAULT (1 << 0) |
49a11518 | 178 | #define MEDIA_ENT_FL_CONNECTOR (1 << 1) |
1651333b LP |
179 | |
180 | struct media_entity_desc { | |
181 | __u32 id; | |
182 | char name[32]; | |
183 | __u32 type; | |
184 | __u32 revision; | |
185 | __u32 flags; | |
186 | __u32 group_id; | |
187 | __u16 pads; | |
188 | __u16 links; | |
189 | ||
190 | __u32 reserved[4]; | |
191 | ||
192 | union { | |
193 | /* Node specifications */ | |
e31a0ba7 MCC |
194 | struct { |
195 | __u32 major; | |
196 | __u32 minor; | |
197 | } dev; | |
198 | ||
7e182f78 HV |
199 | #if 1 |
200 | /* | |
201 | * TODO: this shouldn't have been added without | |
202 | * actual drivers that use this. When the first real driver | |
203 | * appears that sets this information, special attention | |
204 | * should be given whether this information is 1) enough, and | |
205 | * 2) can deal with udev rules that rename devices. The struct | |
206 | * dev would not be sufficient for this since that does not | |
207 | * contain the subdevice information. In addition, struct dev | |
208 | * can only refer to a single device, and not to multiple (e.g. | |
209 | * pcm and mixer devices). | |
210 | * | |
211 | * So for now mark this as a to do. | |
212 | */ | |
213 | struct { | |
214 | __u32 card; | |
215 | __u32 device; | |
216 | __u32 subdevice; | |
217 | } alsa; | |
218 | #endif | |
219 | ||
e31a0ba7 MCC |
220 | #if 1 |
221 | /* | |
222 | * DEPRECATED: previous node specifications. Kept just to | |
223 | * avoid breaking compilation, but media_entity_desc.dev | |
224 | * should be used instead. In particular, alsa and dvb | |
225 | * fields below are wrong: for all devnodes, there should | |
226 | * be just major/minor inside the struct, as this is enough | |
227 | * to represent any devnode, no matter what type. | |
228 | */ | |
1651333b LP |
229 | struct { |
230 | __u32 major; | |
231 | __u32 minor; | |
232 | } v4l; | |
233 | struct { | |
234 | __u32 major; | |
235 | __u32 minor; | |
236 | } fb; | |
1651333b | 237 | int dvb; |
e31a0ba7 | 238 | #endif |
1651333b LP |
239 | |
240 | /* Sub-device specifications */ | |
241 | /* Nothing needed yet */ | |
242 | __u8 raw[184]; | |
243 | }; | |
244 | }; | |
245 | ||
246 | #define MEDIA_PAD_FL_SINK (1 << 0) | |
247 | #define MEDIA_PAD_FL_SOURCE (1 << 1) | |
d0700c51 | 248 | #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2) |
1651333b LP |
249 | |
250 | struct media_pad_desc { | |
251 | __u32 entity; /* entity ID */ | |
252 | __u16 index; /* pad index */ | |
253 | __u32 flags; /* pad flags */ | |
254 | __u32 reserved[2]; | |
255 | }; | |
256 | ||
257 | #define MEDIA_LNK_FL_ENABLED (1 << 0) | |
258 | #define MEDIA_LNK_FL_IMMUTABLE (1 << 1) | |
e02188c9 | 259 | #define MEDIA_LNK_FL_DYNAMIC (1 << 2) |
1651333b | 260 | |
c398bb64 MCC |
261 | #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28) |
262 | # define MEDIA_LNK_FL_DATA_LINK (0 << 28) | |
263 | # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28) | |
264 | ||
1651333b LP |
265 | struct media_link_desc { |
266 | struct media_pad_desc source; | |
267 | struct media_pad_desc sink; | |
268 | __u32 flags; | |
269 | __u32 reserved[2]; | |
270 | }; | |
271 | ||
272 | struct media_links_enum { | |
273 | __u32 entity; | |
274 | /* Should have enough room for pads elements */ | |
275 | struct media_pad_desc __user *pads; | |
276 | /* Should have enough room for links elements */ | |
277 | struct media_link_desc __user *links; | |
278 | __u32 reserved[4]; | |
279 | }; | |
280 | ||
a1d2510e MCC |
281 | /* Interface type ranges */ |
282 | ||
283 | #define MEDIA_INTF_T_DVB_BASE 0x00000100 | |
284 | #define MEDIA_INTF_T_V4L_BASE 0x00000200 | |
5af557a6 | 285 | #define MEDIA_INTF_T_ALSA_BASE 0x00000300 |
a1d2510e MCC |
286 | |
287 | /* Interface types */ | |
288 | ||
289 | #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) | |
290 | #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) | |
291 | #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) | |
292 | #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) | |
293 | #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) | |
294 | ||
295 | #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) | |
296 | #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1) | |
297 | #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) | |
298 | #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) | |
299 | #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) | |
300 | ||
5af557a6 SK |
301 | #define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE) |
302 | #define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1) | |
303 | #define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2) | |
304 | #define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3) | |
305 | #define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4) | |
306 | #define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5) | |
307 | #define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6) | |
308 | #define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7) | |
309 | ||
c398bb64 MCC |
310 | /* |
311 | * MC next gen API definitions | |
312 | * | |
313 | * NOTE: The declarations below are close to the MC RFC for the Media | |
314 | * Controller, the next generation. Yet, there are a few adjustments | |
315 | * to do, as we want to be able to have a functional API before | |
316 | * the MC properties change. Those will be properly marked below. | |
317 | * Please also notice that I removed "num_pads", "num_links", | |
318 | * from the proposal, as a proper userspace application will likely | |
319 | * use lists for pads/links, just as we intend to do in Kernelspace. | |
320 | * The API definition should be freed from fields that are bound to | |
321 | * some specific data structure. | |
322 | * | |
323 | * FIXME: Currently, I opted to name the new types as "media_v2", as this | |
324 | * won't cause any conflict with the Kernelspace namespace, nor with | |
325 | * the previous kAPI media_*_desc namespace. This can be changed | |
326 | * later, before the adding this API upstream. | |
327 | */ | |
328 | ||
333a6515 | 329 | |
c398bb64 MCC |
330 | struct media_v2_entity { |
331 | __u32 id; | |
332 | char name[64]; /* FIXME: move to a property? (RFC says so) */ | |
d87cdb88 | 333 | __u32 function; /* Main function of the entity */ |
fbe093ac SA |
334 | __u32 reserved[6]; |
335 | } __attribute__ ((packed)); | |
c398bb64 MCC |
336 | |
337 | /* Should match the specific fields at media_intf_devnode */ | |
338 | struct media_v2_intf_devnode { | |
339 | __u32 major; | |
340 | __u32 minor; | |
fbe093ac | 341 | } __attribute__ ((packed)); |
c398bb64 MCC |
342 | |
343 | struct media_v2_interface { | |
344 | __u32 id; | |
345 | __u32 intf_type; | |
346 | __u32 flags; | |
347 | __u32 reserved[9]; | |
348 | ||
349 | union { | |
350 | struct media_v2_intf_devnode devnode; | |
351 | __u32 raw[16]; | |
352 | }; | |
fbe093ac | 353 | } __attribute__ ((packed)); |
c398bb64 MCC |
354 | |
355 | struct media_v2_pad { | |
356 | __u32 id; | |
357 | __u32 entity_id; | |
358 | __u32 flags; | |
fbe093ac SA |
359 | __u32 reserved[5]; |
360 | } __attribute__ ((packed)); | |
c398bb64 MCC |
361 | |
362 | struct media_v2_link { | |
363 | __u32 id; | |
364 | __u32 source_id; | |
365 | __u32 sink_id; | |
366 | __u32 flags; | |
fbe093ac SA |
367 | __u32 reserved[6]; |
368 | } __attribute__ ((packed)); | |
c398bb64 MCC |
369 | |
370 | struct media_v2_topology { | |
b3b7a9f1 | 371 | __u64 topology_version; |
c398bb64 | 372 | |
7c9d6731 MCC |
373 | __u32 num_entities; |
374 | __u32 reserved1; | |
b3b7a9f1 | 375 | __u64 ptr_entities; |
c398bb64 | 376 | |
7c9d6731 MCC |
377 | __u32 num_interfaces; |
378 | __u32 reserved2; | |
b3b7a9f1 | 379 | __u64 ptr_interfaces; |
c398bb64 | 380 | |
7c9d6731 MCC |
381 | __u32 num_pads; |
382 | __u32 reserved3; | |
b3b7a9f1 | 383 | __u64 ptr_pads; |
c398bb64 | 384 | |
7c9d6731 MCC |
385 | __u32 num_links; |
386 | __u32 reserved4; | |
b3b7a9f1 | 387 | __u64 ptr_links; |
fbe093ac | 388 | } __attribute__ ((packed)); |
c398bb64 MCC |
389 | |
390 | /* ioctls */ | |
a1d2510e | 391 | |
474966ee LP |
392 | #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) |
393 | #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) | |
394 | #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) | |
395 | #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) | |
c398bb64 | 396 | #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) |
140d8816 LP |
397 | |
398 | #endif /* __LINUX_MEDIA_H */ |