【v4l2】vb2_buffer和v4l2_buffer

来源:互联网 发布:javascript innerhtml 编辑:程序博客网 时间:2024/06/05 09:15
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 buffer168  * @v4l2_buf:           struct v4l2_buffer associated with this buffer; can169  *                      be read by the driver and relevant entries can be170  *                      changed by the driver in case of CAPTURE types171  *                      (such as timestamp)172  * @v4l2_planes:        struct v4l2_planes associated with this buffer; can173  *                      be read by the driver and relevant entries can be174  *                      changed by the driver in case of CAPTURE types175  *                      (such as bytesused); NOTE that even for single-planar176  *                      types, the v4l2_planes[0] struct should be used177  *                      instead of v4l2_buf for filling bytesused - drivers178  *                      should use the vb2_set_plane_payload() function for that179  * @vb2_queue:          the queue to which this driver belongs180  * @num_planes:         number of planes in the buffer181  *                      on an internal driver queue182  * @state:              current buffer state; do not change183  * @queued_entry:       entry on the queued buffers list, which holds all184  *                      buffers queued from userspace185  * @done_entry:         entry on the list that stores all buffers ready to186  *                      be dequeued to userspace187  * @planes:             private per-plane information; do not change188  */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;199 200         struct list_head        queued_entry;201         struct list_head        done_entry;202 203         struct vb2_plane        planes[VIDEO_MAX_PLANES];204 };

videodev2.h,用户应用程序与驱动交互:
617 /**618  * struct v4l2_buffer - video buffer info619  * @index:      id number of the buffer620  * @type:       enum v4l2_buf_type; buffer type (type == *_MPLANE for621  *              multiplanar buffers);622  * @bytesused:  number of bytes occupied by data in the buffer (payload);623  *              unused (set to 0) for multiplanar buffers624  * @flags:      buffer informational flags625  * @field:      enum v4l2_field; field order of the image in the buffer626  * @timestamp:  frame timestamp627  * @timecode:   frame timecode628  * @sequence:   sequence count of this frame629  * @memory:     enum v4l2_memory; the method, in which the actual video data is630  *              passed631  * @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 buffer636  * @fd:         for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF;637  *              a userspace file descriptor associated with this buffer638  * @planes:     for multiplanar buffers; userspace pointer to the array of plane639  *              info structs for this buffer640  * @length:     size in bytes of the buffer (NOT its payload) for single-plane641  *              buffers (when type != *_MPLANE); number of elements in the642  *              planes array for multi-plane buffers643  * @input:      input number from which the video data has has been captured644  *645  * Contains data exchanged by application and driver using one of the Streaming646  * I/O methods.647  */648 struct v4l2_buffer {649         __u32                   index;650         __u32                   type;651         __u32                   bytesused;652         __u32                   flags;653         __u32                   field;654         struct timeval          timestamp;655         struct v4l2_timecode    timecode;656         __u32                   sequence;657 658         /* memory location */659         __u32                   memory;660         union {661                 __u32           offset;662                 unsigned long   userptr;663                 struct v4l2_plane *planes;664                 __s32           fd;665         } m;666         __u32                   length;667         __u32                   reserved2;668         __u32                   reserved;669 };
vb2_buf维护了两个线性链表,可以参考 http://blog.sina.com.cn/s/blog_602f87700101bmvu.html

0 0
原创粉丝点击