[PATCH v2 17/24] drm/panel: sony-acx565akm: Backlight update

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

 



- Use backlight_get_brightness() helper
- Use backlight_is_blank() helper
- Use macro for initialization
- Drop direct access to backlight properties
- Use the devm_ variant for registering backlight device, and drop
  all explicit unregistering of the backlight device.
- Register backligt after drm_panel_init

Signed-off-by: Sam Ravnborg <sam@xxxxxxxxxxxx>
Cc: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
Cc: Thierry Reding <thierry.reding@xxxxxxxxx>
Cc: Sam Ravnborg <sam@xxxxxxxxxxxx>
---
 drivers/gpu/drm/panel/panel-sony-acx565akm.c | 47 +++++++-------------
 1 file changed, 15 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-sony-acx565akm.c b/drivers/gpu/drm/panel/panel-sony-acx565akm.c
index 5c4b6f6e5c2d..65da0160f2b8 100644
--- a/drivers/gpu/drm/panel/panel-sony-acx565akm.c
+++ b/drivers/gpu/drm/panel/panel-sony-acx565akm.c
@@ -298,13 +298,7 @@ static void acx565akm_set_brightness(struct acx565akm_panel *lcd, int level)
 static int acx565akm_bl_update_status_locked(struct backlight_device *dev)
 {
 	struct acx565akm_panel *lcd = dev_get_drvdata(&dev->dev);
-	int level;
-
-	if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
-	    dev->props.power == FB_BLANK_UNBLANK)
-		level = dev->props.brightness;
-	else
-		level = 0;
+	int level = backlight_get_brightness(dev);
 
 	acx565akm_set_brightness(lcd, level);
 
@@ -330,8 +324,7 @@ static int acx565akm_bl_get_intensity(struct backlight_device *dev)
 
 	mutex_lock(&lcd->mutex);
 
-	if (dev->props.fb_blank == FB_BLANK_UNBLANK &&
-	    dev->props.power == FB_BLANK_UNBLANK)
+	if (backlight_is_blank(dev))
 		intensity = acx565akm_get_actual_brightness(lcd);
 	else
 		intensity = 0;
@@ -348,40 +341,32 @@ static const struct backlight_ops acx565akm_bl_ops = {
 
 static int acx565akm_backlight_init(struct acx565akm_panel *lcd)
 {
-	struct backlight_properties props = {
-		.fb_blank = FB_BLANK_UNBLANK,
-		.power = FB_BLANK_UNBLANK,
-		.type = BACKLIGHT_RAW,
-	};
+	DECLARE_BACKLIGHT_INIT_RAW(props, 0, 255);
+	struct backlight_device *bd;
 	int ret;
 
-	lcd->backlight = backlight_device_register(lcd->name, &lcd->spi->dev,
-						   lcd, &acx565akm_bl_ops,
-						   &props);
-	if (IS_ERR(lcd->backlight)) {
-		ret = PTR_ERR(lcd->backlight);
-		lcd->backlight = NULL;
+	bd = devm_backlight_device_register(&lcd->spi->dev, lcd->name,
+					    &lcd->spi->dev, lcd,
+					    &acx565akm_bl_ops, &props);
+	if (IS_ERR(bd)) {
+		ret = PTR_ERR(bd);
 		return ret;
 	}
 
+	lcd->backlight = bd;
 	if (lcd->has_cabc) {
-		ret = sysfs_create_group(&lcd->backlight->dev.kobj,
+		ret = sysfs_create_group(&bd->dev.kobj,
 					 &acx565akm_cabc_attr_group);
 		if (ret < 0) {
 			dev_err(&lcd->spi->dev,
 				"%s failed to create sysfs files\n", __func__);
-			backlight_device_unregister(lcd->backlight);
 			return ret;
 		}
 
 		lcd->cabc_mode = acx565akm_get_hw_cabc_mode(lcd);
 	}
 
-	lcd->backlight->props.max_brightness = 255;
-	lcd->backlight->props.brightness = acx565akm_get_actual_brightness(lcd);
-
-	acx565akm_bl_update_status_locked(lcd->backlight);
-
+	backlight_update_brightness(bd, acx565akm_get_actual_brightness(lcd));
 	return 0;
 }
 
@@ -390,8 +375,6 @@ static void acx565akm_backlight_cleanup(struct acx565akm_panel *lcd)
 	if (lcd->has_cabc)
 		sysfs_remove_group(&lcd->backlight->dev.kobj,
 				   &acx565akm_cabc_attr_group);
-
-	backlight_device_unregister(lcd->backlight);
 }
 
 /* -----------------------------------------------------------------------------
@@ -642,15 +625,15 @@ static int acx565akm_probe(struct spi_device *spi)
 		return ret;
 	}
 
+	drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs,
+		       DRM_MODE_CONNECTOR_DPI);
+
 	if (lcd->has_bc) {
 		ret = acx565akm_backlight_init(lcd);
 		if (ret < 0)
 			return ret;
 	}
 
-	drm_panel_init(&lcd->panel, &lcd->spi->dev, &acx565akm_funcs,
-		       DRM_MODE_CONNECTOR_DPI);
-
 	ret = drm_panel_add(&lcd->panel);
 	if (ret < 0) {
 		if (lcd->has_bc)
-- 
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