media.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. #ifndef __LINUX_MEDIA_H
  23. #define __LINUX_MEDIA_H
  24. #include <linux/ioctl.h>
  25. #include <linux/types.h>
  26. #include <linux/version.h>
  27. #define MEDIA_API_VERSION KERNEL_VERSION(0, 1, 0)
  28. struct media_device_info {
  29. char driver[16];
  30. char model[32];
  31. char serial[40];
  32. char bus_info[32];
  33. __u32 media_version;
  34. __u32 hw_revision;
  35. __u32 driver_version;
  36. __u32 reserved[31];
  37. };
  38. #define MEDIA_ENT_ID_FLAG_NEXT (1 << 31)
  39. /* Used values for media_entity_desc::type */
  40. /*
  41. * Initial value to be used when a new entity is created
  42. * Drivers should change it to something useful
  43. */
  44. #define MEDIA_ENT_T_UNKNOWN 0x00000000
  45. /*
  46. * Base numbers for entity types
  47. *
  48. * Please notice that the huge gap of 16 bits for each base is overkill!
  49. * 8 bits is more than enough to avoid starving entity types for each
  50. * subsystem.
  51. *
  52. * However, It is kept this way just to avoid binary breakages with the
  53. * namespace provided on legacy versions of this header.
  54. */
  55. #define MEDIA_ENT_T_DVB_BASE 0x00000000
  56. #define MEDIA_ENT_T_V4L2_BASE 0x00010000
  57. #define MEDIA_ENT_T_V4L2_SUBDEV_BASE 0x00020000
  58. /*
  59. * V4L2 entities - Those are used for DMA (mmap/DMABUF) and
  60. * read()/write() data I/O associated with the V4L2 devnodes.
  61. */
  62. #define MEDIA_ENT_T_V4L2_VIDEO (MEDIA_ENT_T_V4L2_BASE + 1)
  63. /*
  64. * Please notice that numbers between MEDIA_ENT_T_V4L2_BASE + 2 and
  65. * MEDIA_ENT_T_V4L2_BASE + 4 can't be used, as those values used
  66. * to be declared for FB, ALSA and DVB entities.
  67. * As those values were never actually used in practice, we're just
  68. * adding them as backward compatibility macros and keeping the
  69. * numberspace clean here. This way, we avoid breaking compilation,
  70. * in the case of having some userspace application using the old
  71. * symbols.
  72. */
  73. #define MEDIA_ENT_T_V4L2_VBI (MEDIA_ENT_T_V4L2_BASE + 5)
  74. #define MEDIA_ENT_T_V4L2_SWRADIO (MEDIA_ENT_T_V4L2_BASE + 6)
  75. /* V4L2 Sub-device entities */
  76. /*
  77. * Subdevs are initialized with MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN,
  78. * in order to preserve backward compatibility.
  79. * Drivers should change to the proper subdev type before
  80. * registering the entity.
  81. */
  82. #define MEDIA_ENT_T_V4L2_SUBDEV_UNKNOWN MEDIA_ENT_T_V4L2_SUBDEV_BASE
  83. #define MEDIA_ENT_T_V4L2_SUBDEV_SENSOR (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 1)
  84. #define MEDIA_ENT_T_V4L2_SUBDEV_FLASH (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 2)
  85. #define MEDIA_ENT_T_V4L2_SUBDEV_LENS (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 3)
  86. /* A converter of analogue video to its digital representation. */
  87. #define MEDIA_ENT_T_V4L2_SUBDEV_DECODER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 4)
  88. /* Tuner entity is actually both V4L2 and DVB subdev */
  89. #define MEDIA_ENT_T_V4L2_SUBDEV_TUNER (MEDIA_ENT_T_V4L2_SUBDEV_BASE + 5)
  90. /* DVB entities */
  91. #define MEDIA_ENT_T_DVB_DEMOD (MEDIA_ENT_T_DVB_BASE + 1)
  92. #define MEDIA_ENT_T_DVB_DEMUX (MEDIA_ENT_T_DVB_BASE + 2)
  93. #define MEDIA_ENT_T_DVB_TSOUT (MEDIA_ENT_T_DVB_BASE + 3)
  94. #define MEDIA_ENT_T_DVB_CA (MEDIA_ENT_T_DVB_BASE + 4)
  95. #define MEDIA_ENT_T_DVB_NET_DECAP (MEDIA_ENT_T_DVB_BASE + 5)
  96. /* Legacy symbols used to avoid userspace compilation breakages */
  97. #define MEDIA_ENT_TYPE_SHIFT 16
  98. #define MEDIA_ENT_TYPE_MASK 0x00ff0000
  99. #define MEDIA_ENT_SUBTYPE_MASK 0x0000ffff
  100. #define MEDIA_ENT_T_DEVNODE MEDIA_ENT_T_V4L2_BASE
  101. #define MEDIA_ENT_T_V4L2_SUBDEV MEDIA_ENT_T_V4L2_SUBDEV_BASE
  102. #define MEDIA_ENT_T_DEVNODE_V4L MEDIA_ENT_T_V4L2_VIDEO
  103. #define MEDIA_ENT_T_DEVNODE_FB (MEDIA_ENT_T_DEVNODE + 2)
  104. #define MEDIA_ENT_T_DEVNODE_ALSA (MEDIA_ENT_T_DEVNODE + 3)
  105. #define MEDIA_ENT_T_DEVNODE_DVB (MEDIA_ENT_T_DEVNODE + 4)
  106. /* Entity types */
  107. #define MEDIA_ENT_FL_DEFAULT (1 << 0)
  108. struct media_entity_desc {
  109. __u32 id;
  110. char name[32];
  111. __u32 type;
  112. __u32 revision;
  113. __u32 flags;
  114. __u32 group_id;
  115. __u16 pads;
  116. __u16 links;
  117. __u32 reserved[4];
  118. union {
  119. /* Node specifications */
  120. struct {
  121. __u32 major;
  122. __u32 minor;
  123. } dev;
  124. #if 1
  125. /*
  126. * TODO: this shouldn't have been added without
  127. * actual drivers that use this. When the first real driver
  128. * appears that sets this information, special attention
  129. * should be given whether this information is 1) enough, and
  130. * 2) can deal with udev rules that rename devices. The struct
  131. * dev would not be sufficient for this since that does not
  132. * contain the subdevice information. In addition, struct dev
  133. * can only refer to a single device, and not to multiple (e.g.
  134. * pcm and mixer devices).
  135. *
  136. * So for now mark this as a to do.
  137. */
  138. struct {
  139. __u32 card;
  140. __u32 device;
  141. __u32 subdevice;
  142. } alsa;
  143. #endif
  144. #if 1
  145. /*
  146. * DEPRECATED: previous node specifications. Kept just to
  147. * avoid breaking compilation, but media_entity_desc.dev
  148. * should be used instead. In particular, alsa and dvb
  149. * fields below are wrong: for all devnodes, there should
  150. * be just major/minor inside the struct, as this is enough
  151. * to represent any devnode, no matter what type.
  152. */
  153. struct {
  154. __u32 major;
  155. __u32 minor;
  156. } v4l;
  157. struct {
  158. __u32 major;
  159. __u32 minor;
  160. } fb;
  161. int dvb;
  162. #endif
  163. /* Sub-device specifications */
  164. /* Nothing needed yet */
  165. __u8 raw[184];
  166. };
  167. };
  168. #define MEDIA_PAD_FL_SINK (1 << 0)
  169. #define MEDIA_PAD_FL_SOURCE (1 << 1)
  170. #define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
  171. struct media_pad_desc {
  172. __u32 entity; /* entity ID */
  173. __u16 index; /* pad index */
  174. __u32 flags; /* pad flags */
  175. __u32 reserved[2];
  176. };
  177. #define MEDIA_LNK_FL_ENABLED (1 << 0)
  178. #define MEDIA_LNK_FL_IMMUTABLE (1 << 1)
  179. #define MEDIA_LNK_FL_DYNAMIC (1 << 2)
  180. struct media_link_desc {
  181. struct media_pad_desc source;
  182. struct media_pad_desc sink;
  183. __u32 flags;
  184. __u32 reserved[2];
  185. };
  186. struct media_links_enum {
  187. __u32 entity;
  188. /* Should have enough room for pads elements */
  189. struct media_pad_desc __user *pads;
  190. /* Should have enough room for links elements */
  191. struct media_link_desc __user *links;
  192. __u32 reserved[4];
  193. };
  194. /* Interface type ranges */
  195. #define MEDIA_INTF_T_DVB_BASE 0x00000100
  196. #define MEDIA_INTF_T_V4L_BASE 0x00000200
  197. /* Interface types */
  198. #define MEDIA_INTF_T_DVB_FE (MEDIA_INTF_T_DVB_BASE)
  199. #define MEDIA_INTF_T_DVB_DEMUX (MEDIA_INTF_T_DVB_BASE + 1)
  200. #define MEDIA_INTF_T_DVB_DVR (MEDIA_INTF_T_DVB_BASE + 2)
  201. #define MEDIA_INTF_T_DVB_CA (MEDIA_INTF_T_DVB_BASE + 3)
  202. #define MEDIA_INTF_T_DVB_NET (MEDIA_INTF_T_DVB_BASE + 4)
  203. #define MEDIA_INTF_T_V4L_VIDEO (MEDIA_INTF_T_V4L_BASE)
  204. #define MEDIA_INTF_T_V4L_VBI (MEDIA_INTF_T_V4L_BASE + 1)
  205. #define MEDIA_INTF_T_V4L_RADIO (MEDIA_INTF_T_V4L_BASE + 2)
  206. #define MEDIA_INTF_T_V4L_SUBDEV (MEDIA_INTF_T_V4L_BASE + 3)
  207. #define MEDIA_INTF_T_V4L_SWRADIO (MEDIA_INTF_T_V4L_BASE + 4)
  208. /* TBD: declare the structs needed for the new G_TOPOLOGY ioctl */
  209. #define MEDIA_IOC_DEVICE_INFO _IOWR('|', 0x00, struct media_device_info)
  210. #define MEDIA_IOC_ENUM_ENTITIES _IOWR('|', 0x01, struct media_entity_desc)
  211. #define MEDIA_IOC_ENUM_LINKS _IOWR('|', 0x02, struct media_links_enum)
  212. #define MEDIA_IOC_SETUP_LINK _IOWR('|', 0x03, struct media_link_desc)
  213. #endif /* __LINUX_MEDIA_H */