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
29 #include <linux/ioctl.h>
30 #include <linux/types.h>
31 #include <linux/version.h>
33 #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
35 struct media_device_info {
46 #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
49 * Initial value to be used when a new entity is created
50 * Drivers should change it to something useful
52 #define MEDIA_ENT_F_UNKNOWN 0x00000000
55 * Base number ranges for entity functions
57 * NOTE: those ranges and entity function number are phased just to
58 * make it easier to maintain this file. Userspace should not rely on
59 * the ranges to identify a group of function types, as newer
60 * functions can be added with any name within the full u32 range.
62 #define MEDIA_ENT_F_BASE 0x00000000
63 #define MEDIA_ENT_F_OLD_BASE 0x00010000
64 #define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000
69 #define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 1)
70 #define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 2)
71 #define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 3)
72 #define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 4)
77 /* It is a responsibility of the entity drivers to add connectors and links */
78 #define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 21)
79 #define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 22)
80 #define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 23)
81 /* For internal test signal generators and other debug connectors */
82 #define MEDIA_ENT_F_CONN_TEST (MEDIA_ENT_F_BASE + 24)
87 #define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 31)
88 #define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 32)
89 #define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33)
92 * Analog TV IF-PLL decoders
94 * It is a responsibility of the master/bridge drivers to create links
95 * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
97 #define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 41)
98 #define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 42)
101 * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and
102 * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility
103 * with the legacy v1 API.The number range is out of range by purpose:
104 * several previously reserved numbers got excluded from this range.
106 * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
107 * in order to preserve backward compatibility.
108 * Drivers must change to the proper subdev type before
109 * registering the entity.
112 #define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
114 #define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
115 #define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
116 #define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
117 #define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
119 * It is a responsibility of the master/bridge drivers to add connectors
120 * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
121 * may require the usage of separate I2C chips to decode analog TV signals,
122 * when the master/bridge chipset doesn't have its own TV standard decoder.
123 * On such cases, the IF-PLL staging is mapped via one or two entities:
124 * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
126 #define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
128 #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
133 * Legacy symbols used to avoid userspace compilation breakages
135 * Those symbols map the entity function into types and should be
136 * used only on legacy programs for legacy hardware. Don't rely
137 * on those for MEDIA_IOC_G_TOPOLOGY.
139 #define MEDIA_ENT_TYPE_SHIFT 16
140 #define MEDIA_ENT_TYPE_MASK 0x00ff0000
141 #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
143 #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
144 #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
145 #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
146 #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
147 #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
149 #define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
150 #define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
151 #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
152 #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
153 #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
154 #define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
155 #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
156 #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
160 #define MEDIA_ENT_FL_DEFAULT (1 << 0)
161 #define MEDIA_ENT_FL_CONNECTOR (1 << 1)
163 struct media_entity_desc {
176 /* Node specifications */
184 * TODO: this shouldn't have been added without
185 * actual drivers that use this. When the first real driver
186 * appears that sets this information, special attention
187 * should be given whether this information is 1) enough, and
188 * 2) can deal with udev rules that rename devices. The struct
189 * dev would not be sufficient for this since that does not
190 * contain the subdevice information. In addition, struct dev
191 * can only refer to a single device, and not to multiple (e.g.
192 * pcm and mixer devices).
194 * So for now mark this as a to do.
205 * DEPRECATED: previous node specifications. Kept just to
206 * avoid breaking compilation, but media_entity_desc.dev
207 * should be used instead. In particular, alsa and dvb
208 * fields below are wrong: for all devnodes, there should
209 * be just major/minor inside the struct, as this is enough
210 * to represent any devnode, no matter what type.
223 /* Sub-device specifications */
224 /* Nothing needed yet */
229 #define MEDIA_PAD_FL_SINK (1 << 0)
230 #define MEDIA_PAD_FL_SOURCE (1 << 1)
231 #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
233 struct media_pad_desc {
234 __u32 entity; /* entity ID */
235 __u16 index; /* pad index */
236 __u32 flags; /* pad flags */
240 #define MEDIA_LNK_FL_ENABLED (1 << 0)
241 #define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
242 #define MEDIA_LNK_FL_DYNAMIC (1 << 2)
244 #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
245 # define MEDIA_LNK_FL_DATA_LINK (0 << 28)
246 # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28)
248 struct media_link_desc {
249 struct media_pad_desc source;
250 struct media_pad_desc sink;
255 struct media_links_enum {
257 /* Should have enough room for pads elements */
258 struct media_pad_desc __user *pads;
259 /* Should have enough room for links elements */
260 struct media_link_desc __user *links;
264 /* Interface type ranges */
266 #define MEDIA_INTF_T_DVB_BASE 0x00000100
267 #define MEDIA_INTF_T_V4L_BASE 0x00000200
269 /* Interface types */
271 #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
272 #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
273 #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
274 #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
275 #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
277 #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
278 #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
279 #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
280 #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
281 #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
284 * MC next gen API definitions
286 * NOTE: The declarations below are close to the MC RFC for the Media
287 * Controller, the next generation. Yet, there are a few adjustments
288 * to do, as we want to be able to have a functional API before
289 * the MC properties change. Those will be properly marked below.
290 * Please also notice that I removed "num_pads", "num_links",
291 * from the proposal, as a proper userspace application will likely
292 * use lists for pads/links, just as we intend to do in Kernelspace.
293 * The API definition should be freed from fields that are bound to
294 * some specific data structure.
296 * FIXME: Currently, I opted to name the new types as "media_v2", as this
297 * won't cause any conflict with the Kernelspace namespace, nor with
298 * the previous kAPI media_*_desc namespace. This can be changed
299 * later, before the adding this API upstream.
303 struct media_v2_entity {
305 char name[64]; /* FIXME: move to a property? (RFC says so) */
306 __u32 function; /* Main function of the entity */
310 /* Should match the specific fields at media_intf_devnode */
311 struct media_v2_intf_devnode {
316 struct media_v2_interface {
323 struct media_v2_intf_devnode devnode;
328 struct media_v2_pad {
335 struct media_v2_link {
343 struct media_v2_topology {
344 __u64 topology_version;
350 __u32 num_interfaces;
352 __u64 ptr_interfaces;
363 static inline void __user *media_get_uptr(__u64 arg)
365 return (void __user *)(uintptr_t)arg;
370 #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
371 #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
372 #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
373 #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
374 #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
376 #endif /* __LINUX_MEDIA_H */