vb2_dqbuf(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… vb2_dqbuf β€” like, the Kernel API Manual page, bestie ✨

Okay so welcome to vb2_dqbuf(9), bestie. Yes that's the whole title, and yes it's from the Kernel API Manual. Sit down, grab a strawberry πŸ“, we're learning how to dequeue a buffer to userspace.


🌸 NAME 🌸

vb2_dqbuf β€” Dequeue a buffer to the userspace. That's it, that's the whole vibe. It hands a buffer back to userspace. Iconic behavior, no notes. πŸ‘‘


✨ SYNOPSIS ✨

int vb2_dqbuf (struct vb2_queue *q , struct v4l2_buffer *b , bool
nonblocking );

Three args, one int coming back at you. Locked in. πŸ”’


πŸŽ€ ARGUMENTS πŸŽ€

  • q β€” pointer to struct vb2_queue with the videobuf2 queue. Like, this is the queue. Your main character queue. 🫢
  • b β€” the buffer structure passed from userspace into the driver's v4l2_ioctl_ops->vidioc_dqbuf handler. It literally did the little journey from userspace to you, respect it. πŸ’«
  • nonblocking β€” if true, this call will not sleep waiting for a buffer when there's, like, no buffers ready for dequeuing present. Zero patience energy, lowkey. Normally the driver would be passing (file->f_flags & O_NONBLOCK) here. fr fr. 😴🚫

πŸ’– DESCRIPTION πŸ’–

So this one should be called from the v4l2_ioctl_ops->vidioc_dqbuf ioctl handler of a driver. That's the spot. That's where it lives. 🏠

This function does the following, in order, and honestly it ate:

  1. verifies the passed buffer β€” vibe check first, always βœ…
  2. calls the vb2_ops->buf_finish callback in the driver (if provided), in which the driver can perform any additional operations that may be required before returning the buffer to userspace, such as cache sync. So like, the driver gets its little moment to do extra stuff before the buffer goes home. 🧚
  3. the buffer struct members are filled with relevant information for the userspace. Filled! Stuffed! Delivered! πŸ“¦
The return values from this function are intended to be directly returned from the v4l2_ioctl_ops->vidioc_dqbuf handler in the driver. Do not be weird about it, just return them. βœ‹

πŸ¦‹ SEE ALSO πŸ¦‹

Go look at the kernel file ./include/media/videobuf2-v4l2.h, plus all these besties:

The whole friend group, honestly. iykyk. 🌈


That's the page!! Sourced from ./include/media, dated October 2026 β€” so like, mark your calendars bestie, mwah πŸ’‹, go dequeue some buffers, you're gonna slay πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from