public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: "Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Harry Wentland" <harry.wentland@amd.com>,
	"Leo Li" <sunpeng.li@amd.com>,
	"Rodrigo Siqueira" <Rodrigo.Siqueira@amd.com>,
	"Matt Hartley" <matt.hartley@gmail.com>,
	"Kieran Levin" <ktl@framework.net>,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Jani Nikula" <jani.nikula@linux.intel.com>,
	"Xinhui Pan" <Xinhui.Pan@amd.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org, "Dustin Howett" <dustin@howett.net>,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v5 1/4] drm: Add panel backlight quirks
Date: Thu, 22 Aug 2024 08:34:05 -0500	[thread overview]
Message-ID: <dc4c50db-280f-49dc-8eec-600b57e741a8@amd.com> (raw)
In-Reply-To: <f3dac7f6-22ee-483e-b2f3-3a1c900c3f06@t-8ch.de>

On 8/22/2024 01:12, Thomas Weißschuh wrote:
> On 2024-08-21 15:51:17+0000, Mario Limonciello wrote:
>> On 8/18/2024 01:56, Thomas Weißschuh wrote:
>>> Panels using a PWM-controlled backlight source do not have a standard
>>> way to communicate their valid PWM ranges.
>>> On x86 the ranges are read from ACPI through driver-specific tables.
>>> The built-in ranges are not necessarily correct, or may grow stale if an
>>> older device can be retrofitted with newer panels.
>>>
>>> Add a quirk infrastructure with which the minimum valid backlight value
>>> can be maintained as part of the kernel.
>>>
>>> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
>>> Tested-by: Dustin L. Howett <dustin@howett.net>
>>
>> One small nit below but otherwise this patch is fine to me.
>>
>> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
>>
>>> ---
>>>    Documentation/gpu/drm-kms-helpers.rst        |  3 ++
>>>    drivers/gpu/drm/Kconfig                      |  4 ++
>>>    drivers/gpu/drm/Makefile                     |  1 +
>>>    drivers/gpu/drm/drm_panel_backlight_quirks.c | 70 ++++++++++++++++++++++++++++
>>>    include/drm/drm_utils.h                      |  4 ++
>>>    5 files changed, 82 insertions(+)
>>>
>>> diff --git a/Documentation/gpu/drm-kms-helpers.rst b/Documentation/gpu/drm-kms-helpers.rst
>>> index 8435e8621cc0..a26989500129 100644
>>> --- a/Documentation/gpu/drm-kms-helpers.rst
>>> +++ b/Documentation/gpu/drm-kms-helpers.rst
>>> @@ -230,6 +230,9 @@ Panel Helper Reference
>>>    .. kernel-doc:: drivers/gpu/drm/drm_panel_orientation_quirks.c
>>>       :export:
>>> +.. kernel-doc:: drivers/gpu/drm/drm_panel_backlight_quirks.c
>>> +   :export:
>>> +
>>>    Panel Self Refresh Helper Reference
>>>    ===================================
>>> diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
>>> index 6b2c6b91f962..9ebb8cdb535e 100644
>>> --- a/drivers/gpu/drm/Kconfig
>>> +++ b/drivers/gpu/drm/Kconfig
>>> @@ -454,6 +454,10 @@ config DRM_HYPERV
>>>    config DRM_EXPORT_FOR_TESTS
>>>    	bool
>>> +# Separate option as not all DRM drivers use it
>>> +config DRM_PANEL_BACKLIGHT_QUIRKS
>>> +	tristate
>>> +
>>>    config DRM_LIB_RANDOM
>>>    	bool
>>>    	default n
>>> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
>>> index 68cc9258ffc4..adf85999aee2 100644
>>> --- a/drivers/gpu/drm/Makefile
>>> +++ b/drivers/gpu/drm/Makefile
>>> @@ -92,6 +92,7 @@ drm-$(CONFIG_DRM_PANIC) += drm_panic.o
>>>    obj-$(CONFIG_DRM)	+= drm.o
>>>    obj-$(CONFIG_DRM_PANEL_ORIENTATION_QUIRKS) += drm_panel_orientation_quirks.o
>>> +obj-$(CONFIG_DRM_PANEL_BACKLIGHT_QUIRKS) += drm_panel_backlight_quirks.o
>>>    #
>>>    # Memory-management helpers
>>> diff --git a/drivers/gpu/drm/drm_panel_backlight_quirks.c b/drivers/gpu/drm/drm_panel_backlight_quirks.c
>>> new file mode 100644
>>> index 000000000000..6b8bbed77c7f
>>> --- /dev/null
>>> +++ b/drivers/gpu/drm/drm_panel_backlight_quirks.c
>>> @@ -0,0 +1,70 @@
>>> +// SPDX-License-Identifier: GPL-2.0
>>> +
>>> +#include <linux/array_size.h>
>>> +#include <linux/dmi.h>
>>> +#include <linux/mod_devicetable.h>
>>> +#include <linux/module.h>
>>> +#include <drm/drm_edid.h>
>>> +#include <drm/drm_utils.h>
>>> +
>>> +struct drm_panel_min_backlight_quirk {
>>> +	struct {
>>> +		enum dmi_field field;
>>> +		const char * const value;
>>> +	} dmi_match;
>>> +	struct drm_edid_ident ident;
>>> +	u8 min_brightness;
>>> +};
>>> +
>>> +static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks[] = {
>>> +};
>>> +
>>> +static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_backlight_quirk *quirk,
>>> +						  const struct drm_edid *edid)
>>> +{
>>> +	if (!dmi_match(quirk->dmi_match.field, quirk->dmi_match.value))
>>> +		return false;
>>> +
>>> +	if (!drm_edid_match(edid, &quirk->ident))
>>> +		return false;
>>> +
>>> +	return true;
>>> +}
>>> +
>>> +/**
>>> + * drm_get_panel_min_brightness_quirk - Get minimum supported brightness level for a panel.
>>> + * @edid: EDID of the panel to check
>>> + *
>>> + * This function checks for platform specific (e.g. DMI based) quirks
>>> + * providing info on the minimum backlight brightness for systems where this
>>> + * cannot be probed correctly from the hard-/firm-ware.
>>> + *
>>> + * Returns:
>>> + * A negative error value or
>>> + * an override value in the range [0, 255] representing 0-100% to be scaled to
>>> + * the drivers target range.
>>> + */
>>> +int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid)
>>> +{
>>> +	const struct drm_panel_min_backlight_quirk *quirk;
>>> +	size_t i;
>>
>> Nit: this doesn't really seem like it needs to be size_t.  Shouldn't it just
>> be an unsigned int?
> 
> ARRAY_SIZE() works with sizeof() which returns size_t.
> It doesn't really matter, but I slightly prefer to keep the size_t.

Ah thanks, I didn't realize that.  Feel free to leave as is then.

> 
>>> +
>>> +	if (!IS_ENABLED(CONFIG_DMI))
>>> +		return -ENODATA;
>>> +
>>> +	if (!edid)
>>> +		return -EINVAL;
>>> +
>>> +	for (i = 0; i < ARRAY_SIZE(drm_panel_min_backlight_quirks); i++) {
>>> +		quirk = &drm_panel_min_backlight_quirks[i];
>>> +
>>> +		if (drm_panel_min_backlight_quirk_matches(quirk, edid))
>>> +			return quirk->min_brightness;
>>> +	}
>>> +
>>> +	return -ENODATA;
>>> +}
>>> +EXPORT_SYMBOL(drm_get_panel_min_brightness_quirk);
>>> +
>>> +MODULE_DESCRIPTION("Quirks for panel backlight overrides");
>>> +MODULE_LICENSE("GPL");
>>> diff --git a/include/drm/drm_utils.h b/include/drm/drm_utils.h
>>> index 70775748d243..15fa9b6865f4 100644
>>> --- a/include/drm/drm_utils.h
>>> +++ b/include/drm/drm_utils.h
>>> @@ -12,8 +12,12 @@
>>>    #include <linux/types.h>
>>> +struct drm_edid;
>>> +
>>>    int drm_get_panel_orientation_quirk(int width, int height);
>>> +int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid);
>>> +
>>>    signed long drm_timeout_abs_to_jiffies(int64_t timeout_nsec);
>>>    #endif
>>>
>>


  reply	other threads:[~2024-08-22 13:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-18  6:56 [PATCH v5 0/4] drm: Minimum backlight overrides and implementation for amdgpu Thomas Weißschuh
2024-08-18  6:56 ` [PATCH v5 1/4] drm: Add panel backlight quirks Thomas Weißschuh
2024-08-21 20:51   ` Mario Limonciello
2024-08-22  6:12     ` Thomas Weißschuh
2024-08-22 13:34       ` Mario Limonciello [this message]
2024-08-18  6:56 ` [PATCH v5 2/4] drm/amd/display: Add support for minimum backlight quirk Thomas Weißschuh
2024-08-21 20:54   ` Mario Limonciello
2024-08-22  6:14     ` Thomas Weißschuh
2024-08-22 13:34       ` Mario Limonciello
2024-08-18  6:56 ` [PATCH v5 3/4] drm: panel-backlight-quirks: Add Framework 13 matte panel Thomas Weißschuh
2024-08-21 20:54   ` Mario Limonciello
2024-08-18  6:56 ` [PATCH v5 4/4] drm: panel-backlight-quirks: Add Framework 13 glossy and 2.8k panels Thomas Weißschuh
2024-08-21 20:55   ` Mario Limonciello
2024-08-21 20:45 ` [PATCH v5 0/4] drm: Minimum backlight overrides and implementation for amdgpu Mario Limonciello
2024-08-22  6:09   ` Thomas Weißschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc4c50db-280f-49dc-8eec-600b57e741a8@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dustin@howett.net \
    --cc=harry.wentland@amd.com \
    --cc=hdegoede@redhat.com \
    --cc=jani.nikula@linux.intel.com \
    --cc=ktl@framework.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matt.hartley@gmail.com \
    --cc=mripard@kernel.org \
    --cc=sunpeng.li@amd.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox