Skip to contentSkip to conversation

drm/i915/vlv_dsi: Add DMI quirk for wrong panel modeline in BIOS on Asus TF103C

PATCH In review Hans de Goede 3 participants 5 messages Feb 21, 2022 – Feb 22, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/i915/vlv_dsi: Add DMI quirk for wrong panel modeline in BIOS on Asus TF103C

Vtotal is wrong in the BIOS supplied modeline for the DSI panel on the Asus TF103C leading to the last line of the display being shown as the first line.

The factory installed Android has a hardcoded modeline in its kernel, causing it to not suffer from this BIOS bug;

and the Android boot-splash which uses the EFI FB which does have this bug has the last line all black causing the bug to not be visible.

This commit introduces a generic DMI based mechanism for doing modeline fixups, in case we need similar fixups on other models in the future.

---
 drivers/gpu/drm/i915/display/vlv_dsi.c | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/gpu/drm/i915/display/vlv_dsi.c +36 -0
index 06ef822c27bd..66f5cf32bb66 100644
@@ -23,6 +23,7 @@
  * Author: Jani Nikula <[email protected]>
  */
 
+#include <linux/dmi.h>
 #include <linux/slab.h>
 
 #include <drm/drm_atomic_helper.h>
@@ -1831,6 +1832,33 @@ static void vlv_dphy_param_init(struct intel_dsi *intel_dsi)
 	intel_dsi_log_params(intel_dsi);
 }
 
+typedef void (*vlv_dsi_mode_fixup_func)(struct drm_connector *connector,
+					struct drm_display_mode *fixed_mode);
+
+/*
+ * Vtotal is wrong on the Asus TF103C leading to the last line of the display
+ * being shown as the first line. The factory installed Android has a hardcoded
+ * modeline, causing it to not suffer from this BIOS bug.
+ */
+static void vlv_dsi_asus_tf103c_mode_fixup(struct drm_connector *connector,
+					   struct drm_display_mode *fixed_mode)
+{
+	fixed_mode->vtotal = 816;
+	fixed_mode->crtc_vtotal = 816;
+}
+
+static const struct dmi_system_id dmi_mode_fixup_table[] = {
+	{
+		/* Asus Transformer Pad TF103C */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
+		},
+		.driver_data = (void *)vlv_dsi_asus_tf103c_mode_fixup,
+	},
+	{ }
+};
+
 void vlv_dsi_init(struct drm_i915_private *dev_priv)
 {
 	struct drm_device *dev = &dev_priv->drm;
@@ -1840,6 +1868,8 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
 	struct intel_connector *intel_connector;
 	struct drm_connector *connector;
 	struct drm_display_mode *current_mode, *fixed_mode;
+	const struct dmi_system_id *dmi_id;
+	vlv_dsi_mode_fixup_func mode_fixup;
 	enum port port;
 	enum pipe pipe;
 
@@ -1968,6 +1998,12 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
 		goto err_cleanup_connector;
 	}
 
+	dmi_id = dmi_first_match(dmi_mode_fixup_table);
+	if (dmi_id) {
+		mode_fixup = (vlv_dsi_mode_fixup_func)dmi_id->driver_data;
+		mode_fixup(connector, fixed_mode);
+	}
+
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 	intel_backlight_setup(intel_connector, INVALID_PIPE);
 
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/2 drm/i915/vlv_dsi: Add DMI quirk for wrong panel size on Lenovo Yoga Tablet 2 series

On the Lenovo Yoga Tablet 2 830 / 1050 the VBT contains a bogus 192mm x 120mm size. This is especially a problem on the 8" 830 version which uses a 10:16 portrait screen where as the bogus size is 16:10.

Add a DMI quirk to override the wrong panel size with the correct one. Note both the 10" 1050 models as well as the 8" 830 models use the same mainboard and thus the same DMI strings. The 10" 1050 uses a 1920x1200 landscape screen, where as the 8" 830 uses a 1200x1920 portrait screen, so the quirk handling uses the display resolution to detect the model.

---
 drivers/gpu/drm/i915/display/vlv_dsi.c | 37 ++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/gpu/drm/i915/display/vlv_dsi.c +37 -0
index 66f5cf32bb66..e370a039e991 100644
@@ -1847,6 +1847,29 @@ static void vlv_dsi_asus_tf103c_mode_fixup(struct drm_connector *connector,
 	fixed_mode->crtc_vtotal = 816;
 }
 
