[PATCH] drm/amd/display: Guard ACPI calls with CONFIG_ACPI
Leo Li
sunpeng.li at amd.com
Mon Jun 10 15:44:13 UTC 2024
On 2024-06-10 11:32, Mario Limonciello wrote:
> On 6/10/2024 09:55, sunpeng.li at amd.com wrote:
>> From: Leo Li <sunpeng.li at amd.com>
>>
>> To fix CONFIG_ACPI disabled build error.
>>
>> Fixes: ec6f30c776ad ("drm/amd/display: Set default brightness according to ACPI")
>> Signed-off-by: Leo Li <sunpeng.li at amd.com>
>> ---
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 ++++++
>> 1 file changed, 6 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 a2c098f1b07c..6b3634db4c15 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -4572,7 +4572,9 @@ amdgpu_dm_register_backlight_device(struct
>> amdgpu_dm_connector *aconnector)
>> struct drm_device *drm = aconnector->base.dev;
>> struct amdgpu_display_manager *dm = &drm_to_adev(drm)->dm;
>> struct backlight_properties props = { 0 };
>> +#if defined(CONFIG_ACPI)
>> struct amdgpu_dm_backlight_caps caps = { 0 };
>> +#endif
>> char bl_name[16];
>> if (aconnector->bl_idx == -1)
>> @@ -4585,6 +4587,7 @@ amdgpu_dm_register_backlight_device(struct
>> amdgpu_dm_connector *aconnector)
>> return;
>> }
>> +#if defined(CONFIG_ACPI)
>> amdgpu_acpi_get_backlight_caps(&caps);
>> if (caps.caps_valid) {
>> if (power_supply_is_system_supplied() > 0)
>> @@ -4593,6 +4596,9 @@ amdgpu_dm_register_backlight_device(struct
>> amdgpu_dm_connector *aconnector)
>> props.brightness = caps.dc_level;
>> } else
>> props.brightness = AMDGPU_MAX_BL_LEVEL;
>> +#else
>> + props.brightness = AMDGPU_MAX_BL_LEVEL;
>> +#endif
>
> Hey Leo,
>
> Thanks for the patch!
>
> As caps is initialized to {0} caps.caps_valid will be invalid. So I see two
> other ways to solve this that are a little cleaner (IMO):
>
> 1) Just block the one call:
>
> #if defined(CONFIG_ACPI)
> amdgpu_acpi_get_backlight_caps(&caps);
> #endif
>
> 2) Add a stub inline no-op function for amdgpu_acpi_get_backlight_caps() to the
> header.
>
> I personally think #2 is cleaner (less ifdef makes a lot more readable code).
Agreed, we're using #2 for other ACPI stuff, actually.
Sending v2 soon.
- Leo
>
>> props.max_brightness = AMDGPU_MAX_BL_LEVEL;
>> props.type = BACKLIGHT_RAW;
More information about the amd-gfx
mailing list