FBDEV HELPERS(9)
π 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 π
drm_fb_helper_preparemust be called first β it initializes the minimum required to make hotplug detection work. periodt.- Drivers also need to make sure they properly set up the
drm_mode_config.funcsmember. - After calling
drm_kms_helper_poll_initit is safe to enable interrupts and start processing hotplug events. π₯ - At the same time, drivers should initialize all the modeset objects β the CRTCs, encoders and connectors.
- To finish up the fbdev helper initialization, you call
drm_fb_helper_init. - 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 π
drm_fb_helper_restore_fbdev_mode_unlocked(9)drm_fb_helper_blank(9)drm_fb_helper_prepare(9)drm_fb_helper_unprepare(9)drm_fb_helper_init(9)drm_fb_helper_unregister_info(9)drm_fb_helper_fini(9)drm_fb_helper_deferred_io(9)drm_fb_helper_set_suspend(9)drm_fb_helper_set_suspend_unlocked(9)drm_fb_helper_setcmap(9)drm_fb_helper_ioctl(9)drm_fb_helper_check_var(9)drm_fb_helper_set_par(9)drm_fb_helper_pan_display(9)drm_fb_helper_fill_info(9)drm_fb_helper_initial_config(9)drm_fb_helper_hotplug_event(9)drm_fb_helper_gem_is_fb(9)
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
- 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