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