Laurent Pinchart | 140d881 | 2010-08-18 11:41:22 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Multimedia device API |
| 3 | * |
| 4 | * Copyright (C) 2010 Nokia Corporation |
| 5 | * |
| 6 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
| 7 | * Sakari Ailus <sakari.ailus@iki.fi> |
| 8 | * |
| 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. |
| 12 | * |
| 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. |
| 17 | * |
| 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 |
| 21 | */ |
| 22 | |
| 23 | #ifndef __LINUX_MEDIA_H |
| 24 | #define __LINUX_MEDIA_H |
| 25 | |
| 26 | #include <linux/ioctl.h> |
| 27 | #include <linux/types.h> |
| 28 | #include <linux/version.h> |
| 29 | |
| 30 | #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0) |
| 31 | |
| 32 | struct media_device_info { |
| 33 | char driver[16]; |
| 34 | char model[32]; |
| 35 | char serial[40]; |
| 36 | char bus_info[32]; |
| 37 | __u32 media_version; |
| 38 | __u32 hw_revision; |
| 39 | __u32 driver_version; |
| 40 | __u32 reserved[31]; |
| 41 | }; |
| 42 | |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 43 | #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31) |
| 44 | |
Mauro Carvalho Chehab | b50bde4 | 2015-05-07 22:12:38 -0300 | [diff] [blame] | 45 | /* |
| 46 | * Initial value to be used when a new entity is created |
| 47 | * Drivers should change it to something useful |
| 48 | */ |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 49 | #define MEDIA_ENT_F_UNKNOWN 0x00000000 |
Mauro Carvalho Chehab | b50bde4 | 2015-05-07 22:12:38 -0300 | [diff] [blame] | 50 | |
Mauro Carvalho Chehab | 32fdc0e | 2015-08-21 11:40:34 -0300 | [diff] [blame] | 51 | /* |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 52 | * Base number ranges for entity functions |
Mauro Carvalho Chehab | 32fdc0e | 2015-08-21 11:40:34 -0300 | [diff] [blame] | 53 | * |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 54 | * NOTE: those ranges and entity function number are phased just to |
| 55 | * make it easier to maintain this file. Userspace should not rely on |
| 56 | * the ranges to identify a group of function types, as newer |
| 57 | * functions can be added with any name within the full u32 range. |
| 58 | */ |
| 59 | #define MEDIA_ENT_F_BASE 0x00000000 |
| 60 | #define MEDIA_ENT_F_OLD_BASE 0x00010000 |
| 61 | #define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000 |
| 62 | |
| 63 | /* |
| 64 | * DVB entities |
| 65 | */ |
| 66 | #define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 1) |
| 67 | #define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 2) |
| 68 | #define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 3) |
| 69 | #define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 4) |
| 70 | |
| 71 | /* |
| 72 | * Connectors |
| 73 | */ |
| 74 | #define MEDIA_ENT_F_CONN_RF (MEDIA_ENT_F_BASE + 21) |
| 75 | #define MEDIA_ENT_F_CONN_SVIDEO (MEDIA_ENT_F_BASE + 22) |
| 76 | #define MEDIA_ENT_F_CONN_COMPOSITE (MEDIA_ENT_F_BASE + 23) |
| 77 | /* For internal test signal generators and other debug connectors */ |
| 78 | #define MEDIA_ENT_F_CONN_TEST (MEDIA_ENT_F_BASE + 24) |
| 79 | |
| 80 | /* |
| 81 | * I/O entities |
| 82 | */ |
| 83 | #define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 31) |
| 84 | #define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 32) |
| 85 | #define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 33) |
| 86 | |
| 87 | /* |
| 88 | * Don't touch on those. The ranges MEDIA_ENT_F_OLD_BASE and |
| 89 | * MEDIA_ENT_F_OLD_SUBDEV_BASE are kept to keep backward compatibility |
| 90 | * with the legacy v1 API.The number range is out of range by purpose: |
| 91 | * several previously reserved numbers got excluded from this range. |
Mauro Carvalho Chehab | 32fdc0e | 2015-08-21 11:40:34 -0300 | [diff] [blame] | 92 | * |
Mauro Carvalho Chehab | b50bde4 | 2015-05-07 22:12:38 -0300 | [diff] [blame] | 93 | * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN, |
| 94 | * in order to preserve backward compatibility. |
| 95 | * Drivers should change to the proper subdev type before |
| 96 | * registering the entity. |
| 97 | */ |
Mauro Carvalho Chehab | fa17b46 | 2015-08-21 12:17:40 -0300 | [diff] [blame] | 98 | |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 99 | #define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1) |
Mauro Carvalho Chehab | 32fdc0e | 2015-08-21 11:40:34 -0300 | [diff] [blame] | 100 | |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 101 | #define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1) |
| 102 | #define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2) |
| 103 | #define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3) |
| 104 | #define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4) |
| 105 | #define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5) |
Mauro Carvalho Chehab | 32fdc0e | 2015-08-21 11:40:34 -0300 | [diff] [blame] | 106 | |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 107 | #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE |
Mauro Carvalho Chehab | 49a1151 | 2015-08-31 11:41:29 -0300 | [diff] [blame] | 108 | |
Mauro Carvalho Chehab | 4376679 | 2015-08-29 14:50:46 -0300 | [diff] [blame] | 109 | #ifndef __KERNEL__ |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 110 | |
| 111 | /* |
| 112 | * Legacy symbols used to avoid userspace compilation breakages |
| 113 | * |
| 114 | * Those symbols map the entity function into types and should be |
| 115 | * used only on legacy programs for legacy hardware. Don't rely |
| 116 | * on those for MEDIA_IOC_G_TOPOLOGY. |
| 117 | */ |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 118 | #define MEDIA_ENT_TYPE_SHIFT 16 |
| 119 | #define MEDIA_ENT_TYPE_MASK 0x00ff0000 |
| 120 | #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff |
| 121 | |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 122 | #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE |
| 123 | #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 124 | #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2) |
| 125 | #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3) |
Mauro Carvalho Chehab | 32fdc0e | 2015-08-21 11:40:34 -0300 | [diff] [blame] | 126 | #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4) |
Mauro Carvalho Chehab | 4ca72ef | 2015-12-10 17:25:41 -0200 | [diff] [blame] | 127 | |
| 128 | #define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN |
| 129 | #define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L |
| 130 | #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN |
| 131 | #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR |
| 132 | #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH |
| 133 | #define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS |
| 134 | #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER |
| 135 | #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER |
Mauro Carvalho Chehab | 4376679 | 2015-08-29 14:50:46 -0300 | [diff] [blame] | 136 | #endif |
Mauro Carvalho Chehab | 1d20f9f | 2015-01-03 11:09:39 -0300 | [diff] [blame] | 137 | |
Mauro Carvalho Chehab | 49a1151 | 2015-08-31 11:41:29 -0300 | [diff] [blame] | 138 | /* Entity flags */ |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 139 | #define MEDIA_ENT_FL_DEFAULT (1 << 0) |
Mauro Carvalho Chehab | 49a1151 | 2015-08-31 11:41:29 -0300 | [diff] [blame] | 140 | #define MEDIA_ENT_FL_CONNECTOR (1 << 1) |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 141 | |
| 142 | struct media_entity_desc { |
| 143 | __u32 id; |
| 144 | char name[32]; |
| 145 | __u32 type; |
| 146 | __u32 revision; |
| 147 | __u32 flags; |
| 148 | __u32 group_id; |
| 149 | __u16 pads; |
| 150 | __u16 links; |
| 151 | |
| 152 | __u32 reserved[4]; |
| 153 | |
| 154 | union { |
| 155 | /* Node specifications */ |
| 156 | struct { |
| 157 | __u32 major; |
| 158 | __u32 minor; |
Mauro Carvalho Chehab | e31a0ba | 2015-01-02 12:18:23 -0300 | [diff] [blame] | 159 | } dev; |
| 160 | |
| 161 | #if 1 |
| 162 | /* |
Hans Verkuil | 7e182f7 | 2015-02-25 12:05:13 -0300 | [diff] [blame] | 163 | * TODO: this shouldn't have been added without |
| 164 | * actual drivers that use this. When the first real driver |
| 165 | * appears that sets this information, special attention |
| 166 | * should be given whether this information is 1) enough, and |
| 167 | * 2) can deal with udev rules that rename devices. The struct |
| 168 | * dev would not be sufficient for this since that does not |
| 169 | * contain the subdevice information. In addition, struct dev |
| 170 | * can only refer to a single device, and not to multiple (e.g. |
| 171 | * pcm and mixer devices). |
| 172 | * |
| 173 | * So for now mark this as a to do. |
| 174 | */ |
| 175 | struct { |
| 176 | __u32 card; |
| 177 | __u32 device; |
| 178 | __u32 subdevice; |
| 179 | } alsa; |
| 180 | #endif |
| 181 | |
| 182 | #if 1 |
| 183 | /* |
Mauro Carvalho Chehab | e31a0ba | 2015-01-02 12:18:23 -0300 | [diff] [blame] | 184 | * DEPRECATED: previous node specifications. Kept just to |
| 185 | * avoid breaking compilation, but media_entity_desc.dev |
| 186 | * should be used instead. In particular, alsa and dvb |
| 187 | * fields below are wrong: for all devnodes, there should |
| 188 | * be just major/minor inside the struct, as this is enough |
| 189 | * to represent any devnode, no matter what type. |
| 190 | */ |
| 191 | struct { |
| 192 | __u32 major; |
| 193 | __u32 minor; |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 194 | } v4l; |
| 195 | struct { |
| 196 | __u32 major; |
| 197 | __u32 minor; |
| 198 | } fb; |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 199 | int dvb; |
Mauro Carvalho Chehab | e31a0ba | 2015-01-02 12:18:23 -0300 | [diff] [blame] | 200 | #endif |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 201 | |
| 202 | /* Sub-device specifications */ |
| 203 | /* Nothing needed yet */ |
| 204 | __u8 raw[184]; |
| 205 | }; |
| 206 | }; |
| 207 | |
| 208 | #define MEDIA_PAD_FL_SINK (1 << 0) |
| 209 | #define MEDIA_PAD_FL_SOURCE (1 << 1) |
Sakari Ailus | d0700c5 | 2013-10-13 07:58:43 -0300 | [diff] [blame] | 210 | #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2) |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 211 | |
| 212 | struct media_pad_desc { |
| 213 | __u32 entity; /* entity ID */ |
| 214 | __u16 index; /* pad index */ |
| 215 | __u32 flags; /* pad flags */ |
| 216 | __u32 reserved[2]; |
| 217 | }; |
| 218 | |
| 219 | #define MEDIA_LNK_FL_ENABLED (1 << 0) |
| 220 | #define MEDIA_LNK_FL_IMMUTABLE (1 << 1) |
Laurent Pinchart | e02188c | 2010-08-25 09:00:41 -0300 | [diff] [blame] | 221 | #define MEDIA_LNK_FL_DYNAMIC (1 << 2) |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 222 | |
Mauro Carvalho Chehab | c398bb6 | 2015-08-23 08:28:21 -0300 | [diff] [blame] | 223 | #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28) |
| 224 | # define MEDIA_LNK_FL_DATA_LINK (0 << 28) |
| 225 | # define MEDIA_LNK_FL_INTERFACE_LINK (1 << 28) |
| 226 | |
Laurent Pinchart | 1651333 | 2009-12-09 08:40:01 -0300 | [diff] [blame] | 227 | struct media_link_desc { |
| 228 | struct media_pad_desc source; |
| 229 | struct media_pad_desc sink; |
| 230 | __u32 flags; |
| 231 | __u32 reserved[2]; |
| 232 | }; |
| 233 | |
| 234 | struct media_links_enum { |
| 235 | __u32 entity; |
| 236 | /* Should have enough room for pads elements */ |
| 237 | struct media_pad_desc __user *pads; |
| 238 | /* Should have enough room for links elements */ |
| 239 | struct media_link_desc __user *links; |
| 240 | __u32 reserved[4]; |
| 241 | }; |
| 242 | |
Mauro Carvalho Chehab | a1d2510 | 2015-08-20 07:43:07 -0300 | [diff] [blame] | 243 | /* Interface type ranges */ |
| 244 | |
| 245 | #define MEDIA_INTF_T_DVB_BASE 0x00000100 |
| 246 | #define MEDIA_INTF_T_V4L_BASE 0x00000200 |
| 247 | |
| 248 | /* Interface types */ |
| 249 | |
| 250 | #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE) |
| 251 | #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1) |
| 252 | #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2) |
| 253 | #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3) |
| 254 | #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4) |
| 255 | |
| 256 | #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE) |
| 257 | #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1) |
| 258 | #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2) |
| 259 | #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3) |
| 260 | #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4) |
| 261 | |
Mauro Carvalho Chehab | c398bb6 | 2015-08-23 08:28:21 -0300 | [diff] [blame] | 262 | /* |
| 263 | * MC next gen API definitions |
| 264 | * |
| 265 | * NOTE: The declarations below are close to the MC RFC for the Media |
| 266 | * Controller, the next generation. Yet, there are a few adjustments |
| 267 | * to do, as we want to be able to have a functional API before |
| 268 | * the MC properties change. Those will be properly marked below. |
| 269 | * Please also notice that I removed "num_pads", "num_links", |
| 270 | * from the proposal, as a proper userspace application will likely |
| 271 | * use lists for pads/links, just as we intend to do in Kernelspace. |
| 272 | * The API definition should be freed from fields that are bound to |
| 273 | * some specific data structure. |
| 274 | * |
| 275 | * FIXME: Currently, I opted to name the new types as "media_v2", as this |
| 276 | * won't cause any conflict with the Kernelspace namespace, nor with |
| 277 | * the previous kAPI media_*_desc namespace. This can be changed |
| 278 | * later, before the adding this API upstream. |
| 279 | */ |
| 280 | |
| 281 | |
| 282 | struct media_v2_entity { |
| 283 | __u32 id; |
| 284 | char name[64]; /* FIXME: move to a property? (RFC says so) */ |
Mauro Carvalho Chehab | d87cdb8 | 2015-09-06 10:59:08 -0300 | [diff] [blame] | 285 | __u32 function; /* Main function of the entity */ |
| 286 | __u16 reserved[12]; |
Mauro Carvalho Chehab | c398bb6 | 2015-08-23 08:28:21 -0300 | [diff] [blame] | 287 | }; |
| 288 | |
| 289 | /* Should match the specific fields at media_intf_devnode */ |
| 290 | struct media_v2_intf_devnode { |
| 291 | __u32 major; |
| 292 | __u32 minor; |
| 293 | }; |
| 294 | |
| 295 | struct media_v2_interface { |
| 296 | __u32 id; |
| 297 | __u32 intf_type; |
| 298 | __u32 flags; |
| 299 | __u32 reserved[9]; |
| 300 | |
| 301 | union { |
| 302 | struct media_v2_intf_devnode devnode; |
| 303 | __u32 raw[16]; |
| 304 | }; |
| 305 | }; |
| 306 | |
| 307 | struct media_v2_pad { |
| 308 | __u32 id; |
| 309 | __u32 entity_id; |
| 310 | __u32 flags; |
| 311 | __u16 reserved[9]; |
| 312 | }; |
| 313 | |
| 314 | struct media_v2_link { |
| 315 | __u32 id; |
| 316 | __u32 source_id; |
| 317 | __u32 sink_id; |
| 318 | __u32 flags; |
| 319 | __u32 reserved[5]; |
| 320 | }; |
| 321 | |
| 322 | struct media_v2_topology { |
| 323 | __u32 topology_version; |
| 324 | |
| 325 | __u32 num_entities; |
| 326 | struct media_v2_entity *entities; |
| 327 | |
| 328 | __u32 num_interfaces; |
| 329 | struct media_v2_interface *interfaces; |
| 330 | |
| 331 | __u32 num_pads; |
| 332 | struct media_v2_pad *pads; |
| 333 | |
| 334 | __u32 num_links; |
| 335 | struct media_v2_link *links; |
| 336 | |
| 337 | struct { |
| 338 | __u32 reserved_num; |
| 339 | void *reserved_ptr; |
| 340 | } reserved_types[16]; |
| 341 | __u32 reserved[8]; |
| 342 | }; |
| 343 | |
| 344 | /* ioctls */ |
Mauro Carvalho Chehab | a1d2510 | 2015-08-20 07:43:07 -0300 | [diff] [blame] | 345 | |
Laurent Pinchart | 474966e | 2011-03-05 17:14:33 -0300 | [diff] [blame] | 346 | #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info) |
| 347 | #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc) |
| 348 | #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum) |
| 349 | #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc) |
Mauro Carvalho Chehab | c398bb6 | 2015-08-23 08:28:21 -0300 | [diff] [blame] | 350 | #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology) |
Laurent Pinchart | 140d881 | 2010-08-18 11:41:22 -0300 | [diff] [blame] | 351 | |
| 352 | #endif /* __LINUX_MEDIA_H */ |