FBDEV HELPERS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… fbdev helpers

okay bestie, welcome to fbdev helpers β€” page 9 of the Kernel API Manual. yes this is real kernel documentation and yes we're gonna get through it together 🫢


✨ DESCRIPTION ✨

So the fb helper functions are literally here to give you an fbdev on top of a drm kernel mode setting driver β€” that's the whole gig. The way that they work, you can use them mostly independently from the crtc helper functions that lots of drivers use to implement the kernel mode setting interfaces. cute, right? πŸŽ€

⚠️ but listen β€” if your driver uses one of the shared memory managers (TTM, SHMEM, DMA), don't use these, okay? use the corresponding fbdev emulation instead. iykyk πŸ’…

For suspend/resume, lowkey just consider using drm_mode_config_helper_suspend and drm_mode_config_helper_resume β€” they take care of fbdev as well, so you don't have to 😌✨

And every other function exported by the fb helper library? those are there so the driver can use them to implement the fbdev driver interface. slay.


πŸ¦‹ hotplug detection (the tricky part)

It is possible β€” though perhaps somewhat tricky β€” to implement race-free hotplug detection using the fbdev helpers. here's the order, bestie, do not freestyle it πŸ™ˆ

  1. drm_fb_helper_prepare must be called first β€” it initializes the minimum required to make hotplug detection work. periodt.
  2. Drivers also need to make sure they properly set up the drm_mode_config.funcs member.
  3. After calling drm_kms_helper_poll_init it is safe to enable interrupts and start processing hotplug events. πŸ”₯
  4. At the same time, drivers should initialize all the modeset objects β€” the CRTCs, encoders and connectors.
  5. To finish up the fbdev helper initialization, you call drm_fb_helper_init.
  6. To probe for all attached displays and set up an initial configuration using the detected hardware, drivers should call drm_fb_helper_initial_config.

that's the whole pipeline, no cap πŸ’œ


πŸ“ the dirty work (literally)

If drm_framebuffer_funcs.dirty is set, then these functions:

drm_fb_helper_{cfb,sys}_{write,fillrect,copyarea,imageblit}

will accumulate changes and schedule drm_fb_helper.dirty_work to run right away. ⭐

This worker then calls the dirty function, ensuring that it will always run in process context β€” because the fb_*() function could be running in atomic context, and we simply cannot have that πŸ’€

And if drm_fb_helper_deferred_io is used as the deferred_io callback, it will also schedule dirty_work, this time with the damage collected from the mmap page writes. iconic behaviour honestly πŸ‘‘


🫢 SEE ALSO 🫢

Kernel file ./drivers/gpu/drm/drm_fb_helper.c β€” go read it, it's giving main character energy 🌈


and that's the page!! 🧚 this little beauty lives in ./drivers/gpu/drm and it's dated October 2026 β€” that's the version and the date, bestie, we mention them and we move on πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from