]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/uapi/linux/media.h
[media] adv7604: fix tx 5v detect regression
[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
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 */
4ca72efa
MCC
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)
fa17b46a 73
b50bde4e 74/*
1f452240 75 * I/O entities
4ca72efa 76 */
1f452240
HV
77#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 1001)
78#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 1002)
79#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 1003)
4ca72efa
MCC
80
81/*
1f452240 82 * Connectors
4ca72efa 83 */
1f452240
HV
84/* It is a responsibility of the entity drivers to add connectors and links */
85#define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 10001)
86#define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 10002)
87#define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 10003)
4ca72efa
MCC
88
89/*
90 * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
91 * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
92 * with the legacy v1 API.The number range is out of range by purpose:
93 * several previously reserved numbers got excluded from this range.
94 *
b50bde4e
MCC
95 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
96 * in order to preserve backward compatibility.
d1b9da2d 97 * Drivers must change to the proper subdev type before
b50bde4e
MCC
98 * registering the entity.
99 */
4ca72efa
MCC
100
101#define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
102
103#define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
104#define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
105#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
106#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
b3109d66
MCC
107/*
108 * It is a responsibility of the entity drivers to add connectors and links
109 * for the tuner entities.
110 */
4ca72efa
MCC
111#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
112
113#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
49a11518 114
4376679a 115#ifndef __KERNEL__
4ca72efa
MCC
116
117/*
118 * Legacy symbols used to avoid userspace compilation breakages
119 *
120 * Those symbols map the entity function into types and should be
121 * used only on legacy programs for legacy hardware. Don't rely
122 * on those for MEDIA_IOC_G_TOPOLOGY.
123 */
1651333b
LP
124#define MEDIA_ENT_TYPE_SHIFT 16
125#define MEDIA_ENT_TYPE_MASK 0x00ff0000
126#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
127
4ca72efa
MCC
128#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
129#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
1651333b
LP
130#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
131#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
32fdc0e1 132#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
4ca72efa
MCC
133
134#define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
135#define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
136#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
137#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
138#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
139#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
140#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
141#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
4376679a 142#endif
32fdc0e1 143
49a11518 144/* Entity flags */
1651333b 145#define MEDIA_ENT_FL_DEFAULT (1 << 0)
49a11518 146#define MEDIA_ENT_FL_CONNECTOR (1 << 1)
1651333b
LP
147
148struct media_entity_desc {
149 __u32 id;
150 char name[32];
151 __u32 type;
152 __u32 revision;
153 __u32 flags;
154 __u32 group_id;
155 __u16 pads;
156 __u16 links;
157
158 __u32 reserved[4];
159
160 union {
161 /* Node specifications */
e31a0ba7
MCC
162 struct {
163 __u32 major;
164 __u32 minor;
165 } dev;
166
7e182f78
HV
167#if 1
168 /*
169 * TODO: this shouldn't have been added without
170 * actual drivers that use this. When the first real driver
171 * appears that sets this information, special attention
172 * should be given whether this information is 1) enough, and
173 * 2) can deal with udev rules that rename devices. The struct
174 * dev would not be sufficient for this since that does not
175 * contain the subdevice information. In addition, struct dev
176 * can only refer to a single device, and not to multiple (e.g.
177 * pcm and mixer devices).
178 *
179 * So for now mark this as a to do.
180 */
181 struct {
182 __u32 card;
183 __u32 device;
184 __u32 subdevice;
185 } alsa;
186#endif
187
e31a0ba7
MCC
188#if 1
189 /*
190 * DEPRECATED: previous node specifications. Kept just to
191 * avoid breaking compilation, but media_entity_desc.dev
192 * should be used instead. In particular, alsa and dvb
193 * fields below are wrong: for all devnodes, there should
194 * be just major/minor inside the struct, as this is enough
195 * to represent any devnode, no matter what type.
196 */
1651333b
LP
197 struct {
198 __u32 major;
199 __u32 minor;
200 } v4l;
201 struct {
202 __u32 major;
203 __u32 minor;
204 } fb;
1651333b 205 int dvb;
e31a0ba7 206#endif
1651333b
LP
207
208 /* Sub-device specifications */
209 /* Nothing needed yet */
210 __u8 raw[184];
211 };
212};
213
214#define MEDIA_PAD_FL_SINK (1 << 0)
215#define MEDIA_PAD_FL_SOURCE (1 << 1)
d0700c51 216#define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
1651333b
LP
217
218struct media_pad_desc {
219 __u32 entity; /* entity ID */
220 __u16 index; /* pad index */
221 __u32 flags; /* pad flags */
222 __u32 reserved[2];
223};
224
225#define MEDIA_LNK_FL_ENABLED (1 << 0)
226#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
e02188c9 227#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
1651333b 228
c398bb64
MCC
229#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
230# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
231# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
232
1651333b
LP
233struct media_link_desc {
234 struct media_pad_desc source;
235 struct media_pad_desc sink;
236 __u32 flags;
237 __u32 reserved[2];
238};
239
240struct media_links_enum {
241 __u32 entity;
242 /* Should have enough room for pads elements */
243 struct media_pad_desc __user *pads;
244 /* Should have enough room for links elements */
245 struct media_link_desc __user *links;
246 __u32 reserved[4];
247};
248
a1d2510e
MCC
249/* Interface type ranges */
250
251#define MEDIA_INTF_T_DVB_BASE 0x00000100
252#define MEDIA_INTF_T_V4L_BASE 0x00000200
253
254/* Interface types */
255
256#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
257#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
258#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
259#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
260#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
261
262#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
263#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
264#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
265#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
266#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
267
c398bb64
MCC
268/*
269 * MC next gen API definitions
270 *
271 * NOTE: The declarations below are close to the MC RFC for the Media
272 * Controller, the next generation. Yet, there are a few adjustments
273 * to do, as we want to be able to have a functional API before
274 * the MC properties change. Those will be properly marked below.
275 * Please also notice that I removed "num_pads", "num_links",
276 * from the proposal, as a proper userspace application will likely
277 * use lists for pads/links, just as we intend to do in Kernelspace.
278 * The API definition should be freed from fields that are bound to
279 * some specific data structure.
280 *
281 * FIXME: Currently, I opted to name the new types as "media_v2", as this
282 * won't cause any conflict with the Kernelspace namespace, nor with
283 * the previous kAPI media_*_desc namespace. This can be changed
284 * later, before the adding this API upstream.
285 */
286
be0270ec 287#if 0 /* Let's postpone it to Kernel 4.6 */
c398bb64
MCC
288struct media_v2_entity {
289 __u32 id;
290 char name[64]; /* FIXME: move to a property? (RFC says so) */
d87cdb88
MCC
291 __u32 function; /* Main function of the entity */
292 __u16 reserved[12];
c398bb64
MCC
293};
294
295/* Should match the specific fields at media_intf_devnode */
296struct media_v2_intf_devnode {
297 __u32 major;
298 __u32 minor;
299};
300
301struct media_v2_interface {
302 __u32 id;
303 __u32 intf_type;
304 __u32 flags;
305 __u32 reserved[9];
306
307 union {
308 struct media_v2_intf_devnode devnode;
309 __u32 raw[16];
310 };
311};
312
313struct media_v2_pad {
314 __u32 id;
315 __u32 entity_id;
316 __u32 flags;
317 __u16 reserved[9];
318};
319
320struct media_v2_link {
321 __u32 id;
322 __u32 source_id;
323 __u32 sink_id;
324 __u32 flags;
325 __u32 reserved[5];
326};
327
328struct media_v2_topology {
b3b7a9f1 329 __u64 topology_version;
c398bb64 330
7c9d6731
MCC
331 __u32 num_entities;
332 __u32 reserved1;
b3b7a9f1 333 __u64 ptr_entities;
c398bb64 334
7c9d6731
MCC
335 __u32 num_interfaces;
336 __u32 reserved2;
b3b7a9f1 337 __u64 ptr_interfaces;
c398bb64 338
7c9d6731
MCC
339 __u32 num_pads;
340 __u32 reserved3;
b3b7a9f1 341 __u64 ptr_pads;
c398bb64 342
7c9d6731
MCC
343 __u32 num_links;
344 __u32 reserved4;
b3b7a9f1 345 __u64 ptr_links;
c398bb64
MCC
346};
347
b3b7a9f1
MCC
348static inline void __user *media_get_uptr(__u64 arg)
349{
350 return (void __user *)(uintptr_t)arg;
351}
be0270ec 352#endif
b3b7a9f1 353
c398bb64 354/* ioctls */
a1d2510e 355
474966ee
LP
356#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
357#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
358#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
359#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
be0270ec
MCC
360
361#if 0 /* Let's postpone it to Kernel 4.6 */
c398bb64 362#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
be0270ec 363#endif
140d8816
LP
364
365#endif /* __LINUX_MEDIA_H */