All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Scale custom brightness curve from full range
@ 2026-08-13 17:09 Akhmed Zhitaev
  2026-08-13 17:25 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Akhmed Zhitaev @ 2026-08-13 17:09 UTC (permalink / raw)
  To: amd-gfx
  Cc: harry.wentland, sunpeng.li, siqueira, alexander.deucher,
	christian.koenig, airlied, simona, mario.limonciello, alex.hung,
	roman.li, stable, dri-devel, linux-kernel, Akhmed Zhitaev

Custom brightness curves use an 8-bit input signal.  After exporting the
full PWM range to userspace, the curve normalizer still divides requests
by the physical PWM span.  On panels with a nonzero minimum PWM level,
this can produce a curve input greater than 255 and send an invalid
backlight level to DC.

Scale the userspace [0..max] range to the curve's [0..255] range
instead.  This retains the full advertised range and keeps the reverse
readback conversion unchanged.

Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace")
Cc: stable@vger.kernel.org
Signed-off-by: Akhmed Zhitaev <zhitaevakh@gmail.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 40d82a3ee..533c69f0b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5131,10 +5131,10 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
 	return 1;
 }
 
-/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
-static inline u32 scale_input_to_fw(int min, int max, u64 input)
+/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
+static inline u32 scale_input_to_fw(int max, u64 input)
 {
-	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max - min);
+	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
 }
 
 /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
