v4l2-mc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. /* We don't need to include pci.h or usb.h here */
  24. struct pci_dev;
  25. struct usb_device;
  26. #ifdef CONFIG_MEDIA_CONTROLLER
  27. /**
  28. * v4l2_mc_create_media_graph() - create Media Controller links at the graph.
  29. *
  30. * @mdev: pointer to the &media_device struct.
  31. *
  32. * Add links between the entities commonly found on PC customer's hardware at
  33. * the V4L2 side: camera sensors, audio and video PLL-IF decoders, tuners,
  34. * analog TV decoder and I/O entities (video, VBI and Software Defined Radio).
  35. *
  36. * .. note::
  37. *
  38. * Webcams are modelled on a very simple way: the sensor is
  39. * connected directly to the I/O entity. All dirty details, like
  40. * scaler and crop HW are hidden. While such mapping is enough for v4l2
  41. * interface centric PC-consumer's hardware, V4L2 subdev centric camera
  42. * hardware should not use this routine, as it will not build the right graph.
  43. */
  44. int v4l2_mc_create_media_graph(struct media_device *mdev);
  45. /**
  46. * v4l_enable_media_source() - Hold media source for exclusive use
  47. * if free
  48. *
  49. * @vdev: pointer to struct video_device
  50. *
  51. * This interface calls enable_source handler to determine if
  52. * media source is free for use. The enable_source handler is
  53. * responsible for checking is the media source is free and
  54. * start a pipeline between the media source and the media
  55. * entity associated with the video device. This interface
  56. * should be called from v4l2-core and dvb-core interfaces
  57. * that change the source configuration.
  58. *
  59. * Return: returns zero on success or a negative error code.
  60. */
  61. int v4l_enable_media_source(struct video_device *vdev);
  62. /**
  63. * v4l_disable_media_source() - Release media source
  64. *
  65. * @vdev: pointer to struct video_device
  66. *
  67. * This interface calls disable_source handler to release
  68. * the media source. The disable_source handler stops the
  69. * active media pipeline between the media source and the
  70. * media entity associated with the video device.
  71. *
  72. * Return: returns zero on success or a negative error code.
  73. */
  74. void v4l_disable_media_source(struct video_device *vdev);
  75. /*
  76. * v4l_vb2q_enable_media_tuner - Hold media source for exclusive use
  77. * if free.
  78. * @q - pointer to struct vb2_queue
  79. *
  80. * Wrapper for v4l_enable_media_source(). This function should
  81. * be called from v4l2-core to enable the media source with
  82. * pointer to struct vb2_queue as the input argument. Some
  83. * v4l2-core interfaces don't have access to video device and
  84. * this interface finds the struct video_device for the q and
  85. * calls v4l_enable_media_source().
  86. */
  87. int v4l_vb2q_enable_media_source(struct vb2_queue *q);
  88. /**
  89. * v4l2_pipeline_pm_use - Update the use count of an entity
  90. * @entity: The entity
  91. * @use: Use (1) or stop using (0) the entity
  92. *
  93. * Update the use count of all entities in the pipeline and power entities on or
  94. * off accordingly.
  95. *
  96. * This function is intended to be called in video node open (use ==
  97. * 1) and release (use == 0). It uses struct media_entity.use_count to
  98. * track the power status. The use of this function should be paired
  99. * with v4l2_pipeline_link_notify().
  100. *
  101. * Return 0 on success or a negative error code on failure. Powering entities
  102. * off is assumed to never fail. No failure can occur when the use parameter is
  103. * set to 0.
  104. */
  105. int v4l2_pipeline_pm_use(struct media_entity *entity, int use);
  106. /**
  107. * v4l2_pipeline_link_notify - Link management notification callback
  108. * @link: The link
  109. * @flags: New link flags that will be applied
  110. * @notification: The link's state change notification type (MEDIA_DEV_NOTIFY_*)
  111. *
  112. * React to link management on powered pipelines by updating the use count of
  113. * all entities in the source and sink sides of the link. Entities are powered
  114. * on or off accordingly. The use of this function should be paired
  115. * with v4l2_pipeline_pm_use().
  116. *
  117. * Return 0 on success or a negative error code on failure. Powering entities
  118. * off is assumed to never fail. This function will not fail for disconnection
  119. * events.
  120. */
  121. int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
  122. unsigned int notification);
  123. #else /* CONFIG_MEDIA_CONTROLLER */
  124. static inline int v4l2_mc_create_media_graph(struct media_device *mdev)
  125. {
  126. return 0;
  127. }
  128. static inline int v4l_enable_media_source(struct video_device *vdev)
  129. {
  130. return 0;
  131. }
  132. static inline void v4l_disable_media_source(struct video_device *vdev)
  133. {
  134. }
  135. static inline int v4l_vb2q_enable_media_source(struct vb2_queue *q)
  136. {
  137. return 0;
  138. }
  139. static inline int v4l2_pipeline_pm_use(struct media_entity *entity, int use)
  140. {
  141. return 0;
  142. }
  143. static inline int v4l2_pipeline_link_notify(struct media_link *link, u32 flags,
  144. unsigned int notification)
  145. {
  146. return 0;
  147. }
  148. #endif /* CONFIG_MEDIA_CONTROLLER */
  149. #endif /* _V4L2_MC_H */