mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-15 20:18:04 -05:00
drm: panel-backlight-quirks: Convert brightness quirk to generic structure
Currently, the brightness quirk is limited to minimum brightness only. Refactor it to a structure, so that more quirks can be added in the future. Reserve 0 value for "no quirk", and use u16 to allow minimum brightness up to 255. Tested-by: Philip Müller <philm@manjaro.org> Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250829145541.512671-3-lkml@antheas.dev Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
This commit is contained in:
committed by
Mario Limonciello (AMD)
parent
9931e4be11
commit
6eee1ef9e5
@@ -3612,11 +3612,11 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
|
||||
|
||||
static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
|
||||
{
|
||||
const struct drm_panel_backlight_quirk *panel_backlight_quirk;
|
||||
struct amdgpu_dm_backlight_caps *caps;
|
||||
struct drm_connector *conn_base;
|
||||
struct amdgpu_device *adev;
|
||||
struct drm_luminance_range_info *luminance_range;
|
||||
int min_input_signal_override;
|
||||
|
||||
if (aconnector->bl_idx == -1 ||
|
||||
aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
|
||||
@@ -3656,9 +3656,13 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
|
||||
else
|
||||
caps->aux_min_input_signal = 1;
|
||||
|
||||
min_input_signal_override = drm_get_panel_min_brightness_quirk(aconnector->drm_edid);
|
||||
if (min_input_signal_override >= 0)
|
||||
caps->min_input_signal = min_input_signal_override;
|
||||
panel_backlight_quirk =
|
||||
drm_get_panel_backlight_quirk(aconnector->drm_edid);
|
||||
if (!IS_ERR_OR_NULL(panel_backlight_quirk)) {
|
||||
if (panel_backlight_quirk->min_brightness)
|
||||
caps->min_input_signal =
|
||||
panel_backlight_quirk->min_brightness - 1;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_FREE(sink_release, struct dc_sink *, if (_T) dc_sink_release(_T))
|
||||
|
||||
@@ -8,23 +8,23 @@
|
||||
#include <drm/drm_edid.h>
|
||||
#include <drm/drm_utils.h>
|
||||
|
||||
struct drm_panel_min_backlight_quirk {
|
||||
struct drm_get_panel_backlight_quirk {
|
||||
struct {
|
||||
enum dmi_field field;
|
||||
const char * const value;
|
||||
} dmi_match;
|
||||
struct drm_edid_ident ident;
|
||||
u8 min_brightness;
|
||||
struct drm_panel_backlight_quirk quirk;
|
||||
};
|
||||
|
||||
static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks[] = {
|
||||
static const struct drm_get_panel_backlight_quirk drm_panel_min_backlight_quirks[] = {
|
||||
/* 13 inch matte panel */
|
||||
{
|
||||
.dmi_match.field = DMI_BOARD_VENDOR,
|
||||
.dmi_match.value = "Framework",
|
||||
.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x0bca),
|
||||
.ident.name = "NE135FBM-N41",
|
||||
.min_brightness = 0,
|
||||
.quirk = { .min_brightness = 1, },
|
||||
},
|
||||
/* 13 inch glossy panel */
|
||||
{
|
||||
@@ -32,7 +32,7 @@ static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks
|
||||
.dmi_match.value = "Framework",
|
||||
.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x095f),
|
||||
.ident.name = "NE135FBM-N41",
|
||||
.min_brightness = 0,
|
||||
.quirk = { .min_brightness = 1, },
|
||||
},
|
||||
/* 13 inch 2.8k panel */
|
||||
{
|
||||
@@ -40,12 +40,13 @@ static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks
|
||||
.dmi_match.value = "Framework",
|
||||
.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x0cb4),
|
||||
.ident.name = "NE135A1M-NY1",
|
||||
.min_brightness = 0,
|
||||
.quirk = { .min_brightness = 1, },
|
||||
},
|
||||
};
|
||||
|
||||
static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_backlight_quirk *quirk,
|
||||
const struct drm_edid *edid)
|
||||
static bool drm_panel_min_backlight_quirk_matches(
|
||||
const struct drm_get_panel_backlight_quirk *quirk,
|
||||
const struct drm_edid *edid)
|
||||
{
|
||||
if (!dmi_match(quirk->dmi_match.field, quirk->dmi_match.value))
|
||||
return false;
|
||||
@@ -57,39 +58,39 @@ static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_bac
|
||||
}
|
||||
|
||||
/**
|
||||
* drm_get_panel_min_brightness_quirk - Get minimum supported brightness level for a panel.
|
||||
* drm_get_panel_backlight_quirk - Get backlight quirks 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.
|
||||
* cannot be probed correctly from the hard-/firm-ware and other sources.
|
||||
*
|
||||
* 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.
|
||||
* a drm_panel_backlight_quirk struct if a quirk was found, otherwise an
|
||||
* error pointer.
|
||||
*/
|
||||
int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid)
|
||||
const struct drm_panel_backlight_quirk *
|
||||
drm_get_panel_backlight_quirk(const struct drm_edid *edid)
|
||||
{
|
||||
const struct drm_panel_min_backlight_quirk *quirk;
|
||||
const struct drm_get_panel_backlight_quirk *quirk;
|
||||
size_t i;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_DMI))
|
||||
return -ENODATA;
|
||||
return ERR_PTR(-ENODATA);
|
||||
|
||||
if (!edid)
|
||||
return -EINVAL;
|
||||
return ERR_PTR(-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 &quirk->quirk;
|
||||
}
|
||||
|
||||
return -ENODATA;
|
||||
return ERR_PTR(-ENODATA);
|
||||
}
|
||||
EXPORT_SYMBOL(drm_get_panel_min_brightness_quirk);
|
||||
EXPORT_SYMBOL(drm_get_panel_backlight_quirk);
|
||||
|
||||
MODULE_DESCRIPTION("Quirks for panel backlight overrides");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
@@ -16,7 +16,12 @@ 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);
|
||||
struct drm_panel_backlight_quirk {
|
||||
u16 min_brightness;
|
||||
};
|
||||
|
||||
const struct drm_panel_backlight_quirk *
|
||||
drm_get_panel_backlight_quirk(const struct drm_edid *edid);
|
||||
|
||||
signed long drm_timeout_abs_to_jiffies(int64_t timeout_nsec);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user