STRUCT V4L2_BUFFER(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

struct v4l2_buffer(9) πŸ’…

okay bestie, welcome to the Kernel API Manual page for struct v4l2_buffer β€” literally the video buffer info struct, and yes it's giving very "main character data exchange" energy ✨


NAME πŸŽ€

struct v4l2_buffer β€” video buffer info

SYNOPSIS πŸ¦‹

struct v4l2_buffer {
    __u32 index;
    __u32 type;
    __u32 bytesused;
    __u32 flags;
    __u32 field;
  #ifdef __KERNEL__;
    struct __kernel_v4l2_timeval timestamp;
  #else;
    struct timeval          timestamp;
  #endif;
    struct v4l2_timecode    timecode;
    __u32 sequence;
    __u32 memory;
    union {
      __u32 offset;
      unsigned long   userptr;
      struct v4l2_plane *planes;
      __s32 fd;
    } m;
    __u32 length;
    __u32 reserved2;
    union {
      __s32 request_fd;
      __u32 reserved;
    };
 };

Members πŸ’–

  • index β€” id number of the buffer
  • type β€” enum v4l2_buf_type; buffer type (type == *_MPLANE for multiplanar buffers)
  • bytesused β€” number of bytes occupied by data in the buffer (payload); unused (set to 0) for multiplanar buffers
  • flags β€” buffer informational flags
  • field β€” enum v4l2_field; field order of the image in the buffer
  • timestamp β€” frame timestamp
  • timestamp β€” frame timestamp (yes bestie, it really is listed twice on this page β€” we're keeping both, no cap)
  • timecode β€” frame timecode
  • sequence β€” sequence count of this frame
  • memory β€” enum v4l2_memory; the method, in which the actual video data is passed
  • m β€” union of offset, userptr, planes and fd
  • m.offset β€” for non-multiplanar buffers with memory == V4L2_MEMORY_MMAP; offset from the start of the device memory for this plane, (or a "cookie" that should be passed to mmap as offset)
  • m.userptr β€” for non-multiplanar buffers with memory == V4L2_MEMORY_USERPTR; a userspace pointer pointing to this buffer
  • m.planes β€” for multiplanar buffers; userspace pointer to the array of plane info structs for this buffer
  • m.fd β€” for non-multiplanar buffers with memory == V4L2_MEMORY_DMABUF; a userspace file descriptor associated with this buffer
  • length β€” size in bytes of the buffer (NOT its payload) for single-plane buffers (when type != *_MPLANE); number of elements in the planes array for multi-plane buffers
  • reserved2 β€” drivers and applications must zero this field
  • {unnamed_union} β€” anonymous
  • request_fd β€” fd of the request that this buffer should use
  • reserved β€” for backwards compatibility with applications that do not know about request_fd

Description 🌸

Contains data exchanged by application and driver using one of the Streaming I/O methods. That's the whole vibe: this struct is the little messenger carrying buffer info back and forth πŸ’Œ

SEE ALSO πŸ”₯

Kernel file ./include/uapi/linux/videodev2.h, plus these iconic little references:

  • struct v4l2_capability(9)
  • struct v4l2_plane(9)
  • v4l2_timeval_to_ns(9)
  • struct v4l2_exportbuffer(9)
  • struct v4l2_selection(9)
  • struct v4l2_plane_pix_format(9)
  • struct v4l2_pix_format_mplane(9)
  • struct v4l2_sdr_format(9)
  • struct v4l2_meta_format(9)
  • struct v4l2_format(9)
  • struct v4l2_event_motion_det(9)
  • struct v4l2_create_buffers(9)
  • struct v4l2_remove_buffers(9)

mwah πŸ’‹ this page's source/version footer lives in ./include/uapi/linux, dated October 2026 β€” and honestly? iconic. periodt. 🫢

πŸ“¦ where this page comes from