v4l2-mc.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. * v4l2-mc.h - Media Controller V4L2 types and prototypes
  3. *
  4. * Copyright (C) 2016 Mauro Carvalho Chehab <mchehab@kernel.org>
  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_pad_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_pad_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. *
  110. * .. note::
  111. *
  112. * Webcams are modelled on a very simple way: the sensor is
  113. * connected directly to the I/O entity. All dirty details, like
  114. * scaler and crop HW are hidden. While such mapping is enough for v4l2
  115. * interface centric PC-consumer's hardware, V4L2 subdev centric camera
  116. * hardware should not use this routine, as it will not build the right graph.
  117. */
  118. int v4l2_mc_create_media_graph(struct media_device *mdev);
  119. /**
  120. * v4l_enable_media_source() - Hold media source for exclusive use
  121. * if free
  122. *
  123. * @vdev: pointer to struct video_device
  124. *
  125. * This interface calls enable_source handler to determine if
  126. * media source is free for use. The enable_source handler is
  127. * responsible for checking is the media source is free and
  128. * start a pipeline between the media source and the media
  129. * entity associated with the video device. This interface
  130. * should be called from v4l2-core and dvb-core interfaces
  131. * that change the source configuration.
  132. *
  133. * Return: returns zero on success or a negative error code.
  134. */
  135. int v4l_enable_media_source(struct video_device *vdev);
  136. /**
  137. * v4l_disable_media_source() - Release media source
  138. *
  139. * @vdev: pointer to struct video_device
  140. *
  141. * This interface calls disable_source handler to release
  142. * the media source. The disable_source handler stops the
  143. * active media pipeline between the media source and the
  144. * media entity associated with the video device.
  145. *
  146. * Return: returns zero on success or a negative error code.
  147. */
  148. void v4l_disable_media_source(struct video_device *vdev);
  149. /*
  150. * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use
  151. * if free.
  152. * @q - pointer to struct vb2_queue
  153. *
  154. * Wrapper for v4l_enable_media_source(). This function should
  155. * be called from v4l2-core to enable the media source with
  156. * pointer to struct vb2_queue as the input argument. Some
  157. * v4l2-core interfaces don't have access to video device and
  158. * this interface finds the struct video_device for the q and
  159. * calls v4l_enable_media_source().
  160. */
  161. int v4l_vb2q_enable_media_source(struct vb2_queue *q);
  162. /**
  163. * v4l2_pipeline_pm_use - Update the use count of an entity
  164. * @entity: The entity
  165. * @use: Use (1) or stop using (0) the entity
  166. *
  167. * Update the use count of all entities in the pipeline and power entities on or
  168. * off accordingly.
  169. *
  170. * This function is intended to be called in video node open (use ==
  171. * 1) and release (use == 0). It uses struct media_entity.use_count to
  172. * track the power status. The use of this function should be paired
  173. * with v4l2_pipeline_link_notify().
  174. *
  175. * Return 0 on success or a negative error code on failure. Powering entities
  176. * off is assumed to never fail. No failure can occur when the use parameter is
  177. * set to 0.
  178. */
  179. int v4l2_pipeline_pm_use(struct media_entity *entity, int use);
  180. /**
  181. * v4l2_pipeline_link_notify - Link management notification callback
  182. * @link: The link
  183. * @flags: New link flags that will be applied
  184. * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)
  185. *
  186. * React to link management on powered pipelines by updating the use count of
  187. * all entities in the source and sink sides of the link. Entities are powered
  188. * on or off accordingly. The use of this function should be paired
  189. * with v4l2_pipeline_pm_use().
  190. *
  191. * Return 0 on success or a negative error code on failure. Powering entities
  192. * off is assumed to never fail. This function will not fail for disconnection
  193. * events.
  194. */
  195. int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
  196. unsigned int notification);
  197. #else /* CONFIG_MEDIA_CONTROLLER */
  198. static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
  199. {
  200. return 0;
  201. }
  202. static inline int v4l_enable_media_source(struct video_device *vdev)
  203. {
  204. return 0;
  205. }
  206. static inline void v4l_disable_media_source(struct video_device *vdev)
  207. {
  208. }
  209. static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
  210. {
  211. return 0;
  212. }
  213. static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
  214. {
  215. return 0;
  216. }
  217. static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
  218. unsigned int notification)
  219. {
  220. return 0;
  221. }
  222. #endif /* CONFIG_MEDIA_CONTROLLER */
  223. #endif /* _V4L2_MC_H */