Skip to content

Commit f30e277

Browse files
geertudanvet
authored andcommitted
drm/fb-helper: Round up bits_per_pixel if possible
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]
1 parent 4396393 commit f30e277

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
@@ -1283,7 +1283,7 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
12831283
* Changes struct fb_var_screeninfo are currently not pushed back
12841284
* to KMS, hence fail if different settings are requested.
12851285
*/
1286-
if (var->bits_per_pixel != fb->format->cpp[0] * 8 ||
1286+
if (var->bits_per_pixel > fb->format->cpp[0] * 8 ||
12871287
var->xres > fb->width || var->yres > fb->height ||
12881288
var->xres_virtual > fb->width || var->yres_virtual > fb->height) {
12891289
DRM_DEBUG("fb requested width/height/bpp can't fit in current fb "
@@ -1308,6 +1308,11 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
13081308
drm_fb_helper_fill_pixel_fmt(var, fb->format->depth);
13091309
}
13101310

1311+
/*
1312+
* Likewise, bits_per_pixel should be rounded up to a supported value.
1313+
*/
1314+
var->bits_per_pixel = fb->format->cpp[0] * 8;
1315+
13111316
/*
13121317
* drm fbdev emulation doesn't support changing the pixel format at all,
13131318
* so reject all pixel format changing requests.

0 commit comments

Comments
 (0)