+/*
+ * On the Lenovo Yoga Tablet 2 830 / 1050 width_/height_mm contain a bogus
+ * 192mm x 120mm size. This is especially a problem on the 8" 830 version which
+ * uses a 10:16 portrait screen where as the bogus size is 16:10.
+ */
+static void vlv_dsi_lenovo_yoga_tab2_mode_fixup(struct drm_connector *connector,
+						struct drm_display_mode *fixed_mode)
+{
+	struct drm_display_info *info = &connector->display_info;
+
+	/*
+	 * The 10" 1050 uses a 1920x1200 landscape screen, where as the 8" 830
+	 * uses a 1200x1920 portrait screen.
+	 */
+	if (fixed_mode->hdisplay == 1920) {
+		info->width_mm = 216;
+		info->height_mm = 135;
+	} else {
+		info->width_mm = 107;
+		info->height_mm = 171;
+	}
+}
+
 static const struct dmi_system_id dmi_mode_fixup_table[] = {
 	{
 		/* Asus Transformer Pad TF103C */
@@ -1856,6 +1879,20 @@ static const struct dmi_system_id dmi_mode_fixup_table[] = {
 		},
 		.driver_data = (void *)vlv_dsi_asus_tf103c_mode_fixup,
 	},
+	{
+		/*
+		 * Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10"
+		 * Lenovo Yoga Tablet 2 use the same mainboard)
+		 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
+			DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
+			/* Partial match on beginning of BIOS version */
+			DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"),
+		},
+		.driver_data = (void *)vlv_dsi_lenovo_yoga_tab2_mode_fixup,
+	},
 	{ }
 };
 
Signature · 1 line
2.35.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/i915/vlv_dsi: Add DMI quirk for wrong panel size on Lenovo Yoga Tablet 2 series

Quoted 4 lines · Hans de Goede

On the Lenovo Yoga Tablet 2 830 / 1050 the VBT contains a bogus 192mm x 120mm size. This is especially a problem on the 8" 830 version which uses a 10:16 portrait screen where as the bogus size is 16:10.

Quoted 8 lines

Add a DMI quirk to override the wrong panel size with the correct one. Note both the 10" 1050 models as well as the 8" 830 models use the same mainboard and thus the same DMI strings. The 10" 1050 uses a 1920x1200 landscape screen, where as the 8" 830 uses a 1200x1920 portrait screen, so the quirk handling uses the display resolution to detect the model.

---

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Linux Engineering
Red Hat
Reviewed-by on v1 1/2
#3 lore raw
In reply to Hans de Goede

Hello Hans,

Quoted 51 lines · Hans de Goede

Vtotal is wrong in the BIOS supplied modeline for the DSI panel on the Asus TF103C leading to the last line of the display being shown as the first line.

The factory installed Android has a hardcoded modeline in its kernel, causing it to not suffer from this BIOS bug;

and the Android boot-splash which uses the EFI FB which does have this bug has the last line all black causing the bug to not be visible.

This commit introduces a generic DMI based mechanism for doing modeline fixups, in case we need similar fixups on other models in the future.

---
 drivers/gpu/drm/i915/display/vlv_dsi.c | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/gpu/drm/i915/display/vlv_dsi.c +18 -0
index 06ef822c27bd..66f5cf32bb66 100644
@@ -23,6 +23,7 @@
  * Author: Jani Nikula <[email protected]>
  */
 
+#include <linux/dmi.h>
 #include <linux/slab.h>
 
 #include <drm/drm_atomic_helper.h>
@@ -1831,6 +1832,33 @@ static void vlv_dphy_param_init(struct intel_dsi *intel_dsi)
 	intel_dsi_log_params(intel_dsi);
 }
 
+typedef void (*vlv_dsi_mode_fixup_func)(struct drm_connector *connector,
+					struct drm_display_mode *fixed_mode);
+
+/*
+ * Vtotal is wrong on the Asus TF103C leading to the last line of the display
+ * being shown as the first line. The factory installed Android has a hardcoded
+ * modeline, causing it to not suffer from this BIOS bug.
+ */
+static void vlv_dsi_asus_tf103c_mode_fixup(struct drm_connector *connector,
+					   struct drm_display_mode *fixed_mode)
+{
+	fixed_mode->vtotal = 816;
+	fixed_mode->crtc_vtotal = 816;
+}
+
+static const struct dmi_system_id dmi_mode_fixup_table[] = {
+	{

drivers/gpu/drm/i915/display/vlv_dsi.c static void vlv_dphy_param_init(struct intel_dsi *intel_dsi) · line 1861

Quoted 10 lines
drivers/gpu/drm/i915/display/vlv_dsi.c +10 -0
+		/* Asus Transformer Pad TF103C */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
+		},
+		.driver_data = (void *)vlv_dsi_asus_tf103c_mode_fixup,
+	},
+	{ }
+};
+

There's nothing driver specific in this mechanism so I wonder if would be better to add it as a DRM helper, for others drivers to use it too.

