[PATCH v1 14/22] drm/panel: sony-acx424akp: Backlight update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Use get method to read brightness
- Use drm_panel support for backlight
  - This drops enable/disable operations as they are no longer needed.
    The enable/disable operations had some backlight related comments
    that are no longer valid. The only correct way to enable/disable
    backlight is using the backlight enable/disable helpers.
- Use macro for backlight initialization

Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
Linus Walleij <linus.walleij@xxxxxxxxxx>
Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
Cc: Thierry Reding <thierry.reding@xxxxxxxxx>
Cc: Sam Ravnborg <sam@xxxxxxxxxxxx>
---
 drivers/gpu/drm/panel/panel-sony-acx424akp.c | 49 ++++----------------
 1 file changed, 9 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sony-acx424akp.c b/drivers/gpu/drm/panel/panel-sony-acx424akp.c
index c91e55b2d7a3..ce9ae8f1f5d7 100644
--- a/drivers/gpu/drm/panel/panel-sony-acx424akp.c
+++ b/drivers/gpu/drm/panel/panel-sony-acx424akp.c
@@ -99,7 +99,7 @@ static int acx424akp_set_brightness(struct backlight_device *bl)
 	struct acx424akp *acx = bl_get_data(bl);
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(acx->dev);
 	int period_ns = 1023;
-	int duty_ns = bl->props.brightness;
+	int duty_ns = backlight_get_brightness(bl);
 	u8 pwm_ratio;
 	u8 pwm_div;
 	u8 par;
@@ -332,8 +332,6 @@ static int acx424akp_prepare(struct drm_panel *panel)
 		}
 	}
 
-	acx->bl->props.power = FB_BLANK_NORMAL;
-
 	return 0;
 
 err_power_off:
@@ -376,34 +374,6 @@ static int acx424akp_unprepare(struct drm_panel *panel)
 	msleep(85);
 
 	acx424akp_power_off(acx);
-	acx->bl->props.power = FB_BLANK_POWERDOWN;
-
-	return 0;
-}
-
-static int acx424akp_enable(struct drm_panel *panel)
-{
-	struct acx424akp *acx = panel_to_acx424akp(panel);
-
-	/*
-	 * The backlight is on as long as the display is on
-	 * so no use to call backlight_enable() here.
-	 */
-	acx->bl->props.power = FB_BLANK_UNBLANK;
-
-	return 0;
-}
-
-static int acx424akp_disable(struct drm_panel *panel)
-{
-	struct acx424akp *acx = panel_to_acx424akp(panel);
-
-	/*
-	 * The backlight is on as long as the display is on
-	 * so no use to call backlight_disable() here.
-	 */
-	acx->bl->props.power = FB_BLANK_NORMAL;
-
 	return 0;
 }
 
@@ -435,18 +405,18 @@ static int acx424akp_get_modes(struct drm_panel *panel,
 }
 
 static const struct drm_panel_funcs acx424akp_drm_funcs = {
-	.disable = acx424akp_disable,
 	.unprepare = acx424akp_unprepare,
 	.prepare = acx424akp_prepare,
-	.enable = acx424akp_enable,
 	.get_modes = acx424akp_get_modes,
 };
 
 static int acx424akp_probe(struct mipi_dsi_device *dsi)
 {
+	struct backlight_device *bd;
 	struct device *dev = &dsi->dev;
 	struct acx424akp *acx;
 	int ret;
+	DECLARE_BACKLIGHT_INIT_RAW(props, 512, 1023);
 
 	acx = devm_kzalloc(dev, sizeof(struct acx424akp), GFP_KERNEL);
 	if (!acx)
@@ -496,15 +466,14 @@ static int acx424akp_probe(struct mipi_dsi_device *dsi)
 	drm_panel_init(&acx->panel, dev, &acx424akp_drm_funcs,
 		       DRM_MODE_CONNECTOR_DSI);
 
-	acx->bl = devm_backlight_device_register(dev, "acx424akp", dev, acx,
-						 &acx424akp_bl_ops, NULL);
-	if (IS_ERR(acx->bl)) {
+	bd = devm_backlight_device_register(dev, "acx424akp", dev, acx,
+					    &acx424akp_bl_ops, &props);
+	if (IS_ERR(bd)) {
 		DRM_DEV_ERROR(dev, "failed to register backlight device\n");
-		return PTR_ERR(acx->bl);
+		return PTR_ERR(bd);
 	}
-	acx->bl->props.max_brightness = 1023;
-	acx->bl->props.brightness = 512;
-	acx->bl->props.power = FB_BLANK_POWERDOWN;
+
+	acx->panel.backlight = bd;
 
 	ret = drm_panel_add(&acx->panel);
 	if (ret < 0)
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux