[Intel-gfx] [PATCH] drm/i915: Add sanity check for LVDS timing from VBT

Zhenyu Wang zhenyuw at linux.intel.com
Fri Jul 10 08:51:27 CEST 2009


From: Zhenyu Wang <zhenyu.z.wang at intel.com>

Some invalid LVDS timing block has been observed.
It's better to check modeline from VBT instead of
possible fail later.

Signed-off-by: Zhenyu Wang <zhenyu.z.wang at intel.com>
---
 drivers/gpu/drm/i915/intel_bios.c |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 7cc4471..30f3df5 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -59,7 +59,7 @@ find_section(struct bdb_header *bdb, int section_id)
 	return NULL;
 }
 
-static void
+static bool
 fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
 			struct lvds_dvo_timing *dvo_timing)
 {
@@ -89,7 +89,19 @@ fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
 	if (panel_fixed_mode->vsync_end > panel_fixed_mode->vtotal)
 		panel_fixed_mode->vtotal = panel_fixed_mode->vsync_end + 1;
 
+	/* some sanity check on timing values */
+	if (panel_fixed_mode->hdisplay == 0 ||
+		panel_fixed_mode->vdisplay == 0 ||
+		panel_fixed_mode->htotal == 0 ||
+		panel_fixed_mode->vtotal == 0) {
+		DRM_DEBUG_MODE(DRM_NAME,
+				"Invalid LVDS timing in VBIOS VBT:\n");
+		drm_mode_debug_printmodeline(panel_fixed_mode);
+		return false;
+	}
+
 	drm_mode_set_name(panel_fixed_mode);
+	return true;
 }
 
 /* Try to find integrated panel data */
@@ -144,12 +156,11 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
 
 	panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
 
-	fill_detail_timing_data(panel_fixed_mode, dvo_timing);
-
-	dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
-
-	DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
-	drm_mode_debug_printmodeline(panel_fixed_mode);
+	if (fill_detail_timing_data(panel_fixed_mode, dvo_timing)) {
+		dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
+		DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
+		drm_mode_debug_printmodeline(panel_fixed_mode);
+	}
 
 	return;
 }
@@ -178,10 +189,9 @@ parse_sdvo_panel_data(struct drm_i915_private *dev_priv,
 	if (!panel_fixed_mode)
 		return;
 
-	fill_detail_timing_data(panel_fixed_mode,
-			dvo_timing + sdvo_lvds_options->panel_type);
-
-	dev_priv->sdvo_lvds_vbt_mode = panel_fixed_mode;
+	if (fill_detail_timing_data(panel_fixed_mode,
+			dvo_timing + sdvo_lvds_options->panel_type))
+		dev_priv->sdvo_lvds_vbt_mode = panel_fixed_mode;
 
 	return;
 }
-- 
1.6.0.4




More information about the Intel-gfx mailing list