v4l2-mc.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*
  2. * v4l2-mc.h - Media Controller V4L2 types and prototypes
  3. *
  4. * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@osg.samsung.com>
  5. * Copyright (C) 2006-2010 Nokia Corporation
  6. * Copyright (c) 2016 Intel Corporation.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  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. #ifndef _V4L2_MC_H
  19. #define _V4L2_MC_H
  20. #include <media/media-device.h>
  21. #include <media/v4l2-dev.h>
  22. #include <linux/types.h>
  23. /**
  24. * enum tuner_pad_index - tuner pad index for MEDIA_ENT_F_TUNER
  25. *
  26. * @TUNER_PAD_RF_INPUT: Radiofrequency (RF) sink pad, usually linked to a
  27. * RF connector entity.
  28. * @TUNER_PAD_OUTPUT: Tuner video output source pad. Contains the video
  29. * chrominance and luminance or the hole bandwidth
  30. * of the signal converted to an Intermediate Frequency
  31. * (IF) or to baseband (on zero-IF tuners).
  32. * @TUNER_PAD_AUD_OUT: Tuner audio output source pad. Tuners used to decode
  33. * analog TV signals have an extra pad for audio output.
  34. * Old tuners use an analog stage with a saw filter for
  35. * the audio IF frequency. The output of the pad is, in
  36. * this case, the audio IF, with should be decoded either
  37. * by the bridge chipset (that's the case of cx2388x
  38. * chipsets) or may require an external IF sound
  39. * processor, like msp34xx. On modern silicon tuners,
  40. * the audio IF decoder is usually incorporated at the
  41. * tuner. On such case, the output of this pad is an
  42. * audio sampled data.
  43. * @TUNER_NUM_PADS: Number of pads of the tuner.
  44. */
  45. enum tuner_pad_index {
  46. TUNER_PAD_RF_INPUT,
  47. TUNER_PAD_OUTPUT,
  48. TUNER_PAD_AUD_OUT,
  49. TUNER_NUM_PADS
  50. };
  51. /**
  52. * enum if_vid_dec_index - video IF-PLL pad index for
  53. * MEDIA_ENT_F_IF_VID_DECODER
  54. *
  55. * @IF_VID_DEC_PAD_IF_INPUT: video Intermediate Frequency (IF) sink pad
  56. * @IF_VID_DEC_PAD_OUT: IF-PLL video output source pad. Contains the
  57. * video chrominance and luminance IF signals.
  58. * @IF_VID_DEC_PAD_NUM_PADS: Number of pads of the video IF-PLL.
  59. */
  60. enum if_vid_dec_pad_index {
  61. IF_VID_DEC_PAD_IF_INPUT,
  62. IF_VID_DEC_PAD_OUT,
  63. IF_VID_DEC_PAD_NUM_PADS
  64. };
  65. /**
  66. * enum if_aud_dec_index - audio/sound IF-PLL pad index for
  67. * MEDIA_ENT_F_IF_AUD_DECODER
  68. *
  69. * @IF_AUD_DEC_PAD_IF_INPUT: audio Intermediate Frequency (IF) sink pad
  70. * @IF_AUD_DEC_PAD_OUT: IF-PLL audio output source pad. Contains the
  71. * audio sampled stream data, usually connected
  72. * to the bridge bus via an Inter-IC Sound (I2S)
  73. * bus.
  74. * @IF_AUD_DEC_PAD_NUM_PADS: Number of pads of the audio IF-PLL.
  75. */
  76. enum if_aud_dec_pad_index {
  77. IF_AUD_DEC_PAD_IF_INPUT,
  78. IF_AUD_DEC_PAD_OUT,
  79. IF_AUD_DEC_PAD_NUM_PADS
  80. };
  81. /**
  82. * enum demod_pad_index - analog TV pad index for MEDIA_ENT_F_ATV_DECODER
  83. *
  84. * @DEMOD_PAD_IF_INPUT: IF input sink pad.
  85. * @DEMOD_PAD_VID_OUT: Video output source pad.
  86. * @DEMOD_PAD_VBI_OUT: Vertical Blank Interface (VBI) output source pad.
  87. * @DEMOD_PAD_AUDIO_OUT: Audio output source pad.
  88. * @DEMOD_NUM_PADS: Maximum number of output pads.
  89. */
  90. enum demod_pad_index {
  91. DEMOD_PAD_IF_INPUT,
  92. DEMOD_PAD_VID_OUT,
  93. DEMOD_PAD_VBI_OUT,
  94. DEMOD_PAD_AUDIO_OUT,
  95. DEMOD_NUM_PADS
  96. };
  97. /* We don't need to include pci.h or usb.h here */
  98. struct pci_dev;
  99. struct usb_device;
  100. #ifdef CONFIG_MEDIA_CONTROLLER
  101. /**
  102. * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
  103. *
  104. * @mdev: pointer to the &media_device struct.
  105. *
  106. * Add links between the entities commonly found on PC customer's hardware at
  107. * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
  108. * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
  109. * NOTE: webcams are modelled on a very simple way: the sensor is
  110. * connected directly to the I/O entity. All dirty details, like
  111. * scaler and crop HW are hidden. While such mapping is enough for v4l2
  112. * interface centric PC-consumer's hardware, V4L2 subdev centric camera
  113. * hardware should not use this routine, as it will not build the right graph.
  114. */
  115. int v4l2_mc_create_media_graph(struct media_device *mdev);
  116. /**
  117. * v4l_enable_media_source() - Hold media source for exclusive use
  118. * if free
  119. *
  120. * @vdev: pointer to struct video_device
  121. *
  122. * This interface calls enable_source handler to determine if
  123. * media source is free for use. The enable_source handler is
  124. * responsible for checking is the media source is free and
  125. * start a pipeline between the media source and the media
  126. * entity associated with the video device. This interface
  127. * should be called from v4l2-core and dvb-core interfaces
  128. * that change the source configuration.
  129. *
  130. * Return: returns zero on success or a negative error code.
  131. */
  132. int v4l_enable_media_source(struct video_device *vdev);
  133. /**
  134. * v4l_disable_media_source() - Release media source
  135. *
  136. * @vdev: pointer to struct video_device
  137. *
  138. * This interface calls disable_source handler to release
  139. * the media source. The disable_source handler stops the
  140. * active media pipeline between the media source and the
  141. * media entity associated with the video device.
  142. *
  143. * Return: returns zero on success or a negative error code.
  144. */
  145. void v4l_disable_media_source(struct video_device *vdev);
  146. /*
  147. * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use
  148. * if free.
  149. * @q - pointer to struct vb2_queue
  150. *
  151. * Wrapper for v4l_enable_media_source(). This function should
  152. * be called from v4l2-core to enable the media source with
  153. * pointer to struct vb2_queue as the input argument. Some
  154. * v4l2-core interfaces don't have access to video device and
  155. * this interface finds the struct video_device for the q and
  156. * calls v4l_enable_media_source().
  157. */
  158. int v4l_vb2q_enable_media_source(struct vb2_queue *q);
  159. /**
  160. * v4l2_pipeline_pm_use - Update the use count of an entity
  161. * @entity: The entity
  162. * @use: Use (1) or stop using (0) the entity
  163. *
  164. * Update the use count of all entities in the pipeline and power entities on or
  165. * off accordingly.
  166. *
  167. * This function is intended to be called in video node open (use ==
  168. * 1) and release (use == 0). It uses struct media_entity.use_count to
  169. * track the power status. The use of this function should be paired
  170. * with v4l2_pipeline_link_notify().
  171. *
  172. * Return 0 on success or a negative error code on failure. Powering entities
  173. * off is assumed to never fail. No failure can occur when the use parameter is
  174. * set to 0.
  175. */
  176. int v4l2_pipeline_pm_use(struct media_entity *entity, int use);
  177. /**
  178. * v4l2_pipeline_link_notify - Link management notification callback
  179. * @link: The link
  180. * @flags: New link flags that will be applied
  181. * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)
  182. *
  183. * React to link management on powered pipelines by updating the use count of
  184. * all entities in the source and sink sides of the link. Entities are powered
  185. * on or off accordingly. The use of this function should be paired
  186. * with v4l2_pipeline_pm_use().
  187. *
  188. * Return 0 on success or a negative error code on failure. Powering entities
  189. * off is assumed to never fail. This function will not fail for disconnection
  190. * events.
  191. */
  192. int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
  193. unsigned int notification);
  194. #else /* CONFIG_MEDIA_CONTROLLER */
  195. static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
  196. {
  197. return 0;
  198. }
  199. static inline int v4l_enable_media_source(struct video_device *vdev)
  200. {
  201. return 0;
  202. }
  203. static inline void v4l_disable_media_source(struct video_device *vdev)
  204. {
  205. }
  206. static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
  207. {
  208. return 0;
  209. }
  210. static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
  211. {
  212. return 0;
  213. }
  214. static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
  215. unsigned int notification)
  216. {
  217. return 0;
  218. }
  219. #endif /* CONFIG_MEDIA_CONTROLLER */
  220. #endif /* _V4L2_MC_H */