Skip to contentSkip to conversation

drm/amd: Don't fail on backlight = 0

PATCH In review David Francis 3 participants 3 messages Nov 6, 2018 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Don't fail on backlight = 0

Amgpu's backlight update status function was returning 1 (an error value) when the backlight property was 0. This breaks users that assume 0 is a valid backlight value (which is a correct assumption)

If the user passes in a backlight value of 0, tell them everything is fine, then write a value of 1 to hardware.

Bugzilla: https://bugs.freedesktop.org/108668

Fixes 416615ea9578 ("drm/amd/display: set backlight level limit to 1")
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -8
index f8ec8a146663..131e6483d442 100644
@@ -1567,21 +1567,23 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
 {
 	struct amdgpu_display_manager *dm = bl_get_data(bd);
 
+	/* backlight_pwm_u16_16 parameter is in unsigned 32 bit, 16 bit integer
+	 * and 16 bit fractional, where 1.0 is max backlight value.
+	 * bd->props.brightness is 8 bit format and needs to be converted by
+	 * scaling via copy lower byte to upper byte of 16 bit value.
+	 */
+	uint32_t brightness = bd->props.brightness * 0x101;
+
 	/*
 	 * PWM interperts 0 as 100% rather than 0% because of HW
-	 * limitation for level 0.So limiting minimum brightness level
+	 * limitation for level 0.  So limiting minimum brightness level
 	 * to 1.
 	 */
 	if (bd->props.brightness < 1)
-		return 1;
+		brightness = 0x101;
 
-	/* backlight_pwm_u16_16 parameter is in unsigned 32 bit, 16 bit integer
-	 * and 16 bit fractional, where 1.0 is max backlight value.
-	 * bd->props.brightness is 8 bit format and needs to be converted by
-	 * scaling via copy lower byte to upper byte of 16 bit value.
-	 */
 	if (dc_link_set_backlight_level(dm->backlight_link,
-			(bd->props.brightness * 0x101), 0, 0))
+			brightness, 0, 0))
 		return 0;
 	else
 		return 1;
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20181106161446.17462-1-David.Francis-5C7GfCeVMHo@public.gmane.org

#2 lore raw

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of David Francis <[email protected]>
Sent: Tuesday, November 6, 2018 11:14:46 AM
To: [email protected]
Cc: Francis, David; Samantham-VwIFZPTo/[email protected]; Wentland, Harry; Guttula, Suresh
Subject: [PATCH] drm/amd: Don't fail on backlight = 0

Amgpu's backlight update status function was
returning 1 (an error value) when the backlight
property was 0. This breaks users that assume
0 is a valid backlight value (which is a
correct assumption)

If the user passes in a backlight value of 0, tell them everything is fine, then write a value of 1 to hardware.

Bugzilla: https://bugs.freedesktop.org/108668

Fixes 416615ea9578 ("drm/amd/display: set backlight level limit to 1")
Cc Samantham-VwIFZPTo/[email protected]
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -8
index f8ec8a146663..131e6483d442 100644
@@ -1567,21 +1567,23 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
 {
         struct amdgpu_display_manager *dm = bl_get_data(bd);
 
+       /* backlight_pwm_u16_16 parameter is in unsigned 32 bit, 16 bit integer
+        * and 16 bit fractional, where 1.0 is max backlight value.
+        * bd->props.brightness is 8 bit format and needs to be converted by
+        * scaling via copy lower byte to upper byte of 16 bit value.
+        */
+       uint32_t brightness = bd->props.brightness * 0x101;
+
         /*
          * PWM interperts 0 as 100% rather than 0% because of HW
-        * limitation for level 0.So limiting minimum brightness level
+        * limitation for level 0.  So limiting minimum brightness level
          * to 1.
          */
         if (bd->props.brightness < 1)
-               return 1;
+               brightness = 0x101;
 
-       /* backlight_pwm_u16_16 parameter is in unsigned 32 bit, 16 bit integer
-        * and 16 bit fractional, where 1.0 is max backlight value.
-        * bd->props.brightness is 8 bit format and needs to be converted by
-        * scaling via copy lower byte to upper byte of 16 bit value.
-        */
         if (dc_link_set_backlight_level(dm->backlight_link,
-                       (bd->props.brightness * 0x101), 0, 0))
+                       brightness, 0, 0))
                 return 0;
         else
                 return 1;

--
2.17.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Harry Wentland
#3 lore raw
In reply to a message not in the archive
Quoted 11 lines · David Francis

Amgpu's backlight update status function was returning 1 (an error value) when the backlight property was 0. This breaks users that assume 0 is a valid backlight value (which is a correct assumption)

If the user passes in a backlight value of 0, tell them everything is fine, then write a value of 1 to hardware.

Harry

Quoted 36 lines

Bugzilla: https://bugs.freedesktop.org/108668

Fixes 416615ea9578 ("drm/amd/display: set backlight level limit to 1")
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +9 -3
index f8ec8a146663..131e6483d442 100644
@@ -1567,21 +1567,23 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
 {
 	struct amdgpu_display_manager *dm = bl_get_data(bd);
 
+	/* backlight_pwm_u16_16 parameter is in unsigned 32 bit, 16 bit integer
+	 * and 16 bit fractional, where 1.0 is max backlight value.
+	 * bd->props.brightness is 8 bit format and needs to be converted by
+	 * scaling via copy lower byte to upper byte of 16 bit value.
+	 */
+	uint32_t brightness = bd->props.brightness * 0x101;
+
 	/*
 	 * PWM interperts 0 as 100% rather than 0% because of HW
-	 * limitation for level 0.So limiting minimum brightness level
+	 * limitation for level 0.  So limiting minimum brightness level
 	 * to 1.
 	 */
 	if (bd->props.brightness < 1)
-		return 1;
+		brightness = 0x101;
 
-	/* backlight_pwm_u16_16 parameter is in unsigned 32 bit, 16 bit integer

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int amdgpu_dm_backlight_update_status(struct backlight_device *bd) · line 1589

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -5
-	 * and 16 bit fractional, where 1.0 is max backlight value.
-	 * bd->props.brightness is 8 bit format and needs to be converted by
-	 * scaling via copy lower byte to upper byte of 16 bit value.
-	 */
 	if (dc_link_set_backlight_level(dm->backlight_link,
-			(bd->props.brightness * 0x101), 0, 0))
+			brightness, 0, 0))
 		return 0;
 	else
 		return 1;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx