[Intel-gfx] [RFC][PATCH]i830_lvds.c:filter mode clock for fixed mode

Ma Ling ling.ma at intel.com
Mon Feb 23 10:30:50 CET 2009


´╗┐Hi all,
fixed mode from EDID or bios, but sometime it's clock could be over or lower our clock threshold.
This patch intends to filter bad modes before setting it as fixed mode.

Thanks
Ma Ling

---
 src/i830_lvds.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/i830_lvds.c b/src/i830_lvds.c
index 027bb5d..5899779 100644
--- a/src/i830_lvds.c
+++ b/src/i830_lvds.c
@@ -70,6 +70,8 @@ struct i830_lvds_priv {
     enum pfit_mode fitting_mode;
     uint32_t pfit_control;
     uint32_t pfit_pgm_ratios;
+    uint32_t max_clock;
+    uint32_t min_clock;
 };
 
 #define BACKLIGHT_CLASS "/sys/class/backlight"
@@ -1405,6 +1407,15 @@ static const xf86OutputFuncsRec i830_lvds_output_funcs = {
 #endif
 };
 
+static Bool
+i830_lvds_valid_fixed_mode(struct i830_lvds_priv  *dev_priv,
+	                   DisplayModePtr mode)
+{
+    if (dev_priv->max_clock < mode->Clock ||
+	    dev_priv->min_clock > mode->Clock)
+	return FALSE;
+    return TRUE;
+}
 void
 i830_lvds_init(ScrnInfoPtr pScrn)
 {
@@ -1440,6 +1451,15 @@ i830_lvds_init(ScrnInfoPtr pScrn)
     dev_priv = (struct i830_lvds_priv *) (intel_output + 1);
     intel_output->dev_priv = dev_priv;
     
+    if (INREG(LVDS) & LVDS_B0B3_POWER_MASK) {
+	/* dual channel KHZ*/
+	dev_priv->max_clock = 224000;
+	dev_priv->min_clock = 80000;
+    } else {
+	/* single channel KHZ*/
+	dev_priv->max_clock = 112000;
+	dev_priv->min_clock = 20000;
+    }
     /*
      * Mode detection algorithms for LFP:
      *  1) if EDID present, use it, done
@@ -1468,6 +1488,8 @@ i830_lvds_init(ScrnInfoPtr pScrn)
      */
     modes = i830_ddc_get_modes(output);
     for (scan = modes; scan != NULL; scan = scan->next) {
+	if (i830_lvds_valid_fixed_mode(dev_priv, scan) == FALSE)
+	    continue;
 	if (scan->type & M_T_PREFERRED)
 	    break;
     }
@@ -1494,8 +1516,9 @@ i830_lvds_init(ScrnInfoPtr pScrn)
      * the BIOS being unavailable or broken, but lack the configuration options
      * for now.
      */
-    if (pI830->lvds_fixed_mode)
-	    goto found_mode;
+    if (pI830->lvds_fixed_mode &&
+	    i830_lvds_valid_fixed_mode(dev_priv, pI830->lvds_fixed_mode))
+	goto found_mode;
 
     /* If we *still* don't have a mode, try checking if the panel is already
      * turned on.  If so, assume that whatever is currently programmed is the
-- 
1.5.4.4






More information about the Intel-gfx mailing list