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