diff mbox series

[v5,2/4] drm/amd/display: Add support for minimum backlight quirk

Message ID 20240818-amdgpu-min-backlight-quirk-v5-2-b6c0ead0c73d@weissschuh.net (mailing list archive)
State New, archived
Headers show
Series drm: Minimum backlight overrides and implementation for amdgpu | expand

Commit Message

Thomas Weißschuh Aug. 18, 2024, 6:56 a.m. UTC
Not all platforms provide correct PWM backlight capabilities through ATIF.
Use the generic drm panel minimum backlight quirk infrastructure to
override the capabilities where necessary.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Tested-by: Dustin L. Howett <dustin@howett.net>
---
 drivers/gpu/drm/amd/amdgpu/Kconfig                |  1 +
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++++
 2 files changed, 11 insertions(+)

Comments

Mario Limonciello Aug. 21, 2024, 8:54 p.m. UTC | #1
On 8/18/2024 01:56, Thomas Weißschuh wrote:
> Not all platforms provide correct PWM backlight capabilities through ATIF.

I don't think correct is an accurate term here.  How about 'optimial'?

> Use the generic drm panel minimum backlight quirk infrastructure to
> override the capabilities where necessary.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> Tested-by: Dustin L. Howett <dustin@howett.net>

The code looks fine to me but please wait for an ack from someone on the 
AMD display team.

Also, I would like to see comments about the testing with panel power 
savings enabled to avoid a conflict.

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/Kconfig                |  1 +
>   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
> index 0051fb1b437f..655c10aef2e3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/Kconfig
> +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
> @@ -23,6 +23,7 @@ config DRM_AMDGPU
>   	select DRM_BUDDY
>   	select DRM_SUBALLOC_HELPER
>   	select DRM_EXEC
> +	select DRM_PANEL_BACKLIGHT_QUIRKS
>   	# amdgpu depends on ACPI_VIDEO when ACPI is enabled, for select to work
>   	# ACPI_VIDEO's dependencies must also be selected.
>   	select INPUT if ACPI
> 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 983a977632ff..056960ea335c 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -93,6 +93,7 @@
>   #include <drm/drm_fourcc.h>
>   #include <drm/drm_edid.h>
>   #include <drm/drm_eld.h>
> +#include <drm/drm_utils.h>
>   #include <drm/drm_vblank.h>
>   #include <drm/drm_audio_component.h>
>   #include <drm/drm_gem_atomic_helper.h>
> @@ -3333,6 +3334,8 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
>   	struct drm_connector *conn_base;
>   	struct amdgpu_device *adev;
>   	struct drm_luminance_range_info *luminance_range;
> +	const struct drm_edid *drm_edid;
> +	int min_input_signal_override;
>   
>   	if (aconnector->bl_idx == -1 ||
>   	    aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
> @@ -3367,6 +3370,13 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
>   		caps->aux_min_input_signal = 0;
>   		caps->aux_max_input_signal = 512;
>   	}
> +
> +	drm_edid = drm_edid_alloc(aconnector->edid,
> +				  EDID_LENGTH * (aconnector->edid->extensions + 1));
> +	min_input_signal_override = drm_get_panel_min_brightness_quirk(drm_edid);
> +	drm_edid_free(drm_edid);
> +	if (min_input_signal_override >= 0)
> +		caps->min_input_signal = min_input_signal_override;
>   }
>   
>   void amdgpu_dm_update_connector_after_detect(
>
Thomas Weißschuh Aug. 22, 2024, 6:14 a.m. UTC | #2
On 2024-08-21 15:54:14+0000, Mario Limonciello wrote:
> On 8/18/2024 01:56, Thomas Weißschuh wrote:
> > Not all platforms provide correct PWM backlight capabilities through ATIF.
> 
> I don't think correct is an accurate term here.  How about 'optimial'?

Looks typoed to me :-)

What about this?

Not all platforms provide the full range of PWM backlight capabilities
supported by the hardware through ATIF.


