drm/amd/display: Fix default DC and AC levels
authorMario Limonciello <mario.limonciello@amd.com>
Wed, 14 May 2025 21:06:40 +0000 (16:06 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 3 Jun 2025 19:33:38 +0000 (15:33 -0400)
[Why]
DC and AC levels are advertised in a percentage, not a luminance.

[How]
Scale DC and AC levels to supported values.

Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4221
Reviewed-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Wayne Lin <wayne.lin@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index 588f6af..d3100f6 100644 (file)
@@ -4925,9 +4925,9 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
        amdgpu_acpi_get_backlight_caps(&caps);
        if (caps.caps_valid && get_brightness_range(&caps, &min, &max)) {
                if (power_supply_is_system_supplied() > 0)
-                       props.brightness = caps.ac_level;
+                       props.brightness = (max - min) * DIV_ROUND_CLOSEST(caps.ac_level, 100);
                else
-                       props.brightness = caps.dc_level;
+                       props.brightness = (max - min) * DIV_ROUND_CLOSEST(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,