STRUCT V4L2_PLANE(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct v4l2_plane β€” plane info for multi-planar buffers

okay bestie, welcome to the Kernel API Manual ✨ this one's short but it's important, so pay attention 🫢 It's literally the struct that holds the deets for one single plane inside a multi-planar buffer. no cap.


🌸 SYNOPSIS 🌸

struct v4l2_plane {
    __u32 bytesused;
    __u32 length;
    union {
      __u32 mem_offset;
      unsigned long   userptr;
      __s32 fd;
    } m;
    __u32 data_offset;
    __u32 reserved[11];
 };

like… look at her. she's gorgeous. πŸ’–


πŸŽ€ Members πŸŽ€

  • bytesused β€” the number of bytes that data actually occupies in the plane, aka the payload. the real content. the main character energy 🫢
  • length β€” the size of this plane itself, in bytes. and bestie, read this twice: it is NOT the payload. it's the container, not the snack. πŸ’€
  • m β€” the union of mem_offset, userptr and fd. she contains multitudes πŸ’…
  • m.mem_offset β€” when the memory in the associated struct v4l2_buffer is V4L2_MEMORY_MMAP, this equals the offset from the start of the device memory for this plane β€” or it's a "cookie" that should be passed to mmap called on the video node πŸͺ lowkey iconic
  • m.userptr β€” when the memory is V4L2_MEMORY_USERPTR, this is a userspace pointer pointing right at this plane πŸ”₯
  • m.fd β€” when the memory is V4L2_MEMORY_DMABUF, this is a userspace file descriptor associated with this plane πŸ¦‹
  • data_offset β€” offset in the plane to the start of the data. usually 0, unless there's a header sitting in front of the data πŸ™ˆ (there's always someone in front of you in line, fr fr)
  • reserved β€” drivers and applications must zero this array. not "should", not "maybe", must. zero it out bestie 😭

✨ Description ✨

so multi-planar buffers are made of one or more planes, right? 🌈 like, an YCbCr buffer with two planes can have one plane for Y, and another for the interleaved CbCr components. that's the vibe πŸ’œ

Each plane can live in a separate memory buffer β€” or even in a completely separate memory node (e.g. in embedded devices πŸ‘‘). literally independent. they don't even have to be in the same neighborhood. slay.


πŸ”₯ SEE ALSO πŸ”₯

Kernel file ./include/uapi/linux/videodev2.h β€” go read the source, iykyk πŸ“– and also go say hi to her friends:

  • struct v4l2_capability(9)
  • struct v4l2_buffer(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)

and that's the whole page, bestie πŸ’« this one lives in ./include/uapi/linux, dated October 2026, and it's filed under struct v4l2_plane(9) β€” go forth and zero your reserved array πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from