> > Use the generic drm panel minimum backlight quirk infrastructure to
> > override the capabilities where necessary.
> > 
> > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> > Tested-by: Dustin L. Howett <dustin@howett.net>
> 
> The code looks fine to me but please wait for an ack from someone on the AMD
> display team.
> 
> Also, I would like to see comments about the testing with panel power
> savings enabled to avoid a conflict.

Ack.

> 
> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> > ---
> >   drivers/gpu/drm/amd/amdgpu/Kconfig                |  1 +
> >   drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++++
> >   2 files changed, 11 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
> > index 0051fb1b437f..655c10aef2e3 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/Kconfig
> > +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
> > @@ -23,6 +23,7 @@ config DRM_AMDGPU
> >   	select DRM_BUDDY
> >   	select DRM_SUBALLOC_HELPER
> >   	select DRM_EXEC
> > +	select DRM_PANEL_BACKLIGHT_QUIRKS
> >   	# amdgpu depends on ACPI_VIDEO when ACPI is enabled, for select to work
> >   	# ACPI_VIDEO's dependencies must also be selected.
> >   	select INPUT if ACPI
> > 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 983a977632ff..056960ea335c 100644
> > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> > @@ -93,6 +93,7 @@
> >   #include <drm/drm_fourcc.h>
> >   #include <drm/drm_edid.h>
> >   #include <drm/drm_eld.h>
> > +#include <drm/drm_utils.h>
> >   #include <drm/drm_vblank.h>
> >   #include <drm/drm_audio_component.h>
> >   #include <drm/drm_gem_atomic_helper.h>
> > @@ -3333,6 +3334,8 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
> >   	struct drm_connector *conn_base;
> >   	struct amdgpu_device *adev;
> >   	struct drm_luminance_range_info *luminance_range;
> > +	const struct drm_edid *drm_edid;
> > +	int min_input_signal_override;
> >   	if (aconnector->bl_idx == -1 ||
> >   	    aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
> > @@ -3367,6 +3370,13 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
> >   		caps->aux_min_input_signal = 0;
> >   		caps->aux_max_input_signal = 512;
> >   	}
> > +
> > +	drm_edid = drm_edid_alloc(aconnector->edid,
> > +				  EDID_LENGTH * (aconnector->edid->extensions + 1));
> > +	min_input_signal_override = drm_get_panel_min_brightness_quirk(drm_edid);
> > +	drm_edid_free(drm_edid);
> > +	if (min_input_signal_override >= 0)
> > +		caps->min_input_signal = min_input_signal_override;
> >   }
> >   void amdgpu_dm_update_connector_after_detect(
> > 
>
Mario Limonciello Aug. 22, 2024, 1:34 p.m. UTC | #3
On 8/22/2024 01:14, Thomas Weißschuh wrote:
> On 2024-08-21 15:54:14+0000, Mario Limonciello wrote:
>> On 8/18/2024 01:56, Thomas Weißschuh wrote:
>>> Not all platforms provide correct PWM backlight capabilities through ATIF.
>>
>> I don't think correct is an accurate term here.  How about 'optimial'?
> 
> Looks typoed to me :-)

heh.

> 
> What about this?
> 
> Not all platforms provide the full range of PWM backlight capabilities
> supported by the hardware through ATIF.

