• Linus Walleij's avatar
    drm/fb-helper: Scale back depth to supported maximum · f4bd542b
    Linus Walleij authored
    The following happened when migrating an old fbdev driver to DRM:
    
    The Integrator/CP PL111 supports 16BPP but only ARGB1555/ABGR1555
    or XRGB1555/XBGR1555 i.e. the maximum depth is 15.
    
    This makes the initialization of the framebuffer fail since
    the code in drm_fb_helper_single_fb_probe() assigns the same value
    to sizes.surface_bpp and sizes.surface_depth. I.e. it simply assumes
    a 1-to-1 mapping between BPP and depth, which is true in most cases
    but not for this hardware that only support odd formats.
    
    To support the odd case of a driver supporting 16BPP with only 15
    bits of depth, this patch will make the code loop over the formats
    supported on the primary plane on each CRTC managed by the FB
    helper and cap the depth to the maximum supported on any primary
    plane.
    
    On the PL110 Integrator, this makes drm_mode_legacy_fb_format()
    select DRM_FORMAT_XRGB1555 which is acceptable for this driver, and
    thus we get framebuffer, penguin and console on the Integrator/CP.
    
    Cc: Noralf Trønnes <noralf@tronnes.org>
    Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Link: https://patchwork.freedesktop.org/patch/msgid/20190110114049.10618-1-linus.walleij@linaro.org
    f4bd542b
drm_fb_helper.c 93 KB