Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panel: lvds: use drm_panel backlight support

Use the backlight support in drm_panel to simplify the driver

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20191207140353.23967-13-sam@ravnborg.org

+5 -35
+5 -35
drivers/gpu/drm/panel/panel-lvds.c
··· 8 8 * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) 9 9 */ 10 10 11 - #include <linux/backlight.h> 12 11 #include <linux/gpio/consumer.h> 13 12 #include <linux/module.h> 14 13 #include <linux/of_platform.h> ··· 33 34 unsigned int bus_format; 34 35 bool data_mirror; 35 36 36 - struct backlight_device *backlight; 37 37 struct regulator *supply; 38 38 39 39 struct gpio_desc *enable_gpio; ··· 42 44 static inline struct panel_lvds *to_panel_lvds(struct drm_panel *panel) 43 45 { 44 46 return container_of(panel, struct panel_lvds, panel); 45 - } 46 - 47 - static int panel_lvds_disable(struct drm_panel *panel) 48 - { 49 - struct panel_lvds *lvds = to_panel_lvds(panel); 50 - 51 - if (lvds->backlight) { 52 - lvds->backlight->props.power = FB_BLANK_POWERDOWN; 53 - lvds->backlight->props.state |= BL_CORE_FBBLANK; 54 - backlight_update_status(lvds->backlight); 55 - } 56 - 57 - return 0; 58 47 } 59 48 60 49 static int panel_lvds_unprepare(struct drm_panel *panel) ··· 78 93 return 0; 79 94 } 80 95 81 - static int panel_lvds_enable(struct drm_panel *panel) 82 - { 83 - struct panel_lvds *lvds = to_panel_lvds(panel); 84 - 85 - if (lvds->backlight) { 86 - lvds->backlight->props.state &= ~BL_CORE_FBBLANK; 87 - lvds->backlight->props.power = FB_BLANK_UNBLANK; 88 - backlight_update_status(lvds->backlight); 89 - } 90 - 91 - return 0; 92 - } 93 - 94 96 static int panel_lvds_get_modes(struct drm_panel *panel, 95 97 struct drm_connector *connector) 96 98 { ··· 104 132 } 105 133 106 134 static const struct drm_panel_funcs panel_lvds_funcs = { 107 - .disable = panel_lvds_disable, 108 135 .unprepare = panel_lvds_unprepare, 109 136 .prepare = panel_lvds_prepare, 110 - .enable = panel_lvds_enable, 111 137 .get_modes = panel_lvds_get_modes, 112 138 }; 113 139 ··· 212 242 return ret; 213 243 } 214 244 215 - lvds->backlight = devm_of_find_backlight(lvds->dev); 216 - if (IS_ERR(lvds->backlight)) 217 - return PTR_ERR(lvds->backlight); 218 - 219 245 /* 220 246 * TODO: Handle all power supplies specified in the DT node in a generic 221 247 * way for panels that don't care about power supply ordering. LVDS ··· 222 256 /* Register the panel. */ 223 257 drm_panel_init(&lvds->panel, lvds->dev, &panel_lvds_funcs, 224 258 DRM_MODE_CONNECTOR_LVDS); 259 + 260 + ret = drm_panel_of_backlight(&lvds->panel); 261 + if (ret) 262 + return ret; 225 263 226 264 ret = drm_panel_add(&lvds->panel); 227 265 if (ret < 0) ··· 241 271 242 272 drm_panel_remove(&lvds->panel); 243 273 244 - panel_lvds_disable(&lvds->panel); 274 + drm_panel_disable(&lvds->panel); 245 275 246 276 return 0; 247 277 }