summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Zhao <henryz@localhost.localdomain>2007-03-31 18:47:30 -0800
committerHenry Zhao <henryz@localhost.localdomain>2007-03-31 18:47:30 -0800
commitd569934c3de326483347db00d34268b02101599c (patch)
tree987ed74ebe9cbd4baf93b496efa5b72990e63c2c
parent4d929d383abe064b5334847eb466321a6bf30999 (diff)
10360: Need to inject a mode corresponding panel width/height for validation
-rw-r--r--configure.ac3
-rw-r--r--src/nv_driver.c70
2 files changed, 73 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 274697c..1b3140b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,9 @@ PKG_CHECK_EXISTS([xorg-server >= 1.0.99.901],
[AC_DEFINE(HAVE_XV_DRAWABLE,1,[XV hooks take a DrawablePtr])],
[AC_DEFINE(USE_LIBC_WRAPPER,1,[Use the libc wrapper])])
+PKG_CHECK_EXISTS([xorg-server >= 1.1.99.901],
+ [AC_DEFINE(USE_CVTMODE_FUNC,1,[Use xf86CVTMode func])])
+
# Checks for pkg-config packages
PKG_CHECK_MODULES(XORG, [xorg-server xproto fontsproto $REQUIRED_MODULES])
sdkdir=$(pkg-config --variable=sdkdir xorg-server)
diff --git a/src/nv_driver.c b/src/nv_driver.c
index 8ab76f6..7ac162a 100644
--- a/src/nv_driver.c
+++ b/src/nv_driver.c
@@ -1021,6 +1021,33 @@ Bool NVI2CInit(ScrnInfoPtr pScrn)
return FALSE;
}
+
+#ifdef USE_CVTMODE_FUNC
+/* Copied from ddc/Property.c */
+static DisplayModePtr
+NVModesAdd(DisplayModePtr Modes, DisplayModePtr Additions)
+{
+ if (!Modes) {
+ if (Additions)
+ return Additions;
+ else
+ return NULL;
+ }
+
+ if (Additions) {
+ DisplayModePtr Mode = Modes;
+
+ while (Mode->next)
+ Mode = Mode->next;
+
+ Mode->next = Additions;
+ Additions->prev = Mode;
+ }
+
+ return Modes;
+}
+#endif
+
/* Mandatory */
Bool
NVPreInit(ScrnInfoPtr pScrn, int flags)
@@ -1030,6 +1057,9 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
int i, max_width, max_height;
ClockRangePtr clockRanges;
const char *s;
+#ifdef USE_CVTMODE_FUNC
+ int config_mon_rates;
+#endif
if (flags & PROBE_DETECT) {
EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
@@ -1487,6 +1517,14 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
pNv->alphaCursor = (pNv->Architecture >= NV_ARCH_10) &&
((pNv->Chipset & 0x0ff0) != 0x0100);
+#ifdef USE_CVTMODE_FUNC
+ if ((pScrn->monitor->nHsync == 0) &&
+ (pScrn->monitor->nVrefresh == 0))
+ config_mon_rates = FALSE;
+ else
+ config_mon_rates = TRUE;
+#endif
+
NVCommonSetup(pScrn);
if (pNv->FBDev) {
@@ -1556,6 +1594,38 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
max_height = 4096;
}
+#ifdef USE_CVTMODE_FUNC
+ /* If DFP, add a modeline corresponding to its panel size */
+ if (pNv->FlatPanel && !pNv->Television && pNv->fpWidth && pNv->fpHeight) {
+ DisplayModePtr Mode;
+
+ Mode = xnfcalloc(1, sizeof(DisplayModeRec));
+ Mode = xf86CVTMode(pNv->fpWidth, pNv->fpHeight, 60.00, TRUE, FALSE);
+ Mode->type = M_T_DRIVER;
+ pScrn->monitor->Modes = NVModesAdd(pScrn->monitor->Modes, Mode);
+
+ if (!config_mon_rates) {
+ if (!Mode->HSync)
+ Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
+ if (!Mode->VRefresh)
+ Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
+ ((float) (Mode->HTotal * Mode->VTotal));
+
+ if (Mode->HSync < pScrn->monitor->hsync[0].lo)
+ pScrn->monitor->hsync[0].lo = Mode->HSync;
+ if (Mode->HSync > pScrn->monitor->hsync[0].hi)
+ pScrn->monitor->hsync[0].hi = Mode->HSync;
+ if (Mode->VRefresh < pScrn->monitor->vrefresh[0].lo)
+ pScrn->monitor->vrefresh[0].lo = Mode->VRefresh;
+ if (Mode->VRefresh > pScrn->monitor->vrefresh[0].hi)
+ pScrn->monitor->vrefresh[0].hi = Mode->VRefresh;
+
+ pScrn->monitor->nHsync = 1;
+ pScrn->monitor->nVrefresh = 1;
+ }
+ }
+#endif
+
/*
* xf86ValidateModes will check that the mode HTotal and VTotal values
* don't exceed the chipset's limit if pScrn->maxHValue and