summaryrefslogtreecommitdiff
path: root/src/nv_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nv_driver.c')
-rw-r--r--src/nv_driver.c70
1 files changed, 70 insertions, 0 deletions
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