• Sam Ravnborg's avatar
    drm/panel: add backlight support · 152dbdea
    Sam Ravnborg authored
    Panels often support backlight as specified in a device tree.
    Update the drm_panel infrastructure to support this to
    simplify the drivers.
    
    With this the panel driver just needs to add the following to the
    probe() function:
    
        err = drm_panel_of_backlight(panel);
        if (err)
                return err;
    
    Then drm_panel will handle all the rest.
    
    There is one caveat with the backlight support.
    If drm_panel_(enable|disable) are called multiple times
    in a row then backlight_(enable|disable) will be called multiple times.
    
    The above will happen when a panel drivers unconditionally
    calls drm_panel_disable() in their shutdown() function,
    whan the panel is already disabled and then shutdown() is called.
    
    Reading the backlight code it seems safe to call
    the backlight_(enable|disable) several times.
    
    v3:
    - Improve comments, fix grammar (Laurent)
    - Do not fail in drm_panel_of_backlight() if no DT support (Laurent)
    - Log if backlight_(enable|disable) fails (Laurent)
    - Improve drm_panel_of_backlight() docs
    - Updated changelog with backlight analysis (triggered by Laurent)
    
    v2:
    - Drop test of CONFIG_DRM_PANEL in header-file (Laurent)
    - do not enable backlight if ->enable() returns an error
    Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
    Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
    Cc: Thierry Reding <thierry.reding@gmail.com>
    Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Cc: Maxime Ripard <maxime.ripard@bootlin.com>
    Cc: Sean Paul <sean@poorly.run>
    Cc: David Airlie <airlied@linux.ie>
    Cc: Daniel Vetter <daniel@ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20191207140353.23967-3-sam@ravnborg.org
    152dbdea
drm_panel.c 9.6 KB