summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/sysfb
AgeCommit message (Collapse)Author
2025-06-27drm/vesadrm: Avoid NULL-ptr deref in vesadrm_pmi_cmap_write()Thomas Zimmermann
Only set PMI fields if the screen_info's Vesa PM segment has been set. Vesa PMI is the power-management interface. It also provides means to set the color palette. The interface is optional, so not all VESA graphics cards support it. Print vesafb's warning [1] if the hardware palette cannot be set at all. If unsupported the field PrimaryPalette in struct vesadrm.pmi is NULL, which results in a segmentation fault. Happens with qemu's Cirrus emulation. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Fixes: 814d270b31d2 ("drm/sysfb: vesadrm: Add gamma correction") Link: https://elixir.bootlin.com/linux/v6.15/source/drivers/video/fbdev/vesafb.c#L375 # 1 Cc: Thomas Zimmermann <tzimmermann@suse.de> Cc: Javier Martinez Canillas <javierm@redhat.com> Cc: dri-devel@lists.freedesktop.org Acked-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250617140944.142392-1-tzimmermann@suse.de
2025-04-14drm/sysfb: Share helpers for screen_info validationThomas Zimmermann
Share efidrm's and vesadrm's validation of struct screen_info in shared helpers. Update the drivers. Most validation helpers test individual values against limits and can be shared as they are. For color formats, a common helper looks up the correct DRM format info from a driver-provided list of color formats. These screen_info helpers are only available if CONFIG_SCREEN_INFO has been selected, as done by efidrm and vesadrm. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250410083834.10810-4-tzimmermann@suse.de
2025-04-14drm/sysfb: Share helpers for integer validationThomas Zimmermann
Provide sysfb helpers for validating framebuffer integer values against limits. Update drivers. If a driver did not specify a limit for a certain value, use INT_MAX. v2: - declare module information near EOF (Javier) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250410083834.10810-3-tzimmermann@suse.de
2025-04-14drm/sysfb: Split source fileThomas Zimmermann
Split drm_sysfb_helper.c into two source files. There's now one source file for the mode-setting pipeline and one source file for module meta data. Prepares for adding additional source code to sysfb helpers. v2: - fix typo in commit message (Javier) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250410083834.10810-2-tzimmermann@suse.de
2025-04-11drm/sysfb: efidrm: Avoid clang -Wsometimes-uninitialized in ↵Nathan Chancellor
efidrm_device_create() Clang warns (or errors with CONFIG_WERROR=y): drivers/gpu/drm/sysfb/efidrm.c:353:11: error: variable 'screen_base' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] 353 | else if (mem_flags & EFI_MEMORY_WB) | ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/sysfb/efidrm.c:356:7: note: uninitialized use occurs here 356 | if (!screen_base) | ^~~~~~~~~~~ drivers/gpu/drm/sysfb/efidrm.c:353:7: note: remove the 'if' if its condition is always true 353 | else if (mem_flags & EFI_MEMORY_WB) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 354 | screen_base = devm_memremap(&pdev->dev, mem->start, resource_size(mem), drivers/gpu/drm/sysfb/efidrm.c:261:27: note: initialize the variable 'screen_base' to silence this warning 261 | void __iomem *screen_base; | ^ | = NULL efidrm_get_mem_flags() can only return a mask that has at least one of the tested values set so the else case is impossible but clang's static analysis runs before inlining so it cannot know that. Initialize screen_base to NULL and add a defensive error message in case mem_flags were ever returned without one of the four valid values. Fixes: 32ae90c66fb6 ("drm/sysfb: Add efidrm for EFI displays") Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20250410-efidrm-avoid-uninit-screen_info-warning-v2-1-b79646f58c24@kernel.org
2025-04-09drm/sysfb: efidrm: Support module buildsThomas Zimmermann
Make CONFIG_DRM_EFIDRM a tristate to enable module builds. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250408091837.407401-3-tzimmermann@suse.de
2025-04-08drm/sysfb: simpledrm: Remove unused helper simpledrm_device_of_dev()Thomas Zimmermann
After moving most of the mode-setting pipeline into drm_sysfb_helper.c, simpledrm_device_of_dev() is no longer being used. Remove it. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reported-by: Jocelyn Falempe <jfalempe@redhat.com> Closes: https://lore.kernel.org/dri-devel/20250407131344.139878-1-jfalempe@redhat.com/ Fixes: 177dfbdb7e67 ("drm/sysfb: Merge primary-plane functions") Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://lore.kernel.org/r/20250407134753.985925-3-tzimmermann@suse.de
2025-04-08drm/simpledrm: Do not upcast in release helpersThomas Zimmermann
The res pointer passed to simpledrm_device_release_clocks() and simpledrm_device_release_regulators() points to an instance of struct simpledrm_device. No need to upcast from struct drm_device. The upcast is harmless, as DRM device is the first field in struct simpledrm_device. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Fixes: 11e8f5fd223b ("drm: Add simpledrm driver") Cc: <stable@vger.kernel.org> # v5.14+ Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Link: https://lore.kernel.org/r/20250407134753.985925-2-tzimmermann@suse.de
2025-04-07drm/sysfb: vesadrm: Add gamma correctionThomas Zimmermann
Add palette support and export GAMMA properties via sysfs. User-space compositors can use this interface for programming gamma ramps or night mode. Vesadrm supports palette updates via VGA DAC registers or VESA palette calls. Up to 256 palette entries are available. Userspace always supplies gamma ramps of 256 entries. If the native color format does not match this because pixel component have less then 8 bits, vesadrm interpolates among the palette entries. The code uses CamelCase style in a few places to match the VESA manuals. v3: - fix coding style v2: - use CONFIG_X86_32 instead of __i386__ (checkpatch) - protect struct vesadrm.pmi with CONFIG_X86_32 Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-19-tzimmermann@suse.de
2025-04-07drm/sysfb: vesadrm: Add EDID supportThomas Zimmermann
Enable the connector's EDID property if edid_info contains valid data. Exports the EDID via sysfs for user-space compositors. EDID information is not always available. Depending on the system and kernel configuration, it is either provided by the boot loader or read by the kernel during early boot stages. There's only one VESA display, so EDID data always belongs to this output. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-18-tzimmermann@suse.de
2025-04-07drm/sysfb: Add vesadrm for VESA displaysThomas Zimmermann
Add support for screen_info setups with VIDEO_TYPE_VLFB. Provide the minimum functionality of reading modes, updating and clearing the display. There is existing support for these displays provided by simpledrm with CONFIG_SYSFB_SIMPLEFB=y. Using vesadrm over simpledrm will allow for the use of additional functionality provided by VESA, such as EDID information, gamma correction and palette modes. This enhances the user experience and adds support for more display configuratons. v4: - depend on CONFIG_X86 v3: - depend on !SYSFB_SIMPLEFB (Javier) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-17-tzimmermann@suse.de
2025-04-07drm/sysfb: efidrm: Add EDID supportThomas Zimmermann
Enable the connector's EDID property if edid_info contains valid data. Exports the EDID via sysfs for user-space compositors. EDID information is not always available. Depending on the system and kernel configuration, it is either provided by the boot loader or read by the kernel during early boot stages. As of now, there's only one EFI display, so that EDID data always belongs to this output. This might change if there's ever more than one EFI display in the system. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-16-tzimmermann@suse.de
2025-04-07drm/sysfb: Add efidrm for EFI displaysThomas Zimmermann
Add support for screen_info setups with VIDEO_TYPE_EFI. Provide the minimum functionality of reading modes, updating and clearing the display. There is existing support for these displays provided by simpledrm with CONFIG_SYSFB_SIMPLEFB=y. Using efidrm over simpledrm will allows for the mapping of video memory with correct caching. Simpledrm always assumes WC caching, while fully cached memory is possible with efidrm. Efidrm will also allow for the use of additional functionality provided by EFI, such as EDID information. In addition to efidrm, add struct pixel_format plus initializer macros. The type and macros describe pixel formats in a generic way on order to find the DRM format from the screen_info settings. Similar existing code in SIMPLEFB_FORMATS and fbdev is not really what is needed in efidrm, but SIMPLEFB_FORMATS can later be converted to struct pixel_format. v4: - depend on CONFIG_EFI - disallow module for now as efi_mem_desc_lookup() is not exported v3: - depend on !SYSFB_SIMPLEFB (Javier) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-15-tzimmermann@suse.de
2025-04-07drm/sysfb: ofdrm: Add EDID supportThomas Zimmermann
Add EDID support to sysfb connector helpers. Read the EDID property from the OF node in ofdrm. Without EDID, this does nothing. Some systems with OF display, such as 32-bit PPC Macintoshs, provide the system display's EDID data as node property in their DT. Exporting this information allows compositors to implement correct DPI and meaningful color management. v3: - avoid parser error by clearing EDID extension field v2: - return errno codes on errors (Jani) - simplify EDID read logic (Jani) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-13-tzimmermann@suse.de
2025-04-07drm/sysfb: Merge primary-plane functionsThomas Zimmermann
Merge the primary plane code of ofdrm and simpledrm. Replace the plane implementation in each driver with the shared helpers. Set up driver callbacks and format modifiers with initializer macros. The plane code in ofdrm and simpledrm is very similar. Ofdrm has a more sophisticated implementation of atomic_disable, which clears individual scanlines. The code in simpledrm clears the whole buffer at once. Take the ofdrm version. Simpledrm supports get_scanout_buffer. Import it into the shared helpers, which makes it available in ofdrm. The supported formats are all native formats plus an optional enulated XRGB8888 if that's not already a native format. Provide an initializer macro that computes the size of the formats array. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-12-tzimmermann@suse.de
2025-04-07drm/sysfb: Merge CRTC functionsThomas Zimmermann
Merge the CRTC functions of ofdrm and simpledrm. Replace the code in each driver with the shared helpers. Set up callbacks with initializer macros. Ofdrm supports a gamma LUT, while simpledrm does not. So far ofdrm's LUT size has been hard-coded in the driver CRTC's atomic_check helper. Now pass the size of the LUT to the sysfb device. Ofdrm's custom atomic_flush is still required to apply changes to the LUT. Simpledrm passes a LUT size of 0, which disables the gamma LUT. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-11-tzimmermann@suse.de
2025-04-07drm/sysfb: Maintain CRTC state in struct drm_sysfb_crtc_stateThomas Zimmermann
Move ofdrm's struct ofdrm_crtc_state plus functions to sysfb helpers and rename everything to drm_sysfb_crtc_state. The sysfb CRTC state is a regular CRTC state with information on the primary plane's color format, as required for color management. Helpers for sysfb planes will later set this up automatically. In ofdrm and simpledrm, replace existing code with the new helpers. Ofdrm continues to use the CRTC state for color management. This has no effect on simpledrm. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-10-tzimmermann@suse.de
2025-04-07drm/sysfb: Merge connector functionsThomas Zimmermann
Merge the connector functions of ofdrm and simpledrm. Replace the code in each driver with the shared helpers. Set up callbacks with initializer macros. No effective code changes. The sysfb connector only returns the preconfigured display mode. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-9-tzimmermann@suse.de
2025-04-07drm/sysfb: Merge mode-config functionsThomas Zimmermann
Provide initializer to set struct drm_mode_config_funcs. Convert ofdrm and simpledrm. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-8-tzimmermann@suse.de
2025-04-07drm/sysfb: Provide single mode-init helperThomas Zimmermann
Merge the mode-init functions of ofdrm and simpledrm to the new helper drm_sysfb_mode(). Also implement the DPI defaults there. Replace the code in each driver with the shared helper. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-7-tzimmermann@suse.de
2025-04-07drm/sysfb: Add struct drm_sysfb_deviceThomas Zimmermann
Add struct drm_sysfb_device that stores the system display's hardware settings. Further helpers for the mode-setting pipeline will use these fields. Convert ofdrm and simpledrm by embedding the sysfb device in their device structs. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-6-tzimmermann@suse.de
2025-04-07drm: Move sysfb drivers into separate subdirectoryThomas Zimmermann
The ofdrm and simpledrm drivers are special as they operate on externally provided framebuffers. Move them into their own sub- directory. Will let them share common code. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://lore.kernel.org/r/20250401094056.32904-5-tzimmermann@suse.de