[PATCH AUTOSEL 6.17] drm/amd/display: Indicate when custom brightness curves are in use
From: Sasha Levin <sashal@kernel.org>
Date: 2025-10-25 16:21:11
Also in:
linux-patches
Subsystem:
amd display core, drm drivers, radeon and amdgpu drm drivers, the rest · Maintainers:
Harry Wentland, Leo Li, David Airlie, Simona Vetter, Alex Deucher, Christian König, Linus Torvalds
From: Mario Limonciello <superm1@kernel.org>
[ Upstream commit 68f3c044f37d9f50d67417fa8018d9cf16423458 ]
[Why]
There is a `scale` sysfs attribute that can be used to indicate when
non-linear brightness scaling is in use. As Custom brightness curves
work by linear interpolation of points the scale is no longer linear.
[How]
Indicate non-linear scaling when custom brightness curves in use and
linear scaling otherwise.
Reviewed-by: Alex Hung <redacted>
Signed-off-by: Mario Limonciello <superm1@kernel.org>
Signed-off-by: Wayne Lin <redacted>
Tested-by: Dan Wheeler <redacted>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
LLM Generated explanations, may be completely bogus:
YES
- What it changes
- Sets `backlight_properties.scale` during backlight registration to
reflect actual brightness scaling:
- Marks non-linear when custom brightness curves are used:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5071
- Marks linear otherwise:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5073
- Gate is identical to where custom curves are actually applied
(`caps->data_points` present and debug mask not set):
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5069
- Why it matters (user-visible bug)
- The backlight class exposes a sysfs `scale` attribute that reports
the brightness scale type from `bd->props.scale`:
drivers/video/backlight/backlight.c:264
- Without this patch, AMDGPU leaves `props.scale` at its zero-
initialized default (unknown) due to `props = { 0 }`:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:5041
- When custom brightness curves are in use, AMDGPU actually performs a
piecewise linear interpolation of luminance vs. input signal (i.e.,
non-linear to the user’s scale), see the interpolation path and the
same debug-mask gate:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:4826
- Reporting “unknown” is inaccurate and prevents userspace from
correctly indicating or adapting to non-linear scaling.
- Scope and risk
- Small, localized change in a single function at device registration
time; no architectural changes.
- Does not alter brightness programming, only improves sysfs
reporting. The backlight core only reads `props.scale` for the
`scale` sysfs attribute (no behavioral dependency):
drivers/video/backlight/backlight.c:264
- Uses established backlight scale enums: `BACKLIGHT_SCALE_LINEAR` and
`BACKLIGHT_SCALE_NON_LINEAR`: include/linux/backlight.h:83,
include/linux/backlight.h:91
- Matches existing pattern in other backlight drivers that already set
`props.scale`.
- Stable backport criteria
- Fixes a user-visible correctness issue (sysfs attribute previously
“unknown” despite known scaling behavior).
- Minimal risk of regression; confined to AMDGPU backlight
registration.
- No new features or ABI additions—just accurate population of an
existing, stable attribute.
- Note on applicability
- Targets stable trees that already have `backlight_properties.scale`
and the `scale` sysfs attribute. For trees lacking these, mechanical
backporting would need adaptation, but for kernels with the field
present, this is straightforward and safe.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ++++-
1 file changed, 4 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 afe3a8279c3a9..8eb2fc4133487 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c@@ -5032,8 +5032,11 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector) } else props.brightness = props.max_brightness = MAX_BACKLIGHT_LEVEL; - if (caps->data_points && !(amdgpu_dc_debug_mask & DC_DISABLE_CUSTOM_BRIGHTNESS_CURVE)) + 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; + } else + props.scale = BACKLIGHT_SCALE_LINEAR; props.type = BACKLIGHT_RAW; snprintf(bl_name, sizeof(bl_name), "amdgpu_bl%d",
--
2.51.0