All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Aarav Kumar" <aarav.240604@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amd/display: use linear backlight curve on Linux
Date: Tue, 01 Sep 2026 14:23:06 +0000	[thread overview]
Message-ID: <20260901142307.255B21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901140155.19129-1-aarav.240604@gmail.com>

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

New issues:
- [High] Enabling use_linear_backlight_curve creates an asymmetry between the backlight set and get operations, breaking readbacks.

Pre-existing issues:
- [High] Incorrect millipercent calculation adds the minimum brightness offset twice, artificially doubling the minimum backlight level.
--

commit d81c87ee8304f9423dd46886dacd5118c129a998
Author: Aarav Kumar <aarav.240604@gmail.com>

drm/amd/display: use linear backlight curve on Linux

This commit switches the power module to use a linear backlight curve
on Linux to preserve the existing brightness-to-PWM mapping. This fixes
incorrect brightness levels observed on affected systems.

Link: https://gitlab.freedesktop.org/drm/amd/-/work_items/5723

> 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 eb00c62c6f724..1ba74924859dc 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -418,7 +418,7 @@ static int amdgpu_dm_init_power_module(struct amdgpu_display_manager *dm)
>  			!(amdgpu_dc_feature_mask & DC_DISABLE_FRACTIONAL_PWM_MASK);
>  		init_data[i].use_custom_backlight_caps = false;
>  		init_data[i].custom_backlight_caps_config_no = 0;
> -		init_data[i].use_linear_backlight_curve = false;
> +		init_data[i].use_linear_backlight_curve = true;

[Severity: High]
Does enabling this flag create an asymmetry between the backlight set and get
operations?

When the write path uses the linear curve, the read path in
backlight_pwm_to_millipercent_legacy() in power_abm.c lacks support for this
flag and unconditionally performs a binary search on the non-linear ACPI LUT.

Can this cause sysfs readbacks to return incorrect values?

[Severity: High]
This isn't a bug introduced by this patch, but using the linear curve strictly
exposes an issue in the millipercent calculation in
amdgpu_dm_backlight_set_level() in amdgpu_dm_backlight.c.

In amdgpu_dm_backlight_set_level():

	brightness = convert_brightness_from_user(caps, dm->brightness[bl_idx]);
	...
	get_brightness_range(caps, &min, &max);
	brightness = DIV_ROUND_CLOSEST(brightness * 100, (max - min)) * 1000;

Since convert_brightness_from_user() returns an absolute value scaled between
min and max, computing the percentage without subtracting min first causes the
millipercent value to already contain the minimum offset.

When this is passed to backlight_millipercent_to_pwm_legacy(), which computes:

	min_backlight_pwm + (millipercent * range)

Does this artificially double the minimum backlight level and prevent the
screen from dimming properly?

>  		init_data[i].def_varibright_enable = 0;
>  		init_data[i].varibright_level = 0;
>  		/*

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

      reply	other threads:[~2026-09-01 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 14:01 [PATCH] drm/amd/display: use linear backlight curve on Linux Aarav Kumar
2026-09-01 14:23 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260901142307.255B21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=aarav.240604@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.