Skip to content

Commit 733463f

Browse files
geertugregkh
authored andcommitted
drm/fb-helper: Round up bits_per_pixel if possible
commit f30e277 upstream. When userspace requests a video mode parameter value that is not supported, frame buffer device drivers should round it up to a supported value, if possible, instead of just rejecting it. This allows applications to quickly scan for supported video modes. Currently this rule is not followed for the number of bits per pixel, causing e.g. "fbset -depth N" to fail, if N is smaller than the current number of bits per pixel. Fix this by returning an error only if bits per pixel is too large, and setting it to the current value otherwise. See also Documentation/fb/framebuffer.rst, Section 2 (Programmer's View of /dev/fb*"). Fixes: 865afb1 ("drm/fb-helper: reject any changes to the fbdev") Cc: [email protected] Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent af62c38 commit 733463f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/gpu/drm/drm_fb_helper.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,7 +1590,7 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
15901590
* Changes struct fb_var_screeninfo are currently not pushed back
15911591
* to KMS, hence fail if different settings are requested.
15921592
*/
1593-
if (var->bits_per_pixel != fb->format->cpp[0] * 8 ||
1593+
if (var->bits_per_pixel > fb->format->cpp[0] * 8 ||
15941594
var->xres > fb->width || var->yres > fb->height ||
15951595
var->xres_virtual > fb->width || var->yres_virtual > fb->height) {
15961596
DRM_DEBUG("fb requested width/height/bpp can't fit in current fb "
@@ -1615,6 +1615,11 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
16151615
drm_fb_helper_fill_pixel_fmt(var, fb->format->depth);
16161616
}
16171617

1618+
/*
1619+
* Likewise, bits_per_pixel should be rounded up to a supported value.
1620+
*/
1621+
var->bits_per_pixel = fb->format->cpp[0] * 8;
1622+
16181623
/*
16191624
* drm fbdev emulation doesn't support changing the pixel format at all,
16201625
* so reject all pixel format changing requests.

0 commit comments

Comments
 (0)