vb2_qbuf(9)
π 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 tostruct vb2_queuewith the videobuf2 queue. that's your queue, she's the main character here πmdevβ pointer tostruct 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 thev4l2_ioctl_ops->vidioc_qbufhandler 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:
- verifies the passed buffer β¨
- if
b->request_fdis non-zero andmdev->ops->req_queueis set, then bind the buffer to the request - if necessary, calls the
vb2_ops->buf_preparecallback in the driver (if provided), in which driver-specific buffer initialization can be performed - if streaming is on, queues the buffer in the driver by the means of the
vb2_ops->buf_queuecallback 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:
struct vb2_v4l2_buffer(9)vb2_find_buffer(9)vb2_querybuf(9)vb2_reqbufs(9)vb2_create_bufs(9)vb2_prepare_buf(9)vb2_expbuf(9)vb2_dqbuf(9)vb2_streamon(9)vb2_streamoff(9)vb2_queue_init(9)vb2_queue_init_name(9)vb2_queue_release(9)vb2_queue_change_type(9)vb2_poll(9)vb2_queue_is_busy(9)vb2_video_unregister_device(9)
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
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms