xref: /linux/include/uapi/linux/media.h (revision cdd5b5a9761fd66d17586e4f4ba6588c70e640ea)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2607ca46eSDavid Howells /*
3607ca46eSDavid Howells  * Multimedia device API
4607ca46eSDavid Howells  *
5607ca46eSDavid Howells  * Copyright (C) 2010 Nokia Corporation
6607ca46eSDavid Howells  *
7607ca46eSDavid Howells  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
8607ca46eSDavid Howells  *	     Sakari Ailus <sakari.ailus@iki.fi>
9607ca46eSDavid Howells  *
10607ca46eSDavid Howells  * This program is free software; you can redistribute it and/or modify
11607ca46eSDavid Howells  * it under the terms of the GNU General Public License version 2 as
12607ca46eSDavid Howells  * published by the Free Software Foundation.
13607ca46eSDavid Howells  *
14607ca46eSDavid Howells  * This program is distributed in the hope that it will be useful,
15607ca46eSDavid Howells  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16607ca46eSDavid Howells  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17607ca46eSDavid Howells  * GNU General Public License for more details.
18607ca46eSDavid Howells  */
19607ca46eSDavid Howells 
20607ca46eSDavid Howells #ifndef __LINUX_MEDIA_H
21607ca46eSDavid Howells #define __LINUX_MEDIA_H
22607ca46eSDavid Howells 
23607ca46eSDavid Howells #include <linux/ioctl.h>
24607ca46eSDavid Howells #include <linux/types.h>
25607ca46eSDavid Howells 
26607ca46eSDavid Howells struct media_device_info {
27607ca46eSDavid Howells 	char driver[16];
28607ca46eSDavid Howells 	char model[32];
29607ca46eSDavid Howells 	char serial[40];
30607ca46eSDavid Howells 	char bus_info[32];
31607ca46eSDavid Howells 	__u32 media_version;
32607ca46eSDavid Howells 	__u32 hw_revision;
33607ca46eSDavid Howells 	__u32 driver_version;
34607ca46eSDavid Howells 	__u32 reserved[31];
35607ca46eSDavid Howells };
36607ca46eSDavid Howells 
3732fdc0e1SMauro Carvalho Chehab /*
384ca72efaSMauro Carvalho Chehab  * Base number ranges for entity functions
3932fdc0e1SMauro Carvalho Chehab  *
40ed3056f0SHans Verkuil  * NOTE: Userspace should not rely on these ranges to identify a group
41ed3056f0SHans Verkuil  * of function types, as newer functions can be added with any name within
42ed3056f0SHans Verkuil  * the full u32 range.
43ed3056f0SHans Verkuil  *
44ed3056f0SHans Verkuil  * Some older functions use the MEDIA_ENT_F_OLD_*_BASE range. Do not
45ed3056f0SHans Verkuil  * change this, this is for backwards compatibility. When adding new
46ed3056f0SHans Verkuil  * functions always use MEDIA_ENT_F_BASE.
474ca72efaSMauro Carvalho Chehab  */
484ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_BASE			0x00000000
494ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_OLD_BASE			0x00010000
504ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_OLD_SUBDEV_BASE		0x00020000
514ca72efaSMauro Carvalho Chehab 
524ca72efaSMauro Carvalho Chehab /*
53ed3056f0SHans Verkuil  * Initial value to be used when a new entity is created
54ed3056f0SHans Verkuil  * Drivers should change it to something useful.
55ed3056f0SHans Verkuil  */
56ed3056f0SHans Verkuil #define MEDIA_ENT_F_UNKNOWN			MEDIA_ENT_F_BASE
57ed3056f0SHans Verkuil 
58ed3056f0SHans Verkuil /*
59ed3056f0SHans Verkuil  * Subdevs are initialized with MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN in order
60ed3056f0SHans Verkuil  * to preserve backward compatibility. Drivers must change to the proper
61ed3056f0SHans Verkuil  * subdev type before registering the entity.
62ed3056f0SHans Verkuil  */
63ed3056f0SHans Verkuil #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN		MEDIA_ENT_F_OLD_SUBDEV_BASE
64ed3056f0SHans Verkuil 
65ed3056f0SHans Verkuil /*
66ed3056f0SHans Verkuil  * DVB entity functions
674ca72efaSMauro Carvalho Chehab  */
6858402b6eSHans Verkuil #define MEDIA_ENT_F_DTV_DEMOD			(MEDIA_ENT_F_BASE + 0x00001)
6958402b6eSHans Verkuil #define MEDIA_ENT_F_TS_DEMUX			(MEDIA_ENT_F_BASE + 0x00002)
7058402b6eSHans Verkuil #define MEDIA_ENT_F_DTV_CA			(MEDIA_ENT_F_BASE + 0x00003)
7158402b6eSHans Verkuil #define MEDIA_ENT_F_DTV_NET_DECAP		(MEDIA_ENT_F_BASE + 0x00004)
724ca72efaSMauro Carvalho Chehab 
734ca72efaSMauro Carvalho Chehab /*
74ed3056f0SHans Verkuil  * I/O entity functions
751f452240SHans Verkuil  */
76ed3056f0SHans Verkuil #define MEDIA_ENT_F_IO_V4L			(MEDIA_ENT_F_OLD_BASE + 1)
7758402b6eSHans Verkuil #define MEDIA_ENT_F_IO_DTV			(MEDIA_ENT_F_BASE + 0x01001)
7858402b6eSHans Verkuil #define MEDIA_ENT_F_IO_VBI			(MEDIA_ENT_F_BASE + 0x01002)
7958402b6eSHans Verkuil #define MEDIA_ENT_F_IO_SWRADIO			(MEDIA_ENT_F_BASE + 0x01003)
801f452240SHans Verkuil 
811f452240SHans Verkuil /*
82ed3056f0SHans Verkuil  * Sensor functions
8306131932SMauro Carvalho Chehab  */
844ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_CAM_SENSOR			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
854ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_FLASH			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
864ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_LENS			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
87ed3056f0SHans Verkuil 
88b3109d66SMauro Carvalho Chehab /*
89ed3056f0SHans Verkuil  * Digital TV, analog TV, radio and/or software defined radio tuner functions.
90ed3056f0SHans Verkuil  *
9106131932SMauro Carvalho Chehab  * It is a responsibility of the master/bridge drivers to add connectors
9206131932SMauro Carvalho Chehab  * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
9306131932SMauro Carvalho Chehab  * may require the usage of separate I2C chips to decode analog TV signals,
9406131932SMauro Carvalho Chehab  * when the master/bridge chipset doesn't have its own TV standard decoder.
9506131932SMauro Carvalho Chehab  * On such cases, the IF-PLL staging is mapped via one or two entities:
9606131932SMauro Carvalho Chehab  * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
97b3109d66SMauro Carvalho Chehab  */
984ca72efaSMauro Carvalho Chehab #define MEDIA_ENT_F_TUNER			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
9932fdc0e1SMauro Carvalho Chehab 
100ed3056f0SHans Verkuil /*
101ed3056f0SHans Verkuil  * Analog TV IF-PLL decoder functions
102ed3056f0SHans Verkuil  *
103ed3056f0SHans Verkuil  * It is a responsibility of the master/bridge drivers to create links
104ed3056f0SHans Verkuil  * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
105ed3056f0SHans Verkuil  */
106ed3056f0SHans Verkuil #define MEDIA_ENT_F_IF_VID_DECODER		(MEDIA_ENT_F_BASE + 0x02001)
107ed3056f0SHans Verkuil #define MEDIA_ENT_F_IF_AUD_DECODER		(MEDIA_ENT_F_BASE + 0x02002)
1084ca72efaSMauro Carvalho Chehab 
1094ca72efaSMauro Carvalho Chehab /*
110ed3056f0SHans Verkuil  * Audio entity functions
1114ca72efaSMauro Carvalho Chehab  */
112ed3056f0SHans Verkuil #define MEDIA_ENT_F_AUDIO_CAPTURE		(MEDIA_ENT_F_BASE + 0x03001)
113ed3056f0SHans Verkuil #define MEDIA_ENT_F_AUDIO_PLAYBACK		(MEDIA_ENT_F_BASE + 0x03002)
114ed3056f0SHans Verkuil #define MEDIA_ENT_F_AUDIO_MIXER			(MEDIA_ENT_F_BASE + 0x03003)
115607ca46eSDavid Howells 
116ed3056f0SHans Verkuil /*
117ed3056f0SHans Verkuil  * Processing entity functions
118ed3056f0SHans Verkuil  */
119ed3056f0SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_COMPOSER		(MEDIA_ENT_F_BASE + 0x4001)
120ed3056f0SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER	(MEDIA_ENT_F_BASE + 0x4002)
121ed3056f0SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV	(MEDIA_ENT_F_BASE + 0x4003)
122ed3056f0SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_LUT		(MEDIA_ENT_F_BASE + 0x4004)
123ed3056f0SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_SCALER		(MEDIA_ENT_F_BASE + 0x4005)
124ed3056f0SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS	(MEDIA_ENT_F_BASE + 0x4006)
12545841a97SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_ENCODER		(MEDIA_ENT_F_BASE + 0x4007)
12645841a97SHans Verkuil #define MEDIA_ENT_F_PROC_VIDEO_DECODER		(MEDIA_ENT_F_BASE + 0x4008)
127f7c7d6ccSSakari Ailus #define MEDIA_ENT_F_PROC_VIDEO_ISP		(MEDIA_ENT_F_BASE + 0x4009)
128b2cd2744SMauro Carvalho Chehab 
129ed3056f0SHans Verkuil /*
130ed3056f0SHans Verkuil  * Switch and bridge entity functions
131ed3056f0SHans Verkuil  */
132ed3056f0SHans Verkuil #define MEDIA_ENT_F_VID_MUX			(MEDIA_ENT_F_BASE + 0x5001)
133ed3056f0SHans Verkuil #define MEDIA_ENT_F_VID_IF_BRIDGE		(MEDIA_ENT_F_BASE + 0x5002)
1341d20f9f6SMauro Carvalho Chehab 
135f2399f75SHans Verkuil /*
136f2399f75SHans Verkuil  * Video decoder/encoder functions
137f2399f75SHans Verkuil  */
138f2399f75SHans Verkuil #define MEDIA_ENT_F_ATV_DECODER			(MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
139f2399f75SHans Verkuil #define MEDIA_ENT_F_DV_DECODER			(MEDIA_ENT_F_BASE + 0x6001)
140f2399f75SHans Verkuil #define MEDIA_ENT_F_DV_ENCODER			(MEDIA_ENT_F_BASE + 0x6002)
141f2399f75SHans Verkuil 
14249a11518SMauro Carvalho Chehab /* Entity flags */
143*98b95642SSakari Ailus #define MEDIA_ENT_FL_DEFAULT			(1U << 0)
144*98b95642SSakari Ailus #define MEDIA_ENT_FL_CONNECTOR			(1U << 1)
145607ca46eSDavid Howells 
146ed3056f0SHans Verkuil /* OR with the entity id value to find the next entity */
1475ca004d1SShuah Khan #define MEDIA_ENT_ID_FLAG_NEXT			(1U << 31)
148ed3056f0SHans Verkuil 
149607ca46eSDavid Howells struct media_entity_desc {
150607ca46eSDavid Howells 	__u32 id;
151607ca46eSDavid Howells 	char name[32];
152607ca46eSDavid Howells 	__u32 type;
153607ca46eSDavid Howells 	__u32 revision;
154607ca46eSDavid Howells 	__u32 flags;
155607ca46eSDavid Howells 	__u32 group_id;
156607ca46eSDavid Howells 	__u16 pads;
157607ca46eSDavid Howells 	__u16 links;
158607ca46eSDavid Howells 
159607ca46eSDavid Howells 	__u32 reserved[4];
160607ca46eSDavid Howells 
161607ca46eSDavid Howells 	union {
162607ca46eSDavid Howells 		/* Node specifications */
163607ca46eSDavid Howells 		struct {
164607ca46eSDavid Howells 			__u32 major;
165607ca46eSDavid Howells 			__u32 minor;
166e31a0ba7SMauro Carvalho Chehab 		} dev;
167e31a0ba7SMauro Carvalho Chehab 
168ed3056f0SHans Verkuil #if !defined(__KERNEL__)
169e31a0ba7SMauro Carvalho Chehab 		/*
1707e182f78SHans Verkuil 		 * TODO: this shouldn't have been added without
1717e182f78SHans Verkuil 		 * actual drivers that use this. When the first real driver
1727e182f78SHans Verkuil 		 * appears that sets this information, special attention
1737e182f78SHans Verkuil 		 * should be given whether this information is 1) enough, and
1747e182f78SHans Verkuil 		 * 2) can deal with udev rules that rename devices. The struct
1757e182f78SHans Verkuil 		 * dev would not be sufficient for this since that does not
1767e182f78SHans Verkuil 		 * contain the subdevice information. In addition, struct dev
1777e182f78SHans Verkuil 		 * can only refer to a single device, and not to multiple (e.g.
1787e182f78SHans Verkuil 		 * pcm and mixer devices).
1797e182f78SHans Verkuil 		 */
1807e182f78SHans Verkuil 		struct {
1817e182f78SHans Verkuil 			__u32 card;
1827e182f78SHans Verkuil 			__u32 device;
1837e182f78SHans Verkuil 			__u32 subdevice;
1847e182f78SHans Verkuil 		} alsa;
1857e182f78SHans Verkuil 
1867e182f78SHans Verkuil 		/*
187e31a0ba7SMauro Carvalho Chehab 		 * DEPRECATED: previous node specifications. Kept just to
188ed3056f0SHans Verkuil 		 * avoid breaking compilation. Use media_entity_desc.dev
189ed3056f0SHans Verkuil 		 * instead.
190e31a0ba7SMauro Carvalho Chehab 		 */
191e31a0ba7SMauro Carvalho Chehab 		struct {
192e31a0ba7SMauro Carvalho Chehab 			__u32 major;
193e31a0ba7SMauro Carvalho Chehab 			__u32 minor;
194607ca46eSDavid Howells 		} v4l;
195607ca46eSDavid Howells 		struct {
196607ca46eSDavid Howells 			__u32 major;
197607ca46eSDavid Howells 			__u32 minor;
198607ca46eSDavid Howells 		} fb;
199607ca46eSDavid Howells 		int dvb;
200e31a0ba7SMauro Carvalho Chehab #endif
201607ca46eSDavid Howells 
202607ca46eSDavid Howells 		/* Sub-device specifications */
203607ca46eSDavid Howells 		/* Nothing needed yet */
204607ca46eSDavid Howells 		__u8 raw[184];
205607ca46eSDavid Howells 	};
206607ca46eSDavid Howells };
207607ca46eSDavid Howells 
208*98b95642SSakari Ailus #define MEDIA_PAD_FL_SINK			(1U << 0)
209*98b95642SSakari Ailus #define MEDIA_PAD_FL_SOURCE			(1U << 1)
210*98b95642SSakari Ailus #define MEDIA_PAD_FL_MUST_CONNECT		(1U << 2)
211607ca46eSDavid Howells 
212607ca46eSDavid Howells struct media_pad_desc {
213607ca46eSDavid Howells 	__u32 entity;		/* entity ID */
214607ca46eSDavid Howells 	__u16 index;		/* pad index */
215607ca46eSDavid Howells 	__u32 flags;		/* pad flags */
216607ca46eSDavid Howells 	__u32 reserved[2];
217607ca46eSDavid Howells };
218607ca46eSDavid Howells 
219*98b95642SSakari Ailus #define MEDIA_LNK_FL_ENABLED			(1U << 0)
220*98b95642SSakari Ailus #define MEDIA_LNK_FL_IMMUTABLE			(1U << 1)
221*98b95642SSakari Ailus #define MEDIA_LNK_FL_DYNAMIC			(1U << 2)
222607ca46eSDavid Howells 
223c398bb64SMauro Carvalho Chehab #define MEDIA_LNK_FL_LINK_TYPE			(0xf << 28)
224*98b95642SSakari Ailus #  define MEDIA_LNK_FL_DATA_LINK		(0U << 28)
225*98b95642SSakari Ailus #  define MEDIA_LNK_FL_INTERFACE_LINK		(1U << 28)
226*98b95642SSakari Ailus #  define MEDIA_LNK_FL_ANCILLARY_LINK		(2U << 28)
227c398bb64SMauro Carvalho Chehab 
228607ca46eSDavid Howells struct media_link_desc {
229607ca46eSDavid Howells 	struct media_pad_desc source;
230607ca46eSDavid Howells 	struct media_pad_desc sink;
231607ca46eSDavid Howells 	__u32 flags;
232607ca46eSDavid Howells 	__u32 reserved[2];
233607ca46eSDavid Howells };
234607ca46eSDavid Howells 
235607ca46eSDavid Howells struct media_links_enum {
236607ca46eSDavid Howells 	__u32 entity;
237607ca46eSDavid Howells 	/* Should have enough room for pads elements */
238607ca46eSDavid Howells 	struct media_pad_desc __user *pads;
239607ca46eSDavid Howells 	/* Should have enough room for links elements */
240607ca46eSDavid Howells 	struct media_link_desc __user *links;
241607ca46eSDavid Howells 	__u32 reserved[4];
242607ca46eSDavid Howells };
243607ca46eSDavid Howells 
244a1d2510eSMauro Carvalho Chehab /* Interface type ranges */
245a1d2510eSMauro Carvalho Chehab 
246a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_DVB_BASE			0x00000100
247a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_V4L_BASE			0x00000200
248a1d2510eSMauro Carvalho Chehab 
249a1d2510eSMauro Carvalho Chehab /* Interface types */
250a1d2510eSMauro Carvalho Chehab 
251a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_DVB_FE			(MEDIA_INTF_T_DVB_BASE)
252a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_DVB_DEMUX			(MEDIA_INTF_T_DVB_BASE + 1)
253a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_DVB_DVR			(MEDIA_INTF_T_DVB_BASE + 2)
254a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_DVB_CA			(MEDIA_INTF_T_DVB_BASE + 3)
255a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_DVB_NET			(MEDIA_INTF_T_DVB_BASE + 4)
256a1d2510eSMauro Carvalho Chehab 
257a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_V4L_VIDEO			(MEDIA_INTF_T_V4L_BASE)
258a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_V4L_VBI			(MEDIA_INTF_T_V4L_BASE + 1)
259a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_V4L_RADIO			(MEDIA_INTF_T_V4L_BASE + 2)
260a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_V4L_SUBDEV			(MEDIA_INTF_T_V4L_BASE + 3)
261a1d2510eSMauro Carvalho Chehab #define MEDIA_INTF_T_V4L_SWRADIO		(MEDIA_INTF_T_V4L_BASE + 4)
262b2fe22d0SNick Dyer #define MEDIA_INTF_T_V4L_TOUCH			(MEDIA_INTF_T_V4L_BASE + 5)
263a1d2510eSMauro Carvalho Chehab 
264e377d3e9SShuah Khan #define MEDIA_INTF_T_ALSA_BASE			0x00000300
265e377d3e9SShuah Khan #define MEDIA_INTF_T_ALSA_PCM_CAPTURE		(MEDIA_INTF_T_ALSA_BASE)
266e377d3e9SShuah Khan #define MEDIA_INTF_T_ALSA_PCM_PLAYBACK		(MEDIA_INTF_T_ALSA_BASE + 1)
267e377d3e9SShuah Khan #define MEDIA_INTF_T_ALSA_CONTROL		(MEDIA_INTF_T_ALSA_BASE + 2)
268e377d3e9SShuah Khan 
269ed3056f0SHans Verkuil #if defined(__KERNEL__)
270ed3056f0SHans Verkuil 
271ed3056f0SHans Verkuil /*
272ed3056f0SHans Verkuil  * Connector functions
273ed3056f0SHans Verkuil  *
274ed3056f0SHans Verkuil  * For now these should not be used in userspace, as some definitions may
275ed3056f0SHans Verkuil  * change.
276ed3056f0SHans Verkuil  *
277ed3056f0SHans Verkuil  * It is the responsibility of the entity drivers to add connectors and links.
278ed3056f0SHans Verkuil  */
279ed3056f0SHans Verkuil #define MEDIA_ENT_F_CONN_RF			(MEDIA_ENT_F_BASE + 0x30001)
280ed3056f0SHans Verkuil #define MEDIA_ENT_F_CONN_SVIDEO			(MEDIA_ENT_F_BASE + 0x30002)
281ed3056f0SHans Verkuil #define MEDIA_ENT_F_CONN_COMPOSITE		(MEDIA_ENT_F_BASE + 0x30003)
282ed3056f0SHans Verkuil 
283ed3056f0SHans Verkuil #endif
2845af557a6SShuah Khan 
285c398bb64SMauro Carvalho Chehab /*
286c398bb64SMauro Carvalho Chehab  * MC next gen API definitions
287c398bb64SMauro Carvalho Chehab  */
288c398bb64SMauro Carvalho Chehab 
289588f4ee7SHans Verkuil /*
290588f4ee7SHans Verkuil  * Appeared in 4.19.0.
291588f4ee7SHans Verkuil  *
292588f4ee7SHans Verkuil  * The media_version argument comes from the media_version field in
293588f4ee7SHans Verkuil  * struct media_device_info.
294588f4ee7SHans Verkuil  */
295588f4ee7SHans Verkuil #define MEDIA_V2_ENTITY_HAS_FLAGS(media_version) \
296*98b95642SSakari Ailus 	((media_version) >= ((4U << 16) | (19U << 8) | 0U))
297588f4ee7SHans Verkuil 
298c398bb64SMauro Carvalho Chehab struct media_v2_entity {
299c398bb64SMauro Carvalho Chehab 	__u32 id;
300ed3056f0SHans Verkuil 	char name[64];
301d87cdb88SMauro Carvalho Chehab 	__u32 function;		/* Main function of the entity */
302588f4ee7SHans Verkuil 	__u32 flags;
303588f4ee7SHans Verkuil 	__u32 reserved[5];
304fbe093acSSakari Ailus } __attribute__ ((packed));
305c398bb64SMauro Carvalho Chehab 
306c398bb64SMauro Carvalho Chehab /* Should match the specific fields at media_intf_devnode */
307c398bb64SMauro Carvalho Chehab struct media_v2_intf_devnode {
308c398bb64SMauro Carvalho Chehab 	__u32 major;
309c398bb64SMauro Carvalho Chehab 	__u32 minor;
310fbe093acSSakari Ailus } __attribute__ ((packed));
311c398bb64SMauro Carvalho Chehab 
312c398bb64SMauro Carvalho Chehab struct media_v2_interface {
313c398bb64SMauro Carvalho Chehab 	__u32 id;
314c398bb64SMauro Carvalho Chehab 	__u32 intf_type;
315c398bb64SMauro Carvalho Chehab 	__u32 flags;
316c398bb64SMauro Carvalho Chehab 	__u32 reserved[9];
317c398bb64SMauro Carvalho Chehab 
318c398bb64SMauro Carvalho Chehab 	union {
319c398bb64SMauro Carvalho Chehab 		struct media_v2_intf_devnode devnode;
320c398bb64SMauro Carvalho Chehab 		__u32 raw[16];
321c398bb64SMauro Carvalho Chehab 	};
322fbe093acSSakari Ailus } __attribute__ ((packed));
323c398bb64SMauro Carvalho Chehab 
32430b914c8SHans Verkuil /*
32530b914c8SHans Verkuil  * Appeared in 4.19.0.
32630b914c8SHans Verkuil  *
32730b914c8SHans Verkuil  * The media_version argument comes from the media_version field in
32830b914c8SHans Verkuil  * struct media_device_info.
32930b914c8SHans Verkuil  */
33030b914c8SHans Verkuil #define MEDIA_V2_PAD_HAS_INDEX(media_version) \
331*98b95642SSakari Ailus 	((media_version) >= ((4U << 16) | (19U << 8) | 0U))
33230b914c8SHans Verkuil 
333c398bb64SMauro Carvalho Chehab struct media_v2_pad {
334c398bb64SMauro Carvalho Chehab 	__u32 id;
335c398bb64SMauro Carvalho Chehab 	__u32 entity_id;
336c398bb64SMauro Carvalho Chehab 	__u32 flags;
33730b914c8SHans Verkuil 	__u32 index;
33830b914c8SHans Verkuil 	__u32 reserved[4];
339fbe093acSSakari Ailus } __attribute__ ((packed));
340c398bb64SMauro Carvalho Chehab 
341c398bb64SMauro Carvalho Chehab struct media_v2_link {
342c398bb64SMauro Carvalho Chehab 	__u32 id;
343c398bb64SMauro Carvalho Chehab 	__u32 source_id;
344c398bb64SMauro Carvalho Chehab 	__u32 sink_id;
345c398bb64SMauro Carvalho Chehab 	__u32 flags;
346fbe093acSSakari Ailus 	__u32 reserved[6];
347fbe093acSSakari Ailus } __attribute__ ((packed));
348c398bb64SMauro Carvalho Chehab 
349c398bb64SMauro Carvalho Chehab struct media_v2_topology {
350b3b7a9f1SMauro Carvalho Chehab 	__u64 topology_version;
351c398bb64SMauro Carvalho Chehab 
3527c9d6731SMauro Carvalho Chehab 	__u32 num_entities;
3537c9d6731SMauro Carvalho Chehab 	__u32 reserved1;
354b3b7a9f1SMauro Carvalho Chehab 	__u64 ptr_entities;
355c398bb64SMauro Carvalho Chehab 
3567c9d6731SMauro Carvalho Chehab 	__u32 num_interfaces;
3577c9d6731SMauro Carvalho Chehab 	__u32 reserved2;
358b3b7a9f1SMauro Carvalho Chehab 	__u64 ptr_interfaces;
359c398bb64SMauro Carvalho Chehab 
3607c9d6731SMauro Carvalho Chehab 	__u32 num_pads;
3617c9d6731SMauro Carvalho Chehab 	__u32 reserved3;
362b3b7a9f1SMauro Carvalho Chehab 	__u64 ptr_pads;
363c398bb64SMauro Carvalho Chehab 
3647c9d6731SMauro Carvalho Chehab 	__u32 num_links;
3657c9d6731SMauro Carvalho Chehab 	__u32 reserved4;
366b3b7a9f1SMauro Carvalho Chehab 	__u64 ptr_links;
367fbe093acSSakari Ailus } __attribute__ ((packed));
368c398bb64SMauro Carvalho Chehab 
369c398bb64SMauro Carvalho Chehab /* ioctls */
370a1d2510eSMauro Carvalho Chehab 
371607ca46eSDavid Howells #define MEDIA_IOC_DEVICE_INFO	_IOWR('|', 0x00, struct media_device_info)
372607ca46eSDavid Howells #define MEDIA_IOC_ENUM_ENTITIES	_IOWR('|', 0x01, struct media_entity_desc)
373607ca46eSDavid Howells #define MEDIA_IOC_ENUM_LINKS	_IOWR('|', 0x02, struct media_links_enum)
374607ca46eSDavid Howells #define MEDIA_IOC_SETUP_LINK	_IOWR('|', 0x03, struct media_link_desc)
375c398bb64SMauro Carvalho Chehab #define MEDIA_IOC_G_TOPOLOGY	_IOWR('|', 0x04, struct media_v2_topology)
37666431c0bSHans Verkuil #define MEDIA_IOC_REQUEST_ALLOC	_IOR ('|', 0x05, int)
37766431c0bSHans Verkuil 
37866431c0bSHans Verkuil /*
37966431c0bSHans Verkuil  * These ioctls are called on the request file descriptor as returned
38066431c0bSHans Verkuil  * by MEDIA_IOC_REQUEST_ALLOC.
38166431c0bSHans Verkuil  */
38266431c0bSHans Verkuil #define MEDIA_REQUEST_IOC_QUEUE		_IO('|',  0x80)
38366431c0bSHans Verkuil #define MEDIA_REQUEST_IOC_REINIT	_IO('|',  0x81)
384607ca46eSDavid Howells 
385e1a98c16SHans Verkuil #ifndef __KERNEL__
386ed3056f0SHans Verkuil 
387ed3056f0SHans Verkuil /*
388ed3056f0SHans Verkuil  * Legacy symbols used to avoid userspace compilation breakages.
389ed3056f0SHans Verkuil  * Do not use any of this in new applications!
390ed3056f0SHans Verkuil  *
391ed3056f0SHans Verkuil  * Those symbols map the entity function into types and should be
392ed3056f0SHans Verkuil  * used only on legacy programs for legacy hardware. Don't rely
393ed3056f0SHans Verkuil  * on those for MEDIA_IOC_G_TOPOLOGY.
394ed3056f0SHans Verkuil  */
395ed3056f0SHans Verkuil #define MEDIA_ENT_TYPE_SHIFT			16
396ed3056f0SHans Verkuil #define MEDIA_ENT_TYPE_MASK			0x00ff0000
397ed3056f0SHans Verkuil #define MEDIA_ENT_SUBTYPE_MASK			0x0000ffff
398ed3056f0SHans Verkuil 
399ed3056f0SHans Verkuil #define MEDIA_ENT_T_DEVNODE_UNKNOWN		(MEDIA_ENT_F_OLD_BASE | \
400ed3056f0SHans Verkuil 						 MEDIA_ENT_SUBTYPE_MASK)
401ed3056f0SHans Verkuil 
402ed3056f0SHans Verkuil #define MEDIA_ENT_T_DEVNODE			MEDIA_ENT_F_OLD_BASE
403ed3056f0SHans Verkuil #define MEDIA_ENT_T_DEVNODE_V4L			MEDIA_ENT_F_IO_V4L
404ed3056f0SHans Verkuil #define MEDIA_ENT_T_DEVNODE_FB			(MEDIA_ENT_F_OLD_BASE + 2)
405ed3056f0SHans Verkuil #define MEDIA_ENT_T_DEVNODE_ALSA		(MEDIA_ENT_F_OLD_BASE + 3)
406ed3056f0SHans Verkuil #define MEDIA_ENT_T_DEVNODE_DVB			(MEDIA_ENT_F_OLD_BASE + 4)
407ed3056f0SHans Verkuil 
408ed3056f0SHans Verkuil #define MEDIA_ENT_T_UNKNOWN			MEDIA_ENT_F_UNKNOWN
409ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_VIDEO			MEDIA_ENT_F_IO_V4L
410ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_SUBDEV			MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
411ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR		MEDIA_ENT_F_CAM_SENSOR
412ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH		MEDIA_ENT_F_FLASH
413ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_SUBDEV_LENS		MEDIA_ENT_F_LENS
414ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER		MEDIA_ENT_F_ATV_DECODER
415ed3056f0SHans Verkuil #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER		MEDIA_ENT_F_TUNER
416ed3056f0SHans Verkuil 
417d272bc92SHans Verkuil #define MEDIA_ENT_F_DTV_DECODER			MEDIA_ENT_F_DV_DECODER
418d272bc92SHans Verkuil 
419ed3056f0SHans Verkuil /*
420e377d3e9SShuah Khan  * There is still no full ALSA support in the media controller. These
421ed3056f0SHans Verkuil  * defines should not have been added and we leave them here only
422ed3056f0SHans Verkuil  * in case some application tries to use these defines.
423e377d3e9SShuah Khan  *
424e377d3e9SShuah Khan  * The ALSA defines that are in use have been moved into __KERNEL__
425e377d3e9SShuah Khan  * scope. As support gets added to these interface types, they should
426e377d3e9SShuah Khan  * be moved into __KERNEL__ scope with the code that uses them.
427ed3056f0SHans Verkuil  */
428ed3056f0SHans Verkuil #define MEDIA_INTF_T_ALSA_COMPRESS             (MEDIA_INTF_T_ALSA_BASE + 3)
429ed3056f0SHans Verkuil #define MEDIA_INTF_T_ALSA_RAWMIDI              (MEDIA_INTF_T_ALSA_BASE + 4)
430ed3056f0SHans Verkuil #define MEDIA_INTF_T_ALSA_HWDEP                (MEDIA_INTF_T_ALSA_BASE + 5)
431ed3056f0SHans Verkuil #define MEDIA_INTF_T_ALSA_SEQUENCER            (MEDIA_INTF_T_ALSA_BASE + 6)
432ed3056f0SHans Verkuil #define MEDIA_INTF_T_ALSA_TIMER                (MEDIA_INTF_T_ALSA_BASE + 7)
433ed3056f0SHans Verkuil 
434ed3056f0SHans Verkuil /* Obsolete symbol for media_version, no longer used in the kernel */
435*98b95642SSakari Ailus #define MEDIA_API_VERSION			((0U << 16) | (1U << 8) | 0U)
436ed3056f0SHans Verkuil 
437ed3056f0SHans Verkuil #endif
438ed3056f0SHans Verkuil 
439607ca46eSDavid Howells #endif /* __LINUX_MEDIA_H */
440