Skip to contentSkip to conversation

drm/nouveau: Adding support to control backlight using bl_power for nva3.

PATCH In review antoniospg 4 participants 9 messages Oct 29, 2022 – Nov 9, 2022

Subsystems (3)
lore
Share & tools
lore

antoniospg

author
#0 lore raw

PATCH 1/1 drm/nouveau: Adding support to control backlight using bl_power for nva3.

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +10 -1
index a2141d3d9b1d..855d0ce9f7fa 100644
@@ -263,7 +263,16 @@ nva3_set_intensity(struct backlight_device *bd)
 	u32 div, val;
 
 	div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
-	val = (bd->props.brightness * div) / 100;
+
+	switch (bd->props.power) {
+	case FB_BLANK_UNBLANK:
+		val = (bd->props.brightness * div) / 100;
+		break;
+	default:
+		val = 0;
+		break;
+	}
+
 	if (div) {
 		nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
 			  val |
Signature · 1 line
2.25.1
#1 lore raw
Quoted 8 lines · antoniospg

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

You sent this patch twice, so I reply to the latest one.

What is it doing? Please describe the patch. Remember to write the description in imperative mood.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#2 lore raw
In reply to antoniospg
Quoted 22 lines · antoniospg

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +0 -1
index a2141d3d9b1d..855d0ce9f7fa 100644
@@ -263,7 +263,16 @@ nva3_set_intensity(struct backlight_device *bd)
 	u32 div, val;
 
 	div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
-	val = (bd->props.brightness * div) / 100;

drivers/gpu/drm/nouveau/nouveau_backlight.c nva3_set_intensity(struct backlight_device *bd) · line 275

Quoted 10 lines
drivers/gpu/drm/nouveau/nouveau_backlight.c +10 -0
+
+	switch (bd->props.power) {
+	case FB_BLANK_UNBLANK:
+		val = (bd->props.brightness * div) / 100;
+		break;
+	default:
+		val = 0;
+		break;
+	}
+

Consider the following change:

	val = backlight_get_brightness(bd);
	if (val)
		val = (val * dev) / 100;

Then you avoid hard coding the use of FB_BLANK_UNBLANK.

Sam

author
#3 lore raw

PATCH 1/1 drm/nouveau: Add support to control backlight using bl_power for nva3.

In reply to antoniospg

Summary:

* Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness.

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +5 -1
index a2141d3d9b1d..5c82f5189b79 100644
@@ -263,7 +263,11 @@ nva3_set_intensity(struct backlight_device *bd)
 	u32 div, val;
 
 	div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
-	val = (bd->props.brightness * div) / 100;
+
+	val = backlight_get_brightness(bd);
+	if (val)
+		val = (val * div) / 100;
+
 	if (div) {
 		nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
 			  val |
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH] drm/nouveau: Add support to control backlight using bl_power for nva3.

Quoted 6 lines · antoniospg

Summary:

* Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness.

This is [PATCH v2], right? If so, next time please pass -v <version number> to git-format-patch(1).

Also, just say the prose without using bullet list. "Summary:" line is also redundant. And again, please describe why this change be made.

Quoted 8 lines

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

Shouldn't "test plan" above be documented in Documentation/ instead?

Last but not least, is "antoniospg" your real, legal name?

Thanks.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#5 lore raw

Re: [PATCH] drm/nouveau: Add support to control backlight using bl_power for nva3.

Quoted 9 lines · Bagas Sanjaya
Quoted 6 lines · antoniospg

Summary:

* Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness.

Quoted 6 lines

This is [PATCH v2], right? If so, next time please pass -v <version number> to git-format-patch(1).

Also, just say the prose without using bullet list. "Summary:" line is also redundant. And again, please describe why this change be made.

it's right there in the title....

Quoted 11 lines
Quoted 8 lines

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

Shouldn't "test plan" above be documented in Documentation/ instead?

Given that's already existing infrastructure and is actually documented already (the existence of bl_power I mean), why would that be needed? I don't think it's needed to point that out in the commit log, but if the contributor chooses to document how the patch was tested, then why not?

Quoted 2 lines

Last but not least, is "antoniospg" your real, legal name?

Please leave those discussions to subsystem maintainers.

Saying that, if the contributors prefers to go by this name, this is good enough for me, but having a more explicit or detailed name (like fore- and surname) is generally prefered.

Quoted 5 lines

Thanks.

--
An old man doll... just what I always wanted! - Clara

#6 lore raw

PATCH v3 1/1 drm/nouveau: Add support to control backlight using bl_power for nva3.

In reply to antoniospg

From: antoniospg <[email protected]>

Summary:

* Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness.

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +5 -1
index a2141d3d9b1d..5c82f5189b79 100644
@@ -263,7 +263,11 @@ nva3_set_intensity(struct backlight_device *bd)
 	u32 div, val;
 
 	div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
-	val = (bd->props.brightness * div) / 100;
+
+	val = backlight_get_brightness(bd);
+	if (val)
+		val = (val * div) / 100;
+
 	if (div) {
 		nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
 			  val |
Signature · 1 line
2.25.1
#7 lore raw

PATCH v3 1/1 drm/nouveau: Add support to control backlight using bl_power for nva3.

In reply to antoniospg

From: antoniospg <[email protected]>

Summary:

* Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness.

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +5 -1
index a2141d3d9b1d..5c82f5189b79 100644
@@ -263,7 +263,11 @@ nva3_set_intensity(struct backlight_device *bd)
 	u32 div, val;
 
 	div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
-	val = (bd->props.brightness * div) / 100;
+
+	val = backlight_get_brightness(bd);
+	if (val)
+		val = (val * div) / 100;
+
 	if (div) {
 		nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
 			  val |
Signature · 1 line
2.25.1
Reviewed-by on v3 1/1
#8 lore raw

Re: [PATCH v3] drm/nouveau: Add support to control backlight using bl_power for nva3.

Quoted 40 lines · Antonio Gomes

From: antoniospg <[email protected]>

Summary:

* Add support to turn on/off backlight when changing values in bl_power file. This is achieved by using function backlight_get_brightness() in nva3_set_intensity to get current brightness.

Test plan:

* Turn off:
echo 1 > /sys/class/backlight/nv_backlight/bl_power

* Turn on:
echo 0 > /sys/class/backlight/nv_backlight/bl_power

---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +5 -2
index a2141d3d9b1d..5c82f5189b79 100644
@@ -263,7 +263,11 @@ nva3_set_intensity(struct backlight_device *bd)
        u32 div, val;
 
        div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or));
-       val = (bd->props.brightness * div) / 100;
+
+       val = backlight_get_brightness(bd);
+       if (val)
+               val = (val * div) / 100;
+
        if (div) {
                nvif_wr32(device, NV50_PDISP_SOR_PWM_CTL(or),
                          val |
--
Quoted 2 lines

2.25.1

btw, i'll fix up the name with the one from the Email From field, so you won't have to send it out again.