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