xserver: Branch 'master'
Keith Packard
keithp at kemper.freedesktop.org
Fri Feb 16 07:50:47 EET 2007
hw/xfree86/common/xf86Mode.c | 10 ++
hw/xfree86/ddc/Makefile.am | 3
hw/xfree86/modes/Makefile.am | 2
hw/xfree86/modes/xf86EdidModes.c | 147 +++++++++++++++++++++++++++++++++++++++
4 files changed, 159 insertions(+), 3 deletions(-)
New commits:
diff-tree f350909d1696fcfda87e8f12c729254d762313c9 (from 258beebc77510f84fbea66d6ebf29c5097bd11db)
Author: Keith Packard <keithp at guitar.keithp.com>
Date: Thu Feb 15 21:50:48 2007 -0800
Kludge around duplicate code added in hw/xfree86/modes.
Code added in hw/xfree86/modes came from the server-1.3-branch.
Portions of this code had previously been integrated into xf86Mode.c
and edid_modes.c.
To preserve hw/xfree86/modes as much as possible, the duplicate code from
the other files has been disabled; a more careful review would figure out
where that code actually belonged.
diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index d5085b5..fc905df 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -368,6 +368,7 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
return MODE_OK;
}
+#if 0
/** Calculates the horizontal sync rate of a mode */
_X_EXPORT double
xf86ModeHSync(DisplayModePtr mode)
@@ -411,6 +412,7 @@ xf86SetModeDefaultName(DisplayModePtr mo
mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay);
}
+#endif
/*
* xf86LookupMode
@@ -680,6 +682,7 @@ xf86LookupMode(ScrnInfoPtr scrp, Display
}
+#if 0
/*
* xf86SetModeCrtc
*
@@ -733,7 +736,9 @@ xf86SetModeCrtc(DisplayModePtr p, int ad
p->CrtcHAdjusted = FALSE;
p->CrtcVAdjusted = FALSE;
}
+#endif
+#if 0
/**
* Allocates and returns a copy of pMode, including pointers within pMode.
*/
@@ -814,6 +819,7 @@ xf86ModesEqual(DisplayModePtr pMode1, Di
return FALSE;
}
}
+#endif
/*
* xf86CheckModeForMonitor
@@ -2040,6 +2046,7 @@ add(char **p, char *new)
strcat(*p, new);
}
+#if 0
_X_EXPORT void
xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
{
@@ -2075,6 +2082,7 @@ xf86PrintModeline(int scrnIndex,DisplayM
mode->VTotal, flags);
xfree(flags);
}
+#endif
_X_EXPORT void
xf86PrintModes(ScrnInfoPtr scrp)
@@ -2145,6 +2153,7 @@ xf86PrintModes(ScrnInfoPtr scrp)
} while (p != NULL && p != scrp->modes);
}
+#if 0
/**
* Adds the new mode into the mode list, and returns the new list
*
@@ -2168,3 +2177,4 @@ xf86ModesAdd(DisplayModePtr modes, Displ
return modes;
}
+#endif
diff --git a/hw/xfree86/ddc/Makefile.am b/hw/xfree86/ddc/Makefile.am
index f3ac803..04d3e44 100644
--- a/hw/xfree86/ddc/Makefile.am
+++ b/hw/xfree86/ddc/Makefile.am
@@ -3,8 +3,7 @@ sdk_HEADERS = edid.h vdif.h xf86DDC.h
noinst_LIBRARIES = libddc.a
libddc_a_SOURCES = xf86DDC.c edid.c interpret_edid.c print_edid.c \
- interpret_vdif.c print_vdif.c ddcProperty.c \
- edid_modes.c
+ interpret_vdif.c print_vdif.c ddcProperty.c
INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
diff --git a/hw/xfree86/modes/Makefile.am b/hw/xfree86/modes/Makefile.am
index 60d2553..e0b6136 100644
--- a/hw/xfree86/modes/Makefile.am
+++ b/hw/xfree86/modes/Makefile.am
@@ -24,4 +24,4 @@ sdk_HEADERS = \
xf86RandR12.h \
xf86Rename.h
-AM_CFLAGS = $(XORG_CFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/hw/xfree86/modes/xf86EdidModes.c b/hw/xfree86/modes/xf86EdidModes.c
index 77c0c87..c4cf687 100644
--- a/hw/xfree86/modes/xf86EdidModes.c
+++ b/hw/xfree86/modes/xf86EdidModes.c
@@ -259,6 +259,50 @@ DDCModeFromDetailedTiming(int scrnIndex,
return Mode;
}
+/*
+ *
+ */
+static void
+DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
+{
+ DisplayModePtr Mode = Modes;
+
+ if (!Monitor || !Modes)
+ return;
+
+ /* set up the ranges for scanning through the modes */
+ Monitor->nHsync = 1;
+ Monitor->hsync[0].lo = 1024.0;
+ Monitor->hsync[0].hi = 0.0;
+
+ Monitor->nVrefresh = 1;
+ Monitor->vrefresh[0].lo = 1024.0;
+ Monitor->vrefresh[0].hi = 0.0;
+
+ while (Mode) {
+ 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 < Monitor->hsync[0].lo)
+ Monitor->hsync[0].lo = Mode->HSync;
+
+ if (Mode->HSync > Monitor->hsync[0].hi)
+ Monitor->hsync[0].hi = Mode->HSync;
+
+ if (Mode->VRefresh < Monitor->vrefresh[0].lo)
+ Monitor->vrefresh[0].lo = Mode->VRefresh;
+
+ if (Mode->VRefresh > Monitor->vrefresh[0].hi)
+ Monitor->vrefresh[0].hi = Mode->VRefresh;
+
+ Mode = Mode->next;
+ }
+}
+
DisplayModePtr
xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
{
@@ -341,3 +385,106 @@ xf86DDCGetModes(int scrnIndex, xf86MonPt
}
return Modes;
}
+
+/*
+ * Fill out MonPtr with xf86MonPtr information.
+ */
+void
+xf86DDCMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
+{
+ DisplayModePtr Modes = NULL, Mode;
+ int i, clock;
+ Bool have_hsync = FALSE, have_vrefresh = FALSE;
+
+ if (!Monitor || !DDC)
+ return;
+
+ Monitor->DDC = DDC;
+
+ Monitor->widthmm = 10 * DDC->features.hsize;
+ Monitor->heightmm = 10 * DDC->features.vsize;
+
+ /* If this is a digital display, then we can use reduced blanking */
+ if (DDC->features.input_type)
+ Monitor->reducedblanking = TRUE;
+ /* Allow the user to also enable this through config */
+
+ Modes = xf86DDCGetModes(scrnIndex, DDC);
+
+ /* Skip EDID ranges if they were specified in the config file */
+ have_hsync = (Monitor->nHsync != 0);
+ have_vrefresh = (Monitor->nVrefresh != 0);
+
+ /* Go through the detailed monitor sections */
+ for (i = 0; i < DET_TIMINGS; i++) {
+ switch (DDC->det_mon[i].type) {
+ case DS_RANGES:
+ if (!have_hsync) {
+ if (!Monitor->nHsync)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using EDID range info for horizontal sync\n");
+ Monitor->hsync[Monitor->nHsync].lo =
+ DDC->det_mon[i].section.ranges.min_h;
+ Monitor->hsync[Monitor->nHsync].hi =
+ DDC->det_mon[i].section.ranges.max_h;
+ Monitor->nHsync++;
+ } else {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using hsync ranges from config file\n");
+ }
+
+ if (!have_vrefresh) {
+ if (!Monitor->nVrefresh)
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using EDID range info for vertical refresh\n");
+ Monitor->vrefresh[Monitor->nVrefresh].lo =
+ DDC->det_mon[i].section.ranges.min_v;
+ Monitor->vrefresh[Monitor->nVrefresh].hi =
+ DDC->det_mon[i].section.ranges.max_v;
+ Monitor->nVrefresh++;
+ } else {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Using vrefresh ranges from config file\n");
+ }
+
+ clock = DDC->det_mon[i].section.ranges.max_clock * 1000;
+ if (clock > Monitor->maxPixClock)
+ Monitor->maxPixClock = clock;
+
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (Modes) {
+ /* Print Modes */
+ xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
+
+ Mode = Modes;
+ while (Mode) {
+ xf86PrintModeline(scrnIndex, Mode);
+ Mode = Mode->next;
+ }
+
+ /* Do we still need ranges to be filled in? */
+ if (!Monitor->nHsync || !Monitor->nVrefresh)
+ DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
+
+ /* look for last Mode */
+ Mode = Modes;
+
+ while (Mode->next)
+ Mode = Mode->next;
+
+ /* add to MonPtr */
+ if (Monitor->Modes) {
+ Monitor->Last->next = Modes;
+ Modes->prev = Monitor->Last;
+ Monitor->Last = Mode;
+ } else {
+ Monitor->Modes = Modes;
+ Monitor->Last = Mode;
+ }
+ }
+}
More information about the xorg-commit
mailing list