Merge remote-tracking branch 'iommu/next'
[deliverable/linux.git] / include / uapi / linux / media.h
CommitLineData
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
35struct 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
1179aab1
LP
97/*
98 * Processing entities
99 */
100#define MEDIA_ENT_F_PROC_VIDEO_COMPOSER (MEDIA_ENT_F_BASE + 0x4001)
101#define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER (MEDIA_ENT_F_BASE + 0x4002)
102#define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV (MEDIA_ENT_F_BASE + 0x4003)
103#define MEDIA_ENT_F_PROC_VIDEO_LUT (MEDIA_ENT_F_BASE + 0x4004)
104#define MEDIA_ENT_F_PROC_VIDEO_SCALER (MEDIA_ENT_F_BASE + 0x4005)
eaa0b96b 105#define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006)
1179aab1 106
4ca72efa 107/*
1f452240 108 * Connectors
4ca72efa 109 */
1f452240 110/* It is a responsibility of the entity drivers to add connectors and links */
93125094
MCC
111#ifdef __KERNEL__
112 /*
113 * For now, it should not be used in userspace, as some
114 * definitions may change
115 */
116
58402b6e
HV
117#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 0x30001)
118#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 0x30002)
119#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 0x30003)
4ca72efa 120
93125094
MCC
121#endif
122
4ca72efa
MCC
123/*
124 * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
125 * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
126 * with the legacy v1 API.The number range is out of range by purpose:
127 * several previously reserved numbers got excluded from this range.
128 *
b50bde4e
MCC
129 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
130 * in order to preserve backward compatibility.
d1b9da2d 131 * Drivers must change to the proper subdev type before
b50bde4e
MCC
132 * registering the entity.
133 */
4ca72efa
MCC
134
135#define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
136
137#define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
138#define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
139#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
140#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
b3109d66 141/*
06131932
MCC
142 * It is a responsibility of the master/bridge drivers to add connectors
143 * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
144 * may require the usage of separate I2C chips to decode analog TV signals,
145 * when the master/bridge chipset doesn't have its own TV standard decoder.
146 * On such cases, the IF-PLL staging is mapped via one or two entities:
147 * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
b3109d66 148 */
4ca72efa
MCC
149#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
150
151#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
49a11518 152
b2cd2744 153#if !defined(__KERNEL__) || defined(__NEED_MEDIA_LEGACY_API)
4ca72efa
MCC
154
155/*
156 * Legacy symbols used to avoid userspace compilation breakages
157 *
158 * Those symbols map the entity function into types and should be
159 * used only on legacy programs for legacy hardware. Don't rely
160 * on those for MEDIA_IOC_G_TOPOLOGY.
161 */
1651333b
LP
162#define MEDIA_ENT_TYPE_SHIFT 16
163#define MEDIA_ENT_TYPE_MASK 0x00ff0000
164#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
165
b2cd2744
MCC
166/* End of the old subdev reserved numberspace */
167#define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_T_DEVNODE | \
168 MEDIA_ENT_SUBTYPE_MASK)
169
4ca72efa
MCC
170#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
171#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
1651333b
LP
172#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
173#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
32fdc0e1 174#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
4ca72efa
MCC
175
176#define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
177#define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
178#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
179#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
180#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
181#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
182#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
183#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
4376679a 184#endif
32fdc0e1 185
49a11518 186/* Entity flags */
1651333b 187#define MEDIA_ENT_FL_DEFAULT (1 << 0)
49a11518 188#define MEDIA_ENT_FL_CONNECTOR (1 << 1)
1651333b
LP
189
190struct media_entity_desc {
191 __u32 id;
192 char name[32];
193 __u32 type;
194 __u32 revision;
195 __u32 flags;
196 __u32 group_id;
197 __u16 pads;
198 __u16 links;
199
200 __u32 reserved[4];
201
202 union {
203 /* Node specifications */
e31a0ba7
MCC
204 struct {
205 __u32 major;
206 __u32 minor;
207 } dev;
208
7e182f78
HV
209#if 1
210 /*
211 * TODO: this shouldn't have been added without
212 * actual drivers that use this. When the first real driver
213 * appears that sets this information, special attention
214 * should be given whether this information is 1) enough, and
215 * 2) can deal with udev rules that rename devices. The struct
216 * dev would not be sufficient for this since that does not
217 * contain the subdevice information. In addition, struct dev
218 * can only refer to a single device, and not to multiple (e.g.
219 * pcm and mixer devices).
220 *
221 * So for now mark this as a to do.
222 */
223 struct {
224 __u32 card;
225 __u32 device;
226 __u32 subdevice;
227 } alsa;
228#endif
229
e31a0ba7
MCC
230#if 1
231 /*
232 * DEPRECATED: previous node specifications. Kept just to
233 * avoid breaking compilation, but media_entity_desc.dev
234 * should be used instead. In particular, alsa and dvb
235 * fields below are wrong: for all devnodes, there should
236 * be just major/minor inside the struct, as this is enough
237 * to represent any devnode, no matter what type.
238 */
1651333b
LP
239 struct {
240 __u32 major;
241 __u32 minor;
242 } v4l;
243 struct {
244 __u32 major;
245 __u32 minor;
246 } fb;
1651333b 247 int dvb;
e31a0ba7 248#endif
1651333b
LP
249
250 /* Sub-device specifications */
251 /* Nothing needed yet */
252 __u8 raw[184];
253 };
254};
255
256#define MEDIA_PAD_FL_SINK (1 << 0)
257#define MEDIA_PAD_FL_SOURCE (1 << 1)
d0700c51 258#define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
1651333b
LP
259
260struct media_pad_desc {
261 __u32 entity; /* entity ID */
262 __u16 index; /* pad index */
263 __u32 flags; /* pad flags */
264 __u32 reserved[2];
265};
266
267#define MEDIA_LNK_FL_ENABLED (1 << 0)
268#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
e02188c9 269#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
1651333b 270
c398bb64
MCC
271#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
272# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
273# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
274
1651333b
LP
275struct media_link_desc {
276 struct media_pad_desc source;
277 struct media_pad_desc sink;
278 __u32 flags;
279 __u32 reserved[2];
280};
281
282struct media_links_enum {
283 __u32 entity;
284 /* Should have enough room for pads elements */
285 struct media_pad_desc __user *pads;
286 /* Should have enough room for links elements */
287 struct media_link_desc __user *links;
288 __u32 reserved[4];
289};
290
a1d2510e
MCC
291/* Interface type ranges */
292
293#define MEDIA_INTF_T_DVB_BASE 0x00000100
294#define MEDIA_INTF_T_V4L_BASE 0x00000200
5af557a6 295#define MEDIA_INTF_T_ALSA_BASE 0x00000300
a1d2510e
MCC
296
297/* Interface types */
298
299#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
300#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
301#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
302#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
303#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
304
305#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
306#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
307#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
308#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
309#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
b2fe22d0 310#define MEDIA_INTF_T_V4L_TOUCH (MEDIA_INTF_T_V4L_BASE + 5)
a1d2510e 311
5af557a6
SK
312#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE)
313#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
314#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
315#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3)
316#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)
317#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
318#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6)
319#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
320
c398bb64
MCC
321/*
322 * MC next gen API definitions
323 *
324 * NOTE: The declarations below are close to the MC RFC for the Media
325 * Controller, the next generation. Yet, there are a few adjustments
326 * to do, as we want to be able to have a functional API before
327 * the MC properties change. Those will be properly marked below.
328 * Please also notice that I removed "num_pads", "num_links",
329 * from the proposal, as a proper userspace application will likely
330 * use lists for pads/links, just as we intend to do in Kernelspace.
331 * The API definition should be freed from fields that are bound to
332 * some specific data structure.
333 *
334 * FIXME: Currently, I opted to name the new types as "media_v2", as this
335 * won't cause any conflict with the Kernelspace namespace, nor with
336 * the previous kAPI media_*_desc namespace. This can be changed
337 * later, before the adding this API upstream.
338 */
339
333a6515 340
c398bb64
MCC
341struct media_v2_entity {
342 __u32 id;
343 char name[64]; /* FIXME: move to a property? (RFC says so) */
d87cdb88 344 __u32 function; /* Main function of the entity */
fbe093ac
SA
345 __u32 reserved[6];
346} __attribute__ ((packed));
c398bb64
MCC
347
348/* Should match the specific fields at media_intf_devnode */
349struct media_v2_intf_devnode {
350 __u32 major;
351 __u32 minor;
fbe093ac 352} __attribute__ ((packed));
c398bb64
MCC
353
354struct media_v2_interface {
355 __u32 id;
356 __u32 intf_type;
357 __u32 flags;
358 __u32 reserved[9];
359
360 union {
361 struct media_v2_intf_devnode devnode;
362 __u32 raw[16];
363 };
fbe093ac 364} __attribute__ ((packed));
c398bb64
MCC
365
366struct media_v2_pad {
367 __u32 id;
368 __u32 entity_id;
369 __u32 flags;
fbe093ac
SA
370 __u32 reserved[5];
371} __attribute__ ((packed));
c398bb64
MCC
372
373struct media_v2_link {
374 __u32 id;
375 __u32 source_id;
376 __u32 sink_id;
377 __u32 flags;
fbe093ac
SA
378 __u32 reserved[6];
379} __attribute__ ((packed));
c398bb64
MCC
380
381struct media_v2_topology {
b3b7a9f1 382 __u64 topology_version;
c398bb64 383
7c9d6731
MCC
384 __u32 num_entities;
385 __u32 reserved1;
b3b7a9f1 386 __u64 ptr_entities;
c398bb64 387
7c9d6731
MCC
388 __u32 num_interfaces;
389 __u32 reserved2;
b3b7a9f1 390 __u64 ptr_interfaces;
c398bb64 391
7c9d6731
MCC
392 __u32 num_pads;
393 __u32 reserved3;
b3b7a9f1 394 __u64 ptr_pads;
c398bb64 395
7c9d6731
MCC
396 __u32 num_links;
397 __u32 reserved4;
b3b7a9f1 398 __u64 ptr_links;
fbe093ac 399} __attribute__ ((packed));
c398bb64
MCC
400
401/* ioctls */
a1d2510e 402
474966ee
LP
403#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
404#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
405#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
406#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
c398bb64 407#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
140d8816
LP
408
409#endif /* __LINUX_MEDIA_H */
This page took 0.340188 seconds and 5 git commands to generate.