【v4l2】vb2_buffer和v4l2_buffer

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

@H_502_4@
165 
166 /**@H_502_4@
167 * struct vb2_buffer - represents a video buffer@H_502_4@
168  * @v4l2_buf: struct v4l2_buffer associated with this buffer; can@H_502_4@
169 * be read by the driver and relevant entries can be@H_502_4@
170 * changed by the driver in case of CAPTURE types@H_502_4@
171 * (such as timestamp)@H_502_4@
172 * @v4l2_planes: struct v4l2_planes associated with this buffer; can@H_502_4@
173
174
175 * (such as bytesused); NOTE that even for single-planar@H_502_4@
176 * types,the v4l2_planes[0] struct should be used@H_502_4@
177 * instead of v4l2_buf for filling bytesused - drivers@H_502_4@
178 * should use the vb2_set_plane_payload() function for that@H_502_4@
179  * @vb2_queue: the queue to which this driver belongs@H_502_4@
180 * @num_planes: number of planes in the buffer@H_502_4@
181 * on an internal driver queue@H_502_4@
182 * @state: current buffer state; do not change@H_502_4@183  * @queued_entry: entry on the queued buffers list,which holds all@H_502_4@
184  * buffers queued from userspace@H_502_4@
185  * @done_entry: entry on the list that stores all buffers ready to@H_502_4@
186  * be dequeued to userspace@H_502_4@
187 * @planes: private per-plane information; do not change@H_502_4@
188 */@H_502_4@
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 */@H_502_4@
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@H_502_4@
619 * @index: id number of the buffer@H_502_4@
620 * @type: enum v4l2_buf_type; buffer type (type == *_MPLANE for@H_502_4@
621 * multiplanar buffers);@H_502_4@622  * @bytesused: number of bytes occupied by data in the buffer (payload);@H_502_4@
623  * unused (set to 0) for multiplanar buffers@H_502_4@
624 * @flags: buffer informational flags@H_502_4@
625 * @field: enum v4l2_field; field order of the image in the buffer@H_502_4@
626 * @timestamp: frame timestamp@H_502_4@
627 * @timecode: frame timecode@H_502_4@
628 * @sequence: sequence count of this frame@H_502_4@
629 * @memory: enum v4l2_memory; the method,in which the actual video data is@H_502_4@
630 * passed@H_502_4@
631 * @offset: for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP;@H_502_4@
632 * offset from the start of the device memory for this plane,@H_502_4@
633 * (or a "cookie" that should be passed to mmap() as offset)@H_502_4@
634 * @userptr: for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR;@H_502_4@
635 * a userspace pointer pointing to this buffer@H_502_4@
636 * @fd: for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;@H_502_4@
637 * a userspace file descriptor associated with this buffer@H_502_4@
638 * @planes: for multiplanar buffers; userspace pointer to the array of plane@H_502_4@
639 * info structs for this buffer@H_502_4@
640 * @length: size in bytes of the buffer (NOT its payload) for single-plane@H_502_4@
641 * buffers (when type != *_MPLANE); number of elements in the@H_502_4@
642 * planes array for multi-plane buffers@H_502_4@
643 * @input: input number from which the video data has has been captured@H_502_4@
644 *@H_502_4@
645 * Contains data exchanged by application and driver using one of the Streaming@H_502_4@
646 * I/O methods.@H_502_4@
647
648 struct v4l2_buffer {
649         __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 */@H_502_4@
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相关文章