drm_gem_fb_create(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… drm_gem_fb_create β€” kernel API manual, bestie edition ✨

Okay so real talk, this is drm_gem_fb_create(9) from the Kernel API Manual, and it's genuinely one of those little helper functions that just gets it. Let's go 🫢


✨ NAME ✨

drm_gem_fb_create β€” the helper function for your &drm_mode_config_funcs.fb_create callback. That's the whole vibe. She's a helper, she's a callback plug-in, she's iconic πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

struct drm_framebuffer * drm_gem_fb_create (struct drm_device *dev ,
   struct drm_file *file , const struct drm_format_info *info , const
   struct drm_mode_fb_cmd2 *mode_cmd );

Like, look at her signature. Four args, one framebuffer pointer coming back at you. Periodt ⭐


🌸 ARGUMENTS 🌸

  • dev β€” the DRM device. Main character energy, obviously πŸ‘‘
  • file β€” the DRM file that holds the GEM handle(s) backing the framebuffer. She's the one holding the handles, iykyk 🫢
  • info β€” pixel format information. All the format deets live here πŸŽ€
  • mode_cmd β€” metadata straight from the userspace framebuffer creation request. Handed over by userspace, no cap πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

So this function creates a brand-new framebuffer object, and that object is described by drm_mode_fb_cmd2. And that description? It includes the handles for the buffer(s) backing the framebuffer. Like, handles included, bestie, that's the whole point πŸ’–

If your hardware has special alignment or pitch requirements, lowkey you have to check those before calling this function β€” she's not doing that for you. What she does do is buffer size validation, and she does it. Use drm_gem_fb_create_with_dirty if you need framebuffer flushing instead πŸ”₯

Drivers can totally use this as their drm_mode_config_funcs.fb_create callback. And the ADDFB2 IOCTL calls into this callback. That's the pipeline, and she ate 🌈


πŸ’€ RETURN πŸ’€

  • A pointer to a drm_framebuffer on success xoxo ✨
  • Or an error pointer on failure πŸ™ˆ (check it, don't ignore it, fr fr)

🧚 SEE ALSO 🧚

Go read the Kernel file ./drivers/gpu/drm/drm_gem_framebuffer_helper.c overview(9) for the full lore, plus all her besties:


πŸ’€ one thing before you dip: everything above is from ./drivers/gpu/drm, dated October 2026, and the page itself is drm_gem_fb_create(9). Slay, bye πŸŽ€βœ¨πŸ’œ
πŸ“¦ where this page comes from