DRM_IOCTL_MODE_GETFB2(9)
β¨ 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_idas 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 π₯
- Kernel file
./tools/perf/trace/beauty/include/uapi/drm/drm.h struct drm_gem_close(9)struct drm_gem_flink(9)struct drm_gem_open(9)struct drm_gem_change_handle(9)DRM_CAP_DUMB_BUFFER(9)DRM_CAP_VBLANK_HIGH_CRTC(9)DRM_CAP_DUMB_PREFERRED_DEPTH(9)DRM_CAP_DUMB_PREFER_SHADOW(9)DRM_CAP_PRIME(9)DRM_PRIME_CAP_IMPORT(9)DRM_PRIME_CAP_EXPORT(9)DRM_CAP_TIMESTAMP_MONOTONIC(9)DRM_CAP_ASYNC_PAGE_FLIP(9)DRM_CAP_CURSOR_WIDTH(9)DRM_CAP_CURSOR_HEIGHT(9)DRM_CAP_ADDFB2_MODIFIERS(9)DRM_CAP_PAGE_FLIP_TARGET(9)DRM_CAP_CRTC_IN_VBLANK_EVENT(9)DRM_CAP_SYNCOBJ(9)DRM_CAP_SYNCOBJ_TIMELINE(9)DRM_CAP_ATOMIC_ASYNC_PAGE_FLIP(9)DRM_CLIENT_CAP_STEREO_3D(9)DRM_CLIENT_CAP_UNIVERSAL_PLANES(9)DRM_CLIENT_CAP_ATOMIC(9)DRM_CLIENT_CAP_ASPECT_RATIO(9)DRM_CLIENT_CAP_WRITEBACK_CONNECTORS(9)DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT(9)DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE(9)struct drm_syncobj_eventfd(9)DRM_IOCTL_GEM_CLOSE(9)DRM_IOCTL_PRIME_HANDLE_TO_FD(9)DRM_IOCTL_PRIME_FD_TO_HANDLE(9)DRM_IOCTL_MODE_RMFB(9)DRM_IOCTL_MODE_CREATE_DUMB(9)DRM_IOCTL_SYNCOBJ_EVENTFD(9)DRM_IOCTL_MODE_CLOSEFB(9)DRM_IOCTL_SET_CLIENT_NAME(9)DRM_IOCTL_GEM_CHANGE_HANDLE(9)struct drm_event(9)DRM_EVENT_VBLANK(9)DRM_EVENT_FLIP_COMPLETE(9)DRM_EVENT_CRTC_SEQUENCE(9)
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
- 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