[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0f094c4b-d2a3-42cd-824c-dc2858a5618d@kernel.org>
Date: Sun, 20 Jul 2025 21:20:46 -0500
From: Mario Limonciello <superm1@...nel.org>
To: Lauri Tirkkonen <lauri@...ktheplanet.fi>, linux-kernel@...r.kernel.org
Cc: stable@...r.kernel.org, amd-gfx@...ts.freedesktop.org,
Wayne Lin <wayne.lin@....com>, Alex Deucher <alexander.deucher@....com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [REGRESSION] [PATCH v2] drm/amd/display: fix initial backlight
brightness calculation
On 7/20/25 7:59 PM, Lauri Tirkkonen wrote:
> DIV_ROUND_CLOSEST(x, 100) returns either 0 or 1 if 0<x<=100, so the
> division needs to be performed after the multiplication and not the
> other way around, to properly scale the value.
>
> Fixes: 8b5f3a229a70 ("drm/amd/display: Fix default DC and AC levels")
> Signed-off-by: Lauri Tirkkonen <lauri@...ktheplanet.fi>
> Cc: stable@...r.kernel.org
Thanks so much!
Reviewed-by: Mario Limonciello <mario.limonciello@....com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 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 f58fa5da7fe5..8a5b5dfad1ab 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -4941,9 +4941,9 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> caps = &dm->backlight_caps[aconnector->bl_idx];
> if (get_brightness_range(caps, &min, &max)) {
> if (power_supply_is_system_supplied() > 0)
> - props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps->ac_level, 100);
> + props.brightness = DIV_ROUND_CLOSEST((max - min) * caps->ac_level, 100);
> else
> - props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps->dc_level, 100);
> + props.brightness = DIV_ROUND_CLOSEST((max - min) * caps->dc_level, 100);
> /* min is zero, so max needs to be adjusted */
> props.max_brightness = max - min;
> drm_dbg(drm, "Backlight caps: min: %d, max: %d, ac %d, dc %d\n", min, max,
Powered by blists - more mailing lists