From: Ville Syrjälä <[email protected]>

Respect the user's choice of depth/bpp for the fbdev framebuffer
and throw out the fb we inherited from the BIOS if it doesn't
match.

Signed-off-by: Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_fbdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c 
b/drivers/gpu/drm/i915/display/intel_fbdev.c
index f9c135400453..3754810cc187 100644
--- a/drivers/gpu/drm/i915/display/intel_fbdev.c
+++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
@@ -268,6 +268,8 @@ static bool bios_fb_ok(const struct intel_framebuffer *fb,
        struct intel_display *display = to_intel_display(fb->base.dev);
        int width = fb->base.width;
        int height = fb->base.height;
+       int depth = fb->base.format->depth;
+       int bpp = fb->base.format->cpp[0] * 8;
 
        if (sizes->fb_width > width || sizes->fb_height > height) {
                drm_dbg_kms(display->drm,
@@ -276,6 +278,13 @@ static bool bios_fb_ok(const struct intel_framebuffer *fb,
                return false;
        }
 
+       if (sizes->surface_depth != depth || sizes->surface_bpp != bpp) {
+               drm_dbg_kms(display->drm,
+                           "BIOS fb using wrong depth/bpp (%d/%d), we require 
(%d/%d), releasing it\n",
+                           depth, bpp, sizes->surface_depth, 
sizes->surface_bpp);
+               return false;
+       }
+
        return true;
 }
 
-- 
2.52.0

Reply via email to