Maybe in drivers/gpu/drm/drm_modeset_helper.c or a drm_modeset_quirks.c like we have for drivers/gpu/drm/drm_panel_orientation_quirks.c ?

The patch looks good to me, regardless where you decide to add it.

Best regards,

Signature · 3 lines
Javier Martinez Canillas
Linux Engineering
Red Hat
#4 lore raw
In reply to Hans de Goede
Quoted 1 line · Hans de Goede

Vtotal is wrong in the BIOS supplied modeline for the DSI panel on

Please include both the correct and bad modelines in the commit msg.

Quoted 35 lines

the Asus TF103C leading to the last line of the display being shown as the first line.

The factory installed Android has a hardcoded modeline in its kernel, causing it to not suffer from this BIOS bug;

and the Android boot-splash which uses the EFI FB which does have this bug has the last line all black causing the bug to not be visible.

This commit introduces a generic DMI based mechanism for doing modeline fixups, in case we need similar fixups on other models in the future.

---
 drivers/gpu/drm/i915/display/vlv_dsi.c | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/gpu/drm/i915/display/vlv_dsi.c +3 -0
index 06ef822c27bd..66f5cf32bb66 100644
@@ -23,6 +23,7 @@
  * Author: Jani Nikula <[email protected]>
  */
 
+#include <linux/dmi.h>
 #include <linux/slab.h>
 
 #include <drm/drm_atomic_helper.h>
@@ -1831,6 +1832,33 @@ static void vlv_dphy_param_init(struct intel_dsi *intel_dsi)
 	intel_dsi_log_params(intel_dsi);
 }
 
+typedef void (*vlv_dsi_mode_fixup_func)(struct drm_connector *connector,
+					struct drm_display_mode *fixed_mode);

drivers/gpu/drm/i915/display/vlv_dsi.c static void vlv_dphy_param_init(struct intel_dsi *intel_dsi) · line 1846

Quoted 10 lines
drivers/gpu/drm/i915/display/vlv_dsi.c +10 -0
+
+/*
+ * Vtotal is wrong on the Asus TF103C leading to the last line of the display
+ * being shown as the first line. The factory installed Android has a hardcoded
+ * modeline, causing it to not suffer from this BIOS bug.
+ */
+static void vlv_dsi_asus_tf103c_mode_fixup(struct drm_connector *connector,
+					   struct drm_display_mode *fixed_mode)
+{
+	fixed_mode->vtotal = 816;

I might prefer a full modeline here. Or maybe just vtotal-- or something, if it's just an off by one.

drivers/gpu/drm/i915/display/vlv_dsi.c static void vlv_dphy_param_init(struct intel_dsi *intel_dsi) · line 1847

Quoted 1 line
drivers/gpu/drm/i915/display/vlv_dsi.c +1 -0
+	fixed_mode->crtc_vtotal = 816;

The crtc timings should all be 0 at this point. So this looks redundant.

Quoted 18 lines
drivers/gpu/drm/i915/display/vlv_dsi.c +14 -0
+}
+
+static const struct dmi_system_id dmi_mode_fixup_table[] = {
+	{
+		/* Asus Transformer Pad TF103C */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
+		},
+		.driver_data = (void *)vlv_dsi_asus_tf103c_mode_fixup,
+	},
+	{ }
+};
+
 void vlv_dsi_init(struct drm_i915_private *dev_priv)
 {
 	struct drm_device *dev = &dev_priv->drm;

drivers/gpu/drm/i915/display/vlv_dsi.c void vlv_dsi_init(struct drm_i915_private *dev_priv) · line 1872

Quoted 5 lines
drivers/gpu/drm/i915/display/vlv_dsi.c +2 -0
@@ -1840,6 +1868,8 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
 	struct intel_connector *intel_connector;
 	struct drm_connector *connector;
 	struct drm_display_mode *current_mode, *fixed_mode;
+	const struct dmi_system_id *dmi_id;
+	vlv_dsi_mode_fixup_func mode_fixup;

The function pointer can go into the if block.

Quoted 18 lines
drivers/gpu/drm/i915/display/vlv_dsi.c +6 -0
 	enum port port;
 	enum pipe pipe;
 
@@ -1968,6 +1998,12 @@ void vlv_dsi_init(struct drm_i915_private *dev_priv)
 		goto err_cleanup_connector;
 	}
 
+	dmi_id = dmi_first_match(dmi_mode_fixup_table);
+	if (dmi_id) {
+		mode_fixup = (vlv_dsi_mode_fixup_func)dmi_id->driver_data;
+		mode_fixup(connector, fixed_mode);
+	}
+
 	intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
 	intel_backlight_setup(intel_connector, INVALID_PIPE);
 
Signature · 1 line
2.35.1
Signature · 2 lines
Ville Syrjälä
Intel