v4l2-dev.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. *
  4. * V 4 L 2 D R I V E R H E L P E R A P I
  5. *
  6. * Moved from videodev2.h
  7. *
  8. * Some commonly needed functions for drivers (v4l2-common.o module)
  9. */
  10. #ifndef _V4L2_DEV_H
  11. #define _V4L2_DEV_H
  12. #include <linux/poll.h>
  13. #include <linux/fs.h>
  14. #include <linux/device.h>
  15. #include <linux/cdev.h>
  16. #include <linux/mutex.h>
  17. #include <linux/videodev2.h>
  18. #include <media/media-entity.h>
  19. #define VIDEO_MAJOR 81
  20. /**
  21. * enum vfl_devnode_type - type of V4L2 device node
  22. *
  23. * @VFL_TYPE_VIDEO: for video input/output devices
  24. * @VFL_TYPE_VBI: for vertical blank data (i.e. closed captions, teletext)
  25. * @VFL_TYPE_RADIO: for radio tuners
  26. * @VFL_TYPE_SUBDEV: for V4L2 subdevices
  27. * @VFL_TYPE_SDR: for Software Defined Radio tuners
  28. * @VFL_TYPE_TOUCH: for touch sensors
  29. * @VFL_TYPE_MAX: number of VFL types, must always be last in the enum
  30. */
  31. enum vfl_devnode_type {
  32. VFL_TYPE_VIDEO,
  33. VFL_TYPE_VBI,
  34. VFL_TYPE_RADIO,
  35. VFL_TYPE_SUBDEV,
  36. VFL_TYPE_SDR,
  37. VFL_TYPE_TOUCH,
  38. VFL_TYPE_MAX /* Shall be the last one */
  39. };
  40. /**
  41. * enum vfl_devnode_direction - Identifies if a &struct video_device
  42. * corresponds to a receiver, a transmitter or a mem-to-mem device.
  43. *
  44. * @VFL_DIR_RX: device is a receiver.
  45. * @VFL_DIR_TX: device is a transmitter.
  46. * @VFL_DIR_M2M: device is a memory to memory device.
  47. *
  48. * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV.
  49. */
  50. enum vfl_devnode_direction {
  51. VFL_DIR_RX,
  52. VFL_DIR_TX,
  53. VFL_DIR_M2M,
  54. };
  55. struct v4l2_ioctl_callbacks;
  56. struct video_device;
  57. struct v4l2_device;
  58. struct v4l2_ctrl_handler;
  59. struct dentry;
  60. /**
  61. * enum v4l2_video_device_flags - Flags used by &struct video_device
  62. *
  63. * @V4L2_FL_REGISTERED:
  64. * indicates that a &struct video_device is registered.
  65. * Drivers can clear this flag if they want to block all future
  66. * device access. It is cleared by video_unregister_device.
  67. * @V4L2_FL_USES_V4L2_FH:
  68. * indicates that file->private_data points to &struct v4l2_fh.
  69. * This flag is set by the core when v4l2_fh_init() is called.
  70. * All drivers must use it.
  71. * @V4L2_FL_QUIRK_INVERTED_CROP:
  72. * some old M2M drivers use g/s_crop/cropcap incorrectly: crop and
  73. * compose are swapped. If this flag is set, then the selection
  74. * targets are swapped in the g/s_crop/cropcap functions in v4l2-ioctl.c.
  75. * This allows those drivers to correctly implement the selection API,
  76. * but the old crop API will still work as expected in order to preserve
  77. * backwards compatibility.
  78. * Never set this flag for new drivers.
  79. * @V4L2_FL_SUBDEV_RO_DEVNODE:
  80. * indicates that the video device node is registered in read-only mode.
  81. * The flag only applies to device nodes registered for sub-devices, it is
  82. * set by the core when the sub-devices device nodes are registered with
  83. * v4l2_device_register_ro_subdev_nodes() and used by the sub-device ioctl
  84. * handler to restrict access to some ioctl calls.
  85. */
  86. enum v4l2_video_device_flags {
  87. V4L2_FL_REGISTERED = 0,
  88. V4L2_FL_USES_V4L2_FH = 1,
  89. V4L2_FL_QUIRK_INVERTED_CROP = 2,
  90. V4L2_FL_SUBDEV_RO_DEVNODE = 3,
  91. };
  92. /* Priority helper functions */
  93. /**
  94. * struct v4l2_prio_state - stores the priority states
  95. *
  96. * @prios: array with elements to store the array priorities
  97. *
  98. *
  99. * .. note::
  100. * The size of @prios array matches the number of priority types defined
  101. * by enum &v4l2_priority.
  102. */
  103. struct v4l2_prio_state {
  104. atomic_t prios[4];
  105. };
  106. /**
  107. * v4l2_prio_init - initializes a struct v4l2_prio_state
  108. *
  109. * @global: pointer to &struct v4l2_prio_state
  110. */
  111. void v4l2_prio_init(struct v4l2_prio_state *global);
  112. /**
  113. * v4l2_prio_change - changes the v4l2 file handler priority
  114. *
  115. * @global: pointer to the &struct v4l2_prio_state of the device node.
  116. * @local: pointer to the desired priority, as defined by enum &v4l2_priority
  117. * @new: Priority type requested, as defined by enum &v4l2_priority.
  118. *
  119. * .. note::
  120. * This function should be used only by the V4L2 core.
  121. */
  122. int v4l2_prio_change(struct v4l2_prio_state *global, enum v4l2_priority *local,
  123. enum v4l2_priority new);
  124. /**
  125. * v4l2_prio_open - Implements the priority logic for a file handler open
  126. *
  127. * @global: pointer to the &struct v4l2_prio_state of the device node.
  128. * @local: pointer to the desired priority, as defined by enum &v4l2_priority
  129. *
  130. * .. note::
  131. * This function should be used only by the V4L2 core.
  132. */
  133. void v4l2_prio_open(struct v4l2_prio_state *global, enum v4l2_priority *local);
  134. /**
  135. * v4l2_prio_close - Implements the priority logic for a file handler close
  136. *
  137. * @global: pointer to the &struct v4l2_prio_state of the device node.
  138. * @local: priority to be released, as defined by enum &v4l2_priority
  139. *
  140. * .. note::
  141. * This function should be used only by the V4L2 core.
  142. */
  143. void v4l2_prio_close(struct v4l2_prio_state *global, enum v4l2_priority local);
  144. /**
  145. * v4l2_prio_max - Return the maximum priority, as stored at the @global array.
  146. *
  147. * @global: pointer to the &struct v4l2_prio_state of the device node.
  148. *
  149. * .. note::
  150. * This function should be used only by the V4L2 core.
  151. */
  152. enum v4l2_priority v4l2_prio_max(struct v4l2_prio_state *global);
  153. /**
  154. * v4l2_prio_check - Implements the priority logic for a file handler close
  155. *
  156. * @global: pointer to the &struct v4l2_prio_state of the device node.
  157. * @local: desired priority, as defined by enum &v4l2_priority local
  158. *
  159. * .. note::
  160. * This function should be used only by the V4L2 core.
  161. */
  162. int v4l2_prio_check(struct v4l2_prio_state *global, enum v4l2_priority local);
  163. /**
  164. * struct v4l2_file_operations - fs operations used by a V4L2 device
  165. *
  166. * @owner: pointer to struct module
  167. * @read: operations needed to implement the read() syscall
  168. * @write: operations needed to implement the write() syscall
  169. * @poll: operations needed to implement the poll() syscall
  170. * @unlocked_ioctl: operations needed to implement the ioctl() syscall
  171. * @compat_ioctl32: operations needed to implement the ioctl() syscall for
  172. * the special case where the Kernel uses 64 bits instructions, but
  173. * the userspace uses 32 bits.
  174. * @get_unmapped_area: called by the mmap() syscall, used when %!CONFIG_MMU
  175. * @mmap: operations needed to implement the mmap() syscall
  176. * @open: operations needed to implement the open() syscall
  177. * @release: operations needed to implement the release() syscall
  178. *
  179. * .. note::
  180. *
  181. * Those operations are used to implemente the fs struct file_operations
  182. * at the V4L2 drivers. The V4L2 core overrides the fs ops with some
  183. * extra logic needed by the subsystem.
  184. */
  185. struct v4l2_file_operations {
  186. struct module *owner;
  187. ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
  188. ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
  189. __poll_t (*poll) (struct file *, struct poll_table_struct *);
  190. long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
  191. #ifdef CONFIG_COMPAT
  192. long (*compat_ioctl32) (struct file *, unsigned int, unsigned long);
  193. #endif
  194. unsigned long (*get_unmapped_area) (struct file *, unsigned long,
  195. unsigned long, unsigned long, unsigned long);
  196. int (*mmap) (struct file *, struct vm_area_struct *);
  197. int (*open) (struct file *);
  198. int (*release) (struct file *);
  199. };
  200. /*
  201. * Newer version of video_device, handled by videodev2.c
  202. * This version moves redundant code from video device code to
  203. * the common handler
  204. */
  205. /**
  206. * struct video_device - Structure used to create and manage the V4L2 device
  207. * nodes.
  208. *
  209. * @entity: &struct media_entity
  210. * @intf_devnode: pointer to &struct media_intf_devnode
  211. * @pipe: &struct media_pipeline
  212. * @fops: pointer to &struct v4l2_file_operations for the video device
  213. * @device_caps: device capabilities as used in v4l2_capabilities
  214. * @dev: &struct device for the video device
  215. * @cdev: character device
  216. * @v4l2_dev: pointer to &struct v4l2_device parent
  217. * @dev_parent: pointer to &struct device parent
  218. * @ctrl_handler: Control handler associated with this device node.
  219. * May be NULL.
  220. * @queue: &struct vb2_queue associated with this device node. May be NULL.
  221. * @prio: pointer to &struct v4l2_prio_state with device's Priority state.
  222. * If NULL, then v4l2_dev->prio will be used.
  223. * @name: video device name
  224. * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type
  225. * @vfl_dir: V4L receiver, transmitter or m2m
  226. * @minor: device node 'minor'. It is set to -1 if the registration failed
  227. * @num: number of the video device node
  228. * @flags: video device flags. Use bitops to set/clear/test flags.
  229. * Contains a set of &enum v4l2_video_device_flags.
  230. * @index: attribute to differentiate multiple indices on one physical device
  231. * @fh_lock: Lock for all v4l2_fhs
  232. * @fh_list: List of &struct v4l2_fh
  233. * @dev_debug: Internal device debug flags, not for use by drivers
  234. * @tvnorms: Supported tv norms
  235. *
  236. * @release: video device release() callback
  237. * @ioctl_ops: pointer to &struct v4l2_ioctl_ops with ioctl callbacks
  238. *
  239. * @valid_ioctls: bitmap with the valid ioctls for this device
  240. * @lock: pointer to &struct mutex serialization lock
  241. *
  242. * .. note::
  243. * Only set @dev_parent if that can't be deduced from @v4l2_dev.
  244. */
  245. struct video_device {
  246. #if defined(CONFIG_MEDIA_CONTROLLER)
  247. struct media_entity entity;
  248. struct media_intf_devnode *intf_devnode;
  249. struct media_pipeline pipe;
  250. #endif
  251. const struct v4l2_file_operations *fops;
  252. u32 device_caps;
  253. /* sysfs */
  254. struct device dev;
  255. struct cdev *cdev;
  256. struct v4l2_device *v4l2_dev;
  257. struct device *dev_parent;
  258. struct v4l2_ctrl_handler *ctrl_handler;
  259. struct vb2_queue *queue;
  260. struct v4l2_prio_state *prio;
  261. /* device info */
  262. char name[64];
  263. enum vfl_devnode_type vfl_type;
  264. enum vfl_devnode_direction vfl_dir;
  265. int minor;
  266. u16 num;
  267. unsigned long flags;
  268. int index;
  269. /* V4L2 file handles */
  270. spinlock_t fh_lock;
  271. struct list_head fh_list;
  272. int dev_debug;
  273. v4l2_std_id tvnorms;
  274. /* callbacks */
  275. void (*release)(struct video_device *vdev);
  276. const struct v4l2_ioctl_ops *ioctl_ops;
  277. DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
  278. struct mutex *lock;
  279. };
  280. /**
  281. * media_entity_to_video_device - Returns a &struct video_device from
  282. * the &struct media_entity embedded on it.
  283. *
  284. * @__entity: pointer to &struct media_entity, may be NULL
  285. */
  286. #define media_entity_to_video_device(__entity) \
  287. ({ \
  288. typeof(__entity) __me_vdev_ent = __entity; \
  289. \
  290. __me_vdev_ent ? \
  291. container_of_const(__me_vdev_ent, struct video_device, \
  292. entity) : NULL; \
  293. })
  294. /**
  295. * to_video_device - Returns a &struct video_device from the
  296. * &struct device embedded on it.
  297. *
  298. * @cd: pointer to &struct device
  299. */
  300. #define to_video_device(cd) container_of_const(cd, struct video_device, dev)
  301. /**
  302. * __video_register_device - register video4linux devices
  303. *
  304. * @vdev: struct video_device to register
  305. * @type: type of device to register, as defined by &enum vfl_devnode_type
  306. * @nr: which device node number is desired:
  307. * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
  308. * @warn_if_nr_in_use: warn if the desired device node number
  309. * was already in use and another number was chosen instead.
  310. * @owner: module that owns the video device node
  311. *
  312. * The registration code assigns minor numbers and device node numbers
  313. * based on the requested type and registers the new device node with
  314. * the kernel.
  315. *
  316. * This function assumes that struct video_device was zeroed when it
  317. * was allocated and does not contain any stale date.
  318. *
  319. * An error is returned if no free minor or device node number could be
  320. * found, or if the registration of the device node failed.
  321. *
  322. * Returns 0 on success.
  323. *
  324. * .. note::
  325. *
  326. * This function is meant to be used only inside the V4L2 core.
  327. * Drivers should use video_register_device() or
  328. * video_register_device_no_warn().
  329. */
  330. int __must_check __video_register_device(struct video_device *vdev,
  331. enum vfl_devnode_type type,
  332. int nr, int warn_if_nr_in_use,
  333. struct module *owner);
  334. /**
  335. * video_register_device - register video4linux devices
  336. *
  337. * @vdev: struct video_device to register
  338. * @type: type of device to register, as defined by &enum vfl_devnode_type
  339. * @nr: which device node number is desired:
  340. * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
  341. *
  342. * Internally, it calls __video_register_device(). Please see its
  343. * documentation for more details.
  344. *
  345. * .. note::
  346. * if video_register_device fails, the release() callback of
  347. * &struct video_device structure is *not* called, so the caller
  348. * is responsible for freeing any data. Usually that means that
  349. * you video_device_release() should be called on failure.
  350. */
  351. static inline int __must_check video_register_device(struct video_device *vdev,
  352. enum vfl_devnode_type type,
  353. int nr)
  354. {
  355. return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
  356. }
  357. /**
  358. * video_register_device_no_warn - register video4linux devices
  359. *
  360. * @vdev: struct video_device to register
  361. * @type: type of device to register, as defined by &enum vfl_devnode_type
  362. * @nr: which device node number is desired:
  363. * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
  364. *
  365. * This function is identical to video_register_device() except that no
  366. * warning is issued if the desired device node number was already in use.
  367. *
  368. * Internally, it calls __video_register_device(). Please see its
  369. * documentation for more details.
  370. *
  371. * .. note::
  372. * if video_register_device fails, the release() callback of
  373. * &struct video_device structure is *not* called, so the caller
  374. * is responsible for freeing any data. Usually that means that
  375. * you video_device_release() should be called on failure.
  376. */
  377. static inline int __must_check
  378. video_register_device_no_warn(struct video_device *vdev,
  379. enum vfl_devnode_type type, int nr)
  380. {
  381. return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
  382. }
  383. /**
  384. * video_unregister_device - Unregister video devices.
  385. *
  386. * @vdev: &struct video_device to register
  387. *
  388. * Does nothing if vdev == NULL or if video_is_registered() returns false.
  389. */
  390. void video_unregister_device(struct video_device *vdev);
  391. /**
  392. * video_device_alloc - helper function to alloc &struct video_device
  393. *
  394. * Returns NULL if %-ENOMEM or a &struct video_device on success.
  395. */
  396. struct video_device * __must_check video_device_alloc(void);
  397. /**
  398. * video_device_release - helper function to release &struct video_device
  399. *
  400. * @vdev: pointer to &struct video_device
  401. *
  402. * Can also be used for video_device->release\(\).
  403. */
  404. void video_device_release(struct video_device *vdev);
  405. /**
  406. * video_device_release_empty - helper function to implement the
  407. * video_device->release\(\) callback.
  408. *
  409. * @vdev: pointer to &struct video_device
  410. *
  411. * This release function does nothing.
  412. *
  413. * It should be used when the video_device is a static global struct.
  414. *
  415. * .. note::
  416. * Having a static video_device is a dubious construction at best.
  417. */
  418. void video_device_release_empty(struct video_device *vdev);
  419. /**
  420. * v4l2_disable_ioctl- mark that a given command isn't implemented.
  421. * shouldn't use core locking
  422. *
  423. * @vdev: pointer to &struct video_device
  424. * @cmd: ioctl command
  425. *
  426. * This function allows drivers to provide just one v4l2_ioctl_ops struct, but
  427. * disable ioctls based on the specific card that is actually found.
  428. *
  429. * .. note::
  430. *
  431. * This must be called before video_register_device.
  432. * See also the comments for determine_valid_ioctls().
  433. */
  434. static inline void v4l2_disable_ioctl(struct video_device *vdev,
  435. unsigned int cmd)
  436. {
  437. if (_IOC_NR(cmd) < BASE_VIDIOC_PRIVATE)
  438. set_bit(_IOC_NR(cmd), vdev->valid_ioctls);
  439. }
  440. /**
  441. * video_get_drvdata - gets private data from &struct video_device.
  442. *
  443. * @vdev: pointer to &struct video_device
  444. *
  445. * returns a pointer to the private data
  446. */
  447. static inline void *video_get_drvdata(struct video_device *vdev)
  448. {
  449. return dev_get_drvdata(&vdev->dev);
  450. }
  451. /**
  452. * video_set_drvdata - sets private data from &struct video_device.
  453. *
  454. * @vdev: pointer to &struct video_device
  455. * @data: private data pointer
  456. */
  457. static inline void video_set_drvdata(struct video_device *vdev, void *data)
  458. {
  459. dev_set_drvdata(&vdev->dev, data);
  460. }
  461. /**
  462. * video_devdata - gets &struct video_device from struct file.
  463. *
  464. * @file: pointer to struct file
  465. */
  466. struct video_device *video_devdata(struct file *file);
  467. /**
  468. * video_drvdata - gets private data from &struct video_device using the
  469. * struct file.
  470. *
  471. * @file: pointer to struct file
  472. *
  473. * This is function combines both video_get_drvdata() and video_devdata()
  474. * as this is used very often.
  475. */
  476. static inline void *video_drvdata(struct file *file)
  477. {
  478. return video_get_drvdata(video_devdata(file));
  479. }
  480. /**
  481. * video_device_node_name - returns the video device name
  482. *
  483. * @vdev: pointer to &struct video_device
  484. *
  485. * Returns the device name string
  486. */
  487. static inline const char *video_device_node_name(struct video_device *vdev)
  488. {
  489. return dev_name(&vdev->dev);
  490. }
  491. /**
  492. * video_is_registered - returns true if the &struct video_device is registered.
  493. *
  494. *
  495. * @vdev: pointer to &struct video_device
  496. */
  497. static inline int video_is_registered(struct video_device *vdev)
  498. {
  499. return test_bit(V4L2_FL_REGISTERED, &vdev->flags);
  500. }
  501. /**
  502. * v4l2_debugfs_root - returns the dentry of the top-level "v4l2" debugfs dir
  503. *
  504. * If this directory does not yet exist, then it will be created.
  505. */
  506. #ifdef CONFIG_DEBUG_FS
  507. struct dentry *v4l2_debugfs_root(void);
  508. #else
  509. static inline struct dentry *v4l2_debugfs_root(void)
  510. {
  511. return NULL;
  512. }
  513. #endif
  514. #if defined(CONFIG_MEDIA_CONTROLLER)
  515. /**
  516. * video_device_pipeline_start - Mark a pipeline as streaming
  517. * @vdev: Starting video device
  518. * @pipe: Media pipeline to be assigned to all entities in the pipeline.
  519. *
  520. * Mark all entities connected to a given video device through enabled links,
  521. * either directly or indirectly, as streaming. The given pipeline object is
  522. * assigned to every pad in the pipeline and stored in the media_pad pipe
  523. * field.
  524. *
  525. * Calls to this function can be nested, in which case the same number of
  526. * video_device_pipeline_stop() calls will be required to stop streaming. The
  527. * pipeline pointer must be identical for all nested calls to
  528. * video_device_pipeline_start().
  529. *
  530. * The video device must contain a single pad.
  531. *
  532. * This is a convenience wrapper around media_pipeline_start().
  533. */
  534. __must_check int video_device_pipeline_start(struct video_device *vdev,
  535. struct media_pipeline *pipe);
  536. /**
  537. * __video_device_pipeline_start - Mark a pipeline as streaming
  538. * @vdev: Starting video device
  539. * @pipe: Media pipeline to be assigned to all entities in the pipeline.
  540. *
  541. * ..note:: This is the non-locking version of video_device_pipeline_start()
  542. *
  543. * The video device must contain a single pad.
  544. *
  545. * This is a convenience wrapper around __media_pipeline_start().
  546. */
  547. __must_check int __video_device_pipeline_start(struct video_device *vdev,
  548. struct media_pipeline *pipe);
  549. /**
  550. * video_device_pipeline_stop - Mark a pipeline as not streaming
  551. * @vdev: Starting video device
  552. *
  553. * Mark all entities connected to a given video device through enabled links,
  554. * either directly or indirectly, as not streaming. The media_pad pipe field
  555. * is reset to %NULL.
  556. *
  557. * If multiple calls to media_pipeline_start() have been made, the same
  558. * number of calls to this function are required to mark the pipeline as not
  559. * streaming.
  560. *
  561. * The video device must contain a single pad.
  562. *
  563. * This is a convenience wrapper around media_pipeline_stop().
  564. */
  565. void video_device_pipeline_stop(struct video_device *vdev);
  566. /**
  567. * __video_device_pipeline_stop - Mark a pipeline as not streaming
  568. * @vdev: Starting video device
  569. *
  570. * .. note:: This is the non-locking version of media_pipeline_stop()
  571. *
  572. * The video device must contain a single pad.
  573. *
  574. * This is a convenience wrapper around __media_pipeline_stop().
  575. */
  576. void __video_device_pipeline_stop(struct video_device *vdev);
  577. /**
  578. * video_device_pipeline_alloc_start - Mark a pipeline as streaming
  579. * @vdev: Starting video device
  580. *
  581. * video_device_pipeline_alloc_start() is similar to video_device_pipeline_start()
  582. * but instead of working on a given pipeline the function will use an
  583. * existing pipeline if the video device is already part of a pipeline, or
  584. * allocate a new pipeline.
  585. *
  586. * Calls to video_device_pipeline_alloc_start() must be matched with
  587. * video_device_pipeline_stop().
  588. */
  589. __must_check int video_device_pipeline_alloc_start(struct video_device *vdev);
  590. /**
  591. * video_device_pipeline - Get the media pipeline a video device is part of
  592. * @vdev: The video device
  593. *
  594. * This function returns the media pipeline that a video device has been
  595. * associated with when constructing the pipeline with
  596. * video_device_pipeline_start(). The pointer remains valid until
  597. * video_device_pipeline_stop() is called.
  598. *
  599. * Return: The media_pipeline the video device is part of, or NULL if the video
  600. * device is not part of any pipeline.
  601. *
  602. * The video device must contain a single pad.
  603. *
  604. * This is a convenience wrapper around media_entity_pipeline().
  605. */
  606. struct media_pipeline *video_device_pipeline(struct video_device *vdev);
  607. #endif /* CONFIG_MEDIA_CONTROLLER */
  608. #endif /* _V4L2_DEV_H */