Update backlight to use macro for initialization and the backlight_get_brightness() operation to simply the update operation. Use the drm_panel backlight functionality, which allowed the deletion of the enable and disable functions. Moved init of backlight device so it comes after drm_panel_init(). This is the order that is required by drm_panel. v2: - Use drm_panel based backlight Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx> Cc: Vinay Simha BN <simhavcs@xxxxxxxxx> Cc: Thierry Reding <thierry.reding@xxxxxxxxx> Cc: Sam Ravnborg <sam@xxxxxxxxxxxx> --- .../gpu/drm/panel/panel-jdi-lt070me05000.c | 58 ++++--------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c b/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c index 4bfd8c877c8e..d50dbe74b376 100644 --- a/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c +++ b/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c @@ -39,7 +39,6 @@ struct jdi_panel { struct gpio_desc *enable_gpio; struct gpio_desc *reset_gpio; struct gpio_desc *dcdc_en_gpio; - struct backlight_device *backlight; bool prepared; bool enabled; @@ -176,20 +175,6 @@ static void jdi_panel_off(struct jdi_panel *jdi) msleep(100); } -static int jdi_panel_disable(struct drm_panel *panel) -{ - struct jdi_panel *jdi = to_jdi_panel(panel); - - if (!jdi->enabled) - return 0; - - backlight_disable(jdi->backlight); - - jdi->enabled = false; - - return 0; -} - static int jdi_panel_unprepare(struct drm_panel *panel) { struct jdi_panel *jdi = to_jdi_panel(panel); @@ -272,20 +257,6 @@ static int jdi_panel_prepare(struct drm_panel *panel) return ret; } -static int jdi_panel_enable(struct drm_panel *panel) -{ - struct jdi_panel *jdi = to_jdi_panel(panel); - - if (jdi->enabled) - return 0; - - backlight_enable(jdi->backlight); - - jdi->enabled = true; - - return 0; -} - static const struct drm_display_mode default_mode = { .clock = 155493, .hdisplay = 1200, @@ -329,7 +300,7 @@ static int dsi_dcs_bl_get_brightness(struct backlight_device *bl) { struct mipi_dsi_device *dsi = bl_get_data(bl); int ret; - u16 brightness = bl->props.brightness; + u16 brightness; dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; @@ -349,7 +320,7 @@ static int dsi_dcs_bl_update_status(struct backlight_device *bl) dsi->mode_flags &= ~MIPI_DSI_MODE_LPM; - ret = mipi_dsi_dcs_set_display_brightness(dsi, bl->props.brightness); + ret = mipi_dsi_dcs_set_display_brightness(dsi, backlight_get_brightness(bl)); if (ret < 0) return ret; @@ -367,22 +338,15 @@ static struct backlight_device * drm_panel_create_dsi_backlight(struct mipi_dsi_device *dsi) { struct device *dev = &dsi->dev; - struct backlight_properties props; - - memset(&props, 0, sizeof(props)); - props.type = BACKLIGHT_RAW; - props.brightness = 255; - props.max_brightness = 255; + DECLARE_BACKLIGHT_INIT_RAW(props, 255, 255); return devm_backlight_device_register(dev, dev_name(dev), dev, dsi, &dsi_bl_ops, &props); } static const struct drm_panel_funcs jdi_panel_funcs = { - .disable = jdi_panel_disable, .unprepare = jdi_panel_unprepare, .prepare = jdi_panel_prepare, - .enable = jdi_panel_enable, .get_modes = jdi_panel_get_modes, }; @@ -431,16 +395,16 @@ static int jdi_panel_add(struct jdi_panel *jdi) return ret; } - jdi->backlight = drm_panel_create_dsi_backlight(jdi->dsi); - if (IS_ERR(jdi->backlight)) { - ret = PTR_ERR(jdi->backlight); + drm_panel_init(&jdi->base, &jdi->dsi->dev, &jdi_panel_funcs, + DRM_MODE_CONNECTOR_DSI); + + jdi->base.backlight = drm_panel_create_dsi_backlight(jdi->dsi); + if (IS_ERR(jdi->base.backlight)) { + ret = PTR_ERR(jdi->base.backlight); dev_err(dev, "failed to register backlight %d\n", ret); return ret; } - drm_panel_init(&jdi->base, &jdi->dsi->dev, &jdi_panel_funcs, - DRM_MODE_CONNECTOR_DSI); - ret = drm_panel_add(&jdi->base); return ret; @@ -482,7 +446,7 @@ static int jdi_panel_remove(struct mipi_dsi_device *dsi) struct jdi_panel *jdi = mipi_dsi_get_drvdata(dsi); int ret; - ret = jdi_panel_disable(&jdi->base); + ret = drm_panel_disable(&jdi->base); if (ret < 0) dev_err(&dsi->dev, "failed to disable panel: %d\n", ret); @@ -500,7 +464,7 @@ static void jdi_panel_shutdown(struct mipi_dsi_device *dsi) { struct jdi_panel *jdi = mipi_dsi_get_drvdata(dsi); - jdi_panel_disable(&jdi->base); + drm_panel_disable(&jdi->base); } static struct mipi_dsi_driver jdi_panel_driver = { -- 2.25.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel