antoniospg
2022-Oct-29 18:48 UTC
[Nouveau] [PATCH] 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 Signed-off-by: antoniospg <antoniospg100 at gmail.com> --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c index a2141d3d9b1d..855d0ce9f7fa 100644 --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c @@ -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 | -- 2.25.1
Bagas Sanjaya
2022-Oct-30 13:05 UTC
[Nouveau] [PATCH] drm/nouveau: Adding support to control backlight using bl_power for nva3.
On Sat, Oct 29, 2022 at 03:48:50PM -0300, antoniospg wrote:> 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. -- An old man doll... just what I always wanted! - Clara -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: not available URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20221030/8b81fdf0/attachment-0001.sig>
Sam Ravnborg
2022-Oct-30 20:48 UTC
[Nouveau] [PATCH] drm/nouveau: Adding support to control backlight using bl_power for nva3.
On Sat, Oct 29, 2022 at 03:48:50PM -0300, antoniospg wrote:> 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 at gmail.com> > --- > drivers/gpu/drm/nouveau/nouveau_backlight.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c > index a2141d3d9b1d..855d0ce9f7fa 100644 > --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c > +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c > @@ -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; > + } > +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
antoniospg
2022-Oct-31 16:32 UTC
[Nouveau] [PATCH] drm/nouveau: Add support to control backlight using bl_power for nva3.
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 at gmail.com> --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 | -- 2.25.1
Antonio Gomes
2022-Nov-04 22:01 UTC
[Nouveau] [PATCH v3] drm/nouveau: Add support to control backlight using bl_power for nva3.
From: antoniospg <antoniospg100 at gmail.com> 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 at gmail.com> --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 | -- 2.25.1
Antonio Gomes
2022-Nov-04 22:04 UTC
[Nouveau] [PATCH v3] drm/nouveau: Add support to control backlight using bl_power for nva3.
From: antoniospg <antoniospg100 at gmail.com> 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 at gmail.com> --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 | -- 2.25.1