xref: /linux/include/uapi/linux/media.h (revision 1d20f9f6330c988505e51f5010656978fd70cd0c)
1607ca46eSDavid Howells /*
2607ca46eSDavid Howells  * Multimedia device API
3607ca46eSDavid Howells  *
4607ca46eSDavid Howells  * Copyright (C) 2010 Nokia Corporation
5607ca46eSDavid Howells  *
6607ca46eSDavid Howells  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7607ca46eSDavid Howells  *	     Sakari Ailus <sakari.ailus@iki.fi>
8607ca46eSDavid Howells  *
9607ca46eSDavid Howells  * This program is free software; you can redistribute it and/or modify
10607ca46eSDavid Howells  * it under the terms of the GNU General Public License version 2 as
11607ca46eSDavid Howells  * published by the Free Software Foundation.
12607ca46eSDavid Howells  *
13607ca46eSDavid Howells  * This program is distributed in the hope that it will be useful,
14607ca46eSDavid Howells  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15607ca46eSDavid Howells  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16607ca46eSDavid Howells  * GNU General Public License for more details.
17607ca46eSDavid Howells  *
18607ca46eSDavid Howells  * You should have received a copy of the GNU General Public License
19607ca46eSDavid Howells  * along with this program; if not, write to the Free Software
20607ca46eSDavid Howells  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21607ca46eSDavid Howells  */
22607ca46eSDavid Howells 
23607ca46eSDavid Howells #ifndef __LINUX_MEDIA_H
24607ca46eSDavid Howells #define __LINUX_MEDIA_H
25607ca46eSDavid Howells 
26607ca46eSDavid Howells #include <linux/ioctl.h>
27607ca46eSDavid Howells #include <linux/types.h>
28607ca46eSDavid Howells #include <linux/version.h>
29607ca46eSDavid Howells 
30607ca46eSDavid Howells #define MEDIA_API_VERSION	KERNEL_VERSION(0, 1, 0)
31607ca46eSDavid Howells 
32607ca46eSDavid Howells struct media_device_info {
33607ca46eSDavid Howells 	char driver[16];
34607ca46eSDavid Howells 	char model[32];
35607ca46eSDavid Howells 	char serial[40];
36607ca46eSDavid Howells 	char bus_info[32];
37607ca46eSDavid Howells 	__u32 media_version;
38607ca46eSDavid Howells 	__u32 hw_revision;
39607ca46eSDavid Howells 	__u32 driver_version;
40607ca46eSDavid Howells 	__u32 reserved[31];
41607ca46eSDavid Howells };
42607ca46eSDavid Howells 
43607ca46eSDavid Howells #define MEDIA_ENT_ID_FLAG_NEXT		(1 << 31)
44607ca46eSDavid Howells 
45607ca46eSDavid Howells #define MEDIA_ENT_TYPE_SHIFT		16
46607ca46eSDavid Howells #define MEDIA_ENT_TYPE_MASK		0x00ff0000
47607ca46eSDavid Howells #define MEDIA_ENT_SUBTYPE_MASK		0x0000ffff
48607ca46eSDavid Howells 
49607ca46eSDavid Howells #define MEDIA_ENT_T_DEVNODE		(1 << MEDIA_ENT_TYPE_SHIFT)
50607ca46eSDavid Howells #define MEDIA_ENT_T_DEVNODE_V4L		(MEDIA_ENT_T_DEVNODE + 1)
51607ca46eSDavid Howells #define MEDIA_ENT_T_DEVNODE_FB		(MEDIA_ENT_T_DEVNODE + 2)
52607ca46eSDavid Howells #define MEDIA_ENT_T_DEVNODE_ALSA	(MEDIA_ENT_T_DEVNODE + 3)
53*1d20f9f6SMauro Carvalho Chehab #define MEDIA_ENT_T_DEVNODE_DVB_FE	(MEDIA_ENT_T_DEVNODE + 4)
54*1d20f9f6SMauro Carvalho Chehab #define MEDIA_ENT_T_DEVNODE_DVB_DEMUX	(MEDIA_ENT_T_DEVNODE + 5)
55*1d20f9f6SMauro Carvalho Chehab #define MEDIA_ENT_T_DEVNODE_DVB_DVR	(MEDIA_ENT_T_DEVNODE + 6)
56*1d20f9f6SMauro Carvalho Chehab #define MEDIA_ENT_T_DEVNODE_DVB_CA	(MEDIA_ENT_T_DEVNODE + 7)
57*1d20f9f6SMauro Carvalho Chehab #define MEDIA_ENT_T_DEVNODE_DVB_NET	(MEDIA_ENT_T_DEVNODE + 8)
58*1d20f9f6SMauro Carvalho Chehab 
59*1d20f9f6SMauro Carvalho Chehab /* Legacy symbol. Use it to avoid userspace compilation breakages */
60*1d20f9f6SMauro Carvalho Chehab #define MEDIA_ENT_T_DEVNODE_DVB		MEDIA_ENT_T_DEVNODE_DVB_FE
61607ca46eSDavid Howells 
62607ca46eSDavid Howells #define MEDIA_ENT_T_V4L2_SUBDEV		(2 << MEDIA_ENT_TYPE_SHIFT)
63607ca46eSDavid Howells #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR	(MEDIA_ENT_T_V4L2_SUBDEV + 1)
64607ca46eSDavid Howells #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH	(MEDIA_ENT_T_V4L2_SUBDEV + 2)
65607ca46eSDavid Howells #define MEDIA_ENT_T_V4L2_SUBDEV_LENS	(MEDIA_ENT_T_V4L2_SUBDEV + 3)
66e64171b9SManjunath Hadli /* A converter of analogue video to its digital representation. */
67e64171b9SManjunath Hadli #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER	(MEDIA_ENT_T_V4L2_SUBDEV + 4)
68607ca46eSDavid Howells 
69607ca46eSDavid Howells #define MEDIA_ENT_FL_DEFAULT		(1 << 0)
70607ca46eSDavid Howells 
71607ca46eSDavid Howells struct media_entity_desc {
72607ca46eSDavid Howells 	__u32 id;
73607ca46eSDavid Howells 	char name[32];
74607ca46eSDavid Howells 	__u32 type;
75607ca46eSDavid Howells 	__u32 revision;
76607ca46eSDavid Howells 	__u32 flags;
77607ca46eSDavid Howells 	__u32 group_id;
78607ca46eSDavid Howells 	__u16 pads;
79607ca46eSDavid Howells 	__u16 links;
80607ca46eSDavid Howells 
81607ca46eSDavid Howells 	__u32 reserved[4];
82607ca46eSDavid Howells 
83607ca46eSDavid Howells 	union {
84607ca46eSDavid Howells 		/* Node specifications */
85607ca46eSDavid Howells 		struct {
86607ca46eSDavid Howells 			__u32 major;
87607ca46eSDavid Howells 			__u32 minor;
88e31a0ba7SMauro Carvalho Chehab 		} dev;
89e31a0ba7SMauro Carvalho Chehab 
90e31a0ba7SMauro Carvalho Chehab #if 1
91e31a0ba7SMauro Carvalho Chehab 		/*
92e31a0ba7SMauro Carvalho Chehab 		 * DEPRECATED: previous node specifications. Kept just to
93e31a0ba7SMauro Carvalho Chehab 		 * avoid breaking compilation, but media_entity_desc.dev
94e31a0ba7SMauro Carvalho Chehab 		 * should be used instead. In particular, alsa and dvb
95e31a0ba7SMauro Carvalho Chehab 		 * fields below are wrong: for all devnodes, there should
96e31a0ba7SMauro Carvalho Chehab 		 * be just major/minor inside the struct, as this is enough
97e31a0ba7SMauro Carvalho Chehab 		 * to represent any devnode, no matter what type.
98e31a0ba7SMauro Carvalho Chehab 		 */
99e31a0ba7SMauro Carvalho Chehab 		struct {
100e31a0ba7SMauro Carvalho Chehab 			__u32 major;
101e31a0ba7SMauro Carvalho Chehab 			__u32 minor;
102607ca46eSDavid Howells 		} v4l;
103607ca46eSDavid Howells 		struct {
104607ca46eSDavid Howells 			__u32 major;
105607ca46eSDavid Howells 			__u32 minor;
106607ca46eSDavid Howells 		} fb;
107607ca46eSDavid Howells 		struct {
108607ca46eSDavid Howells 			__u32 card;
109607ca46eSDavid Howells 			__u32 device;
110607ca46eSDavid Howells 			__u32 subdevice;
111607ca46eSDavid Howells 		} alsa;
112607ca46eSDavid Howells 		int dvb;
113e31a0ba7SMauro Carvalho Chehab #endif
114607ca46eSDavid Howells 
115607ca46eSDavid Howells 		/* Sub-device specifications */
116607ca46eSDavid Howells 		/* Nothing needed yet */
117607ca46eSDavid Howells 		__u8 raw[184];
118607ca46eSDavid Howells 	};
119607ca46eSDavid Howells };
120607ca46eSDavid Howells 
121607ca46eSDavid Howells #define MEDIA_PAD_FL_SINK		(1 << 0)
122607ca46eSDavid Howells #define MEDIA_PAD_FL_SOURCE		(1 << 1)
123d0700c51SSakari Ailus #define MEDIA_PAD_FL_MUST_CONNECT	(1 << 2)
124607ca46eSDavid Howells 
125607ca46eSDavid Howells struct media_pad_desc {
126607ca46eSDavid Howells 	__u32 entity;		/* entity ID */
127607ca46eSDavid Howells 	__u16 index;		/* pad index */
128607ca46eSDavid Howells 	__u32 flags;		/* pad flags */
129607ca46eSDavid Howells 	__u32 reserved[2];
130607ca46eSDavid Howells };
131607ca46eSDavid Howells 
132607ca46eSDavid Howells #define MEDIA_LNK_FL_ENABLED		(1 << 0)
133607ca46eSDavid Howells #define MEDIA_LNK_FL_IMMUTABLE		(1 << 1)
134607ca46eSDavid Howells #define MEDIA_LNK_FL_DYNAMIC		(1 << 2)
135607ca46eSDavid Howells 
136607ca46eSDavid Howells struct media_link_desc {
137607ca46eSDavid Howells 	struct media_pad_desc source;
138607ca46eSDavid Howells 	struct media_pad_desc sink;
139607ca46eSDavid Howells 	__u32 flags;
140607ca46eSDavid Howells 	__u32 reserved[2];
141607ca46eSDavid Howells };
142607ca46eSDavid Howells 
143607ca46eSDavid Howells struct media_links_enum {
144607ca46eSDavid Howells 	__u32 entity;
145607ca46eSDavid Howells 	/* Should have enough room for pads elements */
146607ca46eSDavid Howells 	struct media_pad_desc __user *pads;
147607ca46eSDavid Howells 	/* Should have enough room for links elements */
148607ca46eSDavid Howells 	struct media_link_desc __user *links;
149607ca46eSDavid Howells 	__u32 reserved[4];
150607ca46eSDavid Howells };
151607ca46eSDavid Howells 
152607ca46eSDavid Howells #define MEDIA_IOC_DEVICE_INFO		_IOWR('|', 0x00, struct media_device_info)
153607ca46eSDavid Howells #define MEDIA_IOC_ENUM_ENTITIES		_IOWR('|', 0x01, struct media_entity_desc)
154607ca46eSDavid Howells #define MEDIA_IOC_ENUM_LINKS		_IOWR('|', 0x02, struct media_links_enum)
155607ca46eSDavid Howells #define MEDIA_IOC_SETUP_LINK		_IOWR('|', 0x03, struct media_link_desc)
156607ca46eSDavid Howells 
157607ca46eSDavid Howells #endif /* __LINUX_MEDIA_H */
158