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

Message ID 20221031163211.13228-1-antoniospg100@gmail.com
State New
Headers
Series drm/nouveau: Add support to control backlight using bl_power for nva3. |

Commit Message

Antonio Gomes Oct. 31, 2022, 4:32 p.m. UTC
  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

Signed-off-by: antoniospg <antoniospg100@gmail.com>
---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Bagas Sanjaya Nov. 1, 2022, 2:11 a.m. UTC | #1
On 10/31/22 23:32, antoniospg wrote:
> 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.

> 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.
  
Karol Herbst Nov. 1, 2022, 10:41 a.m. UTC | #2
On Tue, Nov 1, 2022 at 3:12 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
>
> On 10/31/22 23:32, antoniospg wrote:
> > 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.
>

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

> > 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?

> 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.

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

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index a2141d3d9b1d..5c82f5189b79 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -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 |