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 | ||
26 | #include <linux/ioctl.h> | |
27 | #include <linux/types.h> | |
28 | #include <linux/version.h> | |
29 | ||
30 | #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0) | |
31 | ||
32 | struct media_device_info { | |
33 | char driver[16]; | |
34 | char model[32]; | |
35 | char serial[40]; | |
36 | char bus_info[32]; | |
37 | __u32 media_version; | |
38 | __u32 hw_revision; | |
39 | __u32 driver_version; | |
40 | __u32 reserved[31]; | |
41 | }; | |
42 | ||
1651333b LP |
43 | #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) |
44 | ||
b50bde4e MCC |
45 | /* |
46 | * Initial value to be used when a new entity is created | |
47 | * Drivers should change it to something useful | |
48 | */ | |
49 | #define MEDIA_ENT_T_UNKNOWN 0x00000000 | |
50 | ||
32fdc0e1 MCC |
51 | /* |
52 | * Base numbers for entity types | |
53 | * | |
54 | * Please notice that the huge gap of 16 bits for each base is overkill! | |
55 | * 8 bits is more than enough to avoid starving entity types for each | |
56 | * subsystem. | |
57 | * | |
58 | * However, It is kept this way just to avoid binary breakages with the | |
59 | * namespace provided on legacy versions of this header. | |
60 | */ | |
61 | #define MEDIA_ENT_T_DVB_BASE 0x00000000 | |
62 | #define MEDIA_ENT_T_V4L2_BASE 0x00010000 | |
63 | #define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000 | |
49a11518 | 64 | #define MEDIA_ENT_T_CONNECTOR_BASE 0x00030000 |
32fdc0e1 MCC |
65 | |
66 | /* | |
67 | * V4L2 entities - Those are used for DMA (mmap/DMABUF) and | |
68 | * read()/write() data I/O associated with the V4L2 devnodes. | |
69 | */ | |
70 | #define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1) | |
71 | /* | |
72 | * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and | |
73 | * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used | |
74 | * to be declared for FB, ALSA and DVB entities. | |
75 | * As those values were never actually used in practice, we're just | |
76 | * adding them as backward compatibility macros and keeping the | |
77 | * numberspace clean here. This way, we avoid breaking compilation, | |
78 | * in the case of having some userspace application using the old | |
79 | * symbols. | |
80 | */ | |
81 | #define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5) | |
82 | #define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 6) | |
83 | ||
84 | /* V4L2 Sub-device entities */ | |
fa17b46a | 85 | |
b50bde4e MCC |
86 | /* |
87 | * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, | |
88 | * in order to preserve backward compatibility. | |
89 | * Drivers should change to the proper subdev type before | |
90 | * registering the entity. | |
91 | */ | |
fa17b46a MCC |
92 | #define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE |
93 | ||
32fdc0e1 MCC |
94 | #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1) |
95 | #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2) | |
96 | #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3) | |
97 | /* A converter of analogue video to its digital representation. */ | |
98 | #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4) | |
99 | /* Tuner entity is actually both V4L2 and DVB subdev */ | |
100 | #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5) | |
101 | ||
102 | /* DVB entities */ | |
103 | #define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 1) | |
104 | #define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 2) | |
105 | #define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 3) | |
106 | #define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 4) | |
107 | #define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 5) | |
108 | ||
49a11518 MCC |
109 | /* Connectors */ |
110 | #define MEDIA_ENT_T_CONN_RF (MEDIA_ENT_T_CONNECTOR_BASE + 1) | |
111 | #define MEDIA_ENT_T_CONN_SVIDEO (MEDIA_ENT_T_CONNECTOR_BASE + 2) | |
112 | #define MEDIA_ENT_T_CONN_COMPOSITE (MEDIA_ENT_T_CONNECTOR_BASE + 3) | |
113 | /* For internal test signal generators and other debug connectors */ | |
114 | #define MEDIA_ENT_T_CONN_TEST (MEDIA_ENT_T_CONNECTOR_BASE + 4) | |
115 | ||
4376679a | 116 | #ifndef __KERNEL__ |
32fdc0e1 | 117 | /* Legacy symbols used to avoid userspace compilation breakages */ |
1651333b LP |
118 | #define MEDIA_ENT_TYPE_SHIFT 16 |
119 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 | |
120 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff | |
121 | ||
32fdc0e1 MCC |
122 | #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE |
123 | #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE | |
124 | ||
125 | #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO | |
126 | ||
1651333b LP |
127 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) |
128 | #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) | |
32fdc0e1 | 129 | #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) |
4376679a | 130 | #endif |
32fdc0e1 | 131 | |
49a11518 | 132 | /* Entity flags */ |
1651333b | 133 | #define MEDIA_ENT_FL_DEFAULT (1 << 0) |
49a11518 | 134 | #define MEDIA_ENT_FL_CONNECTOR (1 << 1) |
1651333b LP |
135 | |
136 | struct media_entity_desc { | |
137 | __u32 id; | |
138 | char name[32]; | |
139 | __u32 type; | |
140 | __u32 revision; | |
141 | __u32 flags; | |
142 | __u32 group_id; | |
143 | __u16 pads; | |
144 | __u16 links; | |
145 | ||
146 | __u32 reserved[4]; | |
147 | ||
148 | union { | |
149 | /* Node specifications */ | |
e31a0ba7 MCC |
150 | struct { |
151 | __u32 major; | |
152 | __u32 minor; | |
153 | } dev; | |
154 | ||
7e182f78 HV |
155 | #if 1 |
156 | /* | |
157 | * TODO: this shouldn't have been added without | |
158 | * actual drivers that use this. When the first real driver | |
159 | * appears that sets this information, special attention | |
160 | * should be given whether this information is 1) enough, and | |
161 | * 2) can deal with udev rules that rename devices. The struct | |
162 | * dev would not be sufficient for this since that does not | |
163 | * contain the subdevice information. In addition, struct dev | |
164 | * can only refer to a single device, and not to multiple (e.g. | |
165 | * pcm and mixer devices). | |
166 | * | |
167 | * So for now mark this as a to do. | |
168 | */ | |
169 | struct { | |
170 | __u32 card; | |
171 | __u32 device; | |
172 | __u32 subdevice; | |
173 | } alsa; | |
174 | #endif | |
175 | ||
e31a0ba7 MCC |
176 | #if 1 |
177 | /* | |
178 | * DEPRECATED: previous node specifications. Kept just to | |
179 | * avoid breaking compilation, but media_entity_desc.dev | |
180 | * should be used instead. In particular, alsa and dvb | |
181 | * fields below are wrong: for all devnodes, there should | |
182 | * be just major/minor inside the struct, as this is enough | |
183 | * to represent any devnode, no matter what type. | |
184 | */ | |
1651333b LP |
185 | struct { |
186 | __u32 major; | |
187 | __u32 minor; | |
188 | } v4l; | |
189 | struct { | |
190 | __u32 major; | |
191 | __u32 minor; | |
192 | } fb; | |
1651333b | 193 | int dvb; |
e31a0ba7 | 194 | #endif |
1651333b LP |
195 | |
196 | /* Sub-device specifications */ | |
197 | /* Nothing needed yet */ | |
198 | __u8 raw[184]; | |
199 | }; | |
200 | }; | |
201 | ||
202 | #define MEDIA_PAD_FL_SINK (1 << 0) | |
203 | #define MEDIA_PAD_FL_SOURCE (1 << 1) | |
d0700c51 | 204 | #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2) |
1651333b LP |
205 | |
206 | struct media_pad_desc { | |
207 | __u32 entity; /* entity ID */ | |
208 | __u16 index; /* pad index */ | |
209 | __u32 flags; /* pad flags */ | |
210 | __u32 reserved[2]; | |
211 | }; | |
212 | ||
213 | #define MEDIA_LNK_FL_ENABLED (1 << 0) | |
214 | #define MEDIA_LNK_FL_IMMUTABLE (1 << 1) | |
e02188c9 | 215 | #define MEDIA_LNK_FL_DYNAMIC (1 << 2) |
1651333b | 216 | |
c398bb64 MCC |
217 | #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28) |
218 | # define MEDIA_LNK_FL_DATA_LINK (0 << 28) | |
219 | # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28) | |
220 | ||
1651333b LP |
221 | struct media_link_desc { |
222 | struct media_pad_desc source; | |
223 | struct media_pad_desc sink; | |
224 | __u32 flags; | |
225 | __u32 reserved[2]; | |
226 | }; | |
227 | ||
228 | struct media_links_enum { | |
229 | __u32 entity; | |
230 | /* Should have enough room for pads elements */ | |
231 | struct media_pad_desc __user *pads; | |
232 | /* Should have enough room for links elements */ | |
233 | struct media_link_desc __user *links; | |
234 | __u32 reserved[4]; | |
235 | }; | |
236 | ||
a1d2510e MCC |
237 | /* Interface type ranges */ |
238 | ||
239 | #define MEDIA_INTF_T_DVB_BASE 0x00000100 | |
240 | #define MEDIA_INTF_T_V4L_BASE 0x00000200 | |
241 | ||
242 | /* Interface types */ | |
243 | ||
244 | #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) | |
245 | #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) | |
246 | #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) | |
247 | #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) | |
248 | #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) | |
249 | ||
250 | #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) | |
251 | #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1) | |
252 | #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) | |
253 | #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) | |
254 | #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) | |
255 | ||
c398bb64 MCC |
256 | /* |
257 | * MC next gen API definitions | |
258 | * | |
259 | * NOTE: The declarations below are close to the MC RFC for the Media | |
260 | * Controller, the next generation. Yet, there are a few adjustments | |
261 | * to do, as we want to be able to have a functional API before | |
262 | * the MC properties change. Those will be properly marked below. | |
263 | * Please also notice that I removed "num_pads", "num_links", | |
264 | * from the proposal, as a proper userspace application will likely | |
265 | * use lists for pads/links, just as we intend to do in Kernelspace. | |
266 | * The API definition should be freed from fields that are bound to | |
267 | * some specific data structure. | |
268 | * | |
269 | * FIXME: Currently, I opted to name the new types as "media_v2", as this | |
270 | * won't cause any conflict with the Kernelspace namespace, nor with | |
271 | * the previous kAPI media_*_desc namespace. This can be changed | |
272 | * later, before the adding this API upstream. | |
273 | */ | |
274 | ||
275 | ||
276 | struct media_v2_entity { | |
277 | __u32 id; | |
278 | char name[64]; /* FIXME: move to a property? (RFC says so) */ | |
279 | __u16 reserved[14]; | |
280 | }; | |
281 | ||
282 | /* Should match the specific fields at media_intf_devnode */ | |
283 | struct media_v2_intf_devnode { | |
284 | __u32 major; | |
285 | __u32 minor; | |
286 | }; | |
287 | ||
288 | struct media_v2_interface { | |
289 | __u32 id; | |
290 | __u32 intf_type; | |
291 | __u32 flags; | |
292 | __u32 reserved[9]; | |
293 | ||
294 | union { | |
295 | struct media_v2_intf_devnode devnode; | |
296 | __u32 raw[16]; | |
297 | }; | |
298 | }; | |
299 | ||
300 | struct media_v2_pad { | |
301 | __u32 id; | |
302 | __u32 entity_id; | |
303 | __u32 flags; | |
304 | __u16 reserved[9]; | |
305 | }; | |
306 | ||
307 | struct media_v2_link { | |
308 | __u32 id; | |
309 | __u32 source_id; | |
310 | __u32 sink_id; | |
311 | __u32 flags; | |
312 | __u32 reserved[5]; | |
313 | }; | |
314 | ||
315 | struct media_v2_topology { | |
316 | __u32 topology_version; | |
317 | ||
318 | __u32 num_entities; | |
319 | struct media_v2_entity *entities; | |
320 | ||
321 | __u32 num_interfaces; | |
322 | struct media_v2_interface *interfaces; | |
323 | ||
324 | __u32 num_pads; | |
325 | struct media_v2_pad *pads; | |
326 | ||
327 | __u32 num_links; | |
328 | struct media_v2_link *links; | |
329 | ||
330 | struct { | |
331 | __u32 reserved_num; | |
332 | void *reserved_ptr; | |
333 | } reserved_types[16]; | |
334 | __u32 reserved[8]; | |
335 | }; | |
336 | ||
337 | /* ioctls */ | |
a1d2510e | 338 | |
474966ee LP |
339 | #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) |
340 | #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) | |
341 | #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) | |
342 | #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) | |
c398bb64 | 343 | #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) |
140d8816 LP |
344 | |
345 | #endif /* __LINUX_MEDIA_H */ |