videobuf2-v4l2.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * videobuf2-v4l2.h - V4L2 driver helper framework
  3. *
  4. * Copyright (C) 2010 Samsung Electronics
  5. *
  6. * Author: Pawel Osciak <pawel@osciak.com>
  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.
  11. */
  12. #ifndef _MEDIA_VIDEOBUF2_V4L2_H
  13. #define _MEDIA_VIDEOBUF2_V4L2_H
  14. #include <linux/videodev2.h>
  15. #include <media/videobuf2-core.h>
  16. #if VB2_MAX_FRAME != VIDEO_MAX_FRAME
  17. #error VB2_MAX_FRAME != VIDEO_MAX_FRAME
  18. #endif
  19. #if VB2_MAX_PLANES != VIDEO_MAX_PLANES
  20. #error VB2_MAX_PLANES != VIDEO_MAX_PLANES
  21. #endif
  22. /**
  23. * struct vb2_v4l2_buffer - video buffer information for v4l2
  24. * @vb2_buf: video buffer 2
  25. * @flags: buffer informational flags
  26. * @field: enum v4l2_field; field order of the image in the buffer
  27. * @timecode: frame timecode
  28. * @sequence: sequence count of this frame
  29. * Should contain enough information to be able to cover all the fields
  30. * of struct v4l2_buffer at videodev2.h
  31. */
  32. struct vb2_v4l2_buffer {
  33. struct vb2_buffer vb2_buf;
  34. __u32 flags;
  35. __u32 field;
  36. struct v4l2_timecode timecode;
  37. __u32 sequence;
  38. };
  39. /*
  40. * to_vb2_v4l2_buffer() - cast struct vb2_buffer * to struct vb2_v4l2_buffer *
  41. */
  42. #define to_vb2_v4l2_buffer(vb) \
  43. container_of(vb, struct vb2_v4l2_buffer, vb2_buf)
  44. int vb2_querybuf(struct vb2_queue *q, struct v4l2_buffer *b);
  45. int vb2_reqbufs(struct vb2_queue *q, struct v4l2_requestbuffers *req);
  46. int vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create);
  47. int vb2_prepare_buf(struct vb2_queue *q, struct v4l2_buffer *b);
  48. int vb2_qbuf(struct vb2_queue *q, struct v4l2_buffer *b);
  49. int vb2_expbuf(struct vb2_queue *q, struct v4l2_exportbuffer *eb);
  50. int vb2_dqbuf(struct vb2_queue *q, struct v4l2_buffer *b, bool nonblocking);
  51. int vb2_streamon(struct vb2_queue *q, enum v4l2_buf_type type);
  52. int vb2_streamoff(struct vb2_queue *q, enum v4l2_buf_type type);
  53. int __must_check vb2_queue_init(struct vb2_queue *q);
  54. void vb2_queue_release(struct vb2_queue *q);
  55. unsigned int vb2_poll(struct vb2_queue *q, struct file *file,
  56. poll_table *wait);
  57. /*
  58. * The following functions are not part of the vb2 core API, but are simple
  59. * helper functions that you can use in your struct v4l2_file_operations,
  60. * struct v4l2_ioctl_ops and struct vb2_ops. They will serialize if vb2_queue->lock
  61. * or video_device->lock is set, and they will set and test vb2_queue->owner
  62. * to check if the calling filehandle is permitted to do the queuing operation.
  63. */
  64. /* struct v4l2_ioctl_ops helpers */
  65. int vb2_ioctl_reqbufs(struct file *file, void *priv,
  66. struct v4l2_requestbuffers *p);
  67. int vb2_ioctl_create_bufs(struct file *file, void *priv,
  68. struct v4l2_create_buffers *p);
  69. int vb2_ioctl_prepare_buf(struct file *file, void *priv,
  70. struct v4l2_buffer *p);
  71. int vb2_ioctl_querybuf(struct file *file, void *priv, struct v4l2_buffer *p);
  72. int vb2_ioctl_qbuf(struct file *file, void *priv, struct v4l2_buffer *p);
  73. int vb2_ioctl_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p);
  74. int vb2_ioctl_streamon(struct file *file, void *priv, enum v4l2_buf_type i);
  75. int vb2_ioctl_streamoff(struct file *file, void *priv, enum v4l2_buf_type i);
  76. int vb2_ioctl_expbuf(struct file *file, void *priv,
  77. struct v4l2_exportbuffer *p);
  78. /* struct v4l2_file_operations helpers */
  79. int vb2_fop_mmap(struct file *file, struct vm_area_struct *vma);
  80. int vb2_fop_release(struct file *file);
  81. int _vb2_fop_release(struct file *file, struct mutex *lock);
  82. ssize_t vb2_fop_write(struct file *file, const char __user *buf,
  83. size_t count, loff_t *ppos);
  84. ssize_t vb2_fop_read(struct file *file, char __user *buf,
  85. size_t count, loff_t *ppos);
  86. unsigned int vb2_fop_poll(struct file *file, poll_table *wait);
  87. #ifndef CONFIG_MMU
  88. unsigned long vb2_fop_get_unmapped_area(struct file *file, unsigned long addr,
  89. unsigned long len, unsigned long pgoff, unsigned long flags);
  90. #endif
  91. /* struct vb2_ops helpers, only use if vq->lock is non-NULL. */
  92. void vb2_ops_wait_prepare(struct vb2_queue *vq);
  93. void vb2_ops_wait_finish(struct vb2_queue *vq);
  94. #endif /* _MEDIA_VIDEOBUF2_V4L2_H */