vb2_prepare_buf(9)
π
vb2_prepare_buf(9) β Kernel API Manual edition π
π NAME π
vb2_prepare_buf β Pass ownership of a buffer from userspace to the kernel. That's the whole serve: userspace hands the buffer over, kernel takes the wheel. π
β¨ SYNOPSIS β¨
okay bestie, the call looks exactly like this, no cap:
int vb2_prepare_buf (struct vb2_queue *q , struct media_device *mdev ,
struct v4l2_buffer *b );
π«Ά ARGUMENTS π«Ά
qβ pointer tostruct vb2_queuewith videobuf2 queue. This is the videobuf2 queue situation, iconic.mdevβ pointer tostruct media_device, may beNULL. Not a typo, bestie,NULLis allowed here. πbβ buffer structure passed from userspace tov4l2_ioctl_ops->vidioc_prepare_bufhandler in driver.
π₯ DESCRIPTION π₯
Should be called from the v4l2_ioctl_ops->vidioc_prepare_buf ioctl handler of a driver. Like, that's its whole main-character entrance. β¨
This function:
- verifies the passed buffer.
- calls
vb2_ops->buf_preparecallback in the driver (if provided), in which driver-specific buffer initialization can be performed. - if
b->request_fdis non-zero andmdev->ops->req_queueis set, then bind the prepared buffer to the request.
The return values from this function are intended to be directly returned from v4l2_ioctl_ops->vidioc_prepare_buf handler in driver. So don't get creative with them β hand them straight back. π
π SEE ALSO π
go read these too, they're all part of the lore:
- Kernel file
./include/media/videobuf2-v4l2.hstructvb2_v4l2_buffer(9) vb2_find_buffer(9)vb2_querybuf(9)vb2_reqbufs(9)vb2_create_bufs(9)vb2_qbuf(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)
mwah π β source/version ./include/media, date October 2026, page vb2_prepare_buf(9). bye bestie, go prepare those buffers π«Ά
π¦ 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