[PATCH v2 21/24] drm/amdgpu/atom: Backlight update

Sam Ravnborg sam at ravnborg.org
Sun Aug 23 10:45:29 UTC 2020


- Use macros for initialization
- Replace direct access to backlight_properties with get and set
  operations

Signed-off-by: Sam Ravnborg <sam at ravnborg.org>
Cc: Alex Deucher <alexander.deucher at amd.com>
Cc: Christian König <christian.koenig at amd.com>
Cc: amd-gfx at lists.freedesktop.org
Cc: Sam Ravnborg <sam at ravnborg.org>
---
 .../gpu/drm/amd/amdgpu/atombios_encoders.c    | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c
index 1e94a9b652f7..882e1a3dad8b 100644
--- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c
+++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c
@@ -122,15 +122,16 @@ amdgpu_atombios_encoder_set_backlight_level(struct amdgpu_encoder *amdgpu_encode
 
 static u8 amdgpu_atombios_encoder_backlight_level(struct backlight_device *bd)
 {
+	int brightness = backlight_get_brightness(bd);
 	u8 level;
 
 	/* Convert brightness to hardware level */
-	if (bd->props.brightness < 0)
+	if (brightness < 0)
 		level = 0;
-	else if (bd->props.brightness > AMDGPU_MAX_BL_LEVEL)
+	else if (brightness > AMDGPU_MAX_BL_LEVEL)
 		level = AMDGPU_MAX_BL_LEVEL;
 	else
-		level = bd->props.brightness;
+		level = brightness;
 
 	return level;
 }
@@ -165,13 +166,12 @@ static const struct backlight_ops amdgpu_atombios_encoder_backlight_ops = {
 void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encoder,
 				     struct drm_connector *drm_connector)
 {
+	DECLARE_BACKLIGHT_INIT_RAW(props, 0, AMDGPU_MAX_BL_LEVEL);
 	struct drm_device *dev = amdgpu_encoder->base.dev;
 	struct amdgpu_device *adev = dev->dev_private;
 	struct backlight_device *bd;
-	struct backlight_properties props;
 	struct amdgpu_backlight_privdata *pdata;
 	struct amdgpu_encoder_atom_dig *dig;
-	u8 backlight_level;
 	char bl_name[16];
 
 	/* Mac laptops with multiple GPUs use the gmux driver for backlight
@@ -193,9 +193,6 @@ void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encode
 		goto error;
 	}
 
-	memset(&props, 0, sizeof(props));
-	props.max_brightness = AMDGPU_MAX_BL_LEVEL;
-	props.type = BACKLIGHT_RAW;
 	snprintf(bl_name, sizeof(bl_name),
 		 "amdgpu_bl%d", dev->primary->index);
 	bd = backlight_device_register(bl_name, drm_connector->kdev,
@@ -207,14 +204,10 @@ void amdgpu_atombios_encoder_init_backlight(struct amdgpu_encoder *amdgpu_encode
 
 	pdata->encoder = amdgpu_encoder;
 
-	backlight_level = amdgpu_atombios_encoder_get_backlight_level_from_reg(adev);
-
 	dig = amdgpu_encoder->enc_priv;
 	dig->bl_dev = bd;
 
-	bd->props.brightness = amdgpu_atombios_encoder_get_backlight_brightness(bd);
-	bd->props.power = FB_BLANK_UNBLANK;
-	backlight_update_status(bd);
+	backlight_enable_brightness(bd, amdgpu_atombios_encoder_get_backlight_brightness(bd));
 
 	DRM_INFO("amdgpu atom DIG backlight initialized\n");
 
-- 
2.25.1



More information about the amd-gfx mailing list