drm: panel-backlight-quirks: Do partial refactor and apply OLED fix
Subsystems (4)
v2 cover drm: panel-backlight-quirks: Do partial refactor and apply OLED fix
This is an alternative to [1], since Phil found out there are still invalid values. We need to reconsider the other patch in that series anyway because the latest AMD firmware update might have fixed the Z13.
This series refactors the panel-backlight-quirks code to make it easier to add new quirks. Specifically, it adds the ability to bind to a secondary DMI match so that the make of a device can be specified. Then, it makes EDID optional, for devices we know the value should be applied universally.
This is then used to add a quirk for OLED panels that have an issue when their backlight is set with a value that contains a 0/1 value in their minor byte. This issue affects four handhelds from three different vendors, three of which are in the field. This quirk applies a |3 mask to the backlight value, which avoids this issue. In addition, the value change is minor enough so that it is essentially a NOOP. There is no need for ensuring it runs only on panels with faulty firmwares.
Finally, since allowed by this refactor, a quirk for Steam Decks is added that lowers their minimum brightness to 0, matching SteamOS. This is a nicety commit, which allows for mildly lower minimum brightness, so there is no time sensitivity for having it merged. Mario noted that if that quirk was refactored to use an EDID match via the current interface, it could go through the fixes tree and land sooner, but perhaps it is not worth the effort.
[1] https://lore.kernel.org/all/[email protected]/
---
V1: https://lore.kernel.org/all/[email protected]/
Changes since v1:
- Remove leftover quirk from patch 3 (refactor)
- Add dangling comma in patch 4 (oled quirk)
- Add the next generation Zotac Zone in patch 4 (currently unreleased)
- Reword patch 1 and 5 subjects
Antheas Kapenekakis (5):
drm: panel-backlight-quirks: Make EDID match optional
drm: panel-backlight-quirks: Convert brightness quirk to generic
structure
drm: panel-backlight-quirks: Add secondary DMI match
drm: panel-backlight-quirks: Add brightness mask quirk
drm: panel-backlight-quirks: Add Steam Deck brightness quirk
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 + drivers/gpu/drm/drm_panel_backlight_quirks.c | 113 ++++++++++++++---- include/drm/drm_utils.h | 8 +- 4 files changed, 115 insertions(+), 31 deletions(-)
base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
Signature · 1 line
2.51.0
PATCH v2 1/5 drm: panel-backlight-quirks: Make EDID match optional
Currently, having a valid panel_id match is required to use the quirk system. For certain devices, we know that all SKUs need a certain quirk. Therefore, allow not specifying ident by only checking for a match if panel_id is non-zero.
--- drivers/gpu/drm/drm_panel_backlight_quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_panel_backlight_quirks.c +1 -1
@@ -50,7 +50,7 @@ static bool drm_panel_min_backlight_quirk_matches(const struct drm_panel_min_bacif (!dmi_match (quirk->dmi_match.field, quirk->dmi_match.value))return false; -if (!drm_edid_match (edid, &quirk->ident)) +if (quirk->ident.panel_id && !drm_edid_match (edid, &quirk->ident))return false;return true;
Signature · 1 line
2.51.0
PATCH v2 2/5 drm: panel-backlight-quirks: Convert brightness quirk to generic structure
In reply to Antheas KapenekakisCurrently, 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.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 12 ++++-- drivers/gpu/drm/drm_panel_backlight_quirks.c | 41 ++++++++++--------- include/drm/drm_utils.h | 7 +++- 3 files changed, 35 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -4
@@ -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))
drivers/gpu/drm/drm_panel_backlight_quirks.c +21 -20
102 lines not on this page · raw message
include/drm/drm_utils.h +6 -1
@@ -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);
Signature · 1 line
2.51.0
PATCH v2 3/5 drm: panel-backlight-quirks: Add secondary DMI match
In reply to Antheas KapenekakisUsing a single DMI match only allows matching per manufacturer. Introduce a second optional match to allow matching make/model. In addition, make DMI optional to allow matching only by EDID.
--- drivers/gpu/drm/drm_panel_backlight_quirks.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_panel_backlight_quirks.c +14 -5
@@ -8,11 +8,14 @@#include <drm/drm_edid.h> #include <drm/drm_utils.h> +struct drm_panel_match { +enum dmi_field field; +const char *const value; +}; +struct drm_get_panel_backlight_quirk { -struct { -enum dmi_field field; -const char *const value; - } dmi_match; +struct drm_panel_match dmi_match; +struct drm_panel_match dmi_match_other;struct drm_edid_ident ident;struct drm_panel_backlight_quirk quirk; };
@@ -48,7 +51,13 @@ 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)) + if (quirk->dmi_match.field && + !dmi_match(quirk->dmi_match.field, quirk->dmi_match.value)) + return false; + +if (quirk->dmi_match_other.field && + !dmi_match (quirk->dmi_match_other.field, + quirk->dmi_match_other.value))return false;if (quirk->ident.panel_id && !drm_edid_match (edid, &quirk->ident))
Signature · 1 line
2.51.0
PATCH v2 4/5 drm: panel-backlight-quirks: Add brightness mask quirk
In reply to Antheas KapenekakisCertain OLED devices malfunction on specific brightness levels. Specifically, when DP_SOURCE_BACKLIGHT_LEVEL is written to with the first byte being 0x00 and sometimes 0x01, the panel forcibly turns off until the device sleeps again.
Below are some examples. This was found by iterating over brighness ranges while printing DP_SOURCE_BACKLIGHT_LEVEL. It was found that the screen would malfunction on specific values, and some of them were collected. Summary examples are found below.
This quirk was tested by removing the workarounds and iterating from 0 to 50_000 value ranges with a cadence of 0.2s/it. The range of the panel is 1000...400_000, so the values were slightly interpolated during testing. The custom brightness curve added on 6.15 was disabled.
86016: 10101000000000000 86272: 10101000100000000 87808: 10101011100000000
251648: 111101011100000000
251649: 111101011100000001
86144: 10101000010000000
87809: 10101011100000001
251650: 111101011100000010
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 ++++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 ++++ drivers/gpu/drm/drm_panel_backlight_quirks.c | 36 +++++++++++++++++++ include/drm/drm_utils.h | 1 + 4 files changed, 50 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -3662,6 +3662,9 @@ static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)if (panel_backlight_quirk->min_brightness) caps->min_input_signal = panel_backlight_quirk->min_brightness -1 ; +if (panel_backlight_quirk->brightness_mask) + caps->brightness_mask = + panel_backlight_quirk->brightness_mask; } }
@@ -4862,6 +4865,10 @@ static void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm, brightness =convert_brightness_from_user (caps, dm->brightness[bl_idx]); link = (struct dc_link *)dm->backlight_link[bl_idx]; +/* Apply brightness quirk */ +if (caps->brightness_mask) + brightness |= caps->brightness_mask; +/* Change brightness based on AUX property */ mutex_lock (&dm->dc_lock);if (dm->dc->caps.ips_support && dm->dc->ctx->dmub_srv->idle_allowed) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +6 -0
@@ -200,6 +200,12 @@ struct amdgpu_dm_backlight_caps {* @aux_support: Describes if the display supports AUX backlight. */ bool aux_support; +/** +* @brightness_mask: After deriving brightness, or it with this mask. +* This is used to workaround panels that have issues with certain +* brightness values. +*/ +u32 brightness_mask;/** * @ac_level: the default brightness if booted on AC */
drivers/gpu/drm/drm_panel_backlight_quirks.c +36 -0
@@ -45,6 +45,42 @@ static const struct drm_get_panel_backlight_quirk drm_panel_min_backlight_quirks .ident.name = "NE135A1M-NY1", .quirk = { .min_brightness = 1, }, }, +/* Have OLED Panels with brightness issue when last byte is 0/1 */ + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "AYANEO", + .dmi_match_other.field = DMI_PRODUCT_NAME, + .dmi_match_other.value = "AYANEO 3", + .quirk = { .brightness_mask = 3, }, + }, + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "ZOTAC", + .dmi_match_other.field = DMI_BOARD_NAME, + .dmi_match_other.value = "G0A1W", + .quirk = { .brightness_mask = 3, }, + }, + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "ZOTAC", + .dmi_match_other.field = DMI_BOARD_NAME, + .dmi_match_other.value = "G1A1W", + .quirk = { .brightness_mask = 3, }, + }, + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "ONE-NETBOOK", + .dmi_match_other.field = DMI_PRODUCT_NAME, + .dmi_match_other.value = "ONEXPLAYER F1Pro", + .quirk = { .brightness_mask = 3, }, + }, + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "ONE-NETBOOK", + .dmi_match_other.field = DMI_PRODUCT_NAME, + .dmi_match_other.value = "ONEXPLAYER F1 EVA-02", + .quirk = { .brightness_mask = 3, }, + }, }; static bool drm_panel_min_backlight_quirk_matches(
include/drm/drm_utils.h +1 -0
@@ -18,6 +18,7 @@ int drm_get_panel_orientation_quirk(int width, int height);struct drm_panel_backlight_quirk {u16 min_brightness; +u32 brightness_mask; }; const struct drm_panel_backlight_quirk *
Signature · 1 line
2.51.0
PATCH v2 5/5 drm: panel-backlight-quirks: Add Steam Deck brightness quirk
In reply to Antheas KapenekakisOn the SteamOS kernel, Valve universally makes minimum brightness 0 for all devices. SteamOS is (was?) meant for the Steam Deck, so enabling it universally is reasonable. However, it causes issues in certain devices. Therefore, introduce it just for the Steam Deck here.
SteamOS kernel does not have a public mirror, but this replaces commit 806dd74bb225 ("amd/drm: override backlight min value from 12 -> 0") in the latest, as of this writing, SteamOS kernel (6.11.11-valve24). See unofficial mirror reconstructed from sources below.
--- drivers/gpu/drm/drm_panel_backlight_quirks.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/drm_panel_backlight_quirks.c +15 -0
@@ -81,6 +81,21 @@ static const struct drm_get_panel_backlight_quirk drm_panel_min_backlight_quirks .dmi_match_other.value = "ONEXPLAYER F1 EVA-02", .quirk = { .brightness_mask = 3, }, }, +/* Steam Deck models */ + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "Valve", + .dmi_match_other.field = DMI_PRODUCT_NAME, + .dmi_match_other.value = "Jupiter", + .quirk = { .min_brightness = 1, }, + }, + { + .dmi_match.field = DMI_SYS_VENDOR, + .dmi_match.value = "Valve", + .dmi_match_other.field = DMI_PRODUCT_NAME, + .dmi_match_other.value = "Galileo", + .quirk = { .min_brightness = 1, }, + }, }; static bool drm_panel_min_backlight_quirk_matches(
Signature · 1 line
2.51.0
Quoted 27 lines · Antheas Kapenekakis
This is an alternative to [1], since Phil found out there are still invalid values. We need to reconsider the other patch in that series anyway because the latest AMD firmware update might have fixed the Z13.
This series refactors the panel-backlight-quirks code to make it easier to add new quirks. Specifically, it adds the ability to bind to a secondary DMI match so that the make of a device can be specified. Then, it makes EDID optional, for devices we know the value should be applied universally.
This is then used to add a quirk for OLED panels that have an issue when their backlight is set with a value that contains a 0/1 value in their minor byte. This issue affects four handhelds from three different vendors, three of which are in the field. This quirk applies a |3 mask to the backlight value, which avoids this issue. In addition, the value change is minor enough so that it is essentially a NOOP. There is no need for ensuring it runs only on panels with faulty firmwares.
Finally, since allowed by this refactor, a quirk for Steam Decks is added that lowers their minimum brightness to 0, matching SteamOS. This is a nicety commit, which allows for mildly lower minimum brightness, so there is no time sensitivity for having it merged. Mario noted that if that quirk was refactored to use an EDID match via the current interface, it could go through the fixes tree and land sooner, but perhaps it is not worth the effort.
Quoted 7 lines
---
V1: https://lore.kernel.org/all/[email protected]/Changes since v1:
- Remove leftover quirk from patch 3 (refactor)
- Add dangling comma in patch 4 (oled quirk)
- Add the next generation Zotac Zone in patch 4 (currently unreleased)
Can you double check with Phil? I thought there are two affected Zotac devices, but I could be wrong. If we can get both in a single go let's do it.
Quoted 10 lines
- Reword patch 1 and 5 subjects
Antheas Kapenekakis (5):
drm: panel-backlight-quirks: Make EDID match optional
drm: panel-backlight-quirks: Convert brightness quirk to generic
structure
drm: panel-backlight-quirks: Add secondary DMI match
drm: panel-backlight-quirks: Add brightness mask quirk
drm: panel-backlight-quirks: Add Steam Deck brightness quirk
Quoted 8 lines
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 + drivers/gpu/drm/drm_panel_backlight_quirks.c | 113 ++++++++++++++---- include/drm/drm_utils.h | 8 +- 4 files changed, 115 insertions(+), 31 deletions(-)base-commit:
1b237f190eb3d36f52dffe07a40b5eb210280e00
The series looks fine to me.
I have two small nits though:
1) Because this is "effectively" going to limit the amount of brightness values available I think there should be a message when a the brightness mask quirk is in use that we can get in the logs so that the changed behavior isn't totally surprising. We have some similar messages for DMI detected quirks in amdgpu already.
drm_info(dev, "support_edp0_on_dp1 attached\n"); drm_info(dev, "aux_hpd_discon_quirk attached\n");
Can you add one for this new quirk?
2) The comment for 'brightness_mask' in patch 4 should have 'or' as 'OR' so it's obvious that it's logical OR to the casual reader and not a typographical error.
IE "After deriving brightness, OR it with this mask."
Quoted 32 lines · Mario Limonciello
Quoted 30 lines · Antheas Kapenekakis
This is an alternative to [1], since Phil found out there are still invalid values. We need to reconsider the other patch in that series anyway because the latest AMD firmware update might have fixed the Z13.
This series refactors the panel-backlight-quirks code to make it easier to add new quirks. Specifically, it adds the ability to bind to a secondary DMI match so that the make of a device can be specified. Then, it makes EDID optional, for devices we know the value should be applied universally.
This is then used to add a quirk for OLED panels that have an issue when their backlight is set with a value that contains a 0/1 value in their minor byte. This issue affects four handhelds from three different vendors, three of which are in the field. This quirk applies a |3 mask to the backlight value, which avoids this issue. In addition, the value change is minor enough so that it is essentially a NOOP. There is no need for ensuring it runs only on panels with faulty firmwares.
Finally, since allowed by this refactor, a quirk for Steam Decks is added that lowers their minimum brightness to 0, matching SteamOS. This is a nicety commit, which allows for mildly lower minimum brightness, so there is no time sensitivity for having it merged. Mario noted that if that quirk was refactored to use an EDID match via the current interface, it could go through the fixes tree and land sooner, but perhaps it is not worth the effort.
Quoted 8 lines
Quoted 4 lines
Changes since v1:
- Remove leftover quirk from patch 3 (refactor)
- Add dangling comma in patch 4 (oled quirk)
- Add the next generation Zotac Zone in patch 4 (currently unreleased)Can you double check with Phil? I thought there are two affected Zotac devices, but I could be wrong. If we can get both in a single go let's do it.
Indeed. V1 already included the released model. Hopefully I did not get the ID wrong on this one.
Quoted 34 lines
Quoted 10 lines
- Reword patch 1 and 5 subjects
Antheas Kapenekakis (5):
drm: panel-backlight-quirks: Make EDID match optional
drm: panel-backlight-quirks: Convert brightness quirk to generic
structure
drm: panel-backlight-quirks: Add secondary DMI match
drm: panel-backlight-quirks: Add brightness mask quirk
drm: panel-backlight-quirks: Add Steam Deck brightness quirkQuoted 8 lines
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 19 ++- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 6 + drivers/gpu/drm/drm_panel_backlight_quirks.c | 113 ++++++++++++++---- include/drm/drm_utils.h | 8 +- 4 files changed, 115 insertions(+), 31 deletions(-)base-commit:
1b237f190eb3d36f52dffe07a40b5eb210280e00The series looks fine to me.
Reviewed-by Mario Limonciello <[email protected]>I have two small nits though:
1) Because this is "effectively" going to limit the amount of brightness values available I think there should be a message when a the brightness mask quirk is in use that we can get in the logs so that the changed behavior isn't totally surprising. We have some similar messages for DMI detected quirks in amdgpu already.
drm_info(dev, "support_edp0_on_dp1 attached\n"); drm_info(dev, "aux_hpd_discon_quirk attached\n");
Quoted 8 lines
Can you add one for this new quirk?
2) The comment for '
brightness_mask' in patch 4 should have 'or' as 'OR' so it's obvious that it's logical OR to the casual reader and not a typographical error.IE "After deriving brightness, OR it with this mask."
Ack. I will give it 1-2 days for more feedback and resend.
Antheas
Quoted 1 line · Mario Limonciello
Can you double check with Phil? I thought there are two affected Zotac devices, but I could be wrong. If we can get both in a single go let's do it.
Yes, the new model is called G1A1W and has the same panel as G0A1W. We might still work with the vendor to get a firmware update. However, so far we can keep the quirk for that model as well. If needed I could send a patch to remove it.
Signature · 1 line
Best, Philip