@@ -5147,7 +5147,7 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap
 				      unsigned int min, unsigned int max,
 				      uint32_t *user_brightness)
 {
-	u32 brightness = scale_input_to_fw(min, max, *user_brightness);
+	u32 brightness = scale_input_to_fw(max, *user_brightness);
 	u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
 	int left, right;
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: Scale custom brightness curve from full range
  2026-08-13 17:09 [PATCH] drm/amd/display: Scale custom brightness curve from full range Akhmed Zhitaev
@ 2026-08-13 17:25 ` sashiko-bot
  2026-08-13 17:45 ` Mario Limonciello
  2026-08-13 19:38 ` Mario Limonciello
  2 siblings, 0 replies; 7+ messages in thread
From: sashiko-bot @ 2026-08-13 17:25 UTC (permalink / raw)
  To: Akhmed Zhitaev; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Double scaling of the brightness value when a custom brightness curve is used, causing the minimum backlight level to be incorrectly raised.
--

--- Patch [1]: [PATCH] drm/amd/display: Scale custom brightness curve from full range ---
commit d7add749f0052e896a6fee3206021e51b2fd8540
Author: Akhmed Zhitaev <zhitaevakh@gmail.com>

drm/amd/display: Scale custom brightness curve from full range

This patch changes the input scaling for custom brightness curves to
map the userspace [0..max] range to the curve's [0..255] range. This
prevents generating a curve input greater than 255 for panels with a
nonzero minimum PWM level.

> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 941c1a3128249..7908b15370845 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
[ ... ]
> -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
> -static inline u32 scale_input_to_fw(int min, int max, u64 input)
> +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
> +static inline u32 scale_input_to_fw(int max, u64 input)
>  {
> -	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max - min);
> +	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
>  }
>  
>  /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
> @@ -5281,7 +5281,7 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap
>  				      unsigned int min, unsigned int max,
>  				      uint32_t *user_brightness)
>  {
> -	u32 brightness = scale_input_to_fw(min, max, *user_brightness);
> +	u32 brightness = scale_input_to_fw(max, *user_brightness);
>  	u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
>  	int left, right;

[Severity: High]
This isn't a bug introduced by this patch, but does the current code
double-scale the brightness when a custom brightness curve is used?

Looking at scale_fw_to_input() in drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c,
it maps the curve's [0..255] output to [min..max]:

static inline u32 scale_fw_to_input(int min, int max, u64 input)
{
	return min + DIV_ROUND_CLOSEST_ULL(input * (max - min),
					   AMDGPU_MAX_BL_LEVEL);
}

This is used at the end of convert_custom_brightness(), meaning the output
brightness value is returned in the [min..max] range.

However, in convert_brightness_from_user(), the output gets rescaled again:

	convert_custom_brightness(caps, min, max, &brightness);

	// Rescale 0..max to min..max
	return min + DIV_ROUND_CLOSEST_ULL((u64)(max - min) * brightness, max);

Because scale_fw_to_input() already mapped it to [min..max], and
convert_brightness_from_user() rescales it to [min..max] again under the
assumption that the value is in [0..max], the minimum offset is applied twice.

Since this patch explicitly aims to fix the brightness scaling logic introduced
by commit 8dbd72cb7900, should scale_fw_to_input() or
convert_brightness_from_user() also be updated to avoid raising the minimum
backlight level incorrectly for panels using custom brightness curves?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260813170959.22073-1-zhitaevakh@gmail.com?part=1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: Scale custom brightness curve from full range
  2026-08-13 17:09 [PATCH] drm/amd/display: Scale custom brightness curve from full range Akhmed Zhitaev
  2026-08-13 17:25 ` sashiko-bot
@ 2026-08-13 17:45 ` Mario Limonciello
  2026-08-13 18:18   ` Ахмед Житаев
  2026-08-13 18:26   ` Ахмед Житаев
  2026-08-13 19:38 ` Mario Limonciello
  2 siblings, 2 replies; 7+ messages in thread
From: Mario Limonciello @ 2026-08-13 17:45 UTC (permalink / raw)
  To: Akhmed Zhitaev, amd-gfx
  Cc: harry.wentland, sunpeng.li, siqueira, alexander.deucher,
	christian.koenig, airlied, simona, alex.hung, roman.li, stable,
	dri-devel, linux-kernel



On 8/13/26 12:09, Akhmed Zhitaev wrote:
> Custom brightness curves use an 8-bit input signal.  After exporting the
> full PWM range to userspace, the curve normalizer still divides requests
> by the physical PWM span.  On panels with a nonzero minimum PWM level,
> this can produce a curve input greater than 255 and send an invalid
> backlight level to DC.
> 
> Scale the userspace [0..max] range to the curve's [0..255] range
> instead.  This retains the full advertised range and keeps the reverse
> readback conversion unchanged.
> 
> Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace")
> Cc: stable@vger.kernel.org
> Signed-off-by: Akhmed Zhitaev <zhitaevakh@gmail.com>
> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 40d82a3ee..533c69f0b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5131,10 +5131,10 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
>   	return 1;
>   }
>   
> -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
> -static inline u32 scale_input_to_fw(int min, int max, u64 input)
> +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
> +static inline u32 scale_input_to_fw(int max, u64 input)
>   {
> -	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max - min);
> +	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
>   }
>   
>   /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
> @@ -5147,7 +5147,7 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap
>   				      unsigned int min, unsigned int max,
>   				      uint32_t *user_brightness)
>   {
> -	u32 brightness = scale_input_to_fw(min, max, *user_brightness);
> +	u32 brightness = scale_input_to_fw(max, *user_brightness);
>   	u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
>   	int left, right;
>   

Is this still needed with

"drm/amd/display: Fix backlight max_brightness to match exported range"

https://github.com/torvalds/linux/commit/f1b5d8f9cc54ae8a2567ac126867ae488e1bf625

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: Scale custom brightness curve from full range
  2026-08-13 17:45 ` Mario Limonciello
@ 2026-08-13 18:18   ` Ахмед Житаев
  2026-08-13 18:26   ` Ахмед Житаев
  1 sibling, 0 replies; 7+ messages in thread
From: Ахмед Житаев @ 2026-08-13 18:18 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: amd-gfx, harry.wentland, sunpeng.li, siqueira, alexander.deucher,
	christian.koenig, airlied, simona, alex.hung, roman.li, stable,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3384 bytes --]

Yes, this is still needed.

f1b5d8f9cc54 fixes the advertised max_brightness mismatch by restoring the
full userspace range [0..max].

The issue fixed by this patch is different: the custom brightness curve
input is still normalized by (max - min). On panels with a non-zero PWM
minimum, valid userspace requests near the top of the [0..max] range can
therefore produce a curve input above 255.

On my panel, min=3084 and max=65535. Without this patch, requests above the
upper boundary caused the backlight to drop dark; with this patch, the full
range maps into [0..255] and the issue no longer reproduces.

I also tested with the f1b5d8f9cc54 semantics present, so the regression is
still present without this change.


чт, 13 авг. 2026 г. в 22:45, Mario Limonciello <mario.limonciello@amd.com>:

>
>
> On 8/13/26 12:09, Akhmed Zhitaev wrote:
> > Custom brightness curves use an 8-bit input signal.  After exporting the
> > full PWM range to userspace, the curve normalizer still divides requests
> > by the physical PWM span.  On panels with a nonzero minimum PWM level,
> > this can produce a curve input greater than 255 and send an invalid
> > backlight level to DC.
> >
> > Scale the userspace [0..max] range to the curve's [0..255] range
> > instead.  This retains the full advertised range and keeps the reverse
> > readback conversion unchanged.
> >
> > Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to
> userspace")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Akhmed Zhitaev <zhitaevakh@gmail.com>
> > ---
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 40d82a3ee..533c69f0b 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -5131,10 +5131,10 @@ static int get_brightness_range(const struct
> amdgpu_dm_backlight_caps *caps,
> >       return 1;
> >   }
> >
> > -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
> > -static inline u32 scale_input_to_fw(int min, int max, u64 input)
> > +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
> > +static inline u32 scale_input_to_fw(int max, u64 input)
> >   {
> > -     return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max -
> min);
> > +     return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
> >   }
> >
> >   /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
> > @@ -5147,7 +5147,7 @@ static void convert_custom_brightness(const struct
> amdgpu_dm_backlight_caps *cap
> >                                     unsigned int min, unsigned int max,
> >                                     uint32_t *user_brightness)
> >   {
> > -     u32 brightness = scale_input_to_fw(min, max, *user_brightness);
> > +     u32 brightness = scale_input_to_fw(max, *user_brightness);
> >       u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
> >       int left, right;
> >
>
> Is this still needed with
>
> "drm/amd/display: Fix backlight max_brightness to match exported range"
>
>
> https://github.com/torvalds/linux/commit/f1b5d8f9cc54ae8a2567ac126867ae488e1bf625
>

[-- Attachment #2: Type: text/html, Size: 4541 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: Scale custom brightness curve from full range
  2026-08-13 17:45 ` Mario Limonciello
  2026-08-13 18:18   ` Ахмед Житаев
@ 2026-08-13 18:26   ` Ахмед Житаев
  1 sibling, 0 replies; 7+ messages in thread
From: Ахмед Житаев @ 2026-08-13 18:26 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: amd-gfx, harry.wentland, sunpeng.li, siqueira, alexander.deucher,
	christian.koenig, airlied, simona, alex.hung, roman.li, stable,
	dri-devel, linux-kernel

Yes, this is still needed.

f1b5d8f9cc54 fixes the advertised max_brightness mismatch by restoring
the full userspace range [0..max].

The issue fixed by this patch is different: the custom brightness curve
input is still normalized by (max - min). On panels with a non-zero PWM
minimum, valid userspace requests near the top of the [0..max] range can
therefore produce a curve input above 255.

On my panel, min=3084 and max=65535. Without this patch, requests above
the upper boundary caused the backlight to drop dark; with this patch,
the full range maps into [0..255] and the issue no longer reproduces.

I also tested with the f1b5d8f9cc54 semantics present, so the regression
is still present without this change.


чт, 13 авг. 2026 г. в 22:45, Mario Limonciello <mario.limonciello@amd.com>:
>
>
>
> On 8/13/26 12:09, Akhmed Zhitaev wrote:
> > Custom brightness curves use an 8-bit input signal.  After exporting the
> > full PWM range to userspace, the curve normalizer still divides requests
> > by the physical PWM span.  On panels with a nonzero minimum PWM level,
> > this can produce a curve input greater than 255 and send an invalid
> > backlight level to DC.
> >
> > Scale the userspace [0..max] range to the curve's [0..255] range
> > instead.  This retains the full advertised range and keeps the reverse
> > readback conversion unchanged.
> >
> > Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Akhmed Zhitaev <zhitaevakh@gmail.com>
> > ---
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 40d82a3ee..533c69f0b 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -5131,10 +5131,10 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
> >       return 1;
> >   }
> >
> > -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
> > -static inline u32 scale_input_to_fw(int min, int max, u64 input)
> > +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
> > +static inline u32 scale_input_to_fw(int max, u64 input)
> >   {
> > -     return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max - min);
> > +     return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
> >   }
> >
> >   /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
> > @@ -5147,7 +5147,7 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap
> >                                     unsigned int min, unsigned int max,
> >                                     uint32_t *user_brightness)
> >   {
> > -     u32 brightness = scale_input_to_fw(min, max, *user_brightness);
> > +     u32 brightness = scale_input_to_fw(max, *user_brightness);
> >       u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
> >       int left, right;
> >
>
> Is this still needed with
>
> "drm/amd/display: Fix backlight max_brightness to match exported range"
>
> https://github.com/torvalds/linux/commit/f1b5d8f9cc54ae8a2567ac126867ae488e1bf625

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: Scale custom brightness curve from full range
  2026-08-13 17:09 [PATCH] drm/amd/display: Scale custom brightness curve from full range Akhmed Zhitaev
  2026-08-13 17:25 ` sashiko-bot
  2026-08-13 17:45 ` Mario Limonciello
@ 2026-08-13 19:38 ` Mario Limonciello
  2026-08-13 22:22   ` Ахмед Житаев
  2 siblings, 1 reply; 7+ messages in thread
From: Mario Limonciello @ 2026-08-13 19:38 UTC (permalink / raw)
  To: Akhmed Zhitaev, amd-gfx
  Cc: harry.wentland, sunpeng.li, siqueira, alexander.deucher,
	christian.koenig, airlied, simona, alex.hung, roman.li, stable,
	dri-devel, linux-kernel



On 8/13/26 12:09, Akhmed Zhitaev wrote:
> Custom brightness curves use an 8-bit input signal.  After exporting the
> full PWM range to userspace, the curve normalizer still divides requests
> by the physical PWM span.  On panels with a nonzero minimum PWM level,
> this can produce a curve input greater than 255 and send an invalid
> backlight level to DC.
> 
> Scale the userspace [0..max] range to the curve's [0..255] range
> instead.  This retains the full advertised range and keeps the reverse
> readback conversion unchanged.
> 
> Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to userspace")
> Cc: stable@vger.kernel.org
> Signed-off-by: Akhmed Zhitaev <zhitaevakh@gmail.com>

Thanks for this.

We have moved the code in amd-staging-drm-next

https://gitlab.freedesktop.org/agd5f/linux/-/commit/6c2b46e9774f13e45985f6da9f7d5f8458767b98

As your changes are trivial, I'll adjust while commiting.

Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>

> ---
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 40d82a3ee..533c69f0b 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5131,10 +5131,10 @@ static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
>   	return 1;
>   }
>   
> -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
> -static inline u32 scale_input_to_fw(int min, int max, u64 input)
> +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
> +static inline u32 scale_input_to_fw(int max, u64 input)
>   {
> -	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max - min);
> +	return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
>   }
>   
>   /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
> @@ -5147,7 +5147,7 @@ static void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *cap
>   				      unsigned int min, unsigned int max,
>   				      uint32_t *user_brightness)
>   {
> -	u32 brightness = scale_input_to_fw(min, max, *user_brightness);
> +	u32 brightness = scale_input_to_fw(max, *user_brightness);
>   	u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
>   	int left, right;
>   


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] drm/amd/display: Scale custom brightness curve from full range
  2026-08-13 19:38 ` Mario Limonciello
@ 2026-08-13 22:22   ` Ахмед Житаев
  0 siblings, 0 replies; 7+ messages in thread
