【v4l2】vb2_buffer和v4l2_buffer

前端之家收集整理的这篇文章主要介绍了【v4l2】vb2_buffer和v4l2_buffer前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
videobuf2-core.h中的vb2_buffer,记录了v4l2_buffer ,驱动可以对vb2_buffer的v4l2_buffer进行操控,
vb2_buffer是v4l2框架层的代码,而v4l2_buffer也是用户空间的应用程序,可以读取的一个数据结构。
videobuf2-core.h:

165 
166 /**
167 * struct vb2_buffer - represents a video buffer
168  * @v4l2_buf: struct v4l2_buffer associated with this buffer; can
169 * be read by the driver and relevant entries can be
170 * changed by the driver in case of CAPTURE types
171 * (such as timestamp)
172 * @v4l2_planes: struct v4l2_planes associated with this buffer; can
173
174
175 * (such as bytesused); NOTE that even for single-planar
176 * types,the v4l2_planes[0] struct should be used
177 * instead of v4l2_buf for filling bytesused - drivers
178 * should use the vb2_set_plane_payload() function for that
179  * @vb2_queue: the queue to which this driver belongs
180 * @num_planes: number of planes in the buffer
181 * on an internal driver queue
182 * @state: current buffer state; do not change183  * @queued_entry: entry on the queued buffers list,which holds all
184  * buffers queued from userspace
185  * @done_entry: entry on the list that stores all buffers ready to
186  * be dequeued to userspace
187 * @planes: private per-plane information; do not change
188 */
189 struct vb2_buffer {
190         struct v4l2_buffer      v4l2_buf;
191         struct v4l2_plane       v4l2_planes[VIDEO_MAX_PLANES];
192 
193         struct vb2_queue        *vb2_queue;
194 
195         unsigned int            num_planes;
196 
197/* Private: internal use only */
198         enum vb2_buffer_state   state;
199200         struct list_head        queued_entry;
201         struct list_head        done_entry;
202 
203         struct vb2_plane        planes[];
204 };

 
videodev2.h,用户应用程序与驱动交互:
617
618 * struct v4l2_buffer - video buffer info
619 * @index: id number of the buffer
620 * @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for
621 * multiplanar buffers);622  * @bytesused: number of bytes occupied by data in the buffer (payload);
623  * unused (set to 0) for multiplanar buffers
624 * @flags: buffer informational flags
625 * @field: enum v4l2_field; field order of the image in the buffer
626 * @timestamp: frame timestamp
627 * @timecode: frame timecode
628 * @sequence: sequence count of this frame
629 * @memory: enum v4l2_memory; the method,in which the actual video data is
630 * passed
@L_403_66@ * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;
632 * offset from the start of the device memory for this plane,
633 * (or a "cookie" that should be passed to mmap() as offset)
634 * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;
635 * a userspace pointer pointing to this buffer
636 * @fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;
637 * a userspace file descriptor associated with this buffer
638 * @planes: for multiplanar buffers; userspace pointer to the array of plane
639 * info structs for this buffer
640 * @length: size in bytes of the buffer (NOT its payload) for single-plane
641 * buffers (when type != *_MPLANE); number of elements in the
642 * planes array for multi-plane buffers
643 * @input: input number from which the video data has has been captured
644 *
645 * Contains data exchanged by application and driver using one of the Streaming
646 * I/O methods.
647
648 struct v4l2_buffer {
@L_502_85@         __u32                   index;
650                   type;
651                   bytesused;
652                   flags;
653                   field;
654         struct timeval          timestamp;
655         struct v4l2_timecode    timecode;
656                   sequence;
657 
658         /* memory location */
659                   memory;
660         union {
661                            offset;
662                 unsigned long   userptr;
663                 struct  *planes;
664                 __s32           fd;
665         } m;
666                   length;
667                   reserved2;
668                   reserved;
669 };
vb2_buf维护了两个线性链表,可以参考 http://blog.sina.com.cn/s/blog_602f87700101bmvu.html

猜你在找的VB相关文章