The samsung-s6e3ha2 had a local way to handle backlight. Update the driver to use a devm_ based register function and utilize drm_panel backlight support. The changes results in a simpler driver with the same functionality. Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx> Cc: Joonas Kylmälä <joonas.kylmala@xxxxxx> Cc: Andrzej Hajda <a.hajda@xxxxxxxxxxx> Cc: Thierry Reding <thierry.reding@xxxxxxxxx> Cc: Inki Dae <inki.dae@xxxxxxxxxxx> Cc: Hyungwon Hwang <human.hwang@xxxxxxxxxxx> Cc: Hoegeun Kwon <hoegeun.kwon@xxxxxxxxxxx> --- drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c | 55 +++++++++++-------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c index 36ebd5a4ac7b..08862146aec3 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e3ha2.c @@ -233,7 +233,6 @@ struct s6e3ha2_panel_desc { struct s6e3ha2 { struct device *dev; struct drm_panel panel; - struct backlight_device *bl_dev; struct regulator_bulk_data supplies[2]; struct gpio_desc *reset_gpio; @@ -415,7 +414,7 @@ static int s6e3ha2_get_brightness(struct backlight_device *bl_dev) static int s6e3ha2_set_vint(struct s6e3ha2 *ctx) { - struct backlight_device *bl_dev = ctx->bl_dev; + struct backlight_device *bl_dev = ctx->panel.backlight; unsigned int brightness = bl_dev->props.brightness; unsigned char data[] = { 0xf4, 0x8b, vint_table[brightness * (S6E3HA2_VINT_STATUS_MAX - 1) / @@ -432,7 +431,7 @@ static unsigned int s6e3ha2_get_brightness_index(unsigned int brightness) static int s6e3ha2_update_gamma(struct s6e3ha2 *ctx, unsigned int brightness) { - struct backlight_device *bl_dev = ctx->bl_dev; + struct backlight_device *bl_dev = ctx->panel.backlight; unsigned int index = s6e3ha2_get_brightness_index(brightness); u8 data[S6E3HA2_GAMMA_CMD_CNT + 1] = { 0xca, }; int ret; @@ -476,6 +475,30 @@ static const struct backlight_ops s6e3ha2_bl_ops = { .update_status = s6e3ha2_set_brightness, }; +static int s6e3ha2_backlight_register(struct s6e3ha2 *ctx) +{ + struct backlight_properties props = { + .type = BACKLIGHT_RAW, + .brightness = S6E3HA2_DEFAULT_BRIGHTNESS, + .max_brightness = S6E3HA2_MAX_BRIGHTNESS, + }; + struct backlight_device *backlight; + struct device *dev = ctx->dev; + int ret = 0; + + backlight = devm_backlight_device_register(dev, "panel", dev, ctx, + &s6e3ha2_bl_ops, + &props); + if (IS_ERR(backlight)) { + ret = PTR_ERR(backlight); + DRM_DEV_ERROR(dev, "error registering backlight device (%d)\n", + ret); + } + ctx->panel.backlight = backlight; + + return ret; +} + static int s6e3ha2_panel_init(struct s6e3ha2 *ctx) { struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev); @@ -509,7 +532,6 @@ static int s6e3ha2_disable(struct drm_panel *panel) s6e3ha2_call_write_func(ret, mipi_dsi_dcs_set_display_off(dsi)); msleep(40); - ctx->bl_dev->props.power = FB_BLANK_NORMAL; return 0; } @@ -555,8 +577,6 @@ static int s6e3ha2_prepare(struct drm_panel *panel) if (ret < 0) goto err; - ctx->bl_dev->props.power = FB_BLANK_NORMAL; - return 0; err: @@ -588,7 +608,6 @@ static int s6e3ha2_enable(struct drm_panel *panel) s6e3ha2_call_write_func(ret, s6e3ha2_te_start_setting(ctx)); /* brightness setting */ - s6e3ha2_call_write_func(ret, s6e3ha2_set_brightness(ctx->bl_dev)); s6e3ha2_call_write_func(ret, s6e3ha2_aor_control(ctx)); s6e3ha2_call_write_func(ret, s6e3ha2_caps_elvss_set(ctx)); s6e3ha2_call_write_func(ret, s6e3ha2_gamma_update(ctx)); @@ -602,7 +621,6 @@ static int s6e3ha2_enable(struct drm_panel *panel) s6e3ha2_call_write_func(ret, s6e3ha2_test_key_off_f0(ctx)); s6e3ha2_call_write_func(ret, mipi_dsi_dcs_set_display_on(dsi)); - ctx->bl_dev->props.power = FB_BLANK_UNBLANK; return 0; } @@ -721,23 +739,16 @@ static int s6e3ha2_probe(struct mipi_dsi_device *dsi) return PTR_ERR(ctx->enable_gpio); } - ctx->bl_dev = backlight_device_register("s6e3ha2", dev, ctx, - &s6e3ha2_bl_ops, NULL); - if (IS_ERR(ctx->bl_dev)) { - dev_err(dev, "failed to register backlight device\n"); - return PTR_ERR(ctx->bl_dev); - } - - ctx->bl_dev->props.max_brightness = S6E3HA2_MAX_BRIGHTNESS; - ctx->bl_dev->props.brightness = S6E3HA2_DEFAULT_BRIGHTNESS; - ctx->bl_dev->props.power = FB_BLANK_POWERDOWN; - drm_panel_init(&ctx->panel, dev, &s6e3ha2_drm_funcs, DRM_MODE_CONNECTOR_DSI); + ret = s6e3ha2_backlight_register(ctx); + if (ret) + return ret; + ret = drm_panel_add(&ctx->panel); if (ret < 0) - goto unregister_backlight; + return ret; ret = mipi_dsi_attach(dsi); if (ret < 0) @@ -748,9 +759,6 @@ static int s6e3ha2_probe(struct mipi_dsi_device *dsi) remove_panel: drm_panel_remove(&ctx->panel); -unregister_backlight: - backlight_device_unregister(ctx->bl_dev); - return ret; } @@ -760,7 +768,6 @@ static int s6e3ha2_remove(struct mipi_dsi_device *dsi) mipi_dsi_detach(dsi); drm_panel_remove(&ctx->panel); - backlight_device_unregister(ctx->bl_dev); return 0; } -- 2.20.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel