aboutsummaryrefslogtreecommitdiffstats
path: root/include/uapi/linux/media.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/uapi/linux/media.h')
-rw-r--r--include/uapi/linux/media.h228
1 files changed, 210 insertions, 18 deletions
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 4e816be3de39..1e3c8cb43bd7 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -23,6 +23,9 @@
23#ifndef __LINUX_MEDIA_H 23#ifndef __LINUX_MEDIA_H
24#define __LINUX_MEDIA_H 24#define __LINUX_MEDIA_H
25 25
26#ifndef __KERNEL__
27#include <stdint.h>
28#endif
26#include <linux/ioctl.h> 29#include <linux/ioctl.h>
27#include <linux/types.h> 30#include <linux/types.h>
28#include <linux/version.h> 31#include <linux/version.h>
@@ -42,33 +45,107 @@ struct media_device_info {
42 45
43#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) 46#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
44 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 + 1)
70#define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 2)
71#define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 3)
72#define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 4)
73
74/*
75 * Connectors
76 */
77/* It is a responsibility of the entity drivers to add connectors and links */
78#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 21)
79#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 22)
80#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 23)
81/* For internal test signal generators and other debug connectors */
82#define MEDIA_ENT_F_CONN_TEST (MEDIA_ENT_F_BASE + 24)
83
84/*
85 * I/O entities
86 */
87#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 31)
88#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 32)
89#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33)
90
91/*
92 * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
93 * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
94 * with the legacy v1 API.The number range is out of range by purpose:
95 * several previously reserved numbers got excluded from this range.
96 *
97 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
98 * in order to preserve backward compatibility.
99 * Drivers must change to the proper subdev type before
100 * registering the entity.
101 */
102
103#define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
104
105#define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
106#define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
107#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
108#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
109/*
110 * It is a responsibility of the entity drivers to add connectors and links
111 * for the tuner entities.
112 */
113#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
114
115#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
116
117#ifndef __KERNEL__
118
119/*
120 * Legacy symbols used to avoid userspace compilation breakages
121 *
122 * Those symbols map the entity function into types and should be
123 * used only on legacy programs for legacy hardware. Don't rely
124 * on those for MEDIA_IOC_G_TOPOLOGY.
125 */
45#define MEDIA_ENT_TYPE_SHIFT 16 126#define MEDIA_ENT_TYPE_SHIFT 16
46#define MEDIA_ENT_TYPE_MASK 0x00ff0000 127#define MEDIA_ENT_TYPE_MASK 0x00ff0000
47#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff 128#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
48 129
49#define MEDIA_ENT_T_DEVNODE (1 << MEDIA_ENT_TYPE_SHIFT) 130#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
50#define MEDIA_ENT_T_DEVNODE_V4L (MEDIA_ENT_T_DEVNODE + 1) 131#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
51#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) 132#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
52#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) 133#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
53#define MEDIA_ENT_T_DEVNODE_DVB_FE (MEDIA_ENT_T_DEVNODE + 4) 134#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
54#define MEDIA_ENT_T_DEVNODE_DVB_DEMUX (MEDIA_ENT_T_DEVNODE + 5)
55#define MEDIA_ENT_T_DEVNODE_DVB_DVR (MEDIA_ENT_T_DEVNODE + 6)
56#define MEDIA_ENT_T_DEVNODE_DVB_CA (MEDIA_ENT_T_DEVNODE + 7)
57#define MEDIA_ENT_T_DEVNODE_DVB_NET (MEDIA_ENT_T_DEVNODE + 8)
58
59/* Legacy symbol. Use it to avoid userspace compilation breakages */
60#define MEDIA_ENT_T_DEVNODE_DVB MEDIA_ENT_T_DEVNODE_DVB_FE
61
62#define MEDIA_ENT_T_V4L2_SUBDEV (2 << MEDIA_ENT_TYPE_SHIFT)
63#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV + 1)
64#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV + 2)
65#define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV + 3)
66/* A converter of analogue video to its digital representation. */
67#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV + 4)
68 135
69#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV + 5) 136#define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
137#define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
138#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
139#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
140#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
141#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
142#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
143#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
144#endif
70 145
146/* Entity flags */
71#define MEDIA_ENT_FL_DEFAULT (1 << 0) 147#define MEDIA_ENT_FL_DEFAULT (1 << 0)
148#define MEDIA_ENT_FL_CONNECTOR (1 << 1)
72 149
73struct media_entity_desc { 150struct media_entity_desc {
74 __u32 id; 151 __u32 id;
@@ -151,6 +228,10 @@ struct media_pad_desc {
151#define MEDIA_LNK_FL_IMMUTABLE (1 << 1) 228#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
152#define MEDIA_LNK_FL_DYNAMIC (1 << 2) 229#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
153 230
231#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
232# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
233# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
234
154struct media_link_desc { 235struct media_link_desc {
155 struct media_pad_desc source; 236 struct media_pad_desc source;
156 struct media_pad_desc sink; 237 struct media_pad_desc sink;
@@ -167,9 +248,120 @@ struct media_links_enum {
167 __u32 reserved[4]; 248 __u32 reserved[4];
168}; 249};
169 250
251/* Interface type ranges */
252
253#define MEDIA_INTF_T_DVB_BASE 0x00000100
254#define MEDIA_INTF_T_V4L_BASE 0x00000200
255
256/* Interface types */
257
258#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
259#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
260#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
261#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
262#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
263
264#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
265#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
266#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
267#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
268#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
269
270/*
271 * MC next gen API definitions
272 *
273 * NOTE: The declarations below are close to the MC RFC for the Media
274 * Controller, the next generation. Yet, there are a few adjustments
275 * to do, as we want to be able to have a functional API before
276 * the MC properties change. Those will be properly marked below.
277 * Please also notice that I removed "num_pads", "num_links",
278 * from the proposal, as a proper userspace application will likely
279 * use lists for pads/links, just as we intend to do in Kernelspace.
280 * The API definition should be freed from fields that are bound to
281 * some specific data structure.
282 *
283 * FIXME: Currently, I opted to name the new types as "media_v2", as this
284 * won't cause any conflict with the Kernelspace namespace, nor with
285 * the previous kAPI media_*_desc namespace. This can be changed
286 * later, before the adding this API upstream.
287 */
288
289#if 0 /* Let's postpone it to Kernel 4.6 */
290struct media_v2_entity {
291 __u32 id;
292 char name[64]; /* FIXME: move to a property? (RFC says so) */
293 __u32 function; /* Main function of the entity */
294 __u16 reserved[12];
295};
296
297/* Should match the specific fields at media_intf_devnode */
298struct media_v2_intf_devnode {
299 __u32 major;
300 __u32 minor;
301};
302
303struct media_v2_interface {
304 __u32 id;
305 __u32 intf_type;
306 __u32 flags;
307 __u32 reserved[9];
308
309 union {
310 struct media_v2_intf_devnode devnode;
311 __u32 raw[16];
312 };
313};
314
315struct media_v2_pad {
316 __u32 id;
317 __u32 entity_id;
318 __u32 flags;
319 __u16 reserved[9];
320};
321
322struct media_v2_link {
323 __u32 id;
324 __u32 source_id;
325 __u32 sink_id;
326 __u32 flags;
327 __u32 reserved[5];
328};
329
330struct media_v2_topology {
331 __u64 topology_version;
332
333 __u32 num_entities;
334 __u32 reserved1;
335 __u64 ptr_entities;
336
337 __u32 num_interfaces;
338 __u32 reserved2;
339 __u64 ptr_interfaces;
340
341 __u32 num_pads;
342 __u32 reserved3;
343 __u64 ptr_pads;
344
345 __u32 num_links;
346 __u32 reserved4;
347 __u64 ptr_links;
348};
349
350static inline void __user *media_get_uptr(__u64 arg)
351{
352 return (void __user *)(uintptr_t)arg;
353}
354#endif
355
356/* ioctls */
357
170#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) 358#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
171#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) 359#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
172#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) 360#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
173#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) 361#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
174 362
363#if 0 /* Let's postpone it to Kernel 4.6 */
364#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
365#endif
366
175#endif /* __LINUX_MEDIA_H */ 367#endif /* __LINUX_MEDIA_H */