• Linus Walleij's avatar
    drm/pl111: Fix FB depth on IMPD-1 framebuffer · 14080973
    Linus Walleij authored
    The last argument to the function drm_fbdev_dma_setup() was
    changed from desired BPP to desired depth.
    
    In our case the desired depth was 15 but BPP was 16, so we
    specified 16 as BPP and we relied on the FB emulation core to
    select a format with a suitable depth for the limited bandwidth
    and end up with e.g. XRGB1555 like in the past:
    
    [drm] Initialized pl111 1.0.0 20170317 for c1000000.display on minor 0
    drm-clcd-pl111 c1000000.display: [drm] requested bpp 16, scaled depth down to 15
    drm-clcd-pl111 c1000000.display: enable IM-PD1 CLCD connectors
    Console: switching to colour frame buffer device 80x30
    drm-clcd-pl111 c1000000.display: [drm] fb0: pl111drmfb frame buffer device
    
    However the current code will fail at that:
    
    [drm] Initialized pl111 1.0.0 20170317 for c1000000.display on minor 0
    drm-clcd-pl111 c1000000.display: [drm] bpp/depth value of 16/16 not supported
    drm-clcd-pl111 c1000000.display: [drm] No compatible format found
    drm-clcd-pl111 c1000000.display: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-12)
    
    Fix this by passing the desired depth of 15 for the IM/PD-1 display
    instead of 16 to drm_fbdev_dma_setup().
    
    The desired depth is however in turn used for bandwidth limiting
    calculations and that was done with a simple / integer division,
    whereas we now have to modify that to use DIV_ROUND_UP() so that
    we get DIV_ROUND_UP(15, 2) = 2 not 15/2 = 1.
    
    After this the display works again on the Integrator/AP IM/PD-1.
    
    Cc: Emma Anholt <emma@anholt.net>
    Cc: stable@vger.kernel.org
    Suggested-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
    Fixes: 37c90d58 ("drm/fb-helper: Fix single-probe color-format selection")
    Link: https://lore.kernel.org/dri-devel/20230102112927.26565-1-tzimmermann@suse.de/Reviewed-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20230515092943.1401558-1-linus.walleij@linaro.org
    14080973
pl111_display.c 15.4 KB