Sounds great, thanks!
> 
> 
>>> Use the generic drm panel minimum backlight quirk infrastructure to
>>> override the capabilities where necessary.
>>>
>>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>>> Tested-by: Dustin L. Howett <dustin@howett.net>
>>
>> The code looks fine to me but please wait for an ack from someone on the AMD
>> display team.
>>
>> Also, I would like to see comments about the testing with panel power
>> savings enabled to avoid a conflict.
> 
> Ack.
> 
>>
>> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>>    drivers/gpu/drm/amd/amdgpu/Kconfig                |  1 +
>>>    drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++++
>>>    2 files changed, 11 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
>>> index 0051fb1b437f..655c10aef2e3 100644
>>> --- a/drivers/gpu/drm/amd/amdgpu/Kconfig
>>> +++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
>>> @@ -23,6 +23,7 @@ config DRM_AMDGPU
>>>    	select DRM_BUDDY
>>>    	select DRM_SUBALLOC_HELPER
>>>    	select DRM_EXEC
>>> +	select DRM_PANEL_BACKLIGHT_QUIRKS
>>>    	# amdgpu depends on ACPI_VIDEO when ACPI is enabled, for select to work
>>>    	# ACPI_VIDEO's dependencies must also be selected.
>>>    	select INPUT if ACPI
>>> 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 983a977632ff..056960ea335c 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> @@ -93,6 +93,7 @@
>>>    #include <drm/drm_fourcc.h>
>>>    #include <drm/drm_edid.h>
>>>    #include <drm/drm_eld.h>
>>> +#include <drm/drm_utils.h>
>>>    #include <drm/drm_vblank.h>
>>>    #include <drm/drm_audio_component.h>
>>>    #include <drm/drm_gem_atomic_helper.h>
>>> @@ -3333,6 +3334,8 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
>>>    	struct drm_connector *conn_base;
>>>    	struct amdgpu_device *adev;
>>>    	struct drm_luminance_range_info *luminance_range;
>>> +	const struct drm_edid *drm_edid;
>>> +	int min_input_signal_override;
>>>    	if (aconnector->bl_idx == -1 ||
>>>    	    aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
>>> @@ -3367,6 +3370,13 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
>>>    		caps->aux_min_input_signal = 0;
>>>    		caps->aux_max_input_signal = 512;
>>>    	}
>>> +
>>> +	drm_edid = drm_edid_alloc(aconnector->edid,
>>> +				  EDID_LENGTH * (aconnector->edid->extensions + 1));
>>> +	min_input_signal_override = drm_get_panel_min_brightness_quirk(drm_edid);
>>> +	drm_edid_free(drm_edid);
>>> +	if (min_input_signal_override >= 0)
>>> +		caps->min_input_signal = min_input_signal_override;
>>>    }
>>>    void amdgpu_dm_update_connector_after_detect(
>>>
>>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
index 0051fb1b437f..655c10aef2e3 100644
--- a/drivers/gpu/drm/amd/amdgpu/Kconfig
+++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
@@ -23,6 +23,7 @@  config DRM_AMDGPU
 	select DRM_BUDDY
 	select DRM_SUBALLOC_HELPER
 	select DRM_EXEC
+	select DRM_PANEL_BACKLIGHT_QUIRKS
 	# amdgpu depends on ACPI_VIDEO when ACPI is enabled, for select to work
 	# ACPI_VIDEO's dependencies must also be selected.
 	select INPUT if ACPI
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 983a977632ff..056960ea335c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -93,6 +93,7 @@ 
 #include <drm/drm_fourcc.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_eld.h>
+#include <drm/drm_utils.h>
 #include <drm/drm_vblank.h>
 #include <drm/drm_audio_component.h>
 #include <drm/drm_gem_atomic_helper.h>
@@ -3333,6 +3334,8 @@  static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 	struct drm_connector *conn_base;
 	struct amdgpu_device *adev;
 	struct drm_luminance_range_info *luminance_range;
+	const struct drm_edid *drm_edid;
+	int min_input_signal_override;
 
 	if (aconnector->bl_idx == -1 ||
 	    aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
@@ -3367,6 +3370,13 @@  static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
 		caps->aux_min_input_signal = 0;
 		caps->aux_max_input_signal = 512;
 	}
+
+	drm_edid = drm_edid_alloc(aconnector->edid,
+				  EDID_LENGTH * (aconnector->edid->extensions + 1));
+	min_input_signal_override = drm_get_panel_min_brightness_quirk(drm_edid);
+	drm_edid_free(drm_edid);
+	if (min_input_signal_override >= 0)
+		caps->min_input_signal = min_input_signal_override;
 }
 
 void amdgpu_dm_update_connector_after_detect(