vb2_qbuf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… vb2_qbuf β€” like, the kernel API manual page, bestie

okay so real quick: this is vb2_qbuf(9), straight out of the Kernel API Manual, and it's the function that queues a buffer from userspace. yes. that one. let's get into it πŸŽ€


✨ SYNOPSIS ✨

int vb2_qbuf (struct vb2_queue *q , struct media_device *mdev , struct v4l2_buffer *b );

three args, one int back, no cap. 🫢


🌸 ARGUMENTS 🌸

  • q β€” pointer to struct vb2_queue with the videobuf2 queue. that's your queue, she's the main character here πŸ‘‘
  • mdev β€” pointer to struct media_device, and heads up: it may be NULL. so don't panic if it's giving "nothing" πŸ’€
  • b β€” the buffer structure passed from userspace to the v4l2_ioctl_ops->vidioc_qbuf handler in the driver. this is the actual buffer the user is handing you, bestie πŸ™ˆ

πŸ”₯ DESCRIPTION πŸ”₯

Should be called from v4l2_ioctl_ops->vidioc_qbuf handler of a driver. literally that's its whole job, it's giving very "I have one purpose and I ate" πŸ’…

So here's what this function does, step by step:

  1. verifies the passed buffer ✨
  2. if b->request_fd is non-zero and mdev->ops->req_queue is set, then bind the buffer to the request
  3. if necessary, calls the vb2_ops->buf_prepare callback in the driver (if provided), in which driver-specific buffer initialization can be performed
  4. if streaming is on, queues the buffer in the driver by the means of the vb2_ops->buf_queue callback for processing

The return values from this function are intended to be directly returned from the v4l2_ioctl_ops->vidioc_qbuf handler in the driver. so like β€” don't overthink it, just pass that int straight on through 🧚


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/media/videobuf2-v4l2.h and honestly the whole friend group:


ok that's the whole page, go queue your buffers, ily, bye πŸ’–

mwah πŸ’‹ β€” this little number lives in ./include/media, dated October 2026, and it's vb2_qbuf(9) forever and always. slay. periodt. 🌈

πŸ“¦ where this page comes from