2 * Multimedia device API
4 * Copyright (C) 2010 Nokia Corporation
6 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
7 * Sakari Ailus <sakari.ailus@iki.fi>
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.
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.
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
23 #ifndef __LINUX_MEDIA_H
24 #define __LINUX_MEDIA_H
26 #include <linux/ioctl.h>
27 #include <linux/types.h>
28 #include <linux/version.h>
30 #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
32 struct media_device_info
{
43 #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
46 * Initial value to be used when a new entity is created
47 * Drivers should change it to something useful
49 #define MEDIA_ENT_T_UNKNOWN 0x00000000
52 * Base numbers for entity types
54 * Please notice that the huge gap of 16 bits for each base is overkill!
55 * 8 bits is more than enough to avoid starving entity types for each
58 * However, It is kept this way just to avoid binary breakages with the
59 * namespace provided on legacy versions of this header.
61 #define MEDIA_ENT_T_DVB_BASE 0x00000000
62 #define MEDIA_ENT_T_V4L2_BASE 0x00010000
63 #define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000
64 #define MEDIA_ENT_T_CONNECTOR_BASE 0x00030000
67 * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
68 * read()/write() data I/O associated with the V4L2 devnodes.
70 #define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1)
72 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
73 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
74 * to be declared for FB, ALSA and DVB entities.
75 * As those values were never actually used in practice, we're just
76 * adding them as backward compatibility macros and keeping the
77 * numberspace clean here. This way, we avoid breaking compilation,
78 * in the case of having some userspace application using the old
81 #define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5)
82 #define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 6)
84 /* V4L2 Sub-device entities */
87 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
88 * in order to preserve backward compatibility.
89 * Drivers should change to the proper subdev type before
90 * registering the entity.
92 #define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE
94 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
95 #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
96 #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
97 /* A converter of analogue video to its digital representation. */
98 #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
99 /* Tuner entity is actually both V4L2 and DVB subdev */
100 #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
103 #define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 1)
104 #define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 2)
105 #define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 3)
106 #define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 4)
107 #define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 5)
110 #define MEDIA_ENT_T_CONN_RF (MEDIA_ENT_T_CONNECTOR_BASE + 1)
111 #define MEDIA_ENT_T_CONN_SVIDEO (MEDIA_ENT_T_CONNECTOR_BASE + 2)
112 #define MEDIA_ENT_T_CONN_COMPOSITE (MEDIA_ENT_T_CONNECTOR_BASE + 3)
113 /* For internal test signal generators and other debug connectors */
114 #define MEDIA_ENT_T_CONN_TEST (MEDIA_ENT_T_CONNECTOR_BASE + 4)
117 /* Legacy symbols used to avoid userspace compilation breakages */
118 #define MEDIA_ENT_TYPE_SHIFT 16
119 #define MEDIA_ENT_TYPE_MASK 0x00ff0000
120 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
122 #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE
123 #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE
125 #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO
127 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
128 #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
129 #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
133 #define MEDIA_ENT_FL_DEFAULT (1 << 0)
134 #define MEDIA_ENT_FL_CONNECTOR (1 << 1)
136 struct media_entity_desc
{
149 /* Node specifications */
157 * TODO: this shouldn't have been added without
158 * actual drivers that use this. When the first real driver
159 * appears that sets this information, special attention
160 * should be given whether this information is 1) enough, and
161 * 2) can deal with udev rules that rename devices. The struct
162 * dev would not be sufficient for this since that does not
163 * contain the subdevice information. In addition, struct dev
164 * can only refer to a single device, and not to multiple (e.g.
165 * pcm and mixer devices).
167 * So for now mark this as a to do.
178 * DEPRECATED: previous node specifications. Kept just to
179 * avoid breaking compilation, but media_entity_desc.dev
180 * should be used instead. In particular, alsa and dvb
181 * fields below are wrong: for all devnodes, there should
182 * be just major/minor inside the struct, as this is enough
183 * to represent any devnode, no matter what type.
196 /* Sub-device specifications */
197 /* Nothing needed yet */
202 #define MEDIA_PAD_FL_SINK (1 << 0)
203 #define MEDIA_PAD_FL_SOURCE (1 << 1)
204 #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
206 struct media_pad_desc
{
207 __u32 entity
; /* entity ID */
208 __u16 index
; /* pad index */
209 __u32 flags
; /* pad flags */
213 #define MEDIA_LNK_FL_ENABLED (1 << 0)
214 #define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
215 #define MEDIA_LNK_FL_DYNAMIC (1 << 2)
217 #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
218 # define MEDIA_LNK_FL_DATA_LINK (0 << 28)
219 # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
221 struct media_link_desc
{
222 struct media_pad_desc source
;
223 struct media_pad_desc sink
;
228 struct media_links_enum
{
230 /* Should have enough room for pads elements */
231 struct media_pad_desc __user
*pads
;
232 /* Should have enough room for links elements */
233 struct media_link_desc __user
*links
;
237 /* Interface type ranges */
239 #define MEDIA_INTF_T_DVB_BASE 0x00000100
240 #define MEDIA_INTF_T_V4L_BASE 0x00000200
242 /* Interface types */
244 #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
245 #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
246 #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
247 #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
248 #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
250 #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
251 #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
252 #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
253 #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
254 #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
257 * MC next gen API definitions
259 * NOTE: The declarations below are close to the MC RFC for the Media
260 * Controller, the next generation. Yet, there are a few adjustments
261 * to do, as we want to be able to have a functional API before
262 * the MC properties change. Those will be properly marked below.
263 * Please also notice that I removed "num_pads", "num_links",
264 * from the proposal, as a proper userspace application will likely
265 * use lists for pads/links, just as we intend to do in Kernelspace.
266 * The API definition should be freed from fields that are bound to
267 * some specific data structure.
269 * FIXME: Currently, I opted to name the new types as "media_v2", as this
270 * won't cause any conflict with the Kernelspace namespace, nor with
271 * the previous kAPI media_*_desc namespace. This can be changed
272 * later, before the adding this API upstream.
276 struct media_v2_entity
{
278 char name
[64]; /* FIXME: move to a property? (RFC says so) */
279 __u32 function
; /* Main function of the entity */
283 /* Should match the specific fields at media_intf_devnode */
284 struct media_v2_intf_devnode
{
289 struct media_v2_interface
{
296 struct media_v2_intf_devnode devnode
;
301 struct media_v2_pad
{
308 struct media_v2_link
{
316 struct media_v2_topology
{
317 __u32 topology_version
;
320 struct media_v2_entity
*entities
;
322 __u32 num_interfaces
;
323 struct media_v2_interface
*interfaces
;
326 struct media_v2_pad
*pads
;
329 struct media_v2_link
*links
;
334 } reserved_types
[16];
340 #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
341 #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
342 #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
343 #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
344 #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
346 #endif /* __LINUX_MEDIA_H */