DRM_IOCTL_MODE_GETFB2(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ DRM_IOCTL_MODE_GETFB2 ✨

okay so bestie, welcome to the kernel API manual page for DRM_IOCTL_MODE_GETFB2 πŸ¦‹ β€” like, the actual manual page, the one from the Kernel API Manual. no cap, this is the whole thing, so let's get into it πŸ’…


🌸 NAME 🌸

DRM_IOCTL_MODE_GETFB2 β€” get framebuffer metadata πŸ’– (yes, that's literally it, that's the whole job, and honestly? iconic.)


πŸŽ€ SYNOPSIS πŸŽ€

DRM_IOCTL_MODE_GETFB2

that's it. that's the synopsis. no args in the header, no drama, just vibes ✨


πŸ’œ DESCRIPTION πŸ’œ

okay so what does this thing do? it queries metadata about a framebuffer πŸ–ΌοΈ.

here's the deal, and pay attention because this part is important:

  • user-space fills drm_mode_fb_cmd2.fb_id as the input
  • and then the kernel fills the rest of the struct as the output ✨

like, you give it one little field and it hands you back everything else. main character energy, honestly πŸ‘‘


🫢 if you're DRM master or you have CAP_SYS_ADMIN 🫢

if the client is DRM master or has CAP_SYS_ADMIN, then drm_mode_fb_cmd2.handles gets filled with GEM buffer handles πŸŽ€.

and listen β€” fresh new GEM handles are always returned, even if another GEM handle referring to the same memory object already exists on the DRM file description. like, it will not reuse, it will not share, it's giving brand new handle every time 😭

the caller is responsible for removing the new handles, e.g. via the DRM_IOCTL_GEM_CLOSE IOCTL. so like... clean up after yourself, bestie, fr fr 🧹

the same new handle will be returned for multiple planes in case they use the same memory object. so don't go double-freeing, iykyk πŸ’€

planes are valid until one has a zero handle β€” this can be used to compute the number of planes. cute little sentinel, honestly 🌸


πŸ™ˆ otherwise (no master, no CAP_SYS_ADMIN) πŸ™ˆ

otherwise, drm_mode_fb_cmd2.handles will be zeroed and planes are valid until one has a zero drm_mode_fb_cmd2.pitches ✨

so like, different sentinel, same energy. you just gotta know which one you're checking for, k? πŸ’…


🌈 about modifiers 🌈

if the framebuffer has a format modifier, DRM_MODE_FB_MODIFIERS will be set in drm_mode_fb_cmd2.flags and drm_mode_fb_cmd2.modifier will contain the modifier βœ…

otherwise, user-space must ignore drm_mode_fb_cmd2.modifier. like, ignore it. do not look at it. it's not for you πŸ™ˆ


πŸ“ the pro move πŸ“

to obtain DMA-BUF FDs for each plane without leaking GEM handles, user-space can export each handle via DRM_IOCTL_PRIME_HANDLE_TO_FD, then immediately close each unique handle via DRM_IOCTL_GEM_CLOSE 🎯

⚠️ and make sure to not double-close handles which are specified multiple times in the array. like for real for real, that's the one thing that will ruin your whole day πŸ˜­πŸ’€

πŸ”₯ SEE ALSO πŸ”₯


okay that's the whole page, bestie, you ate that πŸ«ΆπŸ’œ

sign-off time πŸŽ€ β€” this lil beauty came from ./tools/perf/trace/beauty/incl... (the source path got all truncated, not my fault 😭) and it's dated October 2026, living under the DRM_IOCTL_MODE_GETFB2(9) name in the Kernel API Manual. slay βœ¨πŸ’…

πŸ“¦ where this page comes from