Commit 55935828 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/fb-helper: Don't use the preferred depth for the BPP default

If no preferred value for bits-per-pixel has been given, fall back
to 32. Never use the preferred depth. The color depth is the number
of color/alpha bits per pixel, while bpp is the overall number of
bits in most cases.

Most noteworthy, XRGB8888 has a depth of 24 and a bpp value of 32.
Using depth for bpp would make the value 24 as well and format
selection in fbdev helpers fails. Unfortunately XRGB8888 is the most
common format and the old heuristic therefore fails for most of
the drivers (unless they implement the 24-bit RGB888 format).

Picking a bpp of 32 will later on result in a default depth of 24
and the format XRGB8888. As XRGB8888 is the default format for most
of the current and legacy graphics stack, all drivers must support
it. So it is the safe choice.

v2:
	* fix commit-message typo (Javier)
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20221123115348.2521-8-tzimmermann@suse.de
parent 36aff2ea
...@@ -431,7 +431,6 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = { ...@@ -431,7 +431,6 @@ static const struct drm_client_funcs drm_fbdev_client_funcs = {
* drm_fbdev_generic_setup() - Setup generic fbdev emulation * drm_fbdev_generic_setup() - Setup generic fbdev emulation
* @dev: DRM device * @dev: DRM device
* @preferred_bpp: Preferred bits per pixel for the device. * @preferred_bpp: Preferred bits per pixel for the device.
* @dev->mode_config.preferred_depth is used if this is zero.
* *
* This function sets up generic fbdev emulation for drivers that supports * This function sets up generic fbdev emulation for drivers that supports
* dumb buffers with a virtual address and that can be mmap'ed. * dumb buffers with a virtual address and that can be mmap'ed.
...@@ -475,12 +474,16 @@ void drm_fbdev_generic_setup(struct drm_device *dev, ...@@ -475,12 +474,16 @@ void drm_fbdev_generic_setup(struct drm_device *dev,
} }
/* /*
* FIXME: This mixes up depth with bpp, which results in a glorious * Pick a preferred bpp of 32 if no value has been given. This
* mess, resulting in some drivers picking wrong fbdev defaults and * will select XRGB8888 for the framebuffer formats. All drivers
* others wrong preferred_depth defaults. * have to support XRGB8888 for backwards compatibility with legacy
* userspace, so it's the safe choice here.
*
* TODO: Replace struct drm_mode_config.preferred_depth and this
* bpp value with a preferred format that is given as struct
* drm_format_info. Then derive all other values from the
* format.
*/ */
if (!preferred_bpp)
preferred_bpp = dev->mode_config.preferred_depth;
if (!preferred_bpp) if (!preferred_bpp)
preferred_bpp = 32; preferred_bpp = 32;
fb_helper->preferred_bpp = preferred_bpp; fb_helper->preferred_bpp = preferred_bpp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment