* [PATCH v1] drm/amd/display: Initialise backlight level values from hw
@ 2026-01-12 12:20 Vivek Das Mohapatra
2026-01-12 14:10 ` Mario Limonciello
0 siblings, 1 reply; 4+ messages in thread
From: Vivek Das Mohapatra @ 2026-01-12 12:20 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter
Cc: kernel, amd-gfx, dri-devel, linux-kernel
Internal backlight levels are initialised from ACPI but the values
are sometimes out of sync with the levels in effect until there has
been a read from hardware (eg triggered by reading from sysfs).
This means that the first drm_commit can cause the levels to be set
to a different value than the actual starting one, which results in
a sudden change in brightness.
This path shows the problem (when the values are out of sync):
amdgpu_dm_atomic_commit_tail()
-> amdgpu_dm_commit_streams()
-> amdgpu_dm_backlight_set_level(..., dm->brightness[n])
This patch calls the backlight ops get_brightness explicitly
at the end of backlight registration to make sure dm->brightness[n]
is in sync with the actual hardware levels.
Signed-off-by: Vivek Das Mohapatra <vivek@collabora.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
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 354e359c4507..50f0547ed63c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5258,6 +5258,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
struct amdgpu_dm_backlight_caps *caps;
char bl_name[16];
int min, max;
+ int real_brightness;
+ int init_brightness;
if (aconnector->bl_idx == -1)
return;
@@ -5282,6 +5284,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
} else
props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
+ init_brightness = props.brightness;
+
if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) {
drm_info(drm, "Using custom brightness curve\n");
props.scale = BACKLIGHT_SCALE_NON_LINEAR;
@@ -5297,6 +5301,18 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
&amdgpu_dm_backlight_ops, &props);
dm->brightness[aconnector->bl_idx] = props.brightness;
+ /*
+ * dm->brightness[x] can be inconsistent just after startup until
+ * ops.get_brightness is called.
+ */
+ real_brightness =
+ amdgpu_dm_backlight_ops.get_brightness(dm->backlight_dev[aconnector->bl_idx]);
+
+ if (real_brightness != init_brightness) {
+ dm->actual_brightness[aconnector->bl_idx] = real_brightness;
+ dm->brightness[aconnector->bl_idx] = real_brightness;
+ }
+
if (IS_ERR(dm->backlight_dev[aconnector->bl_idx])) {
drm_err(drm, "DM: Backlight registration failed!\n");
dm->backlight_dev[aconnector->bl_idx] = NULL;
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v1] drm/amd/display: Initialise backlight level values from hw
2026-01-12 12:20 [PATCH v1] drm/amd/display: Initialise backlight level values from hw Vivek Das Mohapatra
@ 2026-01-12 14:10 ` Mario Limonciello
2026-01-12 15:28 ` [PATCH v2] " Vivek Das Mohapatra
0 siblings, 1 reply; 4+ messages in thread
From: Mario Limonciello @ 2026-01-12 14:10 UTC (permalink / raw)
To: Vivek Das Mohapatra, Harry Wentland, Leo Li, Rodrigo Siqueira,
Alex Deucher, Christian König, David Airlie, Simona Vetter
Cc: kernel, amd-gfx, dri-devel, linux-kernel
On 1/12/26 6:20 AM, Vivek Das Mohapatra wrote:
> Internal backlight levels are initialised from ACPI but the values
> are sometimes out of sync with the levels in effect until there has
> been a read from hardware (eg triggered by reading from sysfs).
>
> This means that the first drm_commit can cause the levels to be set
> to a different value than the actual starting one, which results in
> a sudden change in brightness.
>
> This path shows the problem (when the values are out of sync):
>
> amdgpu_dm_atomic_commit_tail()
> -> amdgpu_dm_commit_streams()
> -> amdgpu_dm_backlight_set_level(..., dm->brightness[n])
>
> This patch calls the backlight ops get_brightness explicitly
> at the end of backlight registration to make sure dm->brightness[n]
> is in sync with the actual hardware levels.
>
> Signed-off-by: Vivek Das Mohapatra <vivek@collabora.com>
Thanks for the patch. One comment below.
> ---
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> 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 354e359c4507..50f0547ed63c 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5258,6 +5258,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> struct amdgpu_dm_backlight_caps *caps;
> char bl_name[16];
> int min, max;
> + int real_brightness;
> + int init_brightness;
>
> if (aconnector->bl_idx == -1)
> return;
> @@ -5282,6 +5284,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> } else
> props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
>
> + init_brightness = props.brightness;
> +
> if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) {
> drm_info(drm, "Using custom brightness curve\n");
> props.scale = BACKLIGHT_SCALE_NON_LINEAR;
> @@ -5297,6 +5301,18 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> &amdgpu_dm_backlight_ops, &props);
> dm->brightness[aconnector->bl_idx] = props.brightness;
>
> + /*
> + * dm->brightness[x] can be inconsistent just after startup until
> + * ops.get_brightness is called.
> + */
> + real_brightness =
> + amdgpu_dm_backlight_ops.get_brightness(dm->backlight_dev[aconnector->bl_idx]);
> +
> + if (real_brightness != init_brightness) {
> + dm->actual_brightness[aconnector->bl_idx] = real_brightness;
> + dm->brightness[aconnector->bl_idx] = real_brightness;
> + }
> +
I think this call should be after the IS_ERR() check right below it in
only the case that IS_ERR() failed.
> if (IS_ERR(dm->backlight_dev[aconnector->bl_idx])) {
> drm_err(drm, "DM: Backlight registration failed!\n");
> dm->backlight_dev[aconnector->bl_idx] = NULL;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] drm/amd/display: Initialise backlight level values from hw
2026-01-12 14:10 ` Mario Limonciello
@ 2026-01-12 15:28 ` Vivek Das Mohapatra
2026-01-12 15:52 ` Mario Limonciello
0 siblings, 1 reply; 4+ messages in thread
From: Vivek Das Mohapatra @ 2026-01-12 15:28 UTC (permalink / raw)
To: superm1
Cc: airlied, alexander.deucher, amd-gfx, christian.koenig, dri-devel,
harry.wentland, kernel, linux-kernel, simona, siqueira,
sunpeng.li, vivek
Internal backlight levels are initialised from ACPI but the values
are sometimes out of sync with the levels in effect until there has
been a read from hardware (eg triggered by reading from sysfs).
This means that the first drm_commit can cause the levels to be set
to a different value than the actual starting one, which results in
a sudden change in brightness.
This path shows the problem (when the values are out of sync):
amdgpu_dm_atomic_commit_tail()
-> amdgpu_dm_commit_streams()
-> amdgpu_dm_backlight_set_level(..., dm->brightness[n])
This patch calls the backlight ops get_brightness explicitly
at the end of backlight registration to make sure dm->brightness[n]
is in sync with the actual hardware levels.
Signed-off-by: Vivek Das Mohapatra <vivek@collabora.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
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 354e359c4507..9e8cbfeee915 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5258,6 +5258,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
struct amdgpu_dm_backlight_caps *caps;
char bl_name[16];
int min, max;
+ int real_brightness;
+ int init_brightness;
if (aconnector->bl_idx == -1)
return;
@@ -5282,6 +5284,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
} else
props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
+ init_brightness = props.brightness;
+
if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) {
drm_info(drm, "Using custom brightness curve\n");
props.scale = BACKLIGHT_SCALE_NON_LINEAR;
@@ -5300,8 +5304,20 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
if (IS_ERR(dm->backlight_dev[aconnector->bl_idx])) {
drm_err(drm, "DM: Backlight registration failed!\n");
dm->backlight_dev[aconnector->bl_idx] = NULL;
- } else
+ } else {
+ /*
+ * dm->brightness[x] can be inconsistent just after startup until
+ * ops.get_brightness is called.
+ */
+ real_brightness =
+ amdgpu_dm_backlight_ops.get_brightness(dm->backlight_dev[aconnector->bl_idx]);
+
+ if (real_brightness != init_brightness) {
+ dm->actual_brightness[aconnector->bl_idx] = real_brightness;
+ dm->brightness[aconnector->bl_idx] = real_brightness;
+ }
drm_dbg_driver(drm, "DM: Registered Backlight device: %s\n", bl_name);
+ }
}
static int initialize_plane(struct amdgpu_display_manager *dm,
--
2.39.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] drm/amd/display: Initialise backlight level values from hw
2026-01-12 15:28 ` [PATCH v2] " Vivek Das Mohapatra
@ 2026-01-12 15:52 ` Mario Limonciello
0 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2026-01-12 15:52 UTC (permalink / raw)
To: Vivek Das Mohapatra
Cc: airlied, alexander.deucher, amd-gfx, christian.koenig, dri-devel,
harry.wentland, kernel, linux-kernel, simona, siqueira,
sunpeng.li
On 1/12/26 9:28 AM, Vivek Das Mohapatra wrote:
> Internal backlight levels are initialised from ACPI but the values
> are sometimes out of sync with the levels in effect until there has
> been a read from hardware (eg triggered by reading from sysfs).
>
> This means that the first drm_commit can cause the levels to be set
> to a different value than the actual starting one, which results in
> a sudden change in brightness.
>
> This path shows the problem (when the values are out of sync):
>
> amdgpu_dm_atomic_commit_tail()
> -> amdgpu_dm_commit_streams()
> -> amdgpu_dm_backlight_set_level(..., dm->brightness[n])
>
> This patch calls the backlight ops get_brightness explicitly
> at the end of backlight registration to make sure dm->brightness[n]
> is in sync with the actual hardware levels.
>
> Signed-off-by: Vivek Das Mohapatra <vivek@collabora.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
> ---
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> 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 354e359c4507..9e8cbfeee915 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -5258,6 +5258,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> struct amdgpu_dm_backlight_caps *caps;
> char bl_name[16];
> int min, max;
> + int real_brightness;
> + int init_brightness;
>
> if (aconnector->bl_idx == -1)
> return;
> @@ -5282,6 +5284,8 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> } else
> props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL;
>
> + init_brightness = props.brightness;
> +
> if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) {
> drm_info(drm, "Using custom brightness curve\n");
> props.scale = BACKLIGHT_SCALE_NON_LINEAR;
> @@ -5300,8 +5304,20 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
> if (IS_ERR(dm->backlight_dev[aconnector->bl_idx])) {
> drm_err(drm, "DM: Backlight registration failed!\n");
> dm->backlight_dev[aconnector->bl_idx] = NULL;
> - } else
> + } else {
> + /*
> + * dm->brightness[x] can be inconsistent just after startup until
> + * ops.get_brightness is called.
> + */
> + real_brightness =
> + amdgpu_dm_backlight_ops.get_brightness(dm->backlight_dev[aconnector->bl_idx]);
> +
> + if (real_brightness != init_brightness) {
> + dm->actual_brightness[aconnector->bl_idx] = real_brightness;
> + dm->brightness[aconnector->bl_idx] = real_brightness;
> + }
> drm_dbg_driver(drm, "DM: Registered Backlight device: %s\n", bl_name);
> + }
> }
>
> static int initialize_plane(struct amdgpu_display_manager *dm,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-01-13 8:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-12 12:20 [PATCH v1] drm/amd/display: Initialise backlight level values from hw Vivek Das Mohapatra
2026-01-12 14:10 ` Mario Limonciello
2026-01-12 15:28 ` [PATCH v2] " Vivek Das Mohapatra
2026-01-12 15:52 ` Mario Limonciello
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox