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