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
66 * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
67 * read()/write() data I/O associated with the V4L2 devnodes.
69 #define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1)
71 * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
72 * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
73 * to be declared for FB, ALSA and DVB entities.
74 * As those values were never actually used in practice, we're just
75 * adding them as backward compatibility macros and keeping the
76 * numberspace clean here. This way, we avoid breaking compilation,
77 * in the case of having some userspace application using the old
80 #define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5)
81 #define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 6)
83 /* V4L2 Sub-device entities */
86 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
87 * in order to preserve backward compatibility.
88 * Drivers should change to the proper subdev type before
89 * registering the entity.
91 #define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE
93 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
94 #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
95 #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
96 /* A converter of analogue video to its digital representation. */
97 #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
98 /* Tuner entity is actually both V4L2 and DVB subdev */
99 #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
102 #define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 1)
103 #define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 2)
104 #define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 3)
105 #define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 4)
106 #define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 5)
109 /* Legacy symbols used to avoid userspace compilation breakages */
110 #define MEDIA_ENT_TYPE_SHIFT 16
111 #define MEDIA_ENT_TYPE_MASK 0x00ff0000
112 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
114 #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE
115 #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE
117 #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO
119 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
120 #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
121 #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
126 #define MEDIA_ENT_FL_DEFAULT (1 << 0)
128 struct media_entity_desc
{
141 /* Node specifications */
149 * TODO: this shouldn't have been added without
150 * actual drivers that use this. When the first real driver
151 * appears that sets this information, special attention
152 * should be given whether this information is 1) enough, and
153 * 2) can deal with udev rules that rename devices. The struct
154 * dev would not be sufficient for this since that does not
155 * contain the subdevice information. In addition, struct dev
156 * can only refer to a single device, and not to multiple (e.g.
157 * pcm and mixer devices).
159 * So for now mark this as a to do.
170 * DEPRECATED: previous node specifications. Kept just to
171 * avoid breaking compilation, but media_entity_desc.dev
172 * should be used instead. In particular, alsa and dvb
173 * fields below are wrong: for all devnodes, there should
174 * be just major/minor inside the struct, as this is enough
175 * to represent any devnode, no matter what type.
188 /* Sub-device specifications */
189 /* Nothing needed yet */
194 #define MEDIA_PAD_FL_SINK (1 << 0)
195 #define MEDIA_PAD_FL_SOURCE (1 << 1)
196 #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
198 struct media_pad_desc
{
199 __u32 entity
; /* entity ID */
200 __u16 index
; /* pad index */
201 __u32 flags
; /* pad flags */
205 #define MEDIA_LNK_FL_ENABLED (1 << 0)
206 #define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
207 #define MEDIA_LNK_FL_DYNAMIC (1 << 2)
209 #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
210 # define MEDIA_LNK_FL_DATA_LINK (0 << 28)
211 # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
213 struct media_link_desc
{
214 struct media_pad_desc source
;
215 struct media_pad_desc sink
;
220 struct media_links_enum
{
222 /* Should have enough room for pads elements */
223 struct media_pad_desc __user
*pads
;
224 /* Should have enough room for links elements */
225 struct media_link_desc __user
*links
;
229 /* Interface type ranges */
231 #define MEDIA_INTF_T_DVB_BASE 0x00000100
232 #define MEDIA_INTF_T_V4L_BASE 0x00000200
234 /* Interface types */
236 #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
237 #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
238 #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
239 #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
240 #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
242 #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
243 #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
244 #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
245 #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
246 #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
249 * MC next gen API definitions
251 * NOTE: The declarations below are close to the MC RFC for the Media
252 * Controller, the next generation. Yet, there are a few adjustments
253 * to do, as we want to be able to have a functional API before
254 * the MC properties change. Those will be properly marked below.
255 * Please also notice that I removed "num_pads", "num_links",
256 * from the proposal, as a proper userspace application will likely
257 * use lists for pads/links, just as we intend to do in Kernelspace.
258 * The API definition should be freed from fields that are bound to
259 * some specific data structure.
261 * FIXME: Currently, I opted to name the new types as "media_v2", as this
262 * won't cause any conflict with the Kernelspace namespace, nor with
263 * the previous kAPI media_*_desc namespace. This can be changed
264 * later, before the adding this API upstream.
268 struct media_v2_entity
{
270 char name
[64]; /* FIXME: move to a property? (RFC says so) */
274 /* Should match the specific fields at media_intf_devnode */
275 struct media_v2_intf_devnode
{
280 struct media_v2_interface
{
287 struct media_v2_intf_devnode devnode
;
292 struct media_v2_pad
{
299 struct media_v2_link
{
307 struct media_v2_topology
{
308 __u32 topology_version
;
311 struct media_v2_entity
*entities
;
313 __u32 num_interfaces
;
314 struct media_v2_interface
*interfaces
;
317 struct media_v2_pad
*pads
;
320 struct media_v2_link
*links
;
325 } reserved_types
[16];
331 #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
332 #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
333 #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
334 #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
335 #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
337 #endif /* __LINUX_MEDIA_H */