v4l2-dev.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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 <linux/android_kabi.h>
  19. #include <media/media-entity.h>
  20. #define VIDEO_MAJOR 81
  21. /**
  22. * enum vfl_devnode_type - type of V4L2 device node
  23. *
  24. * @VFL_TYPE_VIDEO: for video input/output devices
  25. * @VFL_TYPE_VBI: for vertical blank data (i.e. closed captions, teletext)
  26. * @VFL_TYPE_RADIO: for radio tuners
  27. * @VFL_TYPE_SUBDEV: for V4L2 subdevices
  28. * @VFL_TYPE_SDR: for Software Defined Radio tuners
  29. * @VFL_TYPE_TOUCH: for touch sensors
  30. * @VFL_TYPE_MAX: number of VFL types, must always be last in the enum
  31. */
  32. enum vfl_devnode_type {
  33. VFL_TYPE_VIDEO,
  34. VFL_TYPE_VBI,
  35. VFL_TYPE_RADIO,
  36. VFL_TYPE_SUBDEV,
  37. VFL_TYPE_SDR,
  38. VFL_TYPE_TOUCH,
  39. VFL_TYPE_MAX /* Shall be the last one */
  40. };
  41. /**
  42. * enum vfl_devnode_direction - Identifies if a &struct video_device
  43. * corresponds to a receiver, a transmitter or a mem-to-mem device.
  44. *
  45. * @VFL_DIR_RX: device is a receiver.
  46. * @VFL_DIR_TX: device is a transmitter.
  47. * @VFL_DIR_M2M: device is a memory to memory device.
  48. *
  49. * Note: Ignored if &enum vfl_devnode_type is %VFL_TYPE_SUBDEV.
  50. */
  51. enum vfl_devnode_direction {
  52. VFL_DIR_RX,
  53. VFL_DIR_TX,
  54. VFL_DIR_M2M,
  55. };
  56. struct v4l2_ioctl_callbacks;
  57. struct video_device;
  58. struct v4l2_device;
  59. struct v4l2_ctrl_handler;
  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 new drivers should 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. ANDROID_KABI_RESERVE(1);
  200. };
  201. /*
  202. * Newer version of video_device, handled by videodev2.c
  203. * This version moves redundant code from video device code to
  204. * the common handler
  205. */
  206. /**
  207. * struct video_device - Structure used to create and manage the V4L2 device
  208. * nodes.
  209. *
  210. * @entity: &struct media_entity
  211. * @intf_devnode: pointer to &struct media_intf_devnode
  212. * @pipe: &struct media_pipeline
  213. * @fops: pointer to &struct v4l2_file_operations for the video device
  214. * @device_caps: device capabilities as used in v4l2_capabilities
  215. * @dev: &struct device for the video device
  216. * @cdev: character device
  217. * @v4l2_dev: pointer to &struct v4l2_device parent
  218. * @dev_parent: pointer to &struct device parent
  219. * @ctrl_handler: Control handler associated with this device node.
  220. * May be NULL.
  221. * @queue: &struct vb2_queue associated with this device node. May be NULL.
  222. * @prio: pointer to &struct v4l2_prio_state with device's Priority state.
  223. * If NULL, then v4l2_dev->prio will be used.
  224. * @name: video device name
  225. * @vfl_type: V4L device type, as defined by &enum vfl_devnode_type
  226. * @vfl_dir: V4L receiver, transmitter or m2m
  227. * @minor: device node 'minor'. It is set to -1 if the registration failed
  228. * @num: number of the video device node
  229. * @flags: video device flags. Use bitops to set/clear/test flags.
  230. * Contains a set of &enum v4l2_video_device_flags.
  231. * @index: attribute to differentiate multiple indices on one physical device
  232. * @fh_lock: Lock for all v4l2_fhs
  233. * @fh_list: List of &struct v4l2_fh
  234. * @dev_debug: Internal device debug flags, not for use by drivers
  235. * @tvnorms: Supported tv norms
  236. *
  237. * @release: video device release() callback
  238. * @ioctl_ops: pointer to &struct v4l2_ioctl_ops with ioctl callbacks
  239. *
  240. * @valid_ioctls: bitmap with the valid ioctls for this device
  241. * @lock: pointer to &struct mutex serialization lock
  242. *
  243. * .. note::
  244. * Only set @dev_parent if that can't be deduced from @v4l2_dev.
  245. */
  246. struct video_device {
  247. #if defined(CONFIG_MEDIA_CONTROLLER)
  248. struct media_entity entity;
  249. struct media_intf_devnode *intf_devnode;
  250. struct media_pipeline pipe;
  251. #endif
  252. const struct v4l2_file_operations *fops;
  253. u32 device_caps;
  254. /* sysfs */
  255. struct device dev;
  256. struct cdev *cdev;
  257. struct v4l2_device *v4l2_dev;
  258. struct device *dev_parent;
  259. struct v4l2_ctrl_handler *ctrl_handler;
  260. struct vb2_queue *queue;
  261. struct v4l2_prio_state *prio;
  262. /* device info */
  263. char name[32];
  264. enum vfl_devnode_type vfl_type;
  265. enum vfl_devnode_direction vfl_dir;
  266. int minor;
  267. u16 num;
  268. unsigned long flags;
  269. int index;
  270. /* V4L2 file handles */
  271. spinlock_t fh_lock;
  272. struct list_head fh_list;
  273. int dev_debug;
  274. v4l2_std_id tvnorms;
  275. /* callbacks */
  276. void (*release)(struct video_device *vdev);
  277. const struct v4l2_ioctl_ops *ioctl_ops;
  278. DECLARE_BITMAP(valid_ioctls, BASE_VIDIOC_PRIVATE);
  279. struct mutex *lock;
  280. ANDROID_KABI_RESERVE(1);
  281. ANDROID_KABI_RESERVE(2);
  282. };
  283. /**
  284. * media_entity_to_video_device - Returns a &struct video_device from
  285. * the &struct media_entity embedded on it.
  286. *
  287. * @__entity: pointer to &struct media_entity
  288. */
  289. #define media_entity_to_video_device(__entity) \
  290. container_of(__entity, struct video_device, entity)
  291. /**
  292. * to_video_device - Returns a &struct video_device from the
  293. * &struct device embedded on it.
  294. *
  295. * @cd: pointer to &struct device
  296. */
  297. #define to_video_device(cd) container_of(cd, struct video_device, dev)
  298. /**
  299. * __video_register_device - register video4linux devices
  300. *
  301. * @vdev: struct video_device to register
  302. * @type: type of device to register, as defined by &enum vfl_devnode_type
  303. * @nr: which device node number is desired:
  304. * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
  305. * @warn_if_nr_in_use: warn if the desired device node number
  306. * was already in use and another number was chosen instead.
  307. * @owner: module that owns the video device node
  308. *
  309. * The registration code assigns minor numbers and device node numbers
  310. * based on the requested type and registers the new device node with
  311. * the kernel.
  312. *
  313. * This function assumes that struct video_device was zeroed when it
  314. * was allocated and does not contain any stale date.
  315. *
  316. * An error is returned if no free minor or device node number could be
  317. * found, or if the registration of the device node failed.
  318. *
  319. * Returns 0 on success.
  320. *
  321. * .. note::
  322. *
  323. * This function is meant to be used only inside the V4L2 core.
  324. * Drivers should use video_register_device() or
  325. * video_register_device_no_warn().
  326. */
  327. int __must_check __video_register_device(struct video_device *vdev,
  328. enum vfl_devnode_type type,
  329. int nr, int warn_if_nr_in_use,
  330. struct module *owner);
  331. /**
  332. * video_register_device - register video4linux devices
  333. *
  334. * @vdev: struct video_device to register
  335. * @type: type of device to register, as defined by &enum vfl_devnode_type
  336. * @nr: which device node number is desired:
  337. * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
  338. *
  339. * Internally, it calls __video_register_device(). Please see its
  340. * documentation for more details.
  341. *
  342. * .. note::
  343. * if video_register_device fails, the release() callback of
  344. * &struct video_device structure is *not* called, so the caller
  345. * is responsible for freeing any data. Usually that means that
  346. * you video_device_release() should be called on failure.
  347. */
  348. static inline int __must_check video_register_device(struct video_device *vdev,
  349. enum vfl_devnode_type type,
  350. int nr)
  351. {
  352. return __video_register_device(vdev, type, nr, 1, vdev->fops->owner);
  353. }
  354. /**
  355. * video_register_device_no_warn - register video4linux devices
  356. *
  357. * @vdev: struct video_device to register
  358. * @type: type of device to register, as defined by &enum vfl_devnode_type
  359. * @nr: which device node number is desired:
  360. * (0 == /dev/video0, 1 == /dev/video1, ..., -1 == first free)
  361. *
  362. * This function is identical to video_register_device() except that no
  363. * warning is issued if the desired device node number was already in use.
  364. *
  365. * Internally, it calls __video_register_device(). Please see its
  366. * documentation for more details.
  367. *
  368. * .. note::
  369. * if video_register_device fails, the release() callback of
  370. * &struct video_device structure is *not* called, so the caller
  371. * is responsible for freeing any data. Usually that means that
  372. * you video_device_release() should be called on failure.
  373. */
  374. static inline int __must_check
  375. video_register_device_no_warn(struct video_device *vdev,
  376. enum vfl_devnode_type type, int nr)
  377. {
  378. return __video_register_device(vdev, type, nr, 0, vdev->fops->owner);
  379. }
  380. /**
  381. * video_unregister_device - Unregister video devices.
  382. *
  383. * @vdev: &struct video_device to register
  384. *
  385. * Does nothing if vdev == NULL or if video_is_registered() returns false.
  386. */
  387. void video_unregister_device(struct video_device *vdev);
  388. /**
  389. * video_device_alloc - helper function to alloc &struct video_device
  390. *
  391. * Returns NULL if %-ENOMEM or a &struct video_device on success.
  392. */
  393. struct video_device * __must_check video_device_alloc(void);
  394. /**
  395. * video_device_release - helper function to release &struct video_device
  396. *
  397. * @vdev: pointer to &struct video_device
  398. *
  399. * Can also be used for video_device->release\(\).
  400. */
  401. void video_device_release(struct video_device *vdev);
  402. /**
  403. * video_device_release_empty - helper function to implement the
  404. * video_device->release\(\) callback.
  405. *
  406. * @vdev: pointer to &struct video_device
  407. *
  408. * This release function does nothing.
  409. *
  410. * It should be used when the video_device is a static global struct.
  411. *
  412. * .. note::
  413. * Having a static video_device is a dubious construction at best.
  414. */
  415. void video_device_release_empty(struct video_device *vdev);
  416. /**
  417. * v4l2_disable_ioctl- mark that a given command isn't implemented.
  418. * shouldn't use core locking
  419. *
  420. * @vdev: pointer to &struct video_device
  421. * @cmd: ioctl command
  422. *
  423. * This function allows drivers to provide just one v4l2_ioctl_ops struct, but
  424. * disable ioctls based on the specific card that is actually found.
  425. *
  426. * .. note::
  427. *
  428. * This must be called before video_register_device.
  429. * See also the comments for determine_valid_ioctls().
  430. */
  431. static inline void v4l2_disable_ioctl(struct video_device *vdev,
  432. unsigned int cmd)
  433. {
  434. if (_IOC_NR(cmd) < BASE_VIDIOC_PRIVATE)
  435. set_bit(_IOC_NR(cmd), vdev->valid_ioctls);
  436. }
  437. /**
  438. * video_get_drvdata - gets private data from &struct video_device.
  439. *
  440. * @vdev: pointer to &struct video_device
  441. *
  442. * returns a pointer to the private data
  443. */
  444. static inline void *video_get_drvdata(struct video_device *vdev)
  445. {
  446. return dev_get_drvdata(&vdev->dev);
  447. }
  448. /**
  449. * video_set_drvdata - sets private data from &struct video_device.
  450. *
  451. * @vdev: pointer to &struct video_device
  452. * @data: private data pointer
  453. */
  454. static inline void video_set_drvdata(struct video_device *vdev, void *data)
  455. {
  456. dev_set_drvdata(&vdev->dev, data);
  457. }
  458. /**
  459. * video_devdata - gets &struct video_device from struct file.
  460. *
  461. * @file: pointer to struct file
  462. */
  463. struct video_device *video_devdata(struct file *file);
  464. /**
  465. * video_drvdata - gets private data from &struct video_device using the
  466. * struct file.
  467. *
  468. * @file: pointer to struct file
  469. *
  470. * This is function combines both video_get_drvdata() and video_devdata()
  471. * as this is used very often.
  472. */
  473. static inline void *video_drvdata(struct file *file)
  474. {
  475. return video_get_drvdata(video_devdata(file));
  476. }
  477. /**
  478. * video_device_node_name - returns the video device name
  479. *
  480. * @vdev: pointer to &struct video_device
  481. *
  482. * Returns the device name string
  483. */
  484. static inline const char *video_device_node_name(struct video_device *vdev)
  485. {
  486. return dev_name(&vdev->dev);
  487. }
  488. /**
  489. * video_is_registered - returns true if the &struct video_device is registered.
  490. *
  491. *
  492. * @vdev: pointer to &struct video_device
  493. */
  494. static inline int video_is_registered(struct video_device *vdev)
  495. {
  496. return test_bit(V4L2_FL_REGISTERED, &vdev->flags);
  497. }
  498. #if defined(CONFIG_MEDIA_CONTROLLER)
  499. /**
  500. * video_device_pipeline_start - Mark a pipeline as streaming
  501. * @vdev: Starting video device
  502. * @pipe: Media pipeline to be assigned to all entities in the pipeline.
  503. *
  504. * Mark all entities connected to a given video device through enabled links,
  505. * either directly or indirectly, as streaming. The given pipeline object is
  506. * assigned to every pad in the pipeline and stored in the media_pad pipe
  507. * field.
  508. *
  509. * Calls to this function can be nested, in which case the same number of
  510. * video_device_pipeline_stop() calls will be required to stop streaming. The
  511. * pipeline pointer must be identical for all nested calls to
  512. * video_device_pipeline_start().
  513. *
  514. * The video device must contain a single pad.
  515. *
  516. * This is a convenience wrapper around media_pipeline_start().
  517. */
  518. __must_check int video_device_pipeline_start(struct video_device *vdev,
  519. struct media_pipeline *pipe);
  520. /**
  521. * __video_device_pipeline_start - Mark a pipeline as streaming
  522. * @vdev: Starting video device
  523. * @pipe: Media pipeline to be assigned to all entities in the pipeline.
  524. *
  525. * ..note:: This is the non-locking version of video_device_pipeline_start()
  526. *
  527. * The video device must contain a single pad.
  528. *
  529. * This is a convenience wrapper around __media_pipeline_start().
  530. */
  531. __must_check int __video_device_pipeline_start(struct video_device *vdev,
  532. struct media_pipeline *pipe);
  533. /**
  534. * video_device_pipeline_stop - Mark a pipeline as not streaming
  535. * @vdev: Starting video device
  536. *
  537. * Mark all entities connected to a given video device through enabled links,
  538. * either directly or indirectly, as not streaming. The media_pad pipe field
  539. * is reset to %NULL.
  540. *
  541. * If multiple calls to media_pipeline_start() have been made, the same
  542. * number of calls to this function are required to mark the pipeline as not
  543. * streaming.
  544. *
  545. * The video device must contain a single pad.
  546. *
  547. * This is a convenience wrapper around media_pipeline_stop().
  548. */
  549. void video_device_pipeline_stop(struct video_device *vdev);
  550. /**
  551. * __video_device_pipeline_stop - Mark a pipeline as not streaming
  552. * @vdev: Starting video device
  553. *
  554. * .. note:: This is the non-locking version of media_pipeline_stop()
  555. *
  556. * The video device must contain a single pad.
  557. *
  558. * This is a convenience wrapper around __media_pipeline_stop().
  559. */
  560. void __video_device_pipeline_stop(struct video_device *vdev);
  561. /**
  562. * video_device_pipeline_alloc_start - Mark a pipeline as streaming
  563. * @vdev: Starting video device
  564. *
  565. * video_device_pipeline_alloc_start() is similar to video_device_pipeline_start()
  566. * but instead of working on a given pipeline the function will use an
  567. * existing pipeline if the video device is already part of a pipeline, or
  568. * allocate a new pipeline.
  569. *
  570. * Calls to video_device_pipeline_alloc_start() must be matched with
  571. * video_device_pipeline_stop().
  572. */
  573. __must_check int video_device_pipeline_alloc_start(struct video_device *vdev);
  574. /**
  575. * video_device_pipeline - Get the media pipeline a video device is part of
  576. * @vdev: The video device
  577. *
  578. * This function returns the media pipeline that a video device has been
  579. * associated with when constructing the pipeline with
  580. * video_device_pipeline_start(). The pointer remains valid until
  581. * video_device_pipeline_stop() is called.
  582. *
  583. * Return: The media_pipeline the video device is part of, or NULL if the video
  584. * device is not part of any pipeline.
  585. *
  586. * The video device must contain a single pad.
  587. *
  588. * This is a convenience wrapper around media_entity_pipeline().
  589. */
  590. struct media_pipeline *video_device_pipeline(struct video_device *vdev);
  591. #endif /* CONFIG_MEDIA_CONTROLLER */
  592. #endif /* _V4L2_DEV_H */