Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
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
20#ifndef __LINUX_MEDIA_H
21#define __LINUX_MEDIA_H
22
23#include <stdint.h>
24#include <linux/ioctl.h>
25#include <linux/types.h>
26#include <linux/version.h>
27
28struct media_device_info {
29 char driver[16];
30 char model[32];
31 char serial[40];
32 char bus_info[32];
33 __u32 media_version;
34 __u32 hw_revision;
35 __u32 driver_version;
36 __u32 reserved[31];
37};
38
39/*
40 * Base number ranges for entity functions
41 *
42 * NOTE: Userspace should not rely on these ranges to identify a group
43 * of function types, as newer functions can be added with any name within
44 * the full u32 range.
45 *
46 * Some older functions use the MEDIA_ENT_F_OLD_*_BASE range. Do not
47 * change this, this is for backwards compatibility. When adding new
48 * functions always use MEDIA_ENT_F_BASE.
49 */
50#define MEDIA_ENT_F_BASE 0x00000000
51#define MEDIA_ENT_F_OLD_BASE 0x00010000
52#define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000
53
54/*
55 * Initial value to be used when a new entity is created
56 * Drivers should change it to something useful.
57 */
58#define MEDIA_ENT_F_UNKNOWN MEDIA_ENT_F_BASE
59
60/*
61 * Subdevs are initialized with MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN in order
62 * to preserve backward compatibility. Drivers must change to the proper
63 * subdev type before registering the entity.
64 */
65#define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
66
67/*
68 * DVB entity functions
69 */
70#define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 0x00001)
71#define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 0x00002)
72#define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 0x00003)
73#define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 0x00004)
74
75/*
76 * I/O entity functions
77 */
78#define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
79#define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 0x01001)
80#define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 0x01002)
81#define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003)
82
83/*
84 * Sensor functions
85 */
86#define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
87#define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
88#define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
89
90/*
91 * Video decoder functions
92 */
93#define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
94#define MEDIA_ENT_F_DTV_DECODER (MEDIA_ENT_F_BASE + 0x6001)
95
96/*
97 * Digital TV, analog TV, radio and/or software defined radio tuner functions.
98 *
99 * It is a responsibility of the master/bridge drivers to add connectors
100 * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
101 * may require the usage of separate I2C chips to decode analog TV signals,
102 * when the master/bridge chipset doesn't have its own TV standard decoder.
103 * On such cases, the IF-PLL staging is mapped via one or two entities:
104 * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
105 */
106#define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
107
108/*
109 * Analog TV IF-PLL decoder functions
110 *
111 * It is a responsibility of the master/bridge drivers to create links
112 * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
113 */
114#define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 0x02001)
115#define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 0x02002)
116
117/*
118 * Audio entity functions
119 */
120#define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 0x03001)
121#define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 0x03002)
122#define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003)
123
124/*
125 * Processing entity functions
126 */
127#define MEDIA_ENT_F_PROC_VIDEO_COMPOSER (MEDIA_ENT_F_BASE + 0x4001)
128#define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER (MEDIA_ENT_F_BASE + 0x4002)
129#define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV (MEDIA_ENT_F_BASE + 0x4003)
130#define MEDIA_ENT_F_PROC_VIDEO_LUT (MEDIA_ENT_F_BASE + 0x4004)
131#define MEDIA_ENT_F_PROC_VIDEO_SCALER (MEDIA_ENT_F_BASE + 0x4005)
132#define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006)
133
134/*
135 * Switch and bridge entity functions
136 */
137#define MEDIA_ENT_F_VID_MUX (MEDIA_ENT_F_BASE + 0x5001)
138#define MEDIA_ENT_F_VID_IF_BRIDGE (MEDIA_ENT_F_BASE + 0x5002)
139
140/* Entity flags */
141#define MEDIA_ENT_FL_DEFAULT (1 << 0)
142#define MEDIA_ENT_FL_CONNECTOR (1 << 1)
143
144/* OR with the entity id value to find the next entity */
145#define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
146
147struct media_entity_desc {
148 __u32 id;
149 char name[32];
150 __u32 type;
151 __u32 revision;
152 __u32 flags;
153 __u32 group_id;
154 __u16 pads;
155 __u16 links;
156
157 __u32 reserved[4];
158
159 union {
160 /* Node specifications */
161 struct {
162 __u32 major;
163 __u32 minor;
164 } dev;
165
166 /*
167 * TODO: this shouldn't have been added without
168 * actual drivers that use this. When the first real driver
169 * appears that sets this information, special attention
170 * should be given whether this information is 1) enough, and
171 * 2) can deal with udev rules that rename devices. The struct
172 * dev would not be sufficient for this since that does not
173 * contain the subdevice information. In addition, struct dev
174 * can only refer to a single device, and not to multiple (e.g.
175 * pcm and mixer devices).
176 */
177 struct {
178 __u32 card;
179 __u32 device;
180 __u32 subdevice;
181 } alsa;
182
183 /*
184 * DEPRECATED: previous node specifications. Kept just to
185 * avoid breaking compilation. Use media_entity_desc.dev
186 * instead.
187 */
188 struct {
189 __u32 major;
190 __u32 minor;
191 } v4l;
192 struct {
193 __u32 major;
194 __u32 minor;
195 } fb;
196 int dvb;
197
198 /* Sub-device specifications */
199 /* Nothing needed yet */
200 __u8 raw[184];
201 };
202};
203
204#define MEDIA_PAD_FL_SINK (1 << 0)
205#define MEDIA_PAD_FL_SOURCE (1 << 1)
206#define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
207
208struct media_pad_desc {
209 __u32 entity; /* entity ID */
210 __u16 index; /* pad index */
211 __u32 flags; /* pad flags */
212 __u32 reserved[2];
213};
214
215#define MEDIA_LNK_FL_ENABLED (1 << 0)
216#define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
217#define MEDIA_LNK_FL_DYNAMIC (1 << 2)
218
219#define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
220# define MEDIA_LNK_FL_DATA_LINK (0 << 28)
221# define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
222
223struct media_link_desc {
224 struct media_pad_desc source;
225 struct media_pad_desc sink;
226 __u32 flags;
227 __u32 reserved[2];
228};
229
230struct media_links_enum {
231 __u32 entity;
232 /* Should have enough room for pads elements */
233 struct media_pad_desc *pads;
234 /* Should have enough room for links elements */
235 struct media_link_desc *links;
236 __u32 reserved[4];
237};
238
239/* Interface type ranges */
240
241#define MEDIA_INTF_T_DVB_BASE 0x00000100
242#define MEDIA_INTF_T_V4L_BASE 0x00000200
243
244/* Interface types */
245
246#define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
247#define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
248#define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
249#define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
250#define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
251
252#define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
253#define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
254#define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
255#define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
256#define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
257#define MEDIA_INTF_T_V4L_TOUCH (MEDIA_INTF_T_V4L_BASE + 5)
258
259
260/*
261 * MC next gen API definitions
262 */
263
264struct media_v2_entity {
265 __u32 id;
266 char name[64];
267 __u32 function; /* Main function of the entity */
268 __u32 reserved[6];
269} __attribute__ ((packed));
270
271/* Should match the specific fields at media_intf_devnode */
272struct media_v2_intf_devnode {
273 __u32 major;
274 __u32 minor;
275} __attribute__ ((packed));
276
277struct media_v2_interface {
278 __u32 id;
279 __u32 intf_type;
280 __u32 flags;
281 __u32 reserved[9];
282
283 union {
284 struct media_v2_intf_devnode devnode;
285 __u32 raw[16];
286 };
287} __attribute__ ((packed));
288
289struct media_v2_pad {
290 __u32 id;
291 __u32 entity_id;
292 __u32 flags;
293 __u32 reserved[5];
294} __attribute__ ((packed));
295
296struct media_v2_link {
297 __u32 id;
298 __u32 source_id;
299 __u32 sink_id;
300 __u32 flags;
301 __u32 reserved[6];
302} __attribute__ ((packed));
303
304struct media_v2_topology {
305 __u64 topology_version;
306
307 __u32 num_entities;
308 __u32 reserved1;
309 __u64 ptr_entities;
310
311 __u32 num_interfaces;
312 __u32 reserved2;
313 __u64 ptr_interfaces;
314
315 __u32 num_pads;
316 __u32 reserved3;
317 __u64 ptr_pads;
318
319 __u32 num_links;
320 __u32 reserved4;
321 __u64 ptr_links;
322} __attribute__ ((packed));
323
324/* ioctls */
325
326#define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
327#define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
328#define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
329#define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
330#define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
331
332
333/*
334 * Legacy symbols used to avoid userspace compilation breakages.
335 * Do not use any of this in new applications!
336 *
337 * Those symbols map the entity function into types and should be
338 * used only on legacy programs for legacy hardware. Don't rely
339 * on those for MEDIA_IOC_G_TOPOLOGY.
340 */
341#define MEDIA_ENT_TYPE_SHIFT 16
342#define MEDIA_ENT_TYPE_MASK 0x00ff0000
343#define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
344
345#define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_F_OLD_BASE | \
346 MEDIA_ENT_SUBTYPE_MASK)
347
348#define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
349#define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
350#define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_F_OLD_BASE + 2)
351#define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_F_OLD_BASE + 3)
352#define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_F_OLD_BASE + 4)
353
354#define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
355#define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
356#define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
357#define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
358#define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
359#define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
360#define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
361#define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
362
363/*
364 * There is still no ALSA support in the media controller. These
365 * defines should not have been added and we leave them here only
366 * in case some application tries to use these defines.
367 */
368#define MEDIA_INTF_T_ALSA_BASE 0x00000300
369#define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE)
370#define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
371#define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
372#define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3)
373#define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)
374#define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
375#define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6)
376#define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
377
378/* Obsolete symbol for media_version, no longer used in the kernel */
379#define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
380
381
382#endif /* __LINUX_MEDIA_H */
383

Warning: That file was not part of the compilation database. It may have many parsing errors.