summaryrefslogtreecommitdiff
path: root/src/i830_xf86Modes.c
diff options
context:
space:
mode:
authorEric Anholt <anholt@FreeBSD.org>2006-06-28 14:21:49 +0200
committerEric Anholt <anholt@FreeBSD.org>2006-06-28 14:21:49 +0200
commitce5bd108c55d2378db072617c380514a39672603 (patch)
treefe0b7439f9bd8a3fd642515e84f98ffa6295c0a9 /src/i830_xf86Modes.c
parent367f69f8e7710e53dcd286f1b62506a3276e80f9 (diff)
Validate and insert user and VESA standard modes for DDC or configured fallback.
This isn't really tested because I lack a good CRT to test against currently.
Diffstat (limited to 'src/i830_xf86Modes.c')
-rw-r--r--src/i830_xf86Modes.c68
1 files changed, 66 insertions, 2 deletions
diff --git a/src/i830_xf86Modes.c b/src/i830_xf86Modes.c
index 6f620c81..09f6b342 100644
--- a/src/i830_xf86Modes.c
+++ b/src/i830_xf86Modes.c
@@ -44,13 +44,32 @@
* there but we still want to use. We need to come up with better API here.
*/
+
/**
- * Calculates the vertical refresh of a mode.
+ * Calculates the horizontal sync rate of a mode.
*
* Exact copy of xf86Mode.c's.
*/
double
-I830ModeVRefresh(DisplayModePtr mode)
+i830xf86ModeHSync(DisplayModePtr mode)
+{
+ double hsync = 0.0;
+
+ if (mode->HSync > 0.0)
+ hsync = mode->HSync;
+ else if (mode->HTotal > 0)
+ hsync = (float)mode->Clock / (float)mode->HTotal;
+
+ return hsync;
+}
+
+/**
+ * Calculates the vertical refresh rate of a mode.
+ *
+ * Exact copy of xf86Mode.c's.
+ */
+double
+i830xf86ModeVRefresh(DisplayModePtr mode)
{
double refresh = 0.0;
@@ -291,6 +310,51 @@ i830xf86ValidateModesSize(ScrnInfoPtr pScrn, DisplayModePtr modeList,
}
/**
+ * Marks as bad any modes that aren't supported by the given monitor's
+ * hsync and vrefresh ranges.
+ *
+ * \param modeList doubly-linked or circular list of modes.
+ *
+ * This is not in xf86Modes.c, but would be part of the proposed new API.
+ */
+void
+i830xf86ValidateModesSync(ScrnInfoPtr pScrn, DisplayModePtr modeList,
+ MonPtr mon)
+{
+ DisplayModePtr mode;
+
+ for (mode = modeList; mode != NULL; mode = mode->next) {
+ Bool bad;
+ int i;
+
+ bad = TRUE;
+ for (i = 0; i < mon->nHsync; i++) {
+ if (i830xf86ModeHSync(mode) >= mon->hsync[i].lo &&
+ i830xf86ModeHSync(mode) <= mon->hsync[i].hi)
+ {
+ bad = FALSE;
+ }
+ }
+ if (bad)
+ mode->status = MODE_HSYNC;
+
+ bad = TRUE;
+ for (i = 0; i < mon->nVrefresh; i++) {
+ if (i830xf86ModeVRefresh(mode) >= mon->vrefresh[i].lo &&
+ i830xf86ModeVRefresh(mode) <= mon->vrefresh[i].hi)
+ {
+ bad = FALSE;
+ }
+ }
+ if (bad)
+ mode->status = MODE_VSYNC;
+
+ if (mode->next == modeList)
+ break;
+ }
+}
+
+/**
* Marks as bad any modes extending beyond outside of the given clock ranges.
*
* \param modeList doubly-linked or circular list of modes.