summaryrefslogtreecommitdiff
path: root/hw/xfree86/common
diff options
context:
space:
mode:
Diffstat (limited to 'hw/xfree86/common')
-rw-r--r--hw/xfree86/common/Makefile.am2
-rw-r--r--hw/xfree86/common/compiler.h4
-rw-r--r--hw/xfree86/common/xf86.h11
-rw-r--r--hw/xfree86/common/xf86Bus.c8
-rw-r--r--hw/xfree86/common/xf86Bus.h2
-rw-r--r--hw/xfree86/common/xf86Configure.c8
-rw-r--r--hw/xfree86/common/xf86Init.c29
-rw-r--r--hw/xfree86/common/xf86Mode.c153
8 files changed, 186 insertions, 31 deletions
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 6ad8566e0..d15e99a51 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -94,4 +94,4 @@ if LNXACPI
XORG_CFLAGS += -DHAVE_ACPI
endif
-AM_CFLAGS = $(XORG_CFLAGS)
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index a330fadf4..ea995eda1 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -118,7 +118,7 @@ extern int ffs(unsigned long);
# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
# if !defined(__arm__)
-# if !defined(__sparc__) && !defined(__arm32__) \
+# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) \
&& !(defined(__alpha__) && defined(linux)) \
&& !(defined(__ia64__) && defined(linux)) \
@@ -1697,7 +1697,7 @@ static __inline__ void ppc_flush_icache(char *addr)
: : "r"(addr) : "memory");
}
-# elif defined(__sparc__) || defined(sparc)
+# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
/*
* Like powerpc, we provide byteswapping and no byteswapping functions
* here with byteswapping as default, drivers that don't need byteswapping
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 51125304e..169a957d2 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -64,7 +64,7 @@ extern ScrnInfoPtr xf86CurrentScreen;
extern Bool pciSlotClaimed;
extern Bool isaSlotClaimed;
extern Bool fbSlotClaimed;
-#ifdef __sparc__
+#if defined(__sparc__) || defined(__sparc)
extern Bool sbusSlotClaimed;
#endif
extern confDRIRec xf86ConfigDRI;
@@ -418,6 +418,15 @@ void xf86PruneDriverModes(ScrnInfoPtr scrp);
void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
void xf86PrintModes(ScrnInfoPtr scrp);
void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
+double xf86ModeHSync(DisplayModePtr mode);
+double xf86ModeVRefresh(DisplayModePtr mode);
+void xf86SetModeDefaultName(DisplayModePtr mode);
+void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
+DisplayModePtr xf86DuplicateMode(DisplayModePtr pMode);
+DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
+Bool xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2);
+void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
+DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
/* xf86Option.c */
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index e20837851..7617bf78a 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -113,7 +113,7 @@ void
xf86BusProbe(void)
{
xf86PciProbe();
-#if defined(__sparc__) && !defined(__OpenBSD__)
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
xf86SbusProbe();
#endif
}
@@ -2373,7 +2373,7 @@ xf86PostProbe(void)
if (fbSlotClaimed) {
if (pciSlotClaimed || isaSlotClaimed
-#if defined(__sparc__) && !defined(__OpenBSD__)
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
|| sbusSlotClaimed
#endif
) {
@@ -3006,7 +3006,7 @@ xf86FindPrimaryDevice()
}
-#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__)
+#if !defined(__sparc) && !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__)
#include "vgaHW.h"
#include "compiler.h"
#endif
@@ -3018,7 +3018,7 @@ static void
CheckGenericGA()
{
/* This needs to be changed for multiple domains */
-#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__)
+#if !defined(__sparc__) && !defined(__sparc) && !defined(__powerpc__) && !defined(__mips__) && !defined(__ia64__) && !defined(__arm__) && !defined(__s390__)
IOADDRESS GenericIOBase = VGAHW_GET_IOBASE();
CARD8 CurrentValue, TestValue;
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index b7d16089c..b638e9026 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -40,7 +40,7 @@
#define _XF86_BUS_H
#include "xf86pciBus.h"
-#ifdef __sparc__
+#if defined(__sparc__) || defined(__sparc)
#include "xf86sbusBus.h"
#endif
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index f1f173dd8..f71486c9d 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -48,7 +48,7 @@
#include "Configint.h"
#include "vbe.h"
#include "xf86DDC.h"
-#if defined(__sparc__) && !defined(__OpenBSD__)
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
#include "xf86Bus.h"
#include "xf86Sbus.h"
#endif
@@ -57,7 +57,7 @@
typedef struct _DevToConfig {
GDevRec GDev;
pciVideoPtr pVideo;
-#if defined(__sparc__) && !defined(__OpenBSD__)
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
sbusDevicePtr sVideo;
#endif
int iDriver;
@@ -134,7 +134,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
if (!DevToConfig[i].pVideo)
return NULL;
break;
-#if defined(__sparc__) && !defined(__OpenBSD__)
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
case BUS_SBUS:
for (i = 0; i < nDevToConfig; i++)
if (DevToConfig[i].sVideo &&
@@ -213,7 +213,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int
NewDevice.GDev.identifier = "ISA Adapter";
NewDevice.GDev.busID = "ISA";
break;
-#if defined(__sparc__) && !defined(__OpenBSD__)
+#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
case BUS_SBUS: {
char *promPath = NULL;
NewDevice.sVideo = (sbusDevicePtr) busData;
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 33351f2c1..68d69c51c 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -100,6 +100,8 @@
static void xf86PrintBanner(void);
static void xf86PrintMarkers(void);
+static void xf86PrintDefaultModulePath(void);
+static void xf86PrintDefaultLibraryPath(void);
static void xf86RunVtInit(void);
#ifdef __UNIXOS2__
@@ -1117,6 +1119,9 @@ ddxGiveUp()
DGAShutdown();
#endif
+ while (xf86NumScreens)
+ xf86DeleteScreen(xf86NumScreens - 1, 0);
+
xf86CloseConsole();
xf86CloseLog();
@@ -1376,6 +1381,16 @@ ddxProcessArgument(int argc, char **argv, int i)
xf86PrintBanner();
exit(0);
}
+ if (!strcmp(argv[i],"-showDefaultModulePath"))
+ {
+ xf86PrintDefaultModulePath();
+ exit(0);
+ }
+ if (!strcmp(argv[i],"-showDefaultLibPath"))
+ {
+ xf86PrintDefaultLibraryPath();
+ exit(0);
+ }
/* Notice the -fp flag, but allow it to pass to the dix layer */
if (!strcmp(argv[i], "-fp"))
{
@@ -1625,6 +1640,8 @@ ddxUseMsg()
ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
ErrorF("-version show the server version\n");
+ ErrorF("-showDefaultModulePath show the server default module path\n");
+ ErrorF("-showDefaultLibPath show the server default library path\n");
/* OS-specific usage */
xf86UseMsg();
ErrorF("\n");
@@ -1748,6 +1765,18 @@ xf86PrintMarkers()
}
static void
+xf86PrintDefaultModulePath(void)
+{
+ ErrorF("%s\n", DEFAULT_MODULE_PATH);
+}
+
+static void
+xf86PrintDefaultLibraryPath(void)
+{
+ ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
+}
+
+static void
xf86RunVtInit(void)
{
int i;
diff --git a/hw/xfree86/common/xf86Mode.c b/hw/xfree86/common/xf86Mode.c
index 456331d3f..3cebac754 100644
--- a/hw/xfree86/common/xf86Mode.c
+++ b/hw/xfree86/common/xf86Mode.c
@@ -368,8 +368,9 @@ xf86HandleBuiltinMode(ScrnInfoPtr scrp,
return MODE_OK;
}
-static double
-ModeHSync(DisplayModePtr mode)
+/** Calculates the horizontal sync rate of a mode */
+_X_EXPORT double
+xf86ModeHSync(DisplayModePtr mode)
{
double hsync = 0.0;
@@ -381,8 +382,9 @@ ModeHSync(DisplayModePtr mode)
return hsync;
}
-static double
-ModeVRefresh(DisplayModePtr mode)
+/** Calculates the vertical refresh rate of a mode */
+_X_EXPORT double
+xf86ModeVRefresh(DisplayModePtr mode)
{
double refresh = 0.0;
@@ -400,6 +402,16 @@ ModeVRefresh(DisplayModePtr mode)
return refresh;
}
+/** Sets a default mode name of <width>x<height> on a mode. */
+_X_EXPORT void
+xf86SetModeDefaultName(DisplayModePtr mode)
+{
+ if (mode->name != NULL)
+ xfree(mode->name);
+
+ mode->name = XNFprintf("%dx%d", mode->HDisplay, mode->VDisplay);
+}
+
/*
* xf86LookupMode
*
@@ -529,7 +541,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
ModePrivFlags = cp->PrivFlags;
break;
}
- refresh = ModeVRefresh(p);
+ refresh = xf86ModeVRefresh(p);
if (p->Flags & V_INTERLACE)
refresh /= INTERLACE_REFRESH_WEIGHT;
if (refresh > bestRefresh) {
@@ -570,7 +582,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
found = TRUE;
if (strategy == LOOKUP_BEST_REFRESH) {
- refresh = ModeVRefresh(p);
+ refresh = xf86ModeVRefresh(p);
if (p->Flags & V_INTERLACE)
refresh /= INTERLACE_REFRESH_WEIGHT;
if (refresh > bestRefresh) {
@@ -674,7 +686,7 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
* Initialises the Crtc parameters for a mode. The initialisation includes
* adjustments for interlaced and double scan modes.
*/
-static void
+_X_EXPORT void
xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
{
if ((p == NULL) || ((p->type & M_T_CRTC_C) == M_T_BUILTIN))
@@ -756,6 +768,87 @@ xf86SetModeCrtc(DisplayModePtr p, int adjustFlags)
}
}
+/**
+ * Allocates and returns a copy of pMode, including pointers within pMode.
+ */
+_X_EXPORT DisplayModePtr
+xf86DuplicateMode(DisplayModePtr pMode)
+{
+ DisplayModePtr pNew;
+
+ pNew = xnfalloc(sizeof(DisplayModeRec));
+ *pNew = *pMode;
+ pNew->next = NULL;
+ pNew->prev = NULL;
+ if (pNew->name == NULL) {
+ xf86SetModeDefaultName(pMode);
+ } else {
+ pNew->name = xnfstrdup(pMode->name);
+ }
+
+ return pNew;
+}
+
+/**
+ * Duplicates every mode in the given list and returns a pointer to the first
+ * mode.
+ *
+ * \param modeList doubly-linked mode list
+ */
+_X_EXPORT DisplayModePtr
+xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList)
+{
+ DisplayModePtr first = NULL, last = NULL;
+ DisplayModePtr mode;
+
+ for (mode = modeList; mode != NULL; mode = mode->next) {
+ DisplayModePtr new;
+
+ new = xf86DuplicateMode(mode);
+
+ /* Insert pNew into modeList */
+ if (last) {
+ last->next = new;
+ new->prev = last;
+ } else {
+ first = new;
+ new->prev = NULL;
+ }
+ new->next = NULL;
+ last = new;
+ }
+
+ return first;
+}
+
+/**
+ * Returns true if the given modes should program to the same timings.
+ *
+ * This doesn't use Crtc values, as it might be used on ModeRecs without the
+ * Crtc values set. So, it's assumed that the other numbers are enough.
+ */
+_X_EXPORT Bool
+xf86ModesEqual(DisplayModePtr pMode1, DisplayModePtr pMode2)
+{
+ if (pMode1->Clock == pMode2->Clock &&
+ pMode1->HDisplay == pMode2->HDisplay &&
+ pMode1->HSyncStart == pMode2->HSyncStart &&
+ pMode1->HSyncEnd == pMode2->HSyncEnd &&
+ pMode1->HTotal == pMode2->HTotal &&
+ pMode1->HSkew == pMode2->HSkew &&
+ pMode1->VDisplay == pMode2->VDisplay &&
+ pMode1->VSyncStart == pMode2->VSyncStart &&
+ pMode1->VSyncEnd == pMode2->VSyncEnd &&
+ pMode1->VTotal == pMode2->VTotal &&
+ pMode1->VScan == pMode2->VScan &&
+ pMode1->Flags == pMode2->Flags)
+ {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
/*
* xf86CheckModeForMonitor
*
@@ -789,7 +882,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
if (monitor->nHsync > 0) {
/* Check hsync against the allowed ranges */
- float hsync = ModeHSync(mode);
+ float hsync = xf86ModeHSync(mode);
for (i = 0; i < monitor->nHsync; i++)
if ((hsync > monitor->hsync[i].lo * (1.0 - SYNC_TOLERANCE)) &&
(hsync < monitor->hsync[i].hi * (1.0 + SYNC_TOLERANCE)))
@@ -802,7 +895,7 @@ xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor)
if (monitor->nVrefresh > 0) {
/* Check vrefresh against the allowed ranges */
- float vrefrsh = ModeVRefresh(mode);
+ float vrefrsh = xf86ModeVRefresh(mode);
for (i = 0; i < monitor->nVrefresh; i++)
if ((vrefrsh > monitor->vrefresh[i].lo * (1.0 - SYNC_TOLERANCE)) &&
(vrefrsh < monitor->vrefresh[i].hi * (1.0 + SYNC_TOLERANCE)))
@@ -1033,8 +1126,8 @@ xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
/ (mode->CrtcHTotal * mode->CrtcVTotal);
}
- mode->HSync = ModeHSync(mode);
- mode->VRefresh = ModeVRefresh(mode);
+ mode->HSync = xf86ModeHSync(mode);
+ mode->VRefresh = xf86ModeVRefresh(mode);
/* Assume it is OK */
return MODE_OK;
@@ -1572,7 +1665,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
"TargetRefresh", 0.0);
if (targetRefresh > 0.0) {
for (p = scrp->modePool; p != NULL; p = p->next) {
- if (ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
+ if (xf86ModeVRefresh(p) > targetRefresh * (1.0 - SYNC_TOLERANCE))
break;
}
if (!p)
@@ -1661,7 +1754,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* If there is a target refresh rate, skip modes that
* don't match up.
*/
- if (ModeVRefresh(q) <
+ if (xf86ModeVRefresh(q) <
(1.0 - SYNC_TOLERANCE) * targetRefresh)
continue;
@@ -1981,8 +2074,8 @@ add(char **p, char *new)
strcat(*p, new);
}
-static void
-PrintModeline(int scrnIndex,DisplayModePtr mode)
+_X_EXPORT void
+xf86PrintModeline(int scrnIndex,DisplayModePtr mode)
{
char tmp[256];
char *flags = xnfcalloc(1, 1);
@@ -2037,8 +2130,8 @@ xf86PrintModes(ScrnInfoPtr scrp)
do {
desc = desc2 = "";
- hsync = ModeHSync(p);
- refresh = ModeVRefresh(p);
+ hsync = xf86ModeHSync(p);
+ refresh = xf86ModeVRefresh(p);
if (p->Flags & V_INTERLACE) {
desc = " (I)";
}
@@ -2081,7 +2174,31 @@ xf86PrintModes(ScrnInfoPtr scrp)
p->SynthClock / 1000.0, hsync, refresh, desc, desc2);
}
if (hsync != 0 && refresh != 0)
- PrintModeline(scrp->scrnIndex,p);
+ xf86PrintModeline(scrp->scrnIndex,p);
p = p->next;
} while (p != NULL && p != scrp->modes);
}
+
+/**
+ * Adds the new mode into the mode list, and returns the new list
+ *
+ * \param modes doubly-linked mode list.
+ */
+_X_EXPORT DisplayModePtr
+xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new)
+{
+ if (modes == NULL)
+ return new;
+
+ if (new) {
+ DisplayModePtr mode = modes;
+
+ while (mode->next)
+ mode = mode->next;
+
+ mode->next = new;
+ new->prev = mode;
+ }
+
+ return modes;
+}