On Wednesday, March 19, 2025 3:44:59 AM EDT Thomas Zimmermann wrote:
> This series simplifies the existing ofdrm and simepldrm drivers,
> and adds new drivers for EFI- and VESA-based framebuffers. Existing
> drivers for system framebuffers, ofdrm and simpledrm, share much of
> their mode-setting pipeline. The major difference between the two
> drivers is in how they retrieve the framebuffer from the systems.
> Hence, it makes sense to share some of the pipeline implementation.
> With the shared helpers in place, we can then add dedicated drivers
> for EFI and VESA easily.
>
> Patches 1 to 3 clean up obsolete artifacts from ofdrm and simpledrm.
>
> Patch 4 moves both drivers from tiny/ into their own subdirectory
> sysfb/. The name aligns with the naming in drivers/firmware/sysfb.c
> to signal the connection. It's the firmware code that creates most
> of the system-framebuffer devices that these drivers operate on. The
> patch also adds a separate menu in Kconfig.
>
> Patches 5 to 11 unify the mode-setting pipeline between ofdrm and
> simpledrm. Either both drivers already use the same implementation
> or they can easily do so. There've been previous attempts to unify
> some of the drivers' code, but with little success. This time the
> helpers will be shared among 4 drivers, so it's already much more
> successful than before.
>
> Patch 12 adds EDID support to ofdrm. The EDID data can be found in
> some Macintosh's DeviceTree next to the framebuffer configuration.
> EDID support will be useful for EFI and VESA as well.
>
> Patch 13 adds another helper for screen_info that will be required
> by EFI and VESA drivers.
>
> Patch 14 and 15 add efidrm, a DRM driver that operates on EFI-provided
> framebuffers. It uses the shared sysfb helpers. The immediate benefit
> over simpledrm is the support for EFI's various types of memory caching
> on the framebuffer. Simpledrm only supported WriteCombine caching.
> There's also EDID support if the kernel's edid_info has been initialized.
> This feature needs to be implemented in the kernel's efistub library.
>
> Patches 16 to 18 add vesadrm, a DRM driver that operates in VESA-
> provided framebuffers. It is very much like efidrm, but tailored
> towards VESA features. It has EDID support and there's a patch at [1]
> for grub to provide the data as part of the kernel's boot parameters.
> Vesadrm also supports gamma ramps. Together with EDID, this allows
> for gamma correction and night mode. Gnome already does that.
>
> Future directions: Efidrm requires EDID data that has to be provided
> by the efistub library. There is an EFI call to do so. Vesadrm currently
> requires a discrete color mode. Support for palette modes can be added
> later. There's still a bit of code duplication among palette handling.
> We have more drivers that use similar code for palette LUTs, such as
> ast and mgag200. We should try to provide generic palette helpers for
> all these drivers.
>
> This series has been tested on various devices that require the provided
> drivers.
>
> [1]
> https://build.opensuse.org/projects/home:tdz:branches:Base:System/packages/grub2/files/grub2-provide-edid.patch?expand=1
>
> Thomas Zimmermann (18):
> drm/ofdrm: Remove struct ofdrm_device.pdev
> drm/ofdrm: Open-code drm_simple_encoder_init()
> drm/simpledrm: Remove struct simpledrm_device.nformats
> drm: Move sysfb drivers into separate subdirectory
> drm/sysfb: Add struct drm_sysfb_device
> drm/sysfb: Provide single mode-init helper
> drm/sysfb: Merge mode-config functions
> drm/sysfb: Merge connector functions
> drm/sysfb: Maintain CRTC state in struct drm_sysfb_crtc_state
> drm/sysfb: Merge CRTC functions
> drm/sysfb: Merge primary-plane functions
> drm/sysfb: ofdrm: Add EDID support
> firmware: sysfb: Move bpp-depth calculation into screen_info helper
> drm/sysfb: Add efidrm for EFI displays
> drm/sysfb: efidrm: Add EDID support
> drm/sysfb: Add vesadrm for VESA displays
> drm/sysfb: vesadrm: Add EDID support
> drm/sysfb: vesadrm: Add gamma correction
>
> MAINTAINERS | 3 +-
> drivers/firmware/sysfb_simplefb.c | 31 +-
> drivers/gpu/drm/Kconfig | 2 +
> drivers/gpu/drm/Makefile | 1 +
> drivers/gpu/drm/sysfb/Kconfig | 76 +++
> drivers/gpu/drm/sysfb/Makefile | 8 +
> drivers/gpu/drm/sysfb/drm_sysfb_helper.c | 319 ++++++++++
> drivers/gpu/drm/sysfb/drm_sysfb_helper.h | 136 ++++
> drivers/gpu/drm/sysfb/efidrm.c | 495 +++++++++++++++
> drivers/gpu/drm/{tiny => sysfb}/ofdrm.c | 364 ++---------
> drivers/gpu/drm/{tiny => sysfb}/simpledrm.c | 237 +------
> drivers/gpu/drm/sysfb/vesadrm.c | 660 ++++++++++++++++++++
> drivers/gpu/drm/tiny/Kconfig | 32 -
> drivers/gpu/drm/tiny/Makefile | 2 -
> drivers/video/screen_info_generic.c | 36 ++
> include/linux/screen_info.h | 9 +
> include/video/pixel_format.h | 41 ++
> 17 files changed, 1885 insertions(+), 567 deletions(-)
> create mode 100644 drivers/gpu/drm/sysfb/Kconfig
> create mode 100644 drivers/gpu/drm/sysfb/Makefile
> create mode 100644 drivers/gpu/drm/sysfb/drm_sysfb_helper.c
> create mode 100644 drivers/gpu/drm/sysfb/drm_sysfb_helper.h
> create mode 100644 drivers/gpu/drm/sysfb/efidrm.c
> rename drivers/gpu/drm/{tiny => sysfb}/ofdrm.c (75%)
> rename drivers/gpu/drm/{tiny => sysfb}/simpledrm.c (76%)
> create mode 100644 drivers/gpu/drm/sysfb/vesadrm.c
> create mode 100644 include/video/pixel_format.h
>
>
FYI When this gets merged,
https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/hw/xfree86/common/xf86platformBus.c?ref_type=heads#L589
might need to be updated to add exceptions for vesadrm and efidrm like there
is for simpledrm.
I am willing to open a merge request, but freedesktop is readonly for now
during their migration.