Skip to content

Commit 6eee1ef

Browse files
antheassuperm1
authored andcommitted
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>
1 parent 9931e4b commit 6eee1ef

3 files changed

Lines changed: 35 additions & 25 deletions

File tree

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3612,11 +3612,11 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
36123612

36133613
static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
36143614
{
3615+
const struct drm_panel_backlight_quirk *panel_backlight_quirk;
36153616
struct amdgpu_dm_backlight_caps *caps;
36163617
struct drm_connector *conn_base;
36173618
struct amdgpu_device *adev;
36183619
struct drm_luminance_range_info *luminance_range;
3619-
int min_input_signal_override;
36203620

36213621
if (aconnector->bl_idx == -1 ||
36223622
aconnector->dc_link->connector_signal != SIGNAL_TYPE_EDP)
@@ -3656,9 +3656,13 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
36563656
else
36573657
caps->aux_min_input_signal = 1;
36583658

3659-
min_input_signal_override = drm_get_panel_min_brightness_quirk(aconnector->drm_edid);
3660-
if (min_input_signal_override >= 0)
3661-
caps->min_input_signal = min_input_signal_override;
3659+
panel_backlight_quirk =
3660+
drm_get_panel_backlight_quirk(aconnector->drm_edid);
3661+
if (!IS_ERR_OR_NULL(panel_backlight_quirk)) {
3662+
if (panel_backlight_quirk->min_brightness)
3663+
caps->min_input_signal =
3664+
panel_backlight_quirk->min_brightness - 1;
3665+
}
36623666
}
36633667

36643668
DEFINE_FREE(sink_release, struct dc_sink *, if (_T) dc_sink_release(_T))

drivers/gpu/drm/drm_panel_backlight_quirks.c

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,44 +8,45 @@
88
#include <drm/drm_edid.h>
99
#include <drm/drm_utils.h>
1010

11-
struct drm_panel_min_backlight_quirk {
11+
struct drm_get_panel_backlight_quirk {
1212
struct {
1313
enum dmi_field field;
1414
const char * const value;
1515
} dmi_match;
1616
struct drm_edid_ident ident;
17-
u8 min_brightness;
17+
struct drm_panel_backlight_quirk quirk;
1818
};
1919

20-
static const struct drm_panel_min_backlight_quirk drm_panel_min_backlight_quirks[] = {
20+
static const struct drm_get_panel_backlight_quirk drm_panel_min_backlight_quirks[] = {
2121
/* 13 inch matte panel */
2222
{
2323
.dmi_match.field = DMI_BOARD_VENDOR,
2424
.dmi_match.value = "Framework",
2525
.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x0bca),
2626
.ident.name = "NE135FBM-N41",
27-
.min_brightness = 0,
27+
.quirk = { .min_brightness = 1, },
2828
},
2929
/* 13 inch glossy panel */
3030
{
3131
.dmi_match.field = DMI_BOARD_VENDOR,
3232
.dmi_match.value = "Framework",
3333
.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x095f),
3434
.ident.name = "NE135FBM-N41",
35-
.min_brightness = 0,
35+
.quirk = { .min_brightness = 1, },
3636
},
3737
/* 13 inch 2.8k panel */
3838
{
3939
.dmi_match.field = DMI_BOARD_VENDOR,
4040
.dmi_match.value = "Framework",
4141
.ident.panel_id = drm_edid_encode_panel_id('B', 'O', 'E', 0x0cb4),
4242
.ident.name = "NE135A1M-NY1",
43-
.min_brightness = 0,
43+
.quirk = { .min_brightness = 1, },
4444
},
4545
};
4646

47-
static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_backlight_quirk *quirk,
48-
const struct drm_edid *edid)
47+
static bool drm_panel_min_backlight_quirk_matches(
48+
const struct drm_get_panel_backlight_quirk *quirk,
49+
const struct drm_edid *edid)
4950
{
5051
if (!dmi_match(quirk->dmi_match.field, quirk->dmi_match.value))
5152
return false;
@@ -57,39 +58,39 @@ static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_bac
5758
}
5859

5960
/**
60-
* drm_get_panel_min_brightness_quirk - Get minimum supported brightness level for a panel.
61+
* drm_get_panel_backlight_quirk - Get backlight quirks for a panel
6162
* @edid: EDID of the panel to check
6263
*
6364
* This function checks for platform specific (e.g. DMI based) quirks
6465
* providing info on the minimum backlight brightness for systems where this
65-
* cannot be probed correctly from the hard-/firm-ware.
66+
* cannot be probed correctly from the hard-/firm-ware and other sources.
6667
*
6768
* Returns:
68-
* A negative error value or
69-
* an override value in the range [0, 255] representing 0-100% to be scaled to
70-
* the drivers target range.
69+
* a drm_panel_backlight_quirk struct if a quirk was found, otherwise an
70+
* error pointer.
7171
*/
72-
int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid)
72+
const struct drm_panel_backlight_quirk *
73+
drm_get_panel_backlight_quirk(const struct drm_edid *edid)
7374
{
74-
const struct drm_panel_min_backlight_quirk *quirk;
75+
const struct drm_get_panel_backlight_quirk *quirk;
7576
size_t i;
7677

7778
if (!IS_ENABLED(CONFIG_DMI))
78-
return -ENODATA;
79+
return ERR_PTR(-ENODATA);
7980

8081
if (!edid)
81-
return -EINVAL;
82+
return ERR_PTR(-EINVAL);
8283

8384
for (i = 0; i < ARRAY_SIZE(drm_panel_min_backlight_quirks); i++) {
8485
quirk = &drm_panel_min_backlight_quirks[i];
8586

8687
if (drm_panel_min_backlight_quirk_matches(quirk, edid))
87-
return quirk->min_brightness;
88+
return &quirk->quirk;
8889
}
8990

90-
return -ENODATA;
91+
return ERR_PTR(-ENODATA);
9192
}
92-
EXPORT_SYMBOL(drm_get_panel_min_brightness_quirk);
93+
EXPORT_SYMBOL(drm_get_panel_backlight_quirk);
9394

9495
MODULE_DESCRIPTION("Quirks for panel backlight overrides");
9596
MODULE_LICENSE("GPL");

include/drm/drm_utils.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ struct drm_edid;
1616

1717
int drm_get_panel_orientation_quirk(int width, int height);
1818

19-
int drm_get_panel_min_brightness_quirk(const struct drm_edid *edid);
19+
struct drm_panel_backlight_quirk {
20+
u16 min_brightness;
21+
};
22+
23+
const struct drm_panel_backlight_quirk *
24+
drm_get_panel_backlight_quirk(const struct drm_edid *edid);
2025

2126
signed long drm_timeout_abs_to_jiffies(int64_t timeout_nsec);
2227

0 commit comments

Comments
 (0)