From: Ахмед Житаев @ 2026-08-13 22:22 UTC (permalink / raw)
  To: superm1
  Cc: amd-gfx, harry.wentland, sunpeng.li, siqueira, alexander.deucher,
	christian.koenig, airlied, simona, alex.hung, roman.li, stable,
	dri-devel, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2940 bytes --]

🎉

Реакция пользователя Ахмед через Gmail
<https://www.google.com/gmail/about/?utm_source=gmail-in-product&utm_medium=et&utm_campaign=emojireactionemail#app>

пт, 14 авг. 2026 г., 00:38 Mario Limonciello <superm1@kernel.org>:

>
>
> On 8/13/26 12:09, Akhmed Zhitaev wrote:
> > Custom brightness curves use an 8-bit input signal.  After exporting the
> > full PWM range to userspace, the curve normalizer still divides requests
> > by the physical PWM span.  On panels with a nonzero minimum PWM level,
> > this can produce a curve input greater than 255 and send an invalid
> > backlight level to DC.
> >
> > Scale the userspace [0..max] range to the curve's [0..255] range
> > instead.  This retains the full advertised range and keeps the reverse
> > readback conversion unchanged.
> >
> > Fixes: 8dbd72cb7900 ("drm/amd/display: Export full brightness range to
> userspace")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Akhmed Zhitaev <zhitaevakh@gmail.com>
>
> Thanks for this.
>
> We have moved the code in amd-staging-drm-next
>
>
> https://gitlab.freedesktop.org/agd5f/linux/-/commit/6c2b46e9774f13e45985f6da9f7d5f8458767b98
>
> As your changes are trivial, I'll adjust while commiting.
>
> Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>
> > ---
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > index 40d82a3ee..533c69f0b 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -5131,10 +5131,10 @@ static int get_brightness_range(const struct
> amdgpu_dm_backlight_caps *caps,
> >       return 1;
> >   }
> >
> > -/* Rescale from [min..max] to [0..AMDGPU_MAX_BL_LEVEL] */
> > -static inline u32 scale_input_to_fw(int min, int max, u64 input)
> > +/* Rescale userspace [0..max] to the firmware curve's [0..255]. */
> > +static inline u32 scale_input_to_fw(int max, u64 input)
> >   {
> > -     return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max -
> min);
> > +     return DIV_ROUND_CLOSEST_ULL(input * AMDGPU_MAX_BL_LEVEL, max);
> >   }
> >
> >   /* Rescale from [0..AMDGPU_MAX_BL_LEVEL] to [min..max] */
> > @@ -5147,7 +5147,7 @@ static void convert_custom_brightness(const struct
> amdgpu_dm_backlight_caps *cap
> >                                     unsigned int min, unsigned int max,
> >                                     uint32_t *user_brightness)
> >   {
> > -     u32 brightness = scale_input_to_fw(min, max, *user_brightness);
> > +     u32 brightness = scale_input_to_fw(max, *user_brightness);
> >       u8 lower_signal, upper_signal, upper_lum, lower_lum, lum;
> >       int left, right;
> >
>
>

[-- Attachment #2: Type: text/vnd.google.email-reaction+json, Size: 40 bytes --]

{
  "emoji": "🎉",
  "version": 1
}

[-- Attachment #3: Type: text/html, Size: 4119 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-14  7:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 17:09 [PATCH] drm/amd/display: Scale custom brightness curve from full range Akhmed Zhitaev
2026-08-13 17:25 ` sashiko-bot
2026-08-13 17:45 ` Mario Limonciello
2026-08-13 18:18   ` Ахмед Житаев
2026-08-13 18:26   ` Ахмед Житаев
2026-08-13 19:38 ` Mario Limonciello
2026-08-13 22:22   ` Ахмед Житаев

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.