[PATCH] drm/i915/quirk: Add quirk for devices with incorrect PWM frequency

From: Allen Ballway
Date: Tue Oct 17 2023 - 14:03:58 EST


Cyernet T10C has a bad default PWM frequency causing the display to
strobe when the brightness is less than 100%. Create a new quirk to use
the value from the BIOS rather than the default register value.

Signed-off-by: Allen Ballway <ballway@xxxxxxxxxxxx>

---

.../gpu/drm/i915/display/intel_backlight.c | 3 ++-
drivers/gpu/drm/i915/display/intel_quirks.c | 26 +++++++++++++++++++
drivers/gpu/drm/i915/display/intel_quirks.h | 1 +
3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_backlight.c b/drivers/gpu/drm/i915/display/intel_backlight.c
index 2e8f17c045222..c4dcfece9deca 100644
--- a/drivers/gpu/drm/i915/display/intel_backlight.c
+++ b/drivers/gpu/drm/i915/display/intel_backlight.c
@@ -1388,7 +1388,8 @@ static int vlv_setup_backlight(struct intel_connector *connector, enum pipe pipe
ctl = intel_de_read(i915, VLV_BLC_PWM_CTL(pipe));
panel->backlight.pwm_level_max = ctl >> 16;

- if (!panel->backlight.pwm_level_max)
+ if (!panel->backlight.pwm_level_max ||
+ intel_has_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY))
panel->backlight.pwm_level_max = get_backlight_max_vbt(connector);

if (!panel->backlight.pwm_level_max)
diff --git a/drivers/gpu/drm/i915/display/intel_quirks.c b/drivers/gpu/drm/i915/display/intel_quirks.c
index a280448df771a..ff6cb499428ce 100644
--- a/drivers/gpu/drm/i915/display/intel_quirks.c
+++ b/drivers/gpu/drm/i915/display/intel_quirks.c
@@ -65,6 +65,12 @@ static void quirk_no_pps_backlight_power_hook(struct drm_i915_private *i915)
drm_info(&i915->drm, "Applying no pps backlight power quirk\n");
}

+static void quirk_ignore_default_pwm_frequency(struct drm_i915_private *i915)
+{
+ intel_set_quirk(i915, QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY);
+ drm_info(&i915->drm, "Applying ignore default pwm frequency quirk");
+}
+
struct intel_quirk {
int device;
int subsystem_vendor;
@@ -90,6 +96,12 @@ static int intel_dmi_no_pps_backlight(const struct dmi_system_id *id)
return 1;
}

+static int intel_dmi_ignore_default_pwm_frequency(const struct dmi_system_id *id)
+{
+ DRM_INFO("Default PWM frequency is incorrect and is overridden on %s\n", id->ident);
+ return 1;
+}
+
static const struct intel_dmi_quirk intel_dmi_quirks[] = {
{
.dmi_id_list = &(const struct dmi_system_id[]) {
@@ -136,6 +148,20 @@ static const struct intel_dmi_quirk intel_dmi_quirks[] = {
},
.hook = quirk_no_pps_backlight_power_hook,
},
+ {
+ .dmi_id_list = &(const struct dmi_system_id[]) {
+ {
+ .callback = intel_dmi_ignore_default_pwm_frequency,
+ .ident = "Cybernet T10C Tablet",
+ .matches = {DMI_EXACT_MATCH(DMI_BOARD_VENDOR,
+ "Cybernet Manufacturing Inc."),
+ DMI_EXACT_MATCH(DMI_BOARD_NAME, "T10C Tablet"),
+ },
+ },
+ { }
+ },
+ .hook = quirk_ignore_default_pwm_frequency,
+ },
};

static struct intel_quirk intel_quirks[] = {
diff --git a/drivers/gpu/drm/i915/display/intel_quirks.h b/drivers/gpu/drm/i915/display/intel_quirks.h
index 10a4d163149fd..70589505e5a0e 100644
--- a/drivers/gpu/drm/i915/display/intel_quirks.h
+++ b/drivers/gpu/drm/i915/display/intel_quirks.h
@@ -17,6 +17,7 @@ enum intel_quirk_id {
QUIRK_INVERT_BRIGHTNESS,
QUIRK_LVDS_SSC_DISABLE,
QUIRK_NO_PPS_BACKLIGHT_POWER_HOOK,
+ QUIRK_IGNORE_DEFAULT_PWM_FREQUENCY
};

void intel_init_quirks(struct drm_i915_private *i915);
--
2.42.0.655.g421f12c284-goog