logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

media.h (12754B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Multimedia device API
  4. *
  5. * Copyright (C) 2010 Nokia Corporation
  6. *
  7. * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  8. * Sakari Ailus <sakari.ailus@iki.fi>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. */
  19. #ifndef __LINUX_MEDIA_H
  20. #define __LINUX_MEDIA_H
  21. #include <linux/ioctl.h>
  22. #include <linux/types.h>
  23. struct media_device_info {
  24. char driver[16];
  25. char model[32];
  26. char serial[40];
  27. char bus_info[32];
  28. __u32 media_version;
  29. __u32 hw_revision;
  30. __u32 driver_version;
  31. __u32 reserved[31];
  32. };
  33. /*
  34. * Base number ranges for entity functions
  35. *
  36. * NOTE: Userspace should not rely on these ranges to identify a group
  37. * of function types, as newer functions can be added with any name within
  38. * the full u32 range.
  39. *
  40. * Some older functions use the MEDIA_ENT_F_OLD_*_BASE range. Do not
  41. * change this, this is for backwards compatibility. When adding new
  42. * functions always use MEDIA_ENT_F_BASE.
  43. */
  44. #define MEDIA_ENT_F_BASE 0x00000000
  45. #define MEDIA_ENT_F_OLD_BASE 0x00010000
  46. #define MEDIA_ENT_F_OLD_SUBDEV_BASE 0x00020000
  47. /*
  48. * Initial value to be used when a new entity is created
  49. * Drivers should change it to something useful.
  50. */
  51. #define MEDIA_ENT_F_UNKNOWN MEDIA_ENT_F_BASE
  52. /*
  53. * Subdevs are initialized with MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN in order
  54. * to preserve backward compatibility. Drivers must change to the proper
  55. * subdev type before registering the entity.
  56. */
  57. #define MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_F_OLD_SUBDEV_BASE
  58. /*
  59. * DVB entity functions
  60. */
  61. #define MEDIA_ENT_F_DTV_DEMOD (MEDIA_ENT_F_BASE + 0x00001)
  62. #define MEDIA_ENT_F_TS_DEMUX (MEDIA_ENT_F_BASE + 0x00002)
  63. #define MEDIA_ENT_F_DTV_CA (MEDIA_ENT_F_BASE + 0x00003)
  64. #define MEDIA_ENT_F_DTV_NET_DECAP (MEDIA_ENT_F_BASE + 0x00004)
  65. /*
  66. * I/O entity functions
  67. */
  68. #define MEDIA_ENT_F_IO_V4L (MEDIA_ENT_F_OLD_BASE + 1)
  69. #define MEDIA_ENT_F_IO_DTV (MEDIA_ENT_F_BASE + 0x01001)
  70. #define MEDIA_ENT_F_IO_VBI (MEDIA_ENT_F_BASE + 0x01002)
  71. #define MEDIA_ENT_F_IO_SWRADIO (MEDIA_ENT_F_BASE + 0x01003)
  72. /*
  73. * Sensor functions
  74. */
  75. #define MEDIA_ENT_F_CAM_SENSOR (MEDIA_ENT_F_OLD_SUBDEV_BASE + 1)
  76. #define MEDIA_ENT_F_FLASH (MEDIA_ENT_F_OLD_SUBDEV_BASE + 2)
  77. #define MEDIA_ENT_F_LENS (MEDIA_ENT_F_OLD_SUBDEV_BASE + 3)
  78. /*
  79. * Digital TV, analog TV, radio and/or software defined radio tuner functions.
  80. *
  81. * It is a responsibility of the master/bridge drivers to add connectors
  82. * and links for MEDIA_ENT_F_TUNER. Please notice that some old tuners
  83. * may require the usage of separate I2C chips to decode analog TV signals,
  84. * when the master/bridge chipset doesn't have its own TV standard decoder.
  85. * On such cases, the IF-PLL staging is mapped via one or two entities:
  86. * MEDIA_ENT_F_IF_VID_DECODER and/or MEDIA_ENT_F_IF_AUD_DECODER.
  87. */
  88. #define MEDIA_ENT_F_TUNER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 5)
  89. /*
  90. * Analog TV IF-PLL decoder functions
  91. *
  92. * It is a responsibility of the master/bridge drivers to create links
  93. * for MEDIA_ENT_F_IF_VID_DECODER and MEDIA_ENT_F_IF_AUD_DECODER.
  94. */
  95. #define MEDIA_ENT_F_IF_VID_DECODER (MEDIA_ENT_F_BASE + 0x02001)
  96. #define MEDIA_ENT_F_IF_AUD_DECODER (MEDIA_ENT_F_BASE + 0x02002)
  97. /*
  98. * Audio entity functions
  99. */
  100. #define MEDIA_ENT_F_AUDIO_CAPTURE (MEDIA_ENT_F_BASE + 0x03001)
  101. #define MEDIA_ENT_F_AUDIO_PLAYBACK (MEDIA_ENT_F_BASE + 0x03002)
  102. #define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003)
  103. /*
  104. * Processing entity functions
  105. */
  106. #define MEDIA_ENT_F_PROC_VIDEO_COMPOSER (MEDIA_ENT_F_BASE + 0x4001)
  107. #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER (MEDIA_ENT_F_BASE + 0x4002)
  108. #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV (MEDIA_ENT_F_BASE + 0x4003)
  109. #define MEDIA_ENT_F_PROC_VIDEO_LUT (MEDIA_ENT_F_BASE + 0x4004)
  110. #define MEDIA_ENT_F_PROC_VIDEO_SCALER (MEDIA_ENT_F_BASE + 0x4005)
  111. #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006)
  112. #define MEDIA_ENT_F_PROC_VIDEO_ENCODER (MEDIA_ENT_F_BASE + 0x4007)
  113. #define MEDIA_ENT_F_PROC_VIDEO_DECODER (MEDIA_ENT_F_BASE + 0x4008)
  114. #define MEDIA_ENT_F_PROC_VIDEO_ISP (MEDIA_ENT_F_BASE + 0x4009)
  115. /*
  116. * Switch and bridge entity functions
  117. */
  118. #define MEDIA_ENT_F_VID_MUX (MEDIA_ENT_F_BASE + 0x5001)
  119. #define MEDIA_ENT_F_VID_IF_BRIDGE (MEDIA_ENT_F_BASE + 0x5002)
  120. /*
  121. * Video decoder/encoder functions
  122. */
  123. #define MEDIA_ENT_F_ATV_DECODER (MEDIA_ENT_F_OLD_SUBDEV_BASE + 4)
  124. #define MEDIA_ENT_F_DV_DECODER (MEDIA_ENT_F_BASE + 0x6001)
  125. #define MEDIA_ENT_F_DV_ENCODER (MEDIA_ENT_F_BASE + 0x6002)
  126. /* Entity flags */
  127. #define MEDIA_ENT_FL_DEFAULT (1U << 0)
  128. #define MEDIA_ENT_FL_CONNECTOR (1U << 1)
  129. /* OR with the entity id value to find the next entity */
  130. #define MEDIA_ENT_ID_FLAG_NEXT (1U << 31)
  131. struct media_entity_desc {
  132. __u32 id;
  133. char name[32];
  134. __u32 type;
  135. __u32 revision;
  136. __u32 flags;
  137. __u32 group_id;
  138. __u16 pads;
  139. __u16 links;
  140. __u32 reserved[4];
  141. union {
  142. /* Node specifications */
  143. struct {
  144. __u32 major;
  145. __u32 minor;
  146. } dev;
  147. /*
  148. * TODO: this shouldn't have been added without
  149. * actual drivers that use this. When the first real driver
  150. * appears that sets this information, special attention
  151. * should be given whether this information is 1) enough, and
  152. * 2) can deal with udev rules that rename devices. The struct
  153. * dev would not be sufficient for this since that does not
  154. * contain the subdevice information. In addition, struct dev
  155. * can only refer to a single device, and not to multiple (e.g.
  156. * pcm and mixer devices).
  157. */
  158. struct {
  159. __u32 card;
  160. __u32 device;
  161. __u32 subdevice;
  162. } alsa;
  163. /*
  164. * DEPRECATED: previous node specifications. Kept just to
  165. * avoid breaking compilation. Use media_entity_desc.dev
  166. * instead.
  167. */
  168. struct {
  169. __u32 major;
  170. __u32 minor;
  171. } v4l;
  172. struct {
  173. __u32 major;
  174. __u32 minor;
  175. } fb;
  176. int dvb;
  177. /* Sub-device specifications */
  178. /* Nothing needed yet */
  179. __u8 raw[184];
  180. };
  181. };
  182. #define MEDIA_PAD_FL_SINK (1U << 0)
  183. #define MEDIA_PAD_FL_SOURCE (1U << 1)
  184. #define MEDIA_PAD_FL_MUST_CONNECT (1U << 2)
  185. struct media_pad_desc {
  186. __u32 entity; /* entity ID */
  187. __u16 index; /* pad index */
  188. __u32 flags; /* pad flags */
  189. __u32 reserved[2];
  190. };
  191. #define MEDIA_LNK_FL_ENABLED (1U << 0)
  192. #define MEDIA_LNK_FL_IMMUTABLE (1U << 1)
  193. #define MEDIA_LNK_FL_DYNAMIC (1U << 2)
  194. #define MEDIA_LNK_FL_LINK_TYPE (0xf << 28)
  195. # define MEDIA_LNK_FL_DATA_LINK (0U << 28)
  196. # define MEDIA_LNK_FL_INTERFACE_LINK (1U << 28)
  197. # define MEDIA_LNK_FL_ANCILLARY_LINK (2U << 28)
  198. struct media_link_desc {
  199. struct media_pad_desc source;
  200. struct media_pad_desc sink;
  201. __u32 flags;
  202. __u32 reserved[2];
  203. };
  204. struct media_links_enum {
  205. __u32 entity;
  206. /* Should have enough room for pads elements */
  207. struct media_pad_desc *pads;
  208. /* Should have enough room for links elements */
  209. struct media_link_desc *links;
  210. __u32 reserved[4];
  211. };
  212. /* Interface type ranges */
  213. #define MEDIA_INTF_T_DVB_BASE 0x00000100
  214. #define MEDIA_INTF_T_V4L_BASE 0x00000200
  215. /* Interface types */
  216. #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
  217. #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
  218. #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
  219. #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
  220. #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
  221. #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
  222. #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
  223. #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
  224. #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
  225. #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
  226. #define MEDIA_INTF_T_V4L_TOUCH (MEDIA_INTF_T_V4L_BASE + 5)
  227. #define MEDIA_INTF_T_ALSA_BASE 0x00000300
  228. #define MEDIA_INTF_T_ALSA_PCM_CAPTURE (MEDIA_INTF_T_ALSA_BASE)
  229. #define MEDIA_INTF_T_ALSA_PCM_PLAYBACK (MEDIA_INTF_T_ALSA_BASE + 1)
  230. #define MEDIA_INTF_T_ALSA_CONTROL (MEDIA_INTF_T_ALSA_BASE + 2)
  231. /*
  232. * MC next gen API definitions
  233. */
  234. /*
  235. * Appeared in 4.19.0.
  236. *
  237. * The media_version argument comes from the media_version field in
  238. * struct media_device_info.
  239. */
  240. #define MEDIA_V2_ENTITY_HAS_FLAGS(media_version) \
  241. ((media_version) >= ((4U << 16) | (19U << 8) | 0U))
  242. struct media_v2_entity {
  243. __u32 id;
  244. char name[64];
  245. __u32 function; /* Main function of the entity */
  246. __u32 flags;
  247. __u32 reserved[5];
  248. } __attribute__ ((packed));
  249. /* Should match the specific fields at media_intf_devnode */
  250. struct media_v2_intf_devnode {
  251. __u32 major;
  252. __u32 minor;
  253. } __attribute__ ((packed));
  254. struct media_v2_interface {
  255. __u32 id;
  256. __u32 intf_type;
  257. __u32 flags;
  258. __u32 reserved[9];
  259. union {
  260. struct media_v2_intf_devnode devnode;
  261. __u32 raw[16];
  262. };
  263. } __attribute__ ((packed));
  264. /*
  265. * Appeared in 4.19.0.
  266. *
  267. * The media_version argument comes from the media_version field in
  268. * struct media_device_info.
  269. */
  270. #define MEDIA_V2_PAD_HAS_INDEX(media_version) \
  271. ((media_version) >= ((4U << 16) | (19U << 8) | 0U))
  272. struct media_v2_pad {
  273. __u32 id;
  274. __u32 entity_id;
  275. __u32 flags;
  276. __u32 index;
  277. __u32 reserved[4];
  278. } __attribute__ ((packed));
  279. struct media_v2_link {
  280. __u32 id;
  281. __u32 source_id;
  282. __u32 sink_id;
  283. __u32 flags;
  284. __u32 reserved[6];
  285. } __attribute__ ((packed));
  286. struct media_v2_topology {
  287. __u64 topology_version;
  288. __u32 num_entities;
  289. __u32 reserved1;
  290. __u64 ptr_entities;
  291. __u32 num_interfaces;
  292. __u32 reserved2;
  293. __u64 ptr_interfaces;
  294. __u32 num_pads;
  295. __u32 reserved3;
  296. __u64 ptr_pads;
  297. __u32 num_links;
  298. __u32 reserved4;
  299. __u64 ptr_links;
  300. } __attribute__ ((packed));
  301. /* ioctls */
  302. #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
  303. #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
  304. #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
  305. #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
  306. #define MEDIA_IOC_G_TOPOLOGY _IOWR('|', 0x04, struct media_v2_topology)
  307. #define MEDIA_IOC_REQUEST_ALLOC _IOR ('|', 0x05, int)
  308. /*
  309. * These ioctls are called on the request file descriptor as returned
  310. * by MEDIA_IOC_REQUEST_ALLOC.
  311. */
  312. #define MEDIA_REQUEST_IOC_QUEUE _IO('|', 0x80)
  313. #define MEDIA_REQUEST_IOC_REINIT _IO('|', 0x81)
  314. /*
  315. * Legacy symbols used to avoid userspace compilation breakages.
  316. * Do not use any of this in new applications!
  317. *
  318. * Those symbols map the entity function into types and should be
  319. * used only on legacy programs for legacy hardware. Don't rely
  320. * on those for MEDIA_IOC_G_TOPOLOGY.
  321. */
  322. #define MEDIA_ENT_TYPE_SHIFT 16
  323. #define MEDIA_ENT_TYPE_MASK 0x00ff0000
  324. #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
  325. #define MEDIA_ENT_T_DEVNODE_UNKNOWN (MEDIA_ENT_F_OLD_BASE | \
  326. MEDIA_ENT_SUBTYPE_MASK)
  327. #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_F_OLD_BASE
  328. #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_F_IO_V4L
  329. #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_F_OLD_BASE + 2)
  330. #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_F_OLD_BASE + 3)
  331. #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_F_OLD_BASE + 4)
  332. #define MEDIA_ENT_T_UNKNOWN MEDIA_ENT_F_UNKNOWN
  333. #define MEDIA_ENT_T_V4L2_VIDEO MEDIA_ENT_F_IO_V4L
  334. #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_F_V4L2_SUBDEV_UNKNOWN
  335. #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR MEDIA_ENT_F_CAM_SENSOR
  336. #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH MEDIA_ENT_F_FLASH
  337. #define MEDIA_ENT_T_V4L2_SUBDEV_LENS MEDIA_ENT_F_LENS
  338. #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER MEDIA_ENT_F_ATV_DECODER
  339. #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER MEDIA_ENT_F_TUNER
  340. #define MEDIA_ENT_F_DTV_DECODER MEDIA_ENT_F_DV_DECODER
  341. /*
  342. * There is still no full ALSA support in the media controller. These
  343. * defines should not have been added and we leave them here only
  344. * in case some application tries to use these defines.
  345. *
  346. * The ALSA defines that are in use have been moved into __KERNEL__
  347. * scope. As support gets added to these interface types, they should
  348. * be moved into __KERNEL__ scope with the code that uses them.
  349. */
  350. #define MEDIA_INTF_T_ALSA_COMPRESS (MEDIA_INTF_T_ALSA_BASE + 3)
  351. #define MEDIA_INTF_T_ALSA_RAWMIDI (MEDIA_INTF_T_ALSA_BASE + 4)
  352. #define MEDIA_INTF_T_ALSA_HWDEP (MEDIA_INTF_T_ALSA_BASE + 5)
  353. #define MEDIA_INTF_T_ALSA_SEQUENCER (MEDIA_INTF_T_ALSA_BASE + 6)
  354. #define MEDIA_INTF_T_ALSA_TIMER (MEDIA_INTF_T_ALSA_BASE + 7)
  355. /* Obsolete symbol for media_version, no longer used in the kernel */
  356. #define MEDIA_API_VERSION ((0U << 16) | (1U << 8) | 0U)
  357. #endif /* __LINUX_MEDIA_H */