Skip to content

Commit 2fe87f5

Browse files
superm1alexdeucher
authored andcommitted
drm/amd/display: Set default brightness according to ACPI
Currently, amdgpu will always set up the brightness at 100% when it loads. However this is jarring when the BIOS has it previously programmed to a much lower value. The ACPI ATIF method includes two members for "ac_level" and "dc_level". These represent the default values that should be used if the system is brought up in AC and DC respectively. Use these values to set up the default brightness when the backlight device is registered. v2: squash in ACPI fix Reviewed-by: Leo Li <sunpeng.li@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent ee3942d commit 2fe87f5

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,6 +1567,7 @@ static inline int amdgpu_acpi_power_shift_control(struct amdgpu_device *adev,
15671567
u8 dev_state, bool drv_state) { return 0; }
15681568
static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev,
15691569
enum amdgpu_ss ss_state) { return 0; }
1570+
static inline void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps) { }
15701571
#endif
15711572

15721573
#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ static int amdgpu_atif_query_backlight_caps(struct amdgpu_atif *atif)
383383
characteristics.min_input_signal;
384384
atif->backlight_caps.max_input_signal =
385385
characteristics.max_input_signal;
386+
atif->backlight_caps.ac_level = characteristics.ac_level;
387+
atif->backlight_caps.dc_level = characteristics.dc_level;
386388
out:
387389
kfree(info);
388390
return err;
@@ -1268,6 +1270,8 @@ void amdgpu_acpi_get_backlight_caps(struct amdgpu_dm_backlight_caps *caps)
12681270
caps->caps_valid = atif->backlight_caps.caps_valid;
12691271
caps->min_input_signal = atif->backlight_caps.min_input_signal;
12701272
caps->max_input_signal = atif->backlight_caps.max_input_signal;
1273+
caps->ac_level = atif->backlight_caps.ac_level;
1274+
caps->dc_level = atif->backlight_caps.dc_level;
12711275
}
12721276

12731277
/**

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#include <linux/types.h>
7878
#include <linux/pm_runtime.h>
7979
#include <linux/pci.h>
80+
#include <linux/power_supply.h>
8081
#include <linux/firmware.h>
8182
#include <linux/component.h>
8283
#include <linux/dmi.h>
@@ -4571,6 +4572,7 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
45714572
struct drm_device *drm = aconnector->base.dev;
45724573
struct amdgpu_display_manager *dm = &drm_to_adev(drm)->dm;
45734574
struct backlight_properties props = { 0 };
4575+
struct amdgpu_dm_backlight_caps caps = { 0 };
45744576
char bl_name[16];
45754577

45764578
if (aconnector->bl_idx == -1)
@@ -4583,8 +4585,16 @@ amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector)
45834585
return;
45844586
}
45854587

4588+
amdgpu_acpi_get_backlight_caps(&caps);
4589+
if (caps.caps_valid) {
4590+
if (power_supply_is_system_supplied() > 0)
4591+
props.brightness = caps.ac_level;
4592+
else
4593+
props.brightness = caps.dc_level;
4594+
} else
4595+
props.brightness = AMDGPU_MAX_BL_LEVEL;
4596+
45864597
props.max_brightness = AMDGPU_MAX_BL_LEVEL;
4587-
props.brightness = AMDGPU_MAX_BL_LEVEL;
45884598
props.type = BACKLIGHT_RAW;
45894599

45904600
snprintf(bl_name, sizeof(bl_name), "amdgpu_bl%d",

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,14 @@ struct amdgpu_dm_backlight_caps {
180180
* @aux_support: Describes if the display supports AUX backlight.
181181
*/
182182
bool aux_support;
183+
/**
184+
* @ac_level: the default brightness if booted on AC
185+
*/
186+
u8 ac_level;
187+
/**
188+
* @dc_level: the default brightness if booted on DC
189+
*/
190+
u8 dc_level;
183191
};
184192

185193
/**

0 commit comments

Comments
 (0)