aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2010-06-11 14:16:16 +0000
committermarha <marha@users.sourceforge.net>2010-06-11 14:16:16 +0000
commitd1e4f4b8546c7955c66dd023bfd6ef437db9d21d (patch)
tree529985e77bfc95aa95fe5b540e8f42b0ef041206 /xorg-server/hw/xfree86
parent13919cf85a6ca41d97238de13344aba59e0f7680 (diff)
parent4c61bf84b11e26e6f22648668c95ea760a379163 (diff)
downloadvcxsrv-d1e4f4b8546c7955c66dd023bfd6ef437db9d21d.tar.gz
vcxsrv-d1e4f4b8546c7955c66dd023bfd6ef437db9d21d.tar.bz2
vcxsrv-d1e4f4b8546c7955c66dd023bfd6ef437db9d21d.zip
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server/hw/xfree86')
-rw-r--r--xorg-server/hw/xfree86/common/xf86.h13
-rw-r--r--xorg-server/hw/xfree86/common/xf86AutoConfig.c7
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.c12
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c13
-rw-r--r--xorg-server/hw/xfree86/common/xf86Cursor.c104
-rw-r--r--xorg-server/hw/xfree86/common/xf86DGA.c35
-rw-r--r--xorg-server/hw/xfree86/common/xf86DPMS.c9
-rw-r--r--xorg-server/hw/xfree86/common/xf86Globals.c412
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c41
-rw-r--r--xorg-server/hw/xfree86/common/xf86Init.c16
-rw-r--r--xorg-server/hw/xfree86/common/xf86Option.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86RandR.c9
-rw-r--r--xorg-server/hw/xfree86/common/xf86VGAarbiter.c13
-rw-r--r--xorg-server/hw/xfree86/common/xf86VidMode.c16
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c234
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.c35
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.h154
-rw-r--r--xorg-server/hw/xfree86/common/xf86fbman.c150
-rw-r--r--xorg-server/hw/xfree86/common/xf86pciBus.c10
-rw-r--r--xorg-server/hw/xfree86/common/xf86pciBus.h2
-rw-r--r--xorg-server/hw/xfree86/common/xf86sbusBus.c5
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.c218
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvmc.c7
-rw-r--r--xorg-server/hw/xfree86/common/xisb.c14
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c16
-rw-r--r--xorg-server/hw/xfree86/ddc/interpret_edid.c2
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c37
-rw-r--r--xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c25
-rw-r--r--xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre71
-rw-r--r--xorg-server/hw/xfree86/doc/sgml/DESIGN.xml5
-rw-r--r--xorg-server/hw/xfree86/dri/dri.c61
-rw-r--r--xorg-server/hw/xfree86/dri/dristruct.h257
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.c2317
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.h13
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2ext.c21
-rw-r--r--xorg-server/hw/xfree86/exa/examodule.c7
-rw-r--r--xorg-server/hw/xfree86/fbdevhw/Makefile.am55
-rw-r--r--xorg-server/hw/xfree86/int10/Makefile.am91
-rw-r--r--xorg-server/hw/xfree86/loader/loadext.c14
-rw-r--r--xorg-server/hw/xfree86/loader/loadmod.c18
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c25
-rw-r--r--xorg-server/hw/xfree86/modes/xf86DiDGA.c3
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c12
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Rotate.c28
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/alpha_video.c1438
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/arm_video.c1332
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c16
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/bsd_init.c1520
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/i386_video.c10
-rw-r--r--xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c182
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_agp.c2
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_init.c802
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c12
-rw-r--r--xorg-server/hw/xfree86/os-support/sco/sco_init.c588
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c8
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c14
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/bios_devmem.c150
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/bios_mmap.c282
-rw-r--r--xorg-server/hw/xfree86/os-support/shared/posix_tty.c46
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c20
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_agp.c12
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/sun_bell.c360
-rw-r--r--xorg-server/hw/xfree86/os-support/sysv/sysv_init.c504
-rw-r--r--xorg-server/hw/xfree86/os-support/sysv/sysv_video.c630
-rw-r--r--xorg-server/hw/xfree86/parser/Configint.h444
-rw-r--r--xorg-server/hw/xfree86/parser/Device.c742
-rw-r--r--xorg-server/hw/xfree86/parser/Flags.c1031
-rw-r--r--xorg-server/hw/xfree86/parser/Input.c420
-rw-r--r--xorg-server/hw/xfree86/parser/InputClass.c689
-rw-r--r--xorg-server/hw/xfree86/parser/Layout.c1116
-rw-r--r--xorg-server/hw/xfree86/parser/Monitor.c1808
-rw-r--r--xorg-server/hw/xfree86/parser/Screen.c1138
-rw-r--r--xorg-server/hw/xfree86/parser/Video.c592
-rw-r--r--xorg-server/hw/xfree86/parser/read.c636
-rw-r--r--xorg-server/hw/xfree86/parser/scan.c2479
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Parser.h1048
-rw-r--r--xorg-server/hw/xfree86/parser/xf86tokens.h586
-rw-r--r--xorg-server/hw/xfree86/ramdac/IBM.c1278
-rw-r--r--xorg-server/hw/xfree86/ramdac/TI.c1434
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86Cursor.c6
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h101
-rw-r--r--xorg-server/hw/xfree86/ramdac/xf86RamDac.c8
-rw-r--r--xorg-server/hw/xfree86/shadowfb/shadow.c57
-rw-r--r--xorg-server/hw/xfree86/utils/gtf/gtf.c1482
-rw-r--r--xorg-server/hw/xfree86/vbe/vbe.c54
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaCmap.c4
-rw-r--r--xorg-server/hw/xfree86/vgahw/vgaHW.c7
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaBitBlt.c34
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaCpyArea.c16
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaCpyPlane.c12
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaCpyWin.c16
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaDashLine.c668
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFillArc.c426
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFillPoly.c1924
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaFillRect.c2190
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaGC.c3
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaImage.c4
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaInit.c25
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaLine.c788
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaLineMisc.c3
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaNonTEText.c24
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaOverlay.c18
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaOverlayDF.c37
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaPCache.c22
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaPict.c40
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaRect.c272
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaSpans.c1764
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaStateChange.c5
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaTEText.c15
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaWideLine.c1842
-rw-r--r--xorg-server/hw/xfree86/xaa/xaaWrapper.c13
-rw-r--r--xorg-server/hw/xfree86/xaa/xaawrap.h158
112 files changed, 20161 insertions, 19855 deletions
diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h
index b7a884b2a..b21bcdf47 100644
--- a/xorg-server/hw/xfree86/common/xf86.h
+++ b/xorg-server/hw/xfree86/common/xf86.h
@@ -55,9 +55,16 @@
extern _X_EXPORT int xf86DoConfigure;
extern _X_EXPORT int xf86DoShowOptions;
extern _X_EXPORT Bool xf86DoConfigurePass1;
-extern _X_EXPORT DevPrivateKey xf86ScreenKey;
-extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey;
-extern _X_EXPORT DevPrivateKey xf86PixmapKey;
+
+extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
+#define xf86ScreenKey (&xf86ScreenKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
+
+extern _X_EXPORT DevPrivateKeyRec xf86PixmapKeyRec;
+#define xf86PixmapKey (&xf86PixmapKeyRec)
+
extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern _X_EXPORT const unsigned char byte_reversed[256];
extern _X_EXPORT Bool fbSlotClaimed;
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
index 9f6348681..a00340191 100644
--- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c
+++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
@@ -120,8 +120,7 @@ FreeList(const char ***list, int *lines)
int i;
for (i = 0; i < *lines; i++) {
- if ((*list)[i])
- free((*list)[i]);
+ free((*list)[i]);
}
free(*list);
*list = NULL;
@@ -186,7 +185,7 @@ xf86AutoConfig(void)
if (ret != CONFIG_OK)
xf86Msg(X_ERROR, "Error parsing the built-in default configuration.\n");
- return (ret == CONFIG_OK);
+ return ret == CONFIG_OK;
}
static void
@@ -257,7 +256,7 @@ listPossibleVideoDrivers(char *matches[], int nmatches)
}
#endif
- xf86PciMatchDriver(matches, nmatches);
+ i = xf86PciMatchDriver(matches, nmatches);
/* Fallback to platform default hardware */
if (i < (nmatches - 1)) {
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index 77693d742..bec2343b2 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -245,7 +245,7 @@ xf86AllocateEntity(void)
xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
xf86Entities[xf86NumEntities - 1]->entityPrivates =
xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
- return (xf86NumEntities - 1);
+ return xf86NumEntities - 1;
}
Bool
@@ -257,9 +257,9 @@ xf86IsEntityPrimary(int entityIndex)
switch (pEnt->bus.type) {
case BUS_PCI:
- return (pEnt->bus.id.pci == primaryBus.id.pci);
+ return pEnt->bus.id.pci == primaryBus.id.pci;
case BUS_SBUS:
- return (pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum);
+ return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
default:
return FALSE;
}
@@ -342,7 +342,7 @@ xf86FindScreenForEntity(int entityIndex)
for (i = 0; i < xf86NumScreens; i++) {
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
if ( xf86Screens[i]->entityList[j] == entityIndex )
- return (xf86Screens[i]);
+ return xf86Screens[i];
}
}
}
@@ -557,7 +557,7 @@ int
xf86GetLastScrnFlag(int entityIndex)
{
if(entityIndex < xf86NumEntities) {
- return(xf86Entities[entityIndex]->lastScrnFlag);
+ return xf86Entities[entityIndex]->lastScrnFlag;
} else {
return -1;
}
@@ -654,7 +654,7 @@ xf86AllocateEntityPrivateIndex(void)
nprivs = xnfrealloc(pEnt->entityPrivates,
xf86EntityPrivateCount * sizeof(DevUnion));
/* Zero the new private */
- bzero(&nprivs[idx], sizeof(DevUnion));
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
pEnt->entityPrivates = nprivs;
}
return idx;
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index 33b38930f..0b1c767fb 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -163,7 +163,7 @@ xf86GetPathElem(char **pnt)
**pnt = '\0';
*pnt += 1;
}
- return(p1);
+ return p1;
}
/*
@@ -239,7 +239,7 @@ xf86ValidateFontPath(char *path)
strcat(out_pnt, path_elem);
out_pnt += strlen(path_elem);
}
- return(tmp_path);
+ return tmp_path;
}
@@ -1252,7 +1252,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
/* 5. Built-in default. */
if (!foundPointer && !xf86Info.allowEmptyInput) {
- bzero(&defPtr, sizeof(defPtr));
+ memset(&defPtr, 0, sizeof(defPtr));
defPtr.inp_identifier = strdup("<default pointer>");
defPtr.inp_driver = strdup("mouse");
confInput = &defPtr;
@@ -1303,7 +1303,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
}
if (!found && !xf86Info.allowEmptyInput) {
xf86Msg(X_INFO, "No default mouse found, adding one\n");
- bzero(&defPtr, sizeof(defPtr));
+ memset(&defPtr, 0, sizeof(defPtr));
defPtr.inp_identifier = strdup("<default pointer>");
defPtr.inp_driver = strdup("mouse");
confInput = &defPtr;
@@ -1392,7 +1392,7 @@ checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
/* 5. Built-in default. */
if (!foundKeyboard && !xf86Info.allowEmptyInput) {
- bzero(&defKbd, sizeof(defKbd));
+ memset(&defKbd, 0, sizeof(defKbd));
defKbd.inp_identifier = strdup("<default keyboard>");
defKbd.inp_driver = strdup("kbd");
confInput = &defKbd;
@@ -1851,7 +1851,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
if (!conf_screen->scrn_monitor) {
XF86ConfMonitorRec defMon;
- bzero(&defMon, sizeof(defMon));
+ memset(&defMon, 0, sizeof(defMon));
defMon.mon_identifier = "<default monitor>";
if (!configMonitor(screenp->monitor, &defMon))
return FALSE;
@@ -2330,6 +2330,7 @@ configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
inputp->driver = conf_input->inp_driver;
inputp->commonOptions = conf_input->inp_option_lst;
inputp->extraOptions = NULL;
+ inputp->attrs = NULL;
return TRUE;
}
diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c
index 76490e52d..acfa79f10 100644
--- a/xorg-server/hw/xfree86/common/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/common/xf86Cursor.c
@@ -581,7 +581,7 @@ xf86InitOrigins(void)
{
unsigned long screensLeft, prevScreensLeft, mask;
screenLayoutPtr screen;
- ScreenPtr pScreen;
+ ScreenPtr pScreen, refScreen;
int x1, x2, y1, y2, left, right, top, bottom;
int i, j, ref, minX, minY, min, max;
xf86ScreenLayoutPtr pLayout;
@@ -590,7 +590,7 @@ xf86InitOrigins(void)
/* need to have this set up with a config file option */
HardEdges = FALSE;
- bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
+ memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
@@ -608,6 +608,7 @@ xf86InitOrigins(void)
continue;
}
+ pScreen = xf86Screens[i]->pScreen;
switch(screen->where) {
case PosObsolete:
OldStyleConfig = TRUE;
@@ -620,7 +621,7 @@ xf86InitOrigins(void)
break;
}
pLayout->left = AddEdge(pLayout->left,
- 0, xf86Screens[i]->pScreen->height,
+ 0, pScreen->height,
xf86Screens[ref]->pScreen->width, 0, ref);
}
if(screen->right) {
@@ -629,7 +630,6 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- pScreen = xf86Screens[i]->pScreen;
pLayout->right = AddEdge(pLayout->right,
0, pScreen->height, -pScreen->width, 0, ref);
}
@@ -640,7 +640,7 @@ xf86InitOrigins(void)
break;
}
pLayout->up = AddEdge(pLayout->up,
- 0, xf86Screens[i]->pScreen->width,
+ 0, pScreen->width,
0, xf86Screens[ref]->pScreen->height, ref);
}
if(screen->bottom) {
@@ -649,7 +649,6 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- pScreen = xf86Screens[i]->pScreen;
pLayout->down = AddEdge(pLayout->down,
0, pScreen->width, 0, -pScreen->height, ref);
}
@@ -658,8 +657,8 @@ xf86InitOrigins(void)
screen->x = screen->y = 0;
/* FALLTHROUGH */
case PosAbsolute:
- dixScreenOrigins[i].x = screen->x;
- dixScreenOrigins[i].y = screen->y;
+ pScreen->x = screen->x;
+ pScreen->y = screen->y;
screensLeft &= ~(1 << i);
break;
case PosRelative:
@@ -669,8 +668,9 @@ xf86InitOrigins(void)
break;
}
if(screensLeft & (1 << ref)) break;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + screen->x;
+ pScreen->y = refScreen->y + screen->y;
screensLeft &= ~(1 << i);
break;
case PosRightOf:
@@ -680,10 +680,9 @@ xf86InitOrigins(void)
break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[ref]->pScreen;
- dixScreenOrigins[i].x =
- dixScreenOrigins[ref].x + pScreen->width;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x + refScreen->width;
+ pScreen->y = refScreen->y;
screensLeft &= ~(1 << i);
break;
case PosLeftOf:
@@ -693,10 +692,9 @@ xf86InitOrigins(void)
break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[i]->pScreen;
- dixScreenOrigins[i].x =
- dixScreenOrigins[ref].x - pScreen->width;
- dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x - pScreen->width;
+ pScreen->y = refScreen->y;
screensLeft &= ~(1 << i);
break;
case PosBelow:
@@ -706,10 +704,9 @@ xf86InitOrigins(void)
break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[ref]->pScreen;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
- dixScreenOrigins[i].y =
- dixScreenOrigins[ref].y + pScreen->height;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y + refScreen->height;
screensLeft &= ~(1 << i);
break;
case PosAbove:
@@ -719,10 +716,9 @@ xf86InitOrigins(void)
break;
}
if(screensLeft & (1 << ref)) break;
- pScreen = xf86Screens[i]->pScreen;
- dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
- dixScreenOrigins[i].y =
- dixScreenOrigins[ref].y - pScreen->height;
+ refScreen = xf86Screens[ref]->pScreen;
+ pScreen->x = refScreen->x;
+ pScreen->y = refScreen->y - pScreen->height;
screensLeft &= ~(1 << i);
break;
default:
@@ -741,7 +737,7 @@ xf86InitOrigins(void)
while(!((1 << i) & screensLeft)){ i++; }
ref = xf86ConfigLayout.screens[i].refscreen->screennum;
- dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
+ xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
screensLeft &= ~(1 << ref);
}
@@ -749,20 +745,20 @@ xf86InitOrigins(void)
}
/* justify the topmost and leftmost to (0,0) */
- minX = dixScreenOrigins[0].x;
- minY = dixScreenOrigins[0].y;
+ minX = xf86Screens[0]->pScreen->x;
+ minY = xf86Screens[0]->pScreen->y;
for(i = 1; i < xf86NumScreens; i++) {
- if(dixScreenOrigins[i].x < minX)
- minX = dixScreenOrigins[i].x;
- if(dixScreenOrigins[i].y < minY)
- minY = dixScreenOrigins[i].y;
+ if(xf86Screens[i]->pScreen->x < minX)
+ minX = xf86Screens[i]->pScreen->x;
+ if(xf86Screens[i]->pScreen->y < minY)
+ minY = xf86Screens[i]->pScreen->y;
}
if (minX || minY) {
for(i = 0; i < xf86NumScreens; i++) {
- dixScreenOrigins[i].x -= minX;
- dixScreenOrigins[i].y -= minY;
+ xf86Screens[i]->pScreen->x -= minX;
+ xf86Screens[i]->pScreen->y -= minY;
}
}
@@ -775,18 +771,20 @@ xf86InitOrigins(void)
pScreen = xf86Screens[i]->pScreen;
- left = dixScreenOrigins[i].x;
+ left = pScreen->x;
right = left + pScreen->width;
- top = dixScreenOrigins[i].y;
+ top = pScreen->y;
bottom = top + pScreen->height;
for(j = 0; j < xf86NumScreens; j++) {
if(i == j) continue;
- x1 = dixScreenOrigins[j].x;
- x2 = x1 + xf86Screens[j]->pScreen->width;
- y1 = dixScreenOrigins[j].y;
- y2 = y1 + xf86Screens[j]->pScreen->height;
+ refScreen = xf86Screens[j]->pScreen;
+
+ x1 = refScreen->x;
+ x2 = x1 + refScreen->width;
+ y1 = refScreen->y;
+ y2 = y1 + refScreen->height;
if((bottom > y1) && (top < y2)) {
min = y1 - top;
@@ -796,13 +794,13 @@ xf86InitOrigins(void)
if(((left - 1) >= x1) && ((left - 1) < x2))
pLayout->left = AddEdge(pLayout->left, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
if((right >= x1) && (right < x2))
pLayout->right = AddEdge(pLayout->right, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
}
@@ -814,13 +812,13 @@ xf86InitOrigins(void)
if(((top - 1) >= y1) && ((top - 1) < y2))
pLayout->up = AddEdge(pLayout->up, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
if((bottom >= y1) && (bottom < y2))
pLayout->down = AddEdge(pLayout->down, min, max,
- dixScreenOrigins[i].x - dixScreenOrigins[j].x,
- dixScreenOrigins[i].y - dixScreenOrigins[j].y, j);
+ pScreen->x - refScreen->x,
+ pScreen->y - refScreen->y, j);
}
}
}
@@ -850,10 +848,10 @@ xf86ReconfigureLayout(void)
for (i = 0; i < MAXSCREENS; i++) {
xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
/* we don't have to zero these, xf86InitOrigins() takes care of that */
- if (sl->left) free(sl->left);
- if (sl->right) free(sl->right);
- if (sl->up) free(sl->up);
- if (sl->down) free(sl->down);
+ free(sl->left);
+ free(sl->right);
+ free(sl->up);
+ free(sl->down);
}
xf86InitOrigins();
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c
index ac8302169..bc2aa3ba6 100644
--- a/xorg-server/hw/xfree86/common/xf86DGA.c
+++ b/xorg-server/hw/xfree86/common/xf86DGA.c
@@ -51,8 +51,8 @@
#include "mi.h"
-static int DGAScreenKeyIndex;
-static DevPrivateKey DGAScreenKey;
+static DevPrivateKeyRec DGAScreenKeyRec;
+#define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec)
static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@@ -71,7 +71,7 @@ DGACopyModeInfo(
int *XDGAEventBase = NULL;
#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey))
+ dixLookupPrivate(&(pScreen)->devPrivates, &DGAScreenKeyRec))
typedef struct _FakedVisualList{
@@ -118,7 +118,8 @@ DGAInit(
if(!modes || num <= 0)
return FALSE;
- DGAScreenKey = &DGAScreenKeyIndex;
+ if (!dixRegisterPrivateKey(&DGAScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -126,7 +127,7 @@ DGAInit(
{
if(!(pScreenPriv = (DGAScreenPtr)malloc(sizeof(DGAScreenRec))))
return FALSE;
- dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv);
+ dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@@ -177,7 +178,7 @@ DGAReInitModes(
int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -347,7 +348,7 @@ xf86SetDGAMode(
DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */
- if (DGAScreenKey == NULL)
+ if (!DGAScreenKeyRegistered)
return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv)
@@ -478,7 +479,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
DGAModePtr pMode;
PixmapPtr pPix;
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -528,7 +529,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
Bool
DGAAvailable(int index)
{
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@@ -542,7 +543,7 @@ DGAActive(int index)
{
DGAScreenPtr pScreenPriv;
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -563,7 +564,7 @@ DGAShutdown(void)
ScrnInfoPtr pScrn;
int i;
- if(DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered)
return;
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -893,7 +894,7 @@ DGAVTSwitch(void)
/* Alternatively, this could send events to DGA clients */
- if(DGAScreenKey) {
+ if(DGAScreenKeyRegistered) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current)
@@ -910,7 +911,7 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
DGAScreenPtr pScreenPriv;
DGAEvent event;
- if(DGAScreenKey == NULL) /* no DGA */
+ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
if (key_code < 8 || key_code > 255)
@@ -943,7 +944,7 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
DGAScreenPtr pScreenPriv;
DGAEvent event;
- if(DGAScreenKey == NULL) /* no DGA */
+ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -981,7 +982,7 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
DGAScreenPtr pScreenPriv;
DGAEvent event;
- if (DGAScreenKey == NULL)
+ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1009,7 +1010,7 @@ Bool
DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
- if (DGAScreenKey == NULL || XDGAEventBase == 0)
+ if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@@ -1203,7 +1204,7 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
DGAScreenPtr pScreenPriv;
/* no DGA */
- if (DGAScreenKey == NULL || XDGAEventBase == 0)
+ if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
diff --git a/xorg-server/hw/xfree86/common/xf86DPMS.c b/xorg-server/hw/xfree86/common/xf86DPMS.c
index 3040cb294..1a8aed306 100644
--- a/xorg-server/hw/xfree86/common/xf86DPMS.c
+++ b/xorg-server/hw/xfree86/common/xf86DPMS.c
@@ -46,7 +46,7 @@
#ifdef DPMSExtension
-static int DPMSKeyIndex;
+static DevPrivateKeyRec DPMSKeyRec;
static DevPrivateKey DPMSKey;
static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0;
@@ -62,10 +62,9 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
pointer DPMSOpt;
MessageType enabled_from;
- DPMSKey = &DPMSKeyIndex;
+ DPMSKey = &DPMSKeyRec;
- if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey,
- calloc(sizeof(DPMSRec), 1)))
+ if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
return FALSE;
pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
@@ -127,8 +126,6 @@ DPMSClose(int i, ScreenPtr pScreen)
xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
}
- free(pDPMS);
- dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0)
DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen);
diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c
index 8b483f35c..44252c75f 100644
--- a/xorg-server/hw/xfree86/common/xf86Globals.c
+++ b/xorg-server/hw/xfree86/common/xf86Globals.c
@@ -1,208 +1,204 @@
-
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains all the XFree86 global variables.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "windowstr.h"
-#include "propertyst.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Parser.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "xf86Config.h"
-
-/* Globals that video drivers may access */
-
-/* Index into pScreen.devPrivates */
-static int xf86CreateRootWindowKeyIndex;
-DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKeyIndex;
-/* Index of ScrnInfo in pScreen.devPrivates */
-static int xf86ScreenKeyIndex;
-DevPrivateKey xf86ScreenKey = &xf86ScreenKeyIndex;
-static int xf86PixmapKeyIndex;
-DevPrivateKey xf86PixmapKey = &xf86PixmapKeyIndex;
-ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-const unsigned char byte_reversed[256] =
-{
- 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
- 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
- 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
- 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
- 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
- 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
- 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
- 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
- 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
- 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
- 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
- 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
- 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
- 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
- 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
- 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
- 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
- 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
- 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
- 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
- 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
- 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
- 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
- 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
- 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
- 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
- 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
- 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
- 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
- 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
- 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
- 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
-/* Globals that input drivers may access */
-InputInfoPtr xf86InputDevs = NULL;
-
-
-/* Globals that video drivers may not access */
-
-xf86InfoRec xf86Info = {
- .consoleFd = -1,
- .vtno = -1,
- .vtSysreq = FALSE,
- .lastEventTime = -1,
- .vtRequestsPending = FALSE,
-#ifdef sun
- .vtPendingNum = -1,
-#endif
- .dontVTSwitch = FALSE,
- .dontZap = FALSE,
- .dontZoom = FALSE,
- .notrapSignals = FALSE,
- .caughtSignal = FALSE,
- .currentScreen = NULL,
-#ifdef CSRG_BASED
- .screenFd = -1,
- .consType = -1,
-#endif
- .allowMouseOpenFail = FALSE,
- .vidModeEnabled = TRUE,
- .vidModeAllowNonLocal = FALSE,
- .miscModInDevEnabled = TRUE,
- .miscModInDevAllowNonLocal = FALSE,
- .pixmap24 = Pix24DontCare,
- .pix24From = X_DEFAULT,
-#ifdef SUPPORT_PC98
- .pc98 = FALSE,
-#endif
- .pmFlag = TRUE,
- .log = LogNone,
- .kbdCustomKeycodes = FALSE,
- .disableRandR = FALSE,
- .randRFrom = X_DEFAULT,
-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
- .allowEmptyInput = TRUE,
- .autoAddDevices = TRUE,
- .autoEnableDevices = TRUE
-#else
- .allowEmptyInput = FALSE,
- .autoAddDevices = FALSE,
- .autoEnableDevices = FALSE
-#endif
-};
-const char *xf86ConfigFile = NULL;
-const char *xf86ConfigDir = NULL;
-const char *xf86ModulePath = DEFAULT_MODULE_PATH;
-MessageType xf86ModPathFrom = X_DEFAULT;
-const char *xf86LogFile = DEFAULT_LOGPREFIX;
-MessageType xf86LogFileFrom = X_DEFAULT;
-Bool xf86LogFileWasOpened = FALSE;
-serverLayoutRec xf86ConfigLayout = {NULL, };
-confDRIRec xf86ConfigDRI = {0, };
-XF86ConfigPtr xf86configptr = NULL;
-Bool xf86Resetting = FALSE;
-Bool xf86Initialising = FALSE;
-Bool xf86DoConfigure = FALSE;
-Bool xf86DoShowOptions = FALSE;
-DriverPtr *xf86DriverList = NULL;
-int xf86NumDrivers = 0;
-InputDriverPtr *xf86InputDriverList = NULL;
-int xf86NumInputDrivers = 0;
-int xf86NumScreens = 0;
-
-const char *xf86VisualNames[] = {
- "StaticGray",
- "GrayScale",
- "StaticColor",
- "PseudoColor",
- "TrueColor",
- "DirectColor"
-};
-
-/* Parameters set only from the command line */
-char *xf86ServerName = "no-name";
-Bool xf86fpFlag = FALSE;
-Bool xf86sFlag = FALSE;
-Bool xf86bsEnableFlag = FALSE;
-Bool xf86bsDisableFlag = FALSE;
-Bool xf86silkenMouseDisableFlag = FALSE;
-Bool xf86xkbdirFlag = FALSE;
-#ifdef HAVE_ACPI
-Bool xf86acpiDisableFlag = FALSE;
-#endif
-char *xf86LayoutName = NULL;
-char *xf86ScreenName = NULL;
-char *xf86PointerName = NULL;
-char *xf86KeyboardName = NULL;
-int xf86Verbose = DEFAULT_VERBOSE;
-int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
-int xf86FbBpp = -1;
-Pix24Flags xf86Pix24 = Pix24DontCare;
-int xf86Depth = -1;
-rgb xf86Weight = {0, 0, 0};
-Bool xf86FlipPixels = FALSE;
-Gamma xf86Gamma = {0.0, 0.0, 0.0};
-Bool xf86AllowMouseOpenFail = FALSE;
-#ifdef XF86VIDMODE
-Bool xf86VidModeDisabled = FALSE;
-Bool xf86VidModeAllowNonLocal = FALSE;
-#endif
-RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
-Bool xf86inSuspend = FALSE;
-Bool xorgHWAccess = FALSE;
-
-struct pci_slot_match xf86IsolateDevice = {
- PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
-};
+
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/*
+ * This file contains all the XFree86 global variables.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "os.h"
+#include "windowstr.h"
+#include "propertyst.h"
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86Parser.h"
+#include "xf86Xinput.h"
+#include "xf86InPriv.h"
+#include "xf86Config.h"
+
+/* Globals that video drivers may access */
+
+DevPrivateKeyRec xf86CreateRootWindowKeyRec;
+DevPrivateKeyRec xf86ScreenKeyRec;
+DevPrivateKeyRec xf86PixmapKeyRec;
+
+ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
+const unsigned char byte_reversed[256] =
+{
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+/* Globals that input drivers may access */
+InputInfoPtr xf86InputDevs = NULL;
+
+
+/* Globals that video drivers may not access */
+
+xf86InfoRec xf86Info = {
+ .consoleFd = -1,
+ .vtno = -1,
+ .vtSysreq = FALSE,
+ .lastEventTime = -1,
+ .vtRequestsPending = FALSE,
+#ifdef sun
+ .vtPendingNum = -1,
+#endif
+ .dontVTSwitch = FALSE,
+ .dontZap = FALSE,
+ .dontZoom = FALSE,
+ .notrapSignals = FALSE,
+ .caughtSignal = FALSE,
+ .currentScreen = NULL,
+#ifdef CSRG_BASED
+ .screenFd = -1,
+ .consType = -1,
+#endif
+ .allowMouseOpenFail = FALSE,
+ .vidModeEnabled = TRUE,
+ .vidModeAllowNonLocal = FALSE,
+ .miscModInDevEnabled = TRUE,
+ .miscModInDevAllowNonLocal = FALSE,
+ .pixmap24 = Pix24DontCare,
+ .pix24From = X_DEFAULT,
+#ifdef SUPPORT_PC98
+ .pc98 = FALSE,
+#endif
+ .pmFlag = TRUE,
+ .log = LogNone,
+ .kbdCustomKeycodes = FALSE,
+ .disableRandR = FALSE,
+ .randRFrom = X_DEFAULT,
+#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
+ .allowEmptyInput = TRUE,
+ .autoAddDevices = TRUE,
+ .autoEnableDevices = TRUE
+#else
+ .allowEmptyInput = FALSE,
+ .autoAddDevices = FALSE,
+ .autoEnableDevices = FALSE
+#endif
+};
+const char *xf86ConfigFile = NULL;
+const char *xf86ConfigDir = NULL;
+const char *xf86ModulePath = DEFAULT_MODULE_PATH;
+MessageType xf86ModPathFrom = X_DEFAULT;
+const char *xf86LogFile = DEFAULT_LOGPREFIX;
+MessageType xf86LogFileFrom = X_DEFAULT;
+Bool xf86LogFileWasOpened = FALSE;
+serverLayoutRec xf86ConfigLayout = {NULL, };
+confDRIRec xf86ConfigDRI = {0, };
+XF86ConfigPtr xf86configptr = NULL;
+Bool xf86Resetting = FALSE;
+Bool xf86Initialising = FALSE;
+Bool xf86DoConfigure = FALSE;
+Bool xf86DoShowOptions = FALSE;
+DriverPtr *xf86DriverList = NULL;
+int xf86NumDrivers = 0;
+InputDriverPtr *xf86InputDriverList = NULL;
+int xf86NumInputDrivers = 0;
+int xf86NumScreens = 0;
+
+const char *xf86VisualNames[] = {
+ "StaticGray",
+ "GrayScale",
+ "StaticColor",
+ "PseudoColor",
+ "TrueColor",
+ "DirectColor"
+};
+
+/* Parameters set only from the command line */
+char *xf86ServerName = "no-name";
+Bool xf86fpFlag = FALSE;
+Bool xf86sFlag = FALSE;
+Bool xf86bsEnableFlag = FALSE;
+Bool xf86bsDisableFlag = FALSE;
+Bool xf86silkenMouseDisableFlag = FALSE;
+Bool xf86xkbdirFlag = FALSE;
+#ifdef HAVE_ACPI
+Bool xf86acpiDisableFlag = FALSE;
+#endif
+char *xf86LayoutName = NULL;
+char *xf86ScreenName = NULL;
+char *xf86PointerName = NULL;
+char *xf86KeyboardName = NULL;
+int xf86Verbose = DEFAULT_VERBOSE;
+int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
+int xf86FbBpp = -1;
+Pix24Flags xf86Pix24 = Pix24DontCare;
+int xf86Depth = -1;
+rgb xf86Weight = {0, 0, 0};
+Bool xf86FlipPixels = FALSE;
+Gamma xf86Gamma = {0.0, 0.0, 0.0};
+Bool xf86AllowMouseOpenFail = FALSE;
+#ifdef XF86VIDMODE
+Bool xf86VidModeDisabled = FALSE;
+Bool xf86VidModeAllowNonLocal = FALSE;
+#endif
+RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
+Bool xf86inSuspend = FALSE;
+Bool xorgHWAccess = FALSE;
+
+struct pci_slot_match xf86IsolateDevice = {
+ PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0
+};
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index 0fa695a3a..a88a1e758 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -234,8 +234,7 @@ xf86DeleteScreen(int scrnIndex, int flags)
if (pScrn->drv)
pScrn->drv->refCount--;
- if (pScrn->privates)
- free(pScrn->privates);
+ free(pScrn->privates);
xf86ClearEntityListForScreen(scrnIndex);
@@ -269,7 +268,7 @@ xf86AllocateScrnInfoPrivateIndex(void)
nprivs = xnfrealloc(pScr->privates,
xf86ScrnInfoPrivateCount * sizeof(DevUnion));
/* Zero the new private */
- bzero(&nprivs[idx], sizeof(DevUnion));
+ memset(&nprivs[idx], 0, sizeof(DevUnion));
pScr->privates = nprivs;
}
return idx;
@@ -327,8 +326,7 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
/* This should *really* be handled in drv->UnInit(dev) call instead, but
* if the driver forgets about it make sure we free it or at least crash
* with flying colors */
- if (pInp->private)
- free(pInp->private);
+ free(pInp->private);
FreeInputAttributes(pInp->attrs);
@@ -1062,7 +1060,7 @@ xf86SetBlackWhitePixels(ScreenPtr pScreen)
static void
xf86SetRootClip (ScreenPtr pScreen, Bool enable)
{
- WindowPtr pWin = WindowTable[pScreen->myNum];
+ WindowPtr pWin = pScreen->root;
WindowPtr pChild;
Bool WasViewable = (Bool)(pWin->viewable);
Bool anyMarked = FALSE;
@@ -1085,8 +1083,8 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
{
RegionPtr borderVisible;
- borderVisible = REGION_CREATE(pScreen, NullBox, 1);
- REGION_SUBTRACT(pScreen, borderVisible,
+ borderVisible = RegionCreate(NullBox, 1);
+ RegionSubtract(borderVisible,
&pWin->borderClip, &pWin->winSize);
pWin->valdata->before.borderVisible = borderVisible;
}
@@ -1105,18 +1103,18 @@ xf86SetRootClip (ScreenPtr pScreen, Bool enable)
box.y1 = 0;
box.x2 = pScreen->width;
box.y2 = pScreen->height;
- REGION_INIT (pScreen, &pWin->winSize, &box, 1);
- REGION_INIT (pScreen, &pWin->borderSize, &box, 1);
+ RegionInit(&pWin->winSize, &box, 1);
+ RegionInit(&pWin->borderSize, &box, 1);
if (WasViewable)
- REGION_RESET(pScreen, &pWin->borderClip, &box);
+ RegionReset(&pWin->borderClip, &box);
pWin->drawable.width = pScreen->width;
pWin->drawable.height = pScreen->height;
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionBreak(&pWin->clipList);
}
else
{
- REGION_EMPTY(pScreen, &pWin->borderClip);
- REGION_BREAK (pWin->drawable.pScreen, &pWin->clipList);
+ RegionEmpty(&pWin->borderClip);
+ RegionBreak(&pWin->clipList);
}
ResizeChildrenWinSize (pWin, 0, 0, 0, 0);
@@ -1362,7 +1360,7 @@ xf86TokenToString(SymTabPtr table, int token)
if (table[i].token < 0)
return NULL;
else
- return(table[i].name);
+ return table[i].name;
}
int
@@ -1376,7 +1374,7 @@ xf86StringToToken(SymTabPtr table, const char *string)
for (i = 0; table[i].token >= 0 && xf86NameCmp(string, table[i].name); i++)
;
- return(table[i].token);
+ return table[i].token;
}
/*
@@ -1995,7 +1993,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
ScrnIndex, property, type, format, len, value);
if (ScrnIndex<0 || ScrnIndex>=xf86NumScreens) {
- return(BadMatch);
+ return BadMatch;
}
if (xf86RegisteredPropertiesTable &&
@@ -2009,7 +2007,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
if (!pNewProp) {
if ((pNewProp = (RootWinPropPtr)malloc(sizeof(RootWinProp))) == NULL) {
- return(BadAlloc);
+ return BadAlloc;
}
/*
* We will put this property at the end of the list so that
@@ -2017,8 +2015,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
*/
pNewProp->next = NULL;
} else {
- if (pNewProp->name)
- free(pNewProp->name);
+ free(pNewProp->name);
existing = TRUE;
}
@@ -2034,7 +2031,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
DebugF("creating xf86RegisteredPropertiesTable[] size %d\n",
xf86NumScreens);
if ( NULL==(xf86RegisteredPropertiesTable=(RootWinPropPtr*)xnfcalloc(sizeof(RootWinProp),xf86NumScreens) )) {
- return(BadAlloc);
+ return BadAlloc;
}
for (i=0; i<xf86NumScreens; i++) {
xf86RegisteredPropertiesTable[i] = NULL;
@@ -2059,7 +2056,7 @@ xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
}
}
DebugF("xf86RegisterRootWindowProperty succeeded\n");
- return(Success);
+ return Success;
}
Bool
diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c
index ed9aca67c..fd3281b83 100644
--- a/xorg-server/hw/xfree86/common/xf86Init.c
+++ b/xorg-server/hw/xfree86/common/xf86Init.c
@@ -66,6 +66,7 @@
#include "xf86Priv.h"
#include "xf86Config.h"
#include "xf86_OSlib.h"
+#include "xf86cmap.h"
#include "xorgVersion.h"
#include "xf86Build.h"
#include "mipointer.h"
@@ -202,8 +203,8 @@ xf86PrintBanner(void)
struct tm t;
char buf[100];
- bzero(&t, sizeof(t));
- bzero(buf, sizeof(buf));
+ memset(&t, 0, sizeof(t));
+ memset(buf, 0, sizeof(buf));
t.tm_mday = BUILD_DATE % 100;
t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
t.tm_year = BUILD_DATE / 10000 - 1900;
@@ -293,7 +294,7 @@ xf86CreateRootWindow(WindowPtr pWin)
}
DebugF("xf86CreateRootWindow() returns %d\n", ret);
- return (ret);
+ return ret;
}
@@ -734,6 +735,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
}
#endif /* SCO325 */
+ for (i = 0; i < xf86NumScreens; i++)
+ if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
+ FatalError("Cannot register DDX private keys");
+
+ if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0) ||
+ !dixRegisterPrivateKey(&xf86PixmapKeyRec, PRIVATE_PIXMAP, 0))
+ FatalError("Cannot register DDX private keys");
+
for (i = 0; i < xf86NumScreens; i++) {
xf86VGAarbiterLock(xf86Screens[i]);
/*
diff --git a/xorg-server/hw/xfree86/common/xf86Option.c b/xorg-server/hw/xfree86/common/xf86Option.c
index d1dcb0f94..5b20229a9 100644
--- a/xorg-server/hw/xfree86/common/xf86Option.c
+++ b/xorg-server/hw/xfree86/common/xf86Option.c
@@ -745,7 +745,7 @@ xf86IsOptionSet(const OptionInfoRec *table, int token)
OptionInfoPtr p;
p = xf86TokenToOptinfo(table, token);
- return (p && p->found);
+ return p && p->found;
}
diff --git a/xorg-server/hw/xfree86/common/xf86RandR.c b/xorg-server/hw/xfree86/common/xf86RandR.c
index 1893974e2..3bd15e059 100644
--- a/xorg-server/hw/xfree86/common/xf86RandR.c
+++ b/xorg-server/hw/xfree86/common/xf86RandR.c
@@ -46,7 +46,7 @@ typedef struct _xf86RandRInfo {
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
-static int xf86RandRKeyIndex;
+static DevPrivateKeyRec xf86RandRKeyRec;
static DevPrivateKey xf86RandRKey;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
@@ -159,7 +159,7 @@ xf86RandRSetMode (ScreenPtr pScreen,
int oldmmHeight = pScreen->mmHeight;
int oldVirtualX = scrp->virtualX;
int oldVirtualY = scrp->virtualY;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
Bool ret = TRUE;
if (pRoot && scrp->vtSema)
@@ -424,7 +424,10 @@ xf86RandRInit (ScreenPtr pScreen)
return TRUE;
#endif
- xf86RandRKey = &xf86RandRKeyIndex;
+ xf86RandRKey = &xf86RandRKeyRec;
+
+ if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
randrp = malloc(sizeof (XF86RandRInfoRec));
if (!randrp)
diff --git a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
index ac44c5e67..e5fd0fb85 100644
--- a/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
+++ b/xorg-server/hw/xfree86/common/xf86VGAarbiter.c
@@ -62,10 +62,10 @@ static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
};
-static int VGAarbiterKeyIndex;
-static DevPrivateKey VGAarbiterScreenKey = &VGAarbiterKeyIndex;
-static int VGAarbiterGCIndex;
-static DevPrivateKey VGAarbiterGCKey = &VGAarbiterGCIndex;
+static DevPrivateKeyRec VGAarbiterScreenKeyRec;
+#define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
+static DevPrivateKeyRec VGAarbiterGCKeyRec;
+#define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
static int vga_no_arb = 0;
void
@@ -175,9 +175,12 @@ xf86VGAarbiterWrapFunctions(void)
pScrn = xf86Screens[pScreen->myNum];
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
- if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec)))
+ if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
return FALSE;
+ if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
return FALSE;
diff --git a/xorg-server/hw/xfree86/common/xf86VidMode.c b/xorg-server/hw/xfree86/common/xf86VidMode.c
index 08f27b8e4..591c338b1 100644
--- a/xorg-server/hw/xfree86/common/xf86VidMode.c
+++ b/xorg-server/hw/xfree86/common/xf86VidMode.c
@@ -47,7 +47,7 @@
#include "vidmodeproc.h"
#include "xf86cmap.h"
-static int VidModeKeyIndex;
+static DevPrivateKeyRec VidModeKeyRec;
static DevPrivateKey VidModeKey;
static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen);
@@ -67,15 +67,17 @@ VidModeExtensionInit(ScreenPtr pScreen)
return FALSE;
}
- VidModeKey = &VidModeKeyIndex;
+ VidModeKey = &VidModeKeyRec;
- if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey,
- calloc(sizeof(VidModeRec), 1))) {
- DebugF("xcalloc failed\n");
+ if (!dixRegisterPrivateKey(&VidModeKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
- }
- pVidMode = VMPTR(pScreen);
+ pVidMode = calloc(sizeof(VidModeRec), 1);
+ if (!pVidMode)
+ return FALSE;
+
+ dixSetPrivate(&pScreen->devPrivates, VidModeKey, pVidMode);
+
pVidMode->Flags = 0;
pVidMode->Next = NULL;
pVidMode->CloseScreen = pScreen->CloseScreen;
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index 2d82ccdbc..845bde87a 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -80,6 +80,9 @@
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
+#ifdef HAVE_SYS_UTSNAME_H
+#include <sys/utsname.h>
+#endif
#include "extnsionst.h"
@@ -278,9 +281,9 @@ xf86SendDragEvents(DeviceIntPtr device)
LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
if (device->button && device->button->buttonsDown > 0)
- return (local->flags & XI86_SEND_DRAG_EVENTS);
+ return local->flags & XI86_SEND_DRAG_EVENTS;
else
- return (TRUE);
+ return TRUE;
}
/***********************************************************************
@@ -497,73 +500,152 @@ AddOtherInputDevices(void)
}
/*
- * Classes without any Match statements match all devices. Otherwise, all
- * statements must match.
+ * Get the operating system name from uname and store it statically to avoid
+ * repeating the system call each time MatchOS is checked.
*/
-static Bool
-InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
+static const char *
+HostOS(void)
{
- char **cur;
- Bool match;
-
- if (iclass->match_product) {
- if (!attrs->product)
- return FALSE;
- /* see if any of the values match */
- for (cur = iclass->match_product, match = FALSE; *cur; cur++)
- if (strstr(attrs->product, *cur)) {
- match = TRUE;
- break;
- }
- if (!match)
- return FALSE;
- }
- if (iclass->match_vendor) {
- if (!attrs->vendor)
- return FALSE;
- /* see if any of the values match */
- for (cur = iclass->match_vendor, match = FALSE; *cur; cur++)
- if (strstr(attrs->vendor, *cur)) {
- match = TRUE;
- break;
- }
- if (!match)
- return FALSE;
+#ifdef HAVE_SYS_UTSNAME_H
+ struct utsname name;
+ static char host_os[sizeof(name.sysname)] = "";
+
+ if (*host_os == '\0') {
+ if (uname(&name) >= 0)
+ strcpy(host_os, name.sysname);
+ else {
+ strncpy(host_os, "unknown", sizeof(host_os));
+ host_os[sizeof(host_os)-1] = '\0';
+ }
}
- if (iclass->match_device) {
- if (!attrs->device)
- return FALSE;
- /* see if any of the values match */
- for (cur = iclass->match_device, match = FALSE; *cur; cur++)
+ return host_os;
+#else
+ return "";
+#endif
+}
+
+static int
+match_substring(const char *attr, const char *pattern)
+{
+ return (strstr(attr, pattern)) ? 0 : -1;
+}
+
+#ifdef HAVE_FNMATCH_H
+static int
+match_pattern(const char *attr, const char *pattern)
+{
+ return fnmatch(pattern, attr, 0);
+}
+#else
+#define match_pattern match_substring
+#endif
+
#ifdef HAVE_FNMATCH_H
- if (fnmatch(*cur, attrs->device, FNM_PATHNAME) == 0) {
+static int
+match_path_pattern(const char *attr, const char *pattern)
+{
+ return fnmatch(pattern, attr, FNM_PATHNAME);
+}
#else
- if (strstr(attrs->device, *cur)) {
+#define match_path_pattern match_substring
#endif
+
+/*
+ * Match an attribute against a list of NULL terminated arrays of patterns.
+ * If a pattern in each list entry is matched, return TRUE.
+ */
+static Bool
+MatchAttrToken(const char *attr, struct list *patterns,
+ int (*compare)(const char *attr, const char *pattern))
+{
+ const xf86MatchGroup *group;
+
+ /* If there are no patterns, accept the match */
+ if (list_is_empty(patterns))
+ return TRUE;
+
+ /* If there are patterns but no attribute, reject the match */
+ if (!attr)
+ return FALSE;
+
+ /*
+ * Otherwise, iterate the list of patterns ensuring each entry has a
+ * match. Each list entry is a separate Match line of the same type.
+ */
+ list_for_each_entry(group, patterns, entry) {
+ char * const *cur;
+ Bool match = FALSE;
+
+ for (cur = group->values; *cur; cur++)
+ if ((*compare)(attr, *cur) == 0) {
match = TRUE;
break;
}
if (!match)
return FALSE;
}
- if (iclass->match_tag) {
+
+ /* All the entries in the list matched the attribute */
+ return TRUE;
+}
+
+/*
+ * Classes without any Match statements match all devices. Otherwise, all
+ * statements must match.
+ */
+static Bool
+InputClassMatches(const XF86ConfInputClassPtr iclass, const IDevPtr idev,
+ const InputAttributes *attrs)
+{
+ /* MatchProduct substring */
+ if (!MatchAttrToken(attrs->product, &iclass->match_product, match_substring))
+ return FALSE;
+
+ /* MatchVendor substring */
+ if (!MatchAttrToken(attrs->vendor, &iclass->match_vendor, match_substring))
+ return FALSE;
+
+ /* MatchDevicePath pattern */
+ if (!MatchAttrToken(attrs->device, &iclass->match_device, match_path_pattern))
+ return FALSE;
+
+ /* MatchOS case-insensitive string */
+ if (!MatchAttrToken(HostOS(), &iclass->match_os, strcasecmp))
+ return FALSE;
+
+ /* MatchPnPID pattern */
+ if (!MatchAttrToken(attrs->pnp_id, &iclass->match_pnpid, match_pattern))
+ return FALSE;
+
+ /* MatchUSBID pattern */
+ if (!MatchAttrToken(attrs->usb_id, &iclass->match_usbid, match_pattern))
+ return FALSE;
+
+ /* MatchDriver string */
+ if (!MatchAttrToken(idev->driver, &iclass->match_driver, strcmp))
+ return FALSE;
+
+ /*
+ * MatchTag string
+ * See if any of the device's tags match any of the MatchTag tokens.
+ */
+ if (!list_is_empty(&iclass->match_tag)) {
+ char * const *tag;
+ Bool match;
+
if (!attrs->tags)
return FALSE;
-
- for (cur = iclass->match_tag, match = FALSE; *cur && !match; cur++) {
- char * const *tag;
- for(tag = attrs->tags; *tag; tag++) {
- if (!strcmp(*tag, *cur)) {
- match = TRUE;
- break;
- }
+ for (tag = attrs->tags, match = FALSE; *tag; tag++) {
+ if (MatchAttrToken(*tag, &iclass->match_tag, strcmp)) {
+ match = TRUE;
+ break;
}
}
-
if (!match)
return FALSE;
}
+ /* MatchIs* booleans */
if (iclass->is_keyboard.set &&
iclass->is_keyboard.val != !!(attrs->flags & ATTR_KEYBOARD))
return FALSE;
@@ -582,6 +664,7 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
if (iclass->is_touchscreen.set &&
iclass->is_touchscreen.val != !!(attrs->flags & ATTR_TOUCHSCREEN))
return FALSE;
+
return TRUE;
}
@@ -591,37 +674,36 @@ InputClassMatches(XF86ConfInputClassPtr iclass, InputAttributes *attrs)
* well as any previous InputClass sections.
*/
static int
-MergeInputClasses(IDevPtr idev, InputAttributes *attrs)
+MergeInputClasses(const IDevPtr idev, const InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
- XF86OptionPtr classopts, mergedopts = NULL;
- char *classdriver = NULL;
+ XF86OptionPtr classopts;
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
- if (!InputClassMatches(cl, attrs))
+ if (!InputClassMatches(cl, idev, attrs))
continue;
- /* Collect class options and merge over previous classes */
+ /* Collect class options and driver settings */
+ classopts = xf86optionListDup(cl->option_lst);
+ if (cl->driver) {
+ free(idev->driver);
+ idev->driver = xstrdup(cl->driver);
+ if (!idev->driver) {
+ xf86Msg(X_ERROR, "Failed to allocate memory while merging "
+ "InputClass configuration");
+ return BadAlloc;
+ }
+ classopts = xf86ReplaceStrOption(classopts, "driver",
+ idev->driver);
+ }
+
+ /* Apply options to device with InputClass settings preferred. */
xf86Msg(X_CONFIG, "%s: Applying InputClass \"%s\"\n",
idev->identifier, cl->identifier);
- if (cl->driver)
- classdriver = cl->driver;
- classopts = xf86optionListDup(cl->option_lst);
- mergedopts = xf86optionListMerge(mergedopts, classopts);
+ idev->commonOptions = xf86optionListMerge(idev->commonOptions,
+ classopts);
}
- /* Apply options to device with InputClass settings preferred. */
- if (classdriver) {
- free(idev->driver);
- idev->driver = xstrdup(classdriver);
- if (!idev->driver) {
- xf86Msg(X_ERROR, "Failed to allocate memory while merging "
- "InputClass configuration");
- return BadAlloc;
- }
- mergedopts = xf86ReplaceStrOption(mergedopts, "driver", idev->driver);
- }
- idev->commonOptions = xf86optionListMerge(idev->commonOptions, mergedopts);
return Success;
}
@@ -630,14 +712,14 @@ MergeInputClasses(IDevPtr idev, InputAttributes *attrs)
* value of the last matching class and holler when returning TRUE.
*/
static Bool
-IgnoreInputClass(IDevPtr idev, InputAttributes *attrs)
+IgnoreInputClass(const IDevPtr idev, const InputAttributes *attrs)
{
XF86ConfInputClassPtr cl;
Bool ignore = FALSE;
const char *ignore_class;
for (cl = xf86configptr->conf_inputclass_lst; cl; cl = cl->list.next) {
- if (!InputClassMatches(cl, attrs))
+ if (!InputClassMatches(cl, idev, attrs))
continue;
if (xf86findOption(cl->option_lst, "Ignore")) {
ignore = xf86CheckBoolOption(cl->option_lst, "Ignore", FALSE);
@@ -844,10 +926,8 @@ NewInputDeviceRequest (InputOption *options, InputAttributes *attrs,
unwind:
if (is_auto && !xf86Info.autoAddDevices)
xf86Msg(X_INFO, "AutoAddDevices is off - not adding device.\n");
- if(idev->driver)
- free(idev->driver);
- if(idev->identifier)
- free(idev->identifier);
+ free(idev->driver);
+ free(idev->identifier);
xf86optionListFree(idev->commonOptions);
free(idev);
return rval;
@@ -1195,7 +1275,7 @@ xf86ScaleAxis(int Cx,
if (X < Sxlow)
X = Sxlow;
- return (X);
+ return X;
}
/*
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c
index fa0ebc8eb..851843faa 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.c
+++ b/xorg-server/hw/xfree86/common/xf86cmap.c
@@ -102,10 +102,11 @@ typedef struct {
int overscan;
} CMapColormapRec, *CMapColormapPtr;
-static int CMapScreenKeyIndex;
-static DevPrivateKey CMapScreenKey;
-static int CMapColormapKeyIndex;
-static DevPrivateKey CMapColormapKey = &CMapColormapKeyIndex;
+static DevPrivateKeyRec CMapScreenKeyRec;
+#define CMapScreenKeyRegistered dixPrivateKeyRegistered(&CMapScreenKeyRec)
+#define CMapScreenKey (&CMapScreenKeyRec)
+static DevPrivateKeyRec CMapColormapKeyRec;
+#define CMapColormapKey (&CMapColormapKeyRec)
static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@@ -128,6 +129,18 @@ static void CMapReinstallMap(ColormapPtr);
static void CMapUnwrapScreen(ScreenPtr pScreen);
+Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
+{
+ /* If we support a better colormap system, then pretend we succeeded. */
+ if (xf86_crtc_supports_gamma(pScrn))
+ return TRUE;
+ if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&CMapColormapKeyRec, PRIVATE_COLORMAP, 0))
+ return FALSE;
+ return TRUE;
+}
Bool xf86HandleColormaps(
ScreenPtr pScreen,
@@ -151,8 +164,6 @@ Bool xf86HandleColormaps(
if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE;
- CMapScreenKey = &CMapScreenKeyIndex;
-
elements = 1 << sigRGBbits;
if(!(gamma = malloc(elements * sizeof(LOCO))))
@@ -169,7 +180,7 @@ Bool xf86HandleColormaps(
return FALSE;
}
- dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
+ dixSetPrivate(&pScreen->devPrivates, &CMapScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap;
@@ -316,7 +327,7 @@ CMapDestroyColormap (ColormapPtr cmap)
CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if(pColPriv) {
- if(pColPriv->colors) free(pColPriv->colors);
+ free(pColPriv->colors);
free(pColPriv);
}
@@ -900,7 +911,7 @@ CMapChangeGamma(
CMapLinkPtr pLink;
/* Is this sufficient checking ? */
- if(CMapScreenKey == NULL)
+ if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@@ -1012,7 +1023,7 @@ xf86ChangeGammaRamp(
}
}
- if(CMapScreenKey == NULL)
+ if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@@ -1080,7 +1091,7 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
return crtc->gammaSize;
}
- if(CMapScreenKey == NULL) return 0;
+ if(!CMapScreenKeyRegistered) return 0;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
CMapScreenKey);
@@ -1120,7 +1131,7 @@ xf86GetGammaRamp(
}
}
- if(CMapScreenKey == NULL)
+ if(!CMapScreenKeyRegistered)
return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.h b/xorg-server/hw/xfree86/common/xf86cmap.h
index f15844e59..caa01e8ed 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.h
+++ b/xorg-server/hw/xfree86/common/xf86cmap.h
@@ -1,75 +1,79 @@
-
-/*
- * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifndef _XF86CMAP_H
-#define _XF86CMAP_H
-
-#include "xf86str.h"
-#include "colormapst.h"
-
-#define CMAP_PALETTED_TRUECOLOR 0x0000001
-#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002
-#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004
-
-extern _X_EXPORT Bool xf86HandleColormaps(
- ScreenPtr pScreen,
- int maxCol,
- int sigRGBbits,
- xf86LoadPaletteProc *loadPalette,
- xf86SetOverscanProc *setOverscan,
- unsigned int flags
-);
-
-extern _X_EXPORT int
-xf86ChangeGamma(
- ScreenPtr pScreen,
- Gamma newGamma
-);
-
-extern _X_EXPORT int
-xf86ChangeGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-);
-
-extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen);
-
-extern _X_EXPORT int
-xf86GetGammaRamp(
- ScreenPtr pScreen,
- int size,
- unsigned short *red,
- unsigned short *green,
- unsigned short *blue
-);
-
-#endif /* _XF86CMAP_H */
-
+
+/*
+ * Copyright (c) 1998-2001 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+#ifndef _XF86CMAP_H
+#define _XF86CMAP_H
+
+#include "xf86str.h"
+#include "colormapst.h"
+
+#define CMAP_PALETTED_TRUECOLOR 0x0000001
+#define CMAP_RELOAD_ON_MODE_SWITCH 0x0000002
+#define CMAP_LOAD_EVEN_IF_OFFSCREEN 0x0000004
+
+extern _X_EXPORT Bool xf86HandleColormaps(
+ ScreenPtr pScreen,
+ int maxCol,
+ int sigRGBbits,
+ xf86LoadPaletteProc *loadPalette,
+ xf86SetOverscanProc *setOverscan,
+ unsigned int flags
+);
+
+extern _X_EXPORT Bool xf86ColormapAllocatePrivates(
+ ScrnInfoPtr pScrn
+);
+
+extern _X_EXPORT int
+xf86ChangeGamma(
+ ScreenPtr pScreen,
+ Gamma newGamma
+);
+
+extern _X_EXPORT int
+xf86ChangeGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+);
+
+extern _X_EXPORT int xf86GetGammaRampSize(ScreenPtr pScreen);
+
+extern _X_EXPORT int
+xf86GetGammaRamp(
+ ScreenPtr pScreen,
+ int size,
+ unsigned short *red,
+ unsigned short *green,
+ unsigned short *blue
+);
+
+#endif /* _XF86CMAP_H */
+
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c
index 1ca27015f..ccb761a2c 100644
--- a/xorg-server/hw/xfree86/common/xf86fbman.c
+++ b/xorg-server/hw/xfree86/common/xf86fbman.c
@@ -42,7 +42,7 @@
#define DEBUG
*/
-static int xf86FBManagerKeyIndex;
+static DevPrivateKeyRec xf86FBManagerKeyRec;
static DevPrivateKey xf86FBManagerKey;
Bool xf86RegisterOffscreenManager(
@@ -50,7 +50,11 @@ Bool xf86RegisterOffscreenManager(
FBManagerFuncsPtr funcs
){
- xf86FBManagerKey = &xf86FBManagerKeyIndex;
+ xf86FBManagerKey = &xf86FBManagerKeyRec;
+
+ if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE;
@@ -60,8 +64,9 @@ Bool xf86RegisterOffscreenManager(
Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
- if(xf86FBManagerKey == NULL)
+ if (xf86FBManagerKey == NULL)
return FALSE;
+
if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE;
@@ -270,8 +275,8 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
\************************************************************/
-static int xf86FBScreenKeyIndex;
-static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKeyIndex;
+static DevPrivateKeyRec xf86FBScreenKeyRec;
+#define xf86FBScreenKey (&xf86FBScreenKeyRec)
typedef struct _FBLink {
FBArea area;
@@ -363,8 +368,8 @@ AllocateArea(
if(granularity <= 1) granularity = 0;
- boxp = REGION_RECTS(offman->FreeBoxes);
- num = REGION_NUM_RECTS(offman->FreeBoxes);
+ boxp = RegionRects(offman->FreeBoxes);
+ num = RegionNumRects(offman->FreeBoxes);
/* look through the free boxes */
for(i = 0; i < num; i++, boxp++) {
@@ -407,9 +412,9 @@ AllocateArea(
/* bye, bye */
(*link->area.RemoveAreaCallback)(&link->area);
- REGION_INIT(pScreen, &NewReg, &(link->area.box), 1);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
- REGION_UNINIT(pScreen, &NewReg);
+ RegionInit(&NewReg, &(link->area.box), 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ RegionUninit(&NewReg);
area = &(link->area);
break;
@@ -427,9 +432,9 @@ AllocateArea(
area->RemoveAreaCallback = removeCB;
area->devPrivate.ptr = privData;
- REGION_INIT(pScreen, &NewReg, &(area->box), 1);
- REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &NewReg);
- REGION_UNINIT(pScreen, &NewReg);
+ RegionInit(&NewReg, &(area->box), 1);
+ RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &NewReg);
+ RegionUninit(&NewReg);
}
return area;
@@ -477,9 +482,9 @@ localFreeOffscreenArea(FBAreaPtr area)
}
/* put the area back into the pool */
- REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
- REGION_UNINIT(pScreen, &FreedRegion);
+ RegionInit(&FreedRegion, &(pLink->area.box), 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedRegion);
+ RegionUninit(&FreedRegion);
if(pLinkPrev)
pLinkPrev->next = pLink->next;
@@ -536,12 +541,12 @@ localResizeOffscreenArea(
(resize->box.x2 == OrigArea.x2))
return TRUE;
- REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
- REGION_INIT(pScreen, &NewReg, &(resize->box), 1);
- REGION_SUBTRACT(pScreen, &FreedReg, &FreedReg, &NewReg);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
- REGION_UNINIT(pScreen, &FreedReg);
- REGION_UNINIT(pScreen, &NewReg);
+ RegionInit(&FreedReg, &OrigArea, 1);
+ RegionInit(&NewReg, &(resize->box), 1);
+ RegionSubtract(&FreedReg, &FreedReg, &NewReg);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionUninit(&FreedReg);
+ RegionUninit(&NewReg);
SendCallFreeBoxCallbacks(offman);
@@ -551,8 +556,8 @@ localResizeOffscreenArea(
/* otherwise we remove the old region */
- REGION_INIT(pScreen, &FreedReg, &OrigArea, 1);
- REGION_UNION(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionInit(&FreedReg, &OrigArea, 1);
+ RegionUnion(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
/* remove the old link */
if(pLinkPrev)
@@ -589,8 +594,8 @@ localResizeOffscreenArea(
offman->NumUsedAreas--;
} else {
/* reinstate the old region */
- REGION_SUBTRACT(pScreen, offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
- REGION_UNINIT(pScreen, &FreedReg);
+ RegionSubtract(offman->FreeBoxes, offman->FreeBoxes, &FreedReg);
+ RegionUninit(&FreedReg);
pLink->next = offman->UsedAreas;
offman->UsedAreas = pLink;
@@ -598,7 +603,7 @@ localResizeOffscreenArea(
}
- REGION_UNINIT(pScreen, &FreedReg);
+ RegionUninit(&FreedReg);
SendCallFreeBoxCallbacks(offman);
@@ -636,47 +641,47 @@ localQueryLargestOffscreenArea(
if(offman->NumUsedAreas) {
FBLinkPtr pLink;
RegionRec tmpRegion;
- newRegion = REGION_CREATE(pScreen, NULL, 1);
- REGION_COPY(pScreen, newRegion, offman->InitialBoxes);
+ newRegion = RegionCreate(NULL, 1);
+ RegionCopy(newRegion, offman->InitialBoxes);
pLink = offman->UsedAreas;
while(pLink) {
if(!pLink->area.RemoveAreaCallback) {
- REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
- REGION_SUBTRACT(pScreen, newRegion, newRegion, &tmpRegion);
- REGION_UNINIT(pScreen, &tmpRegion);
+ RegionInit(&tmpRegion, &(pLink->area.box), 1);
+ RegionSubtract(newRegion, newRegion, &tmpRegion);
+ RegionUninit(&tmpRegion);
}
pLink = pLink->next;
}
- nbox = REGION_NUM_RECTS(newRegion);
- pbox = REGION_RECTS(newRegion);
+ nbox = RegionNumRects(newRegion);
+ pbox = RegionRects(newRegion);
break;
}
case 1:
if(offman->NumUsedAreas) {
FBLinkPtr pLink;
RegionRec tmpRegion;
- newRegion = REGION_CREATE(pScreen, NULL, 1);
- REGION_COPY(pScreen, newRegion, offman->FreeBoxes);
+ newRegion = RegionCreate(NULL, 1);
+ RegionCopy(newRegion, offman->FreeBoxes);
pLink = offman->UsedAreas;
while(pLink) {
if(pLink->area.RemoveAreaCallback) {
- REGION_INIT(pScreen, &tmpRegion, &(pLink->area.box), 1);
- REGION_APPEND(pScreen, newRegion, &tmpRegion);
- REGION_UNINIT(pScreen, &tmpRegion);
+ RegionInit(&tmpRegion, &(pLink->area.box), 1);
+ RegionAppend(newRegion, &tmpRegion);
+ RegionUninit(&tmpRegion);
}
pLink = pLink->next;
}
- nbox = REGION_NUM_RECTS(newRegion);
- pbox = REGION_RECTS(newRegion);
+ nbox = RegionNumRects(newRegion);
+ pbox = RegionRects(newRegion);
break;
}
default:
- nbox = REGION_NUM_RECTS(offman->FreeBoxes);
- pbox = REGION_RECTS(offman->FreeBoxes);
+ nbox = RegionNumRects(offman->FreeBoxes);
+ pbox = RegionRects(offman->FreeBoxes);
break;
}
@@ -719,7 +724,7 @@ localQueryLargestOffscreenArea(
}
if(newRegion)
- REGION_DESTROY(pScreen, newRegion);
+ RegionDestroy(newRegion);
return TRUE;
}
@@ -741,9 +746,9 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
if(pLink->area.RemoveAreaCallback) {
(*pLink->area.RemoveAreaCallback)(&pLink->area);
- REGION_INIT(pScreen, &FreedRegion, &(pLink->area.box), 1);
- REGION_APPEND(pScreen, offman->FreeBoxes, &FreedRegion);
- REGION_UNINIT(pScreen, &FreedRegion);
+ RegionInit(&FreedRegion, &(pLink->area.box), 1);
+ RegionAppend(offman->FreeBoxes, &FreedRegion);
+ RegionUninit(&FreedRegion);
if(pPrev)
pPrev->next = pLink->next;
@@ -761,7 +766,7 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
}
if(anyUsed) {
- REGION_VALIDATE(pScreen, offman->FreeBoxes, &anyUsed);
+ RegionValidate(offman->FreeBoxes, &anyUsed);
SendCallFreeBoxCallbacks(offman);
}
@@ -924,7 +929,7 @@ localAllocateOffscreenLinear(
return NULL;
/* No linear available, so try and pinch some from the XY areas */
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
if (gran > 1) {
@@ -1055,7 +1060,7 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length)
BoxPtr extents;
int pitch, w, h;
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
pitch = extents->x2 - extents->x1;
if(length < pitch) { /* special case */
@@ -1121,7 +1126,7 @@ localQueryLargestOffscreenLinear(
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
if((extents->x2 - extents->x1) == w)
*size = w * h;
return TRUE;
@@ -1171,8 +1176,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
free(tmp2);
}
- REGION_DESTROY(pScreen, offman->InitialBoxes);
- REGION_DESTROY(pScreen, offman->FreeBoxes);
+ RegionDestroy(offman->InitialBoxes);
+ RegionDestroy(offman->FreeBoxes);
free(offman->FreeBoxesUpdateCallback);
free(offman->devPrivates);
@@ -1206,15 +1211,15 @@ xf86InitFBManager(
if (FullBox->y2 < FullBox->y1) return FALSE;
if (FullBox->x2 < FullBox->x1) return FALSE;
- REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
- REGION_INIT(pScreen, &FullRegion, FullBox, 1);
+ RegionInit(&ScreenRegion, &ScreenBox, 1);
+ RegionInit(&FullRegion, FullBox, 1);
- REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);
+ RegionSubtract(&FullRegion, &FullRegion, &ScreenRegion);
ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
- REGION_UNINIT(pScreen, &ScreenRegion);
- REGION_UNINIT(pScreen, &FullRegion);
+ RegionUninit(&ScreenRegion);
+ RegionUninit(&FullRegion);
return ret;
}
@@ -1249,17 +1254,17 @@ xf86InitFBManagerArea(
}
/* Factor out virtual resolution */
- pRegion = RECTS_TO_REGION(pScreen, nRect, Rect, 0);
+ pRegion = RegionFromRects(nRect, Rect, 0);
if (pRegion) {
- if (!REGION_NAR(pRegion)) {
+ if (!RegionNar(pRegion)) {
Rect[2].x = Rect[2].y = 0;
Rect[2].width = pScrn->virtualX;
Rect[2].height = pScrn->virtualY;
- pScreenRegion = RECTS_TO_REGION(pScreen, 1, &Rect[2], 0);
+ pScreenRegion = RegionFromRects(1, &Rect[2], 0);
if (pScreenRegion) {
- if (!REGION_NAR(pScreenRegion)) {
- REGION_SUBTRACT(pScreen, pRegion, pRegion, pScreenRegion);
+ if (!RegionNar(pScreenRegion)) {
+ RegionSubtract(pRegion, pRegion, pScreenRegion);
ret = xf86InitFBManagerRegion(pScreen, pRegion);
@@ -1301,11 +1306,11 @@ xf86InitFBManagerArea(
}
}
- REGION_DESTROY(pScreen, pScreenRegion);
+ RegionDestroy(pScreenRegion);
}
}
- REGION_DESTROY(pScreen, pRegion);
+ RegionDestroy(pRegion);
}
return ret;
@@ -1318,9 +1323,12 @@ xf86InitFBManagerRegion(
){
FBManagerPtr offman;
- if(REGION_NIL(FullRegion))
+ if(RegionNil(FullRegion))
return FALSE;
+ if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE;
@@ -1332,11 +1340,11 @@ xf86InitFBManagerRegion(
offman->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86FBCloseScreen;
- offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1);
- offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1);
+ offman->InitialBoxes = RegionCreate(NULL, 1);
+ offman->FreeBoxes = RegionCreate(NULL, 1);
- REGION_COPY(pScreen, offman->InitialBoxes, FullRegion);
- REGION_COPY(pScreen, offman->FreeBoxes, FullRegion);
+ RegionCopy(offman->InitialBoxes, FullRegion);
+ RegionCopy(offman->FreeBoxes, FullRegion);
offman->pScreen = pScreen;
offman->UsedAreas = NULL;
@@ -1415,7 +1423,7 @@ xf86AllocateLinearOffscreenArea (
offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
- extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
+ extents = RegionExtents(offman->InitialBoxes);
w = extents->x2 - extents->x1;
if (gran > 1) {
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c
index 8d968dc39..461c7c235 100644
--- a/xorg-server/hw/xfree86/common/xf86pciBus.c
+++ b/xorg-server/hw/xfree86/common/xf86pciBus.c
@@ -465,7 +465,7 @@ xf86PciAddMatchingDev(DriverPtr drvp)
pci_iterator_destroy(iter);
- return (numFound != 0);
+ return numFound != 0;
}
Bool
@@ -1294,7 +1294,11 @@ matchDriverFromFiles (char** matches, uint16_t match_vendor, uint16_t match_chip
}
#endif /* __linux__ */
-void
+/**
+ * @return The numbers of found devices that match with the current system
+ * drivers.
+ */
+int
xf86PciMatchDriver(char* matches[], int nmatches) {
int i;
struct pci_device * info = NULL;
@@ -1326,4 +1330,6 @@ xf86PciMatchDriver(char* matches[], int nmatches) {
if ((info != NULL) && (i < nmatches)) {
i += videoPtrToDriverList(info, &(matches[i]), nmatches - i);
}
+
+ return i;
}
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.h b/xorg-server/hw/xfree86/common/xf86pciBus.h
index c8a2eebdd..bcbb8b822 100644
--- a/xorg-server/hw/xfree86/common/xf86pciBus.h
+++ b/xorg-server/hw/xfree86/common/xf86pciBus.h
@@ -37,6 +37,6 @@ void xf86PciProbe(void);
Bool xf86PciAddMatchingDev(DriverPtr drvp);
Bool xf86PciProbeDev(DriverPtr drvp);
void xf86PciIsolateDevice(char *argument);
-void xf86PciMatchDriver(char* matches[], int nmatches);
+int xf86PciMatchDriver(char* matches[], int nmatches);
#endif /* _XF86_PCI_BUS_H */
diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c
index 8df3a6c7a..51e7894db 100644
--- a/xorg-server/hw/xfree86/common/xf86sbusBus.c
+++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c
@@ -478,8 +478,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
instances[i].claimed = TRUE;
instances[i].dev = dev;
}
- if (promPath)
- free(promPath);
+ free(promPath);
}
DebugF("%s instances found: %d\n", driverName, numClaimedInstances);
@@ -531,7 +530,7 @@ xf86GetSbusInfoForEntity(int entityIndex)
for (psdpp = xf86SbusInfo; *psdpp != NULL; psdpp++) {
if (p->bus.id.sbus.fbNum == (*psdpp)->fbNum)
- return (*psdpp);
+ return *psdpp;
}
return NULL;
}
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index e35b8d667..6dae62717 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -110,10 +110,11 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags);
static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-static int XF86XVWindowKeyIndex;
-static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKeyIndex;
-static int XF86XvScreenKeyIndex;
-DevPrivateKey XF86XvScreenKey = &XF86XvScreenKeyIndex;
+static DevPrivateKeyRec XF86XVWindowKeyRec;
+#define XF86XVWindowKey (&XF86XVWindowKeyRec)
+
+DevPrivateKey XF86XvScreenKey;
+
static unsigned long PortResource = 0;
DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
@@ -186,8 +187,8 @@ typedef struct {
int num;
} OffscreenImageRec;
-static int OffscreenPrivateKeyIndex;
-static DevPrivateKey OffscreenPrivateKey = &OffscreenPrivateKeyIndex;
+static DevPrivateKeyRec OffscreenPrivateKeyRec;
+#define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
Bool
@@ -198,9 +199,9 @@ xf86XVRegisterOffscreenImages(
){
OffscreenImageRec *OffscreenImage;
/* This function may be called before xf86XVScreenInit, so there's
- * no better place than this to call dixRequestPrivate to ensure we
+ * no better place than this to call dixRegisterPrivateKey to ensure we
* have space reserved. After the first call it is a no-op. */
- if(!dixRequestPrivate(OffscreenPrivateKey, sizeof(OffscreenImageRec)) ||
+ if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
!(OffscreenImage = GetOffscreenImage(pScreen)))
/* Every X.org driver assumes this function always succeeds, so
* just die on allocation failure. */
@@ -251,7 +252,11 @@ xf86XVScreenInit(
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
XF86XvScreenKey = (*XvGetScreenKeyProc)();
+
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -322,9 +327,9 @@ xf86XVFreeAdaptor(XvAdaptorPtr pAdaptor)
pPriv = (XvPortRecPrivatePtr)pPort->devPriv.ptr;
if(pPriv) {
if(pPriv->clientClip)
- REGION_DESTROY(pAdaptor->pScreen, pPriv->clientClip);
+ RegionDestroy(pPriv->clientClip);
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pAdaptor->pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
free(pPriv);
}
}
@@ -636,14 +641,12 @@ xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
{
RegionPtr pregWin, pCompositeClip;
WindowPtr pWin;
- ScreenPtr pScreen;
Bool freeCompClip = FALSE;
if(portPriv->pCompositeClip)
return;
pWin = (WindowPtr)portPriv->pDraw;
- pScreen = pWin->drawable.pScreen;
/* get window clip list */
if(portPriv->subWindowMode == IncludeInferiors) {
@@ -658,18 +661,18 @@ xf86XVUpdateCompositeClip(XvPortRecPrivatePtr portPriv)
return;
}
- pCompositeClip = REGION_CREATE(pScreen, NullBox, 1);
- REGION_COPY(pScreen, pCompositeClip, portPriv->clientClip);
- REGION_TRANSLATE(pScreen, pCompositeClip,
+ pCompositeClip = RegionCreate(NullBox, 1);
+ RegionCopy(pCompositeClip, portPriv->clientClip);
+ RegionTranslate(pCompositeClip,
portPriv->pDraw->x + portPriv->clipOrg.x,
portPriv->pDraw->y + portPriv->clipOrg.y);
- REGION_INTERSECT(pScreen, pCompositeClip, pregWin, pCompositeClip);
+ RegionIntersect(pCompositeClip, pregWin, pCompositeClip);
portPriv->pCompositeClip = pCompositeClip;
portPriv->FreeCompositeClip = TRUE;
if(freeCompClip) {
- REGION_DESTROY(pScreen, pregWin);
+ RegionDestroy(pregWin);
}
}
@@ -684,17 +687,17 @@ xf86XVCopyClip(
/* copy the new clip if it exists */
if((pGC->clientClipType == CT_REGION) && pGC->clientClip) {
if(!portPriv->clientClip)
- portPriv->clientClip = REGION_CREATE(pScreen, NullBox, 1);
+ portPriv->clientClip = RegionCreate(NullBox, 1);
/* Note: this is in window coordinates */
- REGION_COPY(pScreen, portPriv->clientClip, pGC->clientClip);
+ RegionCopy(portPriv->clientClip, pGC->clientClip);
} else if(portPriv->clientClip) { /* free the old clientClip */
- REGION_DESTROY(pScreen, portPriv->clientClip);
+ RegionDestroy(portPriv->clientClip);
portPriv->clientClip = NULL;
}
/* get rid of the old clip list */
if(portPriv->pCompositeClip && portPriv->FreeCompositeClip) {
- REGION_DESTROY(pScreen, portPriv->pCompositeClip);
+ RegionDestroy(portPriv->pCompositeClip);
}
portPriv->clipOrg = pGC->clipOrg;
@@ -709,11 +712,9 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- ScreenPtr pScreen;
int ret = Success;
Bool clippedAway = FALSE;
- pScreen = portPriv->pDraw->pScreen;
xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
@@ -723,18 +724,18 @@ xf86XVRegetVideo(XvPortRecPrivatePtr portPriv)
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetVideo)(portPriv->pScrn,
@@ -760,8 +761,8 @@ CLIP_VIDEO_BAILOUT:
if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -773,12 +774,9 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- ScreenPtr pScreen;
int ret = Success;
Bool clippedAway = FALSE;
- pScreen = portPriv->pDraw->pScreen;
-
xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
@@ -788,9 +786,9 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -802,21 +800,21 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -826,7 +824,7 @@ xf86XVReputVideo(XvPortRecPrivatePtr portPriv)
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutVideo)(portPriv->pScrn,
@@ -851,8 +849,8 @@ CLIP_VIDEO_BAILOUT:
if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -863,12 +861,9 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
- ScreenPtr pScreen;
int ret = Success;
Bool clippedAway = FALSE;
- pScreen = portPriv->pDraw->pScreen;
-
xf86XVUpdateCompositeClip(portPriv);
/* translate the video region to the screen */
@@ -878,9 +873,9 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
WinBox.y2 = WinBox.y1 + portPriv->drw_h;
/* clip to the window composite clip */
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, portPriv->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, portPriv->pCompositeClip);
/* clip and translate to the viewport */
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
@@ -892,21 +887,21 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* that's all if it's totally obscured */
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto CLIP_VIDEO_BAILOUT;
}
/* bailout if we have to clip but the hardware doesn't support it */
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -916,7 +911,7 @@ xf86XVReputImage(XvPortRecPrivatePtr portPriv)
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->ReputImage)(portPriv->pScrn,
@@ -938,8 +933,8 @@ CLIP_VIDEO_BAILOUT:
if(!portPriv->FreeCompositeClip)
portPriv->pCompositeClip = NULL;
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1060,7 +1055,7 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
XvPortRecPrivatePtr pPriv;
Bool AreasExposed;
- AreasExposed = (WinPriv && reg1 && REGION_NOTEMPTY(pScreen, reg1));
+ AreasExposed = (WinPriv && reg1 && RegionNotEmpty(reg1));
pScreen->WindowExposures = ScreenPriv->WindowExposures;
(*pScreen->WindowExposures)(pWin, reg1, reg2);
@@ -1131,7 +1126,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
if(!pPriv) goto next;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1225,7 +1220,7 @@ xf86XVQueryAdaptors(
*p_nAdaptors = pxvs->nAdaptors;
*p_pAdaptors = pxvs->pAdaptors;
- return (Success);
+ return Success;
}
@@ -1268,7 +1263,7 @@ xf86XVLeaveVT(int index, int flags)
pPriv->isOn = XV_OFF;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1309,7 +1304,7 @@ xf86XVAdjustFrame(int index, int x, int y, int flags)
if(!pPriv->type && (pPriv->isOn != XV_OFF)) { /* overlaid still/image */
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
- REGION_DESTROY(pScreen, pPriv->pCompositeClip);
+ RegionDestroy(pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
@@ -1413,7 +1408,6 @@ xf86XVPutStill(
CARD16 drw_w, CARD16 drw_h
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
@@ -1425,16 +1419,14 @@ xf86XVPutStill(
if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
- pScreen = pDraw->pScreen;
-
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1445,23 +1437,23 @@ xf86XVPutStill(
VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
if(portPriv->pDraw) {
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -1471,7 +1463,7 @@ xf86XVPutStill(
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutStill)(portPriv->pScrn,
@@ -1500,8 +1492,8 @@ PUT_STILL_BAILOUT:
portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1565,7 +1557,6 @@ xf86XVGetStill(
CARD16 drw_w, CARD16 drw_h
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
@@ -1577,28 +1568,26 @@ xf86XVGetStill(
if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
- pScreen = pDraw->pScreen;
-
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->pDraw) {
xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
}
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto GET_STILL_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->GetStill)(portPriv->pScrn,
@@ -1615,8 +1604,8 @@ GET_STILL_BAILOUT:
portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1713,7 +1702,6 @@ xf86XVPutImage(
CARD16 width, CARD16 height
){
XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr)(pPort->devPriv.ptr);
- ScreenPtr pScreen;
RegionRec WinRegion;
RegionRec ClipRegion;
BoxRec WinBox;
@@ -1725,16 +1713,14 @@ xf86XVPutImage(
if(!portPriv->pScrn->vtSema) return Success; /* Success ? */
- pScreen = pDraw->pScreen;
-
WinBox.x1 = pDraw->x + drw_x;
WinBox.y1 = pDraw->y + drw_y;
WinBox.x2 = WinBox.x1 + drw_w;
WinBox.y2 = WinBox.y1 + drw_h;
- REGION_INIT(pScreen, &WinRegion, &WinBox, 1);
- REGION_NULL(pScreen, &ClipRegion);
- REGION_INTERSECT(pScreen, &ClipRegion, &WinRegion, pGC->pCompositeClip);
+ RegionInit(&WinRegion, &WinBox, 1);
+ RegionNull(&ClipRegion);
+ RegionIntersect(&ClipRegion, &WinRegion, pGC->pCompositeClip);
if(portPriv->AdaptorRec->flags & VIDEO_CLIP_TO_VIEWPORT) {
RegionRec VPReg;
@@ -1745,9 +1731,9 @@ xf86XVPutImage(
VPBox.x2 = portPriv->pScrn->frameX1 + 1;
VPBox.y2 = portPriv->pScrn->frameY1 + 1;
- REGION_INIT(pScreen, &VPReg, &VPBox, 1);
- REGION_INTERSECT(pScreen, &ClipRegion, &ClipRegion, &VPReg);
- REGION_UNINIT(pScreen, &VPReg);
+ RegionInit(&VPReg, &VPBox, 1);
+ RegionIntersect(&ClipRegion, &ClipRegion, &VPReg);
+ RegionUninit(&VPReg);
}
/* If we are changing windows, unregister our port in the old window */
@@ -1758,14 +1744,14 @@ xf86XVPutImage(
ret = xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
if(ret != Success) goto PUT_IMAGE_BAILOUT;
- if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
+ if(!RegionNotEmpty(&ClipRegion)) {
clippedAway = TRUE;
goto PUT_IMAGE_BAILOUT;
}
if(portPriv->AdaptorRec->flags & VIDEO_NO_CLIPPING) {
- BoxPtr clipBox = REGION_RECTS(&ClipRegion);
- if( (REGION_NUM_RECTS(&ClipRegion) != 1) ||
+ BoxPtr clipBox = RegionRects(&ClipRegion);
+ if( (RegionNumRects(&ClipRegion) != 1) ||
(clipBox->x1 != WinBox.x1) || (clipBox->x2 != WinBox.x2) ||
(clipBox->y1 != WinBox.y1) || (clipBox->y2 != WinBox.y2))
{
@@ -1775,7 +1761,7 @@ xf86XVPutImage(
}
if(portPriv->AdaptorRec->flags & VIDEO_INVERT_CLIPLIST) {
- REGION_SUBTRACT(pScreen, &ClipRegion, &WinRegion, &ClipRegion);
+ RegionSubtract(&ClipRegion, &WinRegion, &ClipRegion);
}
ret = (*portPriv->AdaptorRec->PutImage)(portPriv->pScrn,
@@ -1803,8 +1789,8 @@ PUT_IMAGE_BAILOUT:
portPriv->isOn = XV_PENDING;
}
- REGION_UNINIT(pScreen, &WinRegion);
- REGION_UNINIT(pScreen, &ClipRegion);
+ RegionUninit(&WinRegion);
+ RegionUninit(&ClipRegion);
return ret;
}
@@ -1834,8 +1820,8 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
WindowPtr pWin = (WindowPtr)pDraw;
XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin);
GCPtr pGC = NULL;
- BoxPtr pbox = REGION_RECTS(clipboxes);
- int i, nbox = REGION_NUM_RECTS(clipboxes);
+ BoxPtr pbox = RegionRects(clipboxes);
+ int i, nbox = RegionNumRects(clipboxes);
xRectangle *rects;
if(!xf86Screens[pScreen->myNum]->vtSema) return;
@@ -1860,7 +1846,7 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
ValidateGC(pDraw, pGC);
}
- REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y);
+ RegionTranslate(clipboxes, -pDraw->x, -pDraw->y);
rects = malloc(nbox * sizeof(xRectangle));
@@ -1881,10 +1867,10 @@ xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
void
xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
{
- DrawablePtr root = &WindowTable[pScreen->myNum]->drawable;
+ DrawablePtr root = &pScreen->root->drawable;
ChangeGCVal pval[2];
- BoxPtr pbox = REGION_RECTS(clipboxes);
- int i, nbox = REGION_NUM_RECTS(clipboxes);
+ BoxPtr pbox = RegionRects(clipboxes);
+ int i, nbox = RegionNumRects(clipboxes);
xRectangle *rects;
GCPtr gc;
@@ -1921,8 +1907,6 @@ xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
boundaries in 16.16 fixed point.
*/
-#define DummyScreen screenInfo.screens[0]
-
Bool
xf86XVClipVideoHelper(
BoxPtr dst,
@@ -1936,7 +1920,7 @@ xf86XVClipVideoHelper(
){
double xsw, xdw, ysw, ydw;
INT32 delta;
- BoxPtr extents = REGION_EXTENTS(DummyScreen, reg);
+ BoxPtr extents = RegionExtents(reg);
int diff;
xsw = (*xb - *xa) << 16;
@@ -1998,9 +1982,9 @@ xf86XVClipVideoHelper(
(dst->y1 > extents->y1) || (dst->y2 < extents->y2))
{
RegionRec clipReg;
- REGION_INIT(DummyScreen, &clipReg, dst, 1);
- REGION_INTERSECT(DummyScreen, reg, reg, &clipReg);
- REGION_UNINIT(DummyScreen, &clipReg);
+ RegionInit(&clipReg, dst, 1);
+ RegionIntersect(reg, reg, &clipReg);
+ RegionUninit(&clipReg);
}
return TRUE;
}
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c
index 9cf36f526..5a7f69d8a 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.c
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.c
@@ -55,8 +55,8 @@ typedef struct {
XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
-static int XF86XvMCScreenKeyIndex;
-static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKeyIndex;
+static DevPrivateKeyRec XF86XvMCScreenKeyRec;
+#define XF86XvMCScreenKey (&XF86XvMCScreenKeyRec)
#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
@@ -172,6 +172,9 @@ Bool xf86XvMCScreenInit(
if(!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if(!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
free(pAdapt);
return FALSE;
diff --git a/xorg-server/hw/xfree86/common/xisb.c b/xorg-server/hw/xfree86/common/xisb.c
index f08327fb3..287a98b53 100644
--- a/xorg-server/hw/xfree86/common/xisb.c
+++ b/xorg-server/hw/xfree86/common/xisb.c
@@ -69,12 +69,12 @@ XisbNew (int fd, ssize_t size)
b = malloc(sizeof (XISBuffer));
if (!b)
- return (NULL);
+ return NULL;
b->buf = malloc((sizeof (unsigned char) * size));
if (!b->buf)
{
free(b);
- return (NULL);
+ return NULL;
}
b->fd = fd;
@@ -83,7 +83,7 @@ XisbNew (int fd, ssize_t size)
b->current = 1; /* force it to be past the end to trigger initial read */
b->end = 0;
b->buffer_size = size;
- return (b);
+ return b;
}
void
@@ -103,7 +103,7 @@ XisbRead (XISBuffer *b)
if (b->block_duration >= 0)
{
if (xf86WaitForInput (b->fd, b->block_duration) < 1)
- return (-1);
+ return -1;
}
else
{
@@ -119,9 +119,9 @@ XisbRead (XISBuffer *b)
switch (ret)
{
case 0:
- return (-1); /* timeout */
+ return -1; /* timeout */
case -1:
- return (-2); /* error */
+ return -2; /* error */
default:
b->end = ret;
b->current = 0;
@@ -132,7 +132,7 @@ XisbRead (XISBuffer *b)
ErrorF ("read 0x%02x (%c)\n", b->buf[b->current],
isprint(b->buf[b->current])?b->buf[b->current]:'.');
- return (b->buf[b->current++]);
+ return b->buf[b->current++];
}
/* the only purpose of this function is to provide output tracing */
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index ec6465818..3b70ce508 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -53,8 +53,8 @@ find_start(unsigned int *ptr)
}
}
for (i=0;i<9;i++)
- if (test[i]) return (i+1);
- return (-1);
+ if (test[i]) return i+1;
+ return -1;
}
static unsigned char *
@@ -75,8 +75,8 @@ find_header(unsigned char *block)
if (i==8) break;
ptr++;
}
- if (ptr == end) return (NULL);
- return (ptr);
+ if (ptr == end) return NULL;
+ return ptr;
}
static unsigned char *
@@ -98,7 +98,7 @@ resort(unsigned char *s_block)
if (s_ptr == s_end) s_ptr = s_block;
}
free(s_block);
- return (d_new);
+ return d_new;
}
static int
@@ -120,7 +120,7 @@ DDC_checksum(unsigned char *block, int len)
/* catch the trivial case where all bytes are 0 */
if (!not_null) return 1;
- return (result&0xFF);
+ return result&0xFF;
}
static unsigned char *
@@ -169,7 +169,7 @@ FetchEDID_DDC1(register ScrnInfoPtr pScrn,
*xp = read_DDC(pScrn);
xp++;
} while(--count);
- return (ptr);
+ return ptr;
}
/* test if DDC1 return 0 if not */
@@ -184,7 +184,7 @@ TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
/* wait for next retrace */
if (old != read_DDC(pScrn)) break;
} while(count--);
- return (count);
+ return count;
}
/*
diff --git a/xorg-server/hw/xfree86/ddc/interpret_edid.c b/xorg-server/hw/xfree86/ddc/interpret_edid.c
index 1a2d2f487..7558206cc 100644
--- a/xorg-server/hw/xfree86/ddc/interpret_edid.c
+++ b/xorg-server/hw/xfree86/ddc/interpret_edid.c
@@ -183,7 +183,7 @@ xf86InterpretEDID(int scrnIndex, Uchar *block)
handle_edid_quirks(m);
encode_aspect_ratio(m);
- return (m);
+ return m;
error:
free(m);
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c
index 0b7d62dca..453ade80b 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -61,10 +61,11 @@ unsigned char DGAReqCode = 0;
int DGAErrorBase;
int DGAEventBase;
-static int DGAScreenPrivateKeyIndex;
-static DevPrivateKey DGAScreenPrivateKey = &DGAScreenPrivateKeyIndex;
-static int DGAClientPrivateKeyIndex;
-static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKeyIndex;
+static DevPrivateKeyRec DGAScreenPrivateKeyRec;
+#define DGAScreenPrivateKey (&DGAScreenPrivateKeyRec)
+#define DGAScreenPrivateKeyRegistered (DGAScreenPrivateKeyRec.initialized)
+static DevPrivateKeyRec DGAClientPrivateKeyRec;
+#define DGAClientPrivateKey (&DGAClientPrivateKeyRec)
static int DGACallbackRefCount = 0;
/* This holds the client's version information */
@@ -89,6 +90,12 @@ XFree86DGAExtensionInit(INITARGS)
{
ExtensionEntry* extEntry;
+ if (!dixRegisterPrivateKey(&DGAClientPrivateKeyRec, PRIVATE_CLIENT, 0))
+ return;
+
+ if (!dixRegisterPrivateKey(&DGAScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
if ((extEntry = AddExtension(XF86DGANAME,
XF86DGANumberEvents,
XF86DGANumberErrors,
@@ -685,10 +692,10 @@ ProcXF86DGAGetVideoLL(ClientPtr client)
rep.sequenceNumber = client->sequence;
if(!DGAAvailable(stuff->screen))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
/* get the parameters for the mode that best matches */
DGAGetModeInfo(stuff->screen, &mode, num);
@@ -717,24 +724,24 @@ ProcXF86DGADirectVideo(ClientPtr client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
- owner = DGA_GETCLIENT(stuff->screen);
-
REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode;
+ owner = DGA_GETCLIENT(stuff->screen);
+
if (owner && owner != client)
return DGAErrorBase + XF86DGANoDirectVideoMode;
if (stuff->enable & XF86DGADirectGraphics) {
if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
} else
num = 0;
if(Success != DGASetMode(stuff->screen, num, &mode, &pix))
- return (DGAErrorBase + XF86DGAScreenNotActive);
+ return DGAErrorBase + XF86DGAScreenNotActive;
DGASetInputMode (stuff->screen,
(stuff->enable & XF86DGADirectKeyb) != 0,
@@ -778,10 +785,10 @@ ProcXF86DGAGetViewPortSize(ClientPtr client)
rep.sequenceNumber = client->sequence;
if (!DGAAvailable(stuff->screen))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if(!(num = DGAGetOldDGAMode(stuff->screen)))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
DGAGetModeInfo(stuff->screen, &mode, num);
@@ -806,7 +813,7 @@ ProcXF86DGASetViewPort(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGASetViewPortReq);
if (!DGAAvailable(stuff->screen))
- return (DGAErrorBase + XF86DGANoDirectVideoMode);
+ return DGAErrorBase + XF86DGANoDirectVideoMode;
if (!DGAActive(stuff->screen))
return DGAErrorBase + XF86DGADirectNotActivated;
@@ -870,7 +877,7 @@ ProcXF86DGAInstallColormap(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGAInstallColormapReq);
if (!DGAActive(stuff->screen))
- return (DGAErrorBase + XF86DGADirectNotActivated);
+ return DGAErrorBase + XF86DGADirectNotActivated;
rc = dixLookupResourceByType((pointer *)&pcmp, stuff->id, RT_COLORMAP,
client, DixInstallAccess);
@@ -919,7 +926,7 @@ ProcXF86DGAViewPortChanged(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86DGAViewPortChangedReq);
if (!DGAActive(stuff->screen))
- return (DGAErrorBase + XF86DGADirectNotActivated);
+ return DGAErrorBase + XF86DGADirectNotActivated;
rep.type = X_Reply;
rep.length = 0;
diff --git a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c
index f29f5bad2..31bb311b3 100644
--- a/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/xorg-server/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -51,8 +51,8 @@ from Kaleb S. KEITHLEY
#define DEFAULT_XF86VIDMODE_VERBOSITY 3
static int VidModeErrorBase;
-static int VidModeClientPrivateKeyIndex;
-static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKeyIndex;
+static DevPrivateKeyRec VidModeClientPrivateKeyRec;
+#define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
/* This holds the client's version information */
typedef struct {
@@ -141,8 +141,8 @@ typedef struct _XF86VidModeScreenPrivate {
Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
-static int ScreenPrivateKeyIndex;
-static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex;
+static DevPrivateKeyRec ScreenPrivateKeyRec;
+#define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@@ -169,6 +169,13 @@ XFree86VidModeExtensionInit(void)
DEBUG_P("XFree86VidModeExtensionInit");
+ if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
+ return;
+#ifdef XF86VIDMODE_EVENTS
+ if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+#endif
+
#ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
#endif
@@ -177,9 +184,6 @@ XFree86VidModeExtensionInit(void)
pScreen = screenInfo.screens[i];
if (VidModeExtensionInit(pScreen))
enabled = TRUE;
-#ifdef XF86VIDMODE_EVENTS
- SetScreenPrivate (pScreen, NULL);
-#endif
}
/* This means that the DDX doesn't want the vidmode extension enabled */
if (!enabled)
@@ -347,7 +351,7 @@ SendXF86VidModeNotify(ScreenPtr pScreen, int state, Bool forced)
ev.type = XF86VidModeNotify + XF86VidModeEventBase;
ev.state = state;
ev.timestamp = currentTime.milliseconds;
- ev.root = WindowTable[pScreen->myNum]->drawable.id;
+ ev.root = pScreen->root->drawable.id;
ev.kind = kind;
ev.forced = forced;
WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
@@ -516,7 +520,7 @@ ProcXF86VidModeGetAllModeLines(ClientPtr client)
modecount = VidModeGetNumOfModes(stuff->screen);
if (modecount < 1)
- return (VidModeErrorBase + XF86VidModeExtensionDisabled);
+ return VidModeErrorBase + XF86VidModeExtensionDisabled;
if (!VidModeGetFirstModeline(stuff->screen, &mode, &dotClock))
return BadValue;
@@ -1098,8 +1102,7 @@ ProcXF86VidModeValidateModeLine(ClientPtr client)
status = VidModeCheckModeForDriver(stuff->screen, modetmp);
status_reply:
- if(modetmp)
- free(modetmp);
+ free(modetmp);
rep.type = X_Reply;
rep.length = bytes_to_int32(SIZEOF(xXF86VidModeValidateModeLineReply)
diff --git a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
index bf1adc4e8..1bec1bf27 100644
--- a/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/xorg-server/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -1065,35 +1065,85 @@ of the class. If none of the optional entries appear, the
.B InputClass
section is generic and will match any input device. If more than one of
these entries appear, they all must match for the configuration to apply.
-The allowed matching entries are shown below.
.PP
+There are two types of match entries used in
+.B InputClass
+sections. The first allows various tokens to be matched against attributes
+of the device. An entry can be constructed to match attributes from different
+devices by separating arguments with a '|' character. Multiple entries of the
+same type may be supplied to add multiple matching conditions on the same
+attribute. For example:
+.PP
+.RS 4
+.nf
+.B "Section \*qInputClass\*q"
+.B " Identifier \*qMy Class\*q"
+.B " # product string must contain example and
+.B " # either gizmo or gadget
+.B " MatchProduct \*qexample\*q
+.B " MatchProduct \*qgizmo|gadget\*q
+.I " ..."
+.B "EndSection"
+.fi
+.RE
.TP 7
.BI "MatchProduct \*q" matchproduct \*q
This entry can be used to check if the substring
.RI \*q matchproduct \*q
-occurs in the device's product name. Multiple substrings can be matched by
-separating arguments with a '|' character.
+occurs in the device's product name.
.TP 7
.BI "MatchVendor \*q" matchvendor \*q
This entry can be used to check if the substring
.RI \*q matchvendor \*q
-occurs in the device's vendor name. Multiple substrings can be matched by
-separating arguments with a '|' character.
+occurs in the device's vendor name.
.TP 7
.BI "MatchDevicePath \*q" matchdevice \*q
This entry can be used to check if the device file matches the
.RI \*q matchdevice \*q
-pathname pattern. Multiple patterns can be matched by separating arguments
-with a '|' character.
+pathname pattern.
+.TP 7
+.BI "MatchOS \*q" matchos \*q
+This entry can be used to check if the operating system matches the
+case-insensitive
+.RI \*q matchos \*q
+string. This entry is only supported on platforms providing the
+.BR uname (2)
+system call.
+.TP 7
+.BI "MatchPnPID \*q" matchpnp \*q
+The device's Plug and Play (PnP) ID can be checked against the
+.RI \*q matchpnp \*q
+shell wildcard pattern.
+.TP 7
+.BI "MatchUSBID \*q" matchusb \*q
+The device's USB ID can be checked against the
+.RI \*q matchusb \*q
+shell wildcard pattern. The ID is constructed as lowercase hexadecimal numbers
+separated by a ':'. This is the same format as the
+.BR lsusb (8)
+program.
+.TP 7
+.BI "MatchDriver \*q" matchdriver \*q
+Check the case-sensitive string
+.RI \*q matchdriver \*q
+against the currently configured driver of the device. Ordering of sections
+using this entry is important since it will not match unless the driver has
+been set by the config backend or a previous
+.B InputClass
+section.
.TP 7
.BI "MatchTag \*q" matchtag \*q
This entry can be used to check if tags assigned by the config backend
matches the
.RI \*q matchtag \*q
-pattern. Multiple patterns can be matched by separating arguments
-with a '|' character. A match is found if at least one of the tags given in
+pattern. A match is found if at least one of the tags given in
.RI \*q matchtag \*q
matches at least one of the tags assigned by the backend.
+.PP
+The second type of entry is used to match device types. These entries take a
+boolean argument similar to
+.B Option
+entries.
.TP 7
.BI "MatchIsKeyboard \*q" bool \*q
.TP 7
@@ -1106,9 +1156,6 @@ matches at least one of the tags assigned by the backend.
.BI "MatchIsTouchpad \*q" bool \*q
.TP 7
.BI "MatchIsTouchscreen \*q" bool \*q
-Match device types. These entries take a boolean argument similar to
-.B Option
-entries.
.PP
When an input device has been matched to the
.B InputClass
diff --git a/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml b/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml
index ff132a182..52a104cbc 100644
--- a/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml
+++ b/xorg-server/hw/xfree86/doc/sgml/DESIGN.xml
@@ -118,8 +118,9 @@ routines common to all the X servers in the sample implementation.
<title>The xorg.conf File</title>
<para>
-The xorg.conf file format is similar to the old format, with the following
-changes:
+The xorg.conf file format is based on the XF86Config format from XFree86 4.4,
+which is in turn similar to the old XFree86 3.x XF86Config format, with the
+following changes:
</para>
<sect2>
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c
index a8b050a94..378731624 100644
--- a/xorg-server/hw/xfree86/dri/dri.c
+++ b/xorg-server/hw/xfree86/dri/dri.c
@@ -74,10 +74,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
static int DRIEntPrivIndex = -1;
-static int DRIScreenPrivKeyIndex;
-static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKeyIndex;
-static int DRIWindowPrivKeyIndex;
-static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKeyIndex;
+static DevPrivateKeyRec DRIScreenPrivKeyRec;
+#define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
+static DevPrivateKeyRec DRIWindowPrivKeyRec;
+#define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0;
@@ -357,6 +357,11 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
if (DRIGeneration != serverGeneration)
DRIGeneration = serverGeneration;
+ if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+ if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
@@ -573,10 +578,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) {
DRIDrvMsg(pScreen->myNum, X_ERROR,
"[drm] failed to setup DRM signal handler\n");
- if (pDRIPriv->hiddenContextStore)
- free(pDRIPriv->hiddenContextStore);
- if (pDRIPriv->partial3DContextStore)
- free(pDRIPriv->partial3DContextStore);
+ free(pDRIPriv->hiddenContextStore);
+ free(pDRIPriv->partial3DContextStore);
DRIDestroyContextPriv(pDRIContextPriv);
return FALSE;
} else {
@@ -785,7 +788,7 @@ drmServerInfo DRIDRMServerInfo = {
Bool
DRIExtensionInit(void)
{
- if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) {
+ if (DRIGeneration != serverGeneration) {
return FALSE;
}
@@ -1157,7 +1160,7 @@ DRIDCNTreeTraversal(WindowPtr pWin, pointer data)
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if (REGION_NUM_RECTS(&pWin->clipList) > 0) {
+ if (RegionNumRects(&pWin->clipList) > 0) {
WindowPtr *pDRIWindows = (WindowPtr*)data;
int i = 0;
@@ -1187,7 +1190,7 @@ DRIDriverClipNotify(ScreenPtr pScreen)
if (pDRIPriv->nrWindows > 0) {
pDRIPriv->nrWalked = 0;
- TraverseTree(WindowTable[pScreen->myNum], DRIDCNTreeTraversal,
+ TraverseTree(pScreen->root, DRIDCNTreeTraversal,
(pointer)pDRIWindows);
}
@@ -1269,7 +1272,7 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
pDRIDrawablePriv->pScreen = pScreen;
pDRIDrawablePriv->refCount = 1;
pDRIDrawablePriv->drawableIndex = -1;
- pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList);
+ pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList);
/* save private off of preallocated index */
dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
@@ -1288,8 +1291,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
drmUpdateDrawableInfo(pDRIPriv->drmFD,
pDRIDrawablePriv->hwDrawable,
DRM_DRAWABLE_CLIPRECTS,
- REGION_NUM_RECTS(&pWin->clipList),
- REGION_RECTS(&pWin->clipList));
+ RegionNumRects(&pWin->clipList),
+ RegionRects(&pWin->clipList));
*hHWDrawable = pDRIDrawablePriv->hwDrawable;
}
}
@@ -1502,8 +1505,8 @@ DRIGetDrawableInfo(ScreenPtr pScreen,
#endif
*W = (int)(pWin->drawable.width);
*H = (int)(pWin->drawable.height);
- *numClipRects = REGION_NUM_RECTS(&pWin->clipList);
- *pClipRects = (drm_clip_rect_t *)REGION_RECTS(&pWin->clipList);
+ *numClipRects = RegionNumRects(&pWin->clipList);
+ *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList);
if (!*numClipRects && pDRIPriv->fullscreen) {
/* use fake full-screen clip rect */
@@ -1613,7 +1616,7 @@ DRICreateInfoRec(void)
void
DRIDestroyInfoRec(DRIInfoPtr DRIInfo)
{
- if (DRIInfo->busIdString) free(DRIInfo->busIdString);
+ free(DRIInfo->busIdString);
free((char*)DRIInfo);
}
@@ -1883,10 +1886,10 @@ DRITreeTraversal(WindowPtr pWin, pointer data)
ScreenPtr pScreen = pWin->drawable.pScreen;
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- if(REGION_NUM_RECTS(&(pWin->clipList)) > 0) {
+ if(RegionNumRects(&(pWin->clipList)) > 0) {
RegionPtr reg = (RegionPtr)data;
- REGION_UNION(pScreen, reg, reg, &(pWin->clipList));
+ RegionUnion(reg, reg, &(pWin->clipList));
pDRIPriv->nrWalked++;
}
@@ -1932,21 +1935,21 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
if(pDRIPriv->nrWindowsVisible > 0) {
RegionRec reg;
- REGION_NULL(pScreen, &reg);
+ RegionNull(&reg);
pDRIPriv->nrWalked = 0;
TraverseTree(pWin, DRITreeTraversal, (pointer)(&reg));
- if(REGION_NOTEMPTY(pScreen, &reg)) {
- REGION_TRANSLATE(pScreen, &reg, ptOldOrg.x - pWin->drawable.x,
+ if(RegionNotEmpty(&reg)) {
+ RegionTranslate(&reg, ptOldOrg.x - pWin->drawable.x,
ptOldOrg.y - pWin->drawable.y);
- REGION_INTERSECT(pScreen, &reg, &reg, prgnSrc);
+ RegionIntersect(&reg, &reg, prgnSrc);
/* The MoveBuffers interface is not ideal */
(*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, &reg,
pDRIPriv->pDriverInfo->ddxDrawableTableEntry);
}
- REGION_UNINIT(pScreen, &reg);
+ RegionUninit(&reg);
}
/* call lower wrapped functions */
@@ -2122,7 +2125,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
if(!pDRIPriv) return;
if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) {
- int nrects = REGION_NUM_RECTS(&pWin->clipList);
+ int nrects = RegionNumRects(&pWin->clipList);
if(!pDRIPriv->windowsTouched) {
DRILockTree(pScreen);
@@ -2143,7 +2146,7 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy)
drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable,
DRM_DRAWABLE_CLIPRECTS,
- nrects, REGION_RECTS(&pWin->clipList));
+ nrects, RegionRects(&pWin->clipList));
}
/* call lower wrapped functions */
@@ -2368,9 +2371,9 @@ DRIMoveBuffersHelper(
BoxRec tmpBox;
int y, nbox;
- extents = REGION_EXTENTS(pScreen, reg);
- nbox = REGION_NUM_RECTS(reg);
- pbox = REGION_RECTS(reg);
+ extents = RegionExtents(reg);
+ nbox = RegionNumRects(reg);
+ pbox = RegionRects(reg);
if((dy > 0) && (dy < (extents->y2 - extents->y1))) {
*ydir = -1;
diff --git a/xorg-server/hw/xfree86/dri/dristruct.h b/xorg-server/hw/xfree86/dri/dristruct.h
index fc929c2f9..bbd158e11 100644
--- a/xorg-server/hw/xfree86/dri/dristruct.h
+++ b/xorg-server/hw/xfree86/dri/dristruct.h
@@ -1,128 +1,129 @@
-/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- *
- */
-
-#ifndef DRI_STRUCT_H
-#define DRI_STRUCT_H
-
-#include "xf86drm.h"
-#include "xf86Crtc.h"
-
-
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
-
-typedef struct _DRIDrawablePrivRec
-{
- drm_drawable_t hwDrawable;
- int drawableIndex;
- ScreenPtr pScreen;
- int refCount;
- int nrects;
-} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
-
-struct _DRIContextPrivRec
-{
- drm_context_t hwContext;
- ScreenPtr pScreen;
- Bool valid3D;
- DRIContextFlags flags;
- void** pContextStore;
-};
-
-#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
- dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey))
-
-#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
- DRIScreenPrivKey))
-
-#define DRI_ENT_PRIV(pScrn) \
- ((DRIEntPrivIndex < 0) ? \
- NULL: \
- ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
- DRIEntPrivIndex)->ptr)))
-
-typedef struct _DRIScreenPrivRec
-{
- Bool directRenderingSupport;
- int drmFD; /* File descriptor for /dev/video/? */
- drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
- XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
- drm_context_t myContext; /* DDX Driver's context */
- DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
- DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
- void** hiddenContextStore; /* hidden X context */
- void** partial3DContextStore; /* parital 3D context */
- DRIInfoPtr pDriverInfo;
- int nrWindows;
- int nrWindowsVisible;
- int nrWalked;
- drm_clip_rect_t private_buffer_rect; /* management of private buffers */
- DrawablePtr fullscreen; /* pointer to fullscreen drawable */
- drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
- DRIWrappedFuncsRec wrap;
- DestroyWindowProcPtr DestroyWindow;
- DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
- DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
- Bool createDummyCtx;
- Bool createDummyCtxPriv;
- Bool grabbedDRILock;
- Bool drmSIGIOHandlerInstalled;
- Bool wrapped;
- Bool windowsTouched;
- int lockRefCount;
- drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */
- XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */
- int* pLockRefCount;
- int* pLockingContext;
- xf86_crtc_notify_proc_ptr xf86_crtc_notify;
-} DRIScreenPrivRec, *DRIScreenPrivPtr;
-
-
-typedef struct _DRIEntPrivRec {
- int drmFD;
- Bool drmOpened;
- Bool sAreaGrabbed;
- drm_handle_t hLSAREA;
- XF86DRILSAREAPtr pLSAREA;
- unsigned long sAreaSize;
- int lockRefCount;
- int lockingContext;
- ScreenPtr resOwner;
- Bool keepFDOpen;
- int refCount;
-} DRIEntPrivRec, *DRIEntPrivPtr;
-
-#endif /* DRI_STRUCT_H */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ */
+
+#ifndef DRI_STRUCT_H
+#define DRI_STRUCT_H
+
+#include "xf86drm.h"
+#include "xf86Crtc.h"
+
+
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
+
+typedef struct _DRIDrawablePrivRec
+{
+ drm_drawable_t hwDrawable;
+ int drawableIndex;
+ ScreenPtr pScreen;
+ int refCount;
+ int nrects;
+} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
+
+struct _DRIContextPrivRec
+{
+ drm_context_t hwContext;
+ ScreenPtr pScreen;
+ Bool valid3D;
+ DRIContextFlags flags;
+ void** pContextStore;
+};
+
+#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
+ (dixPrivateKeyRegistered(DRIScreenPrivKey) ? \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey) : NULL))
+
+#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
+
+#define DRI_ENT_PRIV(pScrn) \
+ ((DRIEntPrivIndex < 0) ? \
+ NULL: \
+ ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
+ DRIEntPrivIndex)->ptr)))
+
+typedef struct _DRIScreenPrivRec
+{
+ Bool directRenderingSupport;
+ int drmFD; /* File descriptor for /dev/video/? */
+ drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
+ XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
+ drm_context_t myContext; /* DDX Driver's context */
+ DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
+ DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
+ void** hiddenContextStore; /* hidden X context */
+ void** partial3DContextStore; /* parital 3D context */
+ DRIInfoPtr pDriverInfo;
+ int nrWindows;
+ int nrWindowsVisible;
+ int nrWalked;
+ drm_clip_rect_t private_buffer_rect; /* management of private buffers */
+ DrawablePtr fullscreen; /* pointer to fullscreen drawable */
+ drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
+ DRIWrappedFuncsRec wrap;
+ DestroyWindowProcPtr DestroyWindow;
+ DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
+ DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
+ Bool createDummyCtx;
+ Bool createDummyCtxPriv;
+ Bool grabbedDRILock;
+ Bool drmSIGIOHandlerInstalled;
+ Bool wrapped;
+ Bool windowsTouched;
+ int lockRefCount;
+ drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */
+ XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */
+ int* pLockRefCount;
+ int* pLockingContext;
+ xf86_crtc_notify_proc_ptr xf86_crtc_notify;
+} DRIScreenPrivRec, *DRIScreenPrivPtr;
+
+
+typedef struct _DRIEntPrivRec {
+ int drmFD;
+ Bool drmOpened;
+ Bool sAreaGrabbed;
+ drm_handle_t hLSAREA;
+ XF86DRILSAREAPtr pLSAREA;
+ unsigned long sAreaSize;
+ int lockRefCount;
+ int lockingContext;
+ ScreenPtr resOwner;
+ Bool keepFDOpen;
+ int refCount;
+} DRIEntPrivRec, *DRIEntPrivPtr;
+
+#endif /* DRI_STRUCT_H */
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index 29c917f21..bb1be358b 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -1,1140 +1,1177 @@
-/*
- * Copyright © 2007, 2008 Red Hat, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Soft-
- * ware"), to deal in the Software without restriction, including without
- * limitation the rights to use, copy, modify, merge, publish, distribute,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, provided that the above copyright
- * notice(s) and this permission notice appear in all copies of the Soft-
- * ware and that both the above copyright notice(s) and this permission
- * notice appear in supporting documentation.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
- * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
- * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
- * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
- * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
- * MANCE OF THIS SOFTWARE.
- *
- * Except as contained in this notice, the name of a copyright holder shall
- * not be used in advertising or otherwise to promote the sale, use or
- * other dealings in this Software without prior written authorization of
- * the copyright holder.
- *
- * Authors:
- * Kristian Høgsberg (krh@redhat.com)
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <errno.h>
-#include <xf86drm.h>
-#include "xf86Module.h"
-#include "list.h"
-#include "scrnintstr.h"
-#include "windowstr.h"
-#include "dixstruct.h"
-#include "dri2.h"
-#include "xf86VGAarbiter.h"
-
-#include "xf86.h"
-
-CARD8 dri2_major; /* version of DRI2 supported by DDX */
-CARD8 dri2_minor;
-
-static int dri2ScreenPrivateKeyIndex;
-static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex;
-static int dri2WindowPrivateKeyIndex;
-static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex;
-static int dri2PixmapPrivateKeyIndex;
-static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
-static RESTYPE dri2DrawableRes;
-
-typedef struct _DRI2Screen *DRI2ScreenPtr;
-
-typedef struct _DRI2Drawable {
- DRI2ScreenPtr dri2_screen;
- DrawablePtr drawable;
- struct list reference_list;
- int width;
- int height;
- DRI2BufferPtr *buffers;
- int bufferCount;
- unsigned int swapsPending;
- ClientPtr blockedClient;
- Bool blockedOnMsc;
- int swap_interval;
- CARD64 swap_count;
- int64_t target_sbc; /* -1 means no SBC wait outstanding */
- CARD64 last_swap_target; /* most recently queued swap target */
- CARD64 last_swap_msc; /* msc at completion of most recent swap */
- CARD64 last_swap_ust; /* ust at completion of most recent swap */
- int swap_limit; /* for N-buffering */
-} DRI2DrawableRec, *DRI2DrawablePtr;
-
-typedef struct _DRI2Screen {
- ScreenPtr screen;
- int refcnt;
- unsigned int numDrivers;
- const char **driverNames;
- const char *deviceName;
- int fd;
- unsigned int lastSequence;
-
- DRI2CreateBufferProcPtr CreateBuffer;
- DRI2DestroyBufferProcPtr DestroyBuffer;
- DRI2CopyRegionProcPtr CopyRegion;
- DRI2ScheduleSwapProcPtr ScheduleSwap;
- DRI2GetMSCProcPtr GetMSC;
- DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
-
- HandleExposuresProcPtr HandleExposures;
-
- ConfigNotifyProcPtr ConfigNotify;
-} DRI2ScreenRec;
-
-static DRI2ScreenPtr
-DRI2GetScreen(ScreenPtr pScreen)
-{
- return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
-}
-
-static DRI2DrawablePtr
-DRI2GetDrawable(DrawablePtr pDraw)
-{
- WindowPtr pWin;
- PixmapPtr pPixmap;
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
- }
-}
-
-static DRI2DrawablePtr
-DRI2AllocateDrawable(DrawablePtr pDraw)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- CARD64 ust;
- WindowPtr pWin;
- PixmapPtr pPixmap;
-
- pPriv = malloc(sizeof *pPriv);
- if (pPriv == NULL)
- return NULL;
-
- pPriv->dri2_screen = ds;
- pPriv->drawable = pDraw;
- pPriv->width = pDraw->width;
- pPriv->height = pDraw->height;
- pPriv->buffers = NULL;
- pPriv->bufferCount = 0;
- pPriv->swapsPending = 0;
- pPriv->blockedClient = NULL;
- pPriv->blockedOnMsc = FALSE;
- pPriv->swap_count = 0;
- pPriv->target_sbc = -1;
- pPriv->swap_interval = 1;
- /* Initialize last swap target from DDX if possible */
- if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
- pPriv->last_swap_target = 0;
-
- pPriv->swap_limit = 1; /* default to double buffering */
- pPriv->last_swap_msc = 0;
- pPriv->last_swap_ust = 0;
- list_init(&pPriv->reference_list);
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
- }
-
- return pPriv;
-}
-
-typedef struct DRI2DrawableRefRec {
- XID id;
- XID dri2_id;
- DRI2InvalidateProcPtr invalidate;
- void *priv;
- struct list link;
-} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
-
-static DRI2DrawableRefPtr
-DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
-{
- DRI2DrawableRefPtr ref;
-
- list_for_each_entry(ref, &pPriv->reference_list, link) {
- if (ref->id == id)
- return ref;
- }
-
- return NULL;
-}
-
-static int
-DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
- DRI2InvalidateProcPtr invalidate, void *priv)
-{
- DRI2DrawableRefPtr ref;
-
- ref = malloc(sizeof *ref);
- if (ref == NULL)
- return BadAlloc;
-
- if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
- return BadAlloc;
- if (!DRI2LookupDrawableRef(pPriv, id))
- if (!AddResource(id, dri2DrawableRes, pPriv))
- return BadAlloc;
-
- ref->id = id;
- ref->dri2_id = dri2_id;
- ref->invalidate = invalidate;
- ref->priv = priv;
- list_add(&ref->link, &pPriv->reference_list);
-
- return Success;
-}
-
-int
-DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
- DRI2InvalidateProcPtr invalidate, void *priv)
-{
- DRI2DrawablePtr pPriv;
- XID dri2_id;
- int rc;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- pPriv = DRI2AllocateDrawable(pDraw);
- if (pPriv == NULL)
- return BadAlloc;
-
- dri2_id = FakeClientID(client->index);
- rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
- if (rc != Success)
- return rc;
-
- return Success;
-}
-
-static int DRI2DrawableGone(pointer p, XID id)
-{
- DRI2DrawablePtr pPriv = p;
- DRI2ScreenPtr ds = pPriv->dri2_screen;
- DRI2DrawableRefPtr ref, next;
- WindowPtr pWin;
- PixmapPtr pPixmap;
- DrawablePtr pDraw;
- int i;
-
- list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
- if (ref->dri2_id == id) {
- list_del(&ref->link);
- /* If this was the last ref under this X drawable XID,
- * unregister the X drawable resource. */
- if (!DRI2LookupDrawableRef(pPriv, ref->id))
- FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
- free(ref);
- break;
- }
-
- if (ref->id == id) {
- list_del(&ref->link);
- FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
- free(ref);
- }
- }
-
- if (!list_is_empty(&pPriv->reference_list))
- return Success;
-
- pDraw = pPriv->drawable;
- if (pDraw->type == DRAWABLE_WINDOW) {
- pWin = (WindowPtr) pDraw;
- dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
- } else {
- pPixmap = (PixmapPtr) pDraw;
- dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
- }
-
- if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++)
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
-
- free(pPriv->buffers);
- }
-
- free(pPriv);
-
- return Success;
-}
-
-static int
-find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
-{
- int i;
-
- if (pPriv->buffers == NULL) {
- return -1;
- }
-
- for (i = 0; i < pPriv->bufferCount; i++) {
- if ((pPriv->buffers[i] != NULL)
- && (pPriv->buffers[i]->attachment == attachment)) {
- return i;
- }
- }
-
- return -1;
-}
-
-static Bool
-allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
- DRI2DrawablePtr pPriv,
- unsigned int attachment, unsigned int format,
- int dimensions_match, DRI2BufferPtr *buffer)
-{
- int old_buf = find_attachment(pPriv, attachment);
-
- if ((old_buf < 0)
- || !dimensions_match
- || (pPriv->buffers[old_buf]->format != format)) {
- *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
- return TRUE;
-
- } else {
- *buffer = pPriv->buffers[old_buf];
- pPriv->buffers[old_buf] = NULL;
- return FALSE;
- }
-}
-
-static void
-update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
- DRI2BufferPtr *buffers, int *out_count, int *width, int *height)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- int i;
-
- if (pPriv->buffers != NULL) {
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i] != NULL) {
- (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
- }
- }
-
- free(pPriv->buffers);
- }
-
- pPriv->buffers = buffers;
- pPriv->bufferCount = *out_count;
- pPriv->width = pDraw->width;
- pPriv->height = pDraw->height;
- *width = pPriv->width;
- *height = pPriv->height;
-}
-
-static DRI2BufferPtr *
-do_get_buffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count,
- int has_format)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
- DRI2BufferPtr *buffers;
- int need_real_front = 0;
- int need_fake_front = 0;
- int have_fake_front = 0;
- int front_format = 0;
- int dimensions_match;
- int buffers_changed = 0;
- int i;
-
- if (!pPriv) {
- *width = pDraw->width;
- *height = pDraw->height;
- *out_count = 0;
- return NULL;
- }
-
- dimensions_match = (pDraw->width == pPriv->width)
- && (pDraw->height == pPriv->height);
-
- buffers = malloc((count + 1) * sizeof(buffers[0]));
-
- for (i = 0; i < count; i++) {
- const unsigned attachment = *(attachments++);
- const unsigned format = (has_format) ? *(attachments++) : 0;
-
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
- format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
-
- /* If the drawable is a window and the front-buffer is requested,
- * silently add the fake front-buffer to the list of requested
- * attachments. The counting logic in the loop accounts for the case
- * where the client requests both the fake and real front-buffer.
- */
- if (attachment == DRI2BufferBackLeft) {
- need_real_front++;
- front_format = format;
- }
-
- if (attachment == DRI2BufferFrontLeft) {
- need_real_front--;
- front_format = format;
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- need_fake_front++;
- }
- }
-
- if (pDraw->type == DRAWABLE_WINDOW) {
- if (attachment == DRI2BufferFakeFrontLeft) {
- need_fake_front--;
- have_fake_front = 1;
- }
- }
- }
-
- if (need_real_front > 0) {
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
- front_format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
- i++;
- }
-
- if (need_fake_front > 0) {
- if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
- front_format, dimensions_match,
- &buffers[i]))
- buffers_changed = 1;
-
- if (buffers[i] == NULL)
- goto err_out;
-
- i++;
- have_fake_front = 1;
- }
-
- *out_count = i;
-
- update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);
-
- /* If the client is getting a fake front-buffer, pre-fill it with the
- * contents of the real front-buffer. This ensures correct operation of
- * applications that call glXWaitX before calling glDrawBuffer.
- */
- if (have_fake_front && buffers_changed) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pPriv->width;
- box.y2 = pPriv->height;
- REGION_INIT(pDraw->pScreen, &region, &box, 0);
-
- DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
- }
-
- return pPriv->buffers;
-
-err_out:
-
- *out_count = 0;
-
- for (i = 0; i < count; i++) {
- if (buffers[i] != NULL)
- (*ds->DestroyBuffer)(pDraw, buffers[i]);
- }
-
- free(buffers);
- buffers = NULL;
-
- update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);
-
- return buffers;
-}
-
-DRI2BufferPtr *
-DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
-{
- return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, FALSE);
-}
-
-DRI2BufferPtr *
-DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
- unsigned int *attachments, int count, int *out_count)
-{
- return do_get_buffers(pDraw, width, height, attachments, count,
- out_count, TRUE);
-}
-
-static void
-DRI2InvalidateDrawable(DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
- DRI2DrawableRefPtr ref;
-
- if (!pPriv)
- return;
-
- list_for_each_entry(ref, &pPriv->reference_list, link)
- ref->invalidate(pDraw, ref->priv);
-}
-
-/*
- * In the direct rendered case, we throttle the clients that have more
- * than their share of outstanding swaps (and thus busy buffers) when a
- * new GetBuffers request is received. In the AIGLX case, we allow the
- * client to get the new buffers, but throttle when the next GLX request
- * comes in (see __glXDRIcontextWait()).
- */
-Bool
-DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return FALSE;
-
- /* Throttle to swap limit */
- if ((pPriv->swapsPending >= pPriv->swap_limit) &&
- !pPriv->blockedClient) {
- ResetCurrentRequest(client);
- client->sequence--;
- IgnoreClient(client);
- pPriv->blockedClient = client;
- return TRUE;
- }
-
- return FALSE;
-}
-
-static void
-__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
-{
- if (pPriv->blockedClient == NULL) {
- IgnoreClient(client);
- pPriv->blockedClient = client;
- }
-}
-
-void
-DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- __DRI2BlockClient(client, pPriv);
- pPriv->blockedOnMsc = TRUE;
-}
-
-int
-DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
- unsigned int dest, unsigned int src)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer, pSrcBuffer;
- int i;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- pDestBuffer = NULL;
- pSrcBuffer = NULL;
- for (i = 0; i < pPriv->bufferCount; i++)
- {
- if (pPriv->buffers[i]->attachment == dest)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == src)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- }
- if (pSrcBuffer == NULL || pDestBuffer == NULL)
- return BadValue;
-
- (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
-
- return Success;
-}
-
-/* Can this drawable be page flipped? */
-Bool
-DRI2CanFlip(DrawablePtr pDraw)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- WindowPtr pWin, pRoot;
- PixmapPtr pWinPixmap, pRootPixmap;
-
- if (pDraw->type == DRAWABLE_PIXMAP)
- return TRUE;
-
- pRoot = WindowTable[pScreen->myNum];
- pRootPixmap = pScreen->GetWindowPixmap(pRoot);
-
- pWin = (WindowPtr) pDraw;
- pWinPixmap = pScreen->GetWindowPixmap(pWin);
- if (pRootPixmap != pWinPixmap)
- return FALSE;
- if (!REGION_EQUAL(pScreen, &pWin->clipList, &pRoot->winSize))
- return FALSE;
-
- return TRUE;
-}
-
-/* Can we do a pixmap exchange instead of a blit? */
-Bool
-DRI2CanExchange(DrawablePtr pDraw)
-{
- return FALSE;
-}
-
-void
-DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return;
-
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
-
- if (pPriv->blockedClient)
- AttendClient(pPriv->blockedClient);
-
- pPriv->blockedClient = NULL;
- pPriv->blockedOnMsc = FALSE;
-}
-
-static void
-DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- /*
- * Swap completed.
- * Wake the client iff:
- * - it was waiting on SBC
- * - was blocked due to GLX make current
- * - was blocked due to swap throttling
- * - is not blocked due to an MSC wait
- */
- if (pPriv->target_sbc != -1 &&
- pPriv->target_sbc <= pPriv->swap_count) {
- ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
- frame, pPriv->swap_count);
- pPriv->target_sbc = -1;
-
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
- if (pPriv->blockedClient) {
- AttendClient(pPriv->blockedClient);
- pPriv->blockedClient = NULL;
- }
- }
-}
-
-void
-DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
- unsigned int tv_sec, unsigned int tv_usec, int type,
- DRI2SwapEventPtr swap_complete, void *swap_data)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2DrawablePtr pPriv;
- CARD64 ust = 0;
- BoxRec box;
- RegionRec region;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- pPriv->swapsPending--;
- pPriv->swap_count++;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- REGION_INIT(pScreen, &region, &box, 0);
- DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
- DRI2BufferFrontLeft);
-
- ust = ((CARD64)tv_sec * 1000000) + tv_usec;
- if (swap_complete)
- swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
-
- pPriv->last_swap_msc = frame;
- pPriv->last_swap_ust = ust;
-
- DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
-}
-
-Bool
-DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
-{
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
-
- /* If we're currently waiting for a swap on this drawable, reset
- * the request and suspend the client. We only support one
- * blocked client per drawable. */
- if ((pPriv->swapsPending) &&
- pPriv->blockedClient == NULL) {
- ResetCurrentRequest(client);
- client->sequence--;
- __DRI2BlockClient(client, pPriv);
- return TRUE;
- }
-
- return FALSE;
-}
-
-int
-DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
- DRI2SwapEventPtr func, void *data)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
- int ret, i;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
- }
-
- for (i = 0; i < pPriv->bufferCount; i++) {
- if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
- pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
- pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
- }
- if (pSrcBuffer == NULL || pDestBuffer == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: drawable has no back or front?\n", __func__);
- return BadDrawable;
- }
-
- /* Old DDX or no swap interval, just blit */
- if (!ds->ScheduleSwap || !pPriv->swap_interval) {
- BoxRec box;
- RegionRec region;
-
- box.x1 = 0;
- box.y1 = 0;
- box.x2 = pDraw->width;
- box.y2 = pDraw->height;
- REGION_INIT(pScreen, &region, &box, 0);
-
- pPriv->swapsPending++;
-
- (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
- DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
- func, data);
- return Success;
- }
-
- /*
- * In the simple glXSwapBuffers case, all params will be 0, and we just
- * need to schedule a swap for the last swap target + the swap interval.
- */
- if (target_msc == 0 && divisor == 0 && remainder == 0) {
- /*
- * Swap target for this swap is last swap target + swap interval since
- * we have to account for the current swap count, interval, and the
- * number of pending swaps.
- */
- *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
- } else {
- /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
- *swap_target = target_msc;
- }
-
- pPriv->swapsPending++;
- ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
- swap_target, divisor, remainder, func, data);
- if (!ret) {
- pPriv->swapsPending--; /* didn't schedule */
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: driver failed to schedule swap\n", __func__);
- return BadDrawable;
- }
-
- pPriv->last_swap_target = *swap_target;
-
- /* According to spec, return expected swapbuffers count SBC after this swap
- * will complete.
- */
- *swap_target = pPriv->swap_count + pPriv->swapsPending;
-
- DRI2InvalidateDrawable(pDraw);
-
- return Success;
-}
-
-void
-DRI2SwapInterval(DrawablePtr pDrawable, int interval)
-{
- ScreenPtr pScreen = pDrawable->pScreen;
- DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
-
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return;
- }
-
- /* fixme: check against arbitrary max? */
- pPriv->swap_interval = interval;
-}
-
-int
-DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- Bool ret;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL) {
- xf86DrvMsg(pScreen->myNum, X_ERROR,
- "[DRI2] %s: bad drawable\n", __func__);
- return BadDrawable;
- }
-
- if (!ds->GetMSC) {
- *ust = 0;
- *msc = 0;
- *sbc = pPriv->swap_count;
- return Success;
- }
-
- /*
- * Spec needs to be updated to include unmapped or redirected
- * drawables
- */
-
- ret = (*ds->GetMSC)(pDraw, ust, msc);
- if (!ret)
- return BadDrawable;
-
- *sbc = pPriv->swap_count;
-
- return Success;
-}
-
-int
-DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
- CARD64 divisor, CARD64 remainder)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
- DRI2DrawablePtr pPriv;
- Bool ret;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- /* Old DDX just completes immediately */
- if (!ds->ScheduleWaitMSC) {
- DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
-
- return Success;
- }
-
- ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
- if (!ret)
- return BadDrawable;
-
- return Success;
-}
-
-int
-DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc,
- CARD64 *ust, CARD64 *msc, CARD64 *sbc)
-{
- DRI2DrawablePtr pPriv;
-
- pPriv = DRI2GetDrawable(pDraw);
- if (pPriv == NULL)
- return BadDrawable;
-
- /* target_sbc == 0 means to block until all pending swaps are
- * finished. Recalculate target_sbc to get that behaviour.
- */
- if (target_sbc == 0)
- target_sbc = pPriv->swap_count + pPriv->swapsPending;
-
- /* If current swap count already >= target_sbc,
- * return immediately with (ust, msc, sbc) triplet of
- * most recent completed swap.
- */
- if (pPriv->swap_count >= target_sbc) {
- *sbc = pPriv->swap_count;
- *msc = pPriv->last_swap_msc;
- *ust = pPriv->last_swap_ust;
- return Success;
- }
-
- pPriv->target_sbc = target_sbc;
- __DRI2BlockClient(client, pPriv);
-
- return Success;
-}
-
-Bool
-DRI2HasSwapControl(ScreenPtr pScreen)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- return (ds->ScheduleSwap && ds->GetMSC);
-}
-
-Bool
-DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
- const char **driverName, const char **deviceName)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- if (ds == NULL || driverType >= ds->numDrivers ||
- !ds->driverNames[driverType])
- return FALSE;
-
- *fd = ds->fd;
- *driverName = ds->driverNames[driverType];
- *deviceName = ds->deviceName;
-
- return TRUE;
-}
-
-Bool
-DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- if (ds == NULL || drmAuthMagic(ds->fd, magic))
- return FALSE;
-
- return TRUE;
-}
-
-static void
-DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
- WindowPtr pSib)
-{
- DrawablePtr pDraw = (DrawablePtr)pWin;
- ScreenPtr pScreen = pDraw->pScreen;
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
- DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
-
- if (ds->ConfigNotify) {
- pScreen->ConfigNotify = ds->ConfigNotify;
-
- (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
-
- ds->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = DRI2ConfigNotify;
- }
-
- if (!dd || (dd->width == w && dd->height == h))
- return;
-
- DRI2InvalidateDrawable(pDraw);
-}
-
-Bool
-DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
-{
- DRI2ScreenPtr ds;
- const char* driverTypeNames[] = {
- "DRI", /* DRI2DriverDRI */
- "VDPAU", /* DRI2DriverVDPAU */
- };
- unsigned int i;
- CARD8 cur_minor;
-
- if (info->version < 3)
- return FALSE;
-
- if (!xf86VGAarbiterAllowDRI(pScreen)) {
- xf86DrvMsg(pScreen->myNum, X_WARNING,
- "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
- return FALSE;
- }
-
- ds = calloc(1, sizeof *ds);
- if (!ds)
- return FALSE;
-
- ds->screen = pScreen;
- ds->fd = info->fd;
- ds->deviceName = info->deviceName;
- dri2_major = 1;
-
- ds->CreateBuffer = info->CreateBuffer;
- ds->DestroyBuffer = info->DestroyBuffer;
- ds->CopyRegion = info->CopyRegion;
-
- if (info->version >= 4) {
- ds->ScheduleSwap = info->ScheduleSwap;
- ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
- ds->GetMSC = info->GetMSC;
- cur_minor = 3;
- } else {
- cur_minor = 1;
- }
-
- /* Initialize minor if needed and set to minimum provied by DDX */
- if (!dri2_minor || dri2_minor > cur_minor)
- dri2_minor = cur_minor;
-
- if (info->version == 3 || info->numDrivers == 0) {
- /* Driver too old: use the old-style driverName field */
- ds->numDrivers = 1;
- ds->driverNames = malloc(sizeof(*ds->driverNames));
- if (!ds->driverNames) {
- free(ds);
- return FALSE;
- }
- ds->driverNames[0] = info->driverName;
- } else {
- ds->numDrivers = info->numDrivers;
- ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
- if (!ds->driverNames) {
- free(ds);
- return FALSE;
- }
- memcpy(ds->driverNames, info->driverNames,
- info->numDrivers * sizeof(*ds->driverNames));
- }
-
- dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
-
- ds->ConfigNotify = pScreen->ConfigNotify;
- pScreen->ConfigNotify = DRI2ConfigNotify;
-
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
- for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
- if (i < ds->numDrivers && ds->driverNames[i]) {
- xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
- driverTypeNames[i], ds->driverNames[i]);
- }
- }
-
- return TRUE;
-}
-
-void
-DRI2CloseScreen(ScreenPtr pScreen)
-{
- DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
-
- free(ds->driverNames);
- free(ds);
- dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
-}
-
-extern ExtensionModule dri2ExtensionModule;
-
-static pointer
-DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
-{
- static Bool setupDone = FALSE;
-
- dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
-
- if (!setupDone)
- {
- setupDone = TRUE;
- LoadExtension(&dri2ExtensionModule, FALSE);
- }
- else
- {
- if (errmaj)
- *errmaj = LDR_ONCEONLY;
- }
-
- return (pointer) 1;
-}
-
-static XF86ModuleVersionInfo DRI2VersRec =
-{
- "dri2",
- MODULEVENDORSTRING,
- MODINFOSTRING1,
- MODINFOSTRING2,
- XORG_VERSION_CURRENT,
- 1, 2, 0,
- ABI_CLASS_EXTENSION,
- ABI_EXTENSION_VERSION,
- MOD_CLASS_NONE,
- { 0, 0, 0, 0 }
-};
-
-_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
-
-void
-DRI2Version(int *major, int *minor)
-{
- if (major != NULL)
- *major = DRI2VersRec.majorversion;
-
- if (minor != NULL)
- *minor = DRI2VersRec.minorversion;
-}
+/*
+ * Copyright © 2007, 2008 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Soft-
+ * ware"), to deal in the Software without restriction, including without
+ * limitation the rights to use, copy, modify, merge, publish, distribute,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, provided that the above copyright
+ * notice(s) and this permission notice appear in all copies of the Soft-
+ * ware and that both the above copyright notice(s) and this permission
+ * notice appear in supporting documentation.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
+ * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
+ * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
+ * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
+ * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
+ * MANCE OF THIS SOFTWARE.
+ *
+ * Except as contained in this notice, the name of a copyright holder shall
+ * not be used in advertising or otherwise to promote the sale, use or
+ * other dealings in this Software without prior written authorization of
+ * the copyright holder.
+ *
+ * Authors:
+ * Kristian Høgsberg (krh@redhat.com)
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <errno.h>
+#ifdef WITH_LIBDRM
+#include <xf86drm.h>
+#endif
+#include "xf86Module.h"
+#include "list.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "dixstruct.h"
+#include "dri2.h"
+#include "xf86VGAarbiter.h"
+
+#include "xf86.h"
+
+CARD8 dri2_major; /* version of DRI2 supported by DDX */
+CARD8 dri2_minor;
+
+static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
+#define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
+
+static DevPrivateKeyRec dri2WindowPrivateKeyRec;
+#define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
+
+static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
+#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
+
+static RESTYPE dri2DrawableRes;
+
+typedef struct _DRI2Screen *DRI2ScreenPtr;
+
+typedef struct _DRI2Drawable {
+ DRI2ScreenPtr dri2_screen;
+ DrawablePtr drawable;
+ struct list reference_list;
+ int width;
+ int height;
+ DRI2BufferPtr *buffers;
+ int bufferCount;
+ unsigned int swapsPending;
+ ClientPtr blockedClient;
+ Bool blockedOnMsc;
+ int swap_interval;
+ CARD64 swap_count;
+ int64_t target_sbc; /* -1 means no SBC wait outstanding */
+ CARD64 last_swap_target; /* most recently queued swap target */
+ CARD64 last_swap_msc; /* msc at completion of most recent swap */
+ CARD64 last_swap_ust; /* ust at completion of most recent swap */
+ int swap_limit; /* for N-buffering */
+} DRI2DrawableRec, *DRI2DrawablePtr;
+
+typedef struct _DRI2Screen {
+ ScreenPtr screen;
+ int refcnt;
+ unsigned int numDrivers;
+ const char **driverNames;
+ const char *deviceName;
+ int fd;
+ unsigned int lastSequence;
+
+ DRI2CreateBufferProcPtr CreateBuffer;
+ DRI2DestroyBufferProcPtr DestroyBuffer;
+ DRI2CopyRegionProcPtr CopyRegion;
+ DRI2ScheduleSwapProcPtr ScheduleSwap;
+ DRI2GetMSCProcPtr GetMSC;
+ DRI2ScheduleWaitMSCProcPtr ScheduleWaitMSC;
+ DRI2AuthMagicProcPtr AuthMagic;
+
+ HandleExposuresProcPtr HandleExposures;
+
+ ConfigNotifyProcPtr ConfigNotify;
+} DRI2ScreenRec;
+
+static DRI2ScreenPtr
+DRI2GetScreen(ScreenPtr pScreen)
+{
+ return dixLookupPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey);
+}
+
+static DRI2DrawablePtr
+DRI2GetDrawable(DrawablePtr pDraw)
+{
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ switch (pDraw->type) {
+ case DRAWABLE_WINDOW:
+ pWin = (WindowPtr) pDraw;
+ return dixLookupPrivate(&pWin->devPrivates, dri2WindowPrivateKey);
+ case DRAWABLE_PIXMAP:
+ pPixmap = (PixmapPtr) pDraw;
+ return dixLookupPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey);
+ default:
+ return NULL;
+ }
+}
+
+static DRI2DrawablePtr
+DRI2AllocateDrawable(DrawablePtr pDraw)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ CARD64 ust;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+
+ pPriv = malloc(sizeof *pPriv);
+ if (pPriv == NULL)
+ return NULL;
+
+ pPriv->dri2_screen = ds;
+ pPriv->drawable = pDraw;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ pPriv->buffers = NULL;
+ pPriv->bufferCount = 0;
+ pPriv->swapsPending = 0;
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
+ pPriv->swap_count = 0;
+ pPriv->target_sbc = -1;
+ pPriv->swap_interval = 1;
+ /* Initialize last swap target from DDX if possible */
+ if (!ds->GetMSC || !(*ds->GetMSC)(pDraw, &ust, &pPriv->last_swap_target))
+ pPriv->last_swap_target = 0;
+
+ pPriv->swap_limit = 1; /* default to double buffering */
+ pPriv->last_swap_msc = 0;
+ pPriv->last_swap_ust = 0;
+ list_init(&pPriv->reference_list);
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, pPriv);
+ } else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, pPriv);
+ }
+
+ return pPriv;
+}
+
+typedef struct DRI2DrawableRefRec {
+ XID id;
+ XID dri2_id;
+ DRI2InvalidateProcPtr invalidate;
+ void *priv;
+ struct list link;
+} DRI2DrawableRefRec, *DRI2DrawableRefPtr;
+
+static DRI2DrawableRefPtr
+DRI2LookupDrawableRef(DRI2DrawablePtr pPriv, XID id)
+{
+ DRI2DrawableRefPtr ref;
+
+ list_for_each_entry(ref, &pPriv->reference_list, link) {
+ if (ref->id == id)
+ return ref;
+ }
+
+ return NULL;
+}
+
+static int
+DRI2AddDrawableRef(DRI2DrawablePtr pPriv, XID id, XID dri2_id,
+ DRI2InvalidateProcPtr invalidate, void *priv)
+{
+ DRI2DrawableRefPtr ref;
+
+ ref = malloc(sizeof *ref);
+ if (ref == NULL)
+ return BadAlloc;
+
+ if (!AddResource(dri2_id, dri2DrawableRes, pPriv))
+ return BadAlloc;
+ if (!DRI2LookupDrawableRef(pPriv, id))
+ if (!AddResource(id, dri2DrawableRes, pPriv))
+ return BadAlloc;
+
+ ref->id = id;
+ ref->dri2_id = dri2_id;
+ ref->invalidate = invalidate;
+ ref->priv = priv;
+ list_add(&ref->link, &pPriv->reference_list);
+
+ return Success;
+}
+
+int
+DRI2CreateDrawable(ClientPtr client, DrawablePtr pDraw, XID id,
+ DRI2InvalidateProcPtr invalidate, void *priv)
+{
+ DRI2DrawablePtr pPriv;
+ XID dri2_id;
+ int rc;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ pPriv = DRI2AllocateDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadAlloc;
+
+ dri2_id = FakeClientID(client->index);
+ rc = DRI2AddDrawableRef(pPriv, id, dri2_id, invalidate, priv);
+ if (rc != Success)
+ return rc;
+
+ return Success;
+}
+
+static int DRI2DrawableGone(pointer p, XID id)
+{
+ DRI2DrawablePtr pPriv = p;
+ DRI2ScreenPtr ds = pPriv->dri2_screen;
+ DRI2DrawableRefPtr ref, next;
+ WindowPtr pWin;
+ PixmapPtr pPixmap;
+ DrawablePtr pDraw;
+ int i;
+
+ list_for_each_entry_safe(ref, next, &pPriv->reference_list, link) {
+ if (ref->dri2_id == id) {
+ list_del(&ref->link);
+ /* If this was the last ref under this X drawable XID,
+ * unregister the X drawable resource. */
+ if (!DRI2LookupDrawableRef(pPriv, ref->id))
+ FreeResourceByType(ref->id, dri2DrawableRes, TRUE);
+ free(ref);
+ break;
+ }
+
+ if (ref->id == id) {
+ list_del(&ref->link);
+ FreeResourceByType(ref->dri2_id, dri2DrawableRes, TRUE);
+ free(ref);
+ }
+ }
+
+ if (!list_is_empty(&pPriv->reference_list))
+ return Success;
+
+ pDraw = pPriv->drawable;
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ pWin = (WindowPtr) pDraw;
+ dixSetPrivate(&pWin->devPrivates, dri2WindowPrivateKey, NULL);
+ } else {
+ pPixmap = (PixmapPtr) pDraw;
+ dixSetPrivate(&pPixmap->devPrivates, dri2PixmapPrivateKey, NULL);
+ }
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++)
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+
+ free(pPriv->buffers);
+ }
+
+ free(pPriv);
+
+ return Success;
+}
+
+static int
+find_attachment(DRI2DrawablePtr pPriv, unsigned attachment)
+{
+ int i;
+
+ if (pPriv->buffers == NULL) {
+ return -1;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if ((pPriv->buffers[i] != NULL)
+ && (pPriv->buffers[i]->attachment == attachment)) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
+static Bool
+allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
+ DRI2DrawablePtr pPriv,
+ unsigned int attachment, unsigned int format,
+ int dimensions_match, DRI2BufferPtr *buffer)
+{
+ int old_buf = find_attachment(pPriv, attachment);
+
+ if ((old_buf < 0)
+ || !dimensions_match
+ || (pPriv->buffers[old_buf]->format != format)) {
+ *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
+ return TRUE;
+
+ } else {
+ *buffer = pPriv->buffers[old_buf];
+ pPriv->buffers[old_buf] = NULL;
+ return FALSE;
+ }
+}
+
+static void
+update_dri2_drawable_buffers(DRI2DrawablePtr pPriv, DrawablePtr pDraw,
+ DRI2BufferPtr *buffers, int *out_count, int *width, int *height)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ int i;
+
+ if (pPriv->buffers != NULL) {
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i] != NULL) {
+ (*ds->DestroyBuffer)(pDraw, pPriv->buffers[i]);
+ }
+ }
+
+ free(pPriv->buffers);
+ }
+
+ pPriv->buffers = buffers;
+ pPriv->bufferCount = *out_count;
+ pPriv->width = pDraw->width;
+ pPriv->height = pDraw->height;
+ *width = pPriv->width;
+ *height = pPriv->height;
+}
+
+static DRI2BufferPtr *
+do_get_buffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count,
+ int has_format)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2BufferPtr *buffers;
+ int need_real_front = 0;
+ int need_fake_front = 0;
+ int have_fake_front = 0;
+ int front_format = 0;
+ int dimensions_match;
+ int buffers_changed = 0;
+ int i;
+
+ if (!pPriv) {
+ *width = pDraw->width;
+ *height = pDraw->height;
+ *out_count = 0;
+ return NULL;
+ }
+
+ dimensions_match = (pDraw->width == pPriv->width)
+ && (pDraw->height == pPriv->height);
+
+ buffers = malloc((count + 1) * sizeof(buffers[0]));
+
+ for (i = 0; i < count; i++) {
+ const unsigned attachment = *(attachments++);
+ const unsigned format = (has_format) ? *(attachments++) : 0;
+
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
+ format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ /* If the drawable is a window and the front-buffer is requested,
+ * silently add the fake front-buffer to the list of requested
+ * attachments. The counting logic in the loop accounts for the case
+ * where the client requests both the fake and real front-buffer.
+ */
+ if (attachment == DRI2BufferBackLeft) {
+ need_real_front++;
+ front_format = format;
+ }
+
+ if (attachment == DRI2BufferFrontLeft) {
+ need_real_front--;
+ front_format = format;
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ need_fake_front++;
+ }
+ }
+
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ if (attachment == DRI2BufferFakeFrontLeft) {
+ need_fake_front--;
+ have_fake_front = 1;
+ }
+ }
+ }
+
+ if (need_real_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+ i++;
+ }
+
+ if (need_fake_front > 0) {
+ if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
+ front_format, dimensions_match,
+ &buffers[i]))
+ buffers_changed = 1;
+
+ if (buffers[i] == NULL)
+ goto err_out;
+
+ i++;
+ have_fake_front = 1;
+ }
+
+ *out_count = i;
+
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);
+
+ /* If the client is getting a fake front-buffer, pre-fill it with the
+ * contents of the real front-buffer. This ensures correct operation of
+ * applications that call glXWaitX before calling glDrawBuffer.
+ */
+ if (have_fake_front && buffers_changed) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pPriv->width;
+ box.y2 = pPriv->height;
+ RegionInit(&region, &box, 0);
+
+ DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+ }
+
+ return pPriv->buffers;
+
+err_out:
+
+ *out_count = 0;
+
+ for (i = 0; i < count; i++) {
+ if (buffers[i] != NULL)
+ (*ds->DestroyBuffer)(pDraw, buffers[i]);
+ }
+
+ free(buffers);
+ buffers = NULL;
+
+ update_dri2_drawable_buffers(pPriv, pDraw, buffers, out_count, width, height);
+
+ return buffers;
+}
+
+DRI2BufferPtr *
+DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, FALSE);
+}
+
+DRI2BufferPtr *
+DRI2GetBuffersWithFormat(DrawablePtr pDraw, int *width, int *height,
+ unsigned int *attachments, int count, int *out_count)
+{
+ return do_get_buffers(pDraw, width, height, attachments, count,
+ out_count, TRUE);
+}
+
+static void
+DRI2InvalidateDrawable(DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
+ DRI2DrawableRefPtr ref;
+
+ if (!pPriv)
+ return;
+
+ list_for_each_entry(ref, &pPriv->reference_list, link)
+ ref->invalidate(pDraw, ref->priv);
+}
+
+/*
+ * In the direct rendered case, we throttle the clients that have more
+ * than their share of outstanding swaps (and thus busy buffers) when a
+ * new GetBuffers request is received. In the AIGLX case, we allow the
+ * client to get the new buffers, but throttle when the next GLX request
+ * comes in (see __glXDRIcontextWait()).
+ */
+Bool
+DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return FALSE;
+
+ /* Throttle to swap limit */
+ if ((pPriv->swapsPending >= pPriv->swap_limit) &&
+ !pPriv->blockedClient) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+__DRI2BlockClient(ClientPtr client, DRI2DrawablePtr pPriv)
+{
+ if (pPriv->blockedClient == NULL) {
+ IgnoreClient(client);
+ pPriv->blockedClient = client;
+ }
+}
+
+void
+DRI2BlockClient(ClientPtr client, DrawablePtr pDraw)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ __DRI2BlockClient(client, pPriv);
+ pPriv->blockedOnMsc = TRUE;
+}
+
+int
+DRI2CopyRegion(DrawablePtr pDraw, RegionPtr pRegion,
+ unsigned int dest, unsigned int src)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer, pSrcBuffer;
+ int i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ pDestBuffer = NULL;
+ pSrcBuffer = NULL;
+ for (i = 0; i < pPriv->bufferCount; i++)
+ {
+ if (pPriv->buffers[i]->attachment == dest)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == src)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL)
+ return BadValue;
+
+ (*ds->CopyRegion)(pDraw, pRegion, pDestBuffer, pSrcBuffer);
+
+ return Success;
+}
+
+/* Can this drawable be page flipped? */
+Bool
+DRI2CanFlip(DrawablePtr pDraw)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ WindowPtr pWin, pRoot;
+ PixmapPtr pWinPixmap, pRootPixmap;
+
+ if (pDraw->type == DRAWABLE_PIXMAP)
+ return TRUE;
+
+ pRoot = pScreen->root;
+ pRootPixmap = pScreen->GetWindowPixmap(pRoot);
+
+ pWin = (WindowPtr) pDraw;
+ pWinPixmap = pScreen->GetWindowPixmap(pWin);
+ if (pRootPixmap != pWinPixmap)
+ return FALSE;
+ if (!RegionEqual(&pWin->clipList, &pRoot->winSize))
+ return FALSE;
+
+ return TRUE;
+}
+
+/* Can we do a pixmap exchange instead of a blit? */
+Bool
+DRI2CanExchange(DrawablePtr pDraw)
+{
+ return FALSE;
+}
+
+void
+DRI2WaitMSCComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return;
+
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+
+ if (pPriv->blockedClient)
+ AttendClient(pPriv->blockedClient);
+
+ pPriv->blockedClient = NULL;
+ pPriv->blockedOnMsc = FALSE;
+}
+
+static void
+DRI2WakeClient(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /*
+ * Swap completed.
+ * Wake the client iff:
+ * - it was waiting on SBC
+ * - was blocked due to GLX make current
+ * - was blocked due to swap throttling
+ * - is not blocked due to an MSC wait
+ */
+ if (pPriv->target_sbc != -1 &&
+ pPriv->target_sbc <= pPriv->swap_count) {
+ ProcDRI2WaitMSCReply(client, ((CARD64)tv_sec * 1000000) + tv_usec,
+ frame, pPriv->swap_count);
+ pPriv->target_sbc = -1;
+
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ } else if (pPriv->target_sbc == -1 && !pPriv->blockedOnMsc) {
+ if (pPriv->blockedClient) {
+ AttendClient(pPriv->blockedClient);
+ pPriv->blockedClient = NULL;
+ }
+ }
+}
+
+void
+DRI2SwapComplete(ClientPtr client, DrawablePtr pDraw, int frame,
+ unsigned int tv_sec, unsigned int tv_usec, int type,
+ DRI2SwapEventPtr swap_complete, void *swap_data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2DrawablePtr pPriv;
+ CARD64 ust = 0;
+ BoxRec box;
+ RegionRec region;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ pPriv->swapsPending--;
+ pPriv->swap_count++;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(&region, &box, 0);
+ DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
+ DRI2BufferFrontLeft);
+
+ ust = ((CARD64)tv_sec * 1000000) + tv_usec;
+ if (swap_complete)
+ swap_complete(client, swap_data, type, ust, frame, pPriv->swap_count);
+
+ pPriv->last_swap_msc = frame;
+ pPriv->last_swap_ust = ust;
+
+ DRI2WakeClient(client, pDraw, frame, tv_sec, tv_usec);
+}
+
+Bool
+DRI2WaitSwap(ClientPtr client, DrawablePtr pDrawable)
+{
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ /* If we're currently waiting for a swap on this drawable, reset
+ * the request and suspend the client. We only support one
+ * blocked client per drawable. */
+ if ((pPriv->swapsPending) &&
+ pPriv->blockedClient == NULL) {
+ ResetCurrentRequest(client);
+ client->sequence--;
+ __DRI2BlockClient(client, pPriv);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+int
+DRI2SwapBuffers(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
+ DRI2SwapEventPtr func, void *data)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ DRI2BufferPtr pDestBuffer = NULL, pSrcBuffer = NULL;
+ int ret, i;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ for (i = 0; i < pPriv->bufferCount; i++) {
+ if (pPriv->buffers[i]->attachment == DRI2BufferFrontLeft)
+ pDestBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ if (pPriv->buffers[i]->attachment == DRI2BufferBackLeft)
+ pSrcBuffer = (DRI2BufferPtr) pPriv->buffers[i];
+ }
+ if (pSrcBuffer == NULL || pDestBuffer == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: drawable has no back or front?\n", __func__);
+ return BadDrawable;
+ }
+
+ /* Old DDX or no swap interval, just blit */
+ if (!ds->ScheduleSwap || !pPriv->swap_interval) {
+ BoxRec box;
+ RegionRec region;
+
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = pDraw->width;
+ box.y2 = pDraw->height;
+ RegionInit(&region, &box, 0);
+
+ pPriv->swapsPending++;
+
+ (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
+ DRI2SwapComplete(client, pDraw, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
+ func, data);
+ return Success;
+ }
+
+ /*
+ * In the simple glXSwapBuffers case, all params will be 0, and we just
+ * need to schedule a swap for the last swap target + the swap interval.
+ */
+ if (target_msc == 0 && divisor == 0 && remainder == 0) {
+ /*
+ * Swap target for this swap is last swap target + swap interval since
+ * we have to account for the current swap count, interval, and the
+ * number of pending swaps.
+ */
+ *swap_target = pPriv->last_swap_target + pPriv->swap_interval;
+ } else {
+ /* glXSwapBuffersMscOML could have a 0 target_msc, honor it */
+ *swap_target = target_msc;
+ }
+
+ pPriv->swapsPending++;
+ ret = (*ds->ScheduleSwap)(client, pDraw, pDestBuffer, pSrcBuffer,
+ swap_target, divisor, remainder, func, data);
+ if (!ret) {
+ pPriv->swapsPending--; /* didn't schedule */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: driver failed to schedule swap\n", __func__);
+ return BadDrawable;
+ }
+
+ pPriv->last_swap_target = *swap_target;
+
+ /* According to spec, return expected swapbuffers count SBC after this swap
+ * will complete.
+ */
+ *swap_target = pPriv->swap_count + pPriv->swapsPending;
+
+ DRI2InvalidateDrawable(pDraw);
+
+ return Success;
+}
+
+void
+DRI2SwapInterval(DrawablePtr pDrawable, int interval)
+{
+ ScreenPtr pScreen = pDrawable->pScreen;
+ DRI2DrawablePtr pPriv = DRI2GetDrawable(pDrawable);
+
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return;
+ }
+
+ /* fixme: check against arbitrary max? */
+ pPriv->swap_interval = interval;
+}
+
+int
+DRI2GetMSC(DrawablePtr pDraw, CARD64 *ust, CARD64 *msc, CARD64 *sbc)
+{
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[DRI2] %s: bad drawable\n", __func__);
+ return BadDrawable;
+ }
+
+ if (!ds->GetMSC) {
+ *ust = 0;
+ *msc = 0;
+ *sbc = pPriv->swap_count;
+ return Success;
+ }
+
+ /*
+ * Spec needs to be updated to include unmapped or redirected
+ * drawables
+ */
+
+ ret = (*ds->GetMSC)(pDraw, ust, msc);
+ if (!ret)
+ return BadDrawable;
+
+ *sbc = pPriv->swap_count;
+
+ return Success;
+}
+
+int
+DRI2WaitMSC(ClientPtr client, DrawablePtr pDraw, CARD64 target_msc,
+ CARD64 divisor, CARD64 remainder)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
+ DRI2DrawablePtr pPriv;
+ Bool ret;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* Old DDX just completes immediately */
+ if (!ds->ScheduleWaitMSC) {
+ DRI2WaitMSCComplete(client, pDraw, target_msc, 0, 0);
+
+ return Success;
+ }
+
+ ret = (*ds->ScheduleWaitMSC)(client, pDraw, target_msc, divisor, remainder);
+ if (!ret)
+ return BadDrawable;
+
+ return Success;
+}
+
+int
+DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw, CARD64 target_sbc)
+{
+ DRI2DrawablePtr pPriv;
+
+ pPriv = DRI2GetDrawable(pDraw);
+ if (pPriv == NULL)
+ return BadDrawable;
+
+ /* target_sbc == 0 means to block until all pending swaps are
+ * finished. Recalculate target_sbc to get that behaviour.
+ */
+ if (target_sbc == 0)
+ target_sbc = pPriv->swap_count + pPriv->swapsPending;
+
+ /* If current swap count already >= target_sbc, reply and
+ * return immediately with (ust, msc, sbc) triplet of
+ * most recent completed swap.
+ */
+ if (pPriv->swap_count >= target_sbc) {
+ ProcDRI2WaitMSCReply(client, pPriv->last_swap_ust,
+ pPriv->last_swap_msc, pPriv->swap_count);
+ return Success;
+ }
+
+ pPriv->target_sbc = target_sbc;
+ __DRI2BlockClient(client, pPriv);
+
+ return Success;
+}
+
+Bool
+DRI2HasSwapControl(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ return ds->ScheduleSwap && ds->GetMSC;
+}
+
+Bool
+DRI2Connect(ScreenPtr pScreen, unsigned int driverType, int *fd,
+ const char **driverName, const char **deviceName)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || driverType >= ds->numDrivers ||
+ !ds->driverNames[driverType])
+ return FALSE;
+
+ *fd = ds->fd;
+ *driverName = ds->driverNames[driverType];
+ *deviceName = ds->deviceName;
+
+ return TRUE;
+}
+
+Bool
+DRI2Authenticate(ScreenPtr pScreen, uint32_t magic)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ if (ds == NULL || (*ds->AuthMagic)(ds->fd, magic))
+ return FALSE;
+
+ return TRUE;
+}
+
+static int
+DRI2ConfigNotify(WindowPtr pWin, int x, int y, int w, int h, int bw,
+ WindowPtr pSib)
+{
+ DrawablePtr pDraw = (DrawablePtr)pWin;
+ ScreenPtr pScreen = pDraw->pScreen;
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+ DRI2DrawablePtr dd = DRI2GetDrawable(pDraw);
+ int ret;
+
+ if (ds->ConfigNotify) {
+ pScreen->ConfigNotify = ds->ConfigNotify;
+
+ ret = (*pScreen->ConfigNotify)(pWin, x, y, w, h, bw, pSib);
+
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+ if (ret)
+ return ret;
+ }
+
+ if (!dd || (dd->width == w && dd->height == h))
+ return Success;
+
+ DRI2InvalidateDrawable(pDraw);
+ return Success;
+}
+
+Bool
+DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
+{
+ DRI2ScreenPtr ds;
+ const char* driverTypeNames[] = {
+ "DRI", /* DRI2DriverDRI */
+ "VDPAU", /* DRI2DriverVDPAU */
+ };
+ unsigned int i;
+ CARD8 cur_minor;
+
+ if (info->version < 3)
+ return FALSE;
+
+ if (!xf86VGAarbiterAllowDRI(pScreen)) {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
+ return FALSE;
+ }
+
+ if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
+ return FALSE;
+
+ ds = calloc(1, sizeof *ds);
+ if (!ds)
+ return FALSE;
+
+ ds->screen = pScreen;
+ ds->fd = info->fd;
+ ds->deviceName = info->deviceName;
+ dri2_major = 1;
+
+ ds->CreateBuffer = info->CreateBuffer;
+ ds->DestroyBuffer = info->DestroyBuffer;
+ ds->CopyRegion = info->CopyRegion;
+
+ if (info->version >= 4) {
+ ds->ScheduleSwap = info->ScheduleSwap;
+ ds->ScheduleWaitMSC = info->ScheduleWaitMSC;
+ ds->GetMSC = info->GetMSC;
+ cur_minor = 3;
+ } else {
+ cur_minor = 1;
+ }
+
+ if (info->version >= 5) {
+ ds->AuthMagic = info->AuthMagic;
+ }
+
+ /*
+ * if the driver doesn't provide an AuthMagic function or the info struct
+ * version is too low, it relies on the old method (using libdrm) or fail
+ */
+ if (!ds->AuthMagic)
+#ifdef WITH_LIBDRM
+ ds->AuthMagic = drmAuthMagic;
+#else
+ goto err_out;
+#endif
+
+ /* Initialize minor if needed and set to minimum provied by DDX */
+ if (!dri2_minor || dri2_minor > cur_minor)
+ dri2_minor = cur_minor;
+
+ if (info->version == 3 || info->numDrivers == 0) {
+ /* Driver too old: use the old-style driverName field */
+ ds->numDrivers = 1;
+ ds->driverNames = malloc(sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ ds->driverNames[0] = info->driverName;
+ } else {
+ ds->numDrivers = info->numDrivers;
+ ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
+ if (!ds->driverNames)
+ goto err_out;
+ memcpy(ds->driverNames, info->driverNames,
+ info->numDrivers * sizeof(*ds->driverNames));
+ }
+
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, ds);
+
+ ds->ConfigNotify = pScreen->ConfigNotify;
+ pScreen->ConfigNotify = DRI2ConfigNotify;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
+ for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
+ if (i < ds->numDrivers && ds->driverNames[i]) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
+ driverTypeNames[i], ds->driverNames[i]);
+ }
+ }
+
+ return TRUE;
+
+err_out:
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[DRI2] Initialization failed for info version %d.\n", info->version);
+ free(ds);
+ return FALSE;
+}
+
+void
+DRI2CloseScreen(ScreenPtr pScreen)
+{
+ DRI2ScreenPtr ds = DRI2GetScreen(pScreen);
+
+ free(ds->driverNames);
+ free(ds);
+ dixSetPrivate(&pScreen->devPrivates, dri2ScreenPrivateKey, NULL);
+}
+
+extern ExtensionModule dri2ExtensionModule;
+
+static pointer
+DRI2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ dri2DrawableRes = CreateNewResourceType(DRI2DrawableGone, "DRI2Drawable");
+
+ if (!setupDone)
+ {
+ setupDone = TRUE;
+ LoadExtension(&dri2ExtensionModule, FALSE);
+ }
+ else
+ {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ }
+
+ return (pointer) 1;
+}
+
+static XF86ModuleVersionInfo DRI2VersRec =
+{
+ "dri2",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 1, 2, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ { 0, 0, 0, 0 }
+};
+
+_X_EXPORT XF86ModuleData dri2ModuleData = { &DRI2VersRec, DRI2Setup, NULL };
+
+void
+DRI2Version(int *major, int *minor)
+{
+ if (major != NULL)
+ *major = DRI2VersRec.majorversion;
+
+ if (minor != NULL)
+ *minor = DRI2VersRec.minorversion;
+}
diff --git a/xorg-server/hw/xfree86/dri2/dri2.h b/xorg-server/hw/xfree86/dri2/dri2.h
index c43aa6a04..afe2083de 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.h
+++ b/xorg-server/hw/xfree86/dri2/dri2.h
@@ -66,6 +66,8 @@ typedef void (*DRI2CopyRegionProcPtr)(DrawablePtr pDraw,
DRI2BufferPtr pSrcBuffer);
typedef void (*DRI2WaitProcPtr)(WindowPtr pWin,
unsigned int sequence);
+typedef int (*DRI2AuthMagicProcPtr)(int fd, uint32_t magic);
+
/**
* Schedule a buffer swap
*
@@ -159,7 +161,7 @@ typedef void (*DRI2InvalidateProcPtr)(DrawablePtr pDraw,
/**
* Version of the DRI2InfoRec structure defined in this header
*/
-#define DRI2INFOREC_VERSION 4
+#define DRI2INFOREC_VERSION 5
typedef struct {
unsigned int version; /**< Version of this struct */
@@ -183,6 +185,10 @@ typedef struct {
/* array of driver names, indexed by DRI2Driver* driver types */
/* a name of NULL means that driver is not supported */
const char * const *driverNames;
+
+ /* added in version 5 */
+
+ DRI2AuthMagicProcPtr AuthMagic;
} DRI2InfoRec, *DRI2InfoPtr;
extern _X_EXPORT int DRI2EventBase;
@@ -200,7 +206,7 @@ extern _X_EXPORT Bool DRI2Connect(ScreenPtr pScreen,
const char **driverName,
const char **deviceName);
-extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, drm_magic_t magic);
+extern _X_EXPORT Bool DRI2Authenticate(ScreenPtr pScreen, uint32_t magic);
extern _X_EXPORT int DRI2CreateDrawable(ClientPtr client,
DrawablePtr pDraw,
@@ -259,8 +265,7 @@ extern _X_EXPORT int DRI2WaitMSC(ClientPtr client, DrawablePtr pDrawable,
extern _X_EXPORT int ProcDRI2WaitMSCReply(ClientPtr client, CARD64 ust,
CARD64 msc, CARD64 sbc);
extern _X_EXPORT int DRI2WaitSBC(ClientPtr client, DrawablePtr pDraw,
- CARD64 target_sbc, CARD64 *ust, CARD64 *msc,
- CARD64 *sbc);
+ CARD64 target_sbc);
extern _X_EXPORT Bool DRI2ThrottleClient(ClientPtr client, DrawablePtr pDraw);
extern _X_EXPORT Bool DRI2CanFlip(DrawablePtr pDraw);
diff --git a/xorg-server/hw/xfree86/dri2/dri2ext.c b/xorg-server/hw/xfree86/dri2/dri2ext.c
index adbc9647b..6853fab9e 100644
--- a/xorg-server/hw/xfree86/dri2/dri2ext.c
+++ b/xorg-server/hw/xfree86/dri2/dri2ext.c
@@ -42,7 +42,6 @@
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "extnsionst.h"
-#include "xf86drm.h"
#include "xfixes.h"
#include "dri2.h"
#include "protocol-versions.h"
@@ -56,7 +55,9 @@ static Bool
validDrawable(ClientPtr client, XID drawable, Mask access_mode,
DrawablePtr *pDrawable, int *status)
{
- *status = dixLookupDrawable(pDrawable, drawable, client, 0, access_mode);
+ *status = dixLookupDrawable(pDrawable, drawable, client,
+ M_DRAWABLE_WINDOW | M_DRAWABLE_PIXMAP,
+ access_mode);
if (*status != Success) {
client->errorValue = drawable;
return FALSE;
@@ -521,9 +522,8 @@ static int
ProcDRI2WaitSBC(ClientPtr client)
{
REQUEST(xDRI2WaitSBCReq);
- xDRI2MSCReply rep;
DrawablePtr pDrawable;
- CARD64 target, ust, msc, sbc;
+ CARD64 target;
int status;
REQUEST_SIZE_MATCH(xDRI2WaitSBCReq);
@@ -533,18 +533,9 @@ ProcDRI2WaitSBC(ClientPtr client)
return status;
target = vals_to_card64(stuff->target_sbc_lo, stuff->target_sbc_hi);
- status = DRI2WaitSBC(client, pDrawable, target, &ust, &msc, &sbc);
- if (status != Success)
- return status;
+ status = DRI2WaitSBC(client, pDrawable, target);
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- load_msc_reply(&rep, ust, msc, sbc);
-
- WriteToClient(client, sizeof(xDRI2MSCReply), &rep);
-
- return Success;
+ return status;
}
static int
diff --git a/xorg-server/hw/xfree86/exa/examodule.c b/xorg-server/hw/xfree86/exa/examodule.c
index 6238582c0..356fd16ca 100644
--- a/xorg-server/hw/xfree86/exa/examodule.c
+++ b/xorg-server/hw/xfree86/exa/examodule.c
@@ -42,8 +42,8 @@ typedef struct _ExaXorgScreenPrivRec {
OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
-static int exaXorgScreenPrivateKeyIndex;
-static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKeyIndex;
+static DevPrivateKeyRec exaXorgScreenPrivateKeyRec;
+#define exaXorgScreenPrivateKey (&exaXorgScreenPrivateKeyRec)
typedef enum {
EXAOPT_MIGRATION_HEURISTIC,
@@ -114,6 +114,9 @@ exaDDXDriverInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv;
+ if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
+ return;
+
pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
return;
diff --git a/xorg-server/hw/xfree86/fbdevhw/Makefile.am b/xorg-server/hw/xfree86/fbdevhw/Makefile.am
index 066352556..076b9741f 100644
--- a/xorg-server/hw/xfree86/fbdevhw/Makefile.am
+++ b/xorg-server/hw/xfree86/fbdevhw/Makefile.am
@@ -1,28 +1,27 @@
-linuxmoduledir = $(moduledir)/linux
-linuxmodule_LTLIBRARIES = libfbdevhw.la
-
-libfbdevhw_la_LDFLAGS = -avoid-version
-
-if FBDEVHW
-libfbdevhw_la_SOURCES = fbdevhw.c
-else
-libfbdevhw_la_SOURCES = fbdevhwstub.c
-endif
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
-
-sdk_HEADERS = fbdevhw.h
-
-include $(top_srcdir)/cpprules.in
-
-drivermandir = $(DRIVER_MAN_DIR)
-driverman_DATA = fbdevhw.$(DRIVER_MAN_SUFFIX)
-CLEANFILES = $(driverman_DATA) fbdevhw.man
-
-fbdevhw.$(DRIVER_MAN_SUFFIX): fbdevhw.man
- -$(AM_V_at)rm -f fbdevhw.$(DRIVER_MAN_SUFFIX)
- $(AM_V_at)$(LN_S) fbdevhw.man fbdevhw.$(DRIVER_MAN_SUFFIX)
-
-EXTRA_DIST = fbpriv.h fbdevhw.man.pre README
+module_LTLIBRARIES = libfbdevhw.la
+
+libfbdevhw_la_LDFLAGS = -avoid-version
+
+if FBDEVHW
+libfbdevhw_la_SOURCES = fbdevhw.c
+else
+libfbdevhw_la_SOURCES = fbdevhwstub.c
+endif
+
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../i2c
+
+AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+
+sdk_HEADERS = fbdevhw.h
+
+include $(top_srcdir)/cpprules.in
+
+drivermandir = $(DRIVER_MAN_DIR)
+driverman_DATA = fbdevhw.$(DRIVER_MAN_SUFFIX)
+CLEANFILES = $(driverman_DATA) fbdevhw.man
+
+fbdevhw.$(DRIVER_MAN_SUFFIX): fbdevhw.man
+ -$(AM_V_at)rm -f fbdevhw.$(DRIVER_MAN_SUFFIX)
+ $(AM_V_at)$(LN_S) fbdevhw.man fbdevhw.$(DRIVER_MAN_SUFFIX)
+
+EXTRA_DIST = fbpriv.h fbdevhw.man.pre README
diff --git a/xorg-server/hw/xfree86/int10/Makefile.am b/xorg-server/hw/xfree86/int10/Makefile.am
index 36d2ad0bb..58e1d0f25 100644
--- a/xorg-server/hw/xfree86/int10/Makefile.am
+++ b/xorg-server/hw/xfree86/int10/Makefile.am
@@ -1,45 +1,46 @@
-module_LTLIBRARIES = libint10.la
-
-sdk_HEADERS = xf86int10.h
-
-EXTRA_CFLAGS =
-
-libint10_la_LDFLAGS = -avoid-version
-
-COMMON_SOURCES = \
- helper_exec.c \
- helper_mem.c \
- xf86int10.c \
- xf86int10module.c
-
-if I386_VIDEO
-I386_VIDEO_CFLAGS = -D_PC
-endif
-
-if INT10_VM86
-AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
-INCLUDES = $(XORG_INCS)
-libint10_la_SOURCES = \
- $(COMMON_SOURCES) \
- $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \
- $(srcdir)/../os-support/linux/int10/linux.c
-endif
-
-if INT10_X86EMU
-AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \
- $(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS)
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu
-libint10_la_SOURCES = \
- $(COMMON_SOURCES) \
- xf86x86emu.c \
- generic.c \
- x86emu.c
-endif
-
-if INT10_STUB
-AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
-INCLUDES = $(XORG_INCS)
-libint10_la_SOURCES = stub.c xf86int10module.c
-endif
-
-EXTRA_DIST = xf86x86emu.h INT10.HOWTO
+module_LTLIBRARIES = libint10.la
+
+sdk_HEADERS = xf86int10.h
+
+EXTRA_CFLAGS =
+
+libint10_la_LDFLAGS = -avoid-version
+libint10_la_LIBADD = $(PCIACCESS_LIBS)
+
+COMMON_SOURCES = \
+ helper_exec.c \
+ helper_mem.c \
+ xf86int10.c \
+ xf86int10module.c
+
+if I386_VIDEO
+I386_VIDEO_CFLAGS = -D_PC
+endif
+
+if INT10_VM86
+AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
+INCLUDES = $(XORG_INCS)
+libint10_la_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(srcdir)/../os-support/linux/int10/vm86/linux_vm86.c \
+ $(srcdir)/../os-support/linux/int10/linux.c
+endif
+
+if INT10_X86EMU
+AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_X86EMU -DNO_SYS_HEADERS \
+ $(XORG_CFLAGS) $(EXTRA_CFLAGS) $(DIX_CFLAGS)
+INCLUDES = $(XORG_INCS) -I$(srcdir)/../x86emu
+libint10_la_SOURCES = \
+ $(COMMON_SOURCES) \
+ xf86x86emu.c \
+ generic.c \
+ x86emu.c
+endif
+
+if INT10_STUB
+AM_CFLAGS = $(I386_VIDEO_CFLAGS) -D_VM86_LINUX $(DIX_CFLAGS) $(XORG_CFLAGS) $(EXTRA_CFLAGS)
+INCLUDES = $(XORG_INCS)
+libint10_la_SOURCES = stub.c xf86int10module.c
+endif
+
+EXTRA_DIST = xf86x86emu.h INT10.HOWTO
diff --git a/xorg-server/hw/xfree86/loader/loadext.c b/xorg-server/hw/xfree86/loader/loadext.c
index 26066856d..8380c300b 100644
--- a/xorg-server/hw/xfree86/loader/loadext.c
+++ b/xorg-server/hw/xfree86/loader/loadext.c
@@ -163,7 +163,7 @@ get_node(const char *name)
for (n = graph; n && n->n_name && strcmp(n->n_name, name);
n = n->n_next) ;
if (n)
- return (n);
+ return n;
n = xnfalloc(sizeof(NODE));
@@ -180,7 +180,7 @@ get_node(const char *name)
n->n_prevp = &graph;
graph = n;
- return (n);
+ return n;
}
/*
@@ -285,7 +285,7 @@ find_cycle(NODE * from, NODE * to, int longest_len, int depth)
* to be acyclic
*/
if (from->n_flags & (NF_NODEST | NF_MARK | NF_ACYCLIC))
- return (0);
+ return 0;
from->n_flags |= NF_MARK;
for (np = from->n_arcs, i = from->n_narcs; --i >= 0; np++) {
@@ -317,7 +317,7 @@ find_cycle(NODE * from, NODE * to, int longest_len, int depth)
}
}
from->n_flags &= ~NF_MARK;
- return (longest_len);
+ return longest_len;
}
/* do topological sort on graph */
@@ -378,10 +378,8 @@ tsort(void)
if (n == NULL)
ErrorF("tsort: internal error -- could not find cycle");
}
- if (cycle_buf)
- free(cycle_buf);
- if (longest_cycle)
- free(longest_cycle);
+ free(cycle_buf);
+ free(longest_cycle);
if (graph)
free_nodes(graph);
}
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index e75ec8f69..171f0521e 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -114,7 +114,7 @@ static char **defaultPathList = NULL;
static Bool
PathIsAbsolute(const char *path)
{
- return (*path == '/');
+ return *path == '/';
}
/*
@@ -315,16 +315,14 @@ InitSubdirs(const char **subdirlist)
if (**s == '/' || **s == '\\' || strchr(*s, ':') ||
strstr(*s, "..")) {
xf86Msg(X_ERROR, "InitSubdirs: Bad subdir: \"%s\"\n", *s);
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return NULL;
}
}
}
subdirs = malloc((i * 2 + 1) * sizeof(char *));
if (!subdirs) {
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return NULL;
}
i = 0;
@@ -348,8 +346,7 @@ InitSubdirs(const char **subdirlist)
while (--i >= 0)
free(subdirs[i]);
free(subdirs);
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return NULL;
}
/* tack on the OS name */
@@ -367,8 +364,7 @@ InitSubdirs(const char **subdirlist)
}
subdirs[i] = NULL;
}
- if (tmp_subdirlist)
- free(tmp_subdirlist);
+ free(tmp_subdirlist);
return (const char **)subdirs;
}
@@ -743,7 +739,7 @@ static ModuleDescPtr
AddSibling(ModuleDescPtr head, ModuleDescPtr new)
{
new->sib = head;
- return (new);
+ return new;
}
pointer
@@ -793,7 +789,7 @@ NewModuleDesc(const char *name)
mdp->TearDownData = NULL;
}
- return (mdp);
+ return mdp;
}
ModuleDescPtr
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index 5705d7da3..9c5b3c1ad 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -157,8 +157,7 @@ xf86CrtcDestroy (xf86CrtcPtr crtc)
xf86_config->num_crtc--;
break;
}
- if (crtc->params)
- free(crtc->params);
+ free(crtc->params);
free(crtc->gamma_red);
free(crtc);
}
@@ -382,8 +381,7 @@ done:
crtc->transformPresent = saved_transform_present;
}
- if (adjusted_mode->name)
- free(adjusted_mode->name);
+ free(adjusted_mode->name);
free(adjusted_mode);
if (didLock)
@@ -482,8 +480,7 @@ xf86OutputSetMonitor (xf86OutputPtr output)
if (!output->name)
return;
- if (output->options)
- free(output->options);
+ free(output->options);
output->options = xnfalloc (sizeof (xf86OutputOptions));
memcpy (output->options, xf86OutputOptions, sizeof (xf86OutputOptions));
@@ -580,7 +577,7 @@ xf86OutputInitialRotation (xf86OutputPtr output)
for (i = 0; i < 4; i++)
if (xf86nameCompare (direction[i], rotate_name) == 0)
- return (1 << i);
+ return 1 << i;
return RR_Rotate_0;
}
@@ -1041,8 +1038,8 @@ xf86DefaultScreenLimits (ScrnInfoPtr scrn, int *widthp, int *heightp,
if (crtc->enabled)
{
- crtc_width = crtc->x + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
- crtc_height = crtc->y + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
+ crtc_width = crtc->desiredX + xf86ModeWidth (&crtc->desiredMode, crtc->desiredRotation);
+ crtc_height = crtc->desiredY + xf86ModeHeight (&crtc->desiredMode, crtc->desiredRotation);
}
if (!canGrow) {
for (o = 0; o < config->num_output; o++)
@@ -2204,7 +2201,7 @@ xf86TargetFallback(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
target_rotation, width, height);
}
- return (target_mode != NULL);
+ return target_mode != NULL;
}
static Bool
@@ -3155,9 +3152,9 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
&crtc_box);
if (crtc) {
- REGION_INIT (pScreen, &crtc_region_local, &crtc_box, 1);
+ RegionInit(&crtc_region_local, &crtc_box, 1);
crtc_region = &crtc_region_local;
- REGION_INTERSECT (pScreen, crtc_region, crtc_region, reg);
+ RegionIntersect(crtc_region, crtc_region, reg);
}
*crtc_ret = crtc;
}
@@ -3166,7 +3163,7 @@ xf86_crtc_clip_video_helper(ScrnInfoPtr pScrn,
crtc_region, width, height);
if (crtc_region != reg)
- REGION_UNINIT (pScreen, &crtc_region_local);
+ RegionUninit(&crtc_region_local);
return ret;
}
@@ -3223,7 +3220,7 @@ xf86_crtc_supports_gamma(ScrnInfoPtr pScrn)
return FALSE;
crtc = xf86_config->crtc[0];
- return (crtc->funcs->gamma_set != NULL);
+ return crtc->funcs->gamma_set != NULL;
}
return FALSE;
diff --git a/xorg-server/hw/xfree86/modes/xf86DiDGA.c b/xorg-server/hw/xfree86/modes/xf86DiDGA.c
index 61c779edc..b2bbefa62 100644
--- a/xorg-server/hw/xfree86/modes/xf86DiDGA.c
+++ b/xorg-server/hw/xfree86/modes/xf86DiDGA.c
@@ -103,8 +103,7 @@ xf86_dga_get_modes (ScreenPtr pScreen)
if (display_mode == scrn->modes)
break;
}
- if (xf86_config->dga_modes)
- free(xf86_config->dga_modes);
+ free(xf86_config->dga_modes);
xf86_config->dga_nmode = num;
xf86_config->dga_modes = modes;
return TRUE;
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index 8a4d72bd6..e49387317 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -71,7 +71,7 @@ static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
static int xf86RandR12Generation;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
-static int xf86RandR12KeyIndex;
+static DevPrivateKeyRec xf86RandR12KeyRec;
static DevPrivateKey xf86RandR12Key;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
@@ -517,7 +517,7 @@ xf86RandR12SetMode (ScreenPtr pScreen,
int oldHeight = pScreen->height;
int oldmmWidth = pScreen->mmWidth;
int oldmmHeight = pScreen->mmHeight;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
DisplayModePtr currentMode = NULL;
Bool ret = TRUE;
PixmapPtr pspix = NULL;
@@ -685,7 +685,7 @@ xf86RandR12ScreenSetSize (ScreenPtr pScreen,
XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen);
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
PixmapPtr pScrnPix = (*pScreen->GetScreenPixmap)(pScreen);
Bool ret = FALSE;
int c;
@@ -739,7 +739,7 @@ finish:
if (pRoot && pScrn->vtSema)
(*pScrn->EnableDisableFBAccess) (pScreen->myNum, TRUE);
#if RANDR_12_INTERFACE
- if (xf86RandR12Key && WindowTable[pScreen->myNum] && ret)
+ if (xf86RandR12Key && pScreen->root && ret)
RRScreenSizeNotify (pScreen);
#endif
return ret;
@@ -883,7 +883,9 @@ xf86RandR12Init (ScreenPtr pScreen)
xf86RandR12Generation = serverGeneration;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
- xf86RandR12Key = &xf86RandR12KeyIndex;
+ xf86RandR12Key = &xf86RandR12KeyRec;
+ if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
#else
xf86RandR12Index = AllocateScreenPrivateIndex();
#endif
diff --git a/xorg-server/hw/xfree86/modes/xf86Rotate.c b/xorg-server/hw/xfree86/modes/xf86Rotate.c
index e15c61476..f846d60ea 100644
--- a/xorg-server/hw/xfree86/modes/xf86Rotate.c
+++ b/xorg-server/hw/xfree86/modes/xf86Rotate.c
@@ -76,13 +76,13 @@ xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
{
ScrnInfoPtr scrn = crtc->scrn;
ScreenPtr screen = scrn->pScreen;
- WindowPtr root = WindowTable[screen->myNum];
+ WindowPtr root = screen->root;
PixmapPtr dst_pixmap = crtc->rotatedPixmap;
- PictFormatPtr format = compWindowFormat (WindowTable[screen->myNum]);
+ PictFormatPtr format = compWindowFormat (screen->root);
int error;
PicturePtr src, dst;
- int n = REGION_NUM_RECTS(region);
- BoxPtr b = REGION_RECTS(region);
+ int n = RegionNumRects(region);
+ BoxPtr b = RegionRects(region);
XID include_inferiors = IncludeInferiors;
src = CreatePicture (None,
@@ -167,10 +167,10 @@ xf86CrtcDamageShadow (xf86CrtcPtr crtc)
if (damage_box.y1 < 0) damage_box.y1 = 0;
if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
- REGION_INIT (pScreen, &damage_region, &damage_box, 1);
+ RegionInit(&damage_region, &damage_box, 1);
DamageRegionAppend (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
&damage_region);
- REGION_UNINIT (pScreen, &damage_region);
+ RegionUninit(&damage_region);
crtc->shadowClear = TRUE;
}
@@ -217,7 +217,7 @@ xf86RotateRedisplay(ScreenPtr pScreen)
return FALSE;
xf86RotatePrepare (pScreen);
region = DamageRegion(damage);
- if (REGION_NOTEMPTY(pScreen, region))
+ if (RegionNotEmpty(region))
{
int c;
SourceValidateProcPtr SourceValidate;
@@ -240,14 +240,14 @@ xf86RotateRedisplay(ScreenPtr pScreen)
RegionRec crtc_damage;
/* compute portion of damage that overlaps crtc */
- REGION_INIT(pScreen, &crtc_damage, &crtc->bounds, 1);
- REGION_INTERSECT (pScreen, &crtc_damage, &crtc_damage, region);
+ RegionInit(&crtc_damage, &crtc->bounds, 1);
+ RegionIntersect(&crtc_damage, &crtc_damage, region);
/* update damaged region */
- if (REGION_NOTEMPTY(pScreen, &crtc_damage))
+ if (RegionNotEmpty(&crtc_damage))
xf86RotateCrtcRedisplay (crtc, &crtc_damage);
- REGION_UNINIT (pScreen, &crtc_damage);
+ RegionUninit(&crtc_damage);
}
}
pScreen->SourceValidate = SourceValidate;
@@ -405,8 +405,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
*/
xf86RotateDestroy (crtc);
crtc->transform_in_use = FALSE;
- if (new_params)
- free(new_params);
+ free(new_params);
new_params = NULL;
new_nparams = 0;
new_filter = NULL;
@@ -506,8 +505,7 @@ xf86CrtcRotate (xf86CrtcPtr crtc)
crtc->crtc_to_framebuffer = crtc_to_fb;
crtc->f_crtc_to_framebuffer = f_crtc_to_fb;
crtc->f_framebuffer_to_crtc = f_fb_to_crtc;
- if (crtc->params)
- free(crtc->params);
+ free(crtc->params);
crtc->params = new_params;
crtc->nparams = new_nparams;
crtc->filter = new_filter;
diff --git a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
index 18e1e0b67..7b5d2c7a4 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/alpha_video.c
@@ -1,719 +1,719 @@
-/*
- * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Rich Murphey and
- * David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-
-#include <sys/param.h>
-#ifndef __NetBSD__
-# include <sys/sysctl.h>
-# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-# include <machine/sysarch.h>
-# endif
-# else
-# include <machine/sysarch.h>
-#endif
-
-#include "xf86Axp.h"
-
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-#if defined(__NetBSD__) && !defined(MAP_FILE)
-#define MAP_FLAGS MAP_SHARED
-#else
-#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
-#endif
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
-axpDevice bsdGetAXP(void);
-
-#ifndef __NetBSD__
-extern unsigned long dense_base(void);
-
-static int axpSystem = -1;
-static unsigned long hae_thresh;
-static unsigned long hae_mask;
-static unsigned long bus_base;
-static unsigned long sparse_size;
-
-static unsigned long
-memory_base(void)
-{
- static unsigned long base = 0;
-
- if (base == 0) {
- size_t len = sizeof(base);
- int error;
-#ifdef __OpenBSD__
- int mib[3];
-
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_MEM;
-
- if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
-#else
- if ((error = sysctlbyname("hw.chipset.memory", &base, &len,
- 0, 0)) < 0)
-#endif
- FatalError("xf86MapVidMem: can't find memory\n");
- }
-
- return base;
-}
-
-static int
-has_bwx(void)
-{
- static int bwx = 0;
- size_t len = sizeof(bwx);
- int error;
-#ifdef __OpenBSD__
- int mib[3];
-
- mib[0] = CTL_MACHDEP;
- mib[1] = CPU_CHIPSET;
- mib[2] = CPU_CHIPSET_BWX;
-
- if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
- return FALSE;
- else
- return bwx;
-#else
- if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
- return FALSE;
- else
- return bwx;
-#endif
-}
-#else /* __NetBSD__ */
-static unsigned long hae_thresh = (1UL << 24);
-static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
-static struct alpha_bus_window *abw;
-static int abw_count = -1;
-
-static void
-init_abw(void)
-{
- if (abw_count < 0) {
- abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
- if (abw_count <= 0)
- FatalError("init_abw: alpha_bus_getwindows failed\n");
- }
-}
-
-static int
-has_bwx(void)
-{
- if (abw_count < 0)
- init_abw();
-
- xf86Msg(X_INFO, "has_bwx = %d\n",
- abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
- return abw[0].abw_abst.abst_flags & ABST_BWX;
-}
-
-static unsigned long
-dense_base(void)
-{
- if (abw_count < 0)
- init_abw();
-
- /* XXX check abst_flags for ABST_DENSE just to be safe? */
- xf86Msg(X_INFO, "dense base = %#lx\n",
- abw[0].abw_abst.abst_sys_start); /* XXXX */
- return abw[0].abw_abst.abst_sys_start;
-}
-
-static unsigned long
-memory_base(void)
-{
- if (abw_count < 0)
- init_abw();
-
- if (abw_count > 1) {
- xf86Msg(X_INFO, "memory base = %#lx\n",
- abw[1].abw_abst.abst_sys_start); /* XXXX */
- return abw[1].abw_abst.abst_sys_start;
- } else if (abw_count == 1) {
- /* assume memory_base == dense_base */
- xf86Msg(X_INFO, "memory base = %#lx\n",
- abw[0].abw_abst.abst_sys_start); /* XXXX */
- return abw[0].abw_abst.abst_sys_start;
- } else {
- xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
- return 0;
- }
-}
-#endif /* __NetBSD__ */
-
-#define BUS_BASE dense_base()
-#define BUS_BASE_BWX memory_base()
-
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
-
-#ifdef __OpenBSD__
-#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
- "\tin /etc/sysctl.conf and reboot your machine\n" \
- "\trefer to xf86(4) for details"
-#endif
-
-static Bool useDevMem = FALSE;
-static int devMemFd = -1;
-
-#ifdef HAS_APERTURE_DRV
-#define DEV_APERTURE "/dev/xf86"
-#endif
-#define DEV_MEM "/dev/mem"
-
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
-static void unmapVidMemSparse(int, pointer, unsigned long);
-
-/*
- * Check if /dev/mem can be mmap'd. If it can't print a warning when
- * "warn" is TRUE.
- */
-static void
-checkDevMem(Bool warn)
-{
- static Bool devMemChecked = FALSE;
- int fd;
- pointer base;
-
- if (devMemChecked)
- return;
- devMemChecked = TRUE;
-
-#ifdef HAS_APERTURE_DRV
- /* Try the aperture driver first */
- if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED) {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
- DEV_APERTURE);
- return;
- } else {
- if (warn) {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_APERTURE, strerror(errno));
- }
- }
- }
-#endif
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED) {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- return;
- } else {
- if (warn) {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- }
- }
- if (warn) {
-#ifndef HAS_APERTURE_DRV
- xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
-#else
-#ifndef __OpenBSD__
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
-#else /* __OpenBSD__ */
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
- "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
- SYSCTL_MSG);
-#endif /* __OpenBSD__ */
-#endif
- xf86ErrorF("\tlinear framebuffer access unavailable\n");
- }
- useDevMem = FALSE;
- return;
-}
-
-void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
- checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
-
- if (has_bwx()) {
- xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n");
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
- } else {
- xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
- pVidMem->mapMem = mapVidMemSparse;
- pVidMem->unmapMem = unmapVidMemSparse;
-#ifndef __NetBSD__
- if (axpSystem == -1)
- axpSystem = bsdGetAXP();
- hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
- hae_mask = xf86AXPParams[axpSystem].hae_mask;
- sparse_size = xf86AXPParams[axpSystem].size;
-#endif /* __NetBSD__ */
- }
- pVidMem->initialised = TRUE;
-}
-
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- pointer base;
-
- checkDevMem(FALSE);
- Base = Base & ((1L<<32) - 1);
-
- if (useDevMem)
- {
- if (devMemFd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
- if (base == MAP_FAILED)
- {
- FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
- "xf86MapVidMem", DEV_MEM, Size, Base,
- strerror(errno));
- }
- return(base);
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
- {
- FatalError("%s: Address 0x%lx outside allowable range\n",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.screenFd,
- (unsigned long)Base + BUS_BASE);
- if (base == MAP_FAILED)
- {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return(base);
-}
-
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- munmap((caddr_t)Base, Size);
-}
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return(-1);
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
- if ((long)ptr == -1)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return(-1);
- }
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
-#endif
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
- return(Len);
-}
-
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
-
-extern int ioperm(unsigned long from, unsigned long num, int on);
-
-Bool
-xf86EnableIO()
-{
- if (!ioperm(0, 65536, TRUE))
- return TRUE;
- return FALSE;
-}
-
-void
-xf86DisableIO()
-{
- return;
-}
-
-#endif /* __FreeBSD_kernel__ || __OpenBSD__ */
-
-#ifdef USE_ALPHA_PIO
-
-Bool
-xf86EnableIO()
-{
- alpha_pci_io_enable(1);
- return TRUE;
-}
-
-void
-xf86DisableIO()
-{
- alpha_pci_io_enable(0);
-}
-
-#endif /* USE_ALPHA_PIO */
-
-#define vuip volatile unsigned int *
-
-static unsigned long msb_set = 0;
-static pointer memSBase = 0;
-static pointer memBase = 0;
-
-extern int readDense8(pointer Base, register unsigned long Offset);
-extern int readDense16(pointer Base, register unsigned long Offset);
-extern int readDense32(pointer Base, register unsigned long Offset);
-extern void
-writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
-extern void
-writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
-extern void
-writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
-extern void
-writeDense8(int Value, pointer Base, register unsigned long Offset);
-extern void
-writeDense16(int Value, pointer Base, register unsigned long Offset);
-extern void
-writeDense32(int Value, pointer Base, register unsigned long Offset);
-
-static int readSparse8(pointer Base, register unsigned long Offset);
-static int readSparse16(pointer Base, register unsigned long Offset);
-static int readSparse32(pointer Base, register unsigned long Offset);
-static void
-writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
-static void
-writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
-static void
-writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
-static void
-writeSparse8(int Value, pointer Base, register unsigned long Offset);
-static void
-writeSparse16(int Value, pointer Base, register unsigned long Offset);
-static void
-writeSparse32(int Value, pointer Base, register unsigned long Offset);
-
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-extern int sysarch(int, void *);
-#endif
-
-struct parms {
- u_int64_t hae;
-};
-
-#ifndef __NetBSD__
-static int
-sethae(u_int64_t hae)
-{
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
-#ifndef ALPHA_SETHAE
-#define ALPHA_SETHAE 0
-#endif
- struct parms p;
- p.hae = hae;
- return (sysarch(ALPHA_SETHAE, (char *)&p));
-#endif
-#ifdef __OpenBSD__
- return -1;
-#endif
-}
-#endif /* __NetBSD__ */
-
-static pointer
-mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- static Bool was_here = FALSE;
-
- if (!was_here) {
- was_here = TRUE;
-
- checkDevMem(FALSE);
-
- xf86WriteMmio8 = writeSparse8;
- xf86WriteMmio16 = writeSparse16;
- xf86WriteMmio32 = writeSparse32;
- xf86WriteMmioNB8 = writeSparseNB8;
- xf86WriteMmioNB16 = writeSparseNB16;
- xf86WriteMmioNB32 = writeSparseNB32;
- xf86ReadMmio8 = readSparse8;
- xf86ReadMmio16 = readSparse16;
- xf86ReadMmio32 = readSparse32;
-
- memBase = mmap((caddr_t)0, 0x100000000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, devMemFd,
- (off_t) BUS_BASE);
- memSBase = mmap((caddr_t)0, 0x100000000,
- PROT_READ | PROT_WRITE,
- MAP_SHARED, devMemFd,
- (off_t) BUS_BASE_BWX);
-
- if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
- FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
- strerror(errno));
- }
- }
- return (pointer)((unsigned long)memBase + Base);
-}
-
-static void
-unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
-{
-}
-
-static int
-readSparse8(pointer Base, register unsigned long Offset)
-{
- register unsigned long result, shift;
- register unsigned long msb;
- mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
- shift = (Offset & 0x3) << 3;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
-#ifndef __NetBSD__
- sethae(msb);
-#endif
- msb_set = msb;
- }
- }
- result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
- result >>= shift;
- return 0xffUL & result;
-}
-
-static int
-readSparse16(pointer Base, register unsigned long Offset)
-{
- register unsigned long result, shift;
- register unsigned long msb;
-
- mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
- shift = (Offset & 0x2) << 3;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
-#ifndef __NetBSD__
- sethae(msb);
-#endif
- msb_set = msb;
- }
- }
- result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2)));
- result >>= shift;
- return 0xffffUL & result;
-}
-
-static int
-readSparse32(pointer Base, register unsigned long Offset)
-{
- mem_barrier();
- return *(vuip)((unsigned long)Base+(Offset));
-}
-
-static void
-writeSparse8(int Value, pointer Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int b = Value & 0xffU;
-
- write_mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
-#ifndef __NetBSD__
- sethae(msb);
-#endif
- msb_set = msb;
- }
- }
- *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparse16(int Value, pointer Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int w = Value & 0xffffU;
-
- write_mem_barrier();
- Offset += (unsigned long)Base - (unsigned long)memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
-#ifndef __NetBSD__
- sethae(msb);
-#endif
- msb_set = msb;
- }
- }
- *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
- w * 0x00010001;
-
-}
-
-static void
-writeSparse32(int Value, pointer Base, register unsigned long Offset)
-{
- write_mem_barrier();
- *(vuip)((unsigned long)Base + (Offset)) = Value;
- return;
-}
-
-static void
-writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int b = Value & 0xffU;
-
- Offset += (unsigned long)Base - (unsigned long)memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask;
- Offset -= msb;
- if (msb_set != msb) {
-#ifndef __NetBSD__
- sethae(msb);
-#endif
- msb_set = msb;
- }
- }
- *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
-}
-
-static void
-writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
-{
- register unsigned long msb;
- register unsigned int w = Value & 0xffffU;
-
- Offset += (unsigned long)Base - (unsigned long)memBase;
- if (Offset >= (hae_thresh)) {
- msb = Offset & hae_mask ;
- Offset -= msb;
- if (msb_set != msb) {
-#ifndef __NetBSD__
- sethae(msb);
-#endif
- msb_set = msb;
- }
- }
- *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
- w * 0x00010001;
-}
-
-static void
-writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
-{
- *(vuip)((unsigned long)Base + (Offset)) = Value;
- return;
-}
-
-void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
- = writeDense8;
-void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
- = writeDense16;
-void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
- = writeDense32;
-void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB8;
-void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB16;
-void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
- = writeDenseNB32;
-int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
- = readDense8;
-int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
- = readDense16;
-int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
- = readDense32;
-
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include <sys/param.h>
+#ifndef __NetBSD__
+# include <sys/sysctl.h>
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+# include <machine/sysarch.h>
+# endif
+# else
+# include <machine/sysarch.h>
+#endif
+
+#include "xf86Axp.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+axpDevice bsdGetAXP(void);
+
+#ifndef __NetBSD__
+extern unsigned long dense_base(void);
+
+static int axpSystem = -1;
+static unsigned long hae_thresh;
+static unsigned long hae_mask;
+static unsigned long bus_base;
+static unsigned long sparse_size;
+
+static unsigned long
+memory_base(void)
+{
+ static unsigned long base = 0;
+
+ if (base == 0) {
+ size_t len = sizeof(base);
+ int error;
+#ifdef __OpenBSD__
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_MEM;
+
+ if ((error = sysctl(mib, 3, &base, &len, NULL, 0)) < 0)
+#else
+ if ((error = sysctlbyname("hw.chipset.memory", &base, &len,
+ 0, 0)) < 0)
+#endif
+ FatalError("xf86MapVidMem: can't find memory\n");
+ }
+
+ return base;
+}
+
+static int
+has_bwx(void)
+{
+ static int bwx = 0;
+ size_t len = sizeof(bwx);
+ int error;
+#ifdef __OpenBSD__
+ int mib[3];
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_CHIPSET;
+ mib[2] = CPU_CHIPSET_BWX;
+
+ if ((error = sysctl(mib, 3, &bwx, &len, NULL, 0)) < 0)
+ return FALSE;
+ else
+ return bwx;
+#else
+ if ((error = sysctlbyname("hw.chipset.bwx", &bwx, &len, 0, 0)) < 0)
+ return FALSE;
+ else
+ return bwx;
+#endif
+}
+#else /* __NetBSD__ */
+static unsigned long hae_thresh = (1UL << 24);
+static unsigned long hae_mask = 0xf8000000UL; /* XXX - should use xf86AXP.c */
+static struct alpha_bus_window *abw;
+static int abw_count = -1;
+
+static void
+init_abw(void)
+{
+ if (abw_count < 0) {
+ abw_count = alpha_bus_getwindows(ALPHA_BUS_TYPE_PCI_MEM, &abw);
+ if (abw_count <= 0)
+ FatalError("init_abw: alpha_bus_getwindows failed\n");
+ }
+}
+
+static int
+has_bwx(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ xf86Msg(X_INFO, "has_bwx = %d\n",
+ abw[0].abw_abst.abst_flags & ABST_BWX ? 1 : 0); /* XXXX */
+ return abw[0].abw_abst.abst_flags & ABST_BWX;
+}
+
+static unsigned long
+dense_base(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ /* XXX check abst_flags for ABST_DENSE just to be safe? */
+ xf86Msg(X_INFO, "dense base = %#lx\n",
+ abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
+}
+
+static unsigned long
+memory_base(void)
+{
+ if (abw_count < 0)
+ init_abw();
+
+ if (abw_count > 1) {
+ xf86Msg(X_INFO, "memory base = %#lx\n",
+ abw[1].abw_abst.abst_sys_start); /* XXXX */
+ return abw[1].abw_abst.abst_sys_start;
+ } else if (abw_count == 1) {
+ /* assume memory_base == dense_base */
+ xf86Msg(X_INFO, "memory base = %#lx\n",
+ abw[0].abw_abst.abst_sys_start); /* XXXX */
+ return abw[0].abw_abst.abst_sys_start;
+ } else {
+ xf86Msg(X_INFO, "no memory base\n"); /* XXXX */
+ return 0;
+ }
+}
+#endif /* __NetBSD__ */
+
+#define BUS_BASE dense_base()
+#define BUS_BASE_BWX memory_base()
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+#ifdef __OpenBSD__
+#define SYSCTL_MSG "\tCheck that you have set 'machdep.allowaperture=1'\n"\
+ "\tin /etc/sysctl.conf and reboot your machine\n" \
+ "\trefer to xf86(4) for details"
+#endif
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#ifdef HAS_APERTURE_DRV
+#define DEV_APERTURE "/dev/xf86"
+#endif
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+static pointer mapVidMemSparse(int, unsigned long, unsigned long, int);
+static void unmapVidMemSparse(int, pointer, unsigned long);
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+#ifdef HAS_APERTURE_DRV
+ /* Try the aperture driver first */
+ if ((fd = open(DEV_APERTURE, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ xf86Msg(X_INFO, "checkDevMem: using aperture driver %s\n",
+ DEV_APERTURE);
+ return;
+ } else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_APERTURE, strerror(errno));
+ }
+ }
+ }
+#endif
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0) {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED) {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ if (warn) {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ }
+ }
+ if (warn) {
+#ifndef HAS_APERTURE_DRV
+ xf86Msg(X_WARNING, "checkDevMem: failed to open/mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+#else
+#ifndef __OpenBSD__
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n", DEV_APERTURE, DEV_MEM, strerror(errno));
+#else /* __OpenBSD__ */
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s and %s\n"
+ "\t(%s)\n%s", DEV_APERTURE, DEV_MEM, strerror(errno),
+ SYSCTL_MSG);
+#endif /* __OpenBSD__ */
+#endif
+ xf86ErrorF("\tlinear framebuffer access unavailable\n");
+ }
+ useDevMem = FALSE;
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+
+ if (has_bwx()) {
+ xf86Msg(X_PROBED,"Machine type has 8/16 bit access\n");
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+ } else {
+ xf86Msg(X_PROBED,"Machine needs sparse mapping\n");
+ pVidMem->mapMem = mapVidMemSparse;
+ pVidMem->unmapMem = unmapVidMemSparse;
+#ifndef __NetBSD__
+ if (axpSystem == -1)
+ axpSystem = bsdGetAXP();
+ hae_thresh = xf86AXPParams[axpSystem].hae_thresh;
+ hae_mask = xf86AXPParams[axpSystem].hae_mask;
+ sparse_size = xf86AXPParams[axpSystem].size;
+#endif /* __NetBSD__ */
+ }
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+ Base = Base & ((1L<<32) - 1);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%lx,a=%lx] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%lx outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base + BUS_BASE);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return base;
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%lx,o=%lx] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return -1;
+ }
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return Len;
+}
+
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+
+extern int ioperm(unsigned long from, unsigned long num, int on);
+
+Bool
+xf86EnableIO()
+{
+ if (!ioperm(0, 65536, TRUE))
+ return TRUE;
+ return FALSE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+#endif /* __FreeBSD_kernel__ || __OpenBSD__ */
+
+#ifdef USE_ALPHA_PIO
+
+Bool
+xf86EnableIO()
+{
+ alpha_pci_io_enable(1);
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ alpha_pci_io_enable(0);
+}
+
+#endif /* USE_ALPHA_PIO */
+
+#define vuip volatile unsigned int *
+
+static unsigned long msb_set = 0;
+static pointer memSBase = 0;
+static pointer memBase = 0;
+
+extern int readDense8(pointer Base, register unsigned long Offset);
+extern int readDense16(pointer Base, register unsigned long Offset);
+extern int readDense32(pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDenseNB32(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense8(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense16(int Value, pointer Base, register unsigned long Offset);
+extern void
+writeDense32(int Value, pointer Base, register unsigned long Offset);
+
+static int readSparse8(pointer Base, register unsigned long Offset);
+static int readSparse16(pointer Base, register unsigned long Offset);
+static int readSparse32(pointer Base, register unsigned long Offset);
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset);
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset);
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+extern int sysarch(int, void *);
+#endif
+
+struct parms {
+ u_int64_t hae;
+};
+
+#ifndef __NetBSD__
+static int
+sethae(u_int64_t hae)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#ifndef ALPHA_SETHAE
+#define ALPHA_SETHAE 0
+#endif
+ struct parms p;
+ p.hae = hae;
+ return (sysarch(ALPHA_SETHAE, (char *)&p));
+#endif
+#ifdef __OpenBSD__
+ return -1;
+#endif
+}
+#endif /* __NetBSD__ */
+
+static pointer
+mapVidMemSparse(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ static Bool was_here = FALSE;
+
+ if (!was_here) {
+ was_here = TRUE;
+
+ checkDevMem(FALSE);
+
+ xf86WriteMmio8 = writeSparse8;
+ xf86WriteMmio16 = writeSparse16;
+ xf86WriteMmio32 = writeSparse32;
+ xf86WriteMmioNB8 = writeSparseNB8;
+ xf86WriteMmioNB16 = writeSparseNB16;
+ xf86WriteMmioNB32 = writeSparseNB32;
+ xf86ReadMmio8 = readSparse8;
+ xf86ReadMmio16 = readSparse16;
+ xf86ReadMmio32 = readSparse32;
+
+ memBase = mmap((caddr_t)0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd,
+ (off_t) BUS_BASE);
+ memSBase = mmap((caddr_t)0, 0x100000000,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED, devMemFd,
+ (off_t) BUS_BASE_BWX);
+
+ if (memSBase == MAP_FAILED || memBase == MAP_FAILED) {
+ FatalError("xf86MapVidMem: Could not mmap framebuffer (%s)\n",
+ strerror(errno));
+ }
+ }
+ return (pointer)((unsigned long)memBase + Base);
+}
+
+static void
+unmapVidMemSparse(int ScreenNum, pointer Base, unsigned long Size)
+{
+}
+
+static int
+readSparse8(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+ mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ shift = (Offset & 0x3) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ result = *(vuip) ((unsigned long)memSBase + (Offset << 5));
+ result >>= shift;
+ return 0xffUL & result;
+}
+
+static int
+readSparse16(pointer Base, register unsigned long Offset)
+{
+ register unsigned long result, shift;
+ register unsigned long msb;
+
+ mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ shift = (Offset & 0x2) << 3;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ result = *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2)));
+ result >>= shift;
+ return 0xffffUL & result;
+}
+
+static int
+readSparse32(pointer Base, register unsigned long Offset)
+{
+ mem_barrier();
+ return *(vuip)((unsigned long)Base+(Offset));
+}
+
+static void
+writeSparse8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparse16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ write_mem_barrier();
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
+ w * 0x00010001;
+
+}
+
+static void
+writeSparse32(int Value, pointer Base, register unsigned long Offset)
+{
+ write_mem_barrier();
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+static void
+writeSparseNB8(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int b = Value & 0xffU;
+
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip) ((unsigned long)memSBase + (Offset << 5)) = b * 0x01010101;
+}
+
+static void
+writeSparseNB16(int Value, pointer Base, register unsigned long Offset)
+{
+ register unsigned long msb;
+ register unsigned int w = Value & 0xffffU;
+
+ Offset += (unsigned long)Base - (unsigned long)memBase;
+ if (Offset >= (hae_thresh)) {
+ msb = Offset & hae_mask ;
+ Offset -= msb;
+ if (msb_set != msb) {
+#ifndef __NetBSD__
+ sethae(msb);
+#endif
+ msb_set = msb;
+ }
+ }
+ *(vuip)((unsigned long)memSBase+(Offset<<5)+(1<<(5-2))) =
+ w * 0x00010001;
+}
+
+static void
+writeSparseNB32(int Value, pointer Base, register unsigned long Offset)
+{
+ *(vuip)((unsigned long)Base + (Offset)) = Value;
+ return;
+}
+
+void (*xf86WriteMmio8)(int Value, pointer Base, unsigned long Offset)
+ = writeDense8;
+void (*xf86WriteMmio16)(int Value, pointer Base, unsigned long Offset)
+ = writeDense16;
+void (*xf86WriteMmio32)(int Value, pointer Base, unsigned long Offset)
+ = writeDense32;
+void (*xf86WriteMmioNB8)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB8;
+void (*xf86WriteMmioNB16)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB16;
+void (*xf86WriteMmioNB32)(int Value, pointer Base, unsigned long Offset)
+ = writeDenseNB32;
+int (*xf86ReadMmio8)(pointer Base, unsigned long Offset)
+ = readDense8;
+int (*xf86ReadMmio16)(pointer Base, unsigned long Offset)
+ = readDense16;
+int (*xf86ReadMmio32)(pointer Base, unsigned long Offset)
+ = readDense32;
+
diff --git a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
index 466a8a0db..10cfee764 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/arm_video.c
@@ -1,666 +1,666 @@
-/*
- * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Rich Murphey and
- * David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-/*
- * The ARM32 code here carries the following copyright:
- *
- * Copyright 1997
- * Digital Equipment Corporation. All rights reserved.
- * This software is furnished under license and may be used and copied only in
- * accordance with the following terms and conditions. Subject to these
- * conditions, you may download, copy, install, use, modify and distribute
- * this software in source and/or binary form. No title or ownership is
- * transferred hereby.
- *
- * 1) Any source code used, modified or distributed must reproduce and retain
- * this copyright notice and list of conditions as they appear in the
- * source file.
- *
- * 2) No right is granted to use any trade name, trademark, or logo of Digital
- * Equipment Corporation. Neither the "Digital Equipment Corporation"
- * name nor any trademark or logo of Digital Equipment Corporation may be
- * used to endorse or promote products derived from this software without
- * the prior written permission of Digital Equipment Corporation.
- *
- * 3) This software is provided "AS-IS" and any express or implied warranties,
- * including but not limited to, any implied warranties of merchantability,
- * fitness for a particular purpose, or non-infringement are disclaimed.
- * In no event shall DIGITAL be liable for any damages whatsoever, and in
- * particular, DIGITAL shall not be liable for special, indirect,
- * consequential, or incidental damages or damages for lost profits, loss
- * of revenue or loss of use, whether such damages arise in contract,
- * negligence, tort, under statute, in equity, at law or otherwise, even
- * if advised of the possibility of such damage.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-#ifdef __arm32__
-#include "machine/devmap.h"
-struct memAccess
-{
- int ioctl;
- struct map_info memInfo;
- pointer regionVirtBase;
- Bool Checked;
- Bool OK;
-};
-
-static pointer xf86MapInfoMap();
-static void xf86MapInfoUnmap();
-static struct memAccess *checkMapInfo();
-extern int vgaPhysLinearBase;
-
-/* A memAccess structure is needed for each possible region */
-struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
- FALSE, FALSE };
-struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
- FALSE, FALSE };
-struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
- FALSE, FALSE };
-#endif /* __arm32__ */
-
-#if defined(__NetBSD__) && !defined(MAP_FILE)
-#define MAP_FLAGS MAP_SHARED
-#else
-#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
-#endif
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
-
-#define BUS_BASE 0L
-#define BUS_BASE_BWX 0L
-
-
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
-
-static Bool useDevMem = FALSE;
-static int devMemFd = -1;
-
-#define DEV_MEM "/dev/mem"
-
-static pointer mapVidMem(int, unsigned long, unsigned long, int);
-static void unmapVidMem(int, pointer, unsigned long);
-
-/*
- * Check if /dev/mem can be mmap'd. If it can't print a warning when
- * "warn" is TRUE.
- */
-static void
-checkDevMem(Bool warn)
-{
- static Bool devMemChecked = FALSE;
- int fd;
- pointer base;
-
- if (devMemChecked)
- return;
- devMemChecked = TRUE;
-
- if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
- {
- /* Try to map a page at the VGA address */
- base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
-
- if (base != MAP_FAILED)
- {
- munmap((caddr_t)base, 4096);
- devMemFd = fd;
- useDevMem = TRUE;
- return;
- } else {
- /* This should not happen */
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
- }
- }
- if (warn)
- {
- xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- useDevMem = FALSE;
- return;
-}
-
-void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
-
- checkDevMem(TRUE);
- pVidMem->linearSupported = useDevMem;
- pVidMem->mapMem = armMapVidMem;
- pVidMem->unmapVidMem = armUnmapVidMem;
-
- pVidMem->initialised = TRUE;
-}
-
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- pointer base;
-
- checkDevMem(FALSE);
-
- if (useDevMem)
- {
- if (devMemFd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
- if (base == MAP_FAILED)
- {
- FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
- "xf86MapVidMem", DEV_MEM, Size, Base,
- strerror(errno));
- }
- return(base);
- }
-
- /* else, mmap /dev/vga */
- if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
- {
- FatalError("%s: Address 0x%x outside allowable range\n",
- "xf86MapVidMem", Base);
- }
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_FLAGS, xf86Info.screenFd,
- (unsigned long)Base - 0xA0000);
- if (base == MAP_FAILED)
- {
- FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
- strerror(errno));
- }
- return(base);
-}
-
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- munmap((caddr_t)Base, Size);
-}
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- unsigned char *ptr;
- int psize;
- int mlen;
-
- checkDevMem(TRUE);
- if (devMemFd == -1) {
- return(-1);
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
- if ((long)ptr == -1)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
- DEV_MEM, Len, Base, Offset, strerror(errno));
- return(-1);
- }
-#ifdef DEBUG
- ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
-#endif
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
- "-> %02x %02x %02x %02x...\n",
- Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
-#endif
- return(Len);
-}
-
-
-/* XXX This needs to be updated for the ND */
-
-/*
-** Find out whether the console driver provides memory mapping information
-** for the specified region and return the map_info pointer. Print a warning if required.
-*/
-static struct memAccess *
-checkMapInfo(Bool warn, int Region)
-{
- struct memAccess *memAccP;
-
- switch (Region)
- {
- case VGA_REGION:
- memAccP = &vgaMemInfo;
- break;
-
- case LINEAR_REGION:
- memAccP = &linearMemInfo;
- break;
-
- case MMIO_REGION:
- memAccP = &ioMemInfo;
- break;
-
- default:
- return NULL;
- break;
- }
-
- if(!memAccP->Checked)
- {
- if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1)
- {
- if(warn)
- {
- xf86Msg(X_WARNING,
- "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
- Region, strerror(errno));
- }
- }
- else
- {
- if(memAccP->memInfo.u.map_info_mmap.map_offset
- != MAP_INFO_UNKNOWN)
- memAccP->OK = TRUE;
- }
- memAccP->Checked = TRUE;
- }
- if (memAccP->OK)
- {
- return memAccP;
- }
- else
- {
- return NULL;
- }
-}
-
-static pointer
-xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size)
-{
- struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
- {
- Size = (unsigned long)Base + Size;
- }
- else
- {
- Size = mapInfoP->u.map_info_mmap.map_size;
- }
-
- switch(mapInfoP->method)
- {
- case MAP_MMAP:
- /* Need to remap if size is unknown because we may not have
- mapped the whole region initially */
- if(memInfoP->regionVirtBase == NULL ||
- mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
- {
- if((memInfoP->regionVirtBase =
- mmap((caddr_t)0,
- Size,
- PROT_READ | PROT_WRITE,
- MAP_SHARED,
- xf86Info.screenFd,
- (unsigned long)mapInfoP->u.map_info_mmap.map_offset))
- == (pointer)-1)
- {
- FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
- mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
- }
- if(mapInfoP->u.map_info_mmap.internal_offset > 0)
- memInfoP->regionVirtBase +=
- mapInfoP->u.map_info_mmap.internal_offset;
- }
- break;
-
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
- }
-
- return (pointer)((int)memInfoP->regionVirtBase + (int)Base);
-}
-
-static void
-xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
-{
- struct map_info *mapInfoP = &(memInfoP->memInfo);
-
- switch(mapInfoP->method)
- {
- case MAP_MMAP:
- if(memInfoP->regionVirtBase != NULL)
- {
- if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
- Size = mapInfoP->u.map_info_mmap.map_size;
- munmap((caddr_t)memInfoP->regionVirtBase, Size);
- memInfoP->regionVirtBase = NULL;
- }
- break;
- default:
- FatalError("xf86MapInfoMap: Unsuported mapping method\n");
- break;
- }
-}
-
-static pointer
-armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- struct memAccess *memInfoP;
-
- if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
- {
- /*
- ** xf86 passes in a physical address offset from the start
- ** of physical memory, but xf86MapInfoMap expects an
- ** offset from the start of the specified region - it gets
- ** the physical address of the region from the display driver.
- */
- switch(Region)
- {
- case LINEAR_REGION:
- if (vgaPhysLinearBase)
- {
- Base -= vgaPhysLinearBase;
- }
- break;
- case VGA_REGION:
- Base -= 0xA0000;
- break;
- }
-
- base = xf86MapInfoMap(memInfoP, Base, Size);
- return (base);
- }
- return mapVidMem(ScreenNum, Base, Size, flags);
-}
-
-static void
-armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- struct memAccess *memInfoP;
-
- if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
- {
- xf86MapInfoUnmap(memInfoP, Base, Size);
- }
- unmapVidMem(ScreenNum, Base, Size);
-}
-
-#ifdef USE_DEV_IO
-static int IoFd = -1;
-
-Bool
-xf86EnableIO()
-{
- if (IoFd >= 0)
- return TRUE;
-
- if ((IoFd = open("/dev/io", O_RDWR)) == -1)
- {
- xf86Msg(X_WARNING,"xf86EnableIO: "
- "Failed to open /dev/io for extended I/O\n");
- return FALSE;
- }
- return TRUE;
-}
-
-void
-xf86DisableIO()
-{
- if (IoFd < 0)
- return;
-
- close(IoFd);
- IoFd = -1;
- return;
-}
-
-#endif
-
-#if defined(USE_ARC_MMAP) || defined(__arm32__)
-
-Bool
-xf86EnableIO()
-{
- int fd;
- pointer base;
-
- if (ExtendedEnabled)
- return TRUE;
-
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0x0000);
-
- if (base != (pointer)-1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- return FALSE;
- }
- }
- else {
- xf86Msg("EnableIO: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- return FALSE;
- }
-
- ExtendedEnabled = TRUE;
-
- return TRUE;
-}
-
-void
-xf86DisableIO()
-{
- return;
-}
-
-#endif /* USE_ARC_MMAP */
-
-#if 0
-/*
- * XXX This is here for reference. It needs to be handled differently for the
- * ND.
- */
-#if defined(USE_ARC_MMAP) || defined(__arm32__)
-
-#ifdef USE_ARM32_MMAP
-#define DEV_MEM_IOBASE 0x43000000
-#endif
-
-static Bool ScreenEnabled[MAXSCREENS];
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
-
-Bool
-xf86EnableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
- int fd;
- pointer base;
-
-#ifdef __arm32__
- struct memAccess *memInfoP;
- int *Size;
-#endif
-
- ScreenEnabled[ScreenNum] = TRUE;
-
- if (ExtendedEnabled)
- return TRUE;
-
-#ifdef USE_ARC_MMAP
- if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
- /* Try to map a page at the pccons I/O space */
- base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
- MAP_FLAGS, fd, (off_t)0x0000);
-
- if (base != (pointer)-1) {
- IOPortBase = base;
- }
- else {
- xf86Msg(X_ERROR,
- "EnableIOPorts: failed to mmap %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
- }
- else {
- xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
- "/dev/ttyC0", strerror(errno));
- }
-#endif
-
-#ifdef __arm32__
- IOPortBase = (unsigned int)-1;
-
- if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
- {
- /*
- * xf86MapInfoMap maps an offset from the start of video IO
- * space (e.g. 0x3B0), but IOPortBase is expected to map to
- * physical address 0x000, so subtract the start of video I/O
- * space from the result. This is safe for now becase we
- * actually mmap the start of the page, then the start of video
- * I/O space is added as an internal offset.
- */
- IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
- (caddr_t)0x0, 0L)
- - memInfoP->memInfo.u.map_info_mmap.internal_offset;
- ExtendedEnabled = TRUE;
- return TRUE;
- }
-#ifdef USE_ARM32_MMAP
- checkDevMem(TRUE);
-
- if (devMemFd >= 0 && useDevMem)
- {
- base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
- MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
-
- if (base != (pointer)-1)
- IOPortBase = (unsigned int)base;
- }
-
- if (IOPortBase == (unsigned int)-1)
- {
- xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
-Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
- return FALSE;
- }
-#else
- /* We don't have the IOBASE, so we can't map the address */
- xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
-Try building the server with USE_ARM32_MMAP defined\n");
- return FALSE;
-#endif
-#endif
-
- ExtendedEnabled = TRUE;
-
- return TRUE;
-}
-
-void
-xf86DisableIOPorts(ScreenNum)
-int ScreenNum;
-{
- int i;
-#ifdef __arm32__
- struct memAccess *memInfoP;
-#endif
-
- ScreenEnabled[ScreenNum] = FALSE;
-
-#ifdef __arm32__
- if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL)
- {
- xf86MapInfoUnmap(memInfoP, 0);
- }
-#endif
-
-#ifdef USE_ARM32_MMAP
- if (!ExtendedEnabled)
- return;
-
- for (i = 0; i < MAXSCREENS; i++)
- if (ScreenEnabled[i])
- return;
-
- munmap((caddr_t)IOPortBase, 0x400);
- IOPortBase = (unsigned int)-1;
- ExtendedEnabled = FALSE;
-#endif
-
- return;
-}
-
-#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
-#endif
-
-
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+/*
+ * The ARM32 code here carries the following copyright:
+ *
+ * Copyright 1997
+ * Digital Equipment Corporation. All rights reserved.
+ * This software is furnished under license and may be used and copied only in
+ * accordance with the following terms and conditions. Subject to these
+ * conditions, you may download, copy, install, use, modify and distribute
+ * this software in source and/or binary form. No title or ownership is
+ * transferred hereby.
+ *
+ * 1) Any source code used, modified or distributed must reproduce and retain
+ * this copyright notice and list of conditions as they appear in the
+ * source file.
+ *
+ * 2) No right is granted to use any trade name, trademark, or logo of Digital
+ * Equipment Corporation. Neither the "Digital Equipment Corporation"
+ * name nor any trademark or logo of Digital Equipment Corporation may be
+ * used to endorse or promote products derived from this software without
+ * the prior written permission of Digital Equipment Corporation.
+ *
+ * 3) This software is provided "AS-IS" and any express or implied warranties,
+ * including but not limited to, any implied warranties of merchantability,
+ * fitness for a particular purpose, or non-infringement are disclaimed.
+ * In no event shall DIGITAL be liable for any damages whatsoever, and in
+ * particular, DIGITAL shall not be liable for special, indirect,
+ * consequential, or incidental damages or damages for lost profits, loss
+ * of revenue or loss of use, whether such damages arise in contract,
+ * negligence, tort, under statute, in equity, at law or otherwise, even
+ * if advised of the possibility of such damage.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifdef __arm32__
+#include "machine/devmap.h"
+struct memAccess
+{
+ int ioctl;
+ struct map_info memInfo;
+ pointer regionVirtBase;
+ Bool Checked;
+ Bool OK;
+};
+
+static pointer xf86MapInfoMap();
+static void xf86MapInfoUnmap();
+static struct memAccess *checkMapInfo();
+extern int vgaPhysLinearBase;
+
+/* A memAccess structure is needed for each possible region */
+struct memAccess vgaMemInfo = { CONSOLE_GET_MEM_INFO, NULL, NULL,
+ FALSE, FALSE };
+struct memAccess linearMemInfo = { CONSOLE_GET_LINEAR_INFO, NULL, NULL,
+ FALSE, FALSE };
+struct memAccess ioMemInfo = { CONSOLE_GET_IO_INFO, NULL, NULL,
+ FALSE, FALSE };
+#endif /* __arm32__ */
+
+#if defined(__NetBSD__) && !defined(MAP_FILE)
+#define MAP_FLAGS MAP_SHARED
+#else
+#define MAP_FLAGS (MAP_FILE | MAP_SHARED)
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+
+#define BUS_BASE 0L
+#define BUS_BASE_BWX 0L
+
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static Bool useDevMem = FALSE;
+static int devMemFd = -1;
+
+#define DEV_MEM "/dev/mem"
+
+static pointer mapVidMem(int, unsigned long, unsigned long, int);
+static void unmapVidMem(int, pointer, unsigned long);
+
+/*
+ * Check if /dev/mem can be mmap'd. If it can't print a warning when
+ * "warn" is TRUE.
+ */
+static void
+checkDevMem(Bool warn)
+{
+ static Bool devMemChecked = FALSE;
+ int fd;
+ pointer base;
+
+ if (devMemChecked)
+ return;
+ devMemChecked = TRUE;
+
+ if ((fd = open(DEV_MEM, O_RDWR)) >= 0)
+ {
+ /* Try to map a page at the VGA address */
+ base = mmap((caddr_t)0, 4096, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0xA0000 + BUS_BASE);
+
+ if (base != MAP_FAILED)
+ {
+ munmap((caddr_t)base, 4096);
+ devMemFd = fd;
+ useDevMem = TRUE;
+ return;
+ } else {
+ /* This should not happen */
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+ }
+ }
+ if (warn)
+ {
+ xf86Msg(X_WARNING, "checkDevMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ useDevMem = FALSE;
+ return;
+}
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+
+ checkDevMem(TRUE);
+ pVidMem->linearSupported = useDevMem;
+ pVidMem->mapMem = armMapVidMem;
+ pVidMem->unmapVidMem = armUnmapVidMem;
+
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+
+ checkDevMem(FALSE);
+
+ if (useDevMem)
+ {
+ if (devMemFd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, devMemFd, (off_t)Base + BUS_BASE_BWX);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: could not mmap %s [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", DEV_MEM, Size, Base,
+ strerror(errno));
+ }
+ return base;
+ }
+
+ /* else, mmap /dev/vga */
+ if ((unsigned long)Base < 0xA0000 || (unsigned long)Base >= 0xC0000)
+ {
+ FatalError("%s: Address 0x%x outside allowable range\n",
+ "xf86MapVidMem", Base);
+ }
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_FLAGS, xf86Info.screenFd,
+ (unsigned long)Base - 0xA0000);
+ if (base == MAP_FAILED)
+ {
+ FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)\n",
+ strerror(errno));
+ }
+ return base;
+}
+
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap((caddr_t)Base, Size);
+}
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ checkDevMem(TRUE);
+ if (devMemFd == -1) {
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, devMemFd, (off_t)Base+BUS_BASE);
+ if ((long)ptr == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: %s mmap[s=%x,a=%x,o=%x] failed (%s)\n",
+ DEV_MEM, Len, Base, Offset, strerror(errno));
+ return -1;
+ }
+#ifdef DEBUG
+ ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+#endif
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "xf86ReadBIOS(%x, %x, Buf, %x)"
+ "-> %02x %02x %02x %02x...\n",
+ Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
+#endif
+ return Len;
+}
+
+
+/* XXX This needs to be updated for the ND */
+
+/*
+** Find out whether the console driver provides memory mapping information
+** for the specified region and return the map_info pointer. Print a warning if required.
+*/
+static struct memAccess *
+checkMapInfo(Bool warn, int Region)
+{
+ struct memAccess *memAccP;
+
+ switch (Region)
+ {
+ case VGA_REGION:
+ memAccP = &vgaMemInfo;
+ break;
+
+ case LINEAR_REGION:
+ memAccP = &linearMemInfo;
+ break;
+
+ case MMIO_REGION:
+ memAccP = &ioMemInfo;
+ break;
+
+ default:
+ return NULL;
+ break;
+ }
+
+ if(!memAccP->Checked)
+ {
+ if(ioctl(xf86Info.screenFd, memAccP->ioctl, &(memAccP->memInfo)) == -1)
+ {
+ if(warn)
+ {
+ xf86Msg(X_WARNING,
+ "checkMapInfo: failed to get map info for region %d\n\t(%s)\n",
+ Region, strerror(errno));
+ }
+ }
+ else
+ {
+ if(memAccP->memInfo.u.map_info_mmap.map_offset
+ != MAP_INFO_UNKNOWN)
+ memAccP->OK = TRUE;
+ }
+ memAccP->Checked = TRUE;
+ }
+ if (memAccP->OK)
+ {
+ return memAccP;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+static pointer
+xf86MapInfoMap(struct memAccess *memInfoP, pointer Base, unsigned long Size)
+{
+ struct map_info *mapInfoP = &(memInfoP->memInfo);
+
+ if (mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
+ {
+ Size = (unsigned long)Base + Size;
+ }
+ else
+ {
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ }
+
+ switch(mapInfoP->method)
+ {
+ case MAP_MMAP:
+ /* Need to remap if size is unknown because we may not have
+ mapped the whole region initially */
+ if(memInfoP->regionVirtBase == NULL ||
+ mapInfoP->u.map_info_mmap.map_size == MAP_INFO_UNKNOWN)
+ {
+ if((memInfoP->regionVirtBase =
+ mmap((caddr_t)0,
+ Size,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ xf86Info.screenFd,
+ (unsigned long)mapInfoP->u.map_info_mmap.map_offset))
+ == (pointer)-1)
+ {
+ FatalError("xf86MapInfoMap: Failed to map memory at 0x%x\n\t%s\n",
+ mapInfoP->u.map_info_mmap.map_offset, strerror(errno));
+ }
+ if(mapInfoP->u.map_info_mmap.internal_offset > 0)
+ memInfoP->regionVirtBase +=
+ mapInfoP->u.map_info_mmap.internal_offset;
+ }
+ break;
+
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
+ }
+
+ return (pointer)((int)memInfoP->regionVirtBase + (int)Base);
+}
+
+static void
+xf86MapInfoUnmap(struct memAccess *memInfoP, unsigned long Size)
+{
+ struct map_info *mapInfoP = &(memInfoP->memInfo);
+
+ switch(mapInfoP->method)
+ {
+ case MAP_MMAP:
+ if(memInfoP->regionVirtBase != NULL)
+ {
+ if(mapInfoP->u.map_info_mmap.map_size != MAP_INFO_UNKNOWN)
+ Size = mapInfoP->u.map_info_mmap.map_size;
+ munmap((caddr_t)memInfoP->regionVirtBase, Size);
+ memInfoP->regionVirtBase = NULL;
+ }
+ break;
+ default:
+ FatalError("xf86MapInfoMap: Unsuported mapping method\n");
+ break;
+ }
+}
+
+static pointer
+armMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ struct memAccess *memInfoP;
+
+ if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
+ {
+ /*
+ ** xf86 passes in a physical address offset from the start
+ ** of physical memory, but xf86MapInfoMap expects an
+ ** offset from the start of the specified region - it gets
+ ** the physical address of the region from the display driver.
+ */
+ switch(Region)
+ {
+ case LINEAR_REGION:
+ if (vgaPhysLinearBase)
+ {
+ Base -= vgaPhysLinearBase;
+ }
+ break;
+ case VGA_REGION:
+ Base -= 0xA0000;
+ break;
+ }
+
+ base = xf86MapInfoMap(memInfoP, Base, Size);
+ return base;
+ }
+ return mapVidMem(ScreenNum, Base, Size, flags);
+}
+
+static void
+armUnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ struct memAccess *memInfoP;
+
+ if((memInfoP = checkMapInfo(FALSE, Region)) != NULL)
+ {
+ xf86MapInfoUnmap(memInfoP, Base, Size);
+ }
+ unmapVidMem(ScreenNum, Base, Size);
+}
+
+#ifdef USE_DEV_IO
+static int IoFd = -1;
+
+Bool
+xf86EnableIO()
+{
+ if (IoFd >= 0)
+ return TRUE;
+
+ if ((IoFd = open("/dev/io", O_RDWR)) == -1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIO: "
+ "Failed to open /dev/io for extended I/O\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (IoFd < 0)
+ return;
+
+ close(IoFd);
+ IoFd = -1;
+ return;
+}
+
+#endif
+
+#if defined(USE_ARC_MMAP) || defined(__arm32__)
+
+Bool
+xf86EnableIO()
+{
+ int fd;
+ pointer base;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0x0000);
+
+ if (base != (pointer)-1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+ }
+ else {
+ xf86Msg("EnableIO: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ return FALSE;
+ }
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ return;
+}
+
+#endif /* USE_ARC_MMAP */
+
+#if 0
+/*
+ * XXX This is here for reference. It needs to be handled differently for the
+ * ND.
+ */
+#if defined(USE_ARC_MMAP) || defined(__arm32__)
+
+#ifdef USE_ARM32_MMAP
+#define DEV_MEM_IOBASE 0x43000000
+#endif
+
+static Bool ScreenEnabled[MAXSCREENS];
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+Bool
+xf86EnableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+ int fd;
+ pointer base;
+
+#ifdef __arm32__
+ struct memAccess *memInfoP;
+ int *Size;
+#endif
+
+ ScreenEnabled[ScreenNum] = TRUE;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+#ifdef USE_ARC_MMAP
+ if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
+ /* Try to map a page at the pccons I/O space */
+ base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, fd, (off_t)0x0000);
+
+ if (base != (pointer)-1) {
+ IOPortBase = base;
+ }
+ else {
+ xf86Msg(X_ERROR,
+ "EnableIOPorts: failed to mmap %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+ }
+ else {
+ xf86Msg(X_ERROR, "EnableIOPorts: failed to open %s (%s)\n",
+ "/dev/ttyC0", strerror(errno));
+ }
+#endif
+
+#ifdef __arm32__
+ IOPortBase = (unsigned int)-1;
+
+ if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
+ {
+ /*
+ * xf86MapInfoMap maps an offset from the start of video IO
+ * space (e.g. 0x3B0), but IOPortBase is expected to map to
+ * physical address 0x000, so subtract the start of video I/O
+ * space from the result. This is safe for now becase we
+ * actually mmap the start of the page, then the start of video
+ * I/O space is added as an internal offset.
+ */
+ IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
+ (caddr_t)0x0, 0L)
+ - memInfoP->memInfo.u.map_info_mmap.internal_offset;
+ ExtendedEnabled = TRUE;
+ return TRUE;
+ }
+#ifdef USE_ARM32_MMAP
+ checkDevMem(TRUE);
+
+ if (devMemFd >= 0 && useDevMem)
+ {
+ base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
+ MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
+
+ if (base != (pointer)-1)
+ IOPortBase = (unsigned int)base;
+ }
+
+ if (IOPortBase == (unsigned int)-1)
+ {
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
+ return FALSE;
+ }
+#else
+ /* We don't have the IOBASE, so we can't map the address */
+ xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
+Try building the server with USE_ARM32_MMAP defined\n");
+ return FALSE;
+#endif
+#endif
+
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIOPorts(ScreenNum)
+int ScreenNum;
+{
+ int i;
+#ifdef __arm32__
+ struct memAccess *memInfoP;
+#endif
+
+ ScreenEnabled[ScreenNum] = FALSE;
+
+#ifdef __arm32__
+ if((memInfoP = checkMapInfo(FALSE, MMIO_REGION)) != NULL)
+ {
+ xf86MapInfoUnmap(memInfoP, 0);
+ }
+#endif
+
+#ifdef USE_ARM32_MMAP
+ if (!ExtendedEnabled)
+ return;
+
+ for (i = 0; i < MAXSCREENS; i++)
+ if (ScreenEnabled[i])
+ return;
+
+ munmap((caddr_t)IOPortBase, 0x400);
+ IOPortBase = (unsigned int)-1;
+ ExtendedEnabled = FALSE;
+#endif
+
+ return;
+}
+
+#endif /* USE_ARC_MMAP || USE_ARM32_MMAP */
+#endif
+
+
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c
index 90c9c30b1..15220d743 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_VTsw.c
@@ -57,7 +57,7 @@ xf86VTSwitchPending()
{
#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
#endif
return FALSE;
@@ -70,9 +70,9 @@ xf86VTSwitchAway()
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
- return(FALSE);
+ return FALSE;
else
- return(TRUE);
+ return TRUE;
}
#endif
return FALSE;
@@ -85,19 +85,19 @@ xf86VTSwitchTo()
if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) {
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- return(FALSE);
+ return FALSE;
else
- return(TRUE);
+ return TRUE;
}
#endif
- return(TRUE);
+ return TRUE;
}
Bool
xf86VTActivate(int vtno)
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) {
- return(FALSE);
+ return FALSE;
}
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
index 7698084ee..62618afd8 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/bsd_init.c
@@ -1,760 +1,760 @@
-/*
- * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Rich Murphey and
- * David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include <sys/utsname.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-#include <errno.h>
-
-static Bool KeepTty = FALSE;
-static int devConsoleFd = -1;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-static int VTnum = -1;
-static int initialVT = -1;
-static Bool ShareVTs = FALSE;
-#endif
-
-#ifdef PCCONS_SUPPORT
-/* Stock 0.1 386bsd pccons console driver interface */
-#ifndef __OpenBSD__
-# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
-#else
-# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0"
-#endif
-#define PCCONS_CONSOLE_DEV2 "/dev/vga"
-#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
-#endif
-
-#ifdef SYSCONS_SUPPORT
-/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
-#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
-#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
-#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
-#endif
-
-#ifdef PCVT_SUPPORT
-/* Hellmuth Michaelis' pcvt driver */
-#ifndef __OpenBSD__
-# define PCVT_CONSOLE_DEV "/dev/ttyv0"
-#else
-# define PCVT_CONSOLE_DEV "/dev/ttyC0"
-#endif
-#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
-#endif
-
-#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
-/* NetBSD's new console driver */
-#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
-#endif
-
-#ifdef __GLIBC__
-#define setpgrp setpgid
-#endif
-
-#define CHECK_DRIVER_MSG \
- "Check your kernel's console driver configuration and /dev entries"
-
-static char *supported_drivers[] = {
-#ifdef PCCONS_SUPPORT
- "pccons (with X support)",
-#endif
-#ifdef SYSCONS_SUPPORT
- "syscons",
-#endif
-#ifdef PCVT_SUPPORT
- "pcvt",
-#endif
-#ifdef WSCONS_SUPPORT
- "wscons",
-#endif
-};
-
-
-/*
- * Functions to probe for the existance of a supported console driver.
- * Any function returns either a valid file descriptor (driver probed
- * succesfully), -1 (driver not found), or uses FatalError() if the
- * driver was found but proved to not support the required mode to run
- * an X server.
- */
-
-typedef int (*xf86ConsOpen_t)(void);
-
-#ifdef PCCONS_SUPPORT
-static int xf86OpenPccons(void);
-#endif /* PCCONS_SUPPORT */
-
-#ifdef SYSCONS_SUPPORT
-static int xf86OpenSyscons(void);
-#endif /* SYSCONS_SUPPORT */
-
-#ifdef PCVT_SUPPORT
-static int xf86OpenPcvt(void);
-#endif /* PCVT_SUPPORT */
-
-#ifdef WSCONS_SUPPORT
-static int xf86OpenWScons(void);
-#endif
-
-/*
- * The sequence of the driver probes is important; start with the
- * driver that is best distinguishable, and end with the most generic
- * driver. (Otherwise, pcvt would also probe as syscons, and either
- * pcvt or syscons might succesfully probe as pccons.)
- */
-static xf86ConsOpen_t xf86ConsTab[] = {
-#ifdef PCVT_SUPPORT
- xf86OpenPcvt,
-#endif
-#ifdef SYSCONS_SUPPORT
- xf86OpenSyscons,
-#endif
-#ifdef PCCONS_SUPPORT
- xf86OpenPccons,
-#endif
-#ifdef WSCONS_SUPPORT
- xf86OpenWScons,
-#endif
- (xf86ConsOpen_t)NULL
-};
-
-
-void
-xf86OpenConsole()
-{
- int i, fd = -1;
- xf86ConsOpen_t *driver;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- int result;
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- struct utsname uts;
-#endif
- vtmode_t vtmode;
-#endif
-
- if (serverGeneration == 1)
- {
- /* check if we are run with euid==0 */
- if (geteuid() != 0)
- {
- FatalError("xf86OpenConsole: Server must be suid root");
- }
-
- if (!KeepTty)
- {
- /*
- * detaching the controlling tty solves problems of kbd character
- * loss. This is not interesting for CO driver, because it is
- * exclusive.
- */
- setpgrp(0, getpid());
- if ((i = open("/dev/tty",O_RDWR)) >= 0)
- {
- ioctl(i,TIOCNOTTY,(char *)0);
- close(i);
- }
- }
-
- /* detect which driver we are running on */
- for (driver = xf86ConsTab; *driver; driver++)
- {
- if ((fd = (*driver)()) >= 0)
- break;
- }
-
- /* Check that a supported console driver was found */
- if (fd < 0)
- {
- char cons_drivers[80] = {0, };
- for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
- {
- if (i)
- {
- strcat(cons_drivers, ", ");
- }
- strcat(cons_drivers, supported_drivers[i]);
- }
- FatalError(
- "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
- "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
- }
-#if 0 /* stdin is already closed in OsInit() */
- fclose(stdin);
-#endif
- xf86Info.consoleFd = fd;
- xf86Info.screenFd = fd;
-
- switch (xf86Info.consType)
- {
-#ifdef PCCONS_SUPPORT
- case PCCONS:
- if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
- {
- FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- /*
- * Hack to prevent keyboard hanging when syslogd closes
- * /dev/console
- */
- if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: couldn't open /dev/console (%s)\n",
- strerror(errno));
- }
- break;
-#endif
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- case SYSCONS:
- /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
- * switching anymore. Here we check for FreeBSD 3.1 and up.
- * Add cases for other *BSD that behave the same.
- */
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
- uname (&uts);
- i = atof(uts.release) * 100;
- if (i >= 310) goto acquire_vt;
-#endif
- /* otherwise fall through */
- case PCVT:
-#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000))
- /*
- * First activate the #1 VT. This is a hack to allow a server
- * to be started while another one is active. There should be
- * a better way.
- */
- if (initialVT != 1) {
-
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- sleep(1);
- }
-#endif
-acquire_vt:
- if (!ShareVTs) {
- /*
- * now get the VT
- */
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- SYSCALL(result =
- ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
- if (result != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
- }
-
- signal(SIGUSR1, xf86VTRequest);
-
- vtmode.mode = VT_PROCESS;
- vtmode.relsig = SIGUSR1;
- vtmode.acqsig = SIGUSR1;
- vtmode.frsig = SIGUSR1;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
- }
- #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
- {
- FatalError("xf86OpenConsole: KDENABIO failed (%s)",
- strerror(errno));
- }
- #endif
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- {
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
- }
- } else { /* ShareVTs */
- close(xf86Info.consoleFd);
- }
- break;
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-#ifdef WSCONS_SUPPORT
- case WSCONS:
- /* Nothing to do */
- break;
-#endif
- }
- }
- else
- {
- /* serverGeneration != 1 */
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
- {
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- }
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- }
- return;
-}
-
-
-#ifdef PCCONS_SUPPORT
-
-static int
-xf86OpenPccons()
-{
- int fd = -1;
-
- if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
- >= 0 ||
- (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
- >= 0)
- {
- if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
- {
- FatalError(
- "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
- "xf86OpenPccons",
- strerror(errno),
- "Was expecting pccons driver with X support",
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = PCCONS;
- xf86Msg(X_PROBED, "Using pccons driver with X support\n");
- }
- return fd;
-}
-
-#endif /* PCCONS_SUPPORT */
-
-#ifdef SYSCONS_SUPPORT
-
-static int
-xf86OpenSyscons()
-{
- int fd = -1;
- vtmode_t vtmode;
- char vtname[12];
- struct stat status;
- long syscons_version;
- MessageType from;
-
- /* Check for syscons */
- if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
- || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
- {
- if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
- {
- /* Get syscons version */
- if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
- {
- syscons_version = 0;
- }
-
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
-
-#ifdef VT_GETACTIVE
- if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
- initialVT = -1;
-#endif
- if (ShareVTs)
- xf86Info.vtno = initialVT;
-
- if (xf86Info.vtno == -1)
- {
- /*
- * For old syscons versions (<0x100), VT_OPENQRY returns
- * the current VT rather than the next free VT. In this
- * case, the server gets started on the current VT instead
- * of the next free VT.
- */
-
-#if 0
- /* check for the fixed VT_OPENQRY */
- if (syscons_version >= 0x100)
- {
-#endif
- if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
- {
- /* No free VTs */
- xf86Info.vtno = -1;
- }
-#if 0
- }
-#endif
-
- if (xf86Info.vtno == -1)
- {
- /*
- * All VTs are in use. If initialVT was found, use it.
- * Otherwise, if stdin is a VT, use that one.
- * XXX stdin is already closed, so this won't work.
- */
- if (initialVT != -1)
- {
- xf86Info.vtno = initialVT;
- }
- else if ((fstat(0, &status) >= 0)
- && S_ISCHR(status.st_mode)
- && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
- {
- /* stdin is a VT */
- xf86Info.vtno = minor(status.st_rdev) + 1;
- }
- else
- {
- if (syscons_version >= 0x100)
- {
- FatalError("%s: Cannot find a free VT",
- "xf86OpenSyscons");
- }
- /* Should no longer reach here */
- FatalError("%s: %s %s\n\t%s %s",
- "xf86OpenSyscons",
- "syscons versions prior to 1.0 require",
- "either the",
- "server's stdin be a VT",
- "or the use of the vtxx server option");
- }
- }
- from = X_PROBED;
- }
-
- close(fd);
-#ifndef __OpenBSD__
- sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
-#else
- sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
-#endif
- if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
- {
- FatalError("xf86OpenSyscons: Cannot open %s (%s)",
- vtname, strerror(errno));
- }
- if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenSyscons: VT_GETMODE failed");
- }
- xf86Info.consType = SYSCONS;
- xf86Msg(X_PROBED, "Using syscons driver with X support");
- if (syscons_version >= 0x100)
- {
- xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
- syscons_version & 0xFF);
- }
- else
- {
- xf86ErrorF(" (version 0.x)\n");
- }
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- }
- else
- {
- /* VT_GETMODE failed, probably not syscons */
- close(fd);
- fd = -1;
- }
- }
- return fd;
-}
-
-#endif /* SYSCONS_SUPPORT */
-
-
-#ifdef PCVT_SUPPORT
-
-static int
-xf86OpenPcvt()
-{
- /* This looks much like syscons, since pcvt is API compatible */
- int fd = -1;
- vtmode_t vtmode;
- char vtname[12], *vtprefix;
- struct stat status;
- struct pcvtid pcvt_version;
-
-#ifndef __OpenBSD__
- vtprefix = "/dev/ttyv";
-#else
- vtprefix = "/dev/ttyC";
-#endif
-
- fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
-#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
- if (fd < 0)
- {
- fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
- vtprefix = "/dev/ttyE";
- }
-#endif
- if (fd >= 0)
- {
- if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
- {
- if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
- "xf86OpenPcvt",
- "Found pcvt driver but X11 seems to be",
- " not supported.", CHECK_DRIVER_MSG);
- }
-
- xf86Info.vtno = VTnum;
-
- if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
- initialVT = -1;
-
- if (xf86Info.vtno == -1)
- {
- if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
- {
- /* No free VTs */
- xf86Info.vtno = -1;
- }
-
- if (xf86Info.vtno == -1)
- {
- /*
- * All VTs are in use. If initialVT was found, use it.
- * Otherwise, if stdin is a VT, use that one.
- * XXX stdin is already closed, so this won't work.
- */
- if (initialVT != -1)
- {
- xf86Info.vtno = initialVT;
- }
- else if ((fstat(0, &status) >= 0)
- && S_ISCHR(status.st_mode)
- && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
- {
- /* stdin is a VT */
- xf86Info.vtno = minor(status.st_rdev) + 1;
- }
- else
- {
- FatalError("%s: Cannot find a free VT",
- "xf86OpenPcvt");
- }
- }
- }
-
- close(fd);
- sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
- if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
- {
- ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
- vtname, strerror(errno));
- xf86Info.vtno = initialVT;
- sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
- if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
- FatalError("xf86OpenPcvt: Cannot open %s (%s)",
- vtname, strerror(errno));
- }
- }
- if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
- {
- FatalError("xf86OpenPcvt: VT_GETMODE failed");
- }
- xf86Info.consType = PCVT;
-#ifdef WSCONS_SUPPORT
- xf86Msg(X_PROBED,
- "Using wscons driver on %s in pcvt compatibility mode "
- "(version %d.%d)\n", vtname,
- pcvt_version.rmajor, pcvt_version.rminor);
-#else
- xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
- pcvt_version.rmajor, pcvt_version.rminor);
-#endif
- }
- else
- {
- /* Not pcvt */
- close(fd);
- fd = -1;
- }
- }
- return fd;
-}
-
-#endif /* PCVT_SUPPORT */
-
-#ifdef WSCONS_SUPPORT
-
-static int
-xf86OpenWScons()
-{
- int fd = -1;
- int mode = WSDISPLAYIO_MODE_MAPPED;
- int i;
- char ttyname[16];
-
- /* XXX Is this ok? */
- for (i = 0; i < 8; i++) {
-#if defined(__NetBSD__)
- sprintf(ttyname, "/dev/ttyE%d", i);
-#elif defined(__OpenBSD__)
- sprintf(ttyname, "/dev/ttyC%x", i);
-#endif
- if ((fd = open(ttyname, 2)) != -1)
- break;
- }
- if (fd != -1) {
- if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
- FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
- "xf86OpenConsole", strerror(errno),
- CHECK_DRIVER_MSG);
- }
- xf86Info.consType = WSCONS;
- xf86Msg(X_PROBED, "Using wscons driver\n");
- }
- return fd;
-}
-
-#endif /* WSCONS_SUPPORT */
-
-void
-xf86CloseConsole()
-{
-#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
- struct vt_mode VT;
-#endif
-
- if (ShareVTs) return;
-
- switch (xf86Info.consType)
- {
-#ifdef PCCONS_SUPPORT
- case PCCONS:
- ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
- break;
-#endif /* PCCONS_SUPPORT */
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- case SYSCONS:
- case PCVT:
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
- }
-#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
- if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
- {
- xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
- strerror(errno));
- }
-#endif
- if (initialVT != -1)
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
- break;
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-#ifdef WSCONS_SUPPORT
- case WSCONS:
- {
- int mode = WSDISPLAYIO_MODE_EMUL;
- ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
- break;
- }
-#endif
- }
-
- if (xf86Info.screenFd != xf86Info.consoleFd)
- {
- close(xf86Info.screenFd);
- close(xf86Info.consoleFd);
- if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
- {
- xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)",
- strerror(errno));
- }
- }
- close(xf86Info.consoleFd);
- if (devConsoleFd >= 0)
- close(devConsoleFd);
- return;
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return(1);
- }
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- if (!strcmp(argv[i], "-sharevts"))
- {
- ShareVTs = TRUE;
- return(1);
- }
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
- VTnum < 1 || VTnum > 12)
- {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- return(1);
- }
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- return(0);
-}
-
-void
-xf86UseMsg()
-{
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
- ErrorF("vtXX use the specified VT number (1-12)\n");
- ErrorF("-sharevts share VTs with another X server\n");
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
- return;
-}
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/utsname.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static Bool KeepTty = FALSE;
+static int devConsoleFd = -1;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+static int VTnum = -1;
+static int initialVT = -1;
+static Bool ShareVTs = FALSE;
+#endif
+
+#ifdef PCCONS_SUPPORT
+/* Stock 0.1 386bsd pccons console driver interface */
+#ifndef __OpenBSD__
+# define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#else
+# define PCCONS_CONSOLE_DEV1 "/dev/ttyC0"
+#endif
+#define PCCONS_CONSOLE_DEV2 "/dev/vga"
+#define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef SYSCONS_SUPPORT
+/* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
+#define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
+#define SYSCONS_CONSOLE_DEV2 "/dev/vga"
+#define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#ifdef PCVT_SUPPORT
+/* Hellmuth Michaelis' pcvt driver */
+#ifndef __OpenBSD__
+# define PCVT_CONSOLE_DEV "/dev/ttyv0"
+#else
+# define PCVT_CONSOLE_DEV "/dev/ttyC0"
+#endif
+#define PCVT_CONSOLE_MODE O_RDWR|O_NDELAY
+#endif
+
+#if defined(WSCONS_SUPPORT) && defined(__NetBSD__)
+/* NetBSD's new console driver */
+#define WSCONS_PCVT_COMPAT_CONSOLE_DEV "/dev/ttyE0"
+#endif
+
+#ifdef __GLIBC__
+#define setpgrp setpgid
+#endif
+
+#define CHECK_DRIVER_MSG \
+ "Check your kernel's console driver configuration and /dev entries"
+
+static char *supported_drivers[] = {
+#ifdef PCCONS_SUPPORT
+ "pccons (with X support)",
+#endif
+#ifdef SYSCONS_SUPPORT
+ "syscons",
+#endif
+#ifdef PCVT_SUPPORT
+ "pcvt",
+#endif
+#ifdef WSCONS_SUPPORT
+ "wscons",
+#endif
+};
+
+
+/*
+ * Functions to probe for the existance of a supported console driver.
+ * Any function returns either a valid file descriptor (driver probed
+ * succesfully), -1 (driver not found), or uses FatalError() if the
+ * driver was found but proved to not support the required mode to run
+ * an X server.
+ */
+
+typedef int (*xf86ConsOpen_t)(void);
+
+#ifdef PCCONS_SUPPORT
+static int xf86OpenPccons(void);
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+static int xf86OpenSyscons(void);
+#endif /* SYSCONS_SUPPORT */
+
+#ifdef PCVT_SUPPORT
+static int xf86OpenPcvt(void);
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+static int xf86OpenWScons(void);
+#endif
+
+/*
+ * The sequence of the driver probes is important; start with the
+ * driver that is best distinguishable, and end with the most generic
+ * driver. (Otherwise, pcvt would also probe as syscons, and either
+ * pcvt or syscons might succesfully probe as pccons.)
+ */
+static xf86ConsOpen_t xf86ConsTab[] = {
+#ifdef PCVT_SUPPORT
+ xf86OpenPcvt,
+#endif
+#ifdef SYSCONS_SUPPORT
+ xf86OpenSyscons,
+#endif
+#ifdef PCCONS_SUPPORT
+ xf86OpenPccons,
+#endif
+#ifdef WSCONS_SUPPORT
+ xf86OpenWScons,
+#endif
+ (xf86ConsOpen_t)NULL
+};
+
+
+void
+xf86OpenConsole()
+{
+ int i, fd = -1;
+ xf86ConsOpen_t *driver;
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ int result;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ struct utsname uts;
+#endif
+ vtmode_t vtmode;
+#endif
+
+ if (serverGeneration == 1)
+ {
+ /* check if we are run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root");
+ }
+
+ if (!KeepTty)
+ {
+ /*
+ * detaching the controlling tty solves problems of kbd character
+ * loss. This is not interesting for CO driver, because it is
+ * exclusive.
+ */
+ setpgrp(0, getpid());
+ if ((i = open("/dev/tty",O_RDWR)) >= 0)
+ {
+ ioctl(i,TIOCNOTTY,(char *)0);
+ close(i);
+ }
+ }
+
+ /* detect which driver we are running on */
+ for (driver = xf86ConsTab; *driver; driver++)
+ {
+ if ((fd = (*driver)()) >= 0)
+ break;
+ }
+
+ /* Check that a supported console driver was found */
+ if (fd < 0)
+ {
+ char cons_drivers[80] = {0, };
+ for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
+ {
+ if (i)
+ {
+ strcat(cons_drivers, ", ");
+ }
+ strcat(cons_drivers, supported_drivers[i]);
+ }
+ FatalError(
+ "%s: No console driver found\n\tSupported drivers: %s\n\t%s",
+ "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
+ }
+#if 0 /* stdin is already closed in OsInit() */
+ fclose(stdin);
+#endif
+ xf86Info.consoleFd = fd;
+ xf86Info.screenFd = fd;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ if (ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
+ {
+ FatalError("%s: CONSOLE_X_MODE_ON failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ /*
+ * Hack to prevent keyboard hanging when syslogd closes
+ * /dev/console
+ */
+ if ((devConsoleFd = open("/dev/console", O_WRONLY,0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: couldn't open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ break;
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ /* as of FreeBSD 2.2.8, syscons driver does not need the #1 vt
+ * switching anymore. Here we check for FreeBSD 3.1 and up.
+ * Add cases for other *BSD that behave the same.
+ */
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ uname (&uts);
+ i = atof(uts.release) * 100;
+ if (i >= 310) goto acquire_vt;
+#endif
+ /* otherwise fall through */
+ case PCVT:
+#if !(defined(__NetBSD__) && (__NetBSD_Version__ >= 200000000))
+ /*
+ * First activate the #1 VT. This is a hack to allow a server
+ * to be started while another one is active. There should be
+ * a better way.
+ */
+ if (initialVT != 1) {
+
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, 1) != 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ sleep(1);
+ }
+#endif
+acquire_vt:
+ if (!ShareVTs) {
+ /*
+ * now get the VT
+ */
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ SYSCALL(result =
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno));
+ if (result != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ vtmode.mode = VT_PROCESS;
+ vtmode.relsig = SIGUSR1;
+ vtmode.acqsig = SIGUSR1;
+ vtmode.frsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed");
+ }
+ #if !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDENABIO, 0) < 0)
+ {
+ FatalError("xf86OpenConsole: KDENABIO failed (%s)",
+ strerror(errno));
+ }
+ #endif
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed");
+ }
+ } else { /* ShareVTs */
+ close(xf86Info.consoleFd);
+ }
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ /* Nothing to do */
+ break;
+#endif
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!ShareVTs) if (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+ {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ }
+ return;
+}
+
+
+#ifdef PCCONS_SUPPORT
+
+static int
+xf86OpenPccons()
+{
+ int fd = -1;
+
+ if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
+ >= 0 ||
+ (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
+ >= 0)
+ {
+ if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
+ {
+ FatalError(
+ "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s",
+ "xf86OpenPccons",
+ strerror(errno),
+ "Was expecting pccons driver with X support",
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = PCCONS;
+ xf86Msg(X_PROBED, "Using pccons driver with X support\n");
+ }
+ return fd;
+}
+
+#endif /* PCCONS_SUPPORT */
+
+#ifdef SYSCONS_SUPPORT
+
+static int
+xf86OpenSyscons()
+{
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12];
+ struct stat status;
+ long syscons_version;
+ MessageType from;
+
+ /* Check for syscons */
+ if ((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
+ || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
+ {
+ if (ioctl(fd, VT_GETMODE, &vtmode) >= 0)
+ {
+ /* Get syscons version */
+ if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
+ {
+ syscons_version = 0;
+ }
+
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+
+#ifdef VT_GETACTIVE
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+#endif
+ if (ShareVTs)
+ xf86Info.vtno = initialVT;
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * For old syscons versions (<0x100), VT_OPENQRY returns
+ * the current VT rather than the next free VT. In this
+ * case, the server gets started on the current VT instead
+ * of the next free VT.
+ */
+
+#if 0
+ /* check for the fixed VT_OPENQRY */
+ if (syscons_version >= 0x100)
+ {
+#endif
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+#if 0
+ }
+#endif
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ if (syscons_version >= 0x100)
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenSyscons");
+ }
+ /* Should no longer reach here */
+ FatalError("%s: %s %s\n\t%s %s",
+ "xf86OpenSyscons",
+ "syscons versions prior to 1.0 require",
+ "either the",
+ "server's stdin be a VT",
+ "or the use of the vtxx server option");
+ }
+ }
+ from = X_PROBED;
+ }
+
+ close(fd);
+#ifndef __OpenBSD__
+ sprintf(vtname, "/dev/ttyv%01x", xf86Info.vtno - 1);
+#else
+ sprintf(vtname, "/dev/ttyC%01x", xf86Info.vtno - 1);
+#endif
+ if ((fd = open(vtname, SYSCONS_CONSOLE_MODE, 0)) < 0)
+ {
+ FatalError("xf86OpenSyscons: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenSyscons: VT_GETMODE failed");
+ }
+ xf86Info.consType = SYSCONS;
+ xf86Msg(X_PROBED, "Using syscons driver with X support");
+ if (syscons_version >= 0x100)
+ {
+ xf86ErrorF(" (version %ld.%ld)\n", syscons_version >> 8,
+ syscons_version & 0xFF);
+ }
+ else
+ {
+ xf86ErrorF(" (version 0.x)\n");
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ }
+ else
+ {
+ /* VT_GETMODE failed, probably not syscons */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* SYSCONS_SUPPORT */
+
+
+#ifdef PCVT_SUPPORT
+
+static int
+xf86OpenPcvt()
+{
+ /* This looks much like syscons, since pcvt is API compatible */
+ int fd = -1;
+ vtmode_t vtmode;
+ char vtname[12], *vtprefix;
+ struct stat status;
+ struct pcvtid pcvt_version;
+
+#ifndef __OpenBSD__
+ vtprefix = "/dev/ttyv";
+#else
+ vtprefix = "/dev/ttyC";
+#endif
+
+ fd = open(PCVT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+#ifdef WSCONS_PCVT_COMPAT_CONSOLE_DEV
+ if (fd < 0)
+ {
+ fd = open(WSCONS_PCVT_COMPAT_CONSOLE_DEV, PCVT_CONSOLE_MODE, 0);
+ vtprefix = "/dev/ttyE";
+ }
+#endif
+ if (fd >= 0)
+ {
+ if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
+ {
+ if(ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("%s: VT_GETMODE failed\n%s%s\n%s",
+ "xf86OpenPcvt",
+ "Found pcvt driver but X11 seems to be",
+ " not supported.", CHECK_DRIVER_MSG);
+ }
+
+ xf86Info.vtno = VTnum;
+
+ if (ioctl(fd, VT_GETACTIVE, &initialVT) < 0)
+ initialVT = -1;
+
+ if (xf86Info.vtno == -1)
+ {
+ if (ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0)
+ {
+ /* No free VTs */
+ xf86Info.vtno = -1;
+ }
+
+ if (xf86Info.vtno == -1)
+ {
+ /*
+ * All VTs are in use. If initialVT was found, use it.
+ * Otherwise, if stdin is a VT, use that one.
+ * XXX stdin is already closed, so this won't work.
+ */
+ if (initialVT != -1)
+ {
+ xf86Info.vtno = initialVT;
+ }
+ else if ((fstat(0, &status) >= 0)
+ && S_ISCHR(status.st_mode)
+ && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
+ {
+ /* stdin is a VT */
+ xf86Info.vtno = minor(status.st_rdev) + 1;
+ }
+ else
+ {
+ FatalError("%s: Cannot find a free VT",
+ "xf86OpenPcvt");
+ }
+ }
+ }
+
+ close(fd);
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0)
+ {
+ ErrorF("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ xf86Info.vtno = initialVT;
+ sprintf(vtname, "%s%01x", vtprefix, xf86Info.vtno - 1);
+ if ((fd = open(vtname, PCVT_CONSOLE_MODE, 0)) < 0) {
+ FatalError("xf86OpenPcvt: Cannot open %s (%s)",
+ vtname, strerror(errno));
+ }
+ }
+ if (ioctl(fd, VT_GETMODE, &vtmode) < 0)
+ {
+ FatalError("xf86OpenPcvt: VT_GETMODE failed");
+ }
+ xf86Info.consType = PCVT;
+#ifdef WSCONS_SUPPORT
+ xf86Msg(X_PROBED,
+ "Using wscons driver on %s in pcvt compatibility mode "
+ "(version %d.%d)\n", vtname,
+ pcvt_version.rmajor, pcvt_version.rminor);
+#else
+ xf86Msg(X_PROBED, "Using pcvt driver (version %d.%d)\n",
+ pcvt_version.rmajor, pcvt_version.rminor);
+#endif
+ }
+ else
+ {
+ /* Not pcvt */
+ close(fd);
+ fd = -1;
+ }
+ }
+ return fd;
+}
+
+#endif /* PCVT_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+
+static int
+xf86OpenWScons()
+{
+ int fd = -1;
+ int mode = WSDISPLAYIO_MODE_MAPPED;
+ int i;
+ char ttyname[16];
+
+ /* XXX Is this ok? */
+ for (i = 0; i < 8; i++) {
+#if defined(__NetBSD__)
+ sprintf(ttyname, "/dev/ttyE%d", i);
+#elif defined(__OpenBSD__)
+ sprintf(ttyname, "/dev/ttyC%x", i);
+#endif
+ if ((fd = open(ttyname, 2)) != -1)
+ break;
+ }
+ if (fd != -1) {
+ if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+ FatalError("%s: WSDISPLAYIO_MODE_MAPPED failed (%s)\n%s",
+ "xf86OpenConsole", strerror(errno),
+ CHECK_DRIVER_MSG);
+ }
+ xf86Info.consType = WSCONS;
+ xf86Msg(X_PROBED, "Using wscons driver\n");
+ }
+ return fd;
+}
+
+#endif /* WSCONS_SUPPORT */
+
+void
+xf86CloseConsole()
+{
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+ struct vt_mode VT;
+#endif
+
+ if (ShareVTs) return;
+
+ switch (xf86Info.consType)
+ {
+#ifdef PCCONS_SUPPORT
+ case PCCONS:
+ ioctl (xf86Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
+ break;
+#endif /* PCCONS_SUPPORT */
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ case SYSCONS:
+ case PCVT:
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
+ }
+#if !defined(OpenBSD) && !defined(USE_DEV_IO) && !defined(USE_I386_IOPL)
+ if (ioctl(xf86Info.consoleFd, KDDISABIO, 0) < 0)
+ {
+ xf86FatalError("xf86CloseConsole: KDDISABIO failed (%s)",
+ strerror(errno));
+ }
+#endif
+ if (initialVT != -1)
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, initialVT);
+ break;
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+#ifdef WSCONS_SUPPORT
+ case WSCONS:
+ {
+ int mode = WSDISPLAYIO_MODE_EMUL;
+ ioctl(xf86Info.screenFd, WSDISPLAYIO_SMODE, &mode);
+ break;
+ }
+#endif
+ }
+
+ if (xf86Info.screenFd != xf86Info.consoleFd)
+ {
+ close(xf86Info.screenFd);
+ close(xf86Info.consoleFd);
+ if ((xf86Info.consoleFd = open("/dev/console",O_RDONLY,0)) <0)
+ {
+ xf86FatalError("xf86CloseConsole: Cannot open /dev/console (%s)",
+ strerror(errno));
+ }
+ }
+ close(xf86Info.consoleFd);
+ if (devConsoleFd >= 0)
+ close(devConsoleFd);
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return 1;
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
+ VTnum < 1 || VTnum > 12)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ return 0;
+}
+
+void
+xf86UseMsg()
+{
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+ ErrorF("vtXX use the specified VT number (1-12)\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
index 0d457193a..9b26fb1dd 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/i386_video.c
@@ -246,7 +246,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
"xf86MapVidMem", DEV_MEM, Size, Base,
strerror(errno));
}
- return(base);
+ return base;
}
/* else, mmap /dev/vga */
@@ -266,7 +266,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
FatalError("xf86MapVidMem: Could not mmap /dev/vga (%s)",
strerror(errno));
}
- return(base);
+ return base;
}
static void
@@ -289,7 +289,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
checkDevMem(TRUE);
if (devMemFd == -1) {
- return(-1);
+ return -1;
}
psize = getpagesize();
@@ -308,7 +308,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
xf86Msg(X_WARNING, SYSCTL_MSG2);
}
#endif
- return(-1);
+ return -1;
}
#ifdef DEBUG
ErrorF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
@@ -321,7 +321,7 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
"-> %02x %02x %02x %02x...\n",
Base, Offset, Len, Buf[0], Buf[1], Buf[2], Buf[3]);
#endif
- return(Len);
+ return Len;
}
#ifdef USE_I386_IOPL
diff --git a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
index ea520c49e..1dcd77711 100644
--- a/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
+++ b/xorg-server/hw/xfree86/os-support/bsd/sparc64_video.c
@@ -1,91 +1,91 @@
-/*
- * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Rich Murphey and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Rich Murphey and
- * David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((caddr_t)-1)
-#endif
-
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
-
-static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int);
-static void sparc64UnmapVidMem(int, pointer, unsigned long);
-
-void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
- pVidMem->linearSupported = TRUE;
- pVidMem->mapMem = sparc64MapVidMem;
- pVidMem->unmapMem = sparc64UnmapVidMem;
- pVidMem->initialised = TRUE;
-}
-
-static pointer
-sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
- int flags)
-{
- int fd = xf86Info.screenFd;
- pointer base;
-
-#ifdef DEBUG
- xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
- Base, Size, fd);
-#endif
-
- base = mmap(0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_SHARED, fd, Base);
- if (base == MAP_FAILED)
- FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
- "xf86MapVidMem", Size, Base, strerror(errno));
- return base;
-}
-
-static void
-sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
- munmap(Base, Size);
-}
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
-
- return (0);
-}
+/*
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Rich Murphey and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Rich Murphey and
+ * David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * RICH MURPHEY AND DAVID WEXELBLAT DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((caddr_t)-1)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+static pointer sparc64MapVidMem(int, unsigned long, unsigned long, int);
+static void sparc64UnmapVidMem(int, pointer, unsigned long);
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = TRUE;
+ pVidMem->mapMem = sparc64MapVidMem;
+ pVidMem->unmapMem = sparc64UnmapVidMem;
+ pVidMem->initialised = TRUE;
+}
+
+static pointer
+sparc64MapVidMem(int ScreenNum, unsigned long Base, unsigned long Size,
+ int flags)
+{
+ int fd = xf86Info.screenFd;
+ pointer base;
+
+#ifdef DEBUG
+ xf86MsgVerb(X_INFO, 3, "mapVidMem %lx, %lx, fd = %d",
+ Base, Size, fd);
+#endif
+
+ base = mmap(0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, Base);
+ if (base == MAP_FAILED)
+ FatalError("%s: could not mmap screen [s=%x,a=%x] (%s)",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ return base;
+}
+
+static void
+sparc64UnmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+ munmap(Base, Size);
+}
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+
+ return 0;
+}
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
index 3fa897366..705bb5ea0 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_agp.c
@@ -64,7 +64,7 @@ GARTInit(int screenNum)
struct _agp_info agpinf;
if (initDone)
- return (gartFd != -1);
+ return gartFd != -1;
initDone = TRUE;
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
index 297e7a65a..722fbb0c1 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_init.c
@@ -1,401 +1,401 @@
-/*
- * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Orest Zborowski and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Orest Zborowski
- * and David Wexelblat make no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
- * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include <sys/stat.h>
-
-static Bool KeepTty = FALSE;
-static int VTnum = -1;
-static Bool VTSwitch = TRUE;
-static Bool ShareVTs = FALSE;
-static int activeVT = -1;
-
-static int vtPermSave[4];
-static char vtname[11];
-static struct termios tty_attr; /* tty state to restore */
-static int tty_mode; /* kbd mode to restore */
-
-static int
-saveVtPerms(void)
-{
- /* We need to use stat to get permissions. */
- struct stat svtp;
-
- /* Do them numerically ordered, hard coded tty0 first. */
- if (stat("/dev/tty0", &svtp) != 0)
- return 0;
- vtPermSave[0] = (int)svtp.st_uid;
- vtPermSave[1] = (int)svtp.st_gid;
-
- /* Now check the console we are dealing with. */
- if (stat(vtname, &svtp) != 0)
- return 0;
- vtPermSave[2] = (int)svtp.st_uid;
- vtPermSave[3] = (int)svtp.st_gid;
-
- return 1;
-}
-
-static void
-restoreVtPerms(void)
-{
- if (geteuid() == 0) {
- /* Set the terminal permissions back to before we started. */
- (void)chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
- (void)chown(vtname, vtPermSave[2], vtPermSave[3]);
- }
-}
-
-static void *console_handler;
-
-static void
-drain_console(int fd, void *closure)
-{
- tcflush(fd, TCIOFLUSH);
-}
-
-void
-xf86OpenConsole(void)
-{
- int i, fd = -1;
- struct vt_mode VT;
- struct vt_stat vts;
- MessageType from = X_PROBED;
- char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
- char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
-
- if (serverGeneration == 1) {
-
- /* when KeepTty check if we're run with euid==0 */
- if (KeepTty && geteuid() != 0)
- FatalError("xf86OpenConsole:"
- " Server must be suid root for option \"KeepTTY\"\n");
-
- /*
- * setup the virtual terminal manager
- */
- if (VTnum != -1) {
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
- } else {
-
- i=0;
- while (tty0[i] != NULL) {
- if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
- break;
- i++;
- }
-
- if (fd < 0)
- FatalError(
- "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
- strerror(errno));
-
- if (ShareVTs)
- {
- if (ioctl(fd, VT_GETSTATE, &vts) == 0)
- xf86Info.vtno = vts.v_active;
- else
- FatalError("xf86OpenConsole: Cannot find the current"
- " VT (%s)\n", strerror(errno));
- } else {
- if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
- (xf86Info.vtno == -1))
- FatalError("xf86OpenConsole: Cannot find a free VT: %s\n",
- strerror(errno));
- }
- close(fd);
- }
-
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
-
- if (!KeepTty) {
- pid_t ppid = getppid();
- pid_t ppgid;
- ppgid = getpgid(ppid);
-
- /*
- * change to parent process group that pgid != pid so
- * that setsid() doesn't fail and we become process
- * group leader
- */
- if (setpgid(0,ppgid) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
- strerror(errno));
-
- /* become process group leader */
- if ((setsid() < 0))
- xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
- strerror(errno));
- }
-
- i=0;
- while (vcs[i] != NULL) {
- sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
- if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
- break;
- i++;
- }
-
- if (xf86Info.consoleFd < 0)
- FatalError("xf86OpenConsole: Cannot open virtual console"
- " %d (%s)\n", xf86Info.vtno, strerror(errno));
-
- if (!ShareVTs)
- {
- /*
- * Grab the vt ownership before we overwrite it.
- * Hard coded /dev/tty0 into this function as well for below.
- */
- if (!saveVtPerms())
- xf86Msg(X_WARNING,
- "xf86OpenConsole: Could not save ownership of VT\n");
-
- if (geteuid() == 0) {
- /* change ownership of the vt */
- if (chown(vtname, getuid(), getgid()) < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
- vtname, strerror(errno));
-
- /*
- * the current VT device we're running on is not
- * "console", we want to grab all consoles too
- *
- * Why is this needed??
- */
- if (chown("/dev/tty0", getuid(), getgid()) < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
- strerror(errno));
- }
- }
-
- /*
- * Linux doesn't switch to an active vt after the last close of a vt,
- * so we do this ourselves by remembering which is active now.
- */
- if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
- xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
- strerror(errno));
- else
- activeVT = vts.v_active;
-
-#if 0
- if (!KeepTty) {
- /*
- * Detach from the controlling tty to avoid char loss
- */
- if ((i = open("/dev/tty",O_RDWR)) >= 0) {
- ioctl(i, TIOCNOTTY, 0);
- close(i);
- }
- }
-#endif
-
- if (!ShareVTs)
- {
- struct termios nTty;
-
- /*
- * now get the VT. This _must_ succeed, or else fail completely.
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
- FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
- strerror(errno));
-
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
- FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
- strerror(errno));
-
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
- strerror(errno));
-
- signal(SIGUSR1, xf86VTRequest);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
-
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
- strerror(errno));
-
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
- strerror(errno));
-
- tcgetattr(xf86Info.consoleFd, &tty_attr);
- ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
-
- if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0)
- FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
- strerror(errno));
-
- nTty = tty_attr;
- nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
- nTty.c_oflag = 0;
- nTty.c_cflag = CREAD | CS8;
- nTty.c_lflag = 0;
- nTty.c_cc[VTIME]=0;
- nTty.c_cc[VMIN]=1;
- cfsetispeed(&nTty, 9600);
- cfsetospeed(&nTty, 9600);
- tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-
- /* need to keep the buffer clean, else the kernel gets angry */
- console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
- drain_console, NULL);
-
- /* we really should have a InitOSInputDevices() function instead
- * of Init?$#*&Device(). So I just place it here */
- }
- } else { /* serverGeneration != 1 */
- if (!ShareVTs && VTSwitch)
- {
- /*
- * now get the VT
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n",
- strerror(errno));
-
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n",
- strerror(errno));
- }
- }
-}
-
-void
-xf86CloseConsole(void)
-{
- struct vt_mode VT;
-
- if (ShareVTs) {
- close(xf86Info.consoleFd);
- return;
- }
-
- if (console_handler) {
- xf86RemoveGeneralHandler(console_handler);
- console_handler = NULL;
- };
-
- /* Back to text mode ... */
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
- strerror(errno));
-
- ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
- tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
-
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
- strerror(errno));
- else {
- /* set dflt vt handling */
- VT.mode = VT_AUTO;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
- strerror(errno));
- }
-
- if (VTSwitch)
- {
- /*
- * Perform a switch back to the active VT when we were started
- */
- if (activeVT >= 0) {
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
- xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
- strerror(errno));
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
- xf86Msg(X_WARNING,
- "xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
- strerror(errno));
- activeVT = -1;
- }
- }
- close(xf86Info.consoleFd); /* make the vt-manager happy */
-
- restoreVtPerms(); /* restore the permissions */
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return(1);
- }
- if (!strcmp(argv[i], "-novtswitch"))
- {
- VTSwitch = FALSE;
- return(1);
- }
- if (!strcmp(argv[i], "-sharevts"))
- {
- ShareVTs = TRUE;
- return(1);
- }
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
- {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- return(1);
- }
- return(0);
-}
-
-void
-xf86UseMsg(void)
-{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
- ErrorF("-novtswitch don't immediately switch to new VT\n");
- ErrorF("-sharevts share VTs with another X server\n");
-}
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE
+ * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include <sys/stat.h>
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static Bool VTSwitch = TRUE;
+static Bool ShareVTs = FALSE;
+static int activeVT = -1;
+
+static int vtPermSave[4];
+static char vtname[11];
+static struct termios tty_attr; /* tty state to restore */
+static int tty_mode; /* kbd mode to restore */
+
+static int
+saveVtPerms(void)
+{
+ /* We need to use stat to get permissions. */
+ struct stat svtp;
+
+ /* Do them numerically ordered, hard coded tty0 first. */
+ if (stat("/dev/tty0", &svtp) != 0)
+ return 0;
+ vtPermSave[0] = (int)svtp.st_uid;
+ vtPermSave[1] = (int)svtp.st_gid;
+
+ /* Now check the console we are dealing with. */
+ if (stat(vtname, &svtp) != 0)
+ return 0;
+ vtPermSave[2] = (int)svtp.st_uid;
+ vtPermSave[3] = (int)svtp.st_gid;
+
+ return 1;
+}
+
+static void
+restoreVtPerms(void)
+{
+ if (geteuid() == 0) {
+ /* Set the terminal permissions back to before we started. */
+ (void)chown("/dev/tty0", vtPermSave[0], vtPermSave[1]);
+ (void)chown(vtname, vtPermSave[2], vtPermSave[3]);
+ }
+}
+
+static void *console_handler;
+
+static void
+drain_console(int fd, void *closure)
+{
+ tcflush(fd, TCIOFLUSH);
+}
+
+void
+xf86OpenConsole(void)
+{
+ int i, fd = -1;
+ struct vt_mode VT;
+ struct vt_stat vts;
+ MessageType from = X_PROBED;
+ char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+ char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+
+ if (serverGeneration == 1) {
+
+ /* when KeepTty check if we're run with euid==0 */
+ if (KeepTty && geteuid() != 0)
+ FatalError("xf86OpenConsole:"
+ " Server must be suid root for option \"KeepTTY\"\n");
+
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum != -1) {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ } else {
+
+ i=0;
+ while (tty0[i] != NULL) {
+ if ((fd = open(tty0[i],O_WRONLY,0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (fd < 0)
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
+ strerror(errno));
+
+ if (ShareVTs)
+ {
+ if (ioctl(fd, VT_GETSTATE, &vts) == 0)
+ xf86Info.vtno = vts.v_active;
+ else
+ FatalError("xf86OpenConsole: Cannot find the current"
+ " VT (%s)\n", strerror(errno));
+ } else {
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ FatalError("xf86OpenConsole: Cannot find a free VT: %s\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ if (!KeepTty) {
+ pid_t ppid = getppid();
+ pid_t ppgid;
+ ppgid = getpgid(ppid);
+
+ /*
+ * change to parent process group that pgid != pid so
+ * that setsid() doesn't fail and we become process
+ * group leader
+ */
+ if (setpgid(0,ppgid) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
+ strerror(errno));
+
+ /* become process group leader */
+ if ((setsid() < 0))
+ xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
+ strerror(errno));
+ }
+
+ i=0;
+ while (vcs[i] != NULL) {
+ sprintf(vtname, vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
+ if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) >= 0)
+ break;
+ i++;
+ }
+
+ if (xf86Info.consoleFd < 0)
+ FatalError("xf86OpenConsole: Cannot open virtual console"
+ " %d (%s)\n", xf86Info.vtno, strerror(errno));
+
+ if (!ShareVTs)
+ {
+ /*
+ * Grab the vt ownership before we overwrite it.
+ * Hard coded /dev/tty0 into this function as well for below.
+ */
+ if (!saveVtPerms())
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: Could not save ownership of VT\n");
+
+ if (geteuid() == 0) {
+ /* change ownership of the vt */
+ if (chown(vtname, getuid(), getgid()) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: chown %s failed: %s\n",
+ vtname, strerror(errno));
+
+ /*
+ * the current VT device we're running on is not
+ * "console", we want to grab all consoles too
+ *
+ * Why is this needed??
+ */
+ if (chown("/dev/tty0", getuid(), getgid()) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: chown /dev/tty0 failed: %s\n",
+ strerror(errno));
+ }
+ }
+
+ /*
+ * Linux doesn't switch to an active vt after the last close of a vt,
+ * so we do this ourselves by remembering which is active now.
+ */
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) < 0)
+ xf86Msg(X_WARNING,"xf86OpenConsole: VT_GETSTATE failed: %s\n",
+ strerror(errno));
+ else
+ activeVT = vts.v_active;
+
+#if 0
+ if (!KeepTty) {
+ /*
+ * Detach from the controlling tty to avoid char loss
+ */
+ if ((i = open("/dev/tty",O_RDWR)) >= 0) {
+ ioctl(i, TIOCNOTTY, 0);
+ close(i);
+ }
+ }
+#endif
+
+ if (!ShareVTs)
+ {
+ struct termios nTty;
+
+ /*
+ * now get the VT. This _must_ succeed, or else fail completely.
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+ FatalError("xf86OpenConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
+ FatalError("xf86OpenConsole: VT_WAITACTIVE failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed %s\n",
+ strerror(errno));
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed: %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed %s\n",
+ strerror(errno));
+
+ tcgetattr(xf86Info.consoleFd, &tty_attr);
+ ioctl(xf86Info.consoleFd, KDGKBMODE, &tty_mode);
+
+ if (ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW) < 0)
+ FatalError("xf86OpenConsole: KDSKBMODE K_RAW failed %s\n",
+ strerror(errno));
+
+ nTty = tty_attr;
+ nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ nTty.c_oflag = 0;
+ nTty.c_cflag = CREAD | CS8;
+ nTty.c_lflag = 0;
+ nTty.c_cc[VTIME]=0;
+ nTty.c_cc[VMIN]=1;
+ cfsetispeed(&nTty, 9600);
+ cfsetospeed(&nTty, 9600);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+
+ /* need to keep the buffer clean, else the kernel gets angry */
+ console_handler = xf86AddGeneralHandler(xf86Info.consoleFd,
+ drain_console, NULL);
+
+ /* we really should have a InitOSInputDevices() function instead
+ * of Init?$#*&Device(). So I just place it here */
+ }
+ } else { /* serverGeneration != 1 */
+ if (!ShareVTs && VTSwitch)
+ {
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed %s\n",
+ strerror(errno));
+
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed %s\n",
+ strerror(errno));
+ }
+ }
+}
+
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+
+ if (ShareVTs) {
+ close(xf86Info.consoleFd);
+ return;
+ }
+
+ if (console_handler) {
+ xf86RemoveGeneralHandler(console_handler);
+ console_handler = NULL;
+ };
+
+ /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: KDSETMODE failed: %s\n",
+ strerror(errno));
+
+ ioctl(xf86Info.consoleFd, KDSKBMODE, tty_mode);
+ tcsetattr(xf86Info.consoleFd, TCSANOW, &tty_attr);
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_GETMODE failed: %s\n",
+ strerror(errno));
+ else {
+ /* set dflt vt handling */
+ VT.mode = VT_AUTO;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_SETMODE failed: %s\n",
+ strerror(errno));
+ }
+
+ if (VTSwitch)
+ {
+ /*
+ * Perform a switch back to the active VT when we were started
+ */
+ if (activeVT >= 0) {
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT) < 0)
+ xf86Msg(X_WARNING, "xf86CloseConsole: VT_ACTIVATE failed: %s\n",
+ strerror(errno));
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, activeVT) < 0)
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole: VT_WAITACTIVE failed: %s\n",
+ strerror(errno));
+ activeVT = -1;
+ }
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+
+ restoreVtPerms(); /* restore the permissions */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-novtswitch"))
+ {
+ VTSwitch = FALSE;
+ return 1;
+ }
+ if (!strcmp(argv[i], "-sharevts"))
+ {
+ ShareVTs = TRUE;
+ return 1;
+ }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void
+xf86UseMsg(void)
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ ErrorF("-novtswitch don't immediately switch to new VT\n");
+ ErrorF("-sharevts share VTs with another X server\n");
+}
diff --git a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c
index 9300b13b9..c9ef7d5cd 100644
--- a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c
+++ b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c
@@ -58,7 +58,7 @@ xf86VTRequest(int sig)
Bool
xf86VTSwitchPending(void)
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
/*
@@ -79,9 +79,9 @@ xf86VTSwitchAway(void)
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) {
- return(FALSE);
+ return FALSE;
} else {
- return(TRUE);
+ return TRUE;
}
}
@@ -97,7 +97,7 @@ xf86VTSwitchTo(void)
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
- return(FALSE);
+ return FALSE;
} else {
if (sco_ledstatus >= 0) {
ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate);
@@ -120,8 +120,8 @@ Bool
xf86VTActivate(int vtno)
{
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno - 1) < 0) {
- return(FALSE);
+ return FALSE;
}
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_init.c b/xorg-server/hw/xfree86/os-support/sco/sco_init.c
index 5f7db3437..fd4c898dd 100644
--- a/xorg-server/hw/xfree86/os-support/sco/sco_init.c
+++ b/xorg-server/hw/xfree86/os-support/sco/sco_init.c
@@ -1,294 +1,294 @@
-/*
- * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* Re-written May 2001 to represent the current state of reality */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-static Bool KeepTty = FALSE;
-static int VTnum = -1;
-static char vtdevice[48];
-static int sco_console_mode = -1;
-
-extern Bool mpxLock;
-
-void
-xf86OpenConsole(void)
-{
- int i, ioctl_ret;
- struct vt_mode VT;
- struct vid_info vidinf;
- struct sigaction sigvtsw;
- char *ttn;
-
- if (serverGeneration == 1) {
- /* check if we're run with euid==0 */
- if (geteuid() != 0) {
- FatalError("xf86OpenConsole: Server must be setuid root\n");
- }
-
- /* If we are run in the background we will get SIGTTOU. Ignore it. */
- OsSignal (SIGTTOU, SIG_IGN);
-
- /*
- * Set up the virtual terminal (multiscreen in SCO parlance).
- * For the actual console itself, screens are numbered from
- * 1 to (usually) 16. However, it is possible to have a nested
- * server, and it is also possible to be on a multi-console
- * system such as MaxSpeed or SunRiver. Therefore, we should
- * not make any assumptions about the TTY name we are on, and
- * instead we rely on ttyname() to give us the real TTY name.
- * Previously, we tried to determine the TTY name manually.
- * This is wrong. The only time we need to futz with the TTY name
- * is if we were given the name of a TTY to run on explicity on
- * the command line.
- */
-
- if (VTnum == -1) {
- /*
- * No device was specified. We need to query the kernel to see which
- * console device we are on (and in fact if we are on a console at all).
- */
- ttn = ttyname (1);
-
- if (ttn == (char *)0) {
- FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n",
- strerror(errno));
- }
- strlcpy (vtdevice, ttn, sizeof(vtdevice));
- } else if (VTnum >= 0) {
- snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum);
- }
-
- /*
- * Now we can dispose of stdin/stdout
- */
- fclose (stdin);
- fclose (stdout);
-
- if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
- FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
- strerror(errno));
- }
-
- /*
- * We make 100% sure we use the correct VT number. This can get ugly
- * where there are multi-consoles in use, so we make sure we query
- * the kernel for the correct VT number. It knows best, we don't.
- */
- vidinf.size = sizeof(vidinf);
- if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
- FatalError ("xf86OpenConsole: %s not a console device "
- "or error querying device: %s\n", vtdevice, strerror (errno));
- }
- xf86Info.vtno = vidinf.m_num;
- VTnum = vidinf.m_num + 1; /* 0-based */
-
- ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
-
- /* We activate the console just in case its not the one we are on */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
- }
-
- /* Disassociate from controling TTY */
- if (!KeepTty) {
- setpgrp();
- }
-
- /*
- * Now we get the current mode that the console device is in. We will
- * use this later when we close the console device to restore it to
- * that same mode.
- */
- if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
- FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
- strerror(errno));
- }
-
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
- FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
- }
-
- sigvtsw.sa_handler = xf86VTRequest;
- sigfillset(&sigvtsw.sa_mask);
- sigvtsw.sa_flags = 0;
-
- /* NOTE: Using sigaction means we dont have to re-arm the signal */
- sigaction(SIGUSR1, &sigvtsw, NULL);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGINT; /* Not implemented */
- VT.waitv = 0;
-
- /*
- * The SCO X server tries the following call 5 times. Lets do the same
- * thing. It shouldn't really be required but sometimes things take a
- * while to settle down when switching screens. *helpless shrug* I know
- * its sucks but ...
- */
-
- ioctl_ret = 0;
- for (i = 0; i < 5; i++) {
- ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
- if (ioctl_ret >= 0)
- break;
- usleep(999999); /* Dont use nap() - it forces linking with -lx */
- }
-
- if (ioctl_ret < 0) {
- FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
- }
-
- /*
- * Convince the console driver we are in graphics mode.
- */
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
- ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
- }
- } else { /* serverGeneration != 1 */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
- }
- }
-}
-
-/*
- * Restore the console to its previous state. This may cause flicker if
- * the screen was previous in a graphics mode, because we first set it
- * to text mode. This has the advantage of getting the console driver
- * to do a soft reset on the card, which really does help settle the
- * video card down again after coming out of Xfree86.
- */
-void
-xf86CloseConsole(void)
-{
- struct vt_mode VT;
- struct sigaction sigvtsw;
-
- /* Set text mode (possibly briefly) */
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
-
- /* Restore the original mode */
- if (sco_console_mode != -1) {
- ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
- }
-
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
-
- sigvtsw.sa_handler = SIG_DFL;
- sigfillset(&sigvtsw.sa_mask);
- sigvtsw.sa_flags = 0;
-
- sigaction(SIGUSR1, &sigvtsw, NULL);
-
- VT.mode = VT_AUTO;
- VT.waitv = 0;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGINT;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
-
- close(xf86Info.consoleFd); /* We're done with the device */
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals).
- */
- if (!strcmp(argv[i], "-keeptty")) {
- KeepTty = TRUE;
- return(1);
- }
-
- /*
- * By default, the X server wants to bind itself to CPU 0. This makes
- * sure that the server has full access to the I/O ports at IOPL 3.
- * Some SMP systems have trouble with I/O on CPU's other than 0. If,
- * however, you have a system that is well behaved, you can specify
- * this argument and let the scheduler decide which CPU the server
- * should run on.
- */
- if (!strcmp(argv[i], "-nompxlock")) {
- mpxLock = FALSE;
- return (1);
- }
-
- /*
- * Specify the VT number to run on (NOT the device).
- */
- if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- if (VTnum <= 0) {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- return(1);
- }
-
- /*
- * Use a device the user specifies.
- */
- if (!strcmp(argv[i], "-crt")) {
- if (++i > argc) {
- UseMsg();
- VTnum = -1;
- return(0);
- } else {
- VTnum = -2;
- strlcpy (vtdevice, argv[i], sizeof(vtdevice));
- return(2);
- }
- }
- return(0);
-}
-
-void
-xf86UseMsg(void)
-{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-crt DEVICE use the specified VT device\n");
- ErrorF("-nompxlock dont bind X server to CPU 0\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
-}
+/*
+ * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name J. Kean Johnston not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. J. Kean Johnston makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
+ * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Re-written May 2001 to represent the current state of reality */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static char vtdevice[48];
+static int sco_console_mode = -1;
+
+extern Bool mpxLock;
+
+void
+xf86OpenConsole(void)
+{
+ int i, ioctl_ret;
+ struct vt_mode VT;
+ struct vid_info vidinf;
+ struct sigaction sigvtsw;
+ char *ttn;
+
+ if (serverGeneration == 1) {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0) {
+ FatalError("xf86OpenConsole: Server must be setuid root\n");
+ }
+
+ /* If we are run in the background we will get SIGTTOU. Ignore it. */
+ OsSignal (SIGTTOU, SIG_IGN);
+
+ /*
+ * Set up the virtual terminal (multiscreen in SCO parlance).
+ * For the actual console itself, screens are numbered from
+ * 1 to (usually) 16. However, it is possible to have a nested
+ * server, and it is also possible to be on a multi-console
+ * system such as MaxSpeed or SunRiver. Therefore, we should
+ * not make any assumptions about the TTY name we are on, and
+ * instead we rely on ttyname() to give us the real TTY name.
+ * Previously, we tried to determine the TTY name manually.
+ * This is wrong. The only time we need to futz with the TTY name
+ * is if we were given the name of a TTY to run on explicity on
+ * the command line.
+ */
+
+ if (VTnum == -1) {
+ /*
+ * No device was specified. We need to query the kernel to see which
+ * console device we are on (and in fact if we are on a console at all).
+ */
+ ttn = ttyname (1);
+
+ if (ttn == (char *)0) {
+ FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n",
+ strerror(errno));
+ }
+ strlcpy (vtdevice, ttn, sizeof(vtdevice));
+ } else if (VTnum >= 0) {
+ snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum);
+ }
+
+ /*
+ * Now we can dispose of stdin/stdout
+ */
+ fclose (stdin);
+ fclose (stdout);
+
+ if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
+ FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
+ strerror(errno));
+ }
+
+ /*
+ * We make 100% sure we use the correct VT number. This can get ugly
+ * where there are multi-consoles in use, so we make sure we query
+ * the kernel for the correct VT number. It knows best, we don't.
+ */
+ vidinf.size = sizeof(vidinf);
+ if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
+ FatalError ("xf86OpenConsole: %s not a console device "
+ "or error querying device: %s\n", vtdevice, strerror (errno));
+ }
+ xf86Info.vtno = vidinf.m_num;
+ VTnum = vidinf.m_num + 1; /* 0-based */
+
+ ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
+
+ /* We activate the console just in case its not the one we are on */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+
+ /* Disassociate from controling TTY */
+ if (!KeepTty) {
+ setpgrp();
+ }
+
+ /*
+ * Now we get the current mode that the console device is in. We will
+ * use this later when we close the console device to restore it to
+ * that same mode.
+ */
+ if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
+ FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
+ strerror(errno));
+ }
+
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
+ FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
+ }
+
+ sigvtsw.sa_handler = xf86VTRequest;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ /* NOTE: Using sigaction means we dont have to re-arm the signal */
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT; /* Not implemented */
+ VT.waitv = 0;
+
+ /*
+ * The SCO X server tries the following call 5 times. Lets do the same
+ * thing. It shouldn't really be required but sometimes things take a
+ * while to settle down when switching screens. *helpless shrug* I know
+ * its sucks but ...
+ */
+
+ ioctl_ret = 0;
+ for (i = 0; i < 5; i++) {
+ ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ if (ioctl_ret >= 0)
+ break;
+ usleep(999999); /* Dont use nap() - it forces linking with -lx */
+ }
+
+ if (ioctl_ret < 0) {
+ FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
+ }
+
+ /*
+ * Convince the console driver we are in graphics mode.
+ */
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
+ ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
+ }
+ } else { /* serverGeneration != 1 */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
+ ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
+ }
+ }
+}
+
+/*
+ * Restore the console to its previous state. This may cause flicker if
+ * the screen was previous in a graphics mode, because we first set it
+ * to text mode. This has the advantage of getting the console driver
+ * to do a soft reset on the card, which really does help settle the
+ * video card down again after coming out of Xfree86.
+ */
+void
+xf86CloseConsole(void)
+{
+ struct vt_mode VT;
+ struct sigaction sigvtsw;
+
+ /* Set text mode (possibly briefly) */
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
+
+ /* Restore the original mode */
+ if (sco_console_mode != -1) {
+ ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
+ }
+
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
+
+ sigvtsw.sa_handler = SIG_DFL;
+ sigfillset(&sigvtsw.sa_mask);
+ sigvtsw.sa_flags = 0;
+
+ sigaction(SIGUSR1, &sigvtsw, NULL);
+
+ VT.mode = VT_AUTO;
+ VT.waitv = 0;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ VT.frsig = SIGINT;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
+
+ close(xf86Info.consoleFd); /* We're done with the device */
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals).
+ */
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return 1;
+ }
+
+ /*
+ * By default, the X server wants to bind itself to CPU 0. This makes
+ * sure that the server has full access to the I/O ports at IOPL 3.
+ * Some SMP systems have trouble with I/O on CPU's other than 0. If,
+ * however, you have a system that is well behaved, you can specify
+ * this argument and let the scheduler decide which CPU the server
+ * should run on.
+ */
+ if (!strcmp(argv[i], "-nompxlock")) {
+ mpxLock = FALSE;
+ return 1;
+ }
+
+ /*
+ * Specify the VT number to run on (NOT the device).
+ */
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ if (VTnum <= 0) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+
+ /*
+ * Use a device the user specifies.
+ */
+ if (!strcmp(argv[i], "-crt")) {
+ if (++i > argc) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ } else {
+ VTnum = -2;
+ strlcpy (vtdevice, argv[i], sizeof(vtdevice));
+ return 2;
+ }
+ }
+ return 0;
+}
+
+void
+xf86UseMsg(void)
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-crt DEVICE use the specified VT device\n");
+ ErrorF("-nompxlock dont bind X server to CPU 0\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+}
diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c
index f3ddb29c9..be47cd681 100644
--- a/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c
+++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_noop.c
@@ -38,23 +38,23 @@
Bool
xf86VTSwitchPending(void)
{
- return(FALSE);
+ return FALSE;
}
Bool
xf86VTSwitchAway(void)
{
- return(FALSE);
+ return FALSE;
}
Bool
xf86VTSwitchTo(void)
{
- return(TRUE);
+ return TRUE;
}
Bool
xf86VTActivate(int vtno)
{
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c
index 34bca7ae2..00bfb7151 100644
--- a/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c
+++ b/xorg-server/hw/xfree86/os-support/shared/VTsw_usl.c
@@ -55,7 +55,7 @@ xf86VTRequest(int sig)
Bool
xf86VTSwitchPending(void)
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
Bool
@@ -64,14 +64,14 @@ xf86VTSwitchAway(void)
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
{
- return(FALSE);
+ return FALSE;
}
else
{
#ifdef OSSWITCHAWAY
OSSWITCHAWAY;
#endif
- return(TRUE);
+ return TRUE;
}
}
@@ -81,11 +81,11 @@ xf86VTSwitchTo(void)
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
{
- return(FALSE);
+ return FALSE;
}
else
{
- return(TRUE);
+ return TRUE;
}
}
@@ -94,8 +94,8 @@ xf86VTActivate(int vtno)
{
#ifdef VT_ACTIVATE
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno) < 0) {
- return(FALSE);
+ return FALSE;
}
#endif
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c
index 67a14f5d6..4699fcb88 100644
--- a/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c
+++ b/xorg-server/hw/xfree86/os-support/shared/bios_devmem.c
@@ -1,75 +1,75 @@
-/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. David Wexelblat makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include <string.h>
-
-/*
- * Read BIOS via /dev/mem.
- */
-
-#ifndef DEV_MEM
-# define DEV_MEM "/dev/mem"
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- int fd;
-
-#ifdef __ia64__
- if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
-#else
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
-#endif
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return(-1);
- }
-
- if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return(-1);
- }
- if (read(fd, Buf, Len) != Len)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return(-1);
- }
- close(fd);
- return(Len);
-}
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include <string.h>
+
+/*
+ * Read BIOS via /dev/mem.
+ */
+
+#ifndef DEV_MEM
+# define DEV_MEM "/dev/mem"
+#endif
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+
+#ifdef __ia64__
+ if ((fd = open(DEV_MEM, O_RDONLY | O_SYNC)) < 0)
+#else
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+#endif
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ if (lseek(fd, (Base+Offset), SEEK_SET) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s seek failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ if (read(fd, Buf, Len) != Len)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s read failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return Len;
+}
diff --git a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
index 40afd5b8e..a5887f578 100644
--- a/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
+++ b/xorg-server/hw/xfree86/os-support/shared/bios_mmap.c
@@ -1,141 +1,141 @@
-/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. David Wexelblat makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-/*
- * Read BIOS via mmap()ing DEV_MEM
- */
-
-#ifndef __alpha__
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- int fd;
- unsigned char *ptr;
- int psize;
- int mlen;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return(-1);
- }
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, fd, (off_t)Base);
- if (ptr == MAP_FAILED)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
- DEV_MEM, strerror(errno));
- close(fd);
- return(-1);
- }
- DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
- Base, ptr[0] | (ptr[1] << 8));
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- (void)munmap((caddr_t)ptr, mlen);
- (void)close(fd);
- return(Len);
-}
-
-#else /* __alpha__ */
-
- /*
- * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
- * which is the KSEG address of the start of the DENSE memory
- * area.
- */
-
- /*
- * NOTE: there prolly ought to be more validity checks and all
- * re: boundaries and sizes and such...
- */
-
-#ifdef linux
-
-extern unsigned long _bus_base(void);
-#define BUS_BASE _bus_base()
-
-#else
-
-extern u_int64_t dense_base(void);
-#define BUS_BASE dense_base()
-
-#endif
-
-int
-xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
-{
- caddr_t base;
- int fd;
- int psize;
- int mlen;
-
- if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- return(-1);
- }
-
- psize = getpagesize();
- Offset += Base & (psize - 1);
- Base &= ~(psize - 1);
- mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- base = mmap((caddr_t)0, mlen, PROT_READ,
- MAP_SHARED, fd, (off_t)(Base + BUS_BASE));
-
- if (base == MAP_FAILED)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
- DEV_MEM, strerror(errno));
- return(-1);
- }
-
- xf86SlowBCopyFromBus((unsigned char *)(base+Offset), Buf, Len);
-
- munmap((caddr_t)base, mlen);
- close(fd);
- return(Len);
-}
-
-#endif /* __alpha__ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. David Wexelblat makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+/*
+ * Read BIOS via mmap()ing DEV_MEM
+ */
+
+#ifndef __alpha__
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ int fd;
+ unsigned char *ptr;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ ptr = (unsigned char *)mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)Base);
+ if (ptr == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed (%s)\n",
+ DEV_MEM, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ DebugF("xf86ReadBIOS: BIOS at 0x%08x has signature 0x%04x\n",
+ Base, ptr[0] | (ptr[1] << 8));
+ (void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ (void)munmap((caddr_t)ptr, mlen);
+ (void)close(fd);
+ return Len;
+}
+
+#else /* __alpha__ */
+
+ /*
+ * We trick "mmap" into mapping BUS memory for us via BUS_BASE,
+ * which is the KSEG address of the start of the DENSE memory
+ * area.
+ */
+
+ /*
+ * NOTE: there prolly ought to be more validity checks and all
+ * re: boundaries and sizes and such...
+ */
+
+#ifdef linux
+
+extern unsigned long _bus_base(void);
+#define BUS_BASE _bus_base()
+
+#else
+
+extern u_int64_t dense_base(void);
+#define BUS_BASE dense_base()
+
+#endif
+
+int
+xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
+ int Len)
+{
+ caddr_t base;
+ int fd;
+ int psize;
+ int mlen;
+
+ if ((fd = open(DEV_MEM, O_RDONLY)) < 0)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ psize = getpagesize();
+ Offset += Base & (psize - 1);
+ Base &= ~(psize - 1);
+ mlen = (Offset + Len + psize - 1) & ~(psize - 1);
+ base = mmap((caddr_t)0, mlen, PROT_READ,
+ MAP_SHARED, fd, (off_t)(Base + BUS_BASE));
+
+ if (base == MAP_FAILED)
+ {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: Failed to mmap %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ return -1;
+ }
+
+ xf86SlowBCopyFromBus((unsigned char *)(base+Offset), Buf, Len);
+
+ munmap((caddr_t)base, mlen);
+ close(fd);
+ return Len;
+}
+
+#endif /* __alpha__ */
diff --git a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c
index 7e2c4a181..97860d0f2 100644
--- a/xorg-server/hw/xfree86/os-support/shared/posix_tty.c
+++ b/xorg-server/hw/xfree86/os-support/shared/posix_tty.c
@@ -108,7 +108,7 @@ GetBaud (int baudrate)
if (baudrate == 460800)
return B460800;
#endif
- return (0);
+ return 0;
}
int
@@ -122,7 +122,7 @@ xf86OpenSerial (pointer options)
if (!dev)
{
xf86Msg (X_ERROR, "xf86OpenSerial: No Device specified.\n");
- return (-1);
+ return -1;
}
SYSCALL (fd = open (dev, O_RDWR | O_NONBLOCK));
@@ -132,14 +132,14 @@ xf86OpenSerial (pointer options)
"xf86OpenSerial: Cannot open device %s\n\t%s.\n",
dev, strerror (errno));
free(dev);
- return (-1);
+ return -1;
}
if (!isatty (fd))
{
/* Allow non-tty devices to be opened. */
free(dev);
- return (fd);
+ return fd;
}
/* set up default port parameters */
@@ -162,7 +162,7 @@ xf86OpenSerial (pointer options)
{
SYSCALL (close (fd));
free(dev);
- return (-1);
+ return -1;
}
SYSCALL (i = fcntl (fd, F_GETFL, 0));
@@ -170,7 +170,7 @@ xf86OpenSerial (pointer options)
{
SYSCALL (close (fd));
free(dev);
- return (-1);
+ return -1;
}
i &= ~O_NONBLOCK;
SYSCALL (i = fcntl (fd, F_SETFL, i));
@@ -178,10 +178,10 @@ xf86OpenSerial (pointer options)
{
SYSCALL (close (fd));
free(dev);
- return (-1);
+ return -1;
}
free(dev);
- return (fd);
+ return fd;
}
int
@@ -212,7 +212,7 @@ xf86SetSerial (int fd, pointer options)
{
xf86Msg (X_ERROR,
"Invalid Option BaudRate value: %d\n", val);
- return (-1);
+ return -1;
}
}
@@ -229,7 +229,7 @@ xf86SetSerial (int fd, pointer options)
default:
xf86Msg (X_ERROR,
"Invalid Option StopBits value: %d\n", val);
- return (-1);
+ return -1;
break;
}
}
@@ -257,7 +257,7 @@ xf86SetSerial (int fd, pointer options)
default:
xf86Msg (X_ERROR,
"Invalid Option DataBits value: %d\n", val);
- return (-1);
+ return -1;
break;
}
}
@@ -281,7 +281,7 @@ xf86SetSerial (int fd, pointer options)
{
xf86Msg (X_ERROR, "Invalid Option Parity value: %s\n",
s);
- return (-1);
+ return -1;
}
}
@@ -317,7 +317,7 @@ xf86SetSerial (int fd, pointer options)
{
xf86Msg (X_ERROR,
"Invalid Option FlowControl value: %s\n", s);
- return (-1);
+ return -1;
}
}
@@ -333,7 +333,7 @@ xf86SetSerial (int fd, pointer options)
#else
xf86Msg (X_WARNING,
"Option ClearDTR not supported on this OS\n");
- return (-1);
+ return -1;
#endif
xf86MarkOptionUsedByName (options, "ClearDTR");
}
@@ -342,12 +342,12 @@ xf86SetSerial (int fd, pointer options)
{
xf86Msg (X_WARNING,
"Option ClearRTS not supported on this OS\n");
- return (-1);
+ return -1;
xf86MarkOptionUsedByName (options, "ClearRTS");
}
SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
- return (r);
+ return r;
}
int
@@ -374,11 +374,11 @@ xf86SetSerialSpeed (int fd, int speed)
{
xf86Msg (X_ERROR,
"Invalid Option BaudRate value: %d\n", speed);
- return (-1);
+ return -1;
}
SYSCALL (r = tcsetattr (fd, TCSANOW, &t));
- return (r);
+ return r;
}
int
@@ -393,7 +393,7 @@ xf86ReadSerial (int fd, void *buf, int count)
for (i = 1; i < r; i++)
DebugF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
DebugF("\n");
- return (r);
+ return r;
}
int
@@ -407,7 +407,7 @@ xf86WriteSerial (int fd, const void *buf, int count)
ErrorF(", 0x%x",(unsigned char)*(((unsigned char *)buf) + i));
DebugF("\n");
SYSCALL (r = write (fd, buf, count));
- return (r);
+ return r;
}
int
@@ -416,7 +416,7 @@ xf86CloseSerial (int fd)
int r;
SYSCALL (r = close (fd));
- return (r);
+ return r;
}
int
@@ -442,7 +442,7 @@ xf86WaitForInput (int fd, int timeout)
SYSCALL (r = select (FD_SETSIZE, NULL, NULL, NULL, &to));
}
xf86ErrorFVerb (9,"select returned %d\n", r);
- return (r);
+ return r;
}
int
@@ -451,7 +451,7 @@ xf86SerialSendBreak (int fd, int duration)
int r;
SYSCALL (r = tcsendbreak (fd, duration));
- return (r);
+ return r;
}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c b/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c
index ee5c7c064..e297f8c49 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -66,7 +66,7 @@ xf86VTAcquire(int sig)
Bool
xf86VTSwitchPending(void)
{
- return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+ return xf86Info.vtRequestsPending ? TRUE : FALSE;
}
Bool
@@ -81,7 +81,7 @@ xf86VTSwitchAway(void)
if (xf86VTPruneDoor) {
xf86VTPruneDoor = 0;
ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- return (TRUE);
+ return TRUE;
}
vt_door_arg.vt_ev = VT_EV_HOTKEYS;
@@ -94,15 +94,15 @@ xf86VTSwitchAway(void)
door_arg.desc_num = 0;
if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
- return (FALSE);
+ return FALSE;
if (door_call(door_fd, &door_arg) != 0) {
close(door_fd);
- return (FALSE);
+ return FALSE;
}
close(door_fd);
- return (TRUE);
+ return TRUE;
}
Bool
@@ -111,11 +111,11 @@ xf86VTSwitchTo(void)
xf86Info.vtRequestsPending = FALSE;
if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
{
- return(FALSE);
+ return FALSE;
}
else
{
- return(TRUE);
+ return TRUE;
}
}
@@ -125,13 +125,13 @@ xf86VTActivate(int vtno)
struct vt_stat state;
if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
- return(FALSE);
+ return FALSE;
if ((state.v_state & (1 << vtno)) == 0)
- return(FALSE);
+ return FALSE;
xf86Info.vtRequestsPending = TRUE;
xf86Info.vtPendingNum = vtno;
- return(TRUE);
+ return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c b/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c
index a5fb5c6e6..b85a3c86b 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_agp.c
@@ -78,7 +78,7 @@ static Bool
GARTInit(int screenNum)
{
if (initDone)
- return (gartFd != -1);
+ return gartFd != -1;
if (gartFd == -1)
gartFd = open(AGP_DEVICE, O_RDWR);
@@ -115,16 +115,16 @@ xf86GetAGPInfo(int screenNum)
if (!GARTInit(screenNum))
return NULL;
- if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
return NULL;
}
- if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
- strerror(errno));
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
return NULL;
}
diff --git a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c
index 05d17492a..e064c9733 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/xorg-server/hw/xfree86/os-support/solaris/sun_bell.c
@@ -1,180 +1,180 @@
-/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <sys/audio.h>
-#include <sys/uio.h>
-#include <limits.h>
-#include <math.h>
-#include <poll.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define BELL_RATE 48000 /* Samples per second */
-#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
-#define BELL_MS (1000/BELL_HZ) /* MS */
-#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
-#define BELL_MIN 3 /* Min # of repeats */
-
-#define AUDIO_DEVICE "/dev/audio"
-
-void
-xf86OSRingBell(int loudness, int pitch, int duration)
-{
- static short samples[BELL_SAMPLES];
- static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
- static int lastFreq;
- int cnt;
- int i;
- int written;
- int repeats;
- int freq;
- audio_info_t audioInfo;
- struct iovec iov[IOV_MAX];
- int iovcnt;
- double ampl, cyclen, phase;
- int audioFD;
-
- if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
- return;
- }
-
- lastFreq = 0;
- bzero(silence, sizeof(silence));
-
- audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK);
- if (audioFD == -1) {
- xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n",
- AUDIO_DEVICE, strerror(errno));
- return;
- }
-
- freq = pitch;
- freq = min(freq, (BELL_RATE / 2) - 1);
- freq = max(freq, 2 * BELL_HZ);
-
- /*
- * Ensure full waves per buffer
- */
- freq -= freq % BELL_HZ;
-
- if (freq != lastFreq) {
- lastFreq = freq;
- ampl = 16384.0;
-
- cyclen = (double) freq / (double) BELL_RATE;
- phase = 0.0;
-
- for (i = 0; i < BELL_SAMPLES; i++) {
- samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
- phase += cyclen;
- if (phase >= 1.0)
- phase -= 1.0;
- }
- }
-
- repeats = (duration + (BELL_MS / 2)) / BELL_MS;
- repeats = max(repeats, BELL_MIN);
-
- loudness = max(0, loudness);
- loudness = min(loudness, 100);
-
-#ifdef DEBUG
- ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
- freq, loudness, duration, repeats);
-#endif
-
- AUDIO_INITINFO(&audioInfo);
- audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
- audioInfo.play.sample_rate = BELL_RATE;
- audioInfo.play.channels = 2;
- audioInfo.play.precision = 16;
- audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
-
- if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
- xf86Msg(X_ERROR,
- "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
- AUDIO_DEVICE, strerror(errno));
- close(audioFD);
- return;
- }
-
- iovcnt = 0;
-
- for (cnt = 0; cnt <= repeats; cnt++) {
- if (cnt == repeats) {
- /* Insert a bit of silence so that multiple beeps are distinct and
- * not compressed into a single tone.
- */
- iov[iovcnt].iov_base = (char *) silence;
- iov[iovcnt++].iov_len = sizeof(silence);
- } else {
- iov[iovcnt].iov_base = (char *) samples;
- iov[iovcnt++].iov_len = sizeof(samples);
- }
- if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
- written = writev(audioFD, iov, iovcnt);
-
- if ((written < ((int)(sizeof(samples) * iovcnt)))) {
- /* audio buffer was full! */
-
- int naptime;
-
- if (written == -1) {
- if (errno != EAGAIN) {
- xf86Msg(X_ERROR,
- "Bell: writev failed on audio device \"%s\": %s\n",
- AUDIO_DEVICE, strerror(errno));
- close(audioFD);
- return;
- }
- i = iovcnt;
- } else {
- i = ((sizeof(samples) * iovcnt) - written)
- / sizeof(samples);
- }
- cnt -= i;
-
- /* sleep a little to allow audio buffer to drain */
- naptime = BELL_MS * i;
- poll(NULL, 0, naptime);
-
- i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
- iovcnt = 0;
- if ((written != -1) && (i > 0)) {
- iov[iovcnt].iov_base = ((char *) samples) + i;
- iov[iovcnt++].iov_len = sizeof(samples) - i;
- }
- } else {
- iovcnt = 0;
- }
- }
- }
-
- close(audioFD);
- return;
-}
+/* Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#define BELL_RATE 48000 /* Samples per second */
+#define BELL_HZ 50 /* Fraction of a second i.e. 1/x */
+#define BELL_MS (1000/BELL_HZ) /* MS */
+#define BELL_SAMPLES (BELL_RATE / BELL_HZ)
+#define BELL_MIN 3 /* Min # of repeats */
+
+#define AUDIO_DEVICE "/dev/audio"
+
+void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+ static short samples[BELL_SAMPLES];
+ static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+ static int lastFreq;
+ int cnt;
+ int i;
+ int written;
+ int repeats;
+ int freq;
+ audio_info_t audioInfo;
+ struct iovec iov[IOV_MAX];
+ int iovcnt;
+ double ampl, cyclen, phase;
+ int audioFD;
+
+ if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+ return;
+ }
+
+ lastFreq = 0;
+ memset(silence, 0, sizeof(silence));
+
+ audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK);
+ if (audioFD == -1) {
+ xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ return;
+ }
+
+ freq = pitch;
+ freq = min(freq, (BELL_RATE / 2) - 1);
+ freq = max(freq, 2 * BELL_HZ);
+
+ /*
+ * Ensure full waves per buffer
+ */
+ freq -= freq % BELL_HZ;
+
+ if (freq != lastFreq) {
+ lastFreq = freq;
+ ampl = 16384.0;
+
+ cyclen = (double) freq / (double) BELL_RATE;
+ phase = 0.0;
+
+ for (i = 0; i < BELL_SAMPLES; i++) {
+ samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+ phase += cyclen;
+ if (phase >= 1.0)
+ phase -= 1.0;
+ }
+ }
+
+ repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+ repeats = max(repeats, BELL_MIN);
+
+ loudness = max(0, loudness);
+ loudness = min(loudness, 100);
+
+#ifdef DEBUG
+ ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+ freq, loudness, duration, repeats);
+#endif
+
+ AUDIO_INITINFO(&audioInfo);
+ audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+ audioInfo.play.sample_rate = BELL_RATE;
+ audioInfo.play.channels = 2;
+ audioInfo.play.precision = 16;
+ audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+ if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+ xf86Msg(X_ERROR,
+ "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ close(audioFD);
+ return;
+ }
+
+ iovcnt = 0;
+
+ for (cnt = 0; cnt <= repeats; cnt++) {
+ if (cnt == repeats) {
+ /* Insert a bit of silence so that multiple beeps are distinct and
+ * not compressed into a single tone.
+ */
+ iov[iovcnt].iov_base = (char *) silence;
+ iov[iovcnt++].iov_len = sizeof(silence);
+ } else {
+ iov[iovcnt].iov_base = (char *) samples;
+ iov[iovcnt++].iov_len = sizeof(samples);
+ }
+ if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+ written = writev(audioFD, iov, iovcnt);
+
+ if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+ /* audio buffer was full! */
+
+ int naptime;
+
+ if (written == -1) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_ERROR,
+ "Bell: writev failed on audio device \"%s\": %s\n",
+ AUDIO_DEVICE, strerror(errno));
+ close(audioFD);
+ return;
+ }
+ i = iovcnt;
+ } else {
+ i = ((sizeof(samples) * iovcnt) - written)
+ / sizeof(samples);
+ }
+ cnt -= i;
+
+ /* sleep a little to allow audio buffer to drain */
+ naptime = BELL_MS * i;
+ poll(NULL, 0, naptime);
+
+ i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+ iovcnt = 0;
+ if ((written != -1) && (i > 0)) {
+ iov[iovcnt].iov_base = ((char *) samples) + i;
+ iov[iovcnt++].iov_len = sizeof(samples) - i;
+ }
+ } else {
+ iovcnt = 0;
+ }
+ }
+ }
+
+ close(audioFD);
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c
index 170bb8914..3b94ac135 100644
--- a/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c
+++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_init.c
@@ -1,252 +1,252 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Thomas Roell and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Thomas Roell and
- * David Wexelblat makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-static Bool KeepTty = FALSE;
-#ifdef SVR4
-static Bool Protect0 = FALSE;
-#endif
-static int VTnum = -1;
-
-
-void
-xf86OpenConsole()
-{
- int fd;
- struct vt_mode VT;
- char vtname1[10],vtname2[10];
- MessageType from = X_PROBED;
-
- if (serverGeneration == 1)
- {
- /* check if we're run with euid==0 */
- if (geteuid() != 0)
- {
- FatalError("xf86OpenConsole: Server must be suid root\n");
- }
-
-#ifdef SVR4
- /* Protect page 0 to help find NULL dereferencing */
- /* mprotect() doesn't seem to work */
- if (Protect0)
- {
- int fd = -1;
-
- if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: cannot open /dev/zero (%s)\n",
- strerror(errno));
- }
- else
- {
- if ((int)mmap(0, 0x1000, PROT_NONE,
- MAP_FIXED | MAP_SHARED, fd, 0) == -1)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: failed to protect page 0 (%s)\n",
- strerror(errno));
- }
- close(fd);
- }
- }
-#endif
- /*
- * setup the virtual terminal manager
- */
- if (VTnum != -1)
- {
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
- }
- else
- {
- if ((fd = open("/dev/console",O_WRONLY,0)) < 0)
- {
- FatalError(
- "xf86OpenConsole: Cannot open /dev/console (%s)\n",
- strerror(errno));
- }
- if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
- (xf86Info.vtno == -1))
- {
- FatalError("xf86OpenConsole: Cannot find a free VT\n");
- }
- close(fd);
- }
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
-
- sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */
- sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */
-
- if (!KeepTty)
- {
- setpgrp();
- }
-
- if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) &&
- ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0))
- {
- FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n",
- vtname2, vtname1, strerror(errno));
- }
-
- /* change ownership of the vt */
- if (chown(vtname1, getuid(), getgid()) < 0)
- {
- chown(vtname2, getuid(), getgid());
- }
-
- /*
- * now get the VT
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
- }
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- {
- FatalError("xf86OpenConsole: VT_GETMODE failed\n");
- }
-
- signal(SIGUSR1, xf86VTRequest);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- {
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
- }
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- {
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
- }
- }
- else
- {
- /* serverGeneration != 1 */
- /*
- * now get the VT
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
- }
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
- {
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
- }
- /*
- * If the server doesn't have the VT when the reset occurs,
- * this is to make sure we don't continue until the activate
- * signal is received.
- */
- if (!xf86Screens[0]->vtSema)
- sleep(5);
- }
- return;
-}
-
-void
-xf86CloseConsole()
-{
- struct vt_mode VT;
-
-#if 0
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
- ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
-#endif
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
- }
- close(xf86Info.consoleFd); /* make the vt-manager happy */
- return;
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals.
- */
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return(1);
- }
-#ifdef SVR4
- /*
- * Undocumented flag to protect page 0 from read/write to help
- * catch NULL pointer dereferences. This is purely a debugging
- * flag.
- */
- if (!strcmp(argv[i], "-protect0"))
- {
- Protect0 = TRUE;
- return(1);
- }
-#endif
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
- {
- UseMsg();
- VTnum = -1;
- return(0);
- }
- return(1);
- }
- return(0);
-}
-
-void
-xf86UseMsg()
-{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
- return;
-}
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+static Bool KeepTty = FALSE;
+#ifdef SVR4
+static Bool Protect0 = FALSE;
+#endif
+static int VTnum = -1;
+
+
+void
+xf86OpenConsole()
+{
+ int fd;
+ struct vt_mode VT;
+ char vtname1[10],vtname2[10];
+ MessageType from = X_PROBED;
+
+ if (serverGeneration == 1)
+ {
+ /* check if we're run with euid==0 */
+ if (geteuid() != 0)
+ {
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+ }
+
+#ifdef SVR4
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0)
+ {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else
+ {
+ if ((int)mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+ }
+ close(fd);
+ }
+ }
+#endif
+ /*
+ * setup the virtual terminal manager
+ */
+ if (VTnum != -1)
+ {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else
+ {
+ if ((fd = open("/dev/console",O_WRONLY,0)) < 0)
+ {
+ FatalError(
+ "xf86OpenConsole: Cannot open /dev/console (%s)\n",
+ strerror(errno));
+ }
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1))
+ {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ close(fd);
+ }
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+
+ sprintf(vtname1,"/dev/vc%02d",xf86Info.vtno); /* ESIX */
+ sprintf(vtname2,"/dev/vt%02d",xf86Info.vtno); /* rest of the world */
+
+ if (!KeepTty)
+ {
+ setpgrp();
+ }
+
+ if (((xf86Info.consoleFd = open(vtname1, O_RDWR|O_NDELAY, 0)) < 0) &&
+ ((xf86Info.consoleFd = open(vtname2, O_RDWR|O_NDELAY, 0)) < 0))
+ {
+ FatalError("xf86OpenConsole: Cannot open %s (%s) (%s)\n",
+ vtname2, vtname1, strerror(errno));
+ }
+
+ /* change ownership of the vt */
+ if (chown(vtname1, getuid(), getgid()) < 0)
+ {
+ chown(vtname2, getuid(), getgid());
+ }
+
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ }
+
+ signal(SIGUSR1, xf86VTRequest);
+
+ VT.mode = VT_PROCESS;
+ VT.relsig = SIGUSR1;
+ VT.acqsig = SIGUSR1;
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ {
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ {
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+ }
+ }
+ else
+ {
+ /* serverGeneration != 1 */
+ /*
+ * now get the VT
+ */
+ if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ }
+ if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+ {
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ }
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+ return;
+}
+
+void
+xf86CloseConsole()
+{
+ struct vt_mode VT;
+
+#if 0
+ ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
+ ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
+#endif
+ ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT); /* Back to text mode ... */
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+ {
+ VT.mode = VT_AUTO;
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+ }
+ close(xf86Info.consoleFd); /* make the vt-manager happy */
+ return;
+}
+
+int
+xf86ProcessArgument(int argc, char *argv[], int i)
+{
+ /*
+ * Keep server from detaching from controlling tty. This is useful
+ * when debugging (so the server can receive keyboard signals.
+ */
+ if (!strcmp(argv[i], "-keeptty"))
+ {
+ KeepTty = TRUE;
+ return 1;
+ }
+#ifdef SVR4
+ /*
+ * Undocumented flag to protect page 0 from read/write to help
+ * catch NULL pointer dereferences. This is purely a debugging
+ * flag.
+ */
+ if (!strcmp(argv[i], "-protect0"))
+ {
+ Protect0 = TRUE;
+ return 1;
+ }
+#endif
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ {
+ if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+void
+xf86UseMsg()
+{
+ ErrorF("vtXX use the specified VT number\n");
+ ErrorF("-keeptty ");
+ ErrorF("don't detach controlling tty (for debugging only)\n");
+ return;
+}
diff --git a/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c
index 43c30621c..6d5948796 100644
--- a/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c
+++ b/xorg-server/hw/xfree86/os-support/sysv/sysv_video.c
@@ -1,315 +1,315 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the names of Thomas Roell and David Wexelblat
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission. Thomas Roell and
- * David Wexelblat makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#define _NEED_SYSI86
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSpriv.h"
-
-#ifndef MAP_FAILED
-#define MAP_FAILED ((void *)-1)
-#endif
-
-#ifndef SI86IOPL
-#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
-#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
-#else
-#define SET_IOPL() sysi86(SI86IOPL,3)
-#define RESET_IOPL() sysi86(SI86IOPL,0)
-#endif
-
-/***************************************************************************/
-/* Video Memory Mapping section */
-/***************************************************************************/
-
-/*
- * XXX Support for SVR3 will need to be reworked if needed. In particular
- * the Region parameter is no longer passed, and will need to be dealt
- * with internally if required.
- * OK, i'll rework that thing ... (clean it up a lot)
- * SVR3 Support only with SVR3_MMAPDRV (mr)
- *
- */
-
-#ifdef HAS_SVR3_MMAPDRV
-#ifndef MMAP_DEBUG
-#define MMAP_DEBUG 3
-#endif
-
-struct kd_memloc MapDSC;
-int mmapFd = -2;
-
-static int
-mmapStat(pointer Base, unsigned long Size) {
-
- int nmmreg,i=0,region=-1;
- mmapinfo_t *ibuf;
-
- nmmreg = ioctl(mmapFd, GETNMMREG);
-
- if(nmmreg <= 0)
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "\nNo physical memory mapped currently.\n\n");
- else {
- if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL)
- xf86Msg(X_WARNING,
- "Couldn't allocate memory 4 mmapinfo_t\n");
- else {
- if(ioctl(mmapFd, GETMMREG, ibuf) != -1)
- {
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "# mmapStat: [Size=%x,Base=%x]\n", Size, Base);
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "# Physical Address Size Reference Count\n");
- for(i = 0; i < nmmreg; i++) {
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "%-4d 0x%08X %5dk %5d ",
- i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt);
- if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) {
- xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!");
- if (region==-1) region=i;
- }
- xf86ErrorFVerb(MMAP_DEBUG, "\n");
- }
- xf86ErrorFVerb(MMAP_DEBUG, "\n");
- }
- free(ibuf);
- }
- }
- if (region == -1 && nmmreg > 0) region=region * i;
- return(region);
-}
-#endif
-
-
-static Bool
-linearVidMem()
-{
-#ifdef SVR4
- return TRUE;
-#elif defined(HAS_SVR3_MMAPDRV)
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "# xf86LinearVidMem: MMAP 2.2.2 called\n");
-
- if(mmapFd >= 0) return TRUE;
-
- if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1)
- {
- if(ioctl(mmapFd, GETVERSION) < 0x0222) {
- xf86Msg(X_WARNING,
- "xf86LinearVidMem: MMAP 2.2.2 or above required\n");
- xf86ErrorF("\tlinear memory access disabled\n");
- return FALSE;
- }
- return TRUE;
- }
- xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
- strerror(errno));
- xf86ErrorF("\tlinear memory access disabled\n");
- return FALSE;
-#endif
-}
-
-static pointer
-mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
-{
- pointer base;
- int fd;
-
-#if defined(SVR4)
- fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
- if (fd < 0)
- {
- FatalError("xf86MapVidMem: failed to open %s (%s)\n",
- DEV_MEM, strerror(errno));
- }
- base = mmap((caddr_t)0, Size,
- (flags & VIDMEM_READONLY) ?
- PROT_READ : (PROT_READ | PROT_WRITE),
- MAP_SHARED, fd, (off_t)Base);
- close(fd);
- if (base == MAP_FAILED)
- {
- FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
- "xf86MapVidMem", Size, Base, strerror(errno));
- }
-#else /* SVR4 */
-#ifdef HAS_SVR3_MMAPDRV
-
- xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n");
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
- if (ioctl(mmapFd, GETVERSION) == -1)
- {
- xf86LinearVidMem();
- }
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "xf86MapVidMem: Screen: %d\n", ScreenNum);
- mmapStat(Base,Size);
- /* To force the MMAP driver to provide the address */
- base = (pointer)0;
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base);
- MapDSC.vaddr = (char *)base;
- MapDSC.physaddr = (char *)Base;
- MapDSC.length = Size;
- MapDSC.ioflg = 1;
- if(mmapFd >= 0)
- {
- if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1)
- {
- FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
- "xf86MapVidMem", Size, Base, strerror(errno));
- /* NOTREACHED */
- }
-
- /* Next time we want the same address! */
- MapDSC.vaddr = (char *)base;
- }
-
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr);
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr);
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "MapDSC.length : %d\n", MapDSC.length);
- mmapStat(Base,Size);
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base);
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n");
-#endif /* HAS_SVR3_MMAPDRV */
-#endif /* SVR4 */
- return(base);
-}
-
-/* ARGSUSED */
-static void
-unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
-{
-#if defined (SVR4)
- munmap(Base, Size);
-#else /* SVR4 */
-#ifdef HAS_SVR3_MMAPDRV
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "# xf86UnMapVidMem: UNMapping FrameBuffer\n");
- mmapStat(Base,Size);
- ioctl(mmapFd, UNMAPRM , Base);
- mmapStat(Base,Size);
- xf86MsgVerb(X_INFO, MMAP_DEBUG,
- "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base);
-#endif /* HAS_SVR3_MMAPDRV */
-#endif /* SVR4 */
- return;
-}
-
-#if defined(SVR4) && defined(__i386__) && !defined(sun)
-/*
- * For some SVR4 versions, a 32-bit read is done for the first location
- * in each page when the page is first mapped. If this is done while
- * memory access is enabled for regions that have read side-effects,
- * this can cause unexpected results, including lockups on some hardware.
- * This function is called to make sure each page is mapped while it is
- * safe to do so.
- */
-
-/*
- * XXX Should get this the correct way (see os/xalloc.c), but since this is
- * for one platform I'll be lazy.
- */
-#define X_PAGE_SIZE 4096
-
-static void
-readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
-{
- unsigned long base, end, addr;
- CARD32 val;
-
- base = (unsigned long)Base;
- end = base + Size;
-
- for (addr = base; addr < end; addr += X_PAGE_SIZE)
- val = *(volatile CARD32 *)addr;
-}
-#endif
-
-void
-xf86OSInitVidMem(VidMemInfoPtr pVidMem)
-{
- pVidMem->linearSupported = linearVidMem();
- pVidMem->mapMem = mapVidMem;
- pVidMem->unmapMem = unmapVidMem;
-#if defined(SVR4) && defined(__i386__) && !defined(sun)
- pVidMem->readSideEffects = readSideEffects;
-#endif
- pVidMem->initialised = TRUE;
-}
-
-/***************************************************************************/
-/* I/O Permissions section */
-/***************************************************************************/
-
-static Bool ExtendedEnabled = FALSE;
-static Bool InitDone = FALSE;
-
-Bool
-xf86EnableIO()
-{
- int i;
-
- if (ExtendedEnabled)
- return TRUE;
-
- if (SET_IOPL() < 0)
- {
- xf86Msg(X_WARNING,
- "xf86EnableIO: Failed to set IOPL for extended I/O\n");
- return FALSE;
- }
- ExtendedEnabled = TRUE;
-
- return TRUE;
-}
-
-void
-xf86DisableIO()
-{
- if (!ExtendedEnabled)
- return;
-
- RESET_IOPL();
- ExtendedEnabled = FALSE;
-
- return;
-}
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Wexelblat
+ * not be used in advertising or publicity pertaining to distribution of
+ * the software without specific, written prior permission. Thomas Roell and
+ * David Wexelblat makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID WEXELBLAT BE LIABLE FOR
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#define _NEED_SYSI86
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86OSpriv.h"
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#ifndef SI86IOPL
+#define SET_IOPL() sysi86(SI86V86,V86SC_IOPL,PS_IOPL)
+#define RESET_IOPL() sysi86(SI86V86,V86SC_IOPL,0)
+#else
+#define SET_IOPL() sysi86(SI86IOPL,3)
+#define RESET_IOPL() sysi86(SI86IOPL,0)
+#endif
+
+/***************************************************************************/
+/* Video Memory Mapping section */
+/***************************************************************************/
+
+/*
+ * XXX Support for SVR3 will need to be reworked if needed. In particular
+ * the Region parameter is no longer passed, and will need to be dealt
+ * with internally if required.
+ * OK, i'll rework that thing ... (clean it up a lot)
+ * SVR3 Support only with SVR3_MMAPDRV (mr)
+ *
+ */
+
+#ifdef HAS_SVR3_MMAPDRV
+#ifndef MMAP_DEBUG
+#define MMAP_DEBUG 3
+#endif
+
+struct kd_memloc MapDSC;
+int mmapFd = -2;
+
+static int
+mmapStat(pointer Base, unsigned long Size) {
+
+ int nmmreg,i=0,region=-1;
+ mmapinfo_t *ibuf;
+
+ nmmreg = ioctl(mmapFd, GETNMMREG);
+
+ if(nmmreg <= 0)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "\nNo physical memory mapped currently.\n\n");
+ else {
+ if((ibuf = (mmapinfo_t *)malloc(nmmreg*sizeof(mmapinfo_t))) == NULL)
+ xf86Msg(X_WARNING,
+ "Couldn't allocate memory 4 mmapinfo_t\n");
+ else {
+ if(ioctl(mmapFd, GETMMREG, ibuf) != -1)
+ {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# mmapStat: [Size=%x,Base=%x]\n", Size, Base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# Physical Address Size Reference Count\n");
+ for(i = 0; i < nmmreg; i++) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "%-4d 0x%08X %5dk %5d ",
+ i, ibuf[i].physaddr, ibuf[i].length/1024, ibuf[i].refcnt);
+ if (ibuf[i].physaddr == Base || ibuf[i].length == Size ) {
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,"MATCH !!!");
+ if (region==-1) region=i;
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ xf86ErrorFVerb(MMAP_DEBUG, "\n");
+ }
+ free(ibuf);
+ }
+ }
+ if (region == -1 && nmmreg > 0) region=region * i;
+ return region;
+}
+#endif
+
+
+static Bool
+linearVidMem()
+{
+#ifdef SVR4
+ return TRUE;
+#elif defined(HAS_SVR3_MMAPDRV)
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86LinearVidMem: MMAP 2.2.2 called\n");
+
+ if(mmapFd >= 0) return TRUE;
+
+ if ((mmapFd = open("/dev/mmap", O_RDWR)) != -1)
+ {
+ if(ioctl(mmapFd, GETVERSION) < 0x0222) {
+ xf86Msg(X_WARNING,
+ "xf86LinearVidMem: MMAP 2.2.2 or above required\n");
+ xf86ErrorF("\tlinear memory access disabled\n");
+ return FALSE;
+ }
+ return TRUE;
+ }
+ xf86Msg(X_WARNING, "xf86LinearVidMem: failed to open /dev/mmap (%s)\n",
+ strerror(errno));
+ xf86ErrorF("\tlinear memory access disabled\n");
+ return FALSE;
+#endif
+}
+
+static pointer
+mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int flags)
+{
+ pointer base;
+ int fd;
+
+#if defined(SVR4)
+ fd = open(DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR);
+ if (fd < 0)
+ {
+ FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ DEV_MEM, strerror(errno));
+ }
+ base = mmap((caddr_t)0, Size,
+ (flags & VIDMEM_READONLY) ?
+ PROT_READ : (PROT_READ | PROT_WRITE),
+ MAP_SHARED, fd, (off_t)Base);
+ close(fd);
+ if (base == MAP_FAILED)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ }
+#else /* SVR4 */
+#ifdef HAS_SVR3_MMAPDRV
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG, "# xf86MapVidMem: MMAP 2.2.2 called\n");
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ if (ioctl(mmapFd, GETVERSION) == -1)
+ {
+ xf86LinearVidMem();
+ }
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MMAP_VERSION: 0x%x\n",ioctl(mmapFd, GETVERSION));
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: Screen: %d\n", ScreenNum);
+ mmapStat(Base,Size);
+ /* To force the MMAP driver to provide the address */
+ base = (pointer)0;
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x]\n", Size, Base);
+ MapDSC.vaddr = (char *)base;
+ MapDSC.physaddr = (char *)Base;
+ MapDSC.length = Size;
+ MapDSC.ioflg = 1;
+ if(mmapFd >= 0)
+ {
+ if((base = (pointer)ioctl(mmapFd, MAP, &MapDSC)) == (pointer)-1)
+ {
+ FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ "xf86MapVidMem", Size, Base, strerror(errno));
+ /* NOTREACHED */
+ }
+
+ /* Next time we want the same address! */
+ MapDSC.vaddr = (char *)base;
+ }
+
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.vaddr : 0x%x\n", MapDSC.vaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.physaddr: 0x%x\n", MapDSC.physaddr);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "MapDSC.length : %d\n", MapDSC.length);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: [s=%x,a=%x,b=%x]\n", Size, Base, base);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "xf86MapVidMem: SUCCEED Mapping FrameBuffer \n");
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return base;
+}
+
+/* ARGSUSED */
+static void
+unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
+{
+#if defined (SVR4)
+ munmap(Base, Size);
+#else /* SVR4 */
+#ifdef HAS_SVR3_MMAPDRV
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: UNMapping FrameBuffer\n");
+ mmapStat(Base,Size);
+ ioctl(mmapFd, UNMAPRM , Base);
+ mmapStat(Base,Size);
+ xf86MsgVerb(X_INFO, MMAP_DEBUG,
+ "# xf86UnMapVidMem: Screen: %d [v=%x]\n", ScreenNum, Base);
+#endif /* HAS_SVR3_MMAPDRV */
+#endif /* SVR4 */
+ return;
+}
+
+#if defined(SVR4) && defined(__i386__) && !defined(sun)
+/*
+ * For some SVR4 versions, a 32-bit read is done for the first location
+ * in each page when the page is first mapped. If this is done while
+ * memory access is enabled for regions that have read side-effects,
+ * this can cause unexpected results, including lockups on some hardware.
+ * This function is called to make sure each page is mapped while it is
+ * safe to do so.
+ */
+
+/*
+ * XXX Should get this the correct way (see os/xalloc.c), but since this is
+ * for one platform I'll be lazy.
+ */
+#define X_PAGE_SIZE 4096
+
+static void
+readSideEffects(int ScreenNum, pointer Base, unsigned long Size)
+{
+ unsigned long base, end, addr;
+ CARD32 val;
+
+ base = (unsigned long)Base;
+ end = base + Size;
+
+ for (addr = base; addr < end; addr += X_PAGE_SIZE)
+ val = *(volatile CARD32 *)addr;
+}
+#endif
+
+void
+xf86OSInitVidMem(VidMemInfoPtr pVidMem)
+{
+ pVidMem->linearSupported = linearVidMem();
+ pVidMem->mapMem = mapVidMem;
+ pVidMem->unmapMem = unmapVidMem;
+#if defined(SVR4) && defined(__i386__) && !defined(sun)
+ pVidMem->readSideEffects = readSideEffects;
+#endif
+ pVidMem->initialised = TRUE;
+}
+
+/***************************************************************************/
+/* I/O Permissions section */
+/***************************************************************************/
+
+static Bool ExtendedEnabled = FALSE;
+static Bool InitDone = FALSE;
+
+Bool
+xf86EnableIO()
+{
+ int i;
+
+ if (ExtendedEnabled)
+ return TRUE;
+
+ if (SET_IOPL() < 0)
+ {
+ xf86Msg(X_WARNING,
+ "xf86EnableIO: Failed to set IOPL for extended I/O\n");
+ return FALSE;
+ }
+ ExtendedEnabled = TRUE;
+
+ return TRUE;
+}
+
+void
+xf86DisableIO()
+{
+ if (!ExtendedEnabled)
+ return;
+
+ RESET_IOPL();
+ ExtendedEnabled = FALSE;
+
+ return;
+}
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h
index 03509b397..63e510d8f 100644
--- a/xorg-server/hw/xfree86/parser/Configint.h
+++ b/xorg-server/hw/xfree86/parser/Configint.h
@@ -1,222 +1,222 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/*
- * These definitions are used through out the configuration file parser, but
- * they should not be visible outside of the parser.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _Configint_h_
-#define _Configint_h_
-
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include "xf86Parser.h"
-
-typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
-
-typedef struct
-{
- int num; /* returned number */
- char *str; /* private copy of the return-string */
- double realnum; /* returned number as a real */
- ParserNumType numType; /* used to enforce correct number formatting */
-}
-LexRec, *LexPtr;
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#include "configProcs.h"
-#include <stdlib.h>
-
-#define TestFree(a) if (a) { free (a); a = NULL; }
-
-#define parsePrologue(typeptr,typerec) typeptr ptr; \
-if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
-
-#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
-if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return; }
-
-#define HANDLE_RETURN(f,func)\
-if ((ptr->f=func) == NULL)\
-{\
- CLEANUP (ptr);\
- return (NULL);\
-}
-
-#define HANDLE_LIST(field,func,type)\
-{\
-type p = func ();\
-if (p == NULL)\
-{\
- CLEANUP (ptr);\
- return (NULL);\
-}\
-else\
-{\
- ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
-}\
-}
-
-#define Error(a,b) do { \
- xf86parseError (a, b); CLEANUP (ptr); return NULL; \
- } while (0)
-
-/*
- * These are defines for error messages to promote consistency.
- * error messages are preceded by the line number, section and file name,
- * so these messages should be about the specific keyword and syntax in error.
- * To help limit namespace polution, end each with _MSG.
- * limit messages to 70 characters if possible.
- */
-
-#define BAD_OPTION_MSG \
-"The Option keyword requires 1 or 2 quoted strings to follow it."
-#define INVALID_KEYWORD_MSG \
-"\"%s\" is not a valid keyword in this section."
-#define INVALID_SECTION_MSG \
-"\"%s\" is not a valid section name."
-#define UNEXPECTED_EOF_MSG \
-"Unexpected EOF. Missing EndSection keyword?"
-#define QUOTE_MSG \
-"The %s keyword requires a quoted string to follow it."
-#define NUMBER_MSG \
-"The %s keyword requires a number to follow it."
-#define POSITIVE_INT_MSG \
-"The %s keyword requires a positive integer to follow it."
-#define BOOL_MSG \
-"The %s keyword requires a boolean to follow it."
-#define ZAXISMAPPING_MSG \
-"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
-#define AUTOREPEAT_MSG \
-"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it."
-#define XLEDS_MSG \
-"The XLeds keyword requries one or more numbers to follow it."
-#define DACSPEED_MSG \
-"The DacSpeed keyword must be followed by a list of up to %d numbers."
-#define DISPLAYSIZE_MSG \
-"The DisplaySize keyword must be followed by the width and height in mm."
-#define HORIZSYNC_MSG \
-"The HorizSync keyword must be followed by a list of numbers or ranges."
-#define VERTREFRESH_MSG \
-"The VertRefresh keyword must be followed by a list of numbers or ranges."
-#define VIEWPORT_MSG \
-"The Viewport keyword must be followed by an X and Y value."
-#define VIRTUAL_MSG \
-"The Virtual keyword must be followed by a width and height value."
-#define WEIGHT_MSG \
-"The Weight keyword must be followed by red, green and blue values."
-#define BLACK_MSG \
-"The Black keyword must be followed by red, green and blue values."
-#define WHITE_MSG \
-"The White keyword must be followed by red, green and blue values."
-#define SCREEN_MSG \
-"The Screen keyword must be followed by an optional number, a screen name\n" \
-"\tin quotes, and optional position/layout information."
-#define INVALID_SCR_MSG \
-"Invalid Screen line."
-#define INPUTDEV_MSG \
-"The InputDevice keyword must be followed by an input device name in quotes."
-#define INACTIVE_MSG \
-"The Inactive keyword must be followed by a Device name in quotes."
-#define UNDEFINED_SCREEN_MSG \
-"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
-#define UNDEFINED_MODES_MSG \
-"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
-#define UNDEFINED_DEVICE_MSG \
-"Undefined Device \"%s\" referenced by Screen \"%s\"."
-#define UNDEFINED_ADAPTOR_MSG \
-"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
-#define ADAPTOR_REF_TWICE_MSG \
-"VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
-#define UNDEFINED_DEVICE_LAY_MSG \
-"Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
-#define UNDEFINED_INPUT_MSG \
-"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
-#define NO_IDENT_MSG \
-"This section must have an Identifier line."
-#define ONLY_ONE_MSG \
-"This section must have only one of either %s line."
-#define UNDEFINED_INPUTDRIVER_MSG \
-"InputDevice section \"%s\" must have a Driver line."
-#define INVALID_GAMMA_MSG \
-"gamma correction value(s) expected\n either one value or three r/g/b values."
-#define GROUP_MSG \
-"The Group keyword must be followed by either a group name in quotes or\n" \
-"\ta numerical group id."
-#define MULTIPLE_MSG \
-"Multiple \"%s\" lines."
-#define MUST_BE_OCTAL_MSG \
-"The number \"%d\" given in this section must be in octal (0xxx) format."
-
-/* Warning messages */
-#define OBSOLETE_MSG \
-"Ignoring obsolete keyword \"%s\"."
-#define MOVED_TO_FLAGS_MSG \
-"Keyword \"%s\" is now an Option flag in the ServerFlags section."
-
-#endif /* _Configint_h_ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * These definitions are used through out the configuration file parser, but
+ * they should not be visible outside of the parser.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _Configint_h_
+#define _Configint_h_
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include "xf86Parser.h"
+
+typedef enum { PARSE_DECIMAL, PARSE_OCTAL, PARSE_HEX } ParserNumType;
+
+typedef struct
+{
+ int num; /* returned number */
+ char *str; /* private copy of the return-string */
+ double realnum; /* returned number as a real */
+ ParserNumType numType; /* used to enforce correct number formatting */
+}
+LexRec, *LexPtr;
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#include "configProcs.h"
+#include <stdlib.h>
+
+#define TestFree(a) if (a) { free (a); a = NULL; }
+
+#define parsePrologue(typeptr,typerec) typeptr ptr; \
+if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
+
+#define parsePrologueVoid(typeptr,typerec) int token; typeptr ptr; \
+if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return; }
+
+#define HANDLE_RETURN(f,func)\
+if ((ptr->f=func) == NULL)\
+{\
+ CLEANUP (ptr);\
+ return NULL;\
+}
+
+#define HANDLE_LIST(field,func,type)\
+{\
+type p = func ();\
+if (p == NULL)\
+{\
+ CLEANUP (ptr);\
+ return NULL;\
+}\
+else\
+{\
+ ptr->field = (type) xf86addListItem ((glp) ptr->field, (glp) p);\
+}\
+}
+
+#define Error(a,b) do { \
+ xf86parseError (a, b); CLEANUP (ptr); return NULL; \
+ } while (0)
+
+/*
+ * These are defines for error messages to promote consistency.
+ * error messages are preceded by the line number, section and file name,
+ * so these messages should be about the specific keyword and syntax in error.
+ * To help limit namespace polution, end each with _MSG.
+ * limit messages to 70 characters if possible.
+ */
+
+#define BAD_OPTION_MSG \
+"The Option keyword requires 1 or 2 quoted strings to follow it."
+#define INVALID_KEYWORD_MSG \
+"\"%s\" is not a valid keyword in this section."
+#define INVALID_SECTION_MSG \
+"\"%s\" is not a valid section name."
+#define UNEXPECTED_EOF_MSG \
+"Unexpected EOF. Missing EndSection keyword?"
+#define QUOTE_MSG \
+"The %s keyword requires a quoted string to follow it."
+#define NUMBER_MSG \
+"The %s keyword requires a number to follow it."
+#define POSITIVE_INT_MSG \
+"The %s keyword requires a positive integer to follow it."
+#define BOOL_MSG \
+"The %s keyword requires a boolean to follow it."
+#define ZAXISMAPPING_MSG \
+"The ZAxisMapping keyword requires 2 positive numbers or X or Y to follow it."
+#define AUTOREPEAT_MSG \
+"The AutoRepeat keyword requires 2 numbers (delay and rate) to follow it."
+#define XLEDS_MSG \
+"The XLeds keyword requries one or more numbers to follow it."
+#define DACSPEED_MSG \
+"The DacSpeed keyword must be followed by a list of up to %d numbers."
+#define DISPLAYSIZE_MSG \
+"The DisplaySize keyword must be followed by the width and height in mm."
+#define HORIZSYNC_MSG \
+"The HorizSync keyword must be followed by a list of numbers or ranges."
+#define VERTREFRESH_MSG \
+"The VertRefresh keyword must be followed by a list of numbers or ranges."
+#define VIEWPORT_MSG \
+"The Viewport keyword must be followed by an X and Y value."
+#define VIRTUAL_MSG \
+"The Virtual keyword must be followed by a width and height value."
+#define WEIGHT_MSG \
+"The Weight keyword must be followed by red, green and blue values."
+#define BLACK_MSG \
+"The Black keyword must be followed by red, green and blue values."
+#define WHITE_MSG \
+"The White keyword must be followed by red, green and blue values."
+#define SCREEN_MSG \
+"The Screen keyword must be followed by an optional number, a screen name\n" \
+"\tin quotes, and optional position/layout information."
+#define INVALID_SCR_MSG \
+"Invalid Screen line."
+#define INPUTDEV_MSG \
+"The InputDevice keyword must be followed by an input device name in quotes."
+#define INACTIVE_MSG \
+"The Inactive keyword must be followed by a Device name in quotes."
+#define UNDEFINED_SCREEN_MSG \
+"Undefined Screen \"%s\" referenced by ServerLayout \"%s\"."
+#define UNDEFINED_MODES_MSG \
+"Undefined Modes Section \"%s\" referenced by Monitor \"%s\"."
+#define UNDEFINED_DEVICE_MSG \
+"Undefined Device \"%s\" referenced by Screen \"%s\"."
+#define UNDEFINED_ADAPTOR_MSG \
+"Undefined VideoAdaptor \"%s\" referenced by Screen \"%s\"."
+#define ADAPTOR_REF_TWICE_MSG \
+"VideoAdaptor \"%s\" already referenced by Screen \"%s\"."
+#define UNDEFINED_DEVICE_LAY_MSG \
+"Undefined Device \"%s\" referenced by ServerLayout \"%s\"."
+#define UNDEFINED_INPUT_MSG \
+"Undefined InputDevice \"%s\" referenced by ServerLayout \"%s\"."
+#define NO_IDENT_MSG \
+"This section must have an Identifier line."
+#define ONLY_ONE_MSG \
+"This section must have only one of either %s line."
+#define UNDEFINED_INPUTDRIVER_MSG \
+"InputDevice section \"%s\" must have a Driver line."
+#define INVALID_GAMMA_MSG \
+"gamma correction value(s) expected\n either one value or three r/g/b values."
+#define GROUP_MSG \
+"The Group keyword must be followed by either a group name in quotes or\n" \
+"\ta numerical group id."
+#define MULTIPLE_MSG \
+"Multiple \"%s\" lines."
+#define MUST_BE_OCTAL_MSG \
+"The number \"%d\" given in this section must be in octal (0xxx) format."
+
+/* Warning messages */
+#define OBSOLETE_MSG \
+"Ignoring obsolete keyword \"%s\"."
+#define MOVED_TO_FLAGS_MSG \
+"Keyword \"%s\" is now an Option flag in the ServerFlags section."
+
+#endif /* _Configint_h_ */
diff --git a/xorg-server/hw/xfree86/parser/Device.c b/xorg-server/hw/xfree86/parser/Device.c
index 47ece07de..c81aa05d9 100644
--- a/xorg-server/hw/xfree86/parser/Device.c
+++ b/xorg-server/hw/xfree86/parser/Device.c
@@ -1,371 +1,371 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static
-xf86ConfigSymTabRec DeviceTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {VENDOR, "vendorname"},
- {BOARD, "boardname"},
- {CHIPSET, "chipset"},
- {RAMDAC, "ramdac"},
- {DACSPEED, "dacspeed"},
- {CLOCKS, "clocks"},
- {OPTION, "option"},
- {VIDEORAM, "videoram"},
- {BIOSBASE, "biosbase"},
- {MEMBASE, "membase"},
- {IOBASE, "iobase"},
- {CLOCKCHIP, "clockchip"},
- {CHIPID, "chipid"},
- {CHIPREV, "chiprev"},
- {CARD, "card"},
- {DRIVER, "driver"},
- {BUSID, "busid"},
- {TEXTCLOCKFRQ, "textclockfreq"},
- {IRQ, "irq"},
- {SCREEN, "screen"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeDeviceList
-
-XF86ConfDevicePtr
-xf86parseDeviceSection (void)
-{
- int i;
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
-
- /* Zero is a valid value for these */
- ptr->dev_chipid = -1;
- ptr->dev_chiprev = -1;
- ptr->dev_irq = -1;
- while ((token = xf86getToken (DeviceTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->dev_identifier = val.str;
- has_ident = TRUE;
- break;
- case VENDOR:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Vendor");
- ptr->dev_vendor = val.str;
- break;
- case BOARD:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Board");
- ptr->dev_board = val.str;
- break;
- case CHIPSET:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Chipset");
- ptr->dev_chipset = val.str;
- break;
- case CARD:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Card");
- ptr->dev_card = val.str;
- break;
- case DRIVER:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- ptr->dev_driver = val.str;
- break;
- case RAMDAC:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "Ramdac");
- ptr->dev_ramdac = val.str;
- break;
- case DACSPEED:
- for (i = 0; i < CONF_MAXDACSPEEDS; i++)
- ptr->dev_dacSpeeds[i] = 0;
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- {
- Error (DACSPEED_MSG, CONF_MAXDACSPEEDS);
- }
- else
- {
- ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
- for (i = 1; i < CONF_MAXDACSPEEDS; i++)
- {
- if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER)
- ptr->dev_dacSpeeds[i] = (int)
- (val.realnum * 1000.0 + 0.5);
- else
- {
- xf86unGetToken (token);
- break;
- }
- }
- }
- break;
- case VIDEORAM:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "VideoRam");
- ptr->dev_videoram = val.num;
- break;
- case BIOSBASE:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "BIOSBase");
- ptr->dev_bios_base = val.num;
- break;
- case MEMBASE:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "MemBase");
- ptr->dev_mem_base = val.num;
- break;
- case IOBASE:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "IOBase");
- ptr->dev_io_base = val.num;
- break;
- case CLOCKCHIP:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "ClockChip");
- ptr->dev_clockchip = val.str;
- break;
- case CHIPID:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "ChipID");
- ptr->dev_chipid = val.num;
- break;
- case CHIPREV:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "ChipRev");
- ptr->dev_chiprev = val.num;
- break;
-
- case CLOCKS:
- token = xf86getSubToken(&(ptr->dev_comment));
- for( i = ptr->dev_clocks;
- token == NUMBER && i < CONF_MAXCLOCKS; i++ ) {
- ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5);
- token = xf86getSubToken(&(ptr->dev_comment));
- }
- ptr->dev_clocks = i;
- xf86unGetToken (token);
- break;
- case TEXTCLOCKFRQ:
- if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
- Error (NUMBER_MSG, "TextClockFreq");
- ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5);
- break;
- case OPTION:
- ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
- break;
- case BUSID:
- if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
- Error (QUOTE_MSG, "BusID");
- ptr->dev_busid = val.str;
- break;
- case IRQ:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (QUOTE_MSG, "IRQ");
- ptr->dev_irq = val.num;
- break;
- case SCREEN:
- if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
- Error (NUMBER_MSG, "Screen");
- ptr->dev_screen = val.num;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Device section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
-{
- int i;
-
- while (ptr)
- {
- fprintf (cf, "Section \"Device\"\n");
- if (ptr->dev_comment)
- fprintf (cf, "%s", ptr->dev_comment);
- if (ptr->dev_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
- if (ptr->dev_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver);
- if (ptr->dev_vendor)
- fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
- if (ptr->dev_board)
- fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board);
- if (ptr->dev_chipset)
- fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
- if (ptr->dev_card)
- fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card);
- if (ptr->dev_ramdac)
- fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
- if (ptr->dev_dacSpeeds[0] > 0 ) {
- fprintf (cf, "\tDacSpeed ");
- for (i = 0; i < CONF_MAXDACSPEEDS
- && ptr->dev_dacSpeeds[i] > 0; i++ )
- fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 );
- fprintf (cf, "\n");
- }
- if (ptr->dev_videoram)
- fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram);
- if (ptr->dev_bios_base)
- fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
- if (ptr->dev_mem_base)
- fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
- if (ptr->dev_io_base)
- fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
- if (ptr->dev_clockchip)
- fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
- if (ptr->dev_chipid != -1)
- fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid);
- if (ptr->dev_chiprev != -1)
- fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
-
- xf86printOptionList(cf, ptr->dev_option_lst, 1);
- if (ptr->dev_clocks > 0 ) {
- fprintf (cf, "\tClocks ");
- for (i = 0; i < ptr->dev_clocks; i++ )
- fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 );
- fprintf (cf, "\n");
- }
- if (ptr->dev_textclockfreq) {
- fprintf (cf, "\tTextClockFreq %.1f\n",
- (double)ptr->dev_textclockfreq / 1000.0);
- }
- if (ptr->dev_busid)
- fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid);
- if (ptr->dev_screen > 0)
- fprintf (cf, "\tScreen %d\n", ptr->dev_screen);
- if (ptr->dev_irq >= 0)
- fprintf (cf, "\tIRQ %d\n", ptr->dev_irq);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-void
-xf86freeDeviceList (XF86ConfDevicePtr ptr)
-{
- XF86ConfDevicePtr prev;
-
- while (ptr)
- {
- TestFree (ptr->dev_identifier);
- TestFree (ptr->dev_vendor);
- TestFree (ptr->dev_board);
- TestFree (ptr->dev_chipset);
- TestFree (ptr->dev_card);
- TestFree (ptr->dev_driver);
- TestFree (ptr->dev_ramdac);
- TestFree (ptr->dev_clockchip);
- TestFree (ptr->dev_comment);
- xf86optionListFree (ptr->dev_option_lst);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-XF86ConfDevicePtr
-xf86findDevice (const char *ident, XF86ConfDevicePtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->dev_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec DeviceTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {CHIPSET, "chipset"},
+ {RAMDAC, "ramdac"},
+ {DACSPEED, "dacspeed"},
+ {CLOCKS, "clocks"},
+ {OPTION, "option"},
+ {VIDEORAM, "videoram"},
+ {BIOSBASE, "biosbase"},
+ {MEMBASE, "membase"},
+ {IOBASE, "iobase"},
+ {CLOCKCHIP, "clockchip"},
+ {CHIPID, "chipid"},
+ {CHIPREV, "chiprev"},
+ {CARD, "card"},
+ {DRIVER, "driver"},
+ {BUSID, "busid"},
+ {TEXTCLOCKFRQ, "textclockfreq"},
+ {IRQ, "irq"},
+ {SCREEN, "screen"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDeviceList
+
+XF86ConfDevicePtr
+xf86parseDeviceSection (void)
+{
+ int i;
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
+
+ /* Zero is a valid value for these */
+ ptr->dev_chipid = -1;
+ ptr->dev_chiprev = -1;
+ ptr->dev_irq = -1;
+ while ((token = xf86getToken (DeviceTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->dev_comment = xf86addComment(ptr->dev_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->dev_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->dev_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Board");
+ ptr->dev_board = val.str;
+ break;
+ case CHIPSET:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Chipset");
+ ptr->dev_chipset = val.str;
+ break;
+ case CARD:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Card");
+ ptr->dev_card = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->dev_driver = val.str;
+ break;
+ case RAMDAC:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "Ramdac");
+ ptr->dev_ramdac = val.str;
+ break;
+ case DACSPEED:
+ for (i = 0; i < CONF_MAXDACSPEEDS; i++)
+ ptr->dev_dacSpeeds[i] = 0;
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ {
+ Error (DACSPEED_MSG, CONF_MAXDACSPEEDS);
+ }
+ else
+ {
+ ptr->dev_dacSpeeds[0] = (int) (val.realnum * 1000.0 + 0.5);
+ for (i = 1; i < CONF_MAXDACSPEEDS; i++)
+ {
+ if (xf86getSubToken (&(ptr->dev_comment)) == NUMBER)
+ ptr->dev_dacSpeeds[i] = (int)
+ (val.realnum * 1000.0 + 0.5);
+ else
+ {
+ xf86unGetToken (token);
+ break;
+ }
+ }
+ }
+ break;
+ case VIDEORAM:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "VideoRam");
+ ptr->dev_videoram = val.num;
+ break;
+ case BIOSBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "BIOSBase");
+ ptr->dev_bios_base = val.num;
+ break;
+ case MEMBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "MemBase");
+ ptr->dev_mem_base = val.num;
+ break;
+ case IOBASE:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "IOBase");
+ ptr->dev_io_base = val.num;
+ break;
+ case CLOCKCHIP:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "ClockChip");
+ ptr->dev_clockchip = val.str;
+ break;
+ case CHIPID:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "ChipID");
+ ptr->dev_chipid = val.num;
+ break;
+ case CHIPREV:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "ChipRev");
+ ptr->dev_chiprev = val.num;
+ break;
+
+ case CLOCKS:
+ token = xf86getSubToken(&(ptr->dev_comment));
+ for( i = ptr->dev_clocks;
+ token == NUMBER && i < CONF_MAXCLOCKS; i++ ) {
+ ptr->dev_clock[i] = (int)(val.realnum * 1000.0 + 0.5);
+ token = xf86getSubToken(&(ptr->dev_comment));
+ }
+ ptr->dev_clocks = i;
+ xf86unGetToken (token);
+ break;
+ case TEXTCLOCKFRQ:
+ if ((token = xf86getSubToken(&(ptr->dev_comment))) != NUMBER)
+ Error (NUMBER_MSG, "TextClockFreq");
+ ptr->dev_textclockfreq = (int)(val.realnum * 1000.0 + 0.5);
+ break;
+ case OPTION:
+ ptr->dev_option_lst = xf86parseOption(ptr->dev_option_lst);
+ break;
+ case BUSID:
+ if (xf86getSubToken (&(ptr->dev_comment)) != STRING)
+ Error (QUOTE_MSG, "BusID");
+ ptr->dev_busid = val.str;
+ break;
+ case IRQ:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (QUOTE_MSG, "IRQ");
+ ptr->dev_irq = val.num;
+ break;
+ case SCREEN:
+ if (xf86getSubToken (&(ptr->dev_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Screen");
+ ptr->dev_screen = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Device section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
+{
+ int i;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Device\"\n");
+ if (ptr->dev_comment)
+ fprintf (cf, "%s", ptr->dev_comment);
+ if (ptr->dev_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->dev_identifier);
+ if (ptr->dev_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->dev_driver);
+ if (ptr->dev_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->dev_vendor);
+ if (ptr->dev_board)
+ fprintf (cf, "\tBoardName \"%s\"\n", ptr->dev_board);
+ if (ptr->dev_chipset)
+ fprintf (cf, "\tChipSet \"%s\"\n", ptr->dev_chipset);
+ if (ptr->dev_card)
+ fprintf (cf, "\tCard \"%s\"\n", ptr->dev_card);
+ if (ptr->dev_ramdac)
+ fprintf (cf, "\tRamDac \"%s\"\n", ptr->dev_ramdac);
+ if (ptr->dev_dacSpeeds[0] > 0 ) {
+ fprintf (cf, "\tDacSpeed ");
+ for (i = 0; i < CONF_MAXDACSPEEDS
+ && ptr->dev_dacSpeeds[i] > 0; i++ )
+ fprintf (cf, "%g ", (double) (ptr->dev_dacSpeeds[i])/ 1000.0 );
+ fprintf (cf, "\n");
+ }
+ if (ptr->dev_videoram)
+ fprintf (cf, "\tVideoRam %d\n", ptr->dev_videoram);
+ if (ptr->dev_bios_base)
+ fprintf (cf, "\tBiosBase 0x%lx\n", ptr->dev_bios_base);
+ if (ptr->dev_mem_base)
+ fprintf (cf, "\tMemBase 0x%lx\n", ptr->dev_mem_base);
+ if (ptr->dev_io_base)
+ fprintf (cf, "\tIOBase 0x%lx\n", ptr->dev_io_base);
+ if (ptr->dev_clockchip)
+ fprintf (cf, "\tClockChip \"%s\"\n", ptr->dev_clockchip);
+ if (ptr->dev_chipid != -1)
+ fprintf (cf, "\tChipId 0x%x\n", ptr->dev_chipid);
+ if (ptr->dev_chiprev != -1)
+ fprintf (cf, "\tChipRev 0x%x\n", ptr->dev_chiprev);
+
+ xf86printOptionList(cf, ptr->dev_option_lst, 1);
+ if (ptr->dev_clocks > 0 ) {
+ fprintf (cf, "\tClocks ");
+ for (i = 0; i < ptr->dev_clocks; i++ )
+ fprintf (cf, "%.1f ", (double)ptr->dev_clock[i] / 1000.0 );
+ fprintf (cf, "\n");
+ }
+ if (ptr->dev_textclockfreq) {
+ fprintf (cf, "\tTextClockFreq %.1f\n",
+ (double)ptr->dev_textclockfreq / 1000.0);
+ }
+ if (ptr->dev_busid)
+ fprintf (cf, "\tBusID \"%s\"\n", ptr->dev_busid);
+ if (ptr->dev_screen > 0)
+ fprintf (cf, "\tScreen %d\n", ptr->dev_screen);
+ if (ptr->dev_irq >= 0)
+ fprintf (cf, "\tIRQ %d\n", ptr->dev_irq);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeDeviceList (XF86ConfDevicePtr ptr)
+{
+ XF86ConfDevicePtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->dev_identifier);
+ TestFree (ptr->dev_vendor);
+ TestFree (ptr->dev_board);
+ TestFree (ptr->dev_chipset);
+ TestFree (ptr->dev_card);
+ TestFree (ptr->dev_driver);
+ TestFree (ptr->dev_ramdac);
+ TestFree (ptr->dev_clockchip);
+ TestFree (ptr->dev_comment);
+ xf86optionListFree (ptr->dev_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+XF86ConfDevicePtr
+xf86findDevice (const char *ident, XF86ConfDevicePtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->dev_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
diff --git a/xorg-server/hw/xfree86/parser/Flags.c b/xorg-server/hw/xfree86/parser/Flags.c
index 699f15ceb..b6ffc1538 100644
--- a/xorg-server/hw/xfree86/parser/Flags.c
+++ b/xorg-server/hw/xfree86/parser/Flags.c
@@ -1,516 +1,515 @@
-/*
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include <math.h>
-#include <X11/Xfuncproto.h>
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec ServerFlagsTab[] =
-{
- {ENDSECTION, "endsection"},
- {NOTRAPSIGNALS, "notrapsignals"},
- {DONTZAP, "dontzap"},
- {DONTZOOM, "dontzoom"},
- {DISABLEVIDMODE, "disablevidmodeextension"},
- {ALLOWNONLOCAL, "allownonlocalxvidtune"},
- {DISABLEMODINDEV, "disablemodindev"},
- {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
- {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
- {OPTION, "option"},
- {BLANKTIME, "blanktime"},
- {STANDBYTIME, "standbytime"},
- {SUSPENDTIME, "suspendtime"},
- {OFFTIME, "offtime"},
- {DEFAULTLAYOUT, "defaultserverlayout"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeFlags
-
-XF86ConfFlagsPtr
-xf86parseFlagsSection (void)
-{
- int token;
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
- {
- int hasvalue = FALSE;
- int strvalue = FALSE;
- int tokentype;
- switch (token)
- {
- case COMMENT:
- ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
- break;
- /*
- * these old keywords are turned into standard generic options.
- * we fall through here on purpose
- */
- case DEFAULTLAYOUT:
- strvalue = TRUE;
- case BLANKTIME:
- case STANDBYTIME:
- case SUSPENDTIME:
- case OFFTIME:
- hasvalue = TRUE;
- case NOTRAPSIGNALS:
- case DONTZAP:
- case DONTZOOM:
- case DISABLEVIDMODE:
- case ALLOWNONLOCAL:
- case DISABLEMODINDEV:
- case MODINDEVALLOWNONLOCAL:
- case ALLOWMOUSEOPENFAIL:
- {
- int i = 0;
- while (ServerFlagsTab[i].token != -1)
- {
- char *tmp;
-
- if (ServerFlagsTab[i].token == token)
- {
- char *valstr = NULL;
- /* can't use strdup because it calls malloc */
- tmp = strdup (ServerFlagsTab[i].name);
- if (hasvalue)
- {
- tokentype = xf86getSubToken(&(ptr->flg_comment));
- if (strvalue) {
- if (tokentype != STRING)
- Error (QUOTE_MSG, tmp);
- valstr = val.str;
- } else {
- if (tokentype != NUMBER)
- Error (NUMBER_MSG, tmp);
- valstr = malloc(16);
- if (valstr)
- sprintf(valstr, "%d", val.num);
- }
- }
- ptr->flg_option_lst = xf86addNewOption
- (ptr->flg_option_lst, tmp, valstr);
- }
- i++;
- }
- }
- break;
- case OPTION:
- ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
-#ifdef DEBUG
- printf ("Flags section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
-{
- XF86OptionPtr p;
-
- if ((!flags) || (!flags->flg_option_lst))
- return;
- p = flags->flg_option_lst;
- fprintf (f, "Section \"ServerFlags\"\n");
- if (flags->flg_comment)
- fprintf (f, "%s", flags->flg_comment);
- xf86printOptionList(f, p, 1);
- fprintf (f, "EndSection\n\n");
-}
-
-static XF86OptionPtr
-addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
-{
- XF86OptionPtr new, old = NULL;
-
- /* Don't allow duplicates, free old strings */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- new = old;
- free(new->opt_name);
- free(new->opt_val);
- }
- else
- new = calloc (1, sizeof (XF86OptionRec));
- new->opt_name = name;
- new->opt_val = val;
- new->opt_used = used;
-
- if (old)
- return head;
- return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
-}
-
-XF86OptionPtr
-xf86addNewOption (XF86OptionPtr head, char *name, char *val)
-{
- return addNewOption2(head, name, val, 0);
-}
-
-void
-xf86freeFlags (XF86ConfFlagsPtr flags)
-{
- if (flags == NULL)
- return;
- xf86optionListFree (flags->flg_option_lst);
- TestFree(flags->flg_comment);
- free (flags);
-}
-
-XF86OptionPtr
-xf86optionListDup (XF86OptionPtr opt)
-{
- XF86OptionPtr newopt = NULL;
- char *val;
-
- while (opt)
- {
- val = opt->opt_val ? strdup(opt->opt_val) : NULL;
- newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
- newopt->opt_used = opt->opt_used;
- if (opt->opt_comment)
- newopt->opt_comment = strdup(opt->opt_comment);
- opt = opt->list.next;
- }
- return newopt;
-}
-
-void
-xf86optionListFree (XF86OptionPtr opt)
-{
- XF86OptionPtr prev;
-
- while (opt)
- {
- TestFree (opt->opt_name);
- TestFree (opt->opt_val);
- TestFree (opt->opt_comment);
- prev = opt;
- opt = opt->list.next;
- free (prev);
- }
-}
-
-char *
-xf86optionName(XF86OptionPtr opt)
-{
- if (opt)
- return opt->opt_name;
- return 0;
-}
-
-char *
-xf86optionValue(XF86OptionPtr opt)
-{
- if (opt)
- return opt->opt_val;
- return 0;
-}
-
-XF86OptionPtr
-xf86newOption(char *name, char *value)
-{
- XF86OptionPtr opt;
-
- opt = calloc(1, sizeof (XF86OptionRec));
- if (!opt)
- return NULL;
-
- opt->opt_used = 0;
- opt->list.next = 0;
- opt->opt_name = name;
- opt->opt_val = value;
-
- return opt;
-}
-
-XF86OptionPtr
-xf86nextOption(XF86OptionPtr list)
-{
- if (!list)
- return NULL;
- return list->list.next;
-}
-
-/*
- * this function searches the given option list for the named option and
- * returns a pointer to the option rec if found. If not found, it returns
- * NULL
- */
-
-XF86OptionPtr
-xf86findOption (XF86OptionPtr list, const char *name)
-{
- while (list)
- {
- if (xf86nameCompare (list->opt_name, name) == 0)
- return (list);
- list = list->list.next;
- }
- return (NULL);
-}
-
-/*
- * this function searches the given option list for the named option. If
- * found and the option has a parameter, a pointer to the parameter is
- * returned. If the option does not have a parameter an empty string is
- * returned. If the option is not found, a NULL is returned.
- */
-
-char *
-xf86findOptionValue (XF86OptionPtr list, const char *name)
-{
- XF86OptionPtr p = xf86findOption (list, name);
-
- if (p)
- {
- if (p->opt_val)
- return (p->opt_val);
- else
- return "";
- }
- return (NULL);
-}
-
-XF86OptionPtr
-xf86optionListCreate( const char **options, int count, int used )
-{
- XF86OptionPtr p = NULL;
- char *t1, *t2;
- int i;
-
- if (count == -1)
- {
- for (count = 0; options[count]; count++)
- ;
- }
- if( (count % 2) != 0 )
- {
- fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
- return (NULL);
- }
- for (i = 0; i < count; i += 2)
- {
- /* can't use strdup because it calls malloc */
- t1 = malloc (sizeof (char) *
- (strlen (options[i]) + 1));
- strcpy (t1, options[i]);
- t2 = malloc (sizeof (char) *
- (strlen (options[i + 1]) + 1));
- strcpy (t2, options[i + 1]);
- p = addNewOption2 (p, t1, t2, used);
- }
-
- return (p);
-}
-
-/* the 2 given lists are merged. If an option with the same name is present in
- * both, the option from the user list - specified in the second argument -
- * is used. The end result is a single valid list of options. Duplicates
- * are freed, and the original lists are no longer guaranteed to be complete.
- */
-XF86OptionPtr
-xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
-{
- XF86OptionPtr a, b, ap = NULL, bp = NULL;
-
- a = tail;
- b = head;
- while (tail && b) {
- if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
- if (b == head)
- head = a;
- else
- bp->list.next = a;
- if (a == tail)
- tail = a->list.next;
- else
- ap->list.next = a->list.next;
- a->list.next = b->list.next;
- b->list.next = NULL;
- xf86optionListFree (b);
- b = a->list.next;
- bp = a;
- a = tail;
- ap = NULL;
- } else {
- ap = a;
- if (!(a = a->list.next)) {
- a = tail;
- bp = b;
- b = b->list.next;
- ap = NULL;
- }
- }
- }
-
- if (head) {
- for (a = head; a->list.next; a = a->list.next)
- ;
- a->list.next = tail;
- } else
- head = tail;
-
- return (head);
-}
-
-char *
-xf86uLongToString(unsigned long i)
-{
- char *s;
- int l;
-
- l = ceil(log10((double)i) + 2.5);
- s = malloc(l);
- if (!s)
- return NULL;
- sprintf(s, "%lu", i);
- return s;
-}
-
-XF86OptionPtr
-xf86parseOption(XF86OptionPtr head)
-{
- XF86OptionPtr option, cnew, old;
- char *name, *comment = NULL;
- int token;
-
- if ((token = xf86getSubToken(&comment)) != STRING) {
- xf86parseError(BAD_OPTION_MSG, NULL);
- if (comment)
- free(comment);
- return (head);
- }
-
- name = val.str;
- if ((token = xf86getSubToken(&comment)) == STRING) {
- option = xf86newOption(name, val.str);
- option->opt_comment = comment;
- if ((token = xf86getToken(NULL)) == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
- else {
- option = xf86newOption(name, NULL);
- option->opt_comment = comment;
- if (token == COMMENT)
- option->opt_comment = xf86addComment(option->opt_comment, val.str);
- else
- xf86unGetToken(token);
- }
-
- old = NULL;
-
- /* Don't allow duplicates */
- if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
- cnew = old;
- free(option->opt_name);
- TestFree(option->opt_val);
- TestFree(option->opt_comment);
- free(option);
- }
- else
- cnew = option;
-
- if (old == NULL)
- return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
-
- return (head);
-}
-
-void
-xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
-{
- int i;
-
- if (!list)
- return;
- while (list) {
- for (i = 0; i < tabs; i++)
- fputc('\t', fp);
- if (list->opt_val)
- fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
- else
- fprintf(fp, "Option \"%s\"", list->opt_name);
- if (list->opt_comment)
- fprintf(fp, "%s", list->opt_comment);
- else
- fputc('\n', fp);
- list = list->list.next;
- }
-}
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <math.h>
+#include <X11/Xfuncproto.h>
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec ServerFlagsTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {NOTRAPSIGNALS, "notrapsignals"},
+ {DONTZAP, "dontzap"},
+ {DONTZOOM, "dontzoom"},
+ {DISABLEVIDMODE, "disablevidmodeextension"},
+ {ALLOWNONLOCAL, "allownonlocalxvidtune"},
+ {DISABLEMODINDEV, "disablemodindev"},
+ {MODINDEVALLOWNONLOCAL, "allownonlocalmodindev"},
+ {ALLOWMOUSEOPENFAIL, "allowmouseopenfail"},
+ {OPTION, "option"},
+ {BLANKTIME, "blanktime"},
+ {STANDBYTIME, "standbytime"},
+ {SUSPENDTIME, "suspendtime"},
+ {OFFTIME, "offtime"},
+ {DEFAULTLAYOUT, "defaultserverlayout"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeFlags
+
+XF86ConfFlagsPtr
+xf86parseFlagsSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
+
+ while ((token = xf86getToken (ServerFlagsTab)) != ENDSECTION)
+ {
+ int hasvalue = FALSE;
+ int strvalue = FALSE;
+ int tokentype;
+ switch (token)
+ {
+ case COMMENT:
+ ptr->flg_comment = xf86addComment(ptr->flg_comment, val.str);
+ break;
+ /*
+ * these old keywords are turned into standard generic options.
+ * we fall through here on purpose
+ */
+ case DEFAULTLAYOUT:
+ strvalue = TRUE;
+ case BLANKTIME:
+ case STANDBYTIME:
+ case SUSPENDTIME:
+ case OFFTIME:
+ hasvalue = TRUE;
+ case NOTRAPSIGNALS:
+ case DONTZAP:
+ case DONTZOOM:
+ case DISABLEVIDMODE:
+ case ALLOWNONLOCAL:
+ case DISABLEMODINDEV:
+ case MODINDEVALLOWNONLOCAL:
+ case ALLOWMOUSEOPENFAIL:
+ {
+ int i = 0;
+ while (ServerFlagsTab[i].token != -1)
+ {
+ char *tmp;
+
+ if (ServerFlagsTab[i].token == token)
+ {
+ char *valstr = NULL;
+ /* can't use strdup because it calls malloc */
+ tmp = strdup (ServerFlagsTab[i].name);
+ if (hasvalue)
+ {
+ tokentype = xf86getSubToken(&(ptr->flg_comment));
+ if (strvalue) {
+ if (tokentype != STRING)
+ Error (QUOTE_MSG, tmp);
+ valstr = val.str;
+ } else {
+ if (tokentype != NUMBER)
+ Error (NUMBER_MSG, tmp);
+ valstr = malloc(16);
+ if (valstr)
+ sprintf(valstr, "%d", val.num);
+ }
+ }
+ ptr->flg_option_lst = xf86addNewOption
+ (ptr->flg_option_lst, tmp, valstr);
+ }
+ i++;
+ }
+ }
+ break;
+ case OPTION:
+ ptr->flg_option_lst = xf86parseOption(ptr->flg_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Flags section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printServerFlagsSection (FILE * f, XF86ConfFlagsPtr flags)
+{
+ XF86OptionPtr p;
+
+ if ((!flags) || (!flags->flg_option_lst))
+ return;
+ p = flags->flg_option_lst;
+ fprintf (f, "Section \"ServerFlags\"\n");
+ if (flags->flg_comment)
+ fprintf (f, "%s", flags->flg_comment);
+ xf86printOptionList(f, p, 1);
+ fprintf (f, "EndSection\n\n");
+}
+
+static XF86OptionPtr
+addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
+{
+ XF86OptionPtr new, old = NULL;
+
+ /* Don't allow duplicates, free old strings */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ new = old;
+ free(new->opt_name);
+ free(new->opt_val);
+ }
+ else
+ new = calloc (1, sizeof (XF86OptionRec));
+ new->opt_name = name;
+ new->opt_val = val;
+ new->opt_used = used;
+
+ if (old)
+ return head;
+ return ((XF86OptionPtr) xf86addListItem ((glp) head, (glp) new));
+}
+
+XF86OptionPtr
+xf86addNewOption (XF86OptionPtr head, char *name, char *val)
+{
+ return addNewOption2(head, name, val, 0);
+}
+
+void
+xf86freeFlags (XF86ConfFlagsPtr flags)
+{
+ if (flags == NULL)
+ return;
+ xf86optionListFree (flags->flg_option_lst);
+ TestFree(flags->flg_comment);
+ free (flags);
+}
+
+XF86OptionPtr
+xf86optionListDup (XF86OptionPtr opt)
+{
+ XF86OptionPtr newopt = NULL;
+ char *val;
+
+ while (opt)
+ {
+ val = opt->opt_val ? strdup(opt->opt_val) : NULL;
+ newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
+ newopt->opt_used = opt->opt_used;
+ if (opt->opt_comment)
+ newopt->opt_comment = strdup(opt->opt_comment);
+ opt = opt->list.next;
+ }
+ return newopt;
+}
+
+void
+xf86optionListFree (XF86OptionPtr opt)
+{
+ XF86OptionPtr prev;
+
+ while (opt)
+ {
+ TestFree (opt->opt_name);
+ TestFree (opt->opt_val);
+ TestFree (opt->opt_comment);
+ prev = opt;
+ opt = opt->list.next;
+ free (prev);
+ }
+}
+
+char *
+xf86optionName(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_name;
+ return 0;
+}
+
+char *
+xf86optionValue(XF86OptionPtr opt)
+{
+ if (opt)
+ return opt->opt_val;
+ return 0;
+}
+
+XF86OptionPtr
+xf86newOption(char *name, char *value)
+{
+ XF86OptionPtr opt;
+
+ opt = calloc(1, sizeof (XF86OptionRec));
+ if (!opt)
+ return NULL;
+
+ opt->opt_used = 0;
+ opt->list.next = 0;
+ opt->opt_name = name;
+ opt->opt_val = value;
+
+ return opt;
+}
+
+XF86OptionPtr
+xf86nextOption(XF86OptionPtr list)
+{
+ if (!list)
+ return NULL;
+ return list->list.next;
+}
+
+/*
+ * this function searches the given option list for the named option and
+ * returns a pointer to the option rec if found. If not found, it returns
+ * NULL
+ */
+
+XF86OptionPtr
+xf86findOption (XF86OptionPtr list, const char *name)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->opt_name, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
+/*
+ * this function searches the given option list for the named option. If
+ * found and the option has a parameter, a pointer to the parameter is
+ * returned. If the option does not have a parameter an empty string is
+ * returned. If the option is not found, a NULL is returned.
+ */
+
+char *
+xf86findOptionValue (XF86OptionPtr list, const char *name)
+{
+ XF86OptionPtr p = xf86findOption (list, name);
+
+ if (p)
+ {
+ if (p->opt_val)
+ return p->opt_val;
+ else
+ return "";
+ }
+ return NULL;
+}
+
+XF86OptionPtr
+xf86optionListCreate( const char **options, int count, int used )
+{
+ XF86OptionPtr p = NULL;
+ char *t1, *t2;
+ int i;
+
+ if (count == -1)
+ {
+ for (count = 0; options[count]; count++)
+ ;
+ }
+ if( (count % 2) != 0 )
+ {
+ fprintf( stderr, "xf86optionListCreate: count must be an even number.\n" );
+ return NULL;
+ }
+ for (i = 0; i < count; i += 2)
+ {
+ /* can't use strdup because it calls malloc */
+ t1 = malloc (sizeof (char) *
+ (strlen (options[i]) + 1));
+ strcpy (t1, options[i]);
+ t2 = malloc (sizeof (char) *
+ (strlen (options[i + 1]) + 1));
+ strcpy (t2, options[i + 1]);
+ p = addNewOption2 (p, t1, t2, used);
+ }
+
+ return p;
+}
+
+/* the 2 given lists are merged. If an option with the same name is present in
+ * both, the option from the user list - specified in the second argument -
+ * is used. The end result is a single valid list of options. Duplicates
+ * are freed, and the original lists are no longer guaranteed to be complete.
+ */
+XF86OptionPtr
+xf86optionListMerge (XF86OptionPtr head, XF86OptionPtr tail)
+{
+ XF86OptionPtr a, b, ap = NULL, bp = NULL;
+
+ a = tail;
+ b = head;
+ while (tail && b) {
+ if (xf86nameCompare (a->opt_name, b->opt_name) == 0) {
+ if (b == head)
+ head = a;
+ else
+ bp->list.next = a;
+ if (a == tail)
+ tail = a->list.next;
+ else
+ ap->list.next = a->list.next;
+ a->list.next = b->list.next;
+ b->list.next = NULL;
+ xf86optionListFree (b);
+ b = a->list.next;
+ bp = a;
+ a = tail;
+ ap = NULL;
+ } else {
+ ap = a;
+ if (!(a = a->list.next)) {
+ a = tail;
+ bp = b;
+ b = b->list.next;
+ ap = NULL;
+ }
+ }
+ }
+
+ if (head) {
+ for (a = head; a->list.next; a = a->list.next)
+ ;
+ a->list.next = tail;
+ } else
+ head = tail;
+
+ return head;
+}
+
+char *
+xf86uLongToString(unsigned long i)
+{
+ char *s;
+ int l;
+
+ l = ceil(log10((double)i) + 2.5);
+ s = malloc(l);
+ if (!s)
+ return NULL;
+ sprintf(s, "%lu", i);
+ return s;
+}
+
+XF86OptionPtr
+xf86parseOption(XF86OptionPtr head)
+{
+ XF86OptionPtr option, cnew, old;
+ char *name, *comment = NULL;
+ int token;
+
+ if ((token = xf86getSubToken(&comment)) != STRING) {
+ xf86parseError(BAD_OPTION_MSG, NULL);
+ free(comment);
+ return head;
+ }
+
+ name = val.str;
+ if ((token = xf86getSubToken(&comment)) == STRING) {
+ option = xf86newOption(name, val.str);
+ option->opt_comment = comment;
+ if ((token = xf86getToken(NULL)) == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+ else {
+ option = xf86newOption(name, NULL);
+ option->opt_comment = comment;
+ if (token == COMMENT)
+ option->opt_comment = xf86addComment(option->opt_comment, val.str);
+ else
+ xf86unGetToken(token);
+ }
+
+ old = NULL;
+
+ /* Don't allow duplicates */
+ if (head != NULL && (old = xf86findOption(head, name)) != NULL) {
+ cnew = old;
+ free(option->opt_name);
+ TestFree(option->opt_val);
+ TestFree(option->opt_comment);
+ free(option);
+ }
+ else
+ cnew = option;
+
+ if (old == NULL)
+ return ((XF86OptionPtr)xf86addListItem((glp)head, (glp)cnew));
+
+ return head;
+}
+
+void
+xf86printOptionList(FILE *fp, XF86OptionPtr list, int tabs)
+{
+ int i;
+
+ if (!list)
+ return;
+ while (list) {
+ for (i = 0; i < tabs; i++)
+ fputc('\t', fp);
+ if (list->opt_val)
+ fprintf(fp, "Option \"%s\" \"%s\"", list->opt_name, list->opt_val);
+ else
+ fprintf(fp, "Option \"%s\"", list->opt_name);
+ if (list->opt_comment)
+ fprintf(fp, "%s", list->opt_comment);
+ else
+ fputc('\n', fp);
+ list = list->list.next;
+ }
+}
diff --git a/xorg-server/hw/xfree86/parser/Input.c b/xorg-server/hw/xfree86/parser/Input.c
index 8c8e46fb4..8adbee9ae 100644
--- a/xorg-server/hw/xfree86/parser/Input.c
+++ b/xorg-server/hw/xfree86/parser/Input.c
@@ -1,210 +1,210 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static
-xf86ConfigSymTabRec InputTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {DRIVER, "driver"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeInputList
-
-XF86ConfInputPtr
-xf86parseInputSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
- while ((token = xf86getToken (InputTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->inp_identifier = val.str;
- has_ident = TRUE;
- break;
- case DRIVER:
- if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- if (strcmp(val.str, "keyboard") == 0)
- ptr->inp_driver = "kbd";
- else
- ptr->inp_driver = val.str;
- break;
- case OPTION:
- ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("InputDevice section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr)
-{
- while (ptr)
- {
- fprintf (cf, "Section \"InputDevice\"\n");
- if (ptr->inp_comment)
- fprintf (cf, "%s", ptr->inp_comment);
- if (ptr->inp_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
- if (ptr->inp_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver);
- xf86printOptionList(cf, ptr->inp_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-void
-xf86freeInputList (XF86ConfInputPtr ptr)
-{
- XF86ConfInputPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->inp_identifier);
- TestFree (ptr->inp_driver);
- TestFree (ptr->inp_comment);
- xf86optionListFree (ptr->inp_option_lst);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-int
-xf86validateInput (XF86ConfigPtr p)
-{
- XF86ConfInputPtr input = p->conf_input_lst;
-
- while (input) {
- if (!input->inp_driver) {
- xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
- return (FALSE);
- }
- input = input->list.next;
- }
- return (TRUE);
-}
-
-XF86ConfInputPtr
-xf86findInput (const char *ident, XF86ConfInputPtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->inp_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
-
-XF86ConfInputPtr
-xf86findInputByDriver (const char *driver, XF86ConfInputPtr p)
-{
- while (p)
- {
- if (xf86nameCompare (driver, p->inp_driver) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
-
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec InputTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputList
+
+XF86ConfInputPtr
+xf86parseInputSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
+
+ while ((token = xf86getToken (InputTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->inp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ if (strcmp(val.str, "keyboard") == 0)
+ ptr->inp_driver = "kbd";
+ else
+ ptr->inp_driver = val.str;
+ break;
+ case OPTION:
+ ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("InputDevice section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printInputSection (FILE * cf, XF86ConfInputPtr ptr)
+{
+ while (ptr)
+ {
+ fprintf (cf, "Section \"InputDevice\"\n");
+ if (ptr->inp_comment)
+ fprintf (cf, "%s", ptr->inp_comment);
+ if (ptr->inp_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->inp_identifier);
+ if (ptr->inp_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->inp_driver);
+ xf86printOptionList(cf, ptr->inp_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeInputList (XF86ConfInputPtr ptr)
+{
+ XF86ConfInputPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->inp_identifier);
+ TestFree (ptr->inp_driver);
+ TestFree (ptr->inp_comment);
+ xf86optionListFree (ptr->inp_option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86validateInput (XF86ConfigPtr p)
+{
+ XF86ConfInputPtr input = p->conf_input_lst;
+
+ while (input) {
+ if (!input->inp_driver) {
+ xf86validationError (UNDEFINED_INPUTDRIVER_MSG, input->inp_identifier);
+ return FALSE;
+ }
+ input = input->list.next;
+ }
+ return TRUE;
+}
+
+XF86ConfInputPtr
+xf86findInput (const char *ident, XF86ConfInputPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->inp_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+XF86ConfInputPtr
+xf86findInputByDriver (const char *driver, XF86ConfInputPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (driver, p->inp_driver) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xfree86/parser/InputClass.c b/xorg-server/hw/xfree86/parser/InputClass.c
index 7fb2866cd..85161c38a 100644
--- a/xorg-server/hw/xfree86/parser/InputClass.c
+++ b/xorg-server/hw/xfree86/parser/InputClass.c
@@ -1,288 +1,401 @@
-/*
- * Copyright (c) 2009 Dan Nicholson
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <string.h>
-#include "os.h"
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static
-xf86ConfigSymTabRec InputClassTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {DRIVER, "driver"},
- {MATCH_PRODUCT, "matchproduct"},
- {MATCH_VENDOR, "matchvendor"},
- {MATCH_DEVICE_PATH, "matchdevicepath"},
- {MATCH_TAG, "matchtag"},
- {MATCH_IS_KEYBOARD, "matchiskeyboard"},
- {MATCH_IS_POINTER, "matchispointer"},
- {MATCH_IS_JOYSTICK, "matchisjoystick"},
- {MATCH_IS_TABLET, "matchistablet"},
- {MATCH_IS_TOUCHPAD, "matchistouchpad"},
- {MATCH_IS_TOUCHSCREEN, "matchistouchscreen"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeInputClassList
-
-#define TOKEN_SEP "|"
-
-XF86ConfInputClassPtr
-xf86parseInputClassSection(void)
-{
- int has_ident = FALSE;
- int token;
-
- parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
-
- while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
- switch (token) {
- case COMMENT:
- ptr->comment = xf86addComment(ptr->comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error(MULTIPLE_MSG, "Identifier");
- ptr->identifier = val.str;
- has_ident = TRUE;
- break;
- case DRIVER:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "Driver");
- if (strcmp(val.str, "keyboard") == 0)
- ptr->driver = "kbd";
- else
- ptr->driver = val.str;
- break;
- case OPTION:
- ptr->option_lst = xf86parseOption(ptr->option_lst);
- break;
- case MATCH_PRODUCT:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchProduct");
- ptr->match_product = xstrtokenize(val.str, TOKEN_SEP);
- break;
- case MATCH_VENDOR:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchVendor");
- ptr->match_vendor = xstrtokenize(val.str, TOKEN_SEP);
- break;
- case MATCH_DEVICE_PATH:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchDevicePath");
- ptr->match_device = xstrtokenize(val.str, TOKEN_SEP);
- break;
- case MATCH_TAG:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchTag");
- ptr->match_tag = xstrtokenize(val.str, TOKEN_SEP);
- break;
- case MATCH_IS_KEYBOARD:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchIsKeyboard");
- ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val,
- val.str);
- if (!ptr->is_keyboard.set)
- Error(BOOL_MSG, "MatchIsKeyboard");
- break;
- case MATCH_IS_POINTER:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchIsPointer");
- ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val,
- val.str);
- if (!ptr->is_pointer.set)
- Error(BOOL_MSG, "MatchIsPointer");
- break;
- case MATCH_IS_JOYSTICK:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchIsJoystick");
- ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val,
- val.str);
- if (!ptr->is_joystick.set)
- Error(BOOL_MSG, "MatchIsJoystick");
- break;
- case MATCH_IS_TABLET:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchIsTablet");
- ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val,
- val.str);
- if (!ptr->is_tablet.set)
- Error(BOOL_MSG, "MatchIsTablet");
- break;
- case MATCH_IS_TOUCHPAD:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchIsTouchpad");
- ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val,
- val.str);
- if (!ptr->is_touchpad.set)
- Error(BOOL_MSG, "MatchIsTouchpad");
- break;
- case MATCH_IS_TOUCHSCREEN:
- if (xf86getSubToken(&(ptr->comment)) != STRING)
- Error(QUOTE_MSG, "MatchIsTouchscreen");
- ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val,
- val.str);
- if (!ptr->is_touchscreen.set)
- Error(BOOL_MSG, "MatchIsTouchscreen");
- break;
- case EOF_TOKEN:
- Error(UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error(INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error(NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf("InputClass section parsed\n");
-#endif
-
- return ptr;
-}
-
-void
-xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
-{
- char **list;
-
- while (ptr) {
- fprintf(cf, "Section \"InputClass\"\n");
- if (ptr->comment)
- fprintf(cf, "%s", ptr->comment);
- if (ptr->identifier)
- fprintf(cf, "\tIdentifier \"%s\"\n", ptr->identifier);
- if (ptr->driver)
- fprintf(cf, "\tDriver \"%s\"\n", ptr->driver);
- if (ptr->match_product) {
- fprintf(cf, "\tMatchProduct \"");
- for (list = ptr->match_product; *list; list++)
- fprintf(cf, "%s%s",
- list == ptr->match_product ? "" : TOKEN_SEP,
- *list);
- fprintf(cf, "\"\n");
- }
- if (ptr->match_vendor) {
- fprintf(cf, "\tMatchVendor \"");
- for (list = ptr->match_vendor; *list; list++)
- fprintf(cf, "%s%s",
- list == ptr->match_vendor ? "" : TOKEN_SEP,
- *list);
- fprintf(cf, "\"\n");
- }
- if (ptr->match_device) {
- fprintf(cf, "\tMatchDevicePath \"");
- for (list = ptr->match_device; *list; list++)
- fprintf(cf, "%s%s",
- list == ptr->match_device ? "" : TOKEN_SEP,
- *list);
- fprintf(cf, "\"\n");
- }
- if (ptr->match_tag) {
- fprintf(cf, "\tMatchTag \"");
- for (list = ptr->match_tag; *list; list++)
- fprintf(cf, "%s%s",
- list == ptr->match_tag ? "" : TOKEN_SEP,
- *list);
- fprintf(cf, "\"\n");
- }
- if (ptr->is_keyboard.set)
- fprintf(cf, "\tIsKeyboard \"%s\"\n",
- ptr->is_keyboard.val ? "yes" : "no");
- if (ptr->is_pointer.set)
- fprintf(cf, "\tIsPointer \"%s\"\n",
- ptr->is_pointer.val ? "yes" : "no");
- if (ptr->is_joystick.set)
- fprintf(cf, "\tIsJoystick \"%s\"\n",
- ptr->is_joystick.val ? "yes" : "no");
- if (ptr->is_tablet.set)
- fprintf(cf, "\tIsTablet \"%s\"\n",
- ptr->is_tablet.val ? "yes" : "no");
- if (ptr->is_touchpad.set)
- fprintf(cf, "\tIsTouchpad \"%s\"\n",
- ptr->is_touchpad.val ? "yes" : "no");
- if (ptr->is_touchscreen.set)
- fprintf(cf, "\tIsTouchscreen \"%s\"\n",
- ptr->is_touchscreen.val ? "yes" : "no");
- xf86printOptionList(cf, ptr->option_lst, 1);
- fprintf(cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-void
-xf86freeInputClassList (XF86ConfInputClassPtr ptr)
-{
- XF86ConfInputClassPtr prev;
- char **list;
-
- while (ptr) {
- TestFree(ptr->identifier);
- TestFree(ptr->driver);
- if (ptr->match_product) {
- for (list = ptr->match_product; *list; list++)
- free(*list);
- free(ptr->match_product);
- }
- if (ptr->match_vendor) {
- for (list = ptr->match_vendor; *list; list++)
- free(*list);
- free(ptr->match_vendor);
- }
- if (ptr->match_device) {
- for (list = ptr->match_device; *list; list++)
- free(*list);
- free(ptr->match_device);
- }
- if (ptr->match_tag) {
- for (list = ptr->match_tag; *list; list++)
- free(*list);
- free(ptr->match_tag);
- }
- TestFree(ptr->comment);
- xf86optionListFree(ptr->option_lst);
-
- prev = ptr;
- ptr = ptr->list.next;
- free(prev);
- }
-}
+/*
+ * Copyright (c) 2009 Dan Nicholson
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <string.h>
+#include "os.h"
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static
+xf86ConfigSymTabRec InputClassTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {DRIVER, "driver"},
+ {MATCH_PRODUCT, "matchproduct"},
+ {MATCH_VENDOR, "matchvendor"},
+ {MATCH_DEVICE_PATH, "matchdevicepath"},
+ {MATCH_OS, "matchos"},
+ {MATCH_PNPID, "matchpnpid"},
+ {MATCH_USBID, "matchusbid"},
+ {MATCH_DRIVER, "matchdriver"},
+ {MATCH_TAG, "matchtag"},
+ {MATCH_IS_KEYBOARD, "matchiskeyboard"},
+ {MATCH_IS_POINTER, "matchispointer"},
+ {MATCH_IS_JOYSTICK, "matchisjoystick"},
+ {MATCH_IS_TABLET, "matchistablet"},
+ {MATCH_IS_TOUCHPAD, "matchistouchpad"},
+ {MATCH_IS_TOUCHSCREEN, "matchistouchscreen"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeInputClassList
+
+#define TOKEN_SEP "|"
+
+static void
+add_group_entry(struct list *head, char **values)
+{
+ xf86MatchGroup *group;
+
+ group = malloc(sizeof(*group));
+ if (group) {
+ group->values = values;
+ list_add(&group->entry, head);
+ }
+}
+
+XF86ConfInputClassPtr
+xf86parseInputClassSection(void)
+{
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue(XF86ConfInputClassPtr, XF86ConfInputClassRec)
+
+ /* Initialize MatchGroup lists */
+ list_init(&ptr->match_product);
+ list_init(&ptr->match_vendor);
+ list_init(&ptr->match_device);
+ list_init(&ptr->match_os);
+ list_init(&ptr->match_pnpid);
+ list_init(&ptr->match_usbid);
+ list_init(&ptr->match_driver);
+ list_init(&ptr->match_tag);
+
+ while ((token = xf86getToken(InputClassTab)) != ENDSECTION) {
+ switch (token) {
+ case COMMENT:
+ ptr->comment = xf86addComment(ptr->comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error(MULTIPLE_MSG, "Identifier");
+ ptr->identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case DRIVER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "Driver");
+ if (strcmp(val.str, "keyboard") == 0)
+ ptr->driver = "kbd";
+ else
+ ptr->driver = val.str;
+ break;
+ case OPTION:
+ ptr->option_lst = xf86parseOption(ptr->option_lst);
+ break;
+ case MATCH_PRODUCT:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchProduct");
+ add_group_entry(&ptr->match_product,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_VENDOR:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchVendor");
+ add_group_entry(&ptr->match_vendor,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_DEVICE_PATH:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchDevicePath");
+ add_group_entry(&ptr->match_device,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_OS:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchOS");
+ add_group_entry(&ptr->match_os,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_PNPID:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchPnPID");
+ add_group_entry(&ptr->match_pnpid,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_USBID:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchUSBID");
+ add_group_entry(&ptr->match_usbid,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_DRIVER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchDriver");
+ add_group_entry(&ptr->match_driver,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_TAG:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchTag");
+ add_group_entry(&ptr->match_tag,
+ xstrtokenize(val.str, TOKEN_SEP));
+ break;
+ case MATCH_IS_KEYBOARD:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsKeyboard");
+ ptr->is_keyboard.set = xf86getBoolValue(&ptr->is_keyboard.val,
+ val.str);
+ if (!ptr->is_keyboard.set)
+ Error(BOOL_MSG, "MatchIsKeyboard");
+ break;
+ case MATCH_IS_POINTER:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsPointer");
+ ptr->is_pointer.set = xf86getBoolValue(&ptr->is_pointer.val,
+ val.str);
+ if (!ptr->is_pointer.set)
+ Error(BOOL_MSG, "MatchIsPointer");
+ break;
+ case MATCH_IS_JOYSTICK:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsJoystick");
+ ptr->is_joystick.set = xf86getBoolValue(&ptr->is_joystick.val,
+ val.str);
+ if (!ptr->is_joystick.set)
+ Error(BOOL_MSG, "MatchIsJoystick");
+ break;
+ case MATCH_IS_TABLET:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTablet");
+ ptr->is_tablet.set = xf86getBoolValue(&ptr->is_tablet.val,
+ val.str);
+ if (!ptr->is_tablet.set)
+ Error(BOOL_MSG, "MatchIsTablet");
+ break;
+ case MATCH_IS_TOUCHPAD:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTouchpad");
+ ptr->is_touchpad.set = xf86getBoolValue(&ptr->is_touchpad.val,
+ val.str);
+ if (!ptr->is_touchpad.set)
+ Error(BOOL_MSG, "MatchIsTouchpad");
+ break;
+ case MATCH_IS_TOUCHSCREEN:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchIsTouchscreen");
+ ptr->is_touchscreen.set = xf86getBoolValue(&ptr->is_touchscreen.val,
+ val.str);
+ if (!ptr->is_touchscreen.set)
+ Error(BOOL_MSG, "MatchIsTouchscreen");
+ break;
+ case EOF_TOKEN:
+ Error(UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error(INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error(NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf("InputClass section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
+{
+ const xf86MatchGroup *group;
+ char * const *cur;
+
+ while (ptr) {
+ fprintf(cf, "Section \"InputClass\"\n");
+ if (ptr->comment)
+ fprintf(cf, "%s", ptr->comment);
+ if (ptr->identifier)
+ fprintf(cf, "\tIdentifier \"%s\"\n", ptr->identifier);
+ if (ptr->driver)
+ fprintf(cf, "\tDriver \"%s\"\n", ptr->driver);
+
+ list_for_each_entry(group, &ptr->match_product, entry) {
+ fprintf(cf, "\tMatchProduct \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_vendor, entry) {
+ fprintf(cf, "\tMatchVendor \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_device, entry) {
+ fprintf(cf, "\tMatchDevicePath \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_os, entry) {
+ fprintf(cf, "\tMatchOS \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_pnpid, entry) {
+ fprintf(cf, "\tMatchPnPID \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_usbid, entry) {
+ fprintf(cf, "\tMatchUSBID \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_driver, entry) {
+ fprintf(cf, "\tMatchDriver \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+ list_for_each_entry(group, &ptr->match_tag, entry) {
+ fprintf(cf, "\tMatchTag \"");
+ for (cur = group->values; *cur; cur++)
+ fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP,
+ *cur);
+ fprintf(cf, "\"\n");
+ }
+
+ if (ptr->is_keyboard.set)
+ fprintf(cf, "\tIsKeyboard \"%s\"\n",
+ ptr->is_keyboard.val ? "yes" : "no");
+ if (ptr->is_pointer.set)
+ fprintf(cf, "\tIsPointer \"%s\"\n",
+ ptr->is_pointer.val ? "yes" : "no");
+ if (ptr->is_joystick.set)
+ fprintf(cf, "\tIsJoystick \"%s\"\n",
+ ptr->is_joystick.val ? "yes" : "no");
+ if (ptr->is_tablet.set)
+ fprintf(cf, "\tIsTablet \"%s\"\n",
+ ptr->is_tablet.val ? "yes" : "no");
+ if (ptr->is_touchpad.set)
+ fprintf(cf, "\tIsTouchpad \"%s\"\n",
+ ptr->is_touchpad.val ? "yes" : "no");
+ if (ptr->is_touchscreen.set)
+ fprintf(cf, "\tIsTouchscreen \"%s\"\n",
+ ptr->is_touchscreen.val ? "yes" : "no");
+ xf86printOptionList(cf, ptr->option_lst, 1);
+ fprintf(cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeInputClassList (XF86ConfInputClassPtr ptr)
+{
+ XF86ConfInputClassPtr prev;
+
+ while (ptr) {
+ xf86MatchGroup *group, *next;
+ char **list;
+
+ TestFree(ptr->identifier);
+ TestFree(ptr->driver);
+
+ list_for_each_entry_safe(group, next, &ptr->match_product, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_vendor, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_device, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_os, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_pnpid, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_usbid, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_driver, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+ list_for_each_entry_safe(group, next, &ptr->match_tag, entry) {
+ list_del(&group->entry);
+ for (list = group->values; *list; list++)
+ free(*list);
+ free(group);
+ }
+
+ TestFree(ptr->comment);
+ xf86optionListFree(ptr->option_lst);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free(prev);
+ }
+}
diff --git a/xorg-server/hw/xfree86/parser/Layout.c b/xorg-server/hw/xfree86/parser/Layout.c
index 00c1e7d09..60e83390f 100644
--- a/xorg-server/hw/xfree86/parser/Layout.c
+++ b/xorg-server/hw/xfree86/parser/Layout.c
@@ -1,558 +1,558 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include <string.h>
-
-
-/* Needed for auto server layout */
-extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec LayoutTab[] =
-{
- {ENDSECTION, "endsection"},
- {SCREEN, "screen"},
- {IDENTIFIER, "identifier"},
- {INACTIVE, "inactive"},
- {INPUTDEVICE, "inputdevice"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-static xf86ConfigSymTabRec AdjTab[] =
-{
- {RIGHTOF, "rightof"},
- {LEFTOF, "leftof"},
- {ABOVE, "above"},
- {BELOW, "below"},
- {RELATIVE, "relative"},
- {ABSOLUTE, "absolute"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeLayoutList
-
-XF86ConfLayoutPtr
-xf86parseLayoutSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->lay_identifier = val.str;
- has_ident = TRUE;
- break;
- case INACTIVE:
- {
- XF86ConfInactivePtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInactiveRec));
- iptr->list.next = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free (iptr);
- Error (INACTIVE_MSG, NULL);
- }
- iptr->inactive_device_str = val.str;
- ptr->lay_inactive_lst = (XF86ConfInactivePtr)
- xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
- }
- break;
- case SCREEN:
- {
- XF86ConfAdjacencyPtr aptr;
- int absKeyword = 0;
-
- aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_scrnum = -1;
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_refscreen = NULL;
- if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
- aptr->adj_scrnum = val.num;
- else
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_screen_str = val.str;
-
- token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
- switch (token)
- {
- case RIGHTOF:
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- break;
- case LEFTOF:
- aptr->adj_where = CONF_ADJ_LEFTOF;
- break;
- case ABOVE:
- aptr->adj_where = CONF_ADJ_ABOVE;
- break;
- case BELOW:
- aptr->adj_where = CONF_ADJ_BELOW;
- break;
- case RELATIVE:
- aptr->adj_where = CONF_ADJ_RELATIVE;
- break;
- case ABSOLUTE:
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- absKeyword = 1;
- break;
- case EOF_TOKEN:
- free(aptr);
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- xf86unGetToken (token);
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == STRING)
- aptr->adj_where = CONF_ADJ_OBSOLETE;
- else
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- }
- switch (aptr->adj_where)
- {
- case CONF_ADJ_ABSOLUTE:
- if (absKeyword)
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token == NUMBER)
- {
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_y = val.num;
- } else {
- if (absKeyword) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- } else
- xf86unGetToken (token);
- }
- break;
- case CONF_ADJ_RIGHTOF:
- case CONF_ADJ_LEFTOF:
- case CONF_ADJ_ABOVE:
- case CONF_ADJ_BELOW:
- case CONF_ADJ_RELATIVE:
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != STRING) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_refscreen = val.str;
- if (aptr->adj_where == CONF_ADJ_RELATIVE)
- {
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_x = val.num;
- token = xf86getSubToken(&(ptr->lay_comment));
- if (token != NUMBER) {
- free(aptr);
- Error(INVALID_SCR_MSG, NULL);
- }
- aptr->adj_y = val.num;
- }
- break;
- case CONF_ADJ_OBSOLETE:
- /* top */
- aptr->adj_top_str = val.str;
-
- /* bottom */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_bottom_str = val.str;
-
- /* left */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_left_str = val.str;
-
- /* right */
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(aptr);
- Error (SCREEN_MSG, NULL);
- }
- aptr->adj_right_str = val.str;
-
- }
- ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
- xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
- }
- break;
- case INPUTDEVICE:
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = calloc (1, sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
- free(iptr);
- Error (INPUTDEV_MSG, NULL);
- }
- iptr->iref_inputdev_str = val.str;
- while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
- {
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
- }
- xf86unGetToken (token);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
- break;
- case OPTION:
- ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Layout section parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
-{
- XF86ConfAdjacencyPtr aptr;
- XF86ConfInactivePtr iptr;
- XF86ConfInputrefPtr inptr;
- XF86OptionPtr optr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"ServerLayout\"\n");
- if (ptr->lay_comment)
- fprintf (cf, "%s", ptr->lay_comment);
- if (ptr->lay_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
-
- for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
- {
- fprintf (cf, "\tScreen ");
- if (aptr->adj_scrnum >= 0)
- fprintf (cf, "%2d", aptr->adj_scrnum);
- else
- fprintf (cf, " ");
- fprintf (cf, " \"%s\"", aptr->adj_screen_str);
- switch(aptr->adj_where)
- {
- case CONF_ADJ_OBSOLETE:
- fprintf (cf, " \"%s\"", aptr->adj_top_str);
- fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
- fprintf (cf, " \"%s\"", aptr->adj_right_str);
- fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
- break;
- case CONF_ADJ_ABSOLUTE:
- if (aptr->adj_x != -1)
- fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
- else
- fprintf (cf, "\n");
- break;
- case CONF_ADJ_RIGHTOF:
- fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_LEFTOF:
- fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_ABOVE:
- fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_BELOW:
- fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
- break;
- case CONF_ADJ_RELATIVE:
- fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
- aptr->adj_x, aptr->adj_y);
- break;
- }
- }
- for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
- fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
- for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
- {
- fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
- for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
- {
- fprintf(cf, " \"%s\"", optr->opt_name);
- }
- fprintf(cf, "\n");
- }
- xf86printOptionList(cf, ptr->lay_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-static void
-xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
-{
- XF86ConfAdjacencyPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->adj_screen_str);
- TestFree (ptr->adj_top_str);
- TestFree (ptr->adj_bottom_str);
- TestFree (ptr->adj_left_str);
- TestFree (ptr->adj_right_str);
-
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-
-}
-
-static void
-xf86freeInputrefList (XF86ConfInputrefPtr ptr)
-{
- XF86ConfInputrefPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->iref_inputdev_str);
- xf86optionListFree (ptr->iref_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-
-}
-
-void
-xf86freeLayoutList (XF86ConfLayoutPtr ptr)
-{
- XF86ConfLayoutPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->lay_identifier);
- TestFree (ptr->lay_comment);
- xf86freeAdjacencyList (ptr->lay_adjacency_lst);
- xf86freeInputrefList (ptr->lay_input_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-int
-xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
-{
- int count = 0;
- XF86ConfInputPtr input = config->conf_input_lst;
- XF86ConfInputrefPtr inptr;
-
- /* add all AutoServerLayout devices to the server layout */
- while (input)
- {
- if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
- {
- XF86ConfInputrefPtr iref = layout->lay_input_lst;
-
- /* avoid duplicates if referenced but lists AutoServerLayout too */
- while (iref)
- {
- if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
- break;
- iref = iref->list.next;
- }
-
- if (!iref)
- {
- XF86ConfInputrefPtr iptr;
- iptr = calloc(1, sizeof(XF86ConfInputrefRec));
- iptr->iref_inputdev_str = input->inp_identifier;
- layout->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
- count++;
- }
- }
- input = input->list.next;
- }
-
- inptr = layout->lay_input_lst;
- while (inptr)
- {
- input = xf86findInput (inptr->iref_inputdev_str,
- config->conf_input_lst);
- if (!input)
- {
- xf86validationError (UNDEFINED_INPUT_MSG,
- inptr->iref_inputdev_str, layout->lay_identifier);
- return -1;
- }
- else
- inptr->iref_inputdev = input;
- inptr = inptr->list.next;
- }
-
- return count;
-}
-
-int
-xf86validateLayout (XF86ConfigPtr p)
-{
- XF86ConfLayoutPtr layout = p->conf_layout_lst;
- XF86ConfAdjacencyPtr adj;
- XF86ConfInactivePtr iptr;
- XF86ConfScreenPtr screen;
- XF86ConfDevicePtr device;
-
- while (layout)
- {
- adj = layout->lay_adjacency_lst;
- while (adj)
- {
- /* the first one can't be "" but all others can */
- screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
- if (!screen)
- {
- xf86validationError (UNDEFINED_SCREEN_MSG,
- adj->adj_screen_str, layout->lay_identifier);
- return (FALSE);
- }
- else
- adj->adj_screen = screen;
-
- adj = adj->list.next;
- }
- iptr = layout->lay_inactive_lst;
- while (iptr)
- {
- device = xf86findDevice (iptr->inactive_device_str,
- p->conf_device_lst);
- if (!device)
- {
- xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
- iptr->inactive_device_str, layout->lay_identifier);
- return (FALSE);
- }
- else
- iptr->inactive_device = device;
- iptr = iptr->list.next;
- }
-
- if (xf86layoutAddInputDevices(p, layout) == -1)
- return FALSE;
-
- layout = layout->list.next;
- }
- return (TRUE);
-}
-
-XF86ConfLayoutPtr
-xf86findLayout (const char *name, XF86ConfLayoutPtr list)
-{
- while (list)
- {
- if (xf86nameCompare (list->lay_identifier, name) == 0)
- return (list);
- list = list->list.next;
- }
- return (NULL);
-}
-
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+#include <string.h>
+
+
+/* Needed for auto server layout */
+extern int xf86CheckBoolOption(void* optlist, const char *name, int deflt);
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec LayoutTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {SCREEN, "screen"},
+ {IDENTIFIER, "identifier"},
+ {INACTIVE, "inactive"},
+ {INPUTDEVICE, "inputdevice"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec AdjTab[] =
+{
+ {RIGHTOF, "rightof"},
+ {LEFTOF, "leftof"},
+ {ABOVE, "above"},
+ {BELOW, "below"},
+ {RELATIVE, "relative"},
+ {ABSOLUTE, "absolute"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeLayoutList
+
+XF86ConfLayoutPtr
+xf86parseLayoutSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
+
+ while ((token = xf86getToken (LayoutTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->lay_comment = xf86addComment(ptr->lay_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->lay_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case INACTIVE:
+ {
+ XF86ConfInactivePtr iptr;
+
+ iptr = calloc (1, sizeof (XF86ConfInactiveRec));
+ iptr->list.next = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free (iptr);
+ Error (INACTIVE_MSG, NULL);
+ }
+ iptr->inactive_device_str = val.str;
+ ptr->lay_inactive_lst = (XF86ConfInactivePtr)
+ xf86addListItem ((glp) ptr->lay_inactive_lst, (glp) iptr);
+ }
+ break;
+ case SCREEN:
+ {
+ XF86ConfAdjacencyPtr aptr;
+ int absKeyword = 0;
+
+ aptr = calloc (1, sizeof (XF86ConfAdjacencyRec));
+ aptr->list.next = NULL;
+ aptr->adj_scrnum = -1;
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ aptr->adj_x = 0;
+ aptr->adj_y = 0;
+ aptr->adj_refscreen = NULL;
+ if ((token = xf86getSubToken (&(ptr->lay_comment))) == NUMBER)
+ aptr->adj_scrnum = val.num;
+ else
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_screen_str = val.str;
+
+ token = xf86getSubTokenWithTab(&(ptr->lay_comment), AdjTab);
+ switch (token)
+ {
+ case RIGHTOF:
+ aptr->adj_where = CONF_ADJ_RIGHTOF;
+ break;
+ case LEFTOF:
+ aptr->adj_where = CONF_ADJ_LEFTOF;
+ break;
+ case ABOVE:
+ aptr->adj_where = CONF_ADJ_ABOVE;
+ break;
+ case BELOW:
+ aptr->adj_where = CONF_ADJ_BELOW;
+ break;
+ case RELATIVE:
+ aptr->adj_where = CONF_ADJ_RELATIVE;
+ break;
+ case ABSOLUTE:
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ absKeyword = 1;
+ break;
+ case EOF_TOKEN:
+ free(aptr);
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86unGetToken (token);
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == STRING)
+ aptr->adj_where = CONF_ADJ_OBSOLETE;
+ else
+ aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ }
+ switch (aptr->adj_where)
+ {
+ case CONF_ADJ_ABSOLUTE:
+ if (absKeyword)
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token == NUMBER)
+ {
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_y = val.num;
+ } else {
+ if (absKeyword) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ } else
+ xf86unGetToken (token);
+ }
+ break;
+ case CONF_ADJ_RIGHTOF:
+ case CONF_ADJ_LEFTOF:
+ case CONF_ADJ_ABOVE:
+ case CONF_ADJ_BELOW:
+ case CONF_ADJ_RELATIVE:
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != STRING) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_refscreen = val.str;
+ if (aptr->adj_where == CONF_ADJ_RELATIVE)
+ {
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_x = val.num;
+ token = xf86getSubToken(&(ptr->lay_comment));
+ if (token != NUMBER) {
+ free(aptr);
+ Error(INVALID_SCR_MSG, NULL);
+ }
+ aptr->adj_y = val.num;
+ }
+ break;
+ case CONF_ADJ_OBSOLETE:
+ /* top */
+ aptr->adj_top_str = val.str;
+
+ /* bottom */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_bottom_str = val.str;
+
+ /* left */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_left_str = val.str;
+
+ /* right */
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(aptr);
+ Error (SCREEN_MSG, NULL);
+ }
+ aptr->adj_right_str = val.str;
+
+ }
+ ptr->lay_adjacency_lst = (XF86ConfAdjacencyPtr)
+ xf86addListItem ((glp) ptr->lay_adjacency_lst, (glp) aptr);
+ }
+ break;
+ case INPUTDEVICE:
+ {
+ XF86ConfInputrefPtr iptr;
+
+ iptr = calloc (1, sizeof (XF86ConfInputrefRec));
+ iptr->list.next = NULL;
+ iptr->iref_option_lst = NULL;
+ if (xf86getSubToken (&(ptr->lay_comment)) != STRING) {
+ free(iptr);
+ Error (INPUTDEV_MSG, NULL);
+ }
+ iptr->iref_inputdev_str = val.str;
+ while ((token = xf86getSubToken (&(ptr->lay_comment))) == STRING)
+ {
+ iptr->iref_option_lst =
+ xf86addNewOption (iptr->iref_option_lst, val.str, NULL);
+ }
+ xf86unGetToken (token);
+ ptr->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
+ }
+ break;
+ case OPTION:
+ ptr->lay_option_lst = xf86parseOption(ptr->lay_option_lst);
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Layout section parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printLayoutSection (FILE * cf, XF86ConfLayoutPtr ptr)
+{
+ XF86ConfAdjacencyPtr aptr;
+ XF86ConfInactivePtr iptr;
+ XF86ConfInputrefPtr inptr;
+ XF86OptionPtr optr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"ServerLayout\"\n");
+ if (ptr->lay_comment)
+ fprintf (cf, "%s", ptr->lay_comment);
+ if (ptr->lay_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->lay_identifier);
+
+ for (aptr = ptr->lay_adjacency_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tScreen ");
+ if (aptr->adj_scrnum >= 0)
+ fprintf (cf, "%2d", aptr->adj_scrnum);
+ else
+ fprintf (cf, " ");
+ fprintf (cf, " \"%s\"", aptr->adj_screen_str);
+ switch(aptr->adj_where)
+ {
+ case CONF_ADJ_OBSOLETE:
+ fprintf (cf, " \"%s\"", aptr->adj_top_str);
+ fprintf (cf, " \"%s\"", aptr->adj_bottom_str);
+ fprintf (cf, " \"%s\"", aptr->adj_right_str);
+ fprintf (cf, " \"%s\"\n", aptr->adj_left_str);
+ break;
+ case CONF_ADJ_ABSOLUTE:
+ if (aptr->adj_x != -1)
+ fprintf (cf, " %d %d\n", aptr->adj_x, aptr->adj_y);
+ else
+ fprintf (cf, "\n");
+ break;
+ case CONF_ADJ_RIGHTOF:
+ fprintf (cf, " RightOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_LEFTOF:
+ fprintf (cf, " LeftOf \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_ABOVE:
+ fprintf (cf, " Above \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_BELOW:
+ fprintf (cf, " Below \"%s\"\n", aptr->adj_refscreen);
+ break;
+ case CONF_ADJ_RELATIVE:
+ fprintf (cf, " Relative \"%s\" %d %d\n", aptr->adj_refscreen,
+ aptr->adj_x, aptr->adj_y);
+ break;
+ }
+ }
+ for (iptr = ptr->lay_inactive_lst; iptr; iptr = iptr->list.next)
+ fprintf (cf, "\tInactive \"%s\"\n", iptr->inactive_device_str);
+ for (inptr = ptr->lay_input_lst; inptr; inptr = inptr->list.next)
+ {
+ fprintf (cf, "\tInputDevice \"%s\"", inptr->iref_inputdev_str);
+ for (optr = inptr->iref_option_lst; optr; optr = optr->list.next)
+ {
+ fprintf(cf, " \"%s\"", optr->opt_name);
+ }
+ fprintf(cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->lay_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+static void
+xf86freeAdjacencyList (XF86ConfAdjacencyPtr ptr)
+{
+ XF86ConfAdjacencyPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->adj_screen_str);
+ TestFree (ptr->adj_top_str);
+ TestFree (ptr->adj_bottom_str);
+ TestFree (ptr->adj_left_str);
+ TestFree (ptr->adj_right_str);
+
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+
+}
+
+static void
+xf86freeInputrefList (XF86ConfInputrefPtr ptr)
+{
+ XF86ConfInputrefPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->iref_inputdev_str);
+ xf86optionListFree (ptr->iref_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+
+}
+
+void
+xf86freeLayoutList (XF86ConfLayoutPtr ptr)
+{
+ XF86ConfLayoutPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->lay_identifier);
+ TestFree (ptr->lay_comment);
+ xf86freeAdjacencyList (ptr->lay_adjacency_lst);
+ xf86freeInputrefList (ptr->lay_input_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout)
+{
+ int count = 0;
+ XF86ConfInputPtr input = config->conf_input_lst;
+ XF86ConfInputrefPtr inptr;
+
+ /* add all AutoServerLayout devices to the server layout */
+ while (input)
+ {
+ if (xf86CheckBoolOption(input->inp_option_lst, "AutoServerLayout", FALSE))
+ {
+ XF86ConfInputrefPtr iref = layout->lay_input_lst;
+
+ /* avoid duplicates if referenced but lists AutoServerLayout too */
+ while (iref)
+ {
+ if (strcmp(iref->iref_inputdev_str, input->inp_identifier) == 0)
+ break;
+ iref = iref->list.next;
+ }
+
+ if (!iref)
+ {
+ XF86ConfInputrefPtr iptr;
+ iptr = calloc(1, sizeof(XF86ConfInputrefRec));
+ iptr->iref_inputdev_str = input->inp_identifier;
+ layout->lay_input_lst = (XF86ConfInputrefPtr)
+ xf86addListItem((glp)layout->lay_input_lst, (glp)iptr);
+ count++;
+ }
+ }
+ input = input->list.next;
+ }
+
+ inptr = layout->lay_input_lst;
+ while (inptr)
+ {
+ input = xf86findInput (inptr->iref_inputdev_str,
+ config->conf_input_lst);
+ if (!input)
+ {
+ xf86validationError (UNDEFINED_INPUT_MSG,
+ inptr->iref_inputdev_str, layout->lay_identifier);
+ return -1;
+ }
+ else
+ inptr->iref_inputdev = input;
+ inptr = inptr->list.next;
+ }
+
+ return count;
+}
+
+int
+xf86validateLayout (XF86ConfigPtr p)
+{
+ XF86ConfLayoutPtr layout = p->conf_layout_lst;
+ XF86ConfAdjacencyPtr adj;
+ XF86ConfInactivePtr iptr;
+ XF86ConfScreenPtr screen;
+ XF86ConfDevicePtr device;
+
+ while (layout)
+ {
+ adj = layout->lay_adjacency_lst;
+ while (adj)
+ {
+ /* the first one can't be "" but all others can */
+ screen = xf86findScreen (adj->adj_screen_str, p->conf_screen_lst);
+ if (!screen)
+ {
+ xf86validationError (UNDEFINED_SCREEN_MSG,
+ adj->adj_screen_str, layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ adj->adj_screen = screen;
+
+ adj = adj->list.next;
+ }
+ iptr = layout->lay_inactive_lst;
+ while (iptr)
+ {
+ device = xf86findDevice (iptr->inactive_device_str,
+ p->conf_device_lst);
+ if (!device)
+ {
+ xf86validationError (UNDEFINED_DEVICE_LAY_MSG,
+ iptr->inactive_device_str, layout->lay_identifier);
+ return FALSE;
+ }
+ else
+ iptr->inactive_device = device;
+ iptr = iptr->list.next;
+ }
+
+ if (xf86layoutAddInputDevices(p, layout) == -1)
+ return FALSE;
+
+ layout = layout->list.next;
+ }
+ return TRUE;
+}
+
+XF86ConfLayoutPtr
+xf86findLayout (const char *name, XF86ConfLayoutPtr list)
+{
+ while (list)
+ {
+ if (xf86nameCompare (list->lay_identifier, name) == 0)
+ return list;
+ list = list->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xfree86/parser/Monitor.c b/xorg-server/hw/xfree86/parser/Monitor.c
index 50de091fc..8ad7c2e79 100644
--- a/xorg-server/hw/xfree86/parser/Monitor.c
+++ b/xorg-server/hw/xfree86/parser/Monitor.c
@@ -1,904 +1,904 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec MonitorTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {VENDOR, "vendorname"},
- {MODEL, "modelname"},
- {USEMODES, "usemodes"},
- {MODELINE, "modeline"},
- {DISPLAYSIZE, "displaysize"},
- {HORIZSYNC, "horizsync"},
- {VERTREFRESH, "vertrefresh"},
- {MODE, "mode"},
- {GAMMA, "gamma"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-static xf86ConfigSymTabRec ModesTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {MODELINE, "modeline"},
- {MODE, "mode"},
- {-1, ""},
-};
-
-static xf86ConfigSymTabRec TimingTab[] =
-{
- {TT_INTERLACE, "interlace"},
- {TT_PHSYNC, "+hsync"},
- {TT_NHSYNC, "-hsync"},
- {TT_PVSYNC, "+vsync"},
- {TT_NVSYNC, "-vsync"},
- {TT_CSYNC, "composite"},
- {TT_PCSYNC, "+csync"},
- {TT_NCSYNC, "-csync"},
- {TT_DBLSCAN, "doublescan"},
- {TT_HSKEW, "hskew"},
- {TT_BCAST, "bcast"},
- {TT_VSCAN, "vscan"},
- {TT_CUSTOM, "CUSTOM"},
- {-1, ""},
-};
-
-static xf86ConfigSymTabRec ModeTab[] =
-{
- {DOTCLOCK, "dotclock"},
- {HTIMINGS, "htimings"},
- {VTIMINGS, "vtimings"},
- {FLAGS, "flags"},
- {HSKEW, "hskew"},
- {BCAST, "bcast"},
- {VSCAN, "vscan"},
- {ENDMODE, "endmode"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeModeLineList
-
-static void
-xf86freeModeLineList (XF86ConfModeLinePtr ptr)
-{
- XF86ConfModeLinePtr prev;
- while (ptr)
- {
- TestFree (ptr->ml_identifier);
- TestFree (ptr->ml_comment);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-static XF86ConfModeLinePtr
-xf86parseModeLine (void)
-{
- int token;
- parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
-
- /* Identifier */
- if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
- Error ("ModeLine identifier expected", NULL);
- ptr->ml_identifier = val.str;
-
- /* DotClock */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine dotclock expected", NULL);
- ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
-
- /* HDisplay */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine Hdisplay expected", NULL);
- ptr->ml_hdisplay = val.num;
-
- /* HSyncStart */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine HSyncStart expected", NULL);
- ptr->ml_hsyncstart = val.num;
-
- /* HSyncEnd */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine HSyncEnd expected", NULL);
- ptr->ml_hsyncend = val.num;
-
- /* HTotal */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine HTotal expected", NULL);
- ptr->ml_htotal = val.num;
-
- /* VDisplay */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine Vdisplay expected", NULL);
- ptr->ml_vdisplay = val.num;
-
- /* VSyncStart */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine VSyncStart expected", NULL);
- ptr->ml_vsyncstart = val.num;
-
- /* VSyncEnd */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine VSyncEnd expected", NULL);
- ptr->ml_vsyncend = val.num;
-
- /* VTotal */
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("ModeLine VTotal expected", NULL);
- ptr->ml_vtotal = val.num;
-
- token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
- while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
- (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
- (token == TT_NVSYNC) || (token == TT_CSYNC) ||
- (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
- (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
- (token == TT_VSCAN) || (token == TT_BCAST))
- {
- switch (token)
- {
-
- case TT_INTERLACE:
- ptr->ml_flags |= XF86CONF_INTERLACE;
- break;
- case TT_PHSYNC:
- ptr->ml_flags |= XF86CONF_PHSYNC;
- break;
- case TT_NHSYNC:
- ptr->ml_flags |= XF86CONF_NHSYNC;
- break;
- case TT_PVSYNC:
- ptr->ml_flags |= XF86CONF_PVSYNC;
- break;
- case TT_NVSYNC:
- ptr->ml_flags |= XF86CONF_NVSYNC;
- break;
- case TT_CSYNC:
- ptr->ml_flags |= XF86CONF_CSYNC;
- break;
- case TT_PCSYNC:
- ptr->ml_flags |= XF86CONF_PCSYNC;
- break;
- case TT_NCSYNC:
- ptr->ml_flags |= XF86CONF_NCSYNC;
- break;
- case TT_DBLSCAN:
- ptr->ml_flags |= XF86CONF_DBLSCAN;
- break;
- case TT_HSKEW:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error (NUMBER_MSG, "Hskew");
- ptr->ml_hskew = val.num;
- ptr->ml_flags |= XF86CONF_HSKEW;
- break;
- case TT_BCAST:
- ptr->ml_flags |= XF86CONF_BCAST;
- break;
- case TT_VSCAN:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error (NUMBER_MSG, "Vscan");
- ptr->ml_vscan = val.num;
- ptr->ml_flags |= XF86CONF_VSCAN;
- break;
- case TT_CUSTOM:
- ptr->ml_flags |= XF86CONF_CUSTOM;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
- }
- xf86unGetToken (token);
-
-#ifdef DEBUG
- printf ("ModeLine parsed\n");
-#endif
- return (ptr);
-}
-
-static XF86ConfModeLinePtr
-xf86parseVerboseMode (void)
-{
- int token, token2;
- int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
- parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
-
- if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
- Error ("Mode name expected", NULL);
- ptr->ml_identifier = val.str;
- while ((token = xf86getToken (ModeTab)) != ENDMODE)
- {
- switch (token)
- {
- case COMMENT:
- ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
- break;
- case DOTCLOCK:
- if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER)
- Error (NUMBER_MSG, "DotClock");
- ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
- had_dotclock = 1;
- break;
- case HTIMINGS:
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hdisplay = val.num;
- else
- Error ("Horizontal display expected", NULL);
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hsyncstart = val.num;
- else
- Error ("Horizontal sync start expected", NULL);
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_hsyncend = val.num;
- else
- Error ("Horizontal sync end expected", NULL);
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_htotal = val.num;
- else
- Error ("Horizontal total expected", NULL);
- had_htimings = 1;
- break;
- case VTIMINGS:
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vdisplay = val.num;
- else
- Error ("Vertical display expected", NULL);
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vsyncstart = val.num;
- else
- Error ("Vertical sync start expected", NULL);
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vsyncend = val.num;
- else
- Error ("Vertical sync end expected", NULL);
-
- if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
- ptr->ml_vtotal = val.num;
- else
- Error ("Vertical total expected", NULL);
- had_vtimings = 1;
- break;
- case FLAGS:
- token = xf86getSubToken (&(ptr->ml_comment));
- if (token != STRING)
- Error (QUOTE_MSG, "Flags");
- while (token == STRING)
- {
- token2 = xf86getStringToken (TimingTab);
- switch (token2)
- {
- case TT_INTERLACE:
- ptr->ml_flags |= XF86CONF_INTERLACE;
- break;
- case TT_PHSYNC:
- ptr->ml_flags |= XF86CONF_PHSYNC;
- break;
- case TT_NHSYNC:
- ptr->ml_flags |= XF86CONF_NHSYNC;
- break;
- case TT_PVSYNC:
- ptr->ml_flags |= XF86CONF_PVSYNC;
- break;
- case TT_NVSYNC:
- ptr->ml_flags |= XF86CONF_NVSYNC;
- break;
- case TT_CSYNC:
- ptr->ml_flags |= XF86CONF_CSYNC;
- break;
- case TT_PCSYNC:
- ptr->ml_flags |= XF86CONF_PCSYNC;
- break;
- case TT_NCSYNC:
- ptr->ml_flags |= XF86CONF_NCSYNC;
- break;
- case TT_DBLSCAN:
- ptr->ml_flags |= XF86CONF_DBLSCAN;
- break;
- case TT_CUSTOM:
- ptr->ml_flags |= XF86CONF_CUSTOM;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error ("Unknown flag string", NULL);
- break;
- }
- token = xf86getSubToken (&(ptr->ml_comment));
- }
- xf86unGetToken (token);
- break;
- case HSKEW:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("Horizontal skew expected", NULL);
- ptr->ml_flags |= XF86CONF_HSKEW;
- ptr->ml_hskew = val.num;
- break;
- case VSCAN:
- if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
- Error ("Vertical scan count expected", NULL);
- ptr->ml_flags |= XF86CONF_VSCAN;
- ptr->ml_vscan = val.num;
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL);
- }
- }
- if (!had_dotclock)
- Error ("the dotclock is missing", NULL);
- if (!had_htimings)
- Error ("the horizontal timings are missing", NULL);
- if (!had_vtimings)
- Error ("the vertical timings are missing", NULL);
-
-#ifdef DEBUG
- printf ("Verbose Mode parsed\n");
-#endif
- return (ptr);
-}
-
-#undef CLEANUP
-
-#define CLEANUP xf86freeMonitorList
-
-XF86ConfMonitorPtr
-xf86parseMonitorSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- while ((token = xf86getToken (MonitorTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->mon_identifier = val.str;
- has_ident = TRUE;
- break;
- case VENDOR:
- if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
- Error (QUOTE_MSG, "Vendor");
- ptr->mon_vendor = val.str;
- break;
- case MODEL:
- if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
- Error (QUOTE_MSG, "ModelName");
- ptr->mon_modelname = val.str;
- break;
- case MODE:
- HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
- XF86ConfModeLinePtr);
- break;
- case MODELINE:
- HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
- XF86ConfModeLinePtr);
- break;
- case DISPLAYSIZE:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (DISPLAYSIZE_MSG, NULL);
- ptr->mon_width = val.realnum;
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (DISPLAYSIZE_MSG, NULL);
- ptr->mon_height = val.realnum;
- break;
-
- case HORIZSYNC:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (HORIZSYNC_MSG, NULL);
- do {
- if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
- Error ("Sorry. Too many horizontal sync intervals.", NULL);
- ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
- switch (token = xf86getSubToken (&(ptr->mon_comment)))
- {
- case COMMA:
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- ptr->mon_hsync[ptr->mon_n_hsync].lo;
- break;
- case DASH:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
- (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo)
- Error (HORIZSYNC_MSG, NULL);
- ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
- if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
- break;
- ptr->mon_n_hsync++;
- goto HorizDone;
- default:
- /* We cannot currently know if a '\n' was found,
- * or this is a real error
- */
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- ptr->mon_hsync[ptr->mon_n_hsync].lo;
- ptr->mon_n_hsync++;
- goto HorizDone;
- }
- ptr->mon_n_hsync++;
- } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
-HorizDone:
- xf86unGetToken (token);
- break;
-
- case VERTREFRESH:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
- Error (VERTREFRESH_MSG, NULL);
- do {
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
- switch (token = xf86getSubToken (&(ptr->mon_comment)))
- {
- case COMMA:
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
- break;
- case DASH:
- if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
- (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
- Error (VERTREFRESH_MSG, NULL);
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
- if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
- break;
- ptr->mon_n_vrefresh++;
- goto VertDone;
- default:
- /* We cannot currently know if a '\n' was found,
- * or this is a real error
- */
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
- ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
- ptr->mon_n_vrefresh++;
- goto VertDone;
- }
- if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
- Error ("Sorry. Too many vertical refresh intervals.", NULL);
- ptr->mon_n_vrefresh++;
- } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
-VertDone:
- xf86unGetToken (token);
- break;
-
- case GAMMA:
- if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER )
- {
- Error (INVALID_GAMMA_MSG, NULL);
- }
- else
- {
- ptr->mon_gamma_red = ptr->mon_gamma_green =
- ptr->mon_gamma_blue = val.realnum;
- if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
- {
- ptr->mon_gamma_green = val.realnum;
- if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
- {
- ptr->mon_gamma_blue = val.realnum;
- }
- else
- {
- Error (INVALID_GAMMA_MSG, NULL);
- }
- }
- else
- xf86unGetToken (token);
- }
- break;
- case OPTION:
- ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
- break;
- case USEMODES:
- {
- XF86ConfModesLinkPtr mptr;
-
- if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING)
- Error (QUOTE_MSG, "UseModes");
-
- /* add to the end of the list of modes sections
- referenced here */
- mptr = calloc (1, sizeof (XF86ConfModesLinkRec));
- mptr->list.next = NULL;
- mptr->ml_modes_str = val.str;
- mptr->ml_modes = NULL;
- ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
- xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst,
- (GenericListPtr)mptr);
- }
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
- CLEANUP (ptr);
- return NULL;
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Monitor section parsed\n");
-#endif
- return ptr;
-}
-
-#undef CLEANUP
-#define CLEANUP xf86freeModesList
-
-XF86ConfModesPtr
-xf86parseModesSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
-
- while ((token = xf86getToken (ModesTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->modes_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->modes_identifier = val.str;
- has_ident = TRUE;
- break;
- case MODE:
- HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
- XF86ConfModeLinePtr);
- break;
- case MODELINE:
- HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
- XF86ConfModeLinePtr);
- break;
- default:
- xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
- CLEANUP (ptr);
- return NULL;
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Modes section parsed\n");
-#endif
- return ptr;
-}
-
-#undef CLEANUP
-
-void
-xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr)
-{
- int i;
- XF86ConfModeLinePtr mlptr;
- XF86ConfModesLinkPtr mptr;
-
- while (ptr)
- {
- mptr = ptr->mon_modes_sect_lst;
- fprintf (cf, "Section \"Monitor\"\n");
- if (ptr->mon_comment)
- fprintf (cf, "%s", ptr->mon_comment);
- if (ptr->mon_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier);
- if (ptr->mon_vendor)
- fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor);
- if (ptr->mon_modelname)
- fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname);
- while (mptr) {
- fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str);
- mptr = mptr->list.next;
- }
- if (ptr->mon_width)
- fprintf (cf, "\tDisplaySize %d\t%d\n",
- ptr->mon_width,
- ptr->mon_height);
- for (i = 0; i < ptr->mon_n_hsync; i++)
- {
- fprintf (cf, "\tHorizSync %2.1f - %2.1f\n",
- ptr->mon_hsync[i].lo,
- ptr->mon_hsync[i].hi);
- }
- for (i = 0; i < ptr->mon_n_vrefresh; i++)
- {
- fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n",
- ptr->mon_vrefresh[i].lo,
- ptr->mon_vrefresh[i].hi);
- }
- if (ptr->mon_gamma_red) {
- if (ptr->mon_gamma_red == ptr->mon_gamma_green
- && ptr->mon_gamma_red == ptr->mon_gamma_blue)
- {
- fprintf (cf, "\tGamma %.4g\n",
- ptr->mon_gamma_red);
- } else {
- fprintf (cf, "\tGamma %.4g %.4g %.4g\n",
- ptr->mon_gamma_red,
- ptr->mon_gamma_green,
- ptr->mon_gamma_blue);
- }
- }
- for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
- {
- fprintf (cf, "\tModeLine \"%s\" %2.1f ",
- mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
- fprintf (cf, "%d %d %d %d %d %d %d %d",
- mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
- mlptr->ml_hsyncend, mlptr->ml_htotal,
- mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
- mlptr->ml_vsyncend, mlptr->ml_vtotal);
- if (mlptr->ml_flags & XF86CONF_PHSYNC)
- fprintf (cf, " +hsync");
- if (mlptr->ml_flags & XF86CONF_NHSYNC)
- fprintf (cf, " -hsync");
- if (mlptr->ml_flags & XF86CONF_PVSYNC)
- fprintf (cf, " +vsync");
- if (mlptr->ml_flags & XF86CONF_NVSYNC)
- fprintf (cf, " -vsync");
- if (mlptr->ml_flags & XF86CONF_INTERLACE)
- fprintf (cf, " interlace");
- if (mlptr->ml_flags & XF86CONF_CSYNC)
- fprintf (cf, " composite");
- if (mlptr->ml_flags & XF86CONF_PCSYNC)
- fprintf (cf, " +csync");
- if (mlptr->ml_flags & XF86CONF_NCSYNC)
- fprintf (cf, " -csync");
- if (mlptr->ml_flags & XF86CONF_DBLSCAN)
- fprintf (cf, " doublescan");
- if (mlptr->ml_flags & XF86CONF_HSKEW)
- fprintf (cf, " hskew %d", mlptr->ml_hskew);
- if (mlptr->ml_flags & XF86CONF_BCAST)
- fprintf (cf, " bcast");
- fprintf (cf, "\n");
- }
- xf86printOptionList(cf, ptr->mon_option_lst, 1);
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-void
-xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr)
-{
- XF86ConfModeLinePtr mlptr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"Modes\"\n");
- if (ptr->modes_comment)
- fprintf (cf, "%s", ptr->modes_comment);
- if (ptr->modes_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier);
- for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
- {
- fprintf (cf, "\tModeLine \"%s\" %2.1f ",
- mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
- fprintf (cf, "%d %d %d %d %d %d %d %d",
- mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
- mlptr->ml_hsyncend, mlptr->ml_htotal,
- mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
- mlptr->ml_vsyncend, mlptr->ml_vtotal);
- if (mlptr->ml_flags & XF86CONF_PHSYNC)
- fprintf (cf, " +hsync");
- if (mlptr->ml_flags & XF86CONF_NHSYNC)
- fprintf (cf, " -hsync");
- if (mlptr->ml_flags & XF86CONF_PVSYNC)
- fprintf (cf, " +vsync");
- if (mlptr->ml_flags & XF86CONF_NVSYNC)
- fprintf (cf, " -vsync");
- if (mlptr->ml_flags & XF86CONF_INTERLACE)
- fprintf (cf, " interlace");
- if (mlptr->ml_flags & XF86CONF_CSYNC)
- fprintf (cf, " composite");
- if (mlptr->ml_flags & XF86CONF_PCSYNC)
- fprintf (cf, " +csync");
- if (mlptr->ml_flags & XF86CONF_NCSYNC)
- fprintf (cf, " -csync");
- if (mlptr->ml_flags & XF86CONF_DBLSCAN)
- fprintf (cf, " doublescan");
- if (mlptr->ml_flags & XF86CONF_HSKEW)
- fprintf (cf, " hskew %d", mlptr->ml_hskew);
- if (mlptr->ml_flags & XF86CONF_VSCAN)
- fprintf (cf, " vscan %d", mlptr->ml_vscan);
- if (mlptr->ml_flags & XF86CONF_BCAST)
- fprintf (cf, " bcast");
- if (mlptr->ml_comment)
- fprintf (cf, "%s", mlptr->ml_comment);
- else
- fprintf (cf, "\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-}
-
-void
-xf86freeMonitorList (XF86ConfMonitorPtr ptr)
-{
- XF86ConfMonitorPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->mon_identifier);
- TestFree (ptr->mon_vendor);
- TestFree (ptr->mon_modelname);
- TestFree (ptr->mon_comment);
- xf86optionListFree (ptr->mon_option_lst);
- xf86freeModeLineList (ptr->mon_modeline_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-void
-xf86freeModesList (XF86ConfModesPtr ptr)
-{
- XF86ConfModesPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->modes_identifier);
- TestFree (ptr->modes_comment);
- xf86freeModeLineList (ptr->mon_modeline_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-XF86ConfMonitorPtr
-xf86findMonitor (const char *ident, XF86ConfMonitorPtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->mon_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
-
-XF86ConfModesPtr
-xf86findModes (const char *ident, XF86ConfModesPtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->modes_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
-
-XF86ConfModeLinePtr
-xf86findModeLine (const char *ident, XF86ConfModeLinePtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->ml_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
-
-int
-xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen)
-{
- XF86ConfMonitorPtr monitor = screen->scrn_monitor;
- XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst;
- XF86ConfModesPtr modes;
- while(modeslnk)
- {
- modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst);
- if (!modes)
- {
- xf86validationError (UNDEFINED_MODES_MSG,
- modeslnk->ml_modes_str,
- screen->scrn_identifier);
- return (FALSE);
- }
- modeslnk->ml_modes = modes;
- modeslnk = modeslnk->list.next;
- }
- return (TRUE);
-}
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec MonitorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {MODEL, "modelname"},
+ {USEMODES, "usemodes"},
+ {MODELINE, "modeline"},
+ {DISPLAYSIZE, "displaysize"},
+ {HORIZSYNC, "horizsync"},
+ {VERTREFRESH, "vertrefresh"},
+ {MODE, "mode"},
+ {GAMMA, "gamma"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModesTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {MODELINE, "modeline"},
+ {MODE, "mode"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec TimingTab[] =
+{
+ {TT_INTERLACE, "interlace"},
+ {TT_PHSYNC, "+hsync"},
+ {TT_NHSYNC, "-hsync"},
+ {TT_PVSYNC, "+vsync"},
+ {TT_NVSYNC, "-vsync"},
+ {TT_CSYNC, "composite"},
+ {TT_PCSYNC, "+csync"},
+ {TT_NCSYNC, "-csync"},
+ {TT_DBLSCAN, "doublescan"},
+ {TT_HSKEW, "hskew"},
+ {TT_BCAST, "bcast"},
+ {TT_VSCAN, "vscan"},
+ {TT_CUSTOM, "CUSTOM"},
+ {-1, ""},
+};
+
+static xf86ConfigSymTabRec ModeTab[] =
+{
+ {DOTCLOCK, "dotclock"},
+ {HTIMINGS, "htimings"},
+ {VTIMINGS, "vtimings"},
+ {FLAGS, "flags"},
+ {HSKEW, "hskew"},
+ {BCAST, "bcast"},
+ {VSCAN, "vscan"},
+ {ENDMODE, "endmode"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeModeLineList
+
+static void
+xf86freeModeLineList (XF86ConfModeLinePtr ptr)
+{
+ XF86ConfModeLinePtr prev;
+ while (ptr)
+ {
+ TestFree (ptr->ml_identifier);
+ TestFree (ptr->ml_comment);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+static XF86ConfModeLinePtr
+xf86parseModeLine (void)
+{
+ int token;
+ parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ /* Identifier */
+ if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
+ Error ("ModeLine identifier expected", NULL);
+ ptr->ml_identifier = val.str;
+
+ /* DotClock */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine dotclock expected", NULL);
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+
+ /* HDisplay */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine Hdisplay expected", NULL);
+ ptr->ml_hdisplay = val.num;
+
+ /* HSyncStart */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HSyncStart expected", NULL);
+ ptr->ml_hsyncstart = val.num;
+
+ /* HSyncEnd */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HSyncEnd expected", NULL);
+ ptr->ml_hsyncend = val.num;
+
+ /* HTotal */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine HTotal expected", NULL);
+ ptr->ml_htotal = val.num;
+
+ /* VDisplay */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine Vdisplay expected", NULL);
+ ptr->ml_vdisplay = val.num;
+
+ /* VSyncStart */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VSyncStart expected", NULL);
+ ptr->ml_vsyncstart = val.num;
+
+ /* VSyncEnd */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VSyncEnd expected", NULL);
+ ptr->ml_vsyncend = val.num;
+
+ /* VTotal */
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("ModeLine VTotal expected", NULL);
+ ptr->ml_vtotal = val.num;
+
+ token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
+ while ((token == TT_INTERLACE) || (token == TT_PHSYNC) ||
+ (token == TT_NHSYNC) || (token == TT_PVSYNC) ||
+ (token == TT_NVSYNC) || (token == TT_CSYNC) ||
+ (token == TT_PCSYNC) || (token == TT_NCSYNC) ||
+ (token == TT_DBLSCAN) || (token == TT_HSKEW) ||
+ (token == TT_VSCAN) || (token == TT_BCAST))
+ {
+ switch (token)
+ {
+
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_HSKEW:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Hskew");
+ ptr->ml_hskew = val.num;
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ break;
+ case TT_BCAST:
+ ptr->ml_flags |= XF86CONF_BCAST;
+ break;
+ case TT_VSCAN:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Vscan");
+ ptr->ml_vscan = val.num;
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ break;
+ case TT_CUSTOM:
+ ptr->ml_flags |= XF86CONF_CUSTOM;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ token = xf86getSubTokenWithTab (&(ptr->ml_comment), TimingTab);
+ }
+ xf86unGetToken (token);
+
+#ifdef DEBUG
+ printf ("ModeLine parsed\n");
+#endif
+ return ptr;
+}
+
+static XF86ConfModeLinePtr
+xf86parseVerboseMode (void)
+{
+ int token, token2;
+ int had_dotclock = 0, had_htimings = 0, had_vtimings = 0;
+ parsePrologue (XF86ConfModeLinePtr, XF86ConfModeLineRec)
+
+ if (xf86getSubToken (&(ptr->ml_comment)) != STRING)
+ Error ("Mode name expected", NULL);
+ ptr->ml_identifier = val.str;
+ while ((token = xf86getToken (ModeTab)) != ENDMODE)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->ml_comment = xf86addComment(ptr->ml_comment, val.str);
+ break;
+ case DOTCLOCK:
+ if ((token = xf86getSubToken (&(ptr->ml_comment))) != NUMBER)
+ Error (NUMBER_MSG, "DotClock");
+ ptr->ml_clock = (int) (val.realnum * 1000.0 + 0.5);
+ had_dotclock = 1;
+ break;
+ case HTIMINGS:
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hdisplay = val.num;
+ else
+ Error ("Horizontal display expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncstart = val.num;
+ else
+ Error ("Horizontal sync start expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_hsyncend = val.num;
+ else
+ Error ("Horizontal sync end expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_htotal = val.num;
+ else
+ Error ("Horizontal total expected", NULL);
+ had_htimings = 1;
+ break;
+ case VTIMINGS:
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vdisplay = val.num;
+ else
+ Error ("Vertical display expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncstart = val.num;
+ else
+ Error ("Vertical sync start expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vsyncend = val.num;
+ else
+ Error ("Vertical sync end expected", NULL);
+
+ if (xf86getSubToken (&(ptr->ml_comment)) == NUMBER)
+ ptr->ml_vtotal = val.num;
+ else
+ Error ("Vertical total expected", NULL);
+ had_vtimings = 1;
+ break;
+ case FLAGS:
+ token = xf86getSubToken (&(ptr->ml_comment));
+ if (token != STRING)
+ Error (QUOTE_MSG, "Flags");
+ while (token == STRING)
+ {
+ token2 = xf86getStringToken (TimingTab);
+ switch (token2)
+ {
+ case TT_INTERLACE:
+ ptr->ml_flags |= XF86CONF_INTERLACE;
+ break;
+ case TT_PHSYNC:
+ ptr->ml_flags |= XF86CONF_PHSYNC;
+ break;
+ case TT_NHSYNC:
+ ptr->ml_flags |= XF86CONF_NHSYNC;
+ break;
+ case TT_PVSYNC:
+ ptr->ml_flags |= XF86CONF_PVSYNC;
+ break;
+ case TT_NVSYNC:
+ ptr->ml_flags |= XF86CONF_NVSYNC;
+ break;
+ case TT_CSYNC:
+ ptr->ml_flags |= XF86CONF_CSYNC;
+ break;
+ case TT_PCSYNC:
+ ptr->ml_flags |= XF86CONF_PCSYNC;
+ break;
+ case TT_NCSYNC:
+ ptr->ml_flags |= XF86CONF_NCSYNC;
+ break;
+ case TT_DBLSCAN:
+ ptr->ml_flags |= XF86CONF_DBLSCAN;
+ break;
+ case TT_CUSTOM:
+ ptr->ml_flags |= XF86CONF_CUSTOM;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error ("Unknown flag string", NULL);
+ break;
+ }
+ token = xf86getSubToken (&(ptr->ml_comment));
+ }
+ xf86unGetToken (token);
+ break;
+ case HSKEW:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("Horizontal skew expected", NULL);
+ ptr->ml_flags |= XF86CONF_HSKEW;
+ ptr->ml_hskew = val.num;
+ break;
+ case VSCAN:
+ if (xf86getSubToken (&(ptr->ml_comment)) != NUMBER)
+ Error ("Vertical scan count expected", NULL);
+ ptr->ml_flags |= XF86CONF_VSCAN;
+ ptr->ml_vscan = val.num;
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error ("Unexepcted token in verbose \"Mode\" entry\n", NULL);
+ }
+ }
+ if (!had_dotclock)
+ Error ("the dotclock is missing", NULL);
+ if (!had_htimings)
+ Error ("the horizontal timings are missing", NULL);
+ if (!had_vtimings)
+ Error ("the vertical timings are missing", NULL);
+
+#ifdef DEBUG
+ printf ("Verbose Mode parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+
+#define CLEANUP xf86freeMonitorList
+
+XF86ConfMonitorPtr
+xf86parseMonitorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
+
+ while ((token = xf86getToken (MonitorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->mon_comment = xf86addComment(ptr->mon_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->mon_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->mon_vendor = val.str;
+ break;
+ case MODEL:
+ if (xf86getSubToken (&(ptr->mon_comment)) != STRING)
+ Error (QUOTE_MSG, "ModelName");
+ ptr->mon_modelname = val.str;
+ break;
+ case MODE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ case DISPLAYSIZE:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (DISPLAYSIZE_MSG, NULL);
+ ptr->mon_width = val.realnum;
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (DISPLAYSIZE_MSG, NULL);
+ ptr->mon_height = val.realnum;
+ break;
+
+ case HORIZSYNC:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (HORIZSYNC_MSG, NULL);
+ do {
+ if (ptr->mon_n_hsync >= CONF_MAX_HSYNC)
+ Error ("Sorry. Too many horizontal sync intervals.", NULL);
+ ptr->mon_hsync[ptr->mon_n_hsync].lo = val.realnum;
+ switch (token = xf86getSubToken (&(ptr->mon_comment)))
+ {
+ case COMMA:
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
+ (float)val.realnum < ptr->mon_hsync[ptr->mon_n_hsync].lo)
+ Error (HORIZSYNC_MSG, NULL);
+ ptr->mon_hsync[ptr->mon_n_hsync].hi = val.realnum;
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_hsync[ptr->mon_n_hsync].hi =
+ ptr->mon_hsync[ptr->mon_n_hsync].lo;
+ ptr->mon_n_hsync++;
+ goto HorizDone;
+ }
+ ptr->mon_n_hsync++;
+ } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
+HorizDone:
+ xf86unGetToken (token);
+ break;
+
+ case VERTREFRESH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER)
+ Error (VERTREFRESH_MSG, NULL);
+ do {
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo = val.realnum;
+ switch (token = xf86getSubToken (&(ptr->mon_comment)))
+ {
+ case COMMA:
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ break;
+ case DASH:
+ if (xf86getSubToken (&(ptr->mon_comment)) != NUMBER ||
+ (float)val.realnum < ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo)
+ Error (VERTREFRESH_MSG, NULL);
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi = val.realnum;
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) == COMMA)
+ break;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ default:
+ /* We cannot currently know if a '\n' was found,
+ * or this is a real error
+ */
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].hi =
+ ptr->mon_vrefresh[ptr->mon_n_vrefresh].lo;
+ ptr->mon_n_vrefresh++;
+ goto VertDone;
+ }
+ if (ptr->mon_n_vrefresh >= CONF_MAX_VREFRESH)
+ Error ("Sorry. Too many vertical refresh intervals.", NULL);
+ ptr->mon_n_vrefresh++;
+ } while ((token = xf86getSubToken (&(ptr->mon_comment))) == NUMBER);
+VertDone:
+ xf86unGetToken (token);
+ break;
+
+ case GAMMA:
+ if( xf86getSubToken (&(ptr->mon_comment)) != NUMBER )
+ {
+ Error (INVALID_GAMMA_MSG, NULL);
+ }
+ else
+ {
+ ptr->mon_gamma_red = ptr->mon_gamma_green =
+ ptr->mon_gamma_blue = val.realnum;
+ if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
+ {
+ ptr->mon_gamma_green = val.realnum;
+ if( xf86getSubToken (&(ptr->mon_comment)) == NUMBER )
+ {
+ ptr->mon_gamma_blue = val.realnum;
+ }
+ else
+ {
+ Error (INVALID_GAMMA_MSG, NULL);
+ }
+ }
+ else
+ xf86unGetToken (token);
+ }
+ break;
+ case OPTION:
+ ptr->mon_option_lst = xf86parseOption(ptr->mon_option_lst);
+ break;
+ case USEMODES:
+ {
+ XF86ConfModesLinkPtr mptr;
+
+ if ((token = xf86getSubToken (&(ptr->mon_comment))) != STRING)
+ Error (QUOTE_MSG, "UseModes");
+
+ /* add to the end of the list of modes sections
+ referenced here */
+ mptr = calloc (1, sizeof (XF86ConfModesLinkRec));
+ mptr->list.next = NULL;
+ mptr->ml_modes_str = val.str;
+ mptr->ml_modes = NULL;
+ ptr->mon_modes_sect_lst = (XF86ConfModesLinkPtr)
+ xf86addListItem((GenericListPtr)ptr->mon_modes_sect_lst,
+ (GenericListPtr)mptr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ CLEANUP (ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Monitor section parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+#define CLEANUP xf86freeModesList
+
+XF86ConfModesPtr
+xf86parseModesSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfModesPtr, XF86ConfModesRec)
+
+ while ((token = xf86getToken (ModesTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->modes_comment = xf86addComment(ptr->modes_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->modes_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->modes_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case MODE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseVerboseMode,
+ XF86ConfModeLinePtr);
+ break;
+ case MODELINE:
+ HANDLE_LIST (mon_modeline_lst, xf86parseModeLine,
+ XF86ConfModeLinePtr);
+ break;
+ default:
+ xf86parseError (INVALID_KEYWORD_MSG, xf86tokenString ());
+ CLEANUP (ptr);
+ return NULL;
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Modes section parsed\n");
+#endif
+ return ptr;
+}
+
+#undef CLEANUP
+
+void
+xf86printMonitorSection (FILE * cf, XF86ConfMonitorPtr ptr)
+{
+ int i;
+ XF86ConfModeLinePtr mlptr;
+ XF86ConfModesLinkPtr mptr;
+
+ while (ptr)
+ {
+ mptr = ptr->mon_modes_sect_lst;
+ fprintf (cf, "Section \"Monitor\"\n");
+ if (ptr->mon_comment)
+ fprintf (cf, "%s", ptr->mon_comment);
+ if (ptr->mon_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->mon_identifier);
+ if (ptr->mon_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->mon_vendor);
+ if (ptr->mon_modelname)
+ fprintf (cf, "\tModelName \"%s\"\n", ptr->mon_modelname);
+ while (mptr) {
+ fprintf (cf, "\tUseModes \"%s\"\n", mptr->ml_modes_str);
+ mptr = mptr->list.next;
+ }
+ if (ptr->mon_width)
+ fprintf (cf, "\tDisplaySize %d\t%d\n",
+ ptr->mon_width,
+ ptr->mon_height);
+ for (i = 0; i < ptr->mon_n_hsync; i++)
+ {
+ fprintf (cf, "\tHorizSync %2.1f - %2.1f\n",
+ ptr->mon_hsync[i].lo,
+ ptr->mon_hsync[i].hi);
+ }
+ for (i = 0; i < ptr->mon_n_vrefresh; i++)
+ {
+ fprintf (cf, "\tVertRefresh %2.1f - %2.1f\n",
+ ptr->mon_vrefresh[i].lo,
+ ptr->mon_vrefresh[i].hi);
+ }
+ if (ptr->mon_gamma_red) {
+ if (ptr->mon_gamma_red == ptr->mon_gamma_green
+ && ptr->mon_gamma_red == ptr->mon_gamma_blue)
+ {
+ fprintf (cf, "\tGamma %.4g\n",
+ ptr->mon_gamma_red);
+ } else {
+ fprintf (cf, "\tGamma %.4g %.4g %.4g\n",
+ ptr->mon_gamma_red,
+ ptr->mon_gamma_green,
+ ptr->mon_gamma_blue);
+ }
+ }
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
+ {
+ fprintf (cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf (cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf (cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf (cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf (cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf (cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf (cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf (cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf (cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf (cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf (cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf (cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf (cf, " bcast");
+ fprintf (cf, "\n");
+ }
+ xf86printOptionList(cf, ptr->mon_option_lst, 1);
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86printModesSection (FILE * cf, XF86ConfModesPtr ptr)
+{
+ XF86ConfModeLinePtr mlptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Modes\"\n");
+ if (ptr->modes_comment)
+ fprintf (cf, "%s", ptr->modes_comment);
+ if (ptr->modes_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->modes_identifier);
+ for (mlptr = ptr->mon_modeline_lst; mlptr; mlptr = mlptr->list.next)
+ {
+ fprintf (cf, "\tModeLine \"%s\" %2.1f ",
+ mlptr->ml_identifier, mlptr->ml_clock / 1000.0);
+ fprintf (cf, "%d %d %d %d %d %d %d %d",
+ mlptr->ml_hdisplay, mlptr->ml_hsyncstart,
+ mlptr->ml_hsyncend, mlptr->ml_htotal,
+ mlptr->ml_vdisplay, mlptr->ml_vsyncstart,
+ mlptr->ml_vsyncend, mlptr->ml_vtotal);
+ if (mlptr->ml_flags & XF86CONF_PHSYNC)
+ fprintf (cf, " +hsync");
+ if (mlptr->ml_flags & XF86CONF_NHSYNC)
+ fprintf (cf, " -hsync");
+ if (mlptr->ml_flags & XF86CONF_PVSYNC)
+ fprintf (cf, " +vsync");
+ if (mlptr->ml_flags & XF86CONF_NVSYNC)
+ fprintf (cf, " -vsync");
+ if (mlptr->ml_flags & XF86CONF_INTERLACE)
+ fprintf (cf, " interlace");
+ if (mlptr->ml_flags & XF86CONF_CSYNC)
+ fprintf (cf, " composite");
+ if (mlptr->ml_flags & XF86CONF_PCSYNC)
+ fprintf (cf, " +csync");
+ if (mlptr->ml_flags & XF86CONF_NCSYNC)
+ fprintf (cf, " -csync");
+ if (mlptr->ml_flags & XF86CONF_DBLSCAN)
+ fprintf (cf, " doublescan");
+ if (mlptr->ml_flags & XF86CONF_HSKEW)
+ fprintf (cf, " hskew %d", mlptr->ml_hskew);
+ if (mlptr->ml_flags & XF86CONF_VSCAN)
+ fprintf (cf, " vscan %d", mlptr->ml_vscan);
+ if (mlptr->ml_flags & XF86CONF_BCAST)
+ fprintf (cf, " bcast");
+ if (mlptr->ml_comment)
+ fprintf (cf, "%s", mlptr->ml_comment);
+ else
+ fprintf (cf, "\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+}
+
+void
+xf86freeMonitorList (XF86ConfMonitorPtr ptr)
+{
+ XF86ConfMonitorPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->mon_identifier);
+ TestFree (ptr->mon_vendor);
+ TestFree (ptr->mon_modelname);
+ TestFree (ptr->mon_comment);
+ xf86optionListFree (ptr->mon_option_lst);
+ xf86freeModeLineList (ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeModesList (XF86ConfModesPtr ptr)
+{
+ XF86ConfModesPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->modes_identifier);
+ TestFree (ptr->modes_comment);
+ xf86freeModeLineList (ptr->mon_modeline_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+XF86ConfMonitorPtr
+xf86findMonitor (const char *ident, XF86ConfMonitorPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->mon_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+XF86ConfModesPtr
+xf86findModes (const char *ident, XF86ConfModesPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->modes_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+XF86ConfModeLinePtr
+xf86findModeLine (const char *ident, XF86ConfModeLinePtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->ml_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
+int
+xf86validateMonitor (XF86ConfigPtr p, XF86ConfScreenPtr screen)
+{
+ XF86ConfMonitorPtr monitor = screen->scrn_monitor;
+ XF86ConfModesLinkPtr modeslnk = monitor->mon_modes_sect_lst;
+ XF86ConfModesPtr modes;
+ while(modeslnk)
+ {
+ modes = xf86findModes (modeslnk->ml_modes_str, p->conf_modes_lst);
+ if (!modes)
+ {
+ xf86validationError (UNDEFINED_MODES_MSG,
+ modeslnk->ml_modes_str,
+ screen->scrn_identifier);
+ return FALSE;
+ }
+ modeslnk->ml_modes = modes;
+ modeslnk = modeslnk->list.next;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c
index b3b004df6..b5667a79e 100644
--- a/xorg-server/hw/xfree86/parser/Screen.c
+++ b/xorg-server/hw/xfree86/parser/Screen.c
@@ -1,569 +1,569 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec DisplayTab[] =
-{
- {ENDSUBSECTION, "endsubsection"},
- {MODES, "modes"},
- {VIEWPORT, "viewport"},
- {VIRTUAL, "virtual"},
- {VISUAL, "visual"},
- {BLACK_TOK, "black"},
- {WHITE_TOK, "white"},
- {DEPTH, "depth"},
- {BPP, "fbbpp"},
- {WEIGHT, "weight"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeDisplayList
-
-static XF86ConfDisplayPtr
-xf86parseDisplaySubSection (void)
-{
- int token;
- parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)
-
- ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
- ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
- ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
- while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
- break;
- case VIEWPORT:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIEWPORT_MSG, NULL);
- ptr->disp_frameX0 = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIEWPORT_MSG, NULL);
- ptr->disp_frameY0 = val.num;
- break;
- case VIRTUAL:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIRTUAL_MSG, NULL);
- ptr->disp_virtualX = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (VIRTUAL_MSG, NULL);
- ptr->disp_virtualY = val.num;
- break;
- case DEPTH:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (NUMBER_MSG, "Display");
- ptr->disp_depth = val.num;
- break;
- case BPP:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (NUMBER_MSG, "Display");
- ptr->disp_bpp = val.num;
- break;
- case VISUAL:
- if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
- Error (QUOTE_MSG, "Display");
- ptr->disp_visual = val.str;
- break;
- case WEIGHT:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WEIGHT_MSG, NULL);
- ptr->disp_weight.red = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WEIGHT_MSG, NULL);
- ptr->disp_weight.green = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WEIGHT_MSG, NULL);
- ptr->disp_weight.blue = val.num;
- break;
- case BLACK_TOK:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (BLACK_MSG, NULL);
- ptr->disp_black.red = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (BLACK_MSG, NULL);
- ptr->disp_black.green = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (BLACK_MSG, NULL);
- ptr->disp_black.blue = val.num;
- break;
- case WHITE_TOK:
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WHITE_MSG, NULL);
- ptr->disp_white.red = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WHITE_MSG, NULL);
- ptr->disp_white.green = val.num;
- if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
- Error (WHITE_MSG, NULL);
- ptr->disp_white.blue = val.num;
- break;
- case MODES:
- {
- XF86ModePtr mptr;
-
- while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
- {
- mptr = calloc (1, sizeof (XF86ModeRec));
- mptr->mode_name = val.str;
- mptr->list.next = NULL;
- ptr->disp_mode_lst = (XF86ModePtr)
- xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
- }
- xf86unGetToken (token);
- }
- break;
- case OPTION:
- ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
-#ifdef DEBUG
- printf ("Display subsection parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-static xf86ConfigSymTabRec ScreenTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {OBSDRIVER, "driver"},
- {MDEVICE, "device"},
- {MONITOR, "monitor"},
- {VIDEOADAPTOR, "videoadaptor"},
- {SCREENNO, "screenno"},
- {SUBSECTION, "subsection"},
- {DEFAULTDEPTH, "defaultcolordepth"},
- {DEFAULTDEPTH, "defaultdepth"},
- {DEFAULTBPP, "defaultbpp"},
- {DEFAULTFBBPP, "defaultfbbpp"},
- {VIRTUAL, "virtual"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeScreenList
-XF86ConfScreenPtr
-xf86parseScreenSection (void)
-{
- int has_ident = FALSE;
- int has_driver= FALSE;
- int token;
-
- parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
-
- while ((token = xf86getToken (ScreenTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- ptr->scrn_identifier = val.str;
- if (has_ident || has_driver)
- Error (ONLY_ONE_MSG,"Identifier or Driver");
- has_ident = TRUE;
- break;
- case OBSDRIVER:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- ptr->scrn_obso_driver = val.str;
- if (has_ident || has_driver)
- Error (ONLY_ONE_MSG,"Identifier or Driver");
- has_driver = TRUE;
- break;
- case DEFAULTDEPTH:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (NUMBER_MSG, "DefaultDepth");
- ptr->scrn_defaultdepth = val.num;
- break;
- case DEFAULTBPP:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (NUMBER_MSG, "DefaultBPP");
- ptr->scrn_defaultbpp = val.num;
- break;
- case DEFAULTFBBPP:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (NUMBER_MSG, "DefaultFbBPP");
- ptr->scrn_defaultfbbpp = val.num;
- break;
- case MDEVICE:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Device");
- ptr->scrn_device_str = val.str;
- break;
- case MONITOR:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "Monitor");
- ptr->scrn_monitor_str = val.str;
- break;
- case VIDEOADAPTOR:
- {
- XF86ConfAdaptorLinkPtr aptr;
-
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "VideoAdaptor");
-
- /* Don't allow duplicates */
- for (aptr = ptr->scrn_adaptor_lst; aptr;
- aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
- if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0)
- break;
-
- if (aptr == NULL)
- {
- aptr = calloc (1, sizeof (XF86ConfAdaptorLinkRec));
- aptr->list.next = NULL;
- aptr->al_adaptor_str = val.str;
- ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
- xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr);
- }
- }
- break;
- case VIRTUAL:
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (VIRTUAL_MSG, NULL);
- ptr->scrn_virtualX = val.num;
- if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
- Error (VIRTUAL_MSG, NULL);
- ptr->scrn_virtualY = val.num;
- break;
- case OPTION:
- ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
- break;
- case SUBSECTION:
- if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
- Error (QUOTE_MSG, "SubSection");
- {
- free(val.str);
- HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection,
- XF86ConfDisplayPtr);
- }
- break;
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident && !has_driver)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("Screen section parsed\n");
-#endif
-
- return ptr;
-}
-
-void
-xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr)
-{
- XF86ConfAdaptorLinkPtr aptr;
- XF86ConfDisplayPtr dptr;
- XF86ModePtr mptr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"Screen\"\n");
- if (ptr->scrn_comment)
- fprintf (cf, "%s", ptr->scrn_comment);
- if (ptr->scrn_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier);
- if (ptr->scrn_obso_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
- if (ptr->scrn_device_str)
- fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
- if (ptr->scrn_monitor_str)
- fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
- if (ptr->scrn_defaultdepth)
- fprintf (cf, "\tDefaultDepth %d\n",
- ptr->scrn_defaultdepth);
- if (ptr->scrn_defaultbpp)
- fprintf (cf, "\tDefaultBPP %d\n",
- ptr->scrn_defaultbpp);
- if (ptr->scrn_defaultfbbpp)
- fprintf (cf, "\tDefaultFbBPP %d\n",
- ptr->scrn_defaultfbbpp);
- xf86printOptionList(cf, ptr->scrn_option_lst, 1);
- for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next)
- {
- fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
- }
- if (ptr->scrn_virtualX && ptr->scrn_virtualY)
- fprintf (cf, "\tVirtual %d %d\n",
- ptr->scrn_virtualX,
- ptr->scrn_virtualY);
- for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next)
- {
- fprintf (cf, "\tSubSection \"Display\"\n");
- if (dptr->disp_comment)
- fprintf (cf, "%s", dptr->disp_comment);
- if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0)
- {
- fprintf (cf, "\t\tViewport %d %d\n",
- dptr->disp_frameX0, dptr->disp_frameY0);
- }
- if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0)
- {
- fprintf (cf, "\t\tVirtual %d %d\n",
- dptr->disp_virtualX, dptr->disp_virtualY);
- }
- if (dptr->disp_depth)
- {
- fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth);
- }
- if (dptr->disp_bpp)
- {
- fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
- }
- if (dptr->disp_visual)
- {
- fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
- }
- if (dptr->disp_weight.red != 0)
- {
- fprintf (cf, "\t\tWeight %d %d %d\n",
- dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue);
- }
- if (dptr->disp_black.red != -1)
- {
- fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
- dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue);
- }
- if (dptr->disp_white.red != -1)
- {
- fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
- dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue);
- }
- if (dptr->disp_mode_lst)
- {
- fprintf (cf, "\t\tModes ");
- }
- for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next)
- {
- fprintf (cf, " \"%s\"", mptr->mode_name);
- }
- if (dptr->disp_mode_lst)
- {
- fprintf (cf, "\n");
- }
- xf86printOptionList(cf, dptr->disp_option_lst, 2);
- fprintf (cf, "\tEndSubSection\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-
-}
-
-void
-xf86freeScreenList (XF86ConfScreenPtr ptr)
-{
- XF86ConfScreenPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->scrn_identifier);
- TestFree (ptr->scrn_monitor_str);
- TestFree (ptr->scrn_device_str);
- TestFree (ptr->scrn_comment);
- xf86optionListFree (ptr->scrn_option_lst);
- xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst);
- xf86freeDisplayList (ptr->scrn_display_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-void
-xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr)
-{
- XF86ConfAdaptorLinkPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->al_adaptor_str);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-void
-xf86freeDisplayList (XF86ConfDisplayPtr ptr)
-{
- XF86ConfDisplayPtr prev;
-
- while (ptr)
- {
- xf86freeModeList (ptr->disp_mode_lst);
- xf86optionListFree (ptr->disp_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-void
-xf86freeModeList (XF86ModePtr ptr)
-{
- XF86ModePtr prev;
-
- while (ptr)
- {
- TestFree (ptr->mode_name);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-int
-xf86validateScreen (XF86ConfigPtr p)
-{
- XF86ConfScreenPtr screen = p->conf_screen_lst;
- XF86ConfMonitorPtr monitor;
- XF86ConfAdaptorLinkPtr adaptor;
-
- while (screen)
- {
- if (screen->scrn_obso_driver && !screen->scrn_identifier)
- screen->scrn_identifier = screen->scrn_obso_driver;
-
- monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst);
- if (screen->scrn_monitor_str)
- {
- if (monitor)
- {
- screen->scrn_monitor = monitor;
- if (!xf86validateMonitor(p, screen))
- return (FALSE);
- }
- }
-
- screen->scrn_device= xf86findDevice (screen->scrn_device_str, p->conf_device_lst);
-
- adaptor = screen->scrn_adaptor_lst;
- while (adaptor)
- {
- adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst);
- if (!adaptor->al_adaptor)
- {
- xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier);
- return (FALSE);
- }
- else if (adaptor->al_adaptor->va_fwdref)
- {
- xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str,
- adaptor->al_adaptor->va_fwdref);
- return (FALSE);
- }
-
- adaptor->al_adaptor->va_fwdref = strdup(screen->scrn_identifier);
- adaptor = adaptor->list.next;
- }
-
- screen = screen->list.next;
- }
-
- return (TRUE);
-}
-
-XF86ConfScreenPtr
-xf86findScreen (const char *ident, XF86ConfScreenPtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->scrn_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
-
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec DisplayTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {MODES, "modes"},
+ {VIEWPORT, "viewport"},
+ {VIRTUAL, "virtual"},
+ {VISUAL, "visual"},
+ {BLACK_TOK, "black"},
+ {WHITE_TOK, "white"},
+ {DEPTH, "depth"},
+ {BPP, "fbbpp"},
+ {WEIGHT, "weight"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeDisplayList
+
+static XF86ConfDisplayPtr
+xf86parseDisplaySubSection (void)
+{
+ int token;
+ parsePrologue (XF86ConfDisplayPtr, XF86ConfDisplayRec)
+
+ ptr->disp_black.red = ptr->disp_black.green = ptr->disp_black.blue = -1;
+ ptr->disp_white.red = ptr->disp_white.green = ptr->disp_white.blue = -1;
+ ptr->disp_frameX0 = ptr->disp_frameY0 = -1;
+ while ((token = xf86getToken (DisplayTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->disp_comment = xf86addComment(ptr->disp_comment, val.str);
+ break;
+ case VIEWPORT:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIEWPORT_MSG, NULL);
+ ptr->disp_frameX0 = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIEWPORT_MSG, NULL);
+ ptr->disp_frameY0 = val.num;
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->disp_virtualX = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->disp_virtualY = val.num;
+ break;
+ case DEPTH:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Display");
+ ptr->disp_depth = val.num;
+ break;
+ case BPP:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (NUMBER_MSG, "Display");
+ ptr->disp_bpp = val.num;
+ break;
+ case VISUAL:
+ if (xf86getSubToken (&(ptr->disp_comment)) != STRING)
+ Error (QUOTE_MSG, "Display");
+ ptr->disp_visual = val.str;
+ break;
+ case WEIGHT:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WEIGHT_MSG, NULL);
+ ptr->disp_weight.blue = val.num;
+ break;
+ case BLACK_TOK:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (BLACK_MSG, NULL);
+ ptr->disp_black.blue = val.num;
+ break;
+ case WHITE_TOK:
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.red = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.green = val.num;
+ if (xf86getSubToken (&(ptr->disp_comment)) != NUMBER)
+ Error (WHITE_MSG, NULL);
+ ptr->disp_white.blue = val.num;
+ break;
+ case MODES:
+ {
+ XF86ModePtr mptr;
+
+ while ((token = xf86getSubTokenWithTab (&(ptr->disp_comment), DisplayTab)) == STRING)
+ {
+ mptr = calloc (1, sizeof (XF86ModeRec));
+ mptr->mode_name = val.str;
+ mptr->list.next = NULL;
+ ptr->disp_mode_lst = (XF86ModePtr)
+ xf86addListItem ((glp) ptr->disp_mode_lst, (glp) mptr);
+ }
+ xf86unGetToken (token);
+ }
+ break;
+ case OPTION:
+ ptr->disp_option_lst = xf86parseOption(ptr->disp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("Display subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec ScreenTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {OBSDRIVER, "driver"},
+ {MDEVICE, "device"},
+ {MONITOR, "monitor"},
+ {VIDEOADAPTOR, "videoadaptor"},
+ {SCREENNO, "screenno"},
+ {SUBSECTION, "subsection"},
+ {DEFAULTDEPTH, "defaultcolordepth"},
+ {DEFAULTDEPTH, "defaultdepth"},
+ {DEFAULTBPP, "defaultbpp"},
+ {DEFAULTFBBPP, "defaultfbbpp"},
+ {VIRTUAL, "virtual"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeScreenList
+XF86ConfScreenPtr
+xf86parseScreenSection (void)
+{
+ int has_ident = FALSE;
+ int has_driver= FALSE;
+ int token;
+
+ parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
+
+ while ((token = xf86getToken (ScreenTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->scrn_comment = xf86addComment(ptr->scrn_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ ptr->scrn_identifier = val.str;
+ if (has_ident || has_driver)
+ Error (ONLY_ONE_MSG,"Identifier or Driver");
+ has_ident = TRUE;
+ break;
+ case OBSDRIVER:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->scrn_obso_driver = val.str;
+ if (has_ident || has_driver)
+ Error (ONLY_ONE_MSG,"Identifier or Driver");
+ has_driver = TRUE;
+ break;
+ case DEFAULTDEPTH:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultDepth");
+ ptr->scrn_defaultdepth = val.num;
+ break;
+ case DEFAULTBPP:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultBPP");
+ ptr->scrn_defaultbpp = val.num;
+ break;
+ case DEFAULTFBBPP:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (NUMBER_MSG, "DefaultFbBPP");
+ ptr->scrn_defaultfbbpp = val.num;
+ break;
+ case MDEVICE:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Device");
+ ptr->scrn_device_str = val.str;
+ break;
+ case MONITOR:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "Monitor");
+ ptr->scrn_monitor_str = val.str;
+ break;
+ case VIDEOADAPTOR:
+ {
+ XF86ConfAdaptorLinkPtr aptr;
+
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "VideoAdaptor");
+
+ /* Don't allow duplicates */
+ for (aptr = ptr->scrn_adaptor_lst; aptr;
+ aptr = (XF86ConfAdaptorLinkPtr) aptr->list.next)
+ if (xf86nameCompare (val.str, aptr->al_adaptor_str) == 0)
+ break;
+
+ if (aptr == NULL)
+ {
+ aptr = calloc (1, sizeof (XF86ConfAdaptorLinkRec));
+ aptr->list.next = NULL;
+ aptr->al_adaptor_str = val.str;
+ ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
+ xf86addListItem ((glp) ptr->scrn_adaptor_lst, (glp) aptr);
+ }
+ }
+ break;
+ case VIRTUAL:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->scrn_virtualX = val.num;
+ if (xf86getSubToken (&(ptr->scrn_comment)) != NUMBER)
+ Error (VIRTUAL_MSG, NULL);
+ ptr->scrn_virtualY = val.num;
+ break;
+ case OPTION:
+ ptr->scrn_option_lst = xf86parseOption(ptr->scrn_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->scrn_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ free(val.str);
+ HANDLE_LIST (scrn_display_lst, xf86parseDisplaySubSection,
+ XF86ConfDisplayPtr);
+ }
+ break;
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident && !has_driver)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("Screen section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printScreenSection (FILE * cf, XF86ConfScreenPtr ptr)
+{
+ XF86ConfAdaptorLinkPtr aptr;
+ XF86ConfDisplayPtr dptr;
+ XF86ModePtr mptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"Screen\"\n");
+ if (ptr->scrn_comment)
+ fprintf (cf, "%s", ptr->scrn_comment);
+ if (ptr->scrn_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->scrn_identifier);
+ if (ptr->scrn_obso_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
+ if (ptr->scrn_device_str)
+ fprintf (cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
+ if (ptr->scrn_monitor_str)
+ fprintf (cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
+ if (ptr->scrn_defaultdepth)
+ fprintf (cf, "\tDefaultDepth %d\n",
+ ptr->scrn_defaultdepth);
+ if (ptr->scrn_defaultbpp)
+ fprintf (cf, "\tDefaultBPP %d\n",
+ ptr->scrn_defaultbpp);
+ if (ptr->scrn_defaultfbbpp)
+ fprintf (cf, "\tDefaultFbBPP %d\n",
+ ptr->scrn_defaultfbbpp);
+ xf86printOptionList(cf, ptr->scrn_option_lst, 1);
+ for (aptr = ptr->scrn_adaptor_lst; aptr; aptr = aptr->list.next)
+ {
+ fprintf (cf, "\tVideoAdaptor \"%s\"\n", aptr->al_adaptor_str);
+ }
+ if (ptr->scrn_virtualX && ptr->scrn_virtualY)
+ fprintf (cf, "\tVirtual %d %d\n",
+ ptr->scrn_virtualX,
+ ptr->scrn_virtualY);
+ for (dptr = ptr->scrn_display_lst; dptr; dptr = dptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"Display\"\n");
+ if (dptr->disp_comment)
+ fprintf (cf, "%s", dptr->disp_comment);
+ if (dptr->disp_frameX0 >= 0 || dptr->disp_frameY0 >= 0)
+ {
+ fprintf (cf, "\t\tViewport %d %d\n",
+ dptr->disp_frameX0, dptr->disp_frameY0);
+ }
+ if (dptr->disp_virtualX != 0 || dptr->disp_virtualY != 0)
+ {
+ fprintf (cf, "\t\tVirtual %d %d\n",
+ dptr->disp_virtualX, dptr->disp_virtualY);
+ }
+ if (dptr->disp_depth)
+ {
+ fprintf (cf, "\t\tDepth %d\n", dptr->disp_depth);
+ }
+ if (dptr->disp_bpp)
+ {
+ fprintf (cf, "\t\tFbBPP %d\n", dptr->disp_bpp);
+ }
+ if (dptr->disp_visual)
+ {
+ fprintf (cf, "\t\tVisual \"%s\"\n", dptr->disp_visual);
+ }
+ if (dptr->disp_weight.red != 0)
+ {
+ fprintf (cf, "\t\tWeight %d %d %d\n",
+ dptr->disp_weight.red, dptr->disp_weight.green, dptr->disp_weight.blue);
+ }
+ if (dptr->disp_black.red != -1)
+ {
+ fprintf (cf, "\t\tBlack 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_black.red, dptr->disp_black.green, dptr->disp_black.blue);
+ }
+ if (dptr->disp_white.red != -1)
+ {
+ fprintf (cf, "\t\tWhite 0x%04x 0x%04x 0x%04x\n",
+ dptr->disp_white.red, dptr->disp_white.green, dptr->disp_white.blue);
+ }
+ if (dptr->disp_mode_lst)
+ {
+ fprintf (cf, "\t\tModes ");
+ }
+ for (mptr = dptr->disp_mode_lst; mptr; mptr = mptr->list.next)
+ {
+ fprintf (cf, " \"%s\"", mptr->mode_name);
+ }
+ if (dptr->disp_mode_lst)
+ {
+ fprintf (cf, "\n");
+ }
+ xf86printOptionList(cf, dptr->disp_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+
+}
+
+void
+xf86freeScreenList (XF86ConfScreenPtr ptr)
+{
+ XF86ConfScreenPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->scrn_identifier);
+ TestFree (ptr->scrn_monitor_str);
+ TestFree (ptr->scrn_device_str);
+ TestFree (ptr->scrn_comment);
+ xf86optionListFree (ptr->scrn_option_lst);
+ xf86freeAdaptorLinkList (ptr->scrn_adaptor_lst);
+ xf86freeDisplayList (ptr->scrn_display_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeAdaptorLinkList (XF86ConfAdaptorLinkPtr ptr)
+{
+ XF86ConfAdaptorLinkPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->al_adaptor_str);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeDisplayList (XF86ConfDisplayPtr ptr)
+{
+ XF86ConfDisplayPtr prev;
+
+ while (ptr)
+ {
+ xf86freeModeList (ptr->disp_mode_lst);
+ xf86optionListFree (ptr->disp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+void
+xf86freeModeList (XF86ModePtr ptr)
+{
+ XF86ModePtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->mode_name);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+int
+xf86validateScreen (XF86ConfigPtr p)
+{
+ XF86ConfScreenPtr screen = p->conf_screen_lst;
+ XF86ConfMonitorPtr monitor;
+ XF86ConfAdaptorLinkPtr adaptor;
+
+ while (screen)
+ {
+ if (screen->scrn_obso_driver && !screen->scrn_identifier)
+ screen->scrn_identifier = screen->scrn_obso_driver;
+
+ monitor = xf86findMonitor (screen->scrn_monitor_str, p->conf_monitor_lst);
+ if (screen->scrn_monitor_str)
+ {
+ if (monitor)
+ {
+ screen->scrn_monitor = monitor;
+ if (!xf86validateMonitor(p, screen))
+ return FALSE;
+ }
+ }
+
+ screen->scrn_device= xf86findDevice (screen->scrn_device_str, p->conf_device_lst);
+
+ adaptor = screen->scrn_adaptor_lst;
+ while (adaptor)
+ {
+ adaptor->al_adaptor = xf86findVideoAdaptor (adaptor->al_adaptor_str, p->conf_videoadaptor_lst);
+ if (!adaptor->al_adaptor)
+ {
+ xf86validationError (UNDEFINED_ADAPTOR_MSG, adaptor->al_adaptor_str, screen->scrn_identifier);
+ return FALSE;
+ }
+ else if (adaptor->al_adaptor->va_fwdref)
+ {
+ xf86validationError (ADAPTOR_REF_TWICE_MSG, adaptor->al_adaptor_str,
+ adaptor->al_adaptor->va_fwdref);
+ return FALSE;
+ }
+
+ adaptor->al_adaptor->va_fwdref = strdup(screen->scrn_identifier);
+ adaptor = adaptor->list.next;
+ }
+
+ screen = screen->list.next;
+ }
+
+ return TRUE;
+}
+
+XF86ConfScreenPtr
+xf86findScreen (const char *ident, XF86ConfScreenPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->scrn_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
+
diff --git a/xorg-server/hw/xfree86/parser/Video.c b/xorg-server/hw/xfree86/parser/Video.c
index beeb43e4f..40a909707 100644
--- a/xorg-server/hw/xfree86/parser/Video.c
+++ b/xorg-server/hw/xfree86/parser/Video.c
@@ -1,296 +1,296 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec VideoPortTab[] =
-{
- {ENDSUBSECTION, "endsubsection"},
- {IDENTIFIER, "identifier"},
- {OPTION, "option"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeVideoPortList
-
-static void
-xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
-{
- XF86ConfVideoPortPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->vp_identifier);
- TestFree (ptr->vp_comment);
- xf86optionListFree (ptr->vp_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-static XF86ConfVideoPortPtr
-xf86parseVideoPortSubSection (void)
-{
- int has_ident = FALSE;
- int token;
- parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec)
-
- while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->vp_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- ptr->vp_identifier = val.str;
- has_ident = TRUE;
- break;
- case OPTION:
- ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst);
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
-#ifdef DEBUG
- printf ("VideoPort subsection parsed\n");
-#endif
-
- return ptr;
-}
-
-#undef CLEANUP
-
-static xf86ConfigSymTabRec VideoAdaptorTab[] =
-{
- {ENDSECTION, "endsection"},
- {IDENTIFIER, "identifier"},
- {VENDOR, "vendorname"},
- {BOARD, "boardname"},
- {BUSID, "busid"},
- {DRIVER, "driver"},
- {OPTION, "option"},
- {SUBSECTION, "subsection"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeVideoAdaptorList
-
-XF86ConfVideoAdaptorPtr
-xf86parseVideoAdaptorSection (void)
-{
- int has_ident = FALSE;
- int token;
-
- parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
-
- while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION)
- {
- switch (token)
- {
- case COMMENT:
- ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
- break;
- case IDENTIFIER:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Identifier");
- ptr->va_identifier = val.str;
- if (has_ident == TRUE)
- Error (MULTIPLE_MSG, "Identifier");
- has_ident = TRUE;
- break;
- case VENDOR:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Vendor");
- ptr->va_vendor = val.str;
- break;
- case BOARD:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Board");
- ptr->va_board = val.str;
- break;
- case BUSID:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "BusID");
- ptr->va_busid = val.str;
- break;
- case DRIVER:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "Driver");
- ptr->va_driver = val.str;
- break;
- case OPTION:
- ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
- break;
- case SUBSECTION:
- if (xf86getSubToken (&(ptr->va_comment)) != STRING)
- Error (QUOTE_MSG, "SubSection");
- {
- HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection,
- XF86ConfVideoPortPtr);
- }
- break;
-
- case EOF_TOKEN:
- Error (UNEXPECTED_EOF_MSG, NULL);
- break;
- default:
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- break;
- }
- }
-
- if (!has_ident)
- Error (NO_IDENT_MSG, NULL);
-
-#ifdef DEBUG
- printf ("VideoAdaptor section parsed\n");
-#endif
-
- return ptr;
-}
-
-void
-xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr)
-{
- XF86ConfVideoPortPtr pptr;
-
- while (ptr)
- {
- fprintf (cf, "Section \"VideoAdaptor\"\n");
- if (ptr->va_comment)
- fprintf (cf, "%s", ptr->va_comment);
- if (ptr->va_identifier)
- fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier);
- if (ptr->va_vendor)
- fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor);
- if (ptr->va_board)
- fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board);
- if (ptr->va_busid)
- fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid);
- if (ptr->va_driver)
- fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver);
- xf86printOptionList(cf, ptr->va_option_lst, 1);
- for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next)
- {
- fprintf (cf, "\tSubSection \"VideoPort\"\n");
- if (pptr->vp_comment)
- fprintf (cf, "%s", pptr->vp_comment);
- if (pptr->vp_identifier)
- fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier);
- xf86printOptionList(cf, pptr->vp_option_lst, 2);
- fprintf (cf, "\tEndSubSection\n");
- }
- fprintf (cf, "EndSection\n\n");
- ptr = ptr->list.next;
- }
-
-}
-
-void
-xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr)
-{
- XF86ConfVideoAdaptorPtr prev;
-
- while (ptr)
- {
- TestFree (ptr->va_identifier);
- TestFree (ptr->va_vendor);
- TestFree (ptr->va_board);
- TestFree (ptr->va_busid);
- TestFree (ptr->va_driver);
- TestFree (ptr->va_fwdref);
- TestFree (ptr->va_comment);
- xf86freeVideoPortList (ptr->va_port_lst);
- xf86optionListFree (ptr->va_option_lst);
- prev = ptr;
- ptr = ptr->list.next;
- free (prev);
- }
-}
-
-XF86ConfVideoAdaptorPtr
-xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p)
-{
- while (p)
- {
- if (xf86nameCompare (ident, p->va_identifier) == 0)
- return (p);
-
- p = p->list.next;
- }
- return (NULL);
-}
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec VideoPortTab[] =
+{
+ {ENDSUBSECTION, "endsubsection"},
+ {IDENTIFIER, "identifier"},
+ {OPTION, "option"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVideoPortList
+
+static void
+xf86freeVideoPortList (XF86ConfVideoPortPtr ptr)
+{
+ XF86ConfVideoPortPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->vp_identifier);
+ TestFree (ptr->vp_comment);
+ xf86optionListFree (ptr->vp_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+static XF86ConfVideoPortPtr
+xf86parseVideoPortSubSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+ parsePrologue (XF86ConfVideoPortPtr, XF86ConfVideoPortRec)
+
+ while ((token = xf86getToken (VideoPortTab)) != ENDSUBSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->vp_comment = xf86addComment(ptr->vp_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->vp_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ ptr->vp_identifier = val.str;
+ has_ident = TRUE;
+ break;
+ case OPTION:
+ ptr->vp_option_lst = xf86parseOption(ptr->vp_option_lst);
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+#ifdef DEBUG
+ printf ("VideoPort subsection parsed\n");
+#endif
+
+ return ptr;
+}
+
+#undef CLEANUP
+
+static xf86ConfigSymTabRec VideoAdaptorTab[] =
+{
+ {ENDSECTION, "endsection"},
+ {IDENTIFIER, "identifier"},
+ {VENDOR, "vendorname"},
+ {BOARD, "boardname"},
+ {BUSID, "busid"},
+ {DRIVER, "driver"},
+ {OPTION, "option"},
+ {SUBSECTION, "subsection"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeVideoAdaptorList
+
+XF86ConfVideoAdaptorPtr
+xf86parseVideoAdaptorSection (void)
+{
+ int has_ident = FALSE;
+ int token;
+
+ parsePrologue (XF86ConfVideoAdaptorPtr, XF86ConfVideoAdaptorRec)
+
+ while ((token = xf86getToken (VideoAdaptorTab)) != ENDSECTION)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->va_comment = xf86addComment(ptr->va_comment, val.str);
+ break;
+ case IDENTIFIER:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Identifier");
+ ptr->va_identifier = val.str;
+ if (has_ident == TRUE)
+ Error (MULTIPLE_MSG, "Identifier");
+ has_ident = TRUE;
+ break;
+ case VENDOR:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Vendor");
+ ptr->va_vendor = val.str;
+ break;
+ case BOARD:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Board");
+ ptr->va_board = val.str;
+ break;
+ case BUSID:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "BusID");
+ ptr->va_busid = val.str;
+ break;
+ case DRIVER:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "Driver");
+ ptr->va_driver = val.str;
+ break;
+ case OPTION:
+ ptr->va_option_lst = xf86parseOption(ptr->va_option_lst);
+ break;
+ case SUBSECTION:
+ if (xf86getSubToken (&(ptr->va_comment)) != STRING)
+ Error (QUOTE_MSG, "SubSection");
+ {
+ HANDLE_LIST (va_port_lst, xf86parseVideoPortSubSection,
+ XF86ConfVideoPortPtr);
+ }
+ break;
+
+ case EOF_TOKEN:
+ Error (UNEXPECTED_EOF_MSG, NULL);
+ break;
+ default:
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ break;
+ }
+ }
+
+ if (!has_ident)
+ Error (NO_IDENT_MSG, NULL);
+
+#ifdef DEBUG
+ printf ("VideoAdaptor section parsed\n");
+#endif
+
+ return ptr;
+}
+
+void
+xf86printVideoAdaptorSection (FILE * cf, XF86ConfVideoAdaptorPtr ptr)
+{
+ XF86ConfVideoPortPtr pptr;
+
+ while (ptr)
+ {
+ fprintf (cf, "Section \"VideoAdaptor\"\n");
+ if (ptr->va_comment)
+ fprintf (cf, "%s", ptr->va_comment);
+ if (ptr->va_identifier)
+ fprintf (cf, "\tIdentifier \"%s\"\n", ptr->va_identifier);
+ if (ptr->va_vendor)
+ fprintf (cf, "\tVendorName \"%s\"\n", ptr->va_vendor);
+ if (ptr->va_board)
+ fprintf (cf, "\tBoardName \"%s\"\n", ptr->va_board);
+ if (ptr->va_busid)
+ fprintf (cf, "\tBusID \"%s\"\n", ptr->va_busid);
+ if (ptr->va_driver)
+ fprintf (cf, "\tDriver \"%s\"\n", ptr->va_driver);
+ xf86printOptionList(cf, ptr->va_option_lst, 1);
+ for (pptr = ptr->va_port_lst; pptr; pptr = pptr->list.next)
+ {
+ fprintf (cf, "\tSubSection \"VideoPort\"\n");
+ if (pptr->vp_comment)
+ fprintf (cf, "%s", pptr->vp_comment);
+ if (pptr->vp_identifier)
+ fprintf (cf, "\t\tIdentifier \"%s\"\n", pptr->vp_identifier);
+ xf86printOptionList(cf, pptr->vp_option_lst, 2);
+ fprintf (cf, "\tEndSubSection\n");
+ }
+ fprintf (cf, "EndSection\n\n");
+ ptr = ptr->list.next;
+ }
+
+}
+
+void
+xf86freeVideoAdaptorList (XF86ConfVideoAdaptorPtr ptr)
+{
+ XF86ConfVideoAdaptorPtr prev;
+
+ while (ptr)
+ {
+ TestFree (ptr->va_identifier);
+ TestFree (ptr->va_vendor);
+ TestFree (ptr->va_board);
+ TestFree (ptr->va_busid);
+ TestFree (ptr->va_driver);
+ TestFree (ptr->va_fwdref);
+ TestFree (ptr->va_comment);
+ xf86freeVideoPortList (ptr->va_port_lst);
+ xf86optionListFree (ptr->va_option_lst);
+ prev = ptr;
+ ptr = ptr->list.next;
+ free (prev);
+ }
+}
+
+XF86ConfVideoAdaptorPtr
+xf86findVideoAdaptor (const char *ident, XF86ConfVideoAdaptorPtr p)
+{
+ while (p)
+ {
+ if (xf86nameCompare (ident, p->va_identifier) == 0)
+ return p;
+
+ p = p->list.next;
+ }
+ return NULL;
+}
diff --git a/xorg-server/hw/xfree86/parser/read.c b/xorg-server/hw/xfree86/parser/read.c
index 4e42b24f0..715626c53 100644
--- a/xorg-server/hw/xfree86/parser/read.c
+++ b/xorg-server/hw/xfree86/parser/read.c
@@ -1,318 +1,318 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec TopLevelTab[] =
-{
- {SECTION, "section"},
- {-1, ""},
-};
-
-#define CLEANUP xf86freeConfig
-
-/*
- * This function resolves name references and reports errors if the named
- * objects cannot be found.
- */
-static int
-xf86validateConfig (XF86ConfigPtr p)
-{
- if (!xf86validateScreen (p))
- return FALSE;
- if (!xf86validateInput (p))
- return FALSE;
- if (!xf86validateLayout (p))
- return FALSE;
-
- return (TRUE);
-}
-
-XF86ConfigPtr
-xf86readConfigFile (void)
-{
- int token;
- XF86ConfigPtr ptr = NULL;
-
- if ((ptr = calloc (1, sizeof (XF86ConfigRec))) == NULL)
- {
- return NULL;
- }
-
- while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
- {
- switch (token)
- {
- case COMMENT:
- ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
- break;
- case SECTION:
- if (xf86getSubToken (&(ptr->conf_comment)) != STRING)
- {
- xf86parseError (QUOTE_MSG, "Section");
- CLEANUP (ptr);
- return (NULL);
- }
- xf86setSection (val.str);
- if (xf86nameCompare (val.str, "files") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_files, xf86parseFilesSection ());
- }
- else if (xf86nameCompare (val.str, "serverflags") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
- }
- else if (xf86nameCompare (val.str, "pointer") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_input_lst, xf86parsePointerSection,
- XF86ConfInputPtr);
- }
- else if (xf86nameCompare (val.str, "videoadaptor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
- XF86ConfVideoAdaptorPtr);
- }
- else if (xf86nameCompare (val.str, "device") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_device_lst, xf86parseDeviceSection,
- XF86ConfDevicePtr);
- }
- else if (xf86nameCompare (val.str, "monitor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection,
- XF86ConfMonitorPtr);
- }
- else if (xf86nameCompare (val.str, "modes") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_modes_lst, xf86parseModesSection,
- XF86ConfModesPtr);
- }
- else if (xf86nameCompare (val.str, "screen") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_screen_lst, xf86parseScreenSection,
- XF86ConfScreenPtr);
- }
- else if (xf86nameCompare(val.str, "inputdevice") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_input_lst, xf86parseInputSection,
- XF86ConfInputPtr);
- }
- else if (xf86nameCompare(val.str, "inputclass") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_inputclass_lst,
- xf86parseInputClassSection,
- XF86ConfInputClassPtr);
- }
- else if (xf86nameCompare (val.str, "module") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_modules, xf86parseModuleSection ());
- }
- else if (xf86nameCompare (val.str, "serverlayout") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection,
- XF86ConfLayoutPtr);
- }
- else if (xf86nameCompare (val.str, "vendor") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection,
- XF86ConfVendorPtr);
- }
- else if (xf86nameCompare (val.str, "dri") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_dri, xf86parseDRISection ());
- }
- else if (xf86nameCompare (val.str, "extensions") == 0)
- {
- free(val.str);
- val.str = NULL;
- HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
- }
- else
- {
- free(val.str);
- val.str = NULL;
- Error (INVALID_SECTION_MSG, xf86tokenString ());
- }
- break;
- default:
- free(val.str);
- val.str = NULL;
- Error (INVALID_KEYWORD_MSG, xf86tokenString ());
- }
- }
-
- if (xf86validateConfig (ptr))
- return (ptr);
- else
- {
- CLEANUP (ptr);
- return (NULL);
- }
-}
-
-#undef CLEANUP
-
-/*
- * adds an item to the end of the linked list. Any record whose first field
- * is a GenericListRec can be cast to this type and used with this function.
- * A pointer to the head of the list is returned to handle the addition of
- * the first item.
- */
-GenericListPtr
-xf86addListItem (GenericListPtr head, GenericListPtr new)
-{
- GenericListPtr p = head;
- GenericListPtr last = NULL;
-
- while (p)
- {
- last = p;
- p = p->next;
- }
-
- if (last)
- {
- last->next = new;
- return (head);
- }
- else
- return (new);
-}
-
-/*
- * Test if one chained list contains the other.
- * In this case both list have the same endpoint (provided they don't loop)
- */
-int
-xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
-{
- GenericListPtr p = list_1;
- GenericListPtr last_1 = NULL, last_2 = NULL;
-
- while (p) {
- last_1 = p;
- p = p->next;
- }
-
- p = list_2;
- while (p) {
- last_2 = p;
- p = p->next;
- }
-
- return (!(last_1 == last_2));
-}
-
-void
-xf86freeConfig (XF86ConfigPtr p)
-{
- if (p == NULL)
- return;
-
- xf86freeFiles (p->conf_files);
- xf86freeModules (p->conf_modules);
- xf86freeFlags (p->conf_flags);
- xf86freeMonitorList (p->conf_monitor_lst);
- xf86freeModesList (p->conf_modes_lst);
- xf86freeVideoAdaptorList (p->conf_videoadaptor_lst);
- xf86freeDeviceList (p->conf_device_lst);
- xf86freeScreenList (p->conf_screen_lst);
- xf86freeLayoutList (p->conf_layout_lst);
- xf86freeInputList (p->conf_input_lst);
- xf86freeVendorList (p->conf_vendor_lst);
- xf86freeDRI (p->conf_dri);
- xf86freeExtensions (p->conf_extensions);
- TestFree(p->conf_comment);
-
- free (p);
-}
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86Parser.h"
+#include "xf86tokens.h"
+#include "Configint.h"
+
+extern LexRec val;
+
+static xf86ConfigSymTabRec TopLevelTab[] =
+{
+ {SECTION, "section"},
+ {-1, ""},
+};
+
+#define CLEANUP xf86freeConfig
+
+/*
+ * This function resolves name references and reports errors if the named
+ * objects cannot be found.
+ */
+static int
+xf86validateConfig (XF86ConfigPtr p)
+{
+ if (!xf86validateScreen (p))
+ return FALSE;
+ if (!xf86validateInput (p))
+ return FALSE;
+ if (!xf86validateLayout (p))
+ return FALSE;
+
+ return TRUE;
+}
+
+XF86ConfigPtr
+xf86readConfigFile (void)
+{
+ int token;
+ XF86ConfigPtr ptr = NULL;
+
+ if ((ptr = calloc (1, sizeof (XF86ConfigRec))) == NULL)
+ {
+ return NULL;
+ }
+
+ while ((token = xf86getToken (TopLevelTab)) != EOF_TOKEN)
+ {
+ switch (token)
+ {
+ case COMMENT:
+ ptr->conf_comment = xf86addComment(ptr->conf_comment, val.str);
+ break;
+ case SECTION:
+ if (xf86getSubToken (&(ptr->conf_comment)) != STRING)
+ {
+ xf86parseError (QUOTE_MSG, "Section");
+ CLEANUP (ptr);
+ return NULL;
+ }
+ xf86setSection (val.str);
+ if (xf86nameCompare (val.str, "files") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_files, xf86parseFilesSection ());
+ }
+ else if (xf86nameCompare (val.str, "serverflags") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
+ }
+ else if (xf86nameCompare (val.str, "pointer") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parsePointerSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare (val.str, "videoadaptor") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_videoadaptor_lst, xf86parseVideoAdaptorSection,
+ XF86ConfVideoAdaptorPtr);
+ }
+ else if (xf86nameCompare (val.str, "device") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_device_lst, xf86parseDeviceSection,
+ XF86ConfDevicePtr);
+ }
+ else if (xf86nameCompare (val.str, "monitor") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_monitor_lst, xf86parseMonitorSection,
+ XF86ConfMonitorPtr);
+ }
+ else if (xf86nameCompare (val.str, "modes") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_modes_lst, xf86parseModesSection,
+ XF86ConfModesPtr);
+ }
+ else if (xf86nameCompare (val.str, "screen") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_screen_lst, xf86parseScreenSection,
+ XF86ConfScreenPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputdevice") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_input_lst, xf86parseInputSection,
+ XF86ConfInputPtr);
+ }
+ else if (xf86nameCompare(val.str, "inputclass") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_inputclass_lst,
+ xf86parseInputClassSection,
+ XF86ConfInputClassPtr);
+ }
+ else if (xf86nameCompare (val.str, "module") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_modules, xf86parseModuleSection ());
+ }
+ else if (xf86nameCompare (val.str, "serverlayout") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_layout_lst, xf86parseLayoutSection,
+ XF86ConfLayoutPtr);
+ }
+ else if (xf86nameCompare (val.str, "vendor") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_LIST (conf_vendor_lst, xf86parseVendorSection,
+ XF86ConfVendorPtr);
+ }
+ else if (xf86nameCompare (val.str, "dri") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_dri, xf86parseDRISection ());
+ }
+ else if (xf86nameCompare (val.str, "extensions") == 0)
+ {
+ free(val.str);
+ val.str = NULL;
+ HANDLE_RETURN (conf_extensions, xf86parseExtensionsSection ());
+ }
+ else
+ {
+ free(val.str);
+ val.str = NULL;
+ Error (INVALID_SECTION_MSG, xf86tokenString ());
+ }
+ break;
+ default:
+ free(val.str);
+ val.str = NULL;
+ Error (INVALID_KEYWORD_MSG, xf86tokenString ());
+ }
+ }
+
+ if (xf86validateConfig (ptr))
+ return ptr;
+ else
+ {
+ CLEANUP (ptr);
+ return NULL;
+ }
+}
+
+#undef CLEANUP
+
+/*
+ * adds an item to the end of the linked list. Any record whose first field
+ * is a GenericListRec can be cast to this type and used with this function.
+ * A pointer to the head of the list is returned to handle the addition of
+ * the first item.
+ */
+GenericListPtr
+xf86addListItem (GenericListPtr head, GenericListPtr new)
+{
+ GenericListPtr p = head;
+ GenericListPtr last = NULL;
+
+ while (p)
+ {
+ last = p;
+ p = p->next;
+ }
+
+ if (last)
+ {
+ last->next = new;
+ return head;
+ }
+ else
+ return new;
+}
+
+/*
+ * Test if one chained list contains the other.
+ * In this case both list have the same endpoint (provided they don't loop)
+ */
+int
+xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2)
+{
+ GenericListPtr p = list_1;
+ GenericListPtr last_1 = NULL, last_2 = NULL;
+
+ while (p) {
+ last_1 = p;
+ p = p->next;
+ }
+
+ p = list_2;
+ while (p) {
+ last_2 = p;
+ p = p->next;
+ }
+
+ return (!(last_1 == last_2));
+}
+
+void
+xf86freeConfig (XF86ConfigPtr p)
+{
+ if (p == NULL)
+ return;
+
+ xf86freeFiles (p->conf_files);
+ xf86freeModules (p->conf_modules);
+ xf86freeFlags (p->conf_flags);
+ xf86freeMonitorList (p->conf_monitor_lst);
+ xf86freeModesList (p->conf_modes_lst);
+ xf86freeVideoAdaptorList (p->conf_videoadaptor_lst);
+ xf86freeDeviceList (p->conf_device_lst);
+ xf86freeScreenList (p->conf_screen_lst);
+ xf86freeLayoutList (p->conf_layout_lst);
+ xf86freeInputList (p->conf_input_lst);
+ xf86freeVendorList (p->conf_vendor_lst);
+ xf86freeDRI (p->conf_dri);
+ xf86freeExtensions (p->conf_extensions);
+ TestFree(p->conf_comment);
+
+ free (p);
+}
diff --git a/xorg-server/hw/xfree86/parser/scan.c b/xorg-server/hw/xfree86/parser/scan.c
index 06710d55a..99e1288a5 100644
--- a/xorg-server/hw/xfree86/parser/scan.c
+++ b/xorg-server/hw/xfree86/parser/scan.c
@@ -1,1247 +1,1232 @@
-/*
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <X11/Xdefs.h>
-#include <X11/Xfuncproto.h>
-
-#if defined(_POSIX_SOURCE)
-#include <limits.h>
-#else
-#define _POSIX_SOURCE
-#include <limits.h>
-#undef _POSIX_SOURCE
-#endif /* _POSIX_SOURCE */
-
-#if !defined(PATH_MAX)
-#if defined(MAXPATHLEN)
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif /* MAXPATHLEN */
-#endif /* !PATH_MAX */
-
-#if !defined(MAXHOSTNAMELEN)
-#define MAXHOSTNAMELEN 32
-#endif /* !MAXHOSTNAMELEN */
-
-#include "Configint.h"
-#include "xf86tokens.h"
-
-#define CONFIG_BUF_LEN 1024
-#define CONFIG_MAX_FILES 64
-
-static int StringToToken (char *, xf86ConfigSymTabRec *);
-
-static struct {
- FILE *file;
- char *path;
-} configFiles[CONFIG_MAX_FILES];
-static const char **builtinConfig = NULL;
-static int builtinIndex = 0;
-static int configPos = 0; /* current readers position */
-static int configLineNo = 0; /* linenumber */
-static char *configBuf, *configRBuf; /* buffer for lines */
-static char *configPath; /* path to config file */
-static char *configDirPath; /* path to config dir */
-static char *configSection = NULL; /* name of current section being parsed */
-static int numFiles = 0; /* number of config files */
-static int curFileIndex = 0; /* index of current config file */
-static int pushToken = LOCK_TOKEN;
-static int eol_seen = 0; /* private state to handle comments */
-LexRec val;
-
-/*
- * xf86strToUL --
- *
- * A portable, but restricted, version of strtoul(). It only understands
- * hex, octal, and decimal. But it's good enough for our needs.
- */
-static unsigned int
-xf86strToUL (char *str)
-{
- int base = 10;
- char *p = str;
- unsigned int tot = 0;
-
- if (*p == '0')
- {
- p++;
- if ((*p == 'x') || (*p == 'X'))
- {
- p++;
- base = 16;
- }
- else
- base = 8;
- }
- while (*p)
- {
- if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9')))
- {
- tot = tot * base + (*p - '0');
- }
- else if ((base == 16) && (*p >= 'a') && (*p <= 'f'))
- {
- tot = tot * base + 10 + (*p - 'a');
- }
- else if ((base == 16) && (*p >= 'A') && (*p <= 'F'))
- {
- tot = tot * base + 10 + (*p - 'A');
- }
- else
- {
- return (tot);
- }
- p++;
- }
- return (tot);
-}
-
-/*
- * xf86getNextLine --
- *
- * read from the configFiles FILE stream until we encounter a new
- * line; this is effectively just a big wrapper for fgets(3).
- *
- * xf86getToken() assumes that we will read up to the next
- * newline; we need to grow configBuf and configRBuf as needed to
- * support that.
- */
-
-static char*
-xf86getNextLine(void)
-{
- static int configBufLen = CONFIG_BUF_LEN;
- char *tmpConfigBuf, *tmpConfigRBuf;
- int c, i, pos = 0, eolFound = 0;
- char *ret = NULL;
-
- /*
- * reallocate the string if it was grown last time (i.e., is no
- * longer CONFIG_BUF_LEN); we malloc the new strings first, so
- * that if either of the mallocs fail, we can fall back on the
- * existing buffer allocations
- */
-
- if (configBufLen != CONFIG_BUF_LEN) {
-
- tmpConfigBuf = malloc(CONFIG_BUF_LEN);
- tmpConfigRBuf = malloc(CONFIG_BUF_LEN);
-
- if (!tmpConfigBuf || !tmpConfigRBuf) {
-
- /*
- * at least one of the mallocs failed; keep the old buffers
- * and free any partial allocations
- */
-
- free(tmpConfigBuf);
- free(tmpConfigRBuf);
-
- } else {
-
- /*
- * malloc succeeded; free the old buffers and use the new
- * buffers
- */
-
- configBufLen = CONFIG_BUF_LEN;
-
- free(configBuf);
- free(configRBuf);
-
- configBuf = tmpConfigBuf;
- configRBuf = tmpConfigRBuf;
- }
- }
-
- /* read in another block of chars */
-
- do {
- ret = fgets(configBuf + pos, configBufLen - pos - 1,
- configFiles[curFileIndex].file);
-
- if (!ret) {
- /*
- * if the file doesn't end in a newline, add one
- * and trigger another read
- */
- if (pos != 0) {
- strcpy(&configBuf[pos], "\n");
- ret = configBuf;
- } else
- break;
- }
-
- /* search for EOL in the new block of chars */
-
- for (i = pos; i < (configBufLen - 1); i++) {
- c = configBuf[i];
-
- if (c == '\0') break;
-
- if ((c == '\n') || (c == '\r')) {
- eolFound = 1;
- break;
- }
- }
-
- /*
- * if we didn't find EOL, then grow the string and
- * read in more
- */
-
- if (!eolFound) {
-
- tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN);
- tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN);
-
- if (!tmpConfigBuf || !tmpConfigRBuf) {
-
- /*
- * at least one of the reallocations failed; use the
- * new allocation that succeeded, but we have to
- * fallback to the previous configBufLen size and use
- * the string we have, even though we don't have an
- * EOL
- */
-
- if (tmpConfigBuf) configBuf = tmpConfigBuf;
- if (tmpConfigRBuf) configRBuf = tmpConfigRBuf;
-
- break;
-
- } else {
-
- /* reallocation succeeded */
-
- configBuf = tmpConfigBuf;
- configRBuf = tmpConfigRBuf;
- pos = i;
- configBufLen += CONFIG_BUF_LEN;
- }
- }
-
- } while (!eolFound);
-
- return (ret);
-}
-
-/*
- * xf86getToken --
- * Read next Token from the config file. Handle the global variable
- * pushToken.
- */
-int
-xf86getToken (xf86ConfigSymTabRec * tab)
-{
- int c, i;
-
- /*
- * First check whether pushToken has a different value than LOCK_TOKEN.
- * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
- * oth * case the next token must be read from the input.
- */
- if (pushToken == EOF_TOKEN)
- return (EOF_TOKEN);
- else if (pushToken == LOCK_TOKEN)
- {
- /*
- * eol_seen is only set for the first token after a newline.
- */
- eol_seen = 0;
-
- c = configBuf[configPos];
-
- /*
- * Get start of next Token. EOF is handled,
- * whitespaces are skipped.
- */
-
-again:
- if (!c)
- {
- char *ret;
- if (numFiles > 0)
- ret = xf86getNextLine();
- else {
- if (builtinConfig[builtinIndex] == NULL)
- ret = NULL;
- else {
- ret = strncpy(configBuf, builtinConfig[builtinIndex],
- CONFIG_BUF_LEN);
- builtinIndex++;
- }
- }
- if (ret == NULL)
- {
- /*
- * if necessary, move to the next file and
- * read the first line
- */
- if (curFileIndex + 1 < numFiles) {
- curFileIndex++;
- configLineNo = 0;
- goto again;
- }
- else
- return (pushToken = EOF_TOKEN);
- }
- configLineNo++;
- configPos = 0;
- eol_seen = 1;
- }
-
- i = 0;
- for (;;) {
- c = configBuf[configPos++];
- configRBuf[i++] = c;
- switch (c) {
- case ' ':
- case '\t':
- case '\r':
- continue;
- case '\n':
- i = 0;
- continue;
- }
- break;
- }
- if (c == '\0')
- goto again;
-
- if (c == '#')
- {
- do
- {
- configRBuf[i++] = (c = configBuf[configPos++]);
- }
- while ((c != '\n') && (c != '\r') && (c != '\0'));
- configRBuf[i] = '\0';
- /* XXX no private copy.
- * Use xf86addComment when setting a comment.
- */
- val.str = configRBuf;
- return (COMMENT);
- }
-
- /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */
- else if ((c == ',') && !isalpha (configBuf[configPos]))
- {
- return COMMA;
- }
- else if ((c == '-') && !isalpha (configBuf[configPos]))
- {
- return DASH;
- }
-
- /*
- * Numbers are returned immediately ...
- */
- if (isdigit (c))
- {
- int base;
-
- if (c == '0')
- if ((configBuf[configPos] == 'x') ||
- (configBuf[configPos] == 'X'))
- {
- base = 16;
- val.numType = PARSE_HEX;
- }
- else
- {
- base = 8;
- val.numType = PARSE_OCTAL;
- }
- else
- {
- base = 10;
- val.numType = PARSE_DECIMAL;
- }
-
- configRBuf[0] = c;
- i = 1;
- while (isdigit (c = configBuf[configPos++]) ||
- (c == '.') || (c == 'x') || (c == 'X') ||
- ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
- ((c >= 'A') && (c <= 'F')))))
- configRBuf[i++] = c;
- configPos--; /* GJA -- one too far */
- configRBuf[i] = '\0';
- val.num = xf86strToUL (configRBuf);
- val.realnum = atof (configRBuf);
- return (NUMBER);
- }
-
- /*
- * All Strings START with a \" ...
- */
- else if (c == '\"')
- {
- i = -1;
- do
- {
- configRBuf[++i] = (c = configBuf[configPos++]);
- }
- while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
- configRBuf[i] = '\0';
- val.str = malloc (strlen (configRBuf) + 1);
- strcpy (val.str, configRBuf); /* private copy ! */
- return (STRING);
- }
-
- /*
- * ... and now we MUST have a valid token. The search is
- * handled later along with the pushed tokens.
- */
- else
- {
- configRBuf[0] = c;
- i = 0;
- do
- {
- configRBuf[++i] = (c = configBuf[configPos++]);
- }
- while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#'));
- --configPos;
- configRBuf[i] = '\0';
- i = 0;
- }
-
- }
- else
- {
-
- /*
- * Here we deal with pushed tokens. Reinitialize pushToken again. If
- * the pushed token was NUMBER || STRING return them again ...
- */
- int temp = pushToken;
- pushToken = LOCK_TOKEN;
-
- if (temp == COMMA || temp == DASH)
- return (temp);
- if (temp == NUMBER || temp == STRING)
- return (temp);
- }
-
- /*
- * Joop, at last we have to lookup the token ...
- */
- if (tab)
- {
- i = 0;
- while (tab[i].token != -1)
- if (xf86nameCompare (configRBuf, tab[i].name) == 0)
- return (tab[i].token);
- else
- i++;
- }
-
- return (ERROR_TOKEN); /* Error catcher */
-}
-
-int
-xf86getSubToken (char **comment)
-{
- int token;
-
- for (;;) {
- token = xf86getToken(NULL);
- if (token == COMMENT) {
- if (comment)
- *comment = xf86addComment(*comment, val.str);
- }
- else
- return (token);
- }
- /*NOTREACHED*/
-}
-
-int
-xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab)
-{
- int token;
-
- for (;;) {
- token = xf86getToken(tab);
- if (token == COMMENT) {
- if (comment)
- *comment = xf86addComment(*comment, val.str);
- }
- else
- return (token);
- }
- /*NOTREACHED*/
-}
-
-void
-xf86unGetToken (int token)
-{
- pushToken = token;
-}
-
-char *
-xf86tokenString (void)
-{
- return configRBuf;
-}
-
-int
-xf86pathIsAbsolute(const char *path)
-{
- if (path && path[0] == '/')
- return 1;
- return 0;
-}
-
-/* A path is "safe" if it is relative and if it contains no ".." elements. */
-int
-xf86pathIsSafe(const char *path)
-{
- if (xf86pathIsAbsolute(path))
- return 0;
-
- /* Compare with ".." */
- if (!strcmp(path, ".."))
- return 0;
-
- /* Look for leading "../" */
- if (!strncmp(path, "../", 3))
- return 0;
-
- /* Look for trailing "/.." */
- if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/.."))
- return 0;
-
- /* Look for "/../" */
- if (strstr(path, "/../"))
- return 0;
-
- return 1;
-}
-
-/*
- * This function substitutes the following escape sequences:
- *
- * %A cmdline argument as an absolute path (must be absolute to match)
- * %R cmdline argument as a relative path
- * %S cmdline argument as a "safe" path (relative, and no ".." elements)
- * %X default config file name ("xorg.conf")
- * %H hostname
- * %E config file environment ($XORGCONFIG) as an absolute path
- * %F config file environment ($XORGCONFIG) as a relative path
- * %G config file environment ($XORGCONFIG) as a safe path
- * %P projroot
- * %C sysconfdir
- * %D datadir
- * %M major version number
- * %% %
- */
-
-#ifndef XCONFIGFILE
-#define XCONFIGFILE "xorg.conf"
-#endif
-#ifndef XCONFIGDIR
-#define XCONFIGDIR "xorg.conf.d"
-#endif
-#ifndef XCONFIGSUFFIX
-#define XCONFIGSUFFIX ".conf"
-#endif
-#ifndef PROJECTROOT
-#define PROJECTROOT "/usr/X11R6"
-#endif
-#ifndef SYSCONFDIR
-#define SYSCONFDIR PROJECTROOT "/etc"
-#endif
-#ifndef DATADIR
-#define DATADIR PROJECTROOT "/share"
-#endif
-#ifndef XCONFENV
-#define XCONFENV "XORGCONFIG"
-#endif
-#define XFREE86CFGFILE "XF86Config"
-#ifndef XF86_VERSION_MAJOR
-#ifdef XVERSION
-#if XVERSION > 40000000
-#define XF86_VERSION_MAJOR (XVERSION / 10000000)
-#else
-#define XF86_VERSION_MAJOR (XVERSION / 1000)
-#endif
-#else
-#define XF86_VERSION_MAJOR 4
-#endif
-#endif
-
-#define BAIL_OUT do { \
- free(result); \
- return NULL; \
- } while (0)
-
-#define CHECK_LENGTH do { \
- if (l > PATH_MAX) { \
- BAIL_OUT; \
- } \
- } while (0)
-
-#define APPEND_STR(s) do { \
- if (strlen(s) + l > PATH_MAX) { \
- BAIL_OUT; \
- } else { \
- strcpy(result + l, s); \
- l += strlen(s); \
- } \
- } while (0)
-
-static char *
-DoSubstitution(const char *template, const char *cmdline, const char *projroot,
- int *cmdlineUsed, int *envUsed,
- const char *XConfigFile)
-{
- char *result;
- int i, l;
- static const char *env = NULL;
- static char *hostname = NULL;
- static char majorvers[3] = "";
-
- if (!template)
- return NULL;
-
- if (cmdlineUsed)
- *cmdlineUsed = 0;
- if (envUsed)
- *envUsed = 0;
-
- result = malloc(PATH_MAX + 1);
- l = 0;
- for (i = 0; template[i]; i++) {
- if (template[i] != '%') {
- result[l++] = template[i];
- CHECK_LENGTH;
- } else {
- switch (template[++i]) {
- case 'A':
- if (cmdline && xf86pathIsAbsolute(cmdline)) {
- APPEND_STR(cmdline);
- if (cmdlineUsed)
- *cmdlineUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'R':
- if (cmdline && !xf86pathIsAbsolute(cmdline)) {
- APPEND_STR(cmdline);
- if (cmdlineUsed)
- *cmdlineUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'S':
- if (cmdline && xf86pathIsSafe(cmdline)) {
- APPEND_STR(cmdline);
- if (cmdlineUsed)
- *cmdlineUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'X':
- APPEND_STR(XConfigFile);
- break;
- case 'H':
- if (!hostname) {
- if ((hostname = malloc(MAXHOSTNAMELEN + 1))) {
- if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
- hostname[MAXHOSTNAMELEN] = '\0';
- } else {
- free(hostname);
- hostname = NULL;
- }
- }
- }
- if (hostname)
- APPEND_STR(hostname);
- break;
- case 'E':
- if (!env)
- env = getenv(XCONFENV);
- if (env && xf86pathIsAbsolute(env)) {
- APPEND_STR(env);
- if (envUsed)
- *envUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'F':
- if (!env)
- env = getenv(XCONFENV);
- if (env && !xf86pathIsAbsolute(env)) {
- APPEND_STR(env);
- if (envUsed)
- *envUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'G':
- if (!env)
- env = getenv(XCONFENV);
- if (env && xf86pathIsSafe(env)) {
- APPEND_STR(env);
- if (envUsed)
- *envUsed = 1;
- } else
- BAIL_OUT;
- break;
- case 'P':
- if (projroot && xf86pathIsAbsolute(projroot))
- APPEND_STR(projroot);
- else
- BAIL_OUT;
- break;
- case 'C':
- APPEND_STR(SYSCONFDIR);
- break;
- case 'D':
- APPEND_STR(DATADIR);
- break;
- case 'M':
- if (!majorvers[0]) {
- if (XF86_VERSION_MAJOR < 0 || XF86_VERSION_MAJOR > 99) {
- fprintf(stderr, "XF86_VERSION_MAJOR is out of range\n");
- BAIL_OUT;
- } else
- sprintf(majorvers, "%d", XF86_VERSION_MAJOR);
- }
- APPEND_STR(majorvers);
- break;
- case '%':
- result[l++] = '%';
- CHECK_LENGTH;
- break;
- default:
- fprintf(stderr, "invalid escape %%%c found in path template\n",
- template[i]);
- BAIL_OUT;
- break;
- }
- }
- }
-#ifdef DEBUG
- fprintf(stderr, "Converted `%s' to `%s'\n", template, result);
-#endif
- return result;
-}
-
-/*
- * Given some searching parameters, locate and open the xorg config file.
- */
-static char *
-OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
- const char *confname)
-{
- char *filepath = NULL;
- char *pathcopy;
- const char *template;
- int cmdlineUsed = 0;
- FILE *file = NULL;
-
- pathcopy = strdup(path);
- for (template = strtok(pathcopy, ","); template && !file;
- template = strtok(NULL, ",")) {
- filepath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL, confname);
- if (!filepath)
- continue;
- if (cmdline && !cmdlineUsed) {
- free(filepath);
- filepath = NULL;
- continue;
- }
- file = fopen(filepath, "r");
- if (!file) {
- free(filepath);
- filepath = NULL;
- }
- }
-
- if (file) {
- configFiles[numFiles].file = file;
- configFiles[numFiles].path = strdup(filepath);
- numFiles++;
- }
- return filepath;
-}
-
-/*
- * Match non-hidden files in the xorg config directory with a .conf
- * suffix. This filter is passed to scandir(3).
- */
-static int
-ConfigFilter(const struct dirent *de)
-{
- const char *name = de->d_name;
- size_t len;
- size_t suflen = strlen(XCONFIGSUFFIX);
-
- if (!name || name[0] == '.')
- return 0;
- len = strlen(name);
- if(len <= suflen)
- return 0;
- if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
- return 0;
- return 1;
-}
-
-static Bool
-AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
-{
- int i;
- Bool openedFile = FALSE;
- Bool warnOnce = FALSE;
-
- for (i = 0; i < num; i++) {
- char *path;
- FILE *file;
-
- if (numFiles >= CONFIG_MAX_FILES) {
- if (!warnOnce) {
- ErrorF("Maximum number of configuration "
- "files opened\n");
- warnOnce = TRUE;
- }
- free(list[i]);
- continue;
- }
-
- path = malloc(PATH_MAX + 1);
- snprintf(path, PATH_MAX + 1, "%s/%s", dirpath,
- list[i]->d_name);
- free(list[i]);
- file = fopen(path, "r");
- if (!file) {
- free(path);
- continue;
- }
- openedFile = TRUE;
-
- configFiles[numFiles].file = file;
- configFiles[numFiles].path = path;
- numFiles++;
- }
-
- return openedFile;
-}
-
-/*
- * Given some searching parameters, locate and open the xorg config
- * directory. The directory does not need to contain config files.
- */
-static char *
-OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
- const char *confname)
-{
- char *dirpath, *pathcopy;
- const char *template;
- Bool found = FALSE;
- int cmdlineUsed = 0;
-
- pathcopy = strdup(path);
- for (template = strtok(pathcopy, ","); template && !found;
- template = strtok(NULL, ",")) {
- struct dirent **list = NULL;
- int num;
-
- dirpath = DoSubstitution(template, cmdline, projroot,
- &cmdlineUsed, NULL, confname);
- if (!dirpath)
- continue;
- if (cmdline && !cmdlineUsed) {
- free(dirpath);
- dirpath = NULL;
- continue;
- }
-
- /* match files named *.conf */
- num = scandir(dirpath, &list, ConfigFilter, alphasort);
- found = AddConfigDirFiles(dirpath, list, num);
- if (!found) {
- free(dirpath);
- dirpath = NULL;
- if (list)
- free(list);
- }
- }
-
- return dirpath;
-}
-
-/*
- * xf86initConfigFiles -- Setup global variables and buffers.
- */
-void
-xf86initConfigFiles(void)
-{
- curFileIndex = 0;
- configPos = 0;
- configLineNo = 0;
- pushToken = LOCK_TOKEN;
-
- configBuf = malloc(CONFIG_BUF_LEN);
- configRBuf = malloc(CONFIG_BUF_LEN);
- configBuf[0] = '\0'; /* sanity ... */
-}
-
-/*
- * xf86openConfigFile --
- *
- * This function take a config file search path (optional), a command-line
- * specified file name (optional) and the ProjectRoot path (optional) and
- * locates and opens a config file based on that information. If a
- * command-line file name is specified, then this function fails if none
- * of the located files.
- *
- * The return value is a pointer to the actual name of the file that was
- * opened. When no file is found, the return value is NULL.
- *
- * The escape sequences allowed in the search path are defined above.
- *
- */
-
-#ifndef DEFAULT_CONF_PATH
-#define DEFAULT_CONF_PATH "/etc/X11/%S," \
- "%P/etc/X11/%S," \
- "/etc/X11/%G," \
- "%P/etc/X11/%G," \
- "/etc/X11/%X-%M," \
- "/etc/X11/%X," \
- "/etc/%X," \
- "%P/etc/X11/%X.%H," \
- "%P/etc/X11/%X-%M," \
- "%P/etc/X11/%X," \
- "%P/lib/X11/%X.%H," \
- "%P/lib/X11/%X-%M," \
- "%P/lib/X11/%X"
-#endif
-
-const char *
-xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
-{
- if (!path || !path[0])
- path = DEFAULT_CONF_PATH;
- if (!projroot || !projroot[0])
- projroot = PROJECTROOT;
-
- /* Search for a config file or a fallback */
- configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
- if (!configPath)
- configPath = OpenConfigFile(path, cmdline, projroot,
- XFREE86CFGFILE);
- return configPath;
-}
-
-/*
- * xf86openConfigDirFiles --
- *
- * This function take a config directory search path (optional), a
- * command-line specified directory name (optional) and the ProjectRoot path
- * (optional) and locates and opens a config directory based on that
- * information. If a command-line name is specified, then this function
- * fails if it is not found.
- *
- * The return value is a pointer to the actual name of the direcoty that was
- * opened. When no directory is found, the return value is NULL.
- *
- * The escape sequences allowed in the search path are defined above.
- *
- */
-const char *
-xf86openConfigDirFiles(const char *path, const char *cmdline,
- const char *projroot)
-{
- if (!path || !path[0])
- path = DEFAULT_CONF_PATH;
- if (!projroot || !projroot[0])
- projroot = PROJECTROOT;
-
- /* Search for the multiconf directory */
- configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
- return configDirPath;
-}
-
-void
-xf86closeConfigFile (void)
-{
- int i;
-
- free (configPath);
- configPath = NULL;
- free (configDirPath);
- configDirPath = NULL;
- free (configRBuf);
- configRBuf = NULL;
- free (configBuf);
- configBuf = NULL;
-
- if (numFiles == 0) {
- builtinConfig = NULL;
- builtinIndex = 0;
- }
- for (i = 0; i < numFiles; i++) {
- fclose(configFiles[i].file);
- configFiles[i].file = NULL;
- free(configFiles[i].path);
- configFiles[i].path = NULL;
- }
- numFiles = 0;
-}
-
-void
-xf86setBuiltinConfig(const char *config[])
-{
- builtinConfig = config;
-}
-
-void
-xf86parseError (char *format,...)
-{
- va_list ap;
- char *filename = numFiles ? configFiles[curFileIndex].path :
- "<builtin configuration>";
-
- ErrorF ("Parse error on line %d of section %s in file %s\n\t",
- configLineNo, configSection, filename);
- va_start (ap, format);
- VErrorF (format, ap);
- va_end (ap);
-
- ErrorF ("\n");
-}
-
-void
-xf86validationError (char *format,...)
-{
- va_list ap;
- char *filename = numFiles ? configFiles[curFileIndex].path :
- "<builtin configuration>";
-
- ErrorF ("Data incomplete in file %s\n\t", filename);
- va_start (ap, format);
- VErrorF (format, ap);
- va_end (ap);
-
- ErrorF ("\n");
-}
-
-void
-xf86setSection (char *section)
-{
- if (configSection)
- free(configSection);
- configSection = malloc(strlen (section) + 1);
- strcpy (configSection, section);
-}
-
-/*
- * xf86getToken --
- * Lookup a string if it is actually a token in disguise.
- */
-int
-xf86getStringToken (xf86ConfigSymTabRec * tab)
-{
- return StringToToken (val.str, tab);
-}
-
-static int
-StringToToken (char *str, xf86ConfigSymTabRec * tab)
-{
- int i;
-
- for (i = 0; tab[i].token != -1; i++)
- {
- if (!xf86nameCompare (tab[i].name, str))
- return tab[i].token;
- }
- return (ERROR_TOKEN);
-}
-
-
-/*
- * Compare two names. The characters '_', ' ', and '\t' are ignored
- * in the comparison.
- */
-int
-xf86nameCompare (const char *s1, const char *s2)
-{
- char c1, c2;
-
- if (!s1 || *s1 == 0) {
- if (!s2 || *s2 == 0)
- return (0);
- else
- return (1);
- }
-
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
- while (c1 == c2)
- {
- if (c1 == '\0')
- return (0);
- s1++;
- s2++;
- while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
- s1++;
- while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
- s2++;
- c1 = (isupper (*s1) ? tolower (*s1) : *s1);
- c2 = (isupper (*s2) ? tolower (*s2) : *s2);
- }
- return (c1 - c2);
-}
-
-char *
-xf86addComment(char *cur, char *add)
-{
- char *str;
- int len, curlen, iscomment, hasnewline = 0, endnewline;
-
- if (add == NULL || add[0] == '\0')
- return (cur);
-
- if (cur) {
- curlen = strlen(cur);
- if (curlen)
- hasnewline = cur[curlen - 1] == '\n';
- eol_seen = 0;
- }
- else
- curlen = 0;
-
- str = add;
- iscomment = 0;
- while (*str) {
- if (*str != ' ' && *str != '\t')
- break;
- ++str;
- }
- iscomment = (*str == '#');
-
- len = strlen(add);
- endnewline = add[len - 1] == '\n';
- len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen;
-
- if ((str = realloc(cur, len + curlen)) == NULL)
- return (cur);
-
- cur = str;
-
- if (eol_seen || (curlen && !hasnewline))
- cur[curlen++] = '\n';
- if (!iscomment)
- cur[curlen++] = '#';
- strcpy(cur + curlen, add);
- if (!endnewline)
- strcat(cur, "\n");
-
- return (cur);
-}
-
-Bool
-xf86getBoolValue(Bool *val, const char *str)
-{
- if (!val || !str)
- return FALSE;
- if (*str == '\0') {
- *val = TRUE;
- } else {
- if (xf86nameCompare(str, "1") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "on") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "true") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "yes") == 0)
- *val = TRUE;
- else if (xf86nameCompare(str, "0") == 0)
- *val = FALSE;
- else if (xf86nameCompare(str, "off") == 0)
- *val = FALSE;
- else if (xf86nameCompare(str, "false") == 0)
- *val = FALSE;
- else if (xf86nameCompare(str, "no") == 0)
- *val = FALSE;
- else
- return FALSE;
- }
- return TRUE;
-}
+/*
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/* View/edit this file with tab stops set to 4 */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <X11/Xdefs.h>
+#include <X11/Xfuncproto.h>
+
+#if defined(_POSIX_SOURCE)
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif /* _POSIX_SOURCE */
+
+#if !defined(PATH_MAX)
+#if defined(MAXPATHLEN)
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif /* MAXPATHLEN */
+#endif /* !PATH_MAX */
+
+#if !defined(MAXHOSTNAMELEN)
+#define MAXHOSTNAMELEN 32
+#endif /* !MAXHOSTNAMELEN */
+
+#include "Configint.h"
+#include "xf86tokens.h"
+
+#define CONFIG_BUF_LEN 1024
+#define CONFIG_MAX_FILES 64
+
+static int StringToToken (char *, xf86ConfigSymTabRec *);
+
+static struct {
+ FILE *file;
+ char *path;
+} configFiles[CONFIG_MAX_FILES];
+static const char **builtinConfig = NULL;
+static int builtinIndex = 0;
+static int configPos = 0; /* current readers position */
+static int configLineNo = 0; /* linenumber */
+static char *configBuf, *configRBuf; /* buffer for lines */
+static char *configPath; /* path to config file */
+static char *configDirPath; /* path to config dir */
+static char *configSection = NULL; /* name of current section being parsed */
+static int numFiles = 0; /* number of config files */
+static int curFileIndex = 0; /* index of current config file */
+static int pushToken = LOCK_TOKEN;
+static int eol_seen = 0; /* private state to handle comments */
+LexRec val;
+
+/*
+ * xf86strToUL --
+ *
+ * A portable, but restricted, version of strtoul(). It only understands
+ * hex, octal, and decimal. But it's good enough for our needs.
+ */
+static unsigned int
+xf86strToUL (char *str)
+{
+ int base = 10;
+ char *p = str;
+ unsigned int tot = 0;
+
+ if (*p == '0')
+ {
+ p++;
+ if ((*p == 'x') || (*p == 'X'))
+ {
+ p++;
+ base = 16;
+ }
+ else
+ base = 8;
+ }
+ while (*p)
+ {
+ if ((*p >= '0') && (*p <= ((base == 8) ? '7' : '9')))
+ {
+ tot = tot * base + (*p - '0');
+ }
+ else if ((base == 16) && (*p >= 'a') && (*p <= 'f'))
+ {
+ tot = tot * base + 10 + (*p - 'a');
+ }
+ else if ((base == 16) && (*p >= 'A') && (*p <= 'F'))
+ {
+ tot = tot * base + 10 + (*p - 'A');
+ }
+ else
+ {
+ return tot;
+ }
+ p++;
+ }
+ return tot;
+}
+
+/*
+ * xf86getNextLine --
+ *
+ * read from the configFiles FILE stream until we encounter a new
+ * line; this is effectively just a big wrapper for fgets(3).
+ *
+ * xf86getToken() assumes that we will read up to the next
+ * newline; we need to grow configBuf and configRBuf as needed to
+ * support that.
+ */
+
+static char*
+xf86getNextLine(void)
+{
+ static int configBufLen = CONFIG_BUF_LEN;
+ char *tmpConfigBuf, *tmpConfigRBuf;
+ int c, i, pos = 0, eolFound = 0;
+ char *ret = NULL;
+
+ /*
+ * reallocate the string if it was grown last time (i.e., is no
+ * longer CONFIG_BUF_LEN); we malloc the new strings first, so
+ * that if either of the mallocs fail, we can fall back on the
+ * existing buffer allocations
+ */
+
+ if (configBufLen != CONFIG_BUF_LEN) {
+
+ tmpConfigBuf = malloc(CONFIG_BUF_LEN);
+ tmpConfigRBuf = malloc(CONFIG_BUF_LEN);
+
+ if (!tmpConfigBuf || !tmpConfigRBuf) {
+
+ /*
+ * at least one of the mallocs failed; keep the old buffers
+ * and free any partial allocations
+ */
+
+ free(tmpConfigBuf);
+ free(tmpConfigRBuf);
+
+ } else {
+
+ /*
+ * malloc succeeded; free the old buffers and use the new
+ * buffers
+ */
+
+ configBufLen = CONFIG_BUF_LEN;
+
+ free(configBuf);
+ free(configRBuf);
+
+ configBuf = tmpConfigBuf;
+ configRBuf = tmpConfigRBuf;
+ }
+ }
+
+ /* read in another block of chars */
+
+ do {
+ ret = fgets(configBuf + pos, configBufLen - pos - 1,
+ configFiles[curFileIndex].file);
+
+ if (!ret) {
+ /*
+ * if the file doesn't end in a newline, add one
+ * and trigger another read
+ */
+ if (pos != 0) {
+ strcpy(&configBuf[pos], "\n");
+ ret = configBuf;
+ } else
+ break;
+ }
+
+ /* search for EOL in the new block of chars */
+
+ for (i = pos; i < (configBufLen - 1); i++) {
+ c = configBuf[i];
+
+ if (c == '\0') break;
+
+ if ((c == '\n') || (c == '\r')) {
+ eolFound = 1;
+ break;
+ }
+ }
+
+ /*
+ * if we didn't find EOL, then grow the string and
+ * read in more
+ */
+
+ if (!eolFound) {
+
+ tmpConfigBuf = realloc(configBuf, configBufLen + CONFIG_BUF_LEN);
+ tmpConfigRBuf = realloc(configRBuf, configBufLen + CONFIG_BUF_LEN);
+
+ if (!tmpConfigBuf || !tmpConfigRBuf) {
+
+ /*
+ * at least one of the reallocations failed; use the
+ * new allocation that succeeded, but we have to
+ * fallback to the previous configBufLen size and use
+ * the string we have, even though we don't have an
+ * EOL
+ */
+
+ if (tmpConfigBuf) configBuf = tmpConfigBuf;
+ if (tmpConfigRBuf) configRBuf = tmpConfigRBuf;
+
+ break;
+
+ } else {
+
+ /* reallocation succeeded */
+
+ configBuf = tmpConfigBuf;
+ configRBuf = tmpConfigRBuf;
+ pos = i;
+ configBufLen += CONFIG_BUF_LEN;
+ }
+ }
+
+ } while (!eolFound);
+
+ return ret;
+}
+
+/*
+ * xf86getToken --
+ * Read next Token from the config file. Handle the global variable
+ * pushToken.
+ */
+int
+xf86getToken (xf86ConfigSymTabRec * tab)
+{
+ int c, i;
+
+ /*
+ * First check whether pushToken has a different value than LOCK_TOKEN.
+ * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the
+ * oth * case the next token must be read from the input.
+ */
+ if (pushToken == EOF_TOKEN)
+ return EOF_TOKEN;
+ else if (pushToken == LOCK_TOKEN)
+ {
+ /*
+ * eol_seen is only set for the first token after a newline.
+ */
+ eol_seen = 0;
+
+ c = configBuf[configPos];
+
+ /*
+ * Get start of next Token. EOF is handled,
+ * whitespaces are skipped.
+ */
+
+again:
+ if (!c)
+ {
+ char *ret;
+ if (numFiles > 0)
+ ret = xf86getNextLine();
+ else {
+ if (builtinConfig[builtinIndex] == NULL)
+ ret = NULL;
+ else {
+ ret = strncpy(configBuf, builtinConfig[builtinIndex],
+ CONFIG_BUF_LEN);
+ builtinIndex++;
+ }
+ }
+ if (ret == NULL)
+ {
+ /*
+ * if necessary, move to the next file and
+ * read the first line
+ */
+ if (curFileIndex + 1 < numFiles) {
+ curFileIndex++;
+ configLineNo = 0;
+ goto again;
+ }
+ else
+ return pushToken = EOF_TOKEN;
+ }
+ configLineNo++;
+ configPos = 0;
+ eol_seen = 1;
+ }
+
+ i = 0;
+ for (;;) {
+ c = configBuf[configPos++];
+ configRBuf[i++] = c;
+ switch (c) {
+ case ' ':
+ case '\t':
+ case '\r':
+ continue;
+ case '\n':
+ i = 0;
+ continue;
+ }
+ break;
+ }
+ if (c == '\0')
+ goto again;
+
+ if (c == '#')
+ {
+ do
+ {
+ configRBuf[i++] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ /* XXX no private copy.
+ * Use xf86addComment when setting a comment.
+ */
+ val.str = configRBuf;
+ return COMMENT;
+ }
+
+ /* GJA -- handle '-' and ',' * Be careful: "-hsync" is a keyword. */
+ else if ((c == ',') && !isalpha (configBuf[configPos]))
+ {
+ return COMMA;
+ }
+ else if ((c == '-') && !isalpha (configBuf[configPos]))
+ {
+ return DASH;
+ }
+
+ /*
+ * Numbers are returned immediately ...
+ */
+ if (isdigit (c))
+ {
+ int base;
+
+ if (c == '0')
+ if ((configBuf[configPos] == 'x') ||
+ (configBuf[configPos] == 'X'))
+ {
+ base = 16;
+ val.numType = PARSE_HEX;
+ }
+ else
+ {
+ base = 8;
+ val.numType = PARSE_OCTAL;
+ }
+ else
+ {
+ base = 10;
+ val.numType = PARSE_DECIMAL;
+ }
+
+ configRBuf[0] = c;
+ i = 1;
+ while (isdigit (c = configBuf[configPos++]) ||
+ (c == '.') || (c == 'x') || (c == 'X') ||
+ ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
+ ((c >= 'A') && (c <= 'F')))))
+ configRBuf[i++] = c;
+ configPos--; /* GJA -- one too far */
+ configRBuf[i] = '\0';
+ val.num = xf86strToUL (configRBuf);
+ val.realnum = atof (configRBuf);
+ return NUMBER;
+ }
+
+ /*
+ * All Strings START with a \" ...
+ */
+ else if (c == '\"')
+ {
+ i = -1;
+ do
+ {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
+ configRBuf[i] = '\0';
+ val.str = malloc (strlen (configRBuf) + 1);
+ strcpy (val.str, configRBuf); /* private copy ! */
+ return STRING;
+ }
+
+ /*
+ * ... and now we MUST have a valid token. The search is
+ * handled later along with the pushed tokens.
+ */
+ else
+ {
+ configRBuf[0] = c;
+ i = 0;
+ do
+ {
+ configRBuf[++i] = (c = configBuf[configPos++]);
+ }
+ while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') && (c != '#'));
+ --configPos;
+ configRBuf[i] = '\0';
+ i = 0;
+ }
+
+ }
+ else
+ {
+
+ /*
+ * Here we deal with pushed tokens. Reinitialize pushToken again. If
+ * the pushed token was NUMBER || STRING return them again ...
+ */
+ int temp = pushToken;
+ pushToken = LOCK_TOKEN;
+
+ if (temp == COMMA || temp == DASH)
+ return temp;
+ if (temp == NUMBER || temp == STRING)
+ return temp;
+ }
+
+ /*
+ * Joop, at last we have to lookup the token ...
+ */
+ if (tab)
+ {
+ i = 0;
+ while (tab[i].token != -1)
+ if (xf86nameCompare (configRBuf, tab[i].name) == 0)
+ return tab[i].token;
+ else
+ i++;
+ }
+
+ return ERROR_TOKEN; /* Error catcher */
+}
+
+int
+xf86getSubToken (char **comment)
+{
+ int token;
+
+ for (;;) {
+ token = xf86getToken(NULL);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return token;
+ }
+ /*NOTREACHED*/
+}
+
+int
+xf86getSubTokenWithTab (char **comment, xf86ConfigSymTabRec *tab)
+{
+ int token;
+
+ for (;;) {
+ token = xf86getToken(tab);
+ if (token == COMMENT) {
+ if (comment)
+ *comment = xf86addComment(*comment, val.str);
+ }
+ else
+ return token;
+ }
+ /*NOTREACHED*/
+}
+
+void
+xf86unGetToken (int token)
+{
+ pushToken = token;
+}
+
+char *
+xf86tokenString (void)
+{
+ return configRBuf;
+}
+
+int
+xf86pathIsAbsolute(const char *path)
+{
+ if (path && path[0] == '/')
+ return 1;
+ return 0;
+}
+
+/* A path is "safe" if it is relative and if it contains no ".." elements. */
+int
+xf86pathIsSafe(const char *path)
+{
+ if (xf86pathIsAbsolute(path))
+ return 0;
+
+ /* Compare with ".." */
+ if (!strcmp(path, ".."))
+ return 0;
+
+ /* Look for leading "../" */
+ if (!strncmp(path, "../", 3))
+ return 0;
+
+ /* Look for trailing "/.." */
+ if ((strlen(path) > 3) && !strcmp(path + strlen(path) - 3, "/.."))
+ return 0;
+
+ /* Look for "/../" */
+ if (strstr(path, "/../"))
+ return 0;
+
+ return 1;
+}
+
+/*
+ * This function substitutes the following escape sequences:
+ *
+ * %A cmdline argument as an absolute path (must be absolute to match)
+ * %R cmdline argument as a relative path
+ * %S cmdline argument as a "safe" path (relative, and no ".." elements)
+ * %X default config file name ("xorg.conf")
+ * %H hostname
+ * %E config file environment ($XORGCONFIG) as an absolute path
+ * %F config file environment ($XORGCONFIG) as a relative path
+ * %G config file environment ($XORGCONFIG) as a safe path
+ * %P projroot
+ * %C sysconfdir
+ * %D datadir
+ * %M config file format version number
+ * %% %
+ */
+
+#ifndef XCONFIGFILE
+#define XCONFIGFILE "xorg.conf"
+#endif
+#ifndef XCONFIGDIR
+#define XCONFIGDIR "xorg.conf.d"
+#endif
+#ifndef XCONFIGSUFFIX
+#define XCONFIGSUFFIX ".conf"
+#endif
+#ifndef PROJECTROOT
+#define PROJECTROOT "/usr/X11R6"
+#endif
+#ifndef SYSCONFDIR
+#define SYSCONFDIR PROJECTROOT "/etc"
+#endif
+#ifndef DATADIR
+#define DATADIR PROJECTROOT "/share"
+#endif
+#ifndef XCONFENV
+#define XCONFENV "XORGCONFIG"
+#endif
+/* xorg.conf is based on XF86Config version 4. If we ever break
+ compatibility of the xorg.conf syntax, we'll bump this version number. */
+#ifndef CONFIG_FILE_VERSION
+#define CONFIG_FILE_VERSION 4
+#endif
+
+#define BAIL_OUT do { \
+ free(result); \
+ return NULL; \
+ } while (0)
+
+#define CHECK_LENGTH do { \
+ if (l > PATH_MAX) { \
+ BAIL_OUT; \
+ } \
+ } while (0)
+
+#define APPEND_STR(s) do { \
+ if (strlen(s) + l > PATH_MAX) { \
+ BAIL_OUT; \
+ } else { \
+ strcpy(result + l, s); \
+ l += strlen(s); \
+ } \
+ } while (0)
+
+static char *
+DoSubstitution(const char *template, const char *cmdline, const char *projroot,
+ int *cmdlineUsed, int *envUsed,
+ const char *XConfigFile)
+{
+ char *result;
+ int i, l;
+ static const char *env = NULL;
+ static char *hostname = NULL;
+ static char majorvers[3] = "";
+
+ if (!template)
+ return NULL;
+
+ if (cmdlineUsed)
+ *cmdlineUsed = 0;
+ if (envUsed)
+ *envUsed = 0;
+
+ result = malloc(PATH_MAX + 1);
+ l = 0;
+ for (i = 0; template[i]; i++) {
+ if (template[i] != '%') {
+ result[l++] = template[i];
+ CHECK_LENGTH;
+ } else {
+ switch (template[++i]) {
+ case 'A':
+ if (cmdline && xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'R':
+ if (cmdline && !xf86pathIsAbsolute(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'S':
+ if (cmdline && xf86pathIsSafe(cmdline)) {
+ APPEND_STR(cmdline);
+ if (cmdlineUsed)
+ *cmdlineUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'X':
+ APPEND_STR(XConfigFile);
+ break;
+ case 'H':
+ if (!hostname) {
+ if ((hostname = malloc(MAXHOSTNAMELEN + 1))) {
+ if (gethostname(hostname, MAXHOSTNAMELEN) == 0) {
+ hostname[MAXHOSTNAMELEN] = '\0';
+ } else {
+ free(hostname);
+ hostname = NULL;
+ }
+ }
+ }
+ if (hostname)
+ APPEND_STR(hostname);
+ break;
+ case 'E':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'F':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && !xf86pathIsAbsolute(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'G':
+ if (!env)
+ env = getenv(XCONFENV);
+ if (env && xf86pathIsSafe(env)) {
+ APPEND_STR(env);
+ if (envUsed)
+ *envUsed = 1;
+ } else
+ BAIL_OUT;
+ break;
+ case 'P':
+ if (projroot && xf86pathIsAbsolute(projroot))
+ APPEND_STR(projroot);
+ else
+ BAIL_OUT;
+ break;
+ case 'C':
+ APPEND_STR(SYSCONFDIR);
+ break;
+ case 'D':
+ APPEND_STR(DATADIR);
+ break;
+ case 'M':
+ if (!majorvers[0]) {
+ snprintf(majorvers, sizeof(majorvers),
+ "%d", CONFIG_FILE_VERSION);
+ }
+ APPEND_STR(majorvers);
+ break;
+ case '%':
+ result[l++] = '%';
+ CHECK_LENGTH;
+ break;
+ default:
+ fprintf(stderr, "invalid escape %%%c found in path template\n",
+ template[i]);
+ BAIL_OUT;
+ break;
+ }
+ }
+ }
+#ifdef DEBUG
+ fprintf(stderr, "Converted `%s' to `%s'\n", template, result);
+#endif
+ return result;
+}
+
+/*
+ * Given some searching parameters, locate and open the xorg config file.
+ */
+static char *
+OpenConfigFile(const char *path, const char *cmdline, const char *projroot,
+ const char *confname)
+{
+ char *filepath = NULL;
+ char *pathcopy;
+ const char *template;
+ int cmdlineUsed = 0;
+ FILE *file = NULL;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !file;
+ template = strtok(NULL, ",")) {
+ filepath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!filepath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(filepath);
+ filepath = NULL;
+ continue;
+ }
+ file = fopen(filepath, "r");
+ if (!file) {
+ free(filepath);
+ filepath = NULL;
+ }
+ }
+
+ if (file) {
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = strdup(filepath);
+ numFiles++;
+ }
+ return filepath;
+}
+
+/*
+ * Match non-hidden files in the xorg config directory with a .conf
+ * suffix. This filter is passed to scandir(3).
+ */
+static int
+ConfigFilter(const struct dirent *de)
+{
+ const char *name = de->d_name;
+ size_t len;
+ size_t suflen = strlen(XCONFIGSUFFIX);
+
+ if (!name || name[0] == '.')
+ return 0;
+ len = strlen(name);
+ if(len <= suflen)
+ return 0;
+ if (strcmp(&name[len-suflen], XCONFIGSUFFIX) != 0)
+ return 0;
+ return 1;
+}
+
+static Bool
+AddConfigDirFiles(const char *dirpath, struct dirent **list, int num)
+{
+ int i;
+ Bool openedFile = FALSE;
+ Bool warnOnce = FALSE;
+
+ for (i = 0; i < num; i++) {
+ char *path;
+ FILE *file;
+
+ if (numFiles >= CONFIG_MAX_FILES) {
+ if (!warnOnce) {
+ ErrorF("Maximum number of configuration "
+ "files opened\n");
+ warnOnce = TRUE;
+ }
+ free(list[i]);
+ continue;
+ }
+
+ path = malloc(PATH_MAX + 1);
+ snprintf(path, PATH_MAX + 1, "%s/%s", dirpath,
+ list[i]->d_name);
+ free(list[i]);
+ file = fopen(path, "r");
+ if (!file) {
+ free(path);
+ continue;
+ }
+ openedFile = TRUE;
+
+ configFiles[numFiles].file = file;
+ configFiles[numFiles].path = path;
+ numFiles++;
+ }
+
+ return openedFile;
+}
+
+/*
+ * Given some searching parameters, locate and open the xorg config
+ * directory. The directory does not need to contain config files.
+ */
+static char *
+OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
+ const char *confname)
+{
+ char *dirpath, *pathcopy;
+ const char *template;
+ Bool found = FALSE;
+ int cmdlineUsed = 0;
+
+ pathcopy = strdup(path);
+ for (template = strtok(pathcopy, ","); template && !found;
+ template = strtok(NULL, ",")) {
+ struct dirent **list = NULL;
+ int num;
+
+ dirpath = DoSubstitution(template, cmdline, projroot,
+ &cmdlineUsed, NULL, confname);
+ if (!dirpath)
+ continue;
+ if (cmdline && !cmdlineUsed) {
+ free(dirpath);
+ dirpath = NULL;
+ continue;
+ }
+
+ /* match files named *.conf */
+ num = scandir(dirpath, &list, ConfigFilter, alphasort);
+ found = AddConfigDirFiles(dirpath, list, num);
+ if (!found) {
+ free(dirpath);
+ dirpath = NULL;
+ free(list);
+ }
+ }
+
+ return dirpath;
+}
+
+/*
+ * xf86initConfigFiles -- Setup global variables and buffers.
+ */
+void
+xf86initConfigFiles(void)
+{
+ curFileIndex = 0;
+ configPos = 0;
+ configLineNo = 0;
+ pushToken = LOCK_TOKEN;
+
+ configBuf = malloc(CONFIG_BUF_LEN);
+ configRBuf = malloc(CONFIG_BUF_LEN);
+ configBuf[0] = '\0'; /* sanity ... */
+}
+
+/*
+ * xf86openConfigFile --
+ *
+ * This function take a config file search path (optional), a command-line
+ * specified file name (optional) and the ProjectRoot path (optional) and
+ * locates and opens a config file based on that information. If a
+ * command-line file name is specified, then this function fails if none
+ * of the located files.
+ *
+ * The return value is a pointer to the actual name of the file that was
+ * opened. When no file is found, the return value is NULL.
+ *
+ * The escape sequences allowed in the search path are defined above.
+ *
+ */
+
+#ifndef DEFAULT_CONF_PATH
+#define DEFAULT_CONF_PATH "/etc/X11/%S," \
+ "%P/etc/X11/%S," \
+ "/etc/X11/%G," \
+ "%P/etc/X11/%G," \
+ "/etc/X11/%X-%M," \
+ "/etc/X11/%X," \
+ "/etc/%X," \
+ "%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X," \
+ "%P/lib/X11/%X.%H," \
+ "%P/lib/X11/%X-%M," \
+ "%P/lib/X11/%X"
+#endif
+
+const char *
+xf86openConfigFile(const char *path, const char *cmdline, const char *projroot)
+{
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
+
+ /* Search for a config file */
+ configPath = OpenConfigFile(path, cmdline, projroot, XCONFIGFILE);
+ return configPath;
+}
+
+/*
+ * xf86openConfigDirFiles --
+ *
+ * This function take a config directory search path (optional), a
+ * command-line specified directory name (optional) and the ProjectRoot path
+ * (optional) and locates and opens a config directory based on that
+ * information. If a command-line name is specified, then this function
+ * fails if it is not found.
+ *
+ * The return value is a pointer to the actual name of the direcoty that was
+ * opened. When no directory is found, the return value is NULL.
+ *
+ * The escape sequences allowed in the search path are defined above.
+ *
+ */
+const char *
+xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot)
+{
+ if (!path || !path[0])
+ path = DEFAULT_CONF_PATH;
+ if (!projroot || !projroot[0])
+ projroot = PROJECTROOT;
+
+ /* Search for the multiconf directory */
+ configDirPath = OpenConfigDir(path, cmdline, projroot, XCONFIGDIR);
+ return configDirPath;
+}
+
+void
+xf86closeConfigFile (void)
+{
+ int i;
+
+ free (configPath);
+ configPath = NULL;
+ free (configDirPath);
+ configDirPath = NULL;
+ free (configRBuf);
+ configRBuf = NULL;
+ free (configBuf);
+ configBuf = NULL;
+
+ if (numFiles == 0) {
+ builtinConfig = NULL;
+ builtinIndex = 0;
+ }
+ for (i = 0; i < numFiles; i++) {
+ fclose(configFiles[i].file);
+ configFiles[i].file = NULL;
+ free(configFiles[i].path);
+ configFiles[i].path = NULL;
+ }
+ numFiles = 0;
+}
+
+void
+xf86setBuiltinConfig(const char *config[])
+{
+ builtinConfig = config;
+}
+
+void
+xf86parseError (char *format,...)
+{
+ va_list ap;
+ char *filename = numFiles ? configFiles[curFileIndex].path :
+ "<builtin configuration>";
+
+ ErrorF ("Parse error on line %d of section %s in file %s\n\t",
+ configLineNo, configSection, filename);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86validationError (char *format,...)
+{
+ va_list ap;
+ char *filename = numFiles ? configFiles[curFileIndex].path :
+ "<builtin configuration>";
+
+ ErrorF ("Data incomplete in file %s\n\t", filename);
+ va_start (ap, format);
+ VErrorF (format, ap);
+ va_end (ap);
+
+ ErrorF ("\n");
+}
+
+void
+xf86setSection (char *section)
+{
+ free(configSection);
+ configSection = malloc(strlen (section) + 1);
+ strcpy (configSection, section);
+}
+
+/*
+ * xf86getToken --
+ * Lookup a string if it is actually a token in disguise.
+ */
+int
+xf86getStringToken (xf86ConfigSymTabRec * tab)
+{
+ return StringToToken (val.str, tab);
+}
+
+static int
+StringToToken (char *str, xf86ConfigSymTabRec * tab)
+{
+ int i;
+
+ for (i = 0; tab[i].token != -1; i++)
+ {
+ if (!xf86nameCompare (tab[i].name, str))
+ return tab[i].token;
+ }
+ return ERROR_TOKEN;
+}
+
+
+/*
+ * Compare two names. The characters '_', ' ', and '\t' are ignored
+ * in the comparison.
+ */
+int
+xf86nameCompare (const char *s1, const char *s2)
+{
+ char c1, c2;
+
+ if (!s1 || *s1 == 0) {
+ if (!s2 || *s2 == 0)
+ return 0;
+ else
+ return 1;
+ }
+
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ while (c1 == c2)
+ {
+ if (c1 == '\0')
+ return 0;
+ s1++;
+ s2++;
+ while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+ s1++;
+ while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+ s2++;
+ c1 = (isupper (*s1) ? tolower (*s1) : *s1);
+ c2 = (isupper (*s2) ? tolower (*s2) : *s2);
+ }
+ return c1 - c2;
+}
+
+char *
+xf86addComment(char *cur, char *add)
+{
+ char *str;
+ int len, curlen, iscomment, hasnewline = 0, endnewline;
+
+ if (add == NULL || add[0] == '\0')
+ return cur;
+
+ if (cur) {
+ curlen = strlen(cur);
+ if (curlen)
+ hasnewline = cur[curlen - 1] == '\n';
+ eol_seen = 0;
+ }
+ else
+ curlen = 0;
+
+ str = add;
+ iscomment = 0;
+ while (*str) {
+ if (*str != ' ' && *str != '\t')
+ break;
+ ++str;
+ }
+ iscomment = (*str == '#');
+
+ len = strlen(add);
+ endnewline = add[len - 1] == '\n';
+ len += 1 + iscomment + (!hasnewline) + (!endnewline) + eol_seen;
+
+ if ((str = realloc(cur, len + curlen)) == NULL)
+ return cur;
+
+ cur = str;
+
+ if (eol_seen || (curlen && !hasnewline))
+ cur[curlen++] = '\n';
+ if (!iscomment)
+ cur[curlen++] = '#';
+ strcpy(cur + curlen, add);
+ if (!endnewline)
+ strcat(cur, "\n");
+
+ return cur;
+}
+
+Bool
+xf86getBoolValue(Bool *val, const char *str)
+{
+ if (!val || !str)
+ return FALSE;
+ if (*str == '\0') {
+ *val = TRUE;
+ } else {
+ if (xf86nameCompare(str, "1") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "on") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "true") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "yes") == 0)
+ *val = TRUE;
+ else if (xf86nameCompare(str, "0") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "off") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "false") == 0)
+ *val = FALSE;
+ else if (xf86nameCompare(str, "no") == 0)
+ *val = FALSE;
+ else
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index d79544a20..d35bbab27 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -1,518 +1,530 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/*
- * This file contains the external interfaces for the XFree86 configuration
- * file parser.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _xf86Parser_h_
-#define _xf86Parser_h_
-
-#include <X11/Xdefs.h>
-#include "xf86Optrec.h"
-
-#define HAVE_PARSER_DECLS
-
-typedef struct
-{
- char *file_logfile;
- char *file_modulepath;
- char *file_fontpath;
- char *file_comment;
- char *file_xkbdir;
-}
-XF86ConfFilesRec, *XF86ConfFilesPtr;
-
-/* Values for load_type */
-#define XF86_LOAD_MODULE 0
-#define XF86_LOAD_DRIVER 1
-#define XF86_DISABLE_MODULE 2
-
-typedef struct
-{
- GenericListRec list;
- int load_type;
- char *load_name;
- XF86OptionPtr load_opt;
- char *load_comment;
- int ignore;
-}
-XF86LoadRec, *XF86LoadPtr;
-
-typedef struct
-{
- XF86LoadPtr mod_load_lst;
- XF86LoadPtr mod_disable_lst;
- char *mod_comment;
-}
-XF86ConfModuleRec, *XF86ConfModulePtr;
-
-#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard"
-
-#define CONF_IMPLICIT_POINTER "Implicit Core Pointer"
-
-#define XF86CONF_PHSYNC 0x0001
-#define XF86CONF_NHSYNC 0x0002
-#define XF86CONF_PVSYNC 0x0004
-#define XF86CONF_NVSYNC 0x0008
-#define XF86CONF_INTERLACE 0x0010
-#define XF86CONF_DBLSCAN 0x0020
-#define XF86CONF_CSYNC 0x0040
-#define XF86CONF_PCSYNC 0x0080
-#define XF86CONF_NCSYNC 0x0100
-#define XF86CONF_HSKEW 0x0200 /* hskew provided */
-#define XF86CONF_BCAST 0x0400
-#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */
-#define XF86CONF_VSCAN 0x1000
-
-typedef struct
-{
- GenericListRec list;
- char *ml_identifier;
- int ml_clock;
- int ml_hdisplay;
- int ml_hsyncstart;
- int ml_hsyncend;
- int ml_htotal;
- int ml_vdisplay;
- int ml_vsyncstart;
- int ml_vsyncend;
- int ml_vtotal;
- int ml_vscan;
- int ml_flags;
- int ml_hskew;
- char *ml_comment;
-}
-XF86ConfModeLineRec, *XF86ConfModeLinePtr;
-
-typedef struct
-{
- GenericListRec list;
- char *vp_identifier;
- XF86OptionPtr vp_option_lst;
- char *vp_comment;
-}
-XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *va_identifier;
- char *va_vendor;
- char *va_board;
- char *va_busid;
- char *va_driver;
- XF86OptionPtr va_option_lst;
- XF86ConfVideoPortPtr va_port_lst;
- char *va_fwdref;
- char *va_comment;
-}
-XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
-
-#define CONF_MAX_HSYNC 8
-#define CONF_MAX_VREFRESH 8
-
-typedef struct
-{
- float hi, lo;
-}
-parser_range;
-
-typedef struct
-{
- int red, green, blue;
-}
-parser_rgb;
-
-typedef struct
-{
- GenericListRec list;
- char *modes_identifier;
- XF86ConfModeLinePtr mon_modeline_lst;
- char *modes_comment;
-}
-XF86ConfModesRec, *XF86ConfModesPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *ml_modes_str;
- XF86ConfModesPtr ml_modes;
-}
-XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *mon_identifier;
- char *mon_vendor;
- char *mon_modelname;
- int mon_width; /* in mm */
- int mon_height; /* in mm */
- XF86ConfModeLinePtr mon_modeline_lst;
- int mon_n_hsync;
- parser_range mon_hsync[CONF_MAX_HSYNC];
- int mon_n_vrefresh;
- parser_range mon_vrefresh[CONF_MAX_VREFRESH];
- float mon_gamma_red;
- float mon_gamma_green;
- float mon_gamma_blue;
- XF86OptionPtr mon_option_lst;
- XF86ConfModesLinkPtr mon_modes_sect_lst;
- char *mon_comment;
-}
-XF86ConfMonitorRec, *XF86ConfMonitorPtr;
-
-#define CONF_MAXDACSPEEDS 4
-#define CONF_MAXCLOCKS 128
-
-typedef struct
-{
- GenericListRec list;
- char *dev_identifier;
- char *dev_vendor;
- char *dev_board;
- char *dev_chipset;
- char *dev_busid;
- char *dev_card;
- char *dev_driver;
- char *dev_ramdac;
- int dev_dacSpeeds[CONF_MAXDACSPEEDS];
- int dev_videoram;
- int dev_textclockfreq;
- unsigned long dev_bios_base;
- unsigned long dev_mem_base;
- unsigned long dev_io_base;
- char *dev_clockchip;
- int dev_clocks;
- int dev_clock[CONF_MAXCLOCKS];
- int dev_chipid;
- int dev_chiprev;
- int dev_irq;
- int dev_screen;
- XF86OptionPtr dev_option_lst;
- char *dev_comment;
-}
-XF86ConfDeviceRec, *XF86ConfDevicePtr;
-
-typedef struct
-{
- GenericListRec list;
- char *mode_name;
-}
-XF86ModeRec, *XF86ModePtr;
-
-typedef struct
-{
- GenericListRec list;
- int disp_frameX0;
- int disp_frameY0;
- int disp_virtualX;
- int disp_virtualY;
- int disp_depth;
- int disp_bpp;
- char *disp_visual;
- parser_rgb disp_weight;
- parser_rgb disp_black;
- parser_rgb disp_white;
- XF86ModePtr disp_mode_lst;
- XF86OptionPtr disp_option_lst;
- char *disp_comment;
-}
-XF86ConfDisplayRec, *XF86ConfDisplayPtr;
-
-typedef struct
-{
- XF86OptionPtr flg_option_lst;
- char *flg_comment;
-}
-XF86ConfFlagsRec, *XF86ConfFlagsPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *al_adaptor_str;
- XF86ConfVideoAdaptorPtr al_adaptor;
-}
-XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *scrn_identifier;
- char *scrn_obso_driver;
- int scrn_defaultdepth;
- int scrn_defaultbpp;
- int scrn_defaultfbbpp;
- char *scrn_monitor_str;
- XF86ConfMonitorPtr scrn_monitor;
- char *scrn_device_str;
- XF86ConfDevicePtr scrn_device;
- XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
- XF86ConfDisplayPtr scrn_display_lst;
- XF86OptionPtr scrn_option_lst;
- char *scrn_comment;
- int scrn_virtualX, scrn_virtualY;
-}
-XF86ConfScreenRec, *XF86ConfScreenPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *inp_identifier;
- char *inp_driver;
- XF86OptionPtr inp_option_lst;
- char *inp_comment;
-}
-XF86ConfInputRec, *XF86ConfInputPtr;
-
-typedef struct
-{
- GenericListRec list;
- XF86ConfInputPtr iref_inputdev;
- char *iref_inputdev_str;
- XF86OptionPtr iref_option_lst;
-}
-XF86ConfInputrefRec, *XF86ConfInputrefPtr;
-
-typedef struct
-{
- Bool set;
- Bool val;
-}
-xf86TriState;
-
-typedef struct
-{
- GenericListRec list;
- char *identifier;
- char *driver;
- char **match_product;
- char **match_vendor;
- char **match_device;
- char **match_tag;
- xf86TriState is_keyboard;
- xf86TriState is_pointer;
- xf86TriState is_joystick;
- xf86TriState is_tablet;
- xf86TriState is_touchpad;
- xf86TriState is_touchscreen;
- XF86OptionPtr option_lst;
- char *comment;
-}
-XF86ConfInputClassRec, *XF86ConfInputClassPtr;
-
-/* Values for adj_where */
-#define CONF_ADJ_OBSOLETE -1
-#define CONF_ADJ_ABSOLUTE 0
-#define CONF_ADJ_RIGHTOF 1
-#define CONF_ADJ_LEFTOF 2
-#define CONF_ADJ_ABOVE 3
-#define CONF_ADJ_BELOW 4
-#define CONF_ADJ_RELATIVE 5
-
-typedef struct
-{
- GenericListRec list;
- int adj_scrnum;
- XF86ConfScreenPtr adj_screen;
- char *adj_screen_str;
- XF86ConfScreenPtr adj_top;
- char *adj_top_str;
- XF86ConfScreenPtr adj_bottom;
- char *adj_bottom_str;
- XF86ConfScreenPtr adj_left;
- char *adj_left_str;
- XF86ConfScreenPtr adj_right;
- char *adj_right_str;
- int adj_where;
- int adj_x;
- int adj_y;
- char *adj_refscreen;
-}
-XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *inactive_device_str;
- XF86ConfDevicePtr inactive_device;
-}
-XF86ConfInactiveRec, *XF86ConfInactivePtr;
-
-typedef struct
-{
- GenericListRec list;
- char *lay_identifier;
- XF86ConfAdjacencyPtr lay_adjacency_lst;
- XF86ConfInactivePtr lay_inactive_lst;
- XF86ConfInputrefPtr lay_input_lst;
- XF86OptionPtr lay_option_lst;
- char *lay_comment;
-}
-XF86ConfLayoutRec, *XF86ConfLayoutPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *vs_name;
- char *vs_identifier;
- XF86OptionPtr vs_option_lst;
- char *vs_comment;
-}
-XF86ConfVendSubRec, *XF86ConfVendSubPtr;
-
-typedef struct
-{
- GenericListRec list;
- char *vnd_identifier;
- XF86OptionPtr vnd_option_lst;
- XF86ConfVendSubPtr vnd_sub_lst;
- char *vnd_comment;
-}
-XF86ConfVendorRec, *XF86ConfVendorPtr;
-
-typedef struct
-{
- GenericListRec list;
- int buf_count;
- int buf_size;
- char *buf_flags;
- char *buf_comment;
-}
-XF86ConfBuffersRec, *XF86ConfBuffersPtr;
-
-typedef struct
-{
- char *dri_group_name;
- int dri_group;
- int dri_mode;
- XF86ConfBuffersPtr dri_buffers_lst;
- char *dri_comment;
-}
-XF86ConfDRIRec, *XF86ConfDRIPtr;
-
-typedef struct
-{
- XF86OptionPtr ext_option_lst;
- char *extensions_comment;
-}
-XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
-
-typedef struct
-{
- XF86ConfFilesPtr conf_files;
- XF86ConfModulePtr conf_modules;
- XF86ConfFlagsPtr conf_flags;
- XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
- XF86ConfModesPtr conf_modes_lst;
- XF86ConfMonitorPtr conf_monitor_lst;
- XF86ConfDevicePtr conf_device_lst;
- XF86ConfScreenPtr conf_screen_lst;
- XF86ConfInputPtr conf_input_lst;
- XF86ConfInputClassPtr conf_inputclass_lst;
- XF86ConfLayoutPtr conf_layout_lst;
- XF86ConfVendorPtr conf_vendor_lst;
- XF86ConfDRIPtr conf_dri;
- XF86ConfExtensionsPtr conf_extensions;
- char *conf_comment;
-}
-XF86ConfigRec, *XF86ConfigPtr;
-
-typedef struct
-{
- int token; /* id of the token */
- char *name; /* pointer to the LOWERCASED name */
-}
-xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
-
-/*
- * prototypes for public functions
- */
-extern void xf86initConfigFiles(void);
-extern const char *xf86openConfigFile(const char *path, const char *cmdline,
- const char *projroot);
-extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline,
- const char *projroot);
-extern void xf86setBuiltinConfig(const char *config[]);
-extern XF86ConfigPtr xf86readConfigFile(void);
-extern void xf86closeConfigFile(void);
-extern void xf86freeConfig(XF86ConfigPtr p);
-extern int xf86writeConfigFile(const char *, XF86ConfigPtr);
-extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
-extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
-extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
-extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p);
-extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p);
-extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
-extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
-extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
-extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
- XF86ConfVideoAdaptorPtr p);
-extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout);
-
-extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
-extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
-
-extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
-extern _X_EXPORT int xf86pathIsSafe(const char *path);
-extern _X_EXPORT char *xf86addComment(char *cur, char *add);
-extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
-
-#endif /* _xf86Parser_h_ */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+/*
+ * This file contains the external interfaces for the XFree86 configuration
+ * file parser.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86Parser_h_
+#define _xf86Parser_h_
+
+#include <X11/Xdefs.h>
+#include "xf86Optrec.h"
+#include "list.h"
+
+#define HAVE_PARSER_DECLS
+
+typedef struct
+{
+ char *file_logfile;
+ char *file_modulepath;
+ char *file_fontpath;
+ char *file_comment;
+ char *file_xkbdir;
+}
+XF86ConfFilesRec, *XF86ConfFilesPtr;
+
+/* Values for load_type */
+#define XF86_LOAD_MODULE 0
+#define XF86_LOAD_DRIVER 1
+#define XF86_DISABLE_MODULE 2
+
+typedef struct
+{
+ GenericListRec list;
+ int load_type;
+ char *load_name;
+ XF86OptionPtr load_opt;
+ char *load_comment;
+ int ignore;
+}
+XF86LoadRec, *XF86LoadPtr;
+
+typedef struct
+{
+ XF86LoadPtr mod_load_lst;
+ XF86LoadPtr mod_disable_lst;
+ char *mod_comment;
+}
+XF86ConfModuleRec, *XF86ConfModulePtr;
+
+#define CONF_IMPLICIT_KEYBOARD "Implicit Core Keyboard"
+
+#define CONF_IMPLICIT_POINTER "Implicit Core Pointer"
+
+#define XF86CONF_PHSYNC 0x0001
+#define XF86CONF_NHSYNC 0x0002
+#define XF86CONF_PVSYNC 0x0004
+#define XF86CONF_NVSYNC 0x0008
+#define XF86CONF_INTERLACE 0x0010
+#define XF86CONF_DBLSCAN 0x0020
+#define XF86CONF_CSYNC 0x0040
+#define XF86CONF_PCSYNC 0x0080
+#define XF86CONF_NCSYNC 0x0100
+#define XF86CONF_HSKEW 0x0200 /* hskew provided */
+#define XF86CONF_BCAST 0x0400
+#define XF86CONF_CUSTOM 0x0800 /* timing numbers customized by editor */
+#define XF86CONF_VSCAN 0x1000
+
+typedef struct
+{
+ GenericListRec list;
+ char *ml_identifier;
+ int ml_clock;
+ int ml_hdisplay;
+ int ml_hsyncstart;
+ int ml_hsyncend;
+ int ml_htotal;
+ int ml_vdisplay;
+ int ml_vsyncstart;
+ int ml_vsyncend;
+ int ml_vtotal;
+ int ml_vscan;
+ int ml_flags;
+ int ml_hskew;
+ char *ml_comment;
+}
+XF86ConfModeLineRec, *XF86ConfModeLinePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vp_identifier;
+ XF86OptionPtr vp_option_lst;
+ char *vp_comment;
+}
+XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *va_identifier;
+ char *va_vendor;
+ char *va_board;
+ char *va_busid;
+ char *va_driver;
+ XF86OptionPtr va_option_lst;
+ XF86ConfVideoPortPtr va_port_lst;
+ char *va_fwdref;
+ char *va_comment;
+}
+XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
+
+#define CONF_MAX_HSYNC 8
+#define CONF_MAX_VREFRESH 8
+
+typedef struct
+{
+ float hi, lo;
+}
+parser_range;
+
+typedef struct
+{
+ int red, green, blue;
+}
+parser_rgb;
+
+typedef struct
+{
+ GenericListRec list;
+ char *modes_identifier;
+ XF86ConfModeLinePtr mon_modeline_lst;
+ char *modes_comment;
+}
+XF86ConfModesRec, *XF86ConfModesPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *ml_modes_str;
+ XF86ConfModesPtr ml_modes;
+}
+XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *mon_identifier;
+ char *mon_vendor;
+ char *mon_modelname;
+ int mon_width; /* in mm */
+ int mon_height; /* in mm */
+ XF86ConfModeLinePtr mon_modeline_lst;
+ int mon_n_hsync;
+ parser_range mon_hsync[CONF_MAX_HSYNC];
+ int mon_n_vrefresh;
+ parser_range mon_vrefresh[CONF_MAX_VREFRESH];
+ float mon_gamma_red;
+ float mon_gamma_green;
+ float mon_gamma_blue;
+ XF86OptionPtr mon_option_lst;
+ XF86ConfModesLinkPtr mon_modes_sect_lst;
+ char *mon_comment;
+}
+XF86ConfMonitorRec, *XF86ConfMonitorPtr;
+
+#define CONF_MAXDACSPEEDS 4
+#define CONF_MAXCLOCKS 128
+
+typedef struct
+{
+ GenericListRec list;
+ char *dev_identifier;
+ char *dev_vendor;
+ char *dev_board;
+ char *dev_chipset;
+ char *dev_busid;
+ char *dev_card;
+ char *dev_driver;
+ char *dev_ramdac;
+ int dev_dacSpeeds[CONF_MAXDACSPEEDS];
+ int dev_videoram;
+ int dev_textclockfreq;
+ unsigned long dev_bios_base;
+ unsigned long dev_mem_base;
+ unsigned long dev_io_base;
+ char *dev_clockchip;
+ int dev_clocks;
+ int dev_clock[CONF_MAXCLOCKS];
+ int dev_chipid;
+ int dev_chiprev;
+ int dev_irq;
+ int dev_screen;
+ XF86OptionPtr dev_option_lst;
+ char *dev_comment;
+}
+XF86ConfDeviceRec, *XF86ConfDevicePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *mode_name;
+}
+XF86ModeRec, *XF86ModePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ int disp_frameX0;
+ int disp_frameY0;
+ int disp_virtualX;
+ int disp_virtualY;
+ int disp_depth;
+ int disp_bpp;
+ char *disp_visual;
+ parser_rgb disp_weight;
+ parser_rgb disp_black;
+ parser_rgb disp_white;
+ XF86ModePtr disp_mode_lst;
+ XF86OptionPtr disp_option_lst;
+ char *disp_comment;
+}
+XF86ConfDisplayRec, *XF86ConfDisplayPtr;
+
+typedef struct
+{
+ XF86OptionPtr flg_option_lst;
+ char *flg_comment;
+}
+XF86ConfFlagsRec, *XF86ConfFlagsPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *al_adaptor_str;
+ XF86ConfVideoAdaptorPtr al_adaptor;
+}
+XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *scrn_identifier;
+ char *scrn_obso_driver;
+ int scrn_defaultdepth;
+ int scrn_defaultbpp;
+ int scrn_defaultfbbpp;
+ char *scrn_monitor_str;
+ XF86ConfMonitorPtr scrn_monitor;
+ char *scrn_device_str;
+ XF86ConfDevicePtr scrn_device;
+ XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
+ XF86ConfDisplayPtr scrn_display_lst;
+ XF86OptionPtr scrn_option_lst;
+ char *scrn_comment;
+ int scrn_virtualX, scrn_virtualY;
+}
+XF86ConfScreenRec, *XF86ConfScreenPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *inp_identifier;
+ char *inp_driver;
+ XF86OptionPtr inp_option_lst;
+ char *inp_comment;
+}
+XF86ConfInputRec, *XF86ConfInputPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ XF86ConfInputPtr iref_inputdev;
+ char *iref_inputdev_str;
+ XF86OptionPtr iref_option_lst;
+}
+XF86ConfInputrefRec, *XF86ConfInputrefPtr;
+
+typedef struct
+{
+ Bool set;
+ Bool val;
+}
+xf86TriState;
+
+typedef struct
+{
+ struct list entry;
+ char **values;
+}
+xf86MatchGroup;
+
+typedef struct
+{
+ GenericListRec list;
+ char *identifier;
+ char *driver;
+ struct list match_product;
+ struct list match_vendor;
+ struct list match_device;
+ struct list match_os;
+ struct list match_pnpid;
+ struct list match_usbid;
+ struct list match_driver;
+ struct list match_tag;
+ xf86TriState is_keyboard;
+ xf86TriState is_pointer;
+ xf86TriState is_joystick;
+ xf86TriState is_tablet;
+ xf86TriState is_touchpad;
+ xf86TriState is_touchscreen;
+ XF86OptionPtr option_lst;
+ char *comment;
+}
+XF86ConfInputClassRec, *XF86ConfInputClassPtr;
+
+/* Values for adj_where */
+#define CONF_ADJ_OBSOLETE -1
+#define CONF_ADJ_ABSOLUTE 0
+#define CONF_ADJ_RIGHTOF 1
+#define CONF_ADJ_LEFTOF 2
+#define CONF_ADJ_ABOVE 3
+#define CONF_ADJ_BELOW 4
+#define CONF_ADJ_RELATIVE 5
+
+typedef struct
+{
+ GenericListRec list;
+ int adj_scrnum;
+ XF86ConfScreenPtr adj_screen;
+ char *adj_screen_str;
+ XF86ConfScreenPtr adj_top;
+ char *adj_top_str;
+ XF86ConfScreenPtr adj_bottom;
+ char *adj_bottom_str;
+ XF86ConfScreenPtr adj_left;
+ char *adj_left_str;
+ XF86ConfScreenPtr adj_right;
+ char *adj_right_str;
+ int adj_where;
+ int adj_x;
+ int adj_y;
+ char *adj_refscreen;
+}
+XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *inactive_device_str;
+ XF86ConfDevicePtr inactive_device;
+}
+XF86ConfInactiveRec, *XF86ConfInactivePtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *lay_identifier;
+ XF86ConfAdjacencyPtr lay_adjacency_lst;
+ XF86ConfInactivePtr lay_inactive_lst;
+ XF86ConfInputrefPtr lay_input_lst;
+ XF86OptionPtr lay_option_lst;
+ char *lay_comment;
+}
+XF86ConfLayoutRec, *XF86ConfLayoutPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vs_name;
+ char *vs_identifier;
+ XF86OptionPtr vs_option_lst;
+ char *vs_comment;
+}
+XF86ConfVendSubRec, *XF86ConfVendSubPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ char *vnd_identifier;
+ XF86OptionPtr vnd_option_lst;
+ XF86ConfVendSubPtr vnd_sub_lst;
+ char *vnd_comment;
+}
+XF86ConfVendorRec, *XF86ConfVendorPtr;
+
+typedef struct
+{
+ GenericListRec list;
+ int buf_count;
+ int buf_size;
+ char *buf_flags;
+ char *buf_comment;
+}
+XF86ConfBuffersRec, *XF86ConfBuffersPtr;
+
+typedef struct
+{
+ char *dri_group_name;
+ int dri_group;
+ int dri_mode;
+ XF86ConfBuffersPtr dri_buffers_lst;
+ char *dri_comment;
+}
+XF86ConfDRIRec, *XF86ConfDRIPtr;
+
+typedef struct
+{
+ XF86OptionPtr ext_option_lst;
+ char *extensions_comment;
+}
+XF86ConfExtensionsRec, *XF86ConfExtensionsPtr;
+
+typedef struct
+{
+ XF86ConfFilesPtr conf_files;
+ XF86ConfModulePtr conf_modules;
+ XF86ConfFlagsPtr conf_flags;
+ XF86ConfVideoAdaptorPtr conf_videoadaptor_lst;
+ XF86ConfModesPtr conf_modes_lst;
+ XF86ConfMonitorPtr conf_monitor_lst;
+ XF86ConfDevicePtr conf_device_lst;
+ XF86ConfScreenPtr conf_screen_lst;
+ XF86ConfInputPtr conf_input_lst;
+ XF86ConfInputClassPtr conf_inputclass_lst;
+ XF86ConfLayoutPtr conf_layout_lst;
+ XF86ConfVendorPtr conf_vendor_lst;
+ XF86ConfDRIPtr conf_dri;
+ XF86ConfExtensionsPtr conf_extensions;
+ char *conf_comment;
+}
+XF86ConfigRec, *XF86ConfigPtr;
+
+typedef struct
+{
+ int token; /* id of the token */
+ char *name; /* pointer to the LOWERCASED name */
+}
+xf86ConfigSymTabRec, *xf86ConfigSymTabPtr;
+
+/*
+ * prototypes for public functions
+ */
+extern void xf86initConfigFiles(void);
+extern const char *xf86openConfigFile(const char *path, const char *cmdline,
+ const char *projroot);
+extern const char *xf86openConfigDirFiles(const char *path, const char *cmdline,
+ const char *projroot);
+extern void xf86setBuiltinConfig(const char *config[]);
+extern XF86ConfigPtr xf86readConfigFile(void);
+extern void xf86closeConfigFile(void);
+extern void xf86freeConfig(XF86ConfigPtr p);
+extern int xf86writeConfigFile(const char *, XF86ConfigPtr);
+extern _X_EXPORT XF86ConfDevicePtr xf86findDevice(const char *ident, XF86ConfDevicePtr p);
+extern _X_EXPORT XF86ConfLayoutPtr xf86findLayout(const char *name, XF86ConfLayoutPtr list);
+extern _X_EXPORT XF86ConfMonitorPtr xf86findMonitor(const char *ident, XF86ConfMonitorPtr p);
+extern _X_EXPORT XF86ConfModesPtr xf86findModes(const char *ident, XF86ConfModesPtr p);
+extern _X_EXPORT XF86ConfModeLinePtr xf86findModeLine(const char *ident, XF86ConfModeLinePtr p);
+extern _X_EXPORT XF86ConfScreenPtr xf86findScreen(const char *ident, XF86ConfScreenPtr p);
+extern _X_EXPORT XF86ConfInputPtr xf86findInput(const char *ident, XF86ConfInputPtr p);
+extern _X_EXPORT XF86ConfInputPtr xf86findInputByDriver(const char *driver, XF86ConfInputPtr p);
+extern _X_EXPORT XF86ConfVideoAdaptorPtr xf86findVideoAdaptor(const char *ident,
+ XF86ConfVideoAdaptorPtr p);
+extern int xf86layoutAddInputDevices(XF86ConfigPtr config, XF86ConfLayoutPtr layout);
+
+extern _X_EXPORT GenericListPtr xf86addListItem(GenericListPtr head, GenericListPtr c_new);
+extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1, GenericListPtr list_2);
+
+extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
+extern _X_EXPORT int xf86pathIsSafe(const char *path);
+extern _X_EXPORT char *xf86addComment(char *cur, char *add);
+extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
+
+#endif /* _xf86Parser_h_ */
diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h
index cb600704b..3bea43d15 100644
--- a/xorg-server/hw/xfree86/parser/xf86tokens.h
+++ b/xorg-server/hw/xfree86/parser/xf86tokens.h
@@ -1,291 +1,295 @@
-/*
- *
- * Copyright (c) 1997 Metro Link Incorporated
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Except as contained in this notice, the name of the Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- *
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _xf86_tokens_h
-#define _xf86_tokens_h
-
-/* Undefine symbols that some OSs might define */
-#undef IOBASE
-
-/*
- * Each token should have a unique value regardless of the section
- * it is used in.
- */
-
-typedef enum {
- /* errno-style tokens */
- OBSOLETE_TOKEN = -5,
- EOF_TOKEN = -4,
- LOCK_TOKEN = -3,
- ERROR_TOKEN = -2,
-
- /* value type tokens */
- NUMBER = 1,
- STRING,
-
- /* Tokens that can appear in many sections */
- SECTION,
- SUBSECTION,
- ENDSECTION,
- ENDSUBSECTION,
- IDENTIFIER,
- VENDOR,
- DASH,
- COMMA,
- OPTION,
- COMMENT,
-
- /* Frequency units */
- HRZ,
- KHZ,
- MHZ,
-
- /* File tokens */
- FONTPATH,
- MODULEPATH,
- LOGFILEPATH,
- XKBDIR,
-
- /* Server Flag tokens. These are deprecated in favour of generic Options */
- NOTRAPSIGNALS,
- DONTZAP,
- DONTZOOM,
- DISABLEVIDMODE,
- ALLOWNONLOCAL,
- DISABLEMODINDEV,
- MODINDEVALLOWNONLOCAL,
- ALLOWMOUSEOPENFAIL,
- BLANKTIME,
- STANDBYTIME,
- SUSPENDTIME,
- OFFTIME,
- DEFAULTLAYOUT,
-
- /* Monitor tokens */
- MODEL,
- MODELINE,
- DISPLAYSIZE,
- HORIZSYNC,
- VERTREFRESH,
- MODE,
- GAMMA,
- USEMODES,
-
- /* Modes tokens */
- /* no new ones */
-
- /* Mode tokens */
- DOTCLOCK,
- HTIMINGS,
- VTIMINGS,
- FLAGS,
- HSKEW,
- BCAST,
- VSCAN,
- ENDMODE,
-
- /* Screen tokens */
- OBSDRIVER,
- MDEVICE,
- MONITOR,
- SCREENNO,
- DEFAULTDEPTH,
- DEFAULTBPP,
- DEFAULTFBBPP,
-
- /* VideoAdaptor tokens */
- VIDEOADAPTOR,
-
- /* Mode timing tokens */
- TT_INTERLACE,
- TT_PHSYNC,
- TT_NHSYNC,
- TT_PVSYNC,
- TT_NVSYNC,
- TT_CSYNC,
- TT_PCSYNC,
- TT_NCSYNC,
- TT_DBLSCAN,
- TT_HSKEW,
- TT_BCAST,
- TT_VSCAN,
- TT_CUSTOM,
-
- /* Module tokens */
- LOAD,
- LOAD_DRIVER,
- DISABLE,
-
- /* Device tokens */
- DRIVER,
- CHIPSET,
- CLOCKS,
- VIDEORAM,
- BOARD,
- IOBASE,
- RAMDAC,
- DACSPEED,
- BIOSBASE,
- MEMBASE,
- CLOCKCHIP,
- CHIPID,
- CHIPREV,
- CARD,
- BUSID,
- TEXTCLOCKFRQ,
- IRQ,
-
- /* Keyboard tokens */
- AUTOREPEAT,
- XLEDS,
- KPROTOCOL,
- XKBKEYMAP,
- XKBCOMPAT,
- XKBTYPES,
- XKBKEYCODES,
- XKBGEOMETRY,
- XKBSYMBOLS,
- XKBDISABLE,
- PANIX106,
- XKBRULES,
- XKBMODEL,
- XKBLAYOUT,
- XKBVARIANT,
- XKBOPTIONS,
- /* The next two have become ServerFlags options */
- VTSYSREQ,
- /* Obsolete keyboard tokens */
- SERVERNUM,
- LEFTALT,
- RIGHTALT,
- SCROLLLOCK_TOK,
- RIGHTCTL,
- /* arguments for the above obsolete tokens */
- CONF_KM_META,
- CONF_KM_COMPOSE,
- CONF_KM_MODESHIFT,
- CONF_KM_MODELOCK,
- CONF_KM_SCROLLLOCK,
- CONF_KM_CONTROL,
-
- /* Pointer tokens */
- EMULATE3,
- BAUDRATE,
- SAMPLERATE,
- PRESOLUTION,
- CLEARDTR,
- CLEARRTS,
- CHORDMIDDLE,
- PROTOCOL,
- PDEVICE,
- EM3TIMEOUT,
- DEVICE_NAME,
- ALWAYSCORE,
- PBUTTONS,
- ZAXISMAPPING,
-
- /* Pointer Z axis mapping tokens */
- XAXIS,
- YAXIS,
-
- /* Display tokens */
- MODES,
- VIEWPORT,
- VIRTUAL,
- VISUAL,
- BLACK_TOK,
- WHITE_TOK,
- DEPTH,
- BPP,
- WEIGHT,
-
- /* Layout Tokens */
- SCREEN,
- INACTIVE,
- INPUTDEVICE,
-
- /* Adjaceny Tokens */
- RIGHTOF,
- LEFTOF,
- ABOVE,
- BELOW,
- RELATIVE,
- ABSOLUTE,
-
- /* Vendor Tokens */
- VENDORNAME,
-
- /* DRI Tokens */
- GROUP,
- BUFFERS,
-
- /* InputClass Tokens */
- MATCH_PRODUCT,
- MATCH_VENDOR,
- MATCH_DEVICE_PATH,
- MATCH_TAG,
- MATCH_IS_KEYBOARD,
- MATCH_IS_POINTER,
- MATCH_IS_JOYSTICK,
- MATCH_IS_TABLET,
- MATCH_IS_TOUCHPAD,
- MATCH_IS_TOUCHSCREEN
-} ParserTokens;
-
-#endif /* _xf86_tokens_h */
+/*
+ *
+ * Copyright (c) 1997 Metro Link Incorporated
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the Metro Link shall not be
+ * used in advertising or otherwise to promote the sale, use or other dealings
+ * in this Software without prior written authorization from Metro Link.
+ *
+ */
+/*
+ * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the name of the copyright holder(s)
+ * and author(s) shall not be used in advertising or otherwise to promote
+ * the sale, use or other dealings in this Software without prior written
+ * authorization from the copyright holder(s) and author(s).
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _xf86_tokens_h
+#define _xf86_tokens_h
+
+/* Undefine symbols that some OSs might define */
+#undef IOBASE
+
+/*
+ * Each token should have a unique value regardless of the section
+ * it is used in.
+ */
+
+typedef enum {
+ /* errno-style tokens */
+ OBSOLETE_TOKEN = -5,
+ EOF_TOKEN = -4,
+ LOCK_TOKEN = -3,
+ ERROR_TOKEN = -2,
+
+ /* value type tokens */
+ NUMBER = 1,
+ STRING,
+
+ /* Tokens that can appear in many sections */
+ SECTION,
+ SUBSECTION,
+ ENDSECTION,
+ ENDSUBSECTION,
+ IDENTIFIER,
+ VENDOR,
+ DASH,
+ COMMA,
+ OPTION,
+ COMMENT,
+
+ /* Frequency units */
+ HRZ,
+ KHZ,
+ MHZ,
+
+ /* File tokens */
+ FONTPATH,
+ MODULEPATH,
+ LOGFILEPATH,
+ XKBDIR,
+
+ /* Server Flag tokens. These are deprecated in favour of generic Options */
+ NOTRAPSIGNALS,
+ DONTZAP,
+ DONTZOOM,
+ DISABLEVIDMODE,
+ ALLOWNONLOCAL,
+ DISABLEMODINDEV,
+ MODINDEVALLOWNONLOCAL,
+ ALLOWMOUSEOPENFAIL,
+ BLANKTIME,
+ STANDBYTIME,
+ SUSPENDTIME,
+ OFFTIME,
+ DEFAULTLAYOUT,
+
+ /* Monitor tokens */
+ MODEL,
+ MODELINE,
+ DISPLAYSIZE,
+ HORIZSYNC,
+ VERTREFRESH,
+ MODE,
+ GAMMA,
+ USEMODES,
+
+ /* Modes tokens */
+ /* no new ones */
+
+ /* Mode tokens */
+ DOTCLOCK,
+ HTIMINGS,
+ VTIMINGS,
+ FLAGS,
+ HSKEW,
+ BCAST,
+ VSCAN,
+ ENDMODE,
+
+ /* Screen tokens */
+ OBSDRIVER,
+ MDEVICE,
+ MONITOR,
+ SCREENNO,
+ DEFAULTDEPTH,
+ DEFAULTBPP,
+ DEFAULTFBBPP,
+
+ /* VideoAdaptor tokens */
+ VIDEOADAPTOR,
+
+ /* Mode timing tokens */
+ TT_INTERLACE,
+ TT_PHSYNC,
+ TT_NHSYNC,
+ TT_PVSYNC,
+ TT_NVSYNC,
+ TT_CSYNC,
+ TT_PCSYNC,
+ TT_NCSYNC,
+ TT_DBLSCAN,
+ TT_HSKEW,
+ TT_BCAST,
+ TT_VSCAN,
+ TT_CUSTOM,
+
+ /* Module tokens */
+ LOAD,
+ LOAD_DRIVER,
+ DISABLE,
+
+ /* Device tokens */
+ DRIVER,
+ CHIPSET,
+ CLOCKS,
+ VIDEORAM,
+ BOARD,
+ IOBASE,
+ RAMDAC,
+ DACSPEED,
+ BIOSBASE,
+ MEMBASE,
+ CLOCKCHIP,
+ CHIPID,
+ CHIPREV,
+ CARD,
+ BUSID,
+ TEXTCLOCKFRQ,
+ IRQ,
+
+ /* Keyboard tokens */
+ AUTOREPEAT,
+ XLEDS,
+ KPROTOCOL,
+ XKBKEYMAP,
+ XKBCOMPAT,
+ XKBTYPES,
+ XKBKEYCODES,
+ XKBGEOMETRY,
+ XKBSYMBOLS,
+ XKBDISABLE,
+ PANIX106,
+ XKBRULES,
+ XKBMODEL,
+ XKBLAYOUT,
+ XKBVARIANT,
+ XKBOPTIONS,
+ /* The next two have become ServerFlags options */
+ VTSYSREQ,
+ /* Obsolete keyboard tokens */
+ SERVERNUM,
+ LEFTALT,
+ RIGHTALT,
+ SCROLLLOCK_TOK,
+ RIGHTCTL,
+ /* arguments for the above obsolete tokens */
+ CONF_KM_META,
+ CONF_KM_COMPOSE,
+ CONF_KM_MODESHIFT,
+ CONF_KM_MODELOCK,
+ CONF_KM_SCROLLLOCK,
+ CONF_KM_CONTROL,
+
+ /* Pointer tokens */
+ EMULATE3,
+ BAUDRATE,
+ SAMPLERATE,
+ PRESOLUTION,
+ CLEARDTR,
+ CLEARRTS,
+ CHORDMIDDLE,
+ PROTOCOL,
+ PDEVICE,
+ EM3TIMEOUT,
+ DEVICE_NAME,
+ ALWAYSCORE,
+ PBUTTONS,
+ ZAXISMAPPING,
+
+ /* Pointer Z axis mapping tokens */
+ XAXIS,
+ YAXIS,
+
+ /* Display tokens */
+ MODES,
+ VIEWPORT,
+ VIRTUAL,
+ VISUAL,
+ BLACK_TOK,
+ WHITE_TOK,
+ DEPTH,
+ BPP,
+ WEIGHT,
+
+ /* Layout Tokens */
+ SCREEN,
+ INACTIVE,
+ INPUTDEVICE,
+
+ /* Adjaceny Tokens */
+ RIGHTOF,
+ LEFTOF,
+ ABOVE,
+ BELOW,
+ RELATIVE,
+ ABSOLUTE,
+
+ /* Vendor Tokens */
+ VENDORNAME,
+
+ /* DRI Tokens */
+ GROUP,
+ BUFFERS,
+
+ /* InputClass Tokens */
+ MATCH_PRODUCT,
+ MATCH_VENDOR,
+ MATCH_DEVICE_PATH,
+ MATCH_OS,
+ MATCH_PNPID,
+ MATCH_USBID,
+ MATCH_DRIVER,
+ MATCH_TAG,
+ MATCH_IS_KEYBOARD,
+ MATCH_IS_POINTER,
+ MATCH_IS_JOYSTICK,
+ MATCH_IS_TABLET,
+ MATCH_IS_TOUCHPAD,
+ MATCH_IS_TOUCHSCREEN
+} ParserTokens;
+
+#endif /* _xf86_tokens_h */
diff --git a/xorg-server/hw/xfree86/ramdac/IBM.c b/xorg-server/hw/xfree86/ramdac/IBM.c
index 2d9fe4d8f..3a477d7be 100644
--- a/xorg-server/hw/xfree86/ramdac/IBM.c
+++ b/xorg-server/hw/xfree86/ramdac/IBM.c
@@ -1,639 +1,639 @@
-/*
- * Copyright 1998 by Alan Hourihane, Wigan, England.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * IBM RAMDAC routines.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "xf86Cursor.h"
-
-#define INIT_IBM_RAMDAC_INFO
-#include "IBMPriv.h"
-#include "xf86RamDacPriv.h"
-
-#define INITIALFREQERR 100000
-
-unsigned long
-IBMramdac640CalculateMNPCForClock(
- unsigned long RefClock, /* In 100Hz units */
- unsigned long ReqClock, /* In 100Hz units */
- char IsPixClock, /* boolean, is this the pixel or the sys clock */
- unsigned long MinClock, /* Min VCO rating */
- unsigned long MaxClock, /* Max VCO rating */
- unsigned long *rM, /* M Out */
- unsigned long *rN, /* N Out */
- unsigned long *rP, /* Min P In, P Out */
- unsigned long *rC /* C Out */
-)
-{
- unsigned long M, N, P, iP = *rP;
- unsigned long IntRef, VCO, Clock;
- long freqErr, lowestFreqErr = INITIALFREQERR;
- unsigned long ActualClock = 0;
-
- for (N = 0; N <= 63; N++)
- {
- IntRef = RefClock / (N + 1);
- if (IntRef < 10000)
- break; /* IntRef needs to be >= 1MHz */
- for (M = 2; M <= 127; M++)
- {
- VCO = IntRef * (M + 1);
- if ((VCO < MinClock) || (VCO > MaxClock))
- continue;
- for (P = iP; P <= 4; P++)
- {
- if (P != 0)
- Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
- else
- Clock = (RefClock * (M + 1)) / (N + 1);
-
- freqErr = (Clock - ReqClock);
-
- if (freqErr < 0)
- {
- /* PixelClock gets rounded up always so monitor reports
- correct frequency. */
- if (IsPixClock)
- continue;
- freqErr = -freqErr;
- }
-
- if (freqErr < lowestFreqErr)
- {
- *rM = M;
- *rN = N;
- *rP = P;
- *rC = (VCO <= 1280000 ? 1 : 2);
- ActualClock = Clock;
-
- lowestFreqErr = freqErr;
- /* Return if we found an exact match */
- if (freqErr == 0)
- return (ActualClock);
- }
- }
- }
- }
-
- return (ActualClock);
-}
-
-unsigned long
-IBMramdac526CalculateMNPCForClock(
- unsigned long RefClock, /* In 100Hz units */
- unsigned long ReqClock, /* In 100Hz units */
- char IsPixClock, /* boolean, is this the pixel or the sys clock */
- unsigned long MinClock, /* Min VCO rating */
- unsigned long MaxClock, /* Max VCO rating */
- unsigned long *rM, /* M Out */
- unsigned long *rN, /* N Out */
- unsigned long *rP, /* Min P In, P Out */
- unsigned long *rC /* C Out */
-)
-{
- unsigned long M, N, P, iP = *rP;
- unsigned long IntRef, VCO, Clock;
- long freqErr, lowestFreqErr = INITIALFREQERR;
- unsigned long ActualClock = 0;
-
- for (N = 0; N <= 63; N++)
- {
- IntRef = RefClock / (N + 1);
- if (IntRef < 10000)
- break; /* IntRef needs to be >= 1MHz */
- for (M = 0; M <= 63; M++)
- {
- VCO = IntRef * (M + 1);
- if ((VCO < MinClock) || (VCO > MaxClock))
- continue;
- for (P = iP; P <= 4; P++)
- {
- if (P)
- Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
- else
- Clock = VCO;
-
- freqErr = (Clock - ReqClock);
-
- if (freqErr < 0)
- {
- /* PixelClock gets rounded up always so monitor reports
- correct frequency. */
- if (IsPixClock)
- continue;
- freqErr = -freqErr;
- }
-
- if (freqErr < lowestFreqErr)
- {
- *rM = M;
- *rN = N;
- *rP = P;
- *rC = (VCO <= 1280000 ? 1 : 2);
- ActualClock = Clock;
-
- lowestFreqErr = freqErr;
- /* Return if we found an exact match */
- if (freqErr == 0)
- return (ActualClock);
- }
- }
- }
- }
-
- return (ActualClock);
-}
-
-void
-IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i, maxreg, dacreg;
-
- switch (ramdacPtr->RamDacType) {
- case IBM640_RAMDAC:
- maxreg = 0x300;
- dacreg = 1024;
- break;
- default:
- maxreg = 0x100;
- dacreg = 768;
- break;
- }
-
- /* Here we pass a short, so that we can evaluate a mask too */
- /* So that the mask is the high byte and the data the low byte */
- for (i=0;i<maxreg;i++)
- (*ramdacPtr->WriteDAC)
- (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
- ramdacReg->DacRegs[i]);
-
- (*ramdacPtr->WriteAddress)(pScrn, 0);
- for (i=0;i<dacreg;i++)
- (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
-}
-
-void
-IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i, maxreg, dacreg;
-
- switch (ramdacPtr->RamDacType) {
- case IBM640_RAMDAC:
- maxreg = 0x300;
- dacreg = 1024;
- break;
- default:
- maxreg = 0x100;
- dacreg = 768;
- break;
- }
-
- (*ramdacPtr->ReadAddress)(pScrn, 0);
- for (i=0;i<dacreg;i++)
- ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
-
- for (i=0;i<maxreg;i++)
- ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i);
-}
-
-RamDacHelperRecPtr
-IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- RamDacHelperRecPtr ramdacHelperPtr = NULL;
- Bool RamDacIsSupported = FALSE;
- int IBMramdac_ID = -1;
- int i;
- unsigned char id, rev, id2, rev2;
-
- /* read ID and revision */
- rev = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
- id = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
-
- /* check if ID and revision are read only */
- (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, IBMRGB_rev);
- (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, IBMRGB_id);
- rev2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
- id2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
-
- switch (id) {
- case 0x30:
- if (rev == 0xc0) IBMramdac_ID = IBM624_RAMDAC;
- if (rev == 0x80) IBMramdac_ID = IBM624DB_RAMDAC;
- break;
- case 0x12:
- if (rev == 0x1c) IBMramdac_ID = IBM640_RAMDAC;
- break;
- case 0x01:
- IBMramdac_ID = IBM525_RAMDAC;
- break;
- case 0x02:
- if (rev == 0xf0) IBMramdac_ID = IBM524_RAMDAC;
- if (rev == 0xe0) IBMramdac_ID = IBM524A_RAMDAC;
- if (rev == 0xc0) IBMramdac_ID = IBM526_RAMDAC;
- if (rev == 0x80) IBMramdac_ID = IBM526DB_RAMDAC;
- break;
- }
-
- if (id == 1 || id == 2) {
- if (id == id2 && rev == rev2) { /* IBM RGB52x found */
- /* check for 128bit VRAM -> RGB528 */
- if (((*ramdacPtr->ReadDAC)(pScrn, IBMRGB_misc1) & 0x03) == 0x03) {
- IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */
- if (rev == 0xe0)
- IBMramdac_ID = IBM528A_RAMDAC;
- }
- }
- }
-
- (*ramdacPtr->WriteDAC)(pScrn, rev, 0, IBMRGB_rev);
- (*ramdacPtr->WriteDAC)(pScrn, id, 0, IBMRGB_id);
-
- if (IBMramdac_ID == -1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Cannot determine IBM RAMDAC type, aborting\n");
- return NULL;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Attached RAMDAC is %s\n", IBMramdacDeviceInfo[IBMramdac_ID&0xFFFF].DeviceName);
- }
-
- for (i=0;ramdacs[i].token != -1;i++) {
- if (ramdacs[i].token == IBMramdac_ID)
- RamDacIsSupported = TRUE;
- }
-
- if (!RamDacIsSupported) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "This IBM RAMDAC is NOT supported by this driver, aborting\n");
- return NULL;
- }
-
- ramdacHelperPtr = RamDacHelperCreateInfoRec();
- switch (IBMramdac_ID) {
- case IBM526_RAMDAC:
- case IBM526DB_RAMDAC:
- ramdacHelperPtr->SetBpp = IBMramdac526SetBpp;
- ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit;
- break;
- case IBM640_RAMDAC:
- ramdacHelperPtr->SetBpp = IBMramdac640SetBpp;
- ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit;
- break;
- }
- ramdacPtr->RamDacType = IBMramdac_ID;
- ramdacHelperPtr->RamDacType = IBMramdac_ID;
- ramdacHelperPtr->Save = IBMramdacSave;
- ramdacHelperPtr->Restore = IBMramdacRestore;
-
- return ramdacHelperPtr;
-}
-
-void
-IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */
-
- switch (pScrn->bitsPerPixel) {
- case 32:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */
- ramdacReg->DacRegs[IBMRGB_key] = 0xFF;
- ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF;
- }
- break;
- case 24:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- break;
- case 16:
- if (pScrn->depth == 16) {
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
- B16_CONTIGUOUS | B16_565;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- } else {
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
- B16_CONTIGUOUS | B16_555;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- }
- break;
- case 8:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT;
- break;
- case 4:
- ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP;
- ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
- ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
- }
-}
-
-IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) {
- return IBMramdac526SetBpp;
-}
-
-void
-IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- unsigned char bpp = 0x00;
- unsigned char overlaybpp = 0x00;
- unsigned char offset = 0x00;
- unsigned char dispcont = 0x44;
-
- ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00;
- ramdacReg->DacRegs[RGB640_DIAGS] = 0x07;
-
- switch (pScrn->depth) {
- case 8:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x03;
- break;
- case 15:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x0E;
- break;
- case 16:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x05;
- break;
- case 24:
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x09;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04;
- ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF;
- ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF;
- offset = 0x04;
- overlaybpp = 0x04;
- dispcont = 0x48;
- }
- break;
- case 30: /* 10 bit dac */
- ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
- ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
- ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
- ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
- ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
- ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 |
- IBM640_PCLK_8; /* pll / 8 */
- bpp = 0x0D;
- break;
- }
-
- {
- int i;
- for (i=0x100;i<0x140;i+=4) {
- /* Initialize FrameBuffer Window Attribute Table */
- ramdacReg->DacRegs[i+0] = bpp;
- ramdacReg->DacRegs[i+1] = offset;
- ramdacReg->DacRegs[i+2] = 0x00;
- ramdacReg->DacRegs[i+3] = 0x00;
- /* Initialize Overlay Window Attribute Table */
- ramdacReg->DacRegs[i+0x100] = overlaybpp;
- ramdacReg->DacRegs[i+0x101] = 0x00;
- ramdacReg->DacRegs[i+0x102] = 0x00;
- ramdacReg->DacRegs[i+0x103] = dispcont;
- }
- }
-}
-
-static void
-IBMramdac526ShowCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Enable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x07);
-}
-
-static void
-IBMramdac640ShowCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Enable cursor - mode2 (x11 mode) */
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00);
-}
-
-static void
-IBMramdac526HideCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Disable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x24);
-}
-
-static void
-IBMramdac640HideCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Disable cursor - mode2 (x11 mode) */
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08);
-}
-
-static void
-IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- x += 64;
- y += 64;
-
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xl, 0x00, x & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xh, 0x00, (x>>8) & 0xf);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yl, 0x00, y & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yh, 0x00, (y>>8) & 0xf);
-}
-
-static void
-IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- x += 64;
- y += 64;
-
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_HIGH, 0x00, (x>>8) & 0xf);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_HIGH, 0x00, (y>>8) & 0xf);
-}
-
-static void
-IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_b, 0x00, bg);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8);
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_b, 0x00, fg);
-}
-
-static void
-IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_COL0, 0x00, 0);
- (*ramdacPtr->WriteData)(pScrn, fg>>16);
- (*ramdacPtr->WriteData)(pScrn, fg>>8);
- (*ramdacPtr->WriteData)(pScrn, fg);
- (*ramdacPtr->WriteData)(pScrn, bg>>16);
- (*ramdacPtr->WriteData)(pScrn, bg>>8);
- (*ramdacPtr->WriteData)(pScrn, bg);
- (*ramdacPtr->WriteData)(pScrn, fg>>16);
- (*ramdacPtr->WriteData)(pScrn, fg>>8);
- (*ramdacPtr->WriteData)(pScrn, fg);
- (*ramdacPtr->WriteData)(pScrn, bg>>16);
- (*ramdacPtr->WriteData)(pScrn, bg>>8);
- (*ramdacPtr->WriteData)(pScrn, bg);
-}
-
-static void
-IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- int i;
- /*
- * Output the cursor data. The realize function has put the planes into
- * their correct order, so we can just blast this out.
- */
- for (i = 0; i < 1024; i++)
- (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
-}
-
-static void
-IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- int i;
- /*
- * Output the cursor data. The realize function has put the planes into
- * their correct order, so we can just blast this out.
- */
- for (i = 0; i < 1024; i++)
- (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
-}
-
-static Bool
-IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
-{
- return TRUE;
-}
-
-static Bool
-IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
-{
- return TRUE;
-}
-
-void
-IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr)
-{
- infoPtr->MaxWidth = 64;
- infoPtr->MaxHeight = 64;
- infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
- infoPtr->SetCursorColors = IBMramdac526SetCursorColors;
- infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition;
- infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage;
- infoPtr->HideCursor = IBMramdac526HideCursor;
- infoPtr->ShowCursor = IBMramdac526ShowCursor;
- infoPtr->UseHWCursor = IBMramdac526UseHWCursor;
-}
-
-void
-IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr)
-{
- infoPtr->MaxWidth = 64;
- infoPtr->MaxHeight = 64;
- infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
- HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
- infoPtr->SetCursorColors = IBMramdac640SetCursorColors;
- infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition;
- infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage;
- infoPtr->HideCursor = IBMramdac640HideCursor;
- infoPtr->ShowCursor = IBMramdac640ShowCursor;
- infoPtr->UseHWCursor = IBMramdac640UseHWCursor;
-}
+/*
+ * Copyright 1998 by Alan Hourihane, Wigan, England.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * IBM RAMDAC routines.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xf86Cursor.h"
+
+#define INIT_IBM_RAMDAC_INFO
+#include "IBMPriv.h"
+#include "xf86RamDacPriv.h"
+
+#define INITIALFREQERR 100000
+
+unsigned long
+IBMramdac640CalculateMNPCForClock(
+ unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP, /* Min P In, P Out */
+ unsigned long *rC /* C Out */
+)
+{
+ unsigned long M, N, P, iP = *rP;
+ unsigned long IntRef, VCO, Clock;
+ long freqErr, lowestFreqErr = INITIALFREQERR;
+ unsigned long ActualClock = 0;
+
+ for (N = 0; N <= 63; N++)
+ {
+ IntRef = RefClock / (N + 1);
+ if (IntRef < 10000)
+ break; /* IntRef needs to be >= 1MHz */
+ for (M = 2; M <= 127; M++)
+ {
+ VCO = IntRef * (M + 1);
+ if ((VCO < MinClock) || (VCO > MaxClock))
+ continue;
+ for (P = iP; P <= 4; P++)
+ {
+ if (P != 0)
+ Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
+ else
+ Clock = (RefClock * (M + 1)) / (N + 1);
+
+ freqErr = (Clock - ReqClock);
+
+ if (freqErr < 0)
+ {
+ /* PixelClock gets rounded up always so monitor reports
+ correct frequency. */
+ if (IsPixClock)
+ continue;
+ freqErr = -freqErr;
+ }
+
+ if (freqErr < lowestFreqErr)
+ {
+ *rM = M;
+ *rN = N;
+ *rP = P;
+ *rC = (VCO <= 1280000 ? 1 : 2);
+ ActualClock = Clock;
+
+ lowestFreqErr = freqErr;
+ /* Return if we found an exact match */
+ if (freqErr == 0)
+ return ActualClock;
+ }
+ }
+ }
+ }
+
+ return ActualClock;
+}
+
+unsigned long
+IBMramdac526CalculateMNPCForClock(
+ unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP, /* Min P In, P Out */
+ unsigned long *rC /* C Out */
+)
+{
+ unsigned long M, N, P, iP = *rP;
+ unsigned long IntRef, VCO, Clock;
+ long freqErr, lowestFreqErr = INITIALFREQERR;
+ unsigned long ActualClock = 0;
+
+ for (N = 0; N <= 63; N++)
+ {
+ IntRef = RefClock / (N + 1);
+ if (IntRef < 10000)
+ break; /* IntRef needs to be >= 1MHz */
+ for (M = 0; M <= 63; M++)
+ {
+ VCO = IntRef * (M + 1);
+ if ((VCO < MinClock) || (VCO > MaxClock))
+ continue;
+ for (P = iP; P <= 4; P++)
+ {
+ if (P)
+ Clock = (RefClock * (M + 1)) / ((N + 1) * 2 * P);
+ else
+ Clock = VCO;
+
+ freqErr = (Clock - ReqClock);
+
+ if (freqErr < 0)
+ {
+ /* PixelClock gets rounded up always so monitor reports
+ correct frequency. */
+ if (IsPixClock)
+ continue;
+ freqErr = -freqErr;
+ }
+
+ if (freqErr < lowestFreqErr)
+ {
+ *rM = M;
+ *rN = N;
+ *rP = P;
+ *rC = (VCO <= 1280000 ? 1 : 2);
+ ActualClock = Clock;
+
+ lowestFreqErr = freqErr;
+ /* Return if we found an exact match */
+ if (freqErr == 0)
+ return ActualClock;
+ }
+ }
+ }
+ }
+
+ return ActualClock;
+}
+
+void
+IBMramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i, maxreg, dacreg;
+
+ switch (ramdacPtr->RamDacType) {
+ case IBM640_RAMDAC:
+ maxreg = 0x300;
+ dacreg = 1024;
+ break;
+ default:
+ maxreg = 0x100;
+ dacreg = 768;
+ break;
+ }
+
+ /* Here we pass a short, so that we can evaluate a mask too */
+ /* So that the mask is the high byte and the data the low byte */
+ for (i=0;i<maxreg;i++)
+ (*ramdacPtr->WriteDAC)
+ (pScrn, i, (ramdacReg->DacRegs[i] & 0xFF00) >> 8,
+ ramdacReg->DacRegs[i]);
+
+ (*ramdacPtr->WriteAddress)(pScrn, 0);
+ for (i=0;i<dacreg;i++)
+ (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
+}
+
+void
+IBMramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i, maxreg, dacreg;
+
+ switch (ramdacPtr->RamDacType) {
+ case IBM640_RAMDAC:
+ maxreg = 0x300;
+ dacreg = 1024;
+ break;
+ default:
+ maxreg = 0x100;
+ dacreg = 768;
+ break;
+ }
+
+ (*ramdacPtr->ReadAddress)(pScrn, 0);
+ for (i=0;i<dacreg;i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
+
+ for (i=0;i<maxreg;i++)
+ ramdacReg->DacRegs[i] = (*ramdacPtr->ReadDAC)(pScrn, i);
+}
+
+RamDacHelperRecPtr
+IBMramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ RamDacHelperRecPtr ramdacHelperPtr = NULL;
+ Bool RamDacIsSupported = FALSE;
+ int IBMramdac_ID = -1;
+ int i;
+ unsigned char id, rev, id2, rev2;
+
+ /* read ID and revision */
+ rev = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
+ id = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
+
+ /* check if ID and revision are read only */
+ (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, IBMRGB_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, IBMRGB_id);
+ rev2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_rev);
+ id2 = (*ramdacPtr->ReadDAC)(pScrn, IBMRGB_id);
+
+ switch (id) {
+ case 0x30:
+ if (rev == 0xc0) IBMramdac_ID = IBM624_RAMDAC;
+ if (rev == 0x80) IBMramdac_ID = IBM624DB_RAMDAC;
+ break;
+ case 0x12:
+ if (rev == 0x1c) IBMramdac_ID = IBM640_RAMDAC;
+ break;
+ case 0x01:
+ IBMramdac_ID = IBM525_RAMDAC;
+ break;
+ case 0x02:
+ if (rev == 0xf0) IBMramdac_ID = IBM524_RAMDAC;
+ if (rev == 0xe0) IBMramdac_ID = IBM524A_RAMDAC;
+ if (rev == 0xc0) IBMramdac_ID = IBM526_RAMDAC;
+ if (rev == 0x80) IBMramdac_ID = IBM526DB_RAMDAC;
+ break;
+ }
+
+ if (id == 1 || id == 2) {
+ if (id == id2 && rev == rev2) { /* IBM RGB52x found */
+ /* check for 128bit VRAM -> RGB528 */
+ if (((*ramdacPtr->ReadDAC)(pScrn, IBMRGB_misc1) & 0x03) == 0x03) {
+ IBMramdac_ID = IBM528_RAMDAC; /* 128bit DAC found */
+ if (rev == 0xe0)
+ IBMramdac_ID = IBM528A_RAMDAC;
+ }
+ }
+ }
+
+ (*ramdacPtr->WriteDAC)(pScrn, rev, 0, IBMRGB_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, id, 0, IBMRGB_id);
+
+ if (IBMramdac_ID == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine IBM RAMDAC type, aborting\n");
+ return NULL;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n", IBMramdacDeviceInfo[IBMramdac_ID&0xFFFF].DeviceName);
+ }
+
+ for (i=0;ramdacs[i].token != -1;i++) {
+ if (ramdacs[i].token == IBMramdac_ID)
+ RamDacIsSupported = TRUE;
+ }
+
+ if (!RamDacIsSupported) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This IBM RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
+ }
+
+ ramdacHelperPtr = RamDacHelperCreateInfoRec();
+ switch (IBMramdac_ID) {
+ case IBM526_RAMDAC:
+ case IBM526DB_RAMDAC:
+ ramdacHelperPtr->SetBpp = IBMramdac526SetBpp;
+ ramdacHelperPtr->HWCursorInit = IBMramdac526HWCursorInit;
+ break;
+ case IBM640_RAMDAC:
+ ramdacHelperPtr->SetBpp = IBMramdac640SetBpp;
+ ramdacHelperPtr->HWCursorInit = IBMramdac640HWCursorInit;
+ break;
+ }
+ ramdacPtr->RamDacType = IBMramdac_ID;
+ ramdacHelperPtr->RamDacType = IBMramdac_ID;
+ ramdacHelperPtr->Save = IBMramdacSave;
+ ramdacHelperPtr->Restore = IBMramdacRestore;
+
+ return ramdacHelperPtr;
+}
+
+void
+IBMramdac526SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ ramdacReg->DacRegs[IBMRGB_key_control] = 0x00; /* Disable Chroma Key */
+
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_32BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = B32_DCOL_DIRECT;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[IBMRGB_key_control] = 0x01; /* Enable Key */
+ ramdacReg->DacRegs[IBMRGB_key] = 0xFF;
+ ramdacReg->DacRegs[IBMRGB_key_mask] = 0xFF;
+ }
+ break;
+ case 24:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_24BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = B24_DCOL_DIRECT;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ break;
+ case 16:
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
+ B16_CONTIGUOUS | B16_565;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ } else {
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_16BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = B16_DCOL_DIRECT|B16_LINEAR |
+ B16_CONTIGUOUS | B16_555;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+ break;
+ case 8:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_8BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = B8_DCOL_INDIRECT;
+ break;
+ case 4:
+ ramdacReg->DacRegs[IBMRGB_pix_fmt] = PIXEL_FORMAT_4BPP;
+ ramdacReg->DacRegs[IBMRGB_32bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_24bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_16bpp] = 0;
+ ramdacReg->DacRegs[IBMRGB_8bpp] = 0;
+ }
+}
+
+IBMramdac526SetBppProc *IBMramdac526SetBppWeak(void) {
+ return IBMramdac526SetBpp;
+}
+
+void
+IBMramdac640SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ unsigned char bpp = 0x00;
+ unsigned char overlaybpp = 0x00;
+ unsigned char offset = 0x00;
+ unsigned char dispcont = 0x44;
+
+ ramdacReg->DacRegs[RGB640_SER_WID_03_00] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x00;
+ ramdacReg->DacRegs[RGB640_DIAGS] = 0x07;
+
+ switch (pScrn->depth) {
+ case 8:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_16_1; /*16:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x03;
+ break;
+ case 15:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x0E;
+ break;
+ case 16:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x10;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x11;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x00;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_8_1; /* 8:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x05;
+ break;
+ case 24:
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x09;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[RGB640_SER_WID_07_04] = 0x04;
+ ramdacReg->DacRegs[RGB640_CHROMA_KEY0] = 0xFF;
+ ramdacReg->DacRegs[RGB640_CHROMA_MASK0] = 0xFF;
+ offset = 0x04;
+ overlaybpp = 0x04;
+ dispcont = 0x48;
+ }
+ break;
+ case 30: /* 10 bit dac */
+ ramdacReg->DacRegs[RGB640_SER_07_00] = 0x30;
+ ramdacReg->DacRegs[RGB640_SER_15_08] = 0x31;
+ ramdacReg->DacRegs[RGB640_SER_23_16] = 0x32;
+ ramdacReg->DacRegs[RGB640_SER_31_24] = 0x33;
+ ramdacReg->DacRegs[RGB640_SER_MODE] = IBM640_SER_4_1; /* 4:1 Mux*/
+ ramdacReg->DacRegs[RGB640_MISC_CONF] = IBM640_PSIZE10 |
+ IBM640_PCLK_8; /* pll / 8 */
+ bpp = 0x0D;
+ break;
+ }
+
+ {
+ int i;
+ for (i=0x100;i<0x140;i+=4) {
+ /* Initialize FrameBuffer Window Attribute Table */
+ ramdacReg->DacRegs[i+0] = bpp;
+ ramdacReg->DacRegs[i+1] = offset;
+ ramdacReg->DacRegs[i+2] = 0x00;
+ ramdacReg->DacRegs[i+3] = 0x00;
+ /* Initialize Overlay Window Attribute Table */
+ ramdacReg->DacRegs[i+0x100] = overlaybpp;
+ ramdacReg->DacRegs[i+0x101] = 0x00;
+ ramdacReg->DacRegs[i+0x102] = 0x00;
+ ramdacReg->DacRegs[i+0x103] = dispcont;
+ }
+ }
+}
+
+static void
+IBMramdac526ShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x07);
+}
+
+static void
+IBMramdac640ShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - mode2 (x11 mode) */
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x0B);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CROSSHAIR_CONTROL, 0x00, 0x00);
+}
+
+static void
+IBMramdac526HideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs, 0x00, 0x24);
+}
+
+static void
+IBMramdac640HideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - mode2 (x11 mode) */
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURSOR_CONTROL, 0x00, 0x08);
+}
+
+static void
+IBMramdac526SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_x, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_hot_y, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xl, 0x00, x & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_xh, 0x00, (x>>8) & 0xf);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yl, 0x00, y & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_yh, 0x00, (y>>8) & 0xf);
+}
+
+static void
+IBMramdac640SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETX, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_OFFSETY, 0x00, 0x3f);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_LOW, 0x00, x & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_X_HIGH, 0x00, (x>>8) & 0xf);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_LOW, 0x00, y & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_Y_HIGH, 0x00, (y>>8) & 0xf);
+}
+
+static void
+IBMramdac526SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_r, 0x00, bg >> 16);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_g, 0x00, bg >> 8);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col1_b, 0x00, bg);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_r, 0x00, fg >> 16);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_g, 0x00, fg >> 8);
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_col2_b, 0x00, fg);
+}
+
+static void
+IBMramdac640SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_COL0, 0x00, 0);
+ (*ramdacPtr->WriteData)(pScrn, fg>>16);
+ (*ramdacPtr->WriteData)(pScrn, fg>>8);
+ (*ramdacPtr->WriteData)(pScrn, fg);
+ (*ramdacPtr->WriteData)(pScrn, bg>>16);
+ (*ramdacPtr->WriteData)(pScrn, bg>>8);
+ (*ramdacPtr->WriteData)(pScrn, bg);
+ (*ramdacPtr->WriteData)(pScrn, fg>>16);
+ (*ramdacPtr->WriteData)(pScrn, fg>>8);
+ (*ramdacPtr->WriteData)(pScrn, fg);
+ (*ramdacPtr->WriteData)(pScrn, bg>>16);
+ (*ramdacPtr->WriteData)(pScrn, bg>>8);
+ (*ramdacPtr->WriteData)(pScrn, bg);
+}
+
+static void
+IBMramdac526LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i;
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ for (i = 0; i < 1024; i++)
+ (*ramdacPtr->WriteDAC)(pScrn, IBMRGB_curs_array + i, 0x00, (*src++));
+}
+
+static void
+IBMramdac640LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i;
+ /*
+ * Output the cursor data. The realize function has put the planes into
+ * their correct order, so we can just blast this out.
+ */
+ for (i = 0; i < 1024; i++)
+ (*ramdacPtr->WriteDAC)(pScrn, RGB640_CURS_WRITE + i, 0x00, (*src++));
+}
+
+static Bool
+IBMramdac526UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+static Bool
+IBMramdac640UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+void
+IBMramdac526HWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = IBMramdac526SetCursorColors;
+ infoPtr->SetCursorPosition = IBMramdac526SetCursorPosition;
+ infoPtr->LoadCursorImage = IBMramdac526LoadCursorImage;
+ infoPtr->HideCursor = IBMramdac526HideCursor;
+ infoPtr->ShowCursor = IBMramdac526ShowCursor;
+ infoPtr->UseHWCursor = IBMramdac526UseHWCursor;
+}
+
+void
+IBMramdac640HWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = IBMramdac640SetCursorColors;
+ infoPtr->SetCursorPosition = IBMramdac640SetCursorPosition;
+ infoPtr->LoadCursorImage = IBMramdac640LoadCursorImage;
+ infoPtr->HideCursor = IBMramdac640HideCursor;
+ infoPtr->ShowCursor = IBMramdac640ShowCursor;
+ infoPtr->UseHWCursor = IBMramdac640UseHWCursor;
+}
diff --git a/xorg-server/hw/xfree86/ramdac/TI.c b/xorg-server/hw/xfree86/ramdac/TI.c
index 1c541d76b..f189fed25 100644
--- a/xorg-server/hw/xfree86/ramdac/TI.c
+++ b/xorg-server/hw/xfree86/ramdac/TI.c
@@ -1,717 +1,717 @@
-/*
- * Copyright 1998 by Alan Hourihane, Wigan, England.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
- *
- * Modified from IBM.c to support TI RAMDAC routines
- * by Jens Owen, <jens@tungstengraphics.com>.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "xf86Cursor.h"
-
-#define INIT_TI_RAMDAC_INFO
-#include "TIPriv.h"
-#include "xf86RamDacPriv.h"
-
-/* The following values are in kHz */
-#define TI_MIN_VCO_FREQ 110000
-#define TI_MAX_VCO_FREQ 220000
-
-unsigned long
-TIramdacCalculateMNPForClock(
- unsigned long RefClock, /* In 100Hz units */
- unsigned long ReqClock, /* In 100Hz units */
- char IsPixClock, /* boolean, is this the pixel or the sys clock */
- unsigned long MinClock, /* Min VCO rating */
- unsigned long MaxClock, /* Max VCO rating */
- unsigned long *rM, /* M Out */
- unsigned long *rN, /* N Out */
- unsigned long *rP /* Min P In, P Out */
-)
-{
- unsigned long n, p;
- unsigned long best_m = 0, best_n = 0;
- double VCO, IntRef = (double)RefClock;
- double m_err, inc_m, calc_m;
- unsigned long ActualClock;
-
- /* Make sure that MinClock <= ReqClock <= MaxClock */
- if ( ReqClock < MinClock)
- ReqClock = MinClock;
- if ( ReqClock > MaxClock )
- ReqClock = MaxClock;
-
- /*
- * ActualClock = VCO / 2 ^ p
- * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ
- * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ
- * we don't have to bother checking for this maximum limit.
- */
- VCO = (double)ReqClock;
- for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ )
- VCO *= 2.0;
-
- /*
- * We avoid doing multiplications by ( 65 - n ),
- * and add an increment instead - this keeps any error small.
- */
- inc_m = VCO / ( IntRef * 8.0 );
-
- /* Initial value of calc_m for the loop */
- calc_m = inc_m + inc_m + inc_m;
-
- /* Initial amount of error for an integer - impossibly large */
- m_err = 2.0;
-
- /* Search for the closest INTEGER value of ( 65 - m ) */
- for ( n = 3; n <= 25; ( n )++, calc_m += inc_m ) {
-
- /* Ignore values of ( 65 - m ) which we can't use */
- if ( calc_m < 3.0 || calc_m > 64.0 )
- continue;
-
- /*
- * Pick the closest INTEGER (has smallest fractional part).
- * The optimizer should clean this up for us.
- */
- if (( calc_m - ( int ) calc_m ) < m_err ) {
- m_err = calc_m - ( int ) calc_m;
- best_m = ( int ) calc_m;
- best_n = n;
- }
- }
-
- /* 65 - ( 65 - x ) = x */
- *rM = 65 - best_m;
- *rN = 65 - best_n;
- *rP = p;
-
- /* Now all the calculations can be completed */
- VCO = 8.0 * IntRef * best_m / best_n;
- ActualClock = VCO / ( 1 << p );
-
- DebugF( "f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n",
- ActualClock, VCO, *rN, *rM, *rP);
-
- return (ActualClock);
-}
-
-void
-TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i;
- unsigned long status;
-
- /* Here we pass a short, so that we can evaluate a mask too
- * So that the mask is the high byte and the data the low byte
- * Order is important
- */
- TIRESTORE(TIDAC_latch_ctrl);
- TIRESTORE(TIDAC_true_color_ctrl);
- TIRESTORE(TIDAC_multiplex_ctrl);
- TIRESTORE(TIDAC_clock_select);
- TIRESTORE(TIDAC_palette_page);
- TIRESTORE(TIDAC_general_ctrl);
- TIRESTORE(TIDAC_misc_ctrl);
- /* 0x2A & 0x2B are reserved */
- TIRESTORE(TIDAC_key_over_low);
- TIRESTORE(TIDAC_key_over_high);
- TIRESTORE(TIDAC_key_red_low);
- TIRESTORE(TIDAC_key_red_high);
- TIRESTORE(TIDAC_key_green_low);
- TIRESTORE(TIDAC_key_green_high);
- TIRESTORE(TIDAC_key_blue_low);
- TIRESTORE(TIDAC_key_blue_high);
- TIRESTORE(TIDAC_key_ctrl);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x30);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x38);
- TIRESTORE(TIDAC_clock_ctrl);
- TIRESTORE(TIDAC_sense_test);
- TIRESTORE(TIDAC_ind_curs_ctrl);
-
- /* only restore clocks if they were valid to begin with */
-
- if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) {
- /* Reset pixel clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, 0x3c);
-
- /* Restore N, M & P values for pixel clocks */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
- ramdacReg->DacRegs[TIDAC_PIXEL_N]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
- ramdacReg->DacRegs[TIDAC_PIXEL_M]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
- ramdacReg->DacRegs[TIDAC_PIXEL_P]);
-
- /* wait for pixel clock to lock */
- i = 1000000;
- do {
- status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- } while ((!(status & 0x40)) && (--i));
- if (!(status & 0x40)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Pixel clock setup timed out\n");
- return;
- }
- }
-
- if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) {
- /* Reset loop clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, 0x70);
-
- /* Restore N, M & P values for pixel clocks */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
- ramdacReg->DacRegs[TIDAC_LOOP_N]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
- ramdacReg->DacRegs[TIDAC_LOOP_M]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
- ramdacReg->DacRegs[TIDAC_LOOP_P]);
-
- /* wait for loop clock to lock */
- i = 1000000;
- do {
- status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- } while ((!(status & 0x40)) && (--i));
- if (!(status & 0x40)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Loop clock setup timed out\n");
- return;
- }
- }
-
- /* restore palette */
- (*ramdacPtr->WriteAddress)(pScrn, 0);
-#ifndef NOT_DONE
- for (i=0;i<768;i++)
- (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
-#else
- (*ramdacPtr->WriteData)(pScrn, 0);
- (*ramdacPtr->WriteData)(pScrn, 0);
- (*ramdacPtr->WriteData)(pScrn, 0);
- for (i=0;i<765;i++)
- (*ramdacPtr->WriteData)(pScrn, 0xff);
-#endif
-}
-
-void
-TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
- RamDacRegRecPtr ramdacReg)
-{
- int i;
-
- (*ramdacPtr->ReadAddress)(pScrn, 0);
- for (i=0;i<768;i++)
- ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
-
- /* Read back N,M and P values for pixel clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- ramdacReg->DacRegs[TIDAC_PIXEL_N] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
- ramdacReg->DacRegs[TIDAC_PIXEL_M] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- ramdacReg->DacRegs[TIDAC_PIXEL_P] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
-
- /* Read back N,M and P values for loop clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- ramdacReg->DacRegs[TIDAC_LOOP_N] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
- ramdacReg->DacRegs[TIDAC_LOOP_M] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- ramdacReg->DacRegs[TIDAC_LOOP_P] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
-
- /* Order is important */
- TISAVE(TIDAC_latch_ctrl);
- TISAVE(TIDAC_true_color_ctrl);
- TISAVE(TIDAC_multiplex_ctrl);
- TISAVE(TIDAC_clock_select);
- TISAVE(TIDAC_palette_page);
- TISAVE(TIDAC_general_ctrl);
- TISAVE(TIDAC_misc_ctrl);
- /* 0x2A & 0x2B are reserved */
- TISAVE(TIDAC_key_over_low);
- TISAVE(TIDAC_key_over_high);
- TISAVE(TIDAC_key_red_low);
- TISAVE(TIDAC_key_red_high);
- TISAVE(TIDAC_key_green_low);
- TISAVE(TIDAC_key_green_high);
- TISAVE(TIDAC_key_blue_low);
- TISAVE(TIDAC_key_blue_high);
- TISAVE(TIDAC_key_ctrl);
- TISAVE(TIDAC_clock_ctrl);
- TISAVE(TIDAC_sense_test);
- TISAVE(TIDAC_ind_curs_ctrl);
-}
-
-RamDacHelperRecPtr
-TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- RamDacHelperRecPtr ramdacHelperPtr = NULL;
- Bool RamDacIsSupported = FALSE;
- int TIramdac_ID = -1;
- int i;
- unsigned char id, rev, rev2, id2;
-
- /* read ID and revision */
- rev = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
- id = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
-
- /* check if ID and revision are read only */
- (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, TIDAC_rev);
- (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, TIDAC_id);
- rev2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
- id2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
-
- switch (id) {
- case TIDAC_TVP_3030_ID:
- if (id == id2 && rev == rev2) /* check for READ ONLY */
- TIramdac_ID = TI3030_RAMDAC;
- break;
- case TIDAC_TVP_3026_ID:
- if (id == id2 && rev == rev2) /* check for READ ONLY */
- TIramdac_ID = TI3026_RAMDAC;
- break;
- }
-
- (*ramdacPtr->WriteDAC)(pScrn, rev, 0, TIDAC_rev);
- (*ramdacPtr->WriteDAC)(pScrn, id, 0, TIDAC_id);
-
- if (TIramdac_ID == -1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Cannot determine TI RAMDAC type, aborting\n");
- return NULL;
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Attached RAMDAC is %s\n", TIramdacDeviceInfo[TIramdac_ID&0xFFFF].DeviceName);
- }
-
- for (i=0;ramdacs[i].token != -1;i++) {
- if (ramdacs[i].token == TIramdac_ID)
- RamDacIsSupported = TRUE;
- }
-
- if (!RamDacIsSupported) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "This TI RAMDAC is NOT supported by this driver, aborting\n");
- return NULL;
- }
-
- ramdacHelperPtr = RamDacHelperCreateInfoRec();
- switch (TIramdac_ID) {
- case TI3030_RAMDAC:
- ramdacHelperPtr->SetBpp = TIramdac3030SetBpp;
- ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
- break;
- case TI3026_RAMDAC:
- ramdacHelperPtr->SetBpp = TIramdac3026SetBpp;
- ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
- break;
- }
- ramdacPtr->RamDacType = TIramdac_ID;
- ramdacHelperPtr->RamDacType = TIramdac_ID;
- ramdacHelperPtr->Save = TIramdacSave;
- ramdacHelperPtr->Restore = TIramdacRestore;
-
- return ramdacHelperPtr;
-}
-
-void
-TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- switch (pScrn->bitsPerPixel) {
- case 32:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
- }
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 24:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 16:
- /* order is important */
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
-#else
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
-#endif
- if (pScrn->depth == 16) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
- } else {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
- }
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
-#else
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
-#endif
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 8:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- }
-}
-
-void
-TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
-{
- switch (pScrn->bitsPerPixel) {
- case 32:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
- }
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 24:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 16:
- /* order is important */
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
-#else
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
-#endif
- if (pScrn->depth == 16) {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
- } else {
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
- }
-#if 0
- /* Matrox driver uses this */
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
-#else
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x85;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
-#endif
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- case 8:
- /* order is important */
- ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
- ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
- ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
- ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
- /* 0x2A & 0x2B are reserved */
- ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
- ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
- ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
- break;
- }
-}
-
-static void
-TIramdacShowCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Enable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03);
-}
-
-static void
-TIramdacHideCursor(ScrnInfoPtr pScrn)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Disable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
-}
-
-static void
-TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- x += 64;
- y += 64;
-
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XLOW, 0, x & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YLOW, 0, y & 0xff);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f);
-}
-
-static void
-TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
-
- /* Background color */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x00ff0000) >> 16));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x0000ff00) >> 8));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (bg&0x000000ff) );
-
- /* Foreground color */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x00ff0000) >> 16));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x0000ff00) >> 8));
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (fg&0x000000ff) );
-}
-
-static void
-TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
-{
- RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
- int i = 1024;
-
- /* reset A9,A8 */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
- /* reset cursor RAM load address A7..A0 */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_INDEX, 0x00, 0x00);
-
- while(i--) {
- /* NOT_DONE: might need a delay here */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
- }
-}
-
-static Bool
-TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
-{
- return TRUE;
-}
-
-void
-TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr)
-{
- infoPtr->MaxWidth = 64;
- infoPtr->MaxHeight = 64;
- infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
- HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
- HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
- infoPtr->SetCursorColors = TIramdacSetCursorColors;
- infoPtr->SetCursorPosition = TIramdacSetCursorPosition;
- infoPtr->LoadCursorImage = TIramdacLoadCursorImage;
- infoPtr->HideCursor = TIramdacHideCursor;
- infoPtr->ShowCursor = TIramdacShowCursor;
- infoPtr->UseHWCursor = TIramdacUseHWCursor;
-}
-
-void TIramdacLoadPalette(
- ScrnInfoPtr pScrn,
- int numColors,
- int *indices,
- LOCO *colors,
- VisualPtr pVisual
-){
- RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
- int i, index, shift;
-
- if (pScrn->depth == 16) {
- for(i = 0; i < numColors; i++) {
- index = indices[i];
- (*hwp->WriteAddress)(pScrn, index << 2);
- (*hwp->WriteData)(pScrn, colors[index >> 1].red);
- (*hwp->WriteData)(pScrn, colors[index].green);
- (*hwp->WriteData)(pScrn, colors[index >> 1].blue);
-
- if(index <= 31) {
- (*hwp->WriteAddress)(pScrn, index << 3);
- (*hwp->WriteData)(pScrn, colors[index].red);
- (*hwp->WriteData)(pScrn, colors[(index << 1) + 1].green);
- (*hwp->WriteData)(pScrn, colors[index].blue);
- }
- }
-} else {
- shift = (pScrn->depth == 15) ? 3 : 0;
-
- for(i = 0; i < numColors; i++) {
- index = indices[i];
- (*hwp->WriteAddress)(pScrn, index << shift);
- (*hwp->WriteData)(pScrn, colors[index].red);
- (*hwp->WriteData)(pScrn, colors[index].green);
- (*hwp->WriteData)(pScrn, colors[index].blue);
- }
-}
-}
-
-TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) {
- return TIramdacLoadPalette;
-}
+/*
+ * Copyright 1998 by Alan Hourihane, Wigan, England.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Alan Hourihane not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Alan Hourihane makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
+ *
+ * Modified from IBM.c to support TI RAMDAC routines
+ * by Jens Owen, <jens@tungstengraphics.com>.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "xf86Cursor.h"
+
+#define INIT_TI_RAMDAC_INFO
+#include "TIPriv.h"
+#include "xf86RamDacPriv.h"
+
+/* The following values are in kHz */
+#define TI_MIN_VCO_FREQ 110000
+#define TI_MAX_VCO_FREQ 220000
+
+unsigned long
+TIramdacCalculateMNPForClock(
+ unsigned long RefClock, /* In 100Hz units */
+ unsigned long ReqClock, /* In 100Hz units */
+ char IsPixClock, /* boolean, is this the pixel or the sys clock */
+ unsigned long MinClock, /* Min VCO rating */
+ unsigned long MaxClock, /* Max VCO rating */
+ unsigned long *rM, /* M Out */
+ unsigned long *rN, /* N Out */
+ unsigned long *rP /* Min P In, P Out */
+)
+{
+ unsigned long n, p;
+ unsigned long best_m = 0, best_n = 0;
+ double VCO, IntRef = (double)RefClock;
+ double m_err, inc_m, calc_m;
+ unsigned long ActualClock;
+
+ /* Make sure that MinClock <= ReqClock <= MaxClock */
+ if ( ReqClock < MinClock)
+ ReqClock = MinClock;
+ if ( ReqClock > MaxClock )
+ ReqClock = MaxClock;
+
+ /*
+ * ActualClock = VCO / 2 ^ p
+ * Choose p so that TI_MIN_VCO_FREQ <= VCO <= TI_MAX_VCO_FREQ
+ * Note that since TI_MAX_VCO_FREQ = 2 * TI_MIN_VCO_FREQ
+ * we don't have to bother checking for this maximum limit.
+ */
+ VCO = (double)ReqClock;
+ for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ )
+ VCO *= 2.0;
+
+ /*
+ * We avoid doing multiplications by ( 65 - n ),
+ * and add an increment instead - this keeps any error small.
+ */
+ inc_m = VCO / ( IntRef * 8.0 );
+
+ /* Initial value of calc_m for the loop */
+ calc_m = inc_m + inc_m + inc_m;
+
+ /* Initial amount of error for an integer - impossibly large */
+ m_err = 2.0;
+
+ /* Search for the closest INTEGER value of ( 65 - m ) */
+ for ( n = 3; n <= 25; ( n )++, calc_m += inc_m ) {
+
+ /* Ignore values of ( 65 - m ) which we can't use */
+ if ( calc_m < 3.0 || calc_m > 64.0 )
+ continue;
+
+ /*
+ * Pick the closest INTEGER (has smallest fractional part).
+ * The optimizer should clean this up for us.
+ */
+ if (( calc_m - ( int ) calc_m ) < m_err ) {
+ m_err = calc_m - ( int ) calc_m;
+ best_m = ( int ) calc_m;
+ best_n = n;
+ }
+ }
+
+ /* 65 - ( 65 - x ) = x */
+ *rM = 65 - best_m;
+ *rN = 65 - best_n;
+ *rP = p;
+
+ /* Now all the calculations can be completed */
+ VCO = 8.0 * IntRef * best_m / best_n;
+ ActualClock = VCO / ( 1 << p );
+
+ DebugF( "f_out=%ld f_vco=%.1f n=%d m=%d p=%d\n",
+ ActualClock, VCO, *rN, *rM, *rP);
+
+ return ActualClock;
+}
+
+void
+TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i;
+ unsigned long status;
+
+ /* Here we pass a short, so that we can evaluate a mask too
+ * So that the mask is the high byte and the data the low byte
+ * Order is important
+ */
+ TIRESTORE(TIDAC_latch_ctrl);
+ TIRESTORE(TIDAC_true_color_ctrl);
+ TIRESTORE(TIDAC_multiplex_ctrl);
+ TIRESTORE(TIDAC_clock_select);
+ TIRESTORE(TIDAC_palette_page);
+ TIRESTORE(TIDAC_general_ctrl);
+ TIRESTORE(TIDAC_misc_ctrl);
+ /* 0x2A & 0x2B are reserved */
+ TIRESTORE(TIDAC_key_over_low);
+ TIRESTORE(TIDAC_key_over_high);
+ TIRESTORE(TIDAC_key_red_low);
+ TIRESTORE(TIDAC_key_red_high);
+ TIRESTORE(TIDAC_key_green_low);
+ TIRESTORE(TIDAC_key_green_high);
+ TIRESTORE(TIDAC_key_blue_low);
+ TIRESTORE(TIDAC_key_blue_high);
+ TIRESTORE(TIDAC_key_ctrl);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x30);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_clock_ctrl, 0, 0x38);
+ TIRESTORE(TIDAC_clock_ctrl);
+ TIRESTORE(TIDAC_sense_test);
+ TIRESTORE(TIDAC_ind_curs_ctrl);
+
+ /* only restore clocks if they were valid to begin with */
+
+ if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) {
+ /* Reset pixel clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0, 0x3c);
+
+ /* Restore N, M & P values for pixel clocks */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_N]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_M]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ ramdacReg->DacRegs[TIDAC_PIXEL_P]);
+
+ /* wait for pixel clock to lock */
+ i = 1000000;
+ do {
+ status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+ } while ((!(status & 0x40)) && (--i));
+ if (!(status & 0x40)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Pixel clock setup timed out\n");
+ return;
+ }
+ }
+
+ if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) {
+ /* Reset loop clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0, 0x70);
+
+ /* Restore N, M & P values for pixel clocks */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_N]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_M]);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ ramdacReg->DacRegs[TIDAC_LOOP_P]);
+
+ /* wait for loop clock to lock */
+ i = 1000000;
+ do {
+ status = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+ } while ((!(status & 0x40)) && (--i));
+ if (!(status & 0x40)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Loop clock setup timed out\n");
+ return;
+ }
+ }
+
+ /* restore palette */
+ (*ramdacPtr->WriteAddress)(pScrn, 0);
+#ifndef NOT_DONE
+ for (i=0;i<768;i++)
+ (*ramdacPtr->WriteData)(pScrn, ramdacReg->DAC[i]);
+#else
+ (*ramdacPtr->WriteData)(pScrn, 0);
+ (*ramdacPtr->WriteData)(pScrn, 0);
+ (*ramdacPtr->WriteData)(pScrn, 0);
+ for (i=0;i<765;i++)
+ (*ramdacPtr->WriteData)(pScrn, 0xff);
+#endif
+}
+
+void
+TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
+ RamDacRegRecPtr ramdacReg)
+{
+ int i;
+
+ (*ramdacPtr->ReadAddress)(pScrn, 0);
+ for (i=0;i<768;i++)
+ ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
+
+ /* Read back N,M and P values for pixel clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ ramdacReg->DacRegs[TIDAC_PIXEL_N] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
+ ramdacReg->DacRegs[TIDAC_PIXEL_M] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_PIXEL_P] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
+
+ /* Read back N,M and P values for loop clock */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
+ ramdacReg->DacRegs[TIDAC_LOOP_N] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x11);
+ ramdacReg->DacRegs[TIDAC_LOOP_M] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_LOOP_P] =
+ (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
+
+ /* Order is important */
+ TISAVE(TIDAC_latch_ctrl);
+ TISAVE(TIDAC_true_color_ctrl);
+ TISAVE(TIDAC_multiplex_ctrl);
+ TISAVE(TIDAC_clock_select);
+ TISAVE(TIDAC_palette_page);
+ TISAVE(TIDAC_general_ctrl);
+ TISAVE(TIDAC_misc_ctrl);
+ /* 0x2A & 0x2B are reserved */
+ TISAVE(TIDAC_key_over_low);
+ TISAVE(TIDAC_key_over_high);
+ TISAVE(TIDAC_key_red_low);
+ TISAVE(TIDAC_key_red_high);
+ TISAVE(TIDAC_key_green_low);
+ TISAVE(TIDAC_key_green_high);
+ TISAVE(TIDAC_key_blue_low);
+ TISAVE(TIDAC_key_blue_high);
+ TISAVE(TIDAC_key_ctrl);
+ TISAVE(TIDAC_clock_ctrl);
+ TISAVE(TIDAC_sense_test);
+ TISAVE(TIDAC_ind_curs_ctrl);
+}
+
+RamDacHelperRecPtr
+TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ RamDacHelperRecPtr ramdacHelperPtr = NULL;
+ Bool RamDacIsSupported = FALSE;
+ int TIramdac_ID = -1;
+ int i;
+ unsigned char id, rev, rev2, id2;
+
+ /* read ID and revision */
+ rev = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
+ id = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
+
+ /* check if ID and revision are read only */
+ (*ramdacPtr->WriteDAC)(pScrn, ~rev, 0, TIDAC_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, ~id, 0, TIDAC_id);
+ rev2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_rev);
+ id2 = (*ramdacPtr->ReadDAC)(pScrn, TIDAC_id);
+
+ switch (id) {
+ case TIDAC_TVP_3030_ID:
+ if (id == id2 && rev == rev2) /* check for READ ONLY */
+ TIramdac_ID = TI3030_RAMDAC;
+ break;
+ case TIDAC_TVP_3026_ID:
+ if (id == id2 && rev == rev2) /* check for READ ONLY */
+ TIramdac_ID = TI3026_RAMDAC;
+ break;
+ }
+
+ (*ramdacPtr->WriteDAC)(pScrn, rev, 0, TIDAC_rev);
+ (*ramdacPtr->WriteDAC)(pScrn, id, 0, TIDAC_id);
+
+ if (TIramdac_ID == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Cannot determine TI RAMDAC type, aborting\n");
+ return NULL;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "Attached RAMDAC is %s\n", TIramdacDeviceInfo[TIramdac_ID&0xFFFF].DeviceName);
+ }
+
+ for (i=0;ramdacs[i].token != -1;i++) {
+ if (ramdacs[i].token == TIramdac_ID)
+ RamDacIsSupported = TRUE;
+ }
+
+ if (!RamDacIsSupported) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "This TI RAMDAC is NOT supported by this driver, aborting\n");
+ return NULL;
+ }
+
+ ramdacHelperPtr = RamDacHelperCreateInfoRec();
+ switch (TIramdac_ID) {
+ case TI3030_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3030SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ case TI3026_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3026SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ }
+ ramdacPtr->RamDacType = TIramdac_ID;
+ ramdacHelperPtr->RamDacType = TIramdac_ID;
+ ramdacHelperPtr->Save = TIramdacSave;
+ ramdacHelperPtr->Restore = TIramdacRestore;
+
+ return ramdacHelperPtr;
+}
+
+void
+TIramdac3026SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
+ }
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 24:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 16:
+ /* order is important */
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
+#else
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+#endif
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
+ } else {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
+ }
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+#else
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+#endif
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 8:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4c;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ }
+}
+
+void
+TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+{
+ switch (pScrn->bitsPerPixel) {
+ case 32:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x46;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5D;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x3C;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x01;
+ }
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 24:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x56;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x58;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x25;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 16:
+ /* order is important */
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
+#else
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+#endif
+ if (pScrn->depth == 16) {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x45;
+ } else {
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
+ }
+#if 0
+ /* Matrox driver uses this */
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x50;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x15;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
+#else
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x85;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+#endif
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ case 8:
+ /* order is important */
+ ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
+ ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x4d;
+ ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
+ ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
+ ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
+ /* 0x2A & 0x2B are reserved */
+ ramdacReg->DacRegs[TIDAC_key_over_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_over_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_red_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_low] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_green_high] = 0xFF;
+ ramdacReg->DacRegs[TIDAC_key_blue_low] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
+ ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x00;
+ ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
+ ramdacReg->DacRegs[TIDAC_ind_curs_ctrl] = 0x00;
+ break;
+ }
+}
+
+static void
+TIramdacShowCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Enable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03);
+}
+
+static void
+TIramdacHideCursor(ScrnInfoPtr pScrn)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Disable cursor - X11 mode */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
+}
+
+static void
+TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ x += 64;
+ y += 64;
+
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XLOW, 0, x & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_XHIGH, 0, (x >> 8) & 0x0f);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YLOW, 0, y & 0xff);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_YHIGH, 0, (y >> 8) & 0x0f);
+}
+
+static void
+TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+
+ /* Background color */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 1);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x00ff0000) >> 16));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((bg&0x0000ff00) >> 8));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (bg&0x000000ff) );
+
+ /* Foreground color */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_WRITE_ADDR, 0, 2);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x00ff0000) >> 16));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, ((fg&0x0000ff00) >> 8));
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_COLOR, 0, (fg&0x000000ff) );
+}
+
+static void
+TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
+ int i = 1024;
+
+ /* reset A9,A8 */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
+ /* reset cursor RAM load address A7..A0 */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_INDEX, 0x00, 0x00);
+
+ while(i--) {
+ /* NOT_DONE: might need a delay here */
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_CURS_RAM_DATA, 0, *(src++));
+ }
+}
+
+static Bool
+TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+void
+TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr)
+{
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+ infoPtr->SetCursorColors = TIramdacSetCursorColors;
+ infoPtr->SetCursorPosition = TIramdacSetCursorPosition;
+ infoPtr->LoadCursorImage = TIramdacLoadCursorImage;
+ infoPtr->HideCursor = TIramdacHideCursor;
+ infoPtr->ShowCursor = TIramdacShowCursor;
+ infoPtr->UseHWCursor = TIramdacUseHWCursor;
+}
+
+void TIramdacLoadPalette(
+ ScrnInfoPtr pScrn,
+ int numColors,
+ int *indices,
+ LOCO *colors,
+ VisualPtr pVisual
+){
+ RamDacRecPtr hwp = RAMDACSCRPTR(pScrn);
+ int i, index, shift;
+
+ if (pScrn->depth == 16) {
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ (*hwp->WriteAddress)(pScrn, index << 2);
+ (*hwp->WriteData)(pScrn, colors[index >> 1].red);
+ (*hwp->WriteData)(pScrn, colors[index].green);
+ (*hwp->WriteData)(pScrn, colors[index >> 1].blue);
+
+ if(index <= 31) {
+ (*hwp->WriteAddress)(pScrn, index << 3);
+ (*hwp->WriteData)(pScrn, colors[index].red);
+ (*hwp->WriteData)(pScrn, colors[(index << 1) + 1].green);
+ (*hwp->WriteData)(pScrn, colors[index].blue);
+ }
+ }
+} else {
+ shift = (pScrn->depth == 15) ? 3 : 0;
+
+ for(i = 0; i < numColors; i++) {
+ index = indices[i];
+ (*hwp->WriteAddress)(pScrn, index << shift);
+ (*hwp->WriteData)(pScrn, colors[index].red);
+ (*hwp->WriteData)(pScrn, colors[index].green);
+ (*hwp->WriteData)(pScrn, colors[index].blue);
+ }
+}
+}
+
+TIramdacLoadPaletteProc *TIramdacLoadPaletteWeak(void) {
+ return TIramdacLoadPalette;
+}
diff --git a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
index 91b5795c3..421e35b51 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86Cursor.c
@@ -18,8 +18,7 @@
#include "inputstr.h"
extern InputInfo inputInfo;
-static int xf86CursorScreenKeyIndex;
-DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKeyIndex;
+DevPrivateKeyRec xf86CursorScreenKeyRec;
/* sprite functions */
@@ -65,6 +64,9 @@ xf86InitCursor(
if (!xf86InitHardwareCursor(pScreen, infoPtr))
return FALSE;
+ if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
if (!ScreenPriv)
return FALSE;
diff --git a/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h b/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h
index 32be9c2f3..76e714b32 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h
+++ b/xorg-server/hw/xfree86/ramdac/xf86CursorPriv.h
@@ -1,50 +1,51 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86CURSORPRIV_H
-#define _XF86CURSORPRIV_H
-
-#include "xf86Cursor.h"
-#include "mipointrst.h"
-
-typedef struct {
- Bool SWCursor;
- Bool isUp;
- Bool showTransparent;
- short HotX;
- short HotY;
- short x;
- short y;
- CursorPtr CurrentCursor, CursorToRestore;
- xf86CursorInfoPtr CursorInfoPtr;
- CloseScreenProcPtr CloseScreen;
- RecolorCursorProcPtr RecolorCursor;
- InstallColormapProcPtr InstallColormap;
- QueryBestSizeProcPtr QueryBestSize;
- miPointerSpriteFuncPtr spriteFuncs;
- Bool PalettedCursor;
- ColormapPtr pInstalledMap;
- Bool (*SwitchMode)(int, DisplayModePtr,int);
- xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
- CursorPtr SavedCursor;
-
- /* Number of requests to force HW cursor */
- int ForceHWCursorCount;
- Bool HWCursorForced;
-
- pointer transparentData;
-} xf86CursorScreenRec, *xf86CursorScreenPtr;
-
-void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y);
-void xf86SetTransparentCursor(ScreenPtr pScreen);
-void xf86MoveCursor(ScreenPtr pScreen, int x, int y);
-void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed);
-Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
-
-CARD32 xf86ReverseBitOrder(CARD32 data);
-
-extern _X_EXPORT DevPrivateKey xf86CursorScreenKey;
-
-#endif /* _XF86CURSORPRIV_H */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#ifndef _XF86CURSORPRIV_H
+#define _XF86CURSORPRIV_H
+
+#include "xf86Cursor.h"
+#include "mipointrst.h"
+
+typedef struct {
+ Bool SWCursor;
+ Bool isUp;
+ Bool showTransparent;
+ short HotX;
+ short HotY;
+ short x;
+ short y;
+ CursorPtr CurrentCursor, CursorToRestore;
+ xf86CursorInfoPtr CursorInfoPtr;
+ CloseScreenProcPtr CloseScreen;
+ RecolorCursorProcPtr RecolorCursor;
+ InstallColormapProcPtr InstallColormap;
+ QueryBestSizeProcPtr QueryBestSize;
+ miPointerSpriteFuncPtr spriteFuncs;
+ Bool PalettedCursor;
+ ColormapPtr pInstalledMap;
+ Bool (*SwitchMode)(int, DisplayModePtr,int);
+ xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
+ CursorPtr SavedCursor;
+
+ /* Number of requests to force HW cursor */
+ int ForceHWCursorCount;
+ Bool HWCursorForced;
+
+ pointer transparentData;
+} xf86CursorScreenRec, *xf86CursorScreenPtr;
+
+void xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y);
+void xf86SetTransparentCursor(ScreenPtr pScreen);
+void xf86MoveCursor(ScreenPtr pScreen, int x, int y);
+void xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed);
+Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
+
+CARD32 xf86ReverseBitOrder(CARD32 data);
+
+extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec;
+#define xf86CursorScreenKey (&xf86CursorScreenKeyRec)
+
+#endif /* _XF86CURSORPRIV_H */
diff --git a/xorg-server/hw/xfree86/ramdac/xf86RamDac.c b/xorg-server/hw/xfree86/ramdac/xf86RamDac.c
index 25d450c07..a170444a9 100644
--- a/xorg-server/hw/xfree86/ramdac/xf86RamDac.c
+++ b/xorg-server/hw/xfree86/ramdac/xf86RamDac.c
@@ -82,7 +82,7 @@ RamDacInit(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPriv)
((RamDacScreenRecPtr) (pScrn)->privates[RamDacGetScreenIndex()].ptr);
ramdacScrPtr->RamDacRec = ramdacPriv;
- return(TRUE);
+ return TRUE;
}
void
@@ -132,12 +132,10 @@ RamDacFreeRec(ScrnInfoPtr pScrn)
ramdacScrPtr = ((RamDacScreenRecPtr)
(pScrn)->privates[RamDacGetScreenIndex()].ptr);
- if (ramdacHWPtr)
- free(ramdacHWPtr);
+ free(ramdacHWPtr);
ramdacHWPtr = NULL;
- if (ramdacScrPtr)
- free(ramdacScrPtr);
+ free(ramdacScrPtr);
ramdacScrPtr = NULL;
}
diff --git a/xorg-server/hw/xfree86/shadowfb/shadow.c b/xorg-server/hw/xfree86/shadowfb/shadow.c
index 9e847f4d2..4c7551de9 100644
--- a/xorg-server/hw/xfree86/shadowfb/shadow.c
+++ b/xorg-server/hw/xfree86/shadowfb/shadow.c
@@ -84,11 +84,11 @@ typedef struct {
GCFuncs *funcs;
} ShadowGCRec, *ShadowGCPtr;
+static DevPrivateKeyRec ShadowScreenKeyRec;
+#define ShadowScreenKey (&ShadowScreenKeyRec)
-static int ShadowScreenKeyIndex;
-static DevPrivateKey ShadowScreenKey = &ShadowScreenKeyIndex;
-static int ShadowGCKeyIndex;
-static DevPrivateKey ShadowGCKey = &ShadowGCKeyIndex;
+static DevPrivateKeyRec ShadowGCKeyRec;
+#define ShadowGCKey (&ShadowGCKeyRec)
#define GET_SCREEN_PRIVATE(pScreen) \
(ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
@@ -162,7 +162,10 @@ ShadowFBInit2 (
if(!preRefreshArea && !postRefreshArea) return FALSE;
- if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec)))
+ if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
+ if(!dixRegisterPrivateKey(&ShadowGCKeyRec, PRIVATE_GC, sizeof(ShadowGCRec)))
return FALSE;
if(!(pPriv = (ShadowScreenPtr)malloc(sizeof(ShadowScreenRec))))
@@ -272,18 +275,18 @@ ShadowCopyWindow(
RegionRec rgnDst;
if (pPriv->vtSema) {
- REGION_NULL(pWin->drawable.pScreen, &rgnDst);
- REGION_COPY(pWin->drawable.pScreen, &rgnDst, prgn);
+ RegionNull(&rgnDst);
+ RegionCopy(&rgnDst, prgn);
- REGION_TRANSLATE(pWin->drawable.pScreen, &rgnDst,
+ RegionTranslate(&rgnDst,
pWin->drawable.x - ptOldOrg.x,
pWin->drawable.y - ptOldOrg.y);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, &rgnDst);
- if ((num = REGION_NUM_RECTS(&rgnDst))) {
+ RegionIntersect(&rgnDst, &pWin->borderClip, &rgnDst);
+ if ((num = RegionNumRects(&rgnDst))) {
if(pPriv->preRefresh)
- (*pPriv->preRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
+ (*pPriv->preRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
} else {
- REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
}
@@ -293,8 +296,8 @@ ShadowCopyWindow(
if (num) {
if (pPriv->postRefresh)
- (*pPriv->postRefresh)(pPriv->pScrn, num, REGION_RECTS(&rgnDst));
- REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ (*pPriv->postRefresh)(pPriv->pScrn, num, RegionRects(&rgnDst));
+ RegionUninit(&rgnDst);
}
}
@@ -1353,38 +1356,32 @@ ShadowFontToBox(BoxPtr BB, DrawablePtr pDrawable, GCPtr pGC, int x, int y,
}
right += pFont->info.maxbounds.rightSideBearing;
BB->x1 =
- max(pDrawable->x + x - left, (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x1);
+ max(pDrawable->x + x - left,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
BB->y1 =
max(pDrawable->y + y - ascent,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y1);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
BB->x2 =
min(pDrawable->x + x + right,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
BB->y2 =
min(pDrawable->y + y + descent,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
} else {
ShadowTextExtent(pFont, count, chars, wide ? (FONTLASTROW(pFont) == 0)
? Linear16Bit : TwoD16Bit : Linear8Bit, BB);
BB->x1 =
- max(pDrawable->x + x + BB->x1, (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x1);
+ max(pDrawable->x + x + BB->x1,
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x1);
BB->y1 =
max(pDrawable->y + y + BB->y1,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y1);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y1);
BB->x2 =
min(pDrawable->x + x + BB->x2,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->x2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->x2);
BB->y2 =
min(pDrawable->y + y + BB->y2,
- (REGION_EXTENTS(pGC->pScreen,
- &((WindowPtr) pDrawable)->winSize))->y2);
+ RegionExtents(&((WindowPtr) pDrawable)->winSize)->y2);
}
}
diff --git a/xorg-server/hw/xfree86/utils/gtf/gtf.c b/xorg-server/hw/xfree86/utils/gtf/gtf.c
index 8ce93276a..840626c66 100644
--- a/xorg-server/hw/xfree86/utils/gtf/gtf.c
+++ b/xorg-server/hw/xfree86/utils/gtf/gtf.c
@@ -1,741 +1,741 @@
-/* gtf.c Generate mode timings using the GTF Timing Standard
- *
- * gcc gtf.c -o gtf -lm -Wall
- *
- * Copyright (c) 2001, Andy Ritger aritger@nvidia.com
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * o Neither the name of NVIDIA nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
- * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- * THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- *
- *
- * This program is based on the Generalized Timing Formula(GTF TM)
- * Standard Version: 1.0, Revision: 1.0
- *
- * The GTF Document contains the following Copyright information:
- *
- * Copyright (c) 1994, 1995, 1996 - Video Electronics Standards
- * Association. Duplication of this document within VESA member
- * companies for review purposes is permitted. All other rights
- * reserved.
- *
- * While every precaution has been taken in the preparation
- * of this standard, the Video Electronics Standards Association and
- * its contributors assume no responsibility for errors or omissions,
- * and make no warranties, expressed or implied, of functionality
- * of suitability for any purpose. The sample code contained within
- * this standard may be used without restriction.
- *
- *
- *
- * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive)
- * implementation of the GTF Timing Standard, is available at:
- *
- * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls
- *
- *
- *
- * This program takes a desired resolution and vertical refresh rate,
- * and computes mode timings according to the GTF Timing Standard.
- * These mode timings can then be formatted as an XServer modeline
- * or a mode description for use by fbset(8).
- *
- *
- *
- * NOTES:
- *
- * The GTF allows for computation of "margins" (the visible border
- * surrounding the addressable video); on most non-overscan type
- * systems, the margin period is zero. I've implemented the margin
- * computations but not enabled it because 1) I don't really have
- * any experience with this, and 2) neither XServer modelines nor
- * fbset fb.modes provide an obvious way for margin timings to be
- * included in their mode descriptions (needs more investigation).
- *
- * The GTF provides for computation of interlaced mode timings;
- * I've implemented the computations but not enabled them, yet.
- * I should probably enable and test this at some point.
- *
- *
- *
- * TODO:
- *
- * o Add support for interlaced modes.
- *
- * o Implement the other portions of the GTF: compute mode timings
- * given either the desired pixel clock or the desired horizontal
- * frequency.
- *
- * o It would be nice if this were more general purpose to do things
- * outside the scope of the GTF: like generate double scan mode
- * timings, for example.
- *
- * o Printing digits to the right of the decimal point when the
- * digits are 0 annoys me.
- *
- * o Error checking.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-# include <xorg-config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#define MARGIN_PERCENT 1.8 /* % of active vertical image */
-#define CELL_GRAN 8.0 /* assumed character cell granularity */
-#define MIN_PORCH 1 /* minimum front porch */
-#define V_SYNC_RQD 3 /* width of vsync in lines */
-#define H_SYNC_PERCENT 8.0 /* width of hsync as % of total line */
-#define MIN_VSYNC_PLUS_BP 550.0 /* min time of vsync + back porch (microsec) */
-#define M 600.0 /* blanking formula gradient */
-#define C 40.0 /* blanking formula offset */
-#define K 128.0 /* blanking formula scaling factor */
-#define J 20.0 /* blanking formula scaling factor */
-
-/* C' and M' are part of the Blanking Duty Cycle computation */
-
-#define C_PRIME (((C - J) * K/256.0) + J)
-#define M_PRIME (K/256.0 * M)
-
-
-/* struct definitions */
-
-typedef struct __mode
-{
- int hr, hss, hse, hfl;
- int vr, vss, vse, vfl;
- float pclk, h_freq, v_freq;
-} mode;
-
-
-typedef struct __options
-{
- int x, y;
- int xorgmode, fbmode;
- float v_freq;
-} options;
-
-
-
-
-/* prototypes */
-
-void print_value(int n, char *name, float val);
-void print_xf86_mode (mode *m);
-void print_fb_mode (mode *m);
-mode *vert_refresh (int h_pixels, int v_lines, float freq,
- int interlaced, int margins);
-options *parse_command_line (int argc, char *argv[]);
-
-
-
-
-/*
- * print_value() - print the result of the named computation; this is
- * useful when comparing against the GTF EXCEL spreadsheet.
- */
-
-int global_verbose = 0;
-
-void print_value(int n, char *name, float val)
-{
- if (global_verbose) {
- printf("%2d: %-27s: %15f\n", n, name, val);
- }
-}
-
-
-
-/* print_xf86_mode() - print the XServer modeline, given mode timings. */
-
-void print_xf86_mode (mode *m)
-{
- printf ("\n");
- printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
- m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
-
- printf (" Modeline \"%dx%d_%.2f\" %.2f"
- " %d %d %d %d"
- " %d %d %d %d"
- " -HSync +Vsync\n\n",
- m->hr, m->vr, m->v_freq, m->pclk,
- m->hr, m->hss, m->hse, m->hfl,
- m->vr, m->vss, m->vse, m->vfl);
-
-}
-
-
-
-/*
- * print_fb_mode() - print a mode description in fbset(8) format;
- * see the fb.modes(8) manpage. The timing description used in
- * this is rather odd; they use "left and right margin" to refer
- * to the portion of the hblank before and after the sync pulse
- * by conceptually wrapping the portion of the blank after the pulse
- * to infront of the visible region; ie:
- *
- *
- * Timing description I'm accustomed to:
- *
- *
- *
- * <--------1--------> <--2--> <--3--> <--4-->
- * _________
- * |-------------------|_______| |_______
- *
- * R SS SE FL
- *
- * 1: visible image
- * 2: blank before sync (aka front porch)
- * 3: sync pulse
- * 4: blank after sync (aka back porch)
- * R: Resolution
- * SS: Sync Start
- * SE: Sync End
- * FL: Frame Length
- *
- *
- * But the fb.modes format is:
- *
- *
- * <--4--> <--------1--------> <--2--> <--3-->
- * _________
- * _______|-------------------|_______| |
- *
- * The fb.modes(8) manpage refers to <4> and <2> as the left and
- * right "margin" (as well as upper and lower margin in the vertical
- * direction) -- note that this has nothing to do with the term
- * "margin" used in the GTF Timing Standard.
- *
- * XXX always prints the 32 bit mode -- should I provide a command
- * line option to specify the bpp? It's simple enough for a user
- * to edit the mode description after it's generated.
- */
-
-void print_fb_mode (mode *m)
-{
- printf ("\n");
- printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n",
- m->hr, m->vr, m->v_freq);
- printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
- m->pclk, m->h_freq, m->v_freq);
- printf (" geometry %d %d %d %d 32\n",
- m->hr, m->vr, m->hr, m->vr);
- printf (" timings %d %d %d %d %d %d %d\n",
- (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */
- m->hfl - m->hse, /* left margin (in pixels) */
- m->hss - m->hr, /* right margin (in pixels) */
- m->vfl - m->vse, /* upper margin (in pixel lines) */
- m->vss - m->vr, /* lower margin (in pixel lines) */
- m->hse - m->hss, /* horizontal sync length (pixels) */
- m->vse - m->vss); /* vert sync length (pixel lines) */
- printf (" hsync low\n");
- printf (" vsync high\n");
- printf ("endmode\n\n");
-
-}
-
-
-
-
-/*
- * vert_refresh() - as defined by the GTF Timing Standard, compute the
- * Stage 1 Parameters using the vertical refresh frequency. In other
- * words: input a desired resolution and desired refresh rate, and
- * output the GTF mode timings.
- *
- * XXX All the code is in place to compute interlaced modes, but I don't
- * feel like testing it right now.
- *
- * XXX margin computations are implemented but not tested (nor used by
- * XServer of fbset mode descriptions, from what I can tell).
- */
-
-mode *vert_refresh (int h_pixels, int v_lines, float freq,
- int interlaced, int margins)
-{
- float h_pixels_rnd;
- float v_lines_rnd;
- float v_field_rate_rqd;
- float top_margin;
- float bottom_margin;
- float interlace;
- float h_period_est;
- float vsync_plus_bp;
- float v_back_porch;
- float total_v_lines;
- float v_field_rate_est;
- float h_period;
- float v_field_rate;
- float v_frame_rate;
- float left_margin;
- float right_margin;
- float total_active_pixels;
- float ideal_duty_cycle;
- float h_blank;
- float total_pixels;
- float pixel_freq;
- float h_freq;
-
- float h_sync;
- float h_front_porch;
- float v_odd_front_porch_lines;
-
- mode *m = (mode*) malloc (sizeof (mode));
-
-
- /* 1. In order to give correct results, the number of horizontal
- * pixels requested is first processed to ensure that it is divisible
- * by the character size, by rounding it to the nearest character
- * cell boundary:
- *
- * [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND])
- */
-
- h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN;
-
- print_value(1, "[H PIXELS RND]", h_pixels_rnd);
-
-
- /* 2. If interlace is requested, the number of vertical lines assumed
- * by the calculation must be halved, as the computation calculates
- * the number of vertical lines per field. In either case, the
- * number of lines is rounded to the nearest integer.
- *
- * [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0),
- * ROUND([V LINES],0))
- */
-
- v_lines_rnd = interlaced ?
- rint((float) v_lines) / 2.0 :
- rint((float) v_lines);
-
- print_value(2, "[V LINES RND]", v_lines_rnd);
-
-
- /* 3. Find the frame rate required:
- *
- * [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2,
- * [I/P FREQ RQD])
- */
-
- v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq);
-
- print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd);
-
-
- /* 4. Find number of lines in Top margin:
- *
- * [TOP MARGIN (LINES)] = IF([MARGINS RQD?]="Y",
- * ROUND(([MARGIN%]/100*[V LINES RND]),0),
- * 0)
- */
-
- top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
-
- print_value(4, "[TOP MARGIN (LINES)]", top_margin);
-
-
- /* 5. Find number of lines in Bottom margin:
- *
- * [BOT MARGIN (LINES)] = IF([MARGINS RQD?]="Y",
- * ROUND(([MARGIN%]/100*[V LINES RND]),0),
- * 0)
- */
-
- bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0);
-
- print_value(5, "[BOT MARGIN (LINES)]", bottom_margin);
-
-
- /* 6. If interlace is required, then set variable [INTERLACE]=0.5:
- *
- * [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
- */
-
- interlace = interlaced ? 0.5 : 0.0;
-
- print_value(6, "[INTERLACE]", interlace);
-
-
- /* 7. Estimate the Horizontal period
- *
- * [H PERIOD EST] = ((1/[V FIELD RATE RQD]) - [MIN VSYNC+BP]/1000000) /
- * ([V LINES RND] + (2*[TOP MARGIN (LINES)]) +
- * [MIN PORCH RND]+[INTERLACE]) * 1000000
- */
-
- h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0))
- / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace)
- * 1000000.0);
-
- print_value(7, "[H PERIOD EST]", h_period_est);
-
-
- /* 8. Find the number of lines in V sync + back porch:
- *
- * [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0)
- */
-
- vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est);
-
- print_value(8, "[V SYNC+BP]", vsync_plus_bp);
-
-
- /* 9. Find the number of lines in V back porch alone:
- *
- * [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND]
- *
- * XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]?
- */
-
- v_back_porch = vsync_plus_bp - V_SYNC_RQD;
-
- print_value(9, "[V BACK PORCH]", v_back_porch);
-
-
- /* 10. Find the total number of lines in Vertical field period:
- *
- * [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] +
- * [BOT MARGIN (LINES)] + [V SYNC+BP] + [INTERLACE] +
- * [MIN PORCH RND]
- */
-
- total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp +
- interlace + MIN_PORCH;
-
- print_value(10, "[TOTAL V LINES]", total_v_lines);
-
-
- /* 11. Estimate the Vertical field frequency:
- *
- * [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000
- */
-
- v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0;
-
- print_value(11, "[V FIELD RATE EST]", v_field_rate_est);
-
-
- /* 12. Find the actual horizontal period:
- *
- * [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST])
- */
-
- h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est);
-
- print_value(12, "[H PERIOD]", h_period);
-
-
- /* 13. Find the actual Vertical field frequency:
- *
- * [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000
- */
-
- v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0;
-
- print_value(13, "[V FIELD RATE]", v_field_rate);
-
-
- /* 14. Find the Vertical frame frequency:
- *
- * [V FRAME RATE] = (IF([INT RQD?]="y", [V FIELD RATE]/2, [V FIELD RATE]))
- */
-
- v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate;
-
- print_value(14, "[V FRAME RATE]", v_frame_rate);
-
-
- /* 15. Find number of pixels in left margin:
- *
- * [LEFT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
- * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 /
- * [CELL GRAN RND]),0)) * [CELL GRAN RND],
- * 0))
- */
-
- left_margin = margins ?
- rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
- 0.0;
-
- print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin);
-
-
- /* 16. Find number of pixels in right margin:
- *
- * [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
- * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 /
- * [CELL GRAN RND]),0)) * [CELL GRAN RND],
- * 0))
- */
-
- right_margin = margins ?
- rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
- 0.0;
-
- print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin);
-
-
- /* 17. Find total number of active pixels in image and left and right
- * margins:
- *
- * [TOTAL ACTIVE PIXELS] = [H PIXELS RND] + [LEFT MARGIN (PIXELS)] +
- * [RIGHT MARGIN (PIXELS)]
- */
-
- total_active_pixels = h_pixels_rnd + left_margin + right_margin;
-
- print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels);
-
-
- /* 18. Find the ideal blanking duty cycle from the blanking duty cycle
- * equation:
- *
- * [IDEAL DUTY CYCLE] = [C'] - ([M']*[H PERIOD]/1000)
- */
-
- ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0);
-
- print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle);
-
-
- /* 19. Find the number of pixels in the blanking time to the nearest
- * double character cell:
- *
- * [H BLANK (PIXELS)] = (ROUND(([TOTAL ACTIVE PIXELS] *
- * [IDEAL DUTY CYCLE] /
- * (100-[IDEAL DUTY CYCLE]) /
- * (2*[CELL GRAN RND])), 0))
- * * (2*[CELL GRAN RND])
- */
-
- h_blank = rint(total_active_pixels *
- ideal_duty_cycle /
- (100.0 - ideal_duty_cycle) /
- (2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN);
-
- print_value(19, "[H BLANK (PIXELS)]", h_blank);
-
-
- /* 20. Find total number of pixels:
- *
- * [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)]
- */
-
- total_pixels = total_active_pixels + h_blank;
-
- print_value(20, "[TOTAL PIXELS]", total_pixels);
-
-
- /* 21. Find pixel clock frequency:
- *
- * [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD]
- */
-
- pixel_freq = total_pixels / h_period;
-
- print_value(21, "[PIXEL FREQ]", pixel_freq);
-
-
- /* 22. Find horizontal frequency:
- *
- * [H FREQ] = 1000 / [H PERIOD]
- */
-
- h_freq = 1000.0 / h_period;
-
- print_value(22, "[H FREQ]", h_freq);
-
-
-
- /* Stage 1 computations are now complete; I should really pass
- the results to another function and do the Stage 2
- computations, but I only need a few more values so I'll just
- append the computations here for now */
-
-
-
- /* 17. Find the number of pixels in the horizontal sync period:
- *
- * [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] /
- * [CELL GRAN RND]),0))*[CELL GRAN RND]
- */
-
- h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
-
- print_value(17, "[H SYNC (PIXELS)]", h_sync);
-
-
- /* 18. Find the number of pixels in the horizontal front porch period:
- *
- * [H FRONT PORCH (PIXELS)] = ([H BLANK (PIXELS)]/2)-[H SYNC (PIXELS)]
- */
-
- h_front_porch = (h_blank / 2.0) - h_sync;
-
- print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch);
-
-
- /* 36. Find the number of lines in the odd front porch period:
- *
- * [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE])
- */
-
- v_odd_front_porch_lines = MIN_PORCH + interlace;
-
- print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines);
-
-
- /* finally, pack the results in the mode struct */
-
- m->hr = (int) (h_pixels_rnd);
- m->hss = (int) (h_pixels_rnd + h_front_porch);
- m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync);
- m->hfl = (int) (total_pixels);
-
- m->vr = (int) (v_lines_rnd);
- m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines);
- m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
- m->vfl = (int) (total_v_lines);
-
- m->pclk = pixel_freq;
- m->h_freq = h_freq;
- m->v_freq = freq;
-
- return (m);
-
-}
-
-
-
-
-/*
- * parse_command_line() - parse the command line and return an
- * alloced structure containing the results. On error print usage
- * and return NULL.
- */
-
-options *parse_command_line (int argc, char *argv[])
-{
- int n;
-
- options *o = (options *) calloc (1, sizeof (options));
-
- if (argc < 4) goto bad_option;
-
- o->x = atoi (argv[1]);
- o->y = atoi (argv[2]);
- o->v_freq = atof (argv[3]);
-
- /* XXX should check for errors in the above */
-
- n = 4;
-
- while (n < argc) {
- if ((strcmp (argv[n], "-v") == 0) ||
- (strcmp (argv[n], "--verbose") == 0)) {
- global_verbose = 1;
- } else if ((strcmp (argv[n], "-f") == 0) ||
- (strcmp (argv[n], "--fbmode") == 0)) {
- o->fbmode = 1;
- } else if ((strcmp (argv[n], "-x") == 0) ||
- (strcmp (argv[n], "--xorgmode") == 0) ||
- (strcmp (argv[n], "--xf86mode") == 0)) {
- o->xorgmode = 1;
- } else {
- goto bad_option;
- }
-
- n++;
- }
-
- /* if neither xorgmode nor fbmode were requested, default to
- xorgmode */
-
- if (!o->fbmode && !o->xorgmode) o->xorgmode = 1;
-
- return (o);
-
- bad_option:
-
- fprintf (stderr, "\n");
- fprintf (stderr, "usage: %s x y refresh [-v|--verbose] "
- "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
-
- fprintf (stderr, "\n");
-
- fprintf (stderr, " x : the desired horizontal "
- "resolution (required)\n");
- fprintf (stderr, " y : the desired vertical "
- "resolution (required)\n");
- fprintf (stderr, " refresh : the desired refresh "
- "rate (required)\n");
- fprintf (stderr, " -v|--verbose : enable verbose printouts "
- "(traces each step of the computation)\n");
- fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode "
- "description\n");
- fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode "
- "description (this is the default\n"
- " if no mode description is requested)\n");
-
- fprintf (stderr, "\n");
-
- free (o);
- return (NULL);
-
-}
-
-
-
-int main (int argc, char *argv[])
-{
- mode *m;
- options *o;
-
- o = parse_command_line (argc, argv);
- if (!o) exit (1);
-
- m = vert_refresh (o->x, o->y, o->v_freq, 0, 0);
- if (!m) exit (1);
-
- if (o->xorgmode)
- print_xf86_mode(m);
-
- if (o->fbmode)
- print_fb_mode(m);
-
- return 0;
-
-}
+/* gtf.c Generate mode timings using the GTF Timing Standard
+ *
+ * gcc gtf.c -o gtf -lm -Wall
+ *
+ * Copyright (c) 2001, Andy Ritger aritger@nvidia.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * o Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * o Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * o Neither the name of NVIDIA nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ *
+ *
+ * This program is based on the Generalized Timing Formula(GTF TM)
+ * Standard Version: 1.0, Revision: 1.0
+ *
+ * The GTF Document contains the following Copyright information:
+ *
+ * Copyright (c) 1994, 1995, 1996 - Video Electronics Standards
+ * Association. Duplication of this document within VESA member
+ * companies for review purposes is permitted. All other rights
+ * reserved.
+ *
+ * While every precaution has been taken in the preparation
+ * of this standard, the Video Electronics Standards Association and
+ * its contributors assume no responsibility for errors or omissions,
+ * and make no warranties, expressed or implied, of functionality
+ * of suitability for any purpose. The sample code contained within
+ * this standard may be used without restriction.
+ *
+ *
+ *
+ * The GTF EXCEL(TM) SPREADSHEET, a sample (and the definitive)
+ * implementation of the GTF Timing Standard, is available at:
+ *
+ * ftp://ftp.vesa.org/pub/GTF/GTF_V1R1.xls
+ *
+ *
+ *
+ * This program takes a desired resolution and vertical refresh rate,
+ * and computes mode timings according to the GTF Timing Standard.
+ * These mode timings can then be formatted as an XServer modeline
+ * or a mode description for use by fbset(8).
+ *
+ *
+ *
+ * NOTES:
+ *
+ * The GTF allows for computation of "margins" (the visible border
+ * surrounding the addressable video); on most non-overscan type
+ * systems, the margin period is zero. I've implemented the margin
+ * computations but not enabled it because 1) I don't really have
+ * any experience with this, and 2) neither XServer modelines nor
+ * fbset fb.modes provide an obvious way for margin timings to be
+ * included in their mode descriptions (needs more investigation).
+ *
+ * The GTF provides for computation of interlaced mode timings;
+ * I've implemented the computations but not enabled them, yet.
+ * I should probably enable and test this at some point.
+ *
+ *
+ *
+ * TODO:
+ *
+ * o Add support for interlaced modes.
+ *
+ * o Implement the other portions of the GTF: compute mode timings
+ * given either the desired pixel clock or the desired horizontal
+ * frequency.
+ *
+ * o It would be nice if this were more general purpose to do things
+ * outside the scope of the GTF: like generate double scan mode
+ * timings, for example.
+ *
+ * o Printing digits to the right of the decimal point when the
+ * digits are 0 annoys me.
+ *
+ * o Error checking.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+# include <xorg-config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#define MARGIN_PERCENT 1.8 /* % of active vertical image */
+#define CELL_GRAN 8.0 /* assumed character cell granularity */
+#define MIN_PORCH 1 /* minimum front porch */
+#define V_SYNC_RQD 3 /* width of vsync in lines */
+#define H_SYNC_PERCENT 8.0 /* width of hsync as % of total line */
+#define MIN_VSYNC_PLUS_BP 550.0 /* min time of vsync + back porch (microsec) */
+#define M 600.0 /* blanking formula gradient */
+#define C 40.0 /* blanking formula offset */
+#define K 128.0 /* blanking formula scaling factor */
+#define J 20.0 /* blanking formula scaling factor */
+
+/* C' and M' are part of the Blanking Duty Cycle computation */
+
+#define C_PRIME (((C - J) * K/256.0) + J)
+#define M_PRIME (K/256.0 * M)
+
+
+/* struct definitions */
+
+typedef struct __mode
+{
+ int hr, hss, hse, hfl;
+ int vr, vss, vse, vfl;
+ float pclk, h_freq, v_freq;
+} mode;
+
+
+typedef struct __options
+{
+ int x, y;
+ int xorgmode, fbmode;
+ float v_freq;
+} options;
+
+
+
+
+/* prototypes */
+
+void print_value(int n, char *name, float val);
+void print_xf86_mode (mode *m);
+void print_fb_mode (mode *m);
+mode *vert_refresh (int h_pixels, int v_lines, float freq,
+ int interlaced, int margins);
+options *parse_command_line (int argc, char *argv[]);
+
+
+
+
+/*
+ * print_value() - print the result of the named computation; this is
+ * useful when comparing against the GTF EXCEL spreadsheet.
+ */
+
+int global_verbose = 0;
+
+void print_value(int n, char *name, float val)
+{
+ if (global_verbose) {
+ printf("%2d: %-27s: %15f\n", n, name, val);
+ }
+}
+
+
+
+/* print_xf86_mode() - print the XServer modeline, given mode timings. */
+
+void print_xf86_mode (mode *m)
+{
+ printf ("\n");
+ printf (" # %dx%d @ %.2f Hz (GTF) hsync: %.2f kHz; pclk: %.2f MHz\n",
+ m->hr, m->vr, m->v_freq, m->h_freq, m->pclk);
+
+ printf (" Modeline \"%dx%d_%.2f\" %.2f"
+ " %d %d %d %d"
+ " %d %d %d %d"
+ " -HSync +Vsync\n\n",
+ m->hr, m->vr, m->v_freq, m->pclk,
+ m->hr, m->hss, m->hse, m->hfl,
+ m->vr, m->vss, m->vse, m->vfl);
+
+}
+
+
+
+/*
+ * print_fb_mode() - print a mode description in fbset(8) format;
+ * see the fb.modes(8) manpage. The timing description used in
+ * this is rather odd; they use "left and right margin" to refer
+ * to the portion of the hblank before and after the sync pulse
+ * by conceptually wrapping the portion of the blank after the pulse
+ * to infront of the visible region; ie:
+ *
+ *
+ * Timing description I'm accustomed to:
+ *
+ *
+ *
+ * <--------1--------> <--2--> <--3--> <--4-->
+ * _________
+ * |-------------------|_______| |_______
+ *
+ * R SS SE FL
+ *
+ * 1: visible image
+ * 2: blank before sync (aka front porch)
+ * 3: sync pulse
+ * 4: blank after sync (aka back porch)
+ * R: Resolution
+ * SS: Sync Start
+ * SE: Sync End
+ * FL: Frame Length
+ *
+ *
+ * But the fb.modes format is:
+ *
+ *
+ * <--4--> <--------1--------> <--2--> <--3-->
+ * _________
+ * _______|-------------------|_______| |
+ *
+ * The fb.modes(8) manpage refers to <4> and <2> as the left and
+ * right "margin" (as well as upper and lower margin in the vertical
+ * direction) -- note that this has nothing to do with the term
+ * "margin" used in the GTF Timing Standard.
+ *
+ * XXX always prints the 32 bit mode -- should I provide a command
+ * line option to specify the bpp? It's simple enough for a user
+ * to edit the mode description after it's generated.
+ */
+
+void print_fb_mode (mode *m)
+{
+ printf ("\n");
+ printf ("mode \"%dx%d %.2fHz 32bit (GTF)\"\n",
+ m->hr, m->vr, m->v_freq);
+ printf (" # PCLK: %.2f MHz, H: %.2f kHz, V: %.2f Hz\n",
+ m->pclk, m->h_freq, m->v_freq);
+ printf (" geometry %d %d %d %d 32\n",
+ m->hr, m->vr, m->hr, m->vr);
+ printf (" timings %d %d %d %d %d %d %d\n",
+ (int) rint(1000000.0/m->pclk),/* pixclock in picoseconds */
+ m->hfl - m->hse, /* left margin (in pixels) */
+ m->hss - m->hr, /* right margin (in pixels) */
+ m->vfl - m->vse, /* upper margin (in pixel lines) */
+ m->vss - m->vr, /* lower margin (in pixel lines) */
+ m->hse - m->hss, /* horizontal sync length (pixels) */
+ m->vse - m->vss); /* vert sync length (pixel lines) */
+ printf (" hsync low\n");
+ printf (" vsync high\n");
+ printf ("endmode\n\n");
+
+}
+
+
+
+
+/*
+ * vert_refresh() - as defined by the GTF Timing Standard, compute the
+ * Stage 1 Parameters using the vertical refresh frequency. In other
+ * words: input a desired resolution and desired refresh rate, and
+ * output the GTF mode timings.
+ *
+ * XXX All the code is in place to compute interlaced modes, but I don't
+ * feel like testing it right now.
+ *
+ * XXX margin computations are implemented but not tested (nor used by
+ * XServer of fbset mode descriptions, from what I can tell).
+ */
+
+mode *vert_refresh (int h_pixels, int v_lines, float freq,
+ int interlaced, int margins)
+{
+ float h_pixels_rnd;
+ float v_lines_rnd;
+ float v_field_rate_rqd;
+ float top_margin;
+ float bottom_margin;
+ float interlace;
+ float h_period_est;
+ float vsync_plus_bp;
+ float v_back_porch;
+ float total_v_lines;
+ float v_field_rate_est;
+ float h_period;
+ float v_field_rate;
+ float v_frame_rate;
+ float left_margin;
+ float right_margin;
+ float total_active_pixels;
+ float ideal_duty_cycle;
+ float h_blank;
+ float total_pixels;
+ float pixel_freq;
+ float h_freq;
+
+ float h_sync;
+ float h_front_porch;
+ float v_odd_front_porch_lines;
+
+ mode *m = (mode*) malloc (sizeof (mode));
+
+
+ /* 1. In order to give correct results, the number of horizontal
+ * pixels requested is first processed to ensure that it is divisible
+ * by the character size, by rounding it to the nearest character
+ * cell boundary:
+ *
+ * [H PIXELS RND] = ((ROUND([H PIXELS]/[CELL GRAN RND],0))*[CELLGRAN RND])
+ */
+
+ h_pixels_rnd = rint((float) h_pixels / CELL_GRAN) * CELL_GRAN;
+
+ print_value(1, "[H PIXELS RND]", h_pixels_rnd);
+
+
+ /* 2. If interlace is requested, the number of vertical lines assumed
+ * by the calculation must be halved, as the computation calculates
+ * the number of vertical lines per field. In either case, the
+ * number of lines is rounded to the nearest integer.
+ *
+ * [V LINES RND] = IF([INT RQD?]="y", ROUND([V LINES]/2,0),
+ * ROUND([V LINES],0))
+ */
+
+ v_lines_rnd = interlaced ?
+ rint((float) v_lines) / 2.0 :
+ rint((float) v_lines);
+
+ print_value(2, "[V LINES RND]", v_lines_rnd);
+
+
+ /* 3. Find the frame rate required:
+ *
+ * [V FIELD RATE RQD] = IF([INT RQD?]="y", [I/P FREQ RQD]*2,
+ * [I/P FREQ RQD])
+ */
+
+ v_field_rate_rqd = interlaced ? (freq * 2.0) : (freq);
+
+ print_value(3, "[V FIELD RATE RQD]", v_field_rate_rqd);
+
+
+ /* 4. Find number of lines in Top margin:
+ *
+ * [TOP MARGIN (LINES)] = IF([MARGINS RQD?]="Y",
+ * ROUND(([MARGIN%]/100*[V LINES RND]),0),
+ * 0)
+ */
+
+ top_margin = margins ? rint(MARGIN_PERCENT / 100.0 * v_lines_rnd) : (0.0);
+
+ print_value(4, "[TOP MARGIN (LINES)]", top_margin);
+
+
+ /* 5. Find number of lines in Bottom margin:
+ *
+ * [BOT MARGIN (LINES)] = IF([MARGINS RQD?]="Y",
+ * ROUND(([MARGIN%]/100*[V LINES RND]),0),
+ * 0)
+ */
+
+ bottom_margin = margins ? rint(MARGIN_PERCENT/100.0 * v_lines_rnd) : (0.0);
+
+ print_value(5, "[BOT MARGIN (LINES)]", bottom_margin);
+
+
+ /* 6. If interlace is required, then set variable [INTERLACE]=0.5:
+ *
+ * [INTERLACE]=(IF([INT RQD?]="y",0.5,0))
+ */
+
+ interlace = interlaced ? 0.5 : 0.0;
+
+ print_value(6, "[INTERLACE]", interlace);
+
+
+ /* 7. Estimate the Horizontal period
+ *
+ * [H PERIOD EST] = ((1/[V FIELD RATE RQD]) - [MIN VSYNC+BP]/1000000) /
+ * ([V LINES RND] + (2*[TOP MARGIN (LINES)]) +
+ * [MIN PORCH RND]+[INTERLACE]) * 1000000
+ */
+
+ h_period_est = (((1.0/v_field_rate_rqd) - (MIN_VSYNC_PLUS_BP/1000000.0))
+ / (v_lines_rnd + (2*top_margin) + MIN_PORCH + interlace)
+ * 1000000.0);
+
+ print_value(7, "[H PERIOD EST]", h_period_est);
+
+
+ /* 8. Find the number of lines in V sync + back porch:
+ *
+ * [V SYNC+BP] = ROUND(([MIN VSYNC+BP]/[H PERIOD EST]),0)
+ */
+
+ vsync_plus_bp = rint(MIN_VSYNC_PLUS_BP/h_period_est);
+
+ print_value(8, "[V SYNC+BP]", vsync_plus_bp);
+
+
+ /* 9. Find the number of lines in V back porch alone:
+ *
+ * [V BACK PORCH] = [V SYNC+BP] - [V SYNC RND]
+ *
+ * XXX is "[V SYNC RND]" a typo? should be [V SYNC RQD]?
+ */
+
+ v_back_porch = vsync_plus_bp - V_SYNC_RQD;
+
+ print_value(9, "[V BACK PORCH]", v_back_porch);
+
+
+ /* 10. Find the total number of lines in Vertical field period:
+ *
+ * [TOTAL V LINES] = [V LINES RND] + [TOP MARGIN (LINES)] +
+ * [BOT MARGIN (LINES)] + [V SYNC+BP] + [INTERLACE] +
+ * [MIN PORCH RND]
+ */
+
+ total_v_lines = v_lines_rnd + top_margin + bottom_margin + vsync_plus_bp +
+ interlace + MIN_PORCH;
+
+ print_value(10, "[TOTAL V LINES]", total_v_lines);
+
+
+ /* 11. Estimate the Vertical field frequency:
+ *
+ * [V FIELD RATE EST] = 1 / [H PERIOD EST] / [TOTAL V LINES] * 1000000
+ */
+
+ v_field_rate_est = 1.0 / h_period_est / total_v_lines * 1000000.0;
+
+ print_value(11, "[V FIELD RATE EST]", v_field_rate_est);
+
+
+ /* 12. Find the actual horizontal period:
+ *
+ * [H PERIOD] = [H PERIOD EST] / ([V FIELD RATE RQD] / [V FIELD RATE EST])
+ */
+
+ h_period = h_period_est / (v_field_rate_rqd / v_field_rate_est);
+
+ print_value(12, "[H PERIOD]", h_period);
+
+
+ /* 13. Find the actual Vertical field frequency:
+ *
+ * [V FIELD RATE] = 1 / [H PERIOD] / [TOTAL V LINES] * 1000000
+ */
+
+ v_field_rate = 1.0 / h_period / total_v_lines * 1000000.0;
+
+ print_value(13, "[V FIELD RATE]", v_field_rate);
+
+
+ /* 14. Find the Vertical frame frequency:
+ *
+ * [V FRAME RATE] = (IF([INT RQD?]="y", [V FIELD RATE]/2, [V FIELD RATE]))
+ */
+
+ v_frame_rate = interlaced ? v_field_rate / 2.0 : v_field_rate;
+
+ print_value(14, "[V FRAME RATE]", v_frame_rate);
+
+
+ /* 15. Find number of pixels in left margin:
+ *
+ * [LEFT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
+ * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 /
+ * [CELL GRAN RND]),0)) * [CELL GRAN RND],
+ * 0))
+ */
+
+ left_margin = margins ?
+ rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
+ 0.0;
+
+ print_value(15, "[LEFT MARGIN (PIXELS)]", left_margin);
+
+
+ /* 16. Find number of pixels in right margin:
+ *
+ * [RIGHT MARGIN (PIXELS)] = (IF( [MARGINS RQD?]="Y",
+ * (ROUND( ([H PIXELS RND] * [MARGIN%] / 100 /
+ * [CELL GRAN RND]),0)) * [CELL GRAN RND],
+ * 0))
+ */
+
+ right_margin = margins ?
+ rint(h_pixels_rnd * MARGIN_PERCENT / 100.0 / CELL_GRAN) * CELL_GRAN :
+ 0.0;
+
+ print_value(16, "[RIGHT MARGIN (PIXELS)]", right_margin);
+
+
+ /* 17. Find total number of active pixels in image and left and right
+ * margins:
+ *
+ * [TOTAL ACTIVE PIXELS] = [H PIXELS RND] + [LEFT MARGIN (PIXELS)] +
+ * [RIGHT MARGIN (PIXELS)]
+ */
+
+ total_active_pixels = h_pixels_rnd + left_margin + right_margin;
+
+ print_value(17, "[TOTAL ACTIVE PIXELS]", total_active_pixels);
+
+
+ /* 18. Find the ideal blanking duty cycle from the blanking duty cycle
+ * equation:
+ *
+ * [IDEAL DUTY CYCLE] = [C'] - ([M']*[H PERIOD]/1000)
+ */
+
+ ideal_duty_cycle = C_PRIME - (M_PRIME * h_period / 1000.0);
+
+ print_value(18, "[IDEAL DUTY CYCLE]", ideal_duty_cycle);
+
+
+ /* 19. Find the number of pixels in the blanking time to the nearest
+ * double character cell:
+ *
+ * [H BLANK (PIXELS)] = (ROUND(([TOTAL ACTIVE PIXELS] *
+ * [IDEAL DUTY CYCLE] /
+ * (100-[IDEAL DUTY CYCLE]) /
+ * (2*[CELL GRAN RND])), 0))
+ * * (2*[CELL GRAN RND])
+ */
+
+ h_blank = rint(total_active_pixels *
+ ideal_duty_cycle /
+ (100.0 - ideal_duty_cycle) /
+ (2.0 * CELL_GRAN)) * (2.0 * CELL_GRAN);
+
+ print_value(19, "[H BLANK (PIXELS)]", h_blank);
+
+
+ /* 20. Find total number of pixels:
+ *
+ * [TOTAL PIXELS] = [TOTAL ACTIVE PIXELS] + [H BLANK (PIXELS)]
+ */
+
+ total_pixels = total_active_pixels + h_blank;
+
+ print_value(20, "[TOTAL PIXELS]", total_pixels);
+
+
+ /* 21. Find pixel clock frequency:
+ *
+ * [PIXEL FREQ] = [TOTAL PIXELS] / [H PERIOD]
+ */
+
+ pixel_freq = total_pixels / h_period;
+
+ print_value(21, "[PIXEL FREQ]", pixel_freq);
+
+
+ /* 22. Find horizontal frequency:
+ *
+ * [H FREQ] = 1000 / [H PERIOD]
+ */
+
+ h_freq = 1000.0 / h_period;
+
+ print_value(22, "[H FREQ]", h_freq);
+
+
+
+ /* Stage 1 computations are now complete; I should really pass
+ the results to another function and do the Stage 2
+ computations, but I only need a few more values so I'll just
+ append the computations here for now */
+
+
+
+ /* 17. Find the number of pixels in the horizontal sync period:
+ *
+ * [H SYNC (PIXELS)] =(ROUND(([H SYNC%] / 100 * [TOTAL PIXELS] /
+ * [CELL GRAN RND]),0))*[CELL GRAN RND]
+ */
+
+ h_sync = rint(H_SYNC_PERCENT/100.0 * total_pixels / CELL_GRAN) * CELL_GRAN;
+
+ print_value(17, "[H SYNC (PIXELS)]", h_sync);
+
+
+ /* 18. Find the number of pixels in the horizontal front porch period:
+ *
+ * [H FRONT PORCH (PIXELS)] = ([H BLANK (PIXELS)]/2)-[H SYNC (PIXELS)]
+ */
+
+ h_front_porch = (h_blank / 2.0) - h_sync;
+
+ print_value(18, "[H FRONT PORCH (PIXELS)]", h_front_porch);
+
+
+ /* 36. Find the number of lines in the odd front porch period:
+ *
+ * [V ODD FRONT PORCH(LINES)]=([MIN PORCH RND]+[INTERLACE])
+ */
+
+ v_odd_front_porch_lines = MIN_PORCH + interlace;
+
+ print_value(36, "[V ODD FRONT PORCH(LINES)]", v_odd_front_porch_lines);
+
+
+ /* finally, pack the results in the mode struct */
+
+ m->hr = (int) (h_pixels_rnd);
+ m->hss = (int) (h_pixels_rnd + h_front_porch);
+ m->hse = (int) (h_pixels_rnd + h_front_porch + h_sync);
+ m->hfl = (int) (total_pixels);
+
+ m->vr = (int) (v_lines_rnd);
+ m->vss = (int) (v_lines_rnd + v_odd_front_porch_lines);
+ m->vse = (int) (int) (v_lines_rnd + v_odd_front_porch_lines + V_SYNC_RQD);
+ m->vfl = (int) (total_v_lines);
+
+ m->pclk = pixel_freq;
+ m->h_freq = h_freq;
+ m->v_freq = freq;
+
+ return m;
+
+}
+
+
+
+
+/*
+ * parse_command_line() - parse the command line and return an
+ * alloced structure containing the results. On error print usage
+ * and return NULL.
+ */
+
+options *parse_command_line (int argc, char *argv[])
+{
+ int n;
+
+ options *o = (options *) calloc (1, sizeof (options));
+
+ if (argc < 4) goto bad_option;
+
+ o->x = atoi (argv[1]);
+ o->y = atoi (argv[2]);
+ o->v_freq = atof (argv[3]);
+
+ /* XXX should check for errors in the above */
+
+ n = 4;
+
+ while (n < argc) {
+ if ((strcmp (argv[n], "-v") == 0) ||
+ (strcmp (argv[n], "--verbose") == 0)) {
+ global_verbose = 1;
+ } else if ((strcmp (argv[n], "-f") == 0) ||
+ (strcmp (argv[n], "--fbmode") == 0)) {
+ o->fbmode = 1;
+ } else if ((strcmp (argv[n], "-x") == 0) ||
+ (strcmp (argv[n], "--xorgmode") == 0) ||
+ (strcmp (argv[n], "--xf86mode") == 0)) {
+ o->xorgmode = 1;
+ } else {
+ goto bad_option;
+ }
+
+ n++;
+ }
+
+ /* if neither xorgmode nor fbmode were requested, default to
+ xorgmode */
+
+ if (!o->fbmode && !o->xorgmode) o->xorgmode = 1;
+
+ return o;
+
+ bad_option:
+
+ fprintf (stderr, "\n");
+ fprintf (stderr, "usage: %s x y refresh [-v|--verbose] "
+ "[-f|--fbmode] [-x|--xorgmode]\n", argv[0]);
+
+ fprintf (stderr, "\n");
+
+ fprintf (stderr, " x : the desired horizontal "
+ "resolution (required)\n");
+ fprintf (stderr, " y : the desired vertical "
+ "resolution (required)\n");
+ fprintf (stderr, " refresh : the desired refresh "
+ "rate (required)\n");
+ fprintf (stderr, " -v|--verbose : enable verbose printouts "
+ "(traces each step of the computation)\n");
+ fprintf (stderr, " -f|--fbmode : output an fbset(8)-style mode "
+ "description\n");
+ fprintf (stderr, " -x|--xorgmode : output an "__XSERVERNAME__"-style mode "
+ "description (this is the default\n"
+ " if no mode description is requested)\n");
+
+ fprintf (stderr, "\n");
+
+ free (o);
+ return NULL;
+
+}
+
+
+
+int main (int argc, char *argv[])
+{
+ mode *m;
+ options *o;
+
+ o = parse_command_line (argc, argv);
+ if (!o) exit (1);
+
+ m = vert_refresh (o->x, o->y, o->v_freq, 0, 0);
+ if (!m) exit (1);
+
+ if (o->xorgmode)
+ print_xf86_mode(m);
+
+ if (o->fbmode)
+ print_fb_mode(m);
+
+ return 0;
+
+}
diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c
index 21fe0c812..11b1f25eb 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.c
+++ b/xorg-server/hw/xfree86/vbe/vbe.c
@@ -345,7 +345,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
char *str;
CARD16 major, *modes;
- bzero(pVbe->memory, sizeof(VbeInfoBlock));
+ memset(pVbe->memory, 0, sizeof(VbeInfoBlock));
/*
Input:
@@ -370,7 +370,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
block = calloc(sizeof(VbeInfoBlock), 1);
block->VESASignature[0] = ((char*)pVbe->memory)[0];
@@ -418,7 +418,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
memcpy(&block->OemData, ((char*)pVbe->memory) + 256, 256);
}
- return (block);
+ return block;
}
void
@@ -493,10 +493,10 @@ VBEGetVBEMode(vbeInfoPtr pVbe, int *mode)
if (R16(pVbe->pInt10->ax) == 0x4f) {
*mode = R16(pVbe->pInt10->bx);
- return (TRUE);
+ return TRUE;
}
- return (FALSE);
+ return FALSE;
}
VbeModeInfoBlock *
@@ -504,7 +504,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
{
VbeModeInfoBlock *block = NULL;
- bzero(pVbe->memory, sizeof(VbeModeInfoBlock));
+ memset(pVbe->memory, 0, sizeof(VbeModeInfoBlock));
/*
Input:
@@ -525,7 +525,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
pVbe->pInt10->di = SEG_OFF(pVbe->real_mode_base);
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
block = calloc(sizeof(VbeModeInfoBlock), 1);
@@ -591,7 +591,7 @@ VBEGetModeInfo(vbeInfoPtr pVbe, int mode)
else
memcpy(&block->PhysBasePtr, ((char*)pVbe->memory) + 40, 216);
- return (block);
+ return block;
}
void
@@ -657,7 +657,7 @@ VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
pVbe->pInt10->cx = 0x000f;
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
if (function == MODE_SAVE) {
int npages = (R16(pVbe->pInt10->bx) * 64) / 4096 + 1;
@@ -665,7 +665,7 @@ VBESaveRestore(vbeInfoPtr pVbe, vbeSaveRestoreFunction function,
real_mode_pages)) == NULL) {
xf86DrvMsg(screen, X_ERROR,
"Cannot allocate memory to save SVGA state.\n");
- return (FALSE);
+ return FALSE;
}
}
*size = pVbe->pInt10->bx * 64;
@@ -716,9 +716,9 @@ VBEBankSwitch(vbeInfoPtr pVbe, unsigned int iBank, int window)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
- return (TRUE);
+ return TRUE;
}
Bool
@@ -726,7 +726,7 @@ VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
int width, int *pixels, int *bytes, int *max)
{
if (command < SCANWID_SET || command > SCANWID_GET_MAX)
- return (FALSE);
+ return FALSE;
/*
Input:
@@ -755,7 +755,7 @@ VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
if (command == SCANWID_GET || command == SCANWID_GET_MAX) {
if (pixels)
@@ -766,7 +766,7 @@ VBESetGetLogicalScanlineLength(vbeInfoPtr pVbe, vbeScanwidthCommand command,
*max = R16(pVbe->pInt10->dx);
}
- return (TRUE);
+ return TRUE;
}
Bool
@@ -780,9 +780,9 @@ VBESetDisplayStart(vbeInfoPtr pVbe, int x, int y, Bool wait_retrace)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
- return (TRUE);
+ return TRUE;
}
Bool
@@ -794,12 +794,12 @@ VBEGetDisplayStart(vbeInfoPtr pVbe, int *x, int *y)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (FALSE);
+ return FALSE;
*x = pVbe->pInt10->cx;
*y = pVbe->pInt10->dx;
- return (TRUE);
+ return TRUE;
}
int
@@ -827,7 +827,7 @@ VBESetGetDACPaletteFormat(vbeInfoPtr pVbe, int bits)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (0);
+ return 0;
return (bits != 0 ? bits : (pVbe->pInt10->bx >> 8) & 0x00ff);
}
@@ -878,15 +878,15 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
if (set)
- return (data);
+ return data;
data = malloc(num * sizeof(CARD32));
memcpy(data, pVbe->memory, num * sizeof(CARD32));
- return (data);
+ return data;
}
VBEpmi *
@@ -915,14 +915,14 @@ VBEGetVBEpmi(vbeInfoPtr pVbe)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (NULL);
+ return NULL;
pmi = malloc(sizeof(VBEpmi));
pmi->seg_tbl = R16(pVbe->pInt10->es);
pmi->tbl_off = R16(pVbe->pInt10->di);
pmi->tbl_len = R16(pVbe->pInt10->cx);
- return (pmi);
+ return pmi;
}
#if 0
@@ -1034,9 +1034,9 @@ VBEGetPixelClock(vbeInfoPtr pVbe, int mode, int clock)
xf86ExecX86int10(pVbe->pInt10);
if (R16(pVbe->pInt10->ax) != 0x4f)
- return (0);
+ return 0;
- return (pVbe->pInt10->cx);
+ return pVbe->pInt10->cx;
}
Bool
diff --git a/xorg-server/hw/xfree86/vgahw/vgaCmap.c b/xorg-server/hw/xfree86/vgahw/vgaCmap.c
index e337b42c0..a65bb5e86 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaCmap.c
+++ b/xorg-server/hw/xfree86/vgahw/vgaCmap.c
@@ -51,7 +51,7 @@ vgaListInstalledColormaps(pScreen, pmaps)
* is always a colormap installed */
*pmaps = GetInstalledmiColormap(pScreen)->mid;
- return(1);
+ return 1;
}
int
@@ -63,7 +63,7 @@ vgaGetInstalledColormaps(pScreen, pmaps)
* is always a colormap installed */
*pmaps = GetInstalledmiColormap(pScreen);
- return(1);
+ return 1;
}
int vgaCheckColorMap(ColormapPtr pmap)
diff --git a/xorg-server/hw/xfree86/vgahw/vgaHW.c b/xorg-server/hw/xfree86/vgahw/vgaHW.c
index 396a3cc62..7b1c95e62 100644
--- a/xorg-server/hw/xfree86/vgahw/vgaHW.c
+++ b/xorg-server/hw/xfree86/vgahw/vgaHW.c
@@ -658,7 +658,7 @@ vgaHWSaveScreen(ScreenPtr pScreen, int mode)
if ((pScrn != NULL) && pScrn->vtSema) {
vgaHWBlankScreen(pScrn, on);
}
- return (TRUE);
+ return TRUE;
}
@@ -1351,7 +1351,7 @@ vgaHWInit(ScrnInfoPtr scrninfp, DisplayModePtr mode)
regp->Attribute[19] = 0x00;
regp->Attribute[20] = 0x00;
- return(TRUE);
+ return TRUE;
}
/*
@@ -1479,8 +1479,7 @@ vgaHWGetHWRecPrivate(void)
static void
vgaHWFreeRegs(vgaRegPtr regp)
{
- if (regp->CRTC)
- free(regp->CRTC);
+ free(regp->CRTC);
regp->CRTC =
regp->Sequencer =
diff --git a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c
index b1fda1cd6..cc7e810ca 100644
--- a/xorg-server/hw/xfree86/xaa/xaaBitBlt.c
+++ b/xorg-server/hw/xfree86/xaa/xaaBitBlt.c
@@ -118,8 +118,8 @@ XAABitBlt(
fastExpose = 0;
}
} else {
- REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
- REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
+ RegionInit(&rgnDst, &fastBox, 1);
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip);
}
dstx += pDstDrawable->x;
@@ -128,9 +128,9 @@ XAABitBlt(
if (pDstDrawable->type == DRAWABLE_WINDOW) {
if (!((WindowPtr)pDstDrawable)->realized) {
if (!fastClip)
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return NULL;
}
}
@@ -153,8 +153,8 @@ XAABitBlt(
blown region and call intersect */
cclip = pGC->pCompositeClip;
- if (REGION_NUM_RECTS(cclip) == 1) {
- BoxPtr pBox = REGION_RECTS(cclip);
+ if (RegionNumRects(cclip) == 1) {
+ BoxPtr pBox = RegionRects(cclip);
if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;
if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;
@@ -163,37 +163,37 @@ XAABitBlt(
/* Check to see if the region is empty */
if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
- REGION_NULL(pGC->pScreen, &rgnDst);
+ RegionNull(&rgnDst);
} else {
- REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
+ RegionInit(&rgnDst, &fastBox, 1);
}
} else {
/* We must turn off fastClip now, since we must create
a full blown region. It is intersected with the
composite clip below. */
fastClip = 0;
- REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
+ RegionInit(&rgnDst, &fastBox,1);
}
} else {
- REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
+ RegionTranslate(&rgnDst, -dx, -dy);
}
if (!fastClip) {
- REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
+ RegionIntersect(&rgnDst, &rgnDst,
pGC->pCompositeClip);
}
/* Do bit blitting */
- numRects = REGION_NUM_RECTS(&rgnDst);
+ numRects = RegionNumRects(&rgnDst);
if (numRects && width && height) {
if(!(pptSrc = (DDXPointPtr)malloc(numRects *
sizeof(DDXPointRec)))) {
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return NULL;
}
- pbox = REGION_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
ppt = pptSrc;
for (i = numRects; --i >= 0; pbox++, ppt++) {
ppt->x = pbox->x1 + dx;
@@ -214,8 +214,8 @@ XAABitBlt(
(int)origSource.height,
origDest.x, origDest.y, bitPlane);
}
- REGION_UNINIT(pGC->pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if (freeSrcClip)
- REGION_DESTROY(pGC->pScreen, prgnSrcClip);
+ RegionDestroy(prgnSrcClip);
return prgnExposed;
}
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c
index eefd8d38d..5e594633d 100644
--- a/xorg-server/hw/xfree86/xaa/xaaCpyArea.c
+++ b/xorg-server/hw/xfree86/xaa/xaaCpyArea.c
@@ -95,8 +95,8 @@ XAADoBitBlt(
((pSrc->type == DRAWABLE_WINDOW) &&
(pDst->type == DRAWABLE_WINDOW)));
- pbox = REGION_RECTS(prgnDst);
- nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = RegionRects(prgnDst);
+ nbox = RegionNumRects(prgnDst);
pboxNew1 = NULL;
pptNew1 = NULL;
@@ -148,8 +148,8 @@ XAADoBitBlt(
pboxNew2 = (BoxPtr)malloc(sizeof(BoxRec) * nbox);
pptNew2 = (DDXPointPtr)malloc(sizeof(DDXPointRec) * nbox);
if(!pboxNew2 || !pptNew2) {
- if (pptNew2) free(pptNew2);
- if (pboxNew2) free(pboxNew2);
+ free(pptNew2);
+ free(pboxNew2);
if (pboxNew1) {
free(pptNew1);
free(pboxNew1);
@@ -204,8 +204,8 @@ XAADoImageWrite(
int srcwidth;
unsigned char* psrcBase; /* start of image */
unsigned char* srcPntr; /* index into the image */
- BoxPtr pbox = REGION_RECTS(prgnDst);
- int nbox = REGION_NUM_RECTS(prgnDst);
+ BoxPtr pbox = RegionRects(prgnDst);
+ int nbox = RegionNumRects(prgnDst);
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
int Bpp = pSrc->bitsPerPixel >> 3;
@@ -233,8 +233,8 @@ XAADoImageRead(
int dstwidth;
unsigned char* pdstBase; /* start of image */
unsigned char* dstPntr; /* index into the image */
- BoxPtr pbox = REGION_RECTS(prgnDst);
- int nbox = REGION_NUM_RECTS(prgnDst);
+ BoxPtr pbox = RegionRects(prgnDst);
+ int nbox = RegionNumRects(prgnDst);
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
int Bpp = pSrc->bitsPerPixel >> 3; /* wouldn't get here unless both
src and dst have same bpp */
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c
index 358cb6fb2..2d036c936 100644
--- a/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c
+++ b/xorg-server/hw/xfree86/xaa/xaaCpyPlane.c
@@ -76,8 +76,8 @@ XAACopyPlane1toNColorExpand(
DDXPointPtr pptSrc )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pbox = REGION_RECTS(rgnDst);
- int numrects = REGION_NUM_RECTS(rgnDst);
+ BoxPtr pbox = RegionRects(rgnDst);
+ int numrects = RegionNumRects(rgnDst);
unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
int srcwidth = ((PixmapPtr)pSrc)->devKind;
@@ -101,8 +101,8 @@ XAACopyPlaneNtoNColorExpand(
DDXPointPtr pptSrc
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pbox = REGION_RECTS(rgnDst);
- int numrects = REGION_NUM_RECTS(rgnDst);
+ BoxPtr pbox = RegionRects(rgnDst);
+ int numrects = RegionNumRects(rgnDst);
unsigned char *src = ((PixmapPtr)pSrc)->devPrivate.ptr;
unsigned char *data, *srcPtr, *dataPtr;
int srcwidth = ((PixmapPtr)pSrc)->devKind;
@@ -168,14 +168,14 @@ XAAPushPixelsSolidColorExpansion(
int xOrg, int yOrg )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
+ int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
BoxPtr pbox, pClipBoxes;
int nboxes, srcx, srcy;
xRectangle TheRect;
unsigned char *src = pBitMap->devPrivate.ptr;
int srcwidth = pBitMap->devKind;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
TheRect.x = xOrg;
diff --git a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c
index 34f460f24..d8608b095 100644
--- a/xorg-server/hw/xfree86/xaa/xaaCpyWin.c
+++ b/xorg-server/hw/xfree86/xaa/xaaCpyWin.c
@@ -47,20 +47,20 @@ XAACopyWindow(
return;
}
- pwinRoot = WindowTable[pScreen->myNum];
+ pwinRoot = pScreen->root;
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
- pbox = REGION_RECTS(&rgnDst);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
if(!nbox ||
!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
return;
}
ppt = pptSrc;
@@ -78,5 +78,5 @@ XAACopyWindow(
&(infoRec->ScratchGC), &rgnDst, pptSrc);
free(pptSrc);
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
diff --git a/xorg-server/hw/xfree86/xaa/xaaDashLine.c b/xorg-server/hw/xfree86/xaa/xaaDashLine.c
index 63233e05d..adae2e583 100644
--- a/xorg-server/hw/xfree86/xaa/xaaDashLine.c
+++ b/xorg-server/hw/xfree86/xaa/xaaDashLine.c
@@ -1,334 +1,334 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include <X11/X.h>
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "miline.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-void
-#ifdef POLYSEGMENT
-XAAPolySegmentDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-#else
-XAAPolyLinesDashed(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode, /* Origin or Previous */
- int npt, /* number of points */
- DDXPointPtr pptInit
-#endif
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
- XAAGetGCKey());
- BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
- int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
- unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
- int xorg = pDrawable->x;
- int yorg = pDrawable->y;
- int nbox;
- BoxPtr pbox;
-#ifndef POLYSEGMENT
- DDXPointPtr ppt;
-#endif
- unsigned int oc1, oc2;
- int dmin, dmaj, e, octant;
- int x1, x2, y1, y2, tmp, len, offset;
- int PatternLength, PatternOffset;
-
- if(!nboxInit)
- return;
-
- if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) {
- int minValX = infoRec->DashedLineLimits.x1;
- int maxValX = infoRec->DashedLineLimits.x2;
- int minValY = infoRec->DashedLineLimits.y1;
- int maxValY = infoRec->DashedLineLimits.y2;
-#ifdef POLYSEGMENT
- int n = nseg;
- xSegment *s = pSeg;
-
- while (n--)
-#else
- int n = npt;
- int xorgtmp = xorg;
- int yorgtmp = yorg;
-
- ppt = pptInit;
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
- while (--n)
-#endif
- {
-#ifdef POLYSEGMENT
- x1 = s->x1 + xorg;
- y1 = s->y1 + yorg;
- x2 = s->x2 + xorg;
- y2 = s->y2 + yorg;
- s++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorgtmp = x1;
- yorgtmp = y1;
- }
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
-#endif
- if (x1 > maxValX || x1 < minValX ||
- x2 > maxValX || x2 < minValX ||
- y1 > maxValY || y1 < minValY ||
- y2 > maxValY || y2 < minValY) {
-#ifdef POLYSEGMENT
- XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
-#else
- XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
-#endif
- return;
- }
- }
- }
-
- PatternLength = pGCPriv->DashLength;
- PatternOffset = pGC->dashOffset % PatternLength;
-
- (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel,
- (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1,
- pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern);
-
-
-#ifdef POLYSEGMENT
- while (nseg--)
-#else
- ppt = pptInit;
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
- while(--npt)
-#endif
- {
- nbox = nboxInit;
- pbox = pboxInit;
-
-#ifdef POLYSEGMENT
- x1 = pSeg->x1 + xorg;
- y1 = pSeg->y1 + yorg;
- x2 = pSeg->x2 + xorg;
- y2 = pSeg->y2 + yorg;
- pSeg++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorg = x1;
- yorg = y1;
- }
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
-#endif
-
-
- if (infoRec->SubsequentDashedBresenhamLine) {
- if((dmaj = x2 - x1) < 0) {
- dmaj = -dmaj;
- octant = XDECREASING;
- } else octant = 0;
-
- if((dmin = y2 - y1) < 0) {
- dmin = -dmin;
- octant |= YDECREASING;
- }
-
- if(dmin >= dmaj){
- tmp = dmin; dmin = dmaj; dmaj = tmp;
- octant |= YMAJOR;
- }
-
- e = -dmaj - ((bias >> octant) & 1);
- len = dmaj;
- dmin <<= 1;
- dmaj <<= 1;
- } else { /* Muffle compiler */
- dmin = dmaj = e = octant = len = 0;
- }
-
- while(nbox--) {
- oc1 = oc2 = 0;
- OUTCODES(oc1, x1, y1, pbox);
- OUTCODES(oc2, x2, y2, pbox);
- if (!(oc1 | oc2)) { /* uncliped */
- if(infoRec->SubsequentDashedTwoPointLine) {
- (*infoRec->SubsequentDashedTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST, PatternOffset);
- } else {
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant, PatternOffset);
- }
- break;
- } else if (oc1 & oc2) { /* completely clipped */
- pbox++;
- } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) {
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
-
- if(infoRec->SubsequentDashedBresenhamLine) {
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant, PatternOffset);
- } else {
- (*infoRec->SubsequentDashedTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST, PatternOffset
- );
- }
- (*infoRec->DisableClipping)(infoRec->pScrn);
- pbox++;
- } else {
- int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
- int clip1 = 0, clip2 = 0;
- int err, adx, ady;
-
- if(octant & YMAJOR) {
- ady = dmaj >> 1;
- adx = dmin >> 1;
- } else {
- ady = dmin >> 1;
- adx = dmaj >> 1;
- }
-
- if (miZeroClipLine(pbox->x1, pbox->y1,
- pbox->x2 - 1, pbox->y2 - 1,
- &new_x1, &new_y1, &new_x2, &new_y2,
- adx, ady, &clip1, &clip2,
- octant, bias, oc1, oc2) == -1)
- {
- pbox++;
- continue;
- }
-
- if (octant & YMAJOR)
- len = abs(new_y2 - new_y1);
- else
- len = abs(new_x2 - new_x1);
-#ifdef POLYSEGMENT
- if (clip2 != 0 || pGC->capStyle != CapNotLast)
- len++;
-#else
- len += (clip2 != 0);
-#endif
- if (len) {
- int abserr, clipdx, clipdy;
- /* unwind bresenham error term to first point */
- if (clip1) {
- clipdx = abs(new_x1 - x1);
- clipdy = abs(new_y1 - y1);
-
- if (octant & YMAJOR)
- err = e + clipdy*dmin - clipdx*dmaj;
- else
- err = e + clipdx*dmin - clipdy*dmaj;
- } else
- err = e;
-
-#define range infoRec->DashedBresenhamLineErrorTermBits
- abserr = abs(err);
- while((abserr & range) ||
- (dmaj & range) ||
- (dmin & range)) {
- dmin >>= 1;
- dmaj >>= 1;
- abserr >>= 1;
- err /= 2;
- }
-
- if(octant & YMAJOR)
- offset = abs(new_y1 - y1);
- else
- offset = abs(new_x1 - x1);
-
- offset += PatternOffset;
- offset %= PatternLength;
-
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, new_x1, new_y1,
- dmaj, dmin, err, len, octant, offset);
- }
- pbox++;
- }
- } /* while (nbox--) */
-#ifndef POLYSEGMENT
- len = abs(y2 - y1);
- tmp = abs(x2 - x1);
- PatternOffset += (len > tmp) ? len : tmp;
- PatternOffset %= PatternLength;
-#endif
- } /* while (nline--) */
-
-#ifndef POLYSEGMENT
- /* paint the last point if the end style isn't CapNotLast.
- (Assume that a projecting, butt, or round cap that is one
- pixel wide is the same as the single pixel of the endpoint.)
- */
-
- if ((pGC->capStyle != CapNotLast) &&
- ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
- (ppt->y + yorg != pptInit->y + pDrawable->y) ||
- (ppt == pptInit + 1)))
- {
- nbox = nboxInit;
- pbox = pboxInit;
- while (nbox--) {
- if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
- (x2 < pbox->x2) && (y2 < pbox->y2))
- {
- if(infoRec->SubsequentDashedTwoPointLine) {
- (*infoRec->SubsequentDashedTwoPointLine)(
- infoRec->pScrn, x2, y2, x2, y2, 0,
- PatternOffset);
- } else {
- (*infoRec->SubsequentDashedBresenhamLine)(
- infoRec->pScrn, x2, y2, 2, 0, -1,
- 1, 0, PatternOffset);
- }
- break;
- } else
- pbox++;
- }
- }
-#endif
-
- SET_SYNC_FLAG(infoRec);
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+void
+#ifdef POLYSEGMENT
+XAAPolySegmentDashed(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+#else
+XAAPolyLinesDashed(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode, /* Origin or Previous */
+ int npt, /* number of points */
+ DDXPointPtr pptInit
+#endif
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
+ BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+ int nboxInit = RegionNumRects(pGC->pCompositeClip);
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ int nbox;
+ BoxPtr pbox;
+#ifndef POLYSEGMENT
+ DDXPointPtr ppt;
+#endif
+ unsigned int oc1, oc2;
+ int dmin, dmaj, e, octant;
+ int x1, x2, y1, y2, tmp, len, offset;
+ int PatternLength, PatternOffset;
+
+ if(!nboxInit)
+ return;
+
+ if (infoRec->DashedLineFlags & LINE_LIMIT_COORDS) {
+ int minValX = infoRec->DashedLineLimits.x1;
+ int maxValX = infoRec->DashedLineLimits.x2;
+ int minValY = infoRec->DashedLineLimits.y1;
+ int maxValY = infoRec->DashedLineLimits.y2;
+#ifdef POLYSEGMENT
+ int n = nseg;
+ xSegment *s = pSeg;
+
+ while (n--)
+#else
+ int n = npt;
+ int xorgtmp = xorg;
+ int yorgtmp = yorg;
+
+ ppt = pptInit;
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+ while (--n)
+#endif
+ {
+#ifdef POLYSEGMENT
+ x1 = s->x1 + xorg;
+ y1 = s->y1 + yorg;
+ x2 = s->x2 + xorg;
+ y2 = s->y2 + yorg;
+ s++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorgtmp = x1;
+ yorgtmp = y1;
+ }
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+#endif
+ if (x1 > maxValX || x1 < minValX ||
+ x2 > maxValX || x2 < minValX ||
+ y1 > maxValY || y1 < minValY ||
+ y2 > maxValY || y2 < minValY) {
+#ifdef POLYSEGMENT
+ XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
+#else
+ XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
+#endif
+ return;
+ }
+ }
+ }
+
+ PatternLength = pGCPriv->DashLength;
+ PatternOffset = pGC->dashOffset % PatternLength;
+
+ (*infoRec->SetupForDashedLine)(infoRec->pScrn, pGC->fgPixel,
+ (pGC->lineStyle == LineDoubleDash) ? pGC->bgPixel : -1,
+ pGC->alu, pGC->planemask, PatternLength, pGCPriv->DashPattern);
+
+
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+
+ if (infoRec->SubsequentDashedBresenhamLine) {
+ if((dmaj = x2 - x1) < 0) {
+ dmaj = -dmaj;
+ octant = XDECREASING;
+ } else octant = 0;
+
+ if((dmin = y2 - y1) < 0) {
+ dmin = -dmin;
+ octant |= YDECREASING;
+ }
+
+ if(dmin >= dmaj){
+ tmp = dmin; dmin = dmaj; dmaj = tmp;
+ octant |= YMAJOR;
+ }
+
+ e = -dmaj - ((bias >> octant) & 1);
+ len = dmaj;
+ dmin <<= 1;
+ dmaj <<= 1;
+ } else { /* Muffle compiler */
+ dmin = dmaj = e = octant = len = 0;
+ }
+
+ while(nbox--) {
+ oc1 = oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if (!(oc1 | oc2)) { /* uncliped */
+ if(infoRec->SubsequentDashedTwoPointLine) {
+ (*infoRec->SubsequentDashedTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST, PatternOffset);
+ } else {
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant, PatternOffset);
+ }
+ break;
+ } else if (oc1 & oc2) { /* completely clipped */
+ pbox++;
+ } else if (infoRec->ClippingFlags & HARDWARE_CLIP_DASHED_LINE) {
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
+
+ if(infoRec->SubsequentDashedBresenhamLine) {
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant, PatternOffset);
+ } else {
+ (*infoRec->SubsequentDashedTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST, PatternOffset
+ );
+ }
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+ pbox++;
+ } else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int err, adx, ady;
+
+ if(octant & YMAJOR) {
+ ady = dmaj >> 1;
+ adx = dmin >> 1;
+ } else {
+ ady = dmin >> 1;
+ adx = dmaj >> 1;
+ }
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (octant & YMAJOR)
+ len = abs(new_y2 - new_y1);
+ else
+ len = abs(new_x2 - new_x1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ int abserr, clipdx, clipdy;
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+
+ if (octant & YMAJOR)
+ err = e + clipdy*dmin - clipdx*dmaj;
+ else
+ err = e + clipdx*dmin - clipdy*dmaj;
+ } else
+ err = e;
+
+#define range infoRec->DashedBresenhamLineErrorTermBits
+ abserr = abs(err);
+ while((abserr & range) ||
+ (dmaj & range) ||
+ (dmin & range)) {
+ dmin >>= 1;
+ dmaj >>= 1;
+ abserr >>= 1;
+ err /= 2;
+ }
+
+ if(octant & YMAJOR)
+ offset = abs(new_y1 - y1);
+ else
+ offset = abs(new_x1 - x1);
+
+ offset += PatternOffset;
+ offset %= PatternLength;
+
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, new_x1, new_y1,
+ dmaj, dmin, err, len, octant, offset);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+#ifndef POLYSEGMENT
+ len = abs(y2 - y1);
+ tmp = abs(x2 - x1);
+ PatternOffset += (len > tmp) ? len : tmp;
+ PatternOffset %= PatternLength;
+#endif
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--) {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) && (y2 < pbox->y2))
+ {
+ if(infoRec->SubsequentDashedTwoPointLine) {
+ (*infoRec->SubsequentDashedTwoPointLine)(
+ infoRec->pScrn, x2, y2, x2, y2, 0,
+ PatternOffset);
+ } else {
+ (*infoRec->SubsequentDashedBresenhamLine)(
+ infoRec->pScrn, x2, y2, 2, 0, -1,
+ 1, 0, PatternOffset);
+ }
+ break;
+ } else
+ pbox++;
+ }
+ }
+#endif
+
+ SET_SYNC_FLAG(infoRec);
+}
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillArc.c b/xorg-server/hw/xfree86/xaa/xaaFillArc.c
index d83922ce0..824d2af1d 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFillArc.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFillArc.c
@@ -1,213 +1,213 @@
-/*
- * Copyright 1996 The XFree86 Project
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
- */
-
-/*
- * Filled solid arcs, based on cfbfillarc.c.
- *
- * Fill arc using calls to low-level span fill. Because the math for
- * each span can be done concurrently with the drawing of the span
- * with a graphics coprocessor operation, this is faster than just
- * using miPolyFillArc, which first calculates all the spans and then
- * calls FillSpans.
- *
- * Clipped arcs are dispatched to FillSpans.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <limits.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-#include "mifillarc.h"
-#include "mi.h"
-
-/*
- * This is based on the integer-math versions from mi. Perhaps on a
- * Pentium, the floating-point (double)-math version is faster.
- */
-
-static void
-XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- register int x, y, e;
- int yk, xk, ym, xm, dx, dy, xorg, yorg;
- int slw;
- miFillArcRec info;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- miFillArcSetup(arc, &info);
- MIFILLARCSETUP();
- if (pGC->miTranslate)
- {
- xorg += pDraw->x;
- yorg += pDraw->y;
- }
- while (y > 0)
- {
- MIFILLARCSTEP(slw);
- if (slw > 0) {
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x,
- yorg - y, slw, 1);
- if (miFillArcLower(slw))
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- xorg - x, yorg + y + dy, slw, 1);
- }
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-#define ADDSPAN(l,r) \
- if (r >= l) \
- (*infoRec->SubsequentSolidFillRect)( \
- infoRec->pScrn, l, ya, r - l + 1, 1);
-
-#define ADDSLICESPANS(flip) \
- if (!flip) \
- { \
- ADDSPAN(xl, xr); \
- } \
- else \
- { \
- xc = xorg - x; \
- ADDSPAN(xc, xr); \
- xc += slw - 1; \
- ADDSPAN(xl, xc); \
- }
-
-static void
-XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
- register int x, y, e;
- miFillArcRec info;
- miArcSliceRec slice;
- int ya, xl, xr, xc;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- miFillArcSetup(arc, &info);
- miFillArcSliceSetup(arc, &slice, pGC);
- MIFILLARCSETUP();
- slw = arc->height;
- if (slice.flip_top || slice.flip_bot)
- slw += (arc->height >> 1) + 1;
- if (pGC->miTranslate)
- {
- xorg += pDraw->x;
- yorg += pDraw->y;
- slice.edge1.x += pDraw->x;
- slice.edge2.x += pDraw->x;
- }
- while (y > 0)
- {
- MIFILLARCSTEP(slw);
- MIARCSLICESTEP(slice.edge1);
- MIARCSLICESTEP(slice.edge2);
- if (miFillSliceUpper(slice))
- {
- ya = yorg - y;
- MIARCSLICEUPPER(xl, xr, slice, slw);
-
- ADDSLICESPANS(slice.flip_top);
- }
- if (miFillSliceLower(slice))
- {
- ya = yorg + y + dy;
- MIARCSLICELOWER(xl, xr, slice, slw);
- ADDSLICESPANS(slice.flip_bot);
- }
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
-{
- register xArc *arc;
- register int i;
- int x2, y2;
- BoxRec box;
- RegionPtr cclip;
-
- cclip = pGC->pCompositeClip;
-
- if(!REGION_NUM_RECTS(cclip))
- return;
-
- for (arc = parcs, i = narcs; --i >= 0; arc++)
- {
- if (miFillArcEmpty(arc))
- continue;
- if (miCanFillArc(arc))
- {
- box.x1 = arc->x + pDraw->x;
- box.y1 = arc->y + pDraw->y;
- /*
- * Because box.x2 and box.y2 get truncated to 16 bits, and the
- * RECT_IN_REGION test treats the resulting number as a signed
- * integer, the RECT_IN_REGION test alone can go the wrong way.
- * This can result in a server crash because the rendering
- * routines in this file deal directly with cpu addresses
- * of pixels to be stored, and do not clip or otherwise check
- * that all such addresses are within their respective pixmaps.
- * So we only allow the RECT_IN_REGION test to be used for
- * values that can be expressed correctly in a signed short.
- */
- x2 = box.x1 + (int)arc->width + 1;
- box.x2 = x2;
- y2 = box.y1 + (int)arc->height + 1;
- box.y2 = y2;
- if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
- (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) )
- {
- if ((arc->angle2 >= FULLCIRCLE) ||
- (arc->angle2 <= -FULLCIRCLE))
- XAAFillEllipseSolid(pDraw, pGC, arc);
- else
- XAAFillArcSliceSolid(pDraw, pGC, arc);
- continue;
- }
- }
- miPolyFillArc(pDraw, pGC, 1, arc);
- }
-}
+/*
+ * Copyright 1996 The XFree86 Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+ */
+
+/*
+ * Filled solid arcs, based on cfbfillarc.c.
+ *
+ * Fill arc using calls to low-level span fill. Because the math for
+ * each span can be done concurrently with the drawing of the span
+ * with a graphics coprocessor operation, this is faster than just
+ * using miPolyFillArc, which first calculates all the spans and then
+ * calls FillSpans.
+ *
+ * Clipped arcs are dispatched to FillSpans.
+ */
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <limits.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "mifillarc.h"
+#include "mi.h"
+
+/*
+ * This is based on the integer-math versions from mi. Perhaps on a
+ * Pentium, the floating-point (double)-math version is faster.
+ */
+
+static void
+XAAFillEllipseSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ register int x, y, e;
+ int yk, xk, ym, xm, dx, dy, xorg, yorg;
+ int slw;
+ miFillArcRec info;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ if (slw > 0) {
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn, xorg - x,
+ yorg - y, slw, 1);
+ if (miFillArcLower(slw))
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ xorg - x, yorg + y + dy, slw, 1);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+#define ADDSPAN(l,r) \
+ if (r >= l) \
+ (*infoRec->SubsequentSolidFillRect)( \
+ infoRec->pScrn, l, ya, r - l + 1, 1);
+
+#define ADDSLICESPANS(flip) \
+ if (!flip) \
+ { \
+ ADDSPAN(xl, xr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ ADDSPAN(xc, xr); \
+ xc += slw - 1; \
+ ADDSPAN(xl, xc); \
+ }
+
+static void
+XAAFillArcSliceSolid(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ register int x, y, e;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int ya, xl, xr, xc;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ miFillArcSetup(arc, &info);
+ miFillArcSliceSetup(arc, &slice, pGC);
+ MIFILLARCSETUP();
+ slw = arc->height;
+ if (slice.flip_top || slice.flip_bot)
+ slw += (arc->height >> 1) + 1;
+ if (pGC->miTranslate)
+ {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ slice.edge1.x += pDraw->x;
+ slice.edge2.x += pDraw->x;
+ }
+ while (y > 0)
+ {
+ MIFILLARCSTEP(slw);
+ MIARCSLICESTEP(slice.edge1);
+ MIARCSLICESTEP(slice.edge2);
+ if (miFillSliceUpper(slice))
+ {
+ ya = yorg - y;
+ MIARCSLICEUPPER(xl, xr, slice, slw);
+
+ ADDSLICESPANS(slice.flip_top);
+ }
+ if (miFillSliceLower(slice))
+ {
+ ya = yorg + y + dy;
+ MIARCSLICELOWER(xl, xr, slice, slw);
+ ADDSLICESPANS(slice.flip_bot);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+void
+XAAPolyFillArcSolid(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
+{
+ register xArc *arc;
+ register int i;
+ int x2, y2;
+ BoxRec box;
+ RegionPtr cclip;
+
+ cclip = pGC->pCompositeClip;
+
+ if(!RegionNumRects(cclip))
+ return;
+
+ for (arc = parcs, i = narcs; --i >= 0; arc++)
+ {
+ if (miFillArcEmpty(arc))
+ continue;
+ if (miCanFillArc(arc))
+ {
+ box.x1 = arc->x + pDraw->x;
+ box.y1 = arc->y + pDraw->y;
+ /*
+ * Because box.x2 and box.y2 get truncated to 16 bits, and the
+ * RECT_IN_REGION test treats the resulting number as a signed
+ * integer, the RECT_IN_REGION test alone can go the wrong way.
+ * This can result in a server crash because the rendering
+ * routines in this file deal directly with cpu addresses
+ * of pixels to be stored, and do not clip or otherwise check
+ * that all such addresses are within their respective pixmaps.
+ * So we only allow the RECT_IN_REGION test to be used for
+ * values that can be expressed correctly in a signed short.
+ */
+ x2 = box.x1 + (int)arc->width + 1;
+ box.x2 = x2;
+ y2 = box.y1 + (int)arc->height + 1;
+ box.y2 = y2;
+ if ( (x2 <= SHRT_MAX) && (y2 <= SHRT_MAX) &&
+ (RegionContainsRect(cclip, &box) == rgnIN) )
+ {
+ if ((arc->angle2 >= FULLCIRCLE) ||
+ (arc->angle2 <= -FULLCIRCLE))
+ XAAFillEllipseSolid(pDraw, pGC, arc);
+ else
+ XAAFillArcSliceSolid(pDraw, pGC, arc);
+ continue;
+ }
+ }
+ miPolyFillArc(pDraw, pGC, 1, arc);
+ }
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c
index 6f11e35ff..b8347b336 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFillPoly.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFillPoly.c
@@ -1,962 +1,962 @@
-
-/*
- * Copyright 1996 The XFree86 Project
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
- * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- */
-
-/*
- * Written by Mark Vojkovich. Loosly based on an original version
- * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which
- * only did solid rectangles and didn't have trapezoid support.
- *
- */
-
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "micoord.h"
-
-#include "xaa.h"
-#include "xaalocal.h"
-
-#define POLY_USE_MI 0
-#define POLY_FULLY_CLIPPED 1
-#define POLY_IS_EASY 2
-
-
-#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\
- x = intToX(vertex); \
- if ((dy = intToY(c) - y)) { \
- DX = dx = intToX(c) - x; \
- step = 0; \
- if (dx >= 0) \
- { \
- e = 0; \
- sign = 1; \
- if (dx >= dy) {\
- step = dx / dy; \
- dx %= dy; \
- } \
- } \
- else \
- { \
- e = 1 - dy; \
- sign = -1; \
- dx = -dx; \
- if (dx >= dy) { \
- step = - (dx / dy); \
- dx %= dy; \
- } \
- } \
- } \
- x += origin; \
- vertex = c; \
-}
-
-#define Step(x,dx,dy,e,sign,step) {\
- x += step; \
- if ((e += dx) > 0) \
- { \
- x += sign; \
- e -= dy; \
- } \
-}
-
-#define FixError(x, dx, dy, e, sign, step, h) { \
- e += (h) * dx; \
- x += (h) * step; \
- if(e > 0) { \
- x += e * sign/dy; \
- e %= dy; \
- if(e) { \
- x += sign; \
- e -= dy; \
- } \
- } \
-}
-
-
-/*
- XAAIsEasyPoly -
-
- Checks CoordModeOrigin one rect polygons to see if we need
- to use Mi.
- Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY
- as well as the pointer to the "top" point and the y
- extents.
-*/
-
-int
-XAAIsEasyPolygon(
- DDXPointPtr ptsIn,
- int count,
- BoxPtr extents,
- int origin,
- DDXPointPtr *topPoint, /* return */
- int *topY, int *bottomY, /* return */
- int shape
-){
- int c = 0, vertex1, vertex2;
-
- *topY = 32767;
- *bottomY = 0;
-
- origin -= (origin & 0x8000) << 1;
- vertex1 = extents->x1 - origin;
- vertex2 = extents->x2 - origin /* - 0x00010001 */;
- /* I think this was an error in cfb ^ */
-
- if (shape == Convex) {
- while (count--) {
- c = *((int*)ptsIn);
- if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
- return POLY_USE_MI;
-
- c = intToY(c);
- if (c < *topY) {
- *topY = c;
- *topPoint = ptsIn;
- }
- ptsIn++;
- if (c > *bottomY) *bottomY = c;
- }
- } else {
- int yFlip = 0;
- int dx2, dx1, x1, x2;
-
- x2 = x1 = -1;
- dx2 = dx1 = 1;
-
- while (count--) {
- c = *((int*)ptsIn);
- if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
- return POLY_USE_MI;
- c = intToY(c);
- if (c < *topY) {
- *topY = c;
- *topPoint = ptsIn;
- }
- ptsIn++;
- if (c > *bottomY) *bottomY = c;
- if (c == x1)
- continue;
- if (dx1 > 0) {
- if (x2 < 0) x2 = c;
- else dx2 = dx1 = (c - x1) >> 31;
- } else if ((c - x1) >> 31 != dx1) {
- dx1 = ~dx1;
- yFlip++;
- }
- x1 = c;
- }
- x1 = (x2 - c) >> 31;
- if (x1 != dx1) yFlip++;
- if (x1 != dx2) yFlip++;
- if (yFlip != 2) {
- if(*topY == *bottomY)
- return POLY_FULLY_CLIPPED;
- else
- return POLY_USE_MI;
- }
- }
- if (*topY == *bottomY)
- return POLY_FULLY_CLIPPED;
-
- return POLY_IS_EASY;
-}
-
-void
-XAAFillPolygonSolid(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int origin, vertex1, vertex2;
- int *vertex1p, *vertex2p, *endp;
- int x1 = 0, x2 = 0;
- int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
- int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
- int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
- int c, y, maxy, h, yoffset;
- DDXPointPtr topPoint;
-
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
- return;
-
- if (mode == CoordModePrevious) {
- register DDXPointPtr ppt = ptsIn + 1;
-
- for (origin = 1; origin < count; origin++, ppt++) {
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- mode = CoordModeOrigin;
- }
-
- if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- origin = coordToInt(pDraw->x, pDraw->y);
-
- switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
- origin, &topPoint, &y, &maxy, shape) ) {
- case POLY_USE_MI:
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- case POLY_FULLY_CLIPPED:
- return;
- }
-
- endp = (int*)ptsIn + count;
- vertex2p = vertex1p = (int *)topPoint;
- origin = pDraw->x;
- yoffset = pDraw->y;
- vertex2 = vertex1 = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *) ptsIn;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- while(1) {
- if (y == intToY(vertex1)) {
- do {
- if (vertex1p == (int *) ptsIn)
- vertex1p = endp;
- c = *--vertex1p;
- Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
- } while (y >= intToY(vertex1));
- h = dy1;
- } else {
- Step(x1,dx1,dy1,e1,sign1,step1)
- h = intToY(vertex1) - y;
- }
- if (y == intToY(vertex2)) {
- do {
- c = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *) ptsIn;
- Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
- } while (y >= intToY(vertex2));
- if (dy2 < h)
- h = dy2;
- } else {
- Step(x2,dx2,dy2,e2,sign2,step2)
- if ((c = (intToY(vertex2) - y)) < h)
- h = c;
- }
-
- /* fill spans for this segment */
- if(DX1 | DX2) {
- if(infoRec->SubsequentSolidFillTrap && (h > 6)) {
- if(x1 == x2) {
- while(x1 == x2) {
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- if(y == maxy) break;
- if(!h) continue;
- }
-
- if(x1 < x2)
- (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
- y + yoffset, h,
- x1, DX1, dy1, e1,
- x2 - 1, DX2, dy2, e2);
- else
- (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
- y + yoffset, h,
- x2, DX2, dy2, e2,
- x1 - 1, DX1, dy1, e1);
- y += h;
- if(--h) {
- FixError(x1,dx1,dy1,e1,sign1,step1,h);
- FixError(x2,dx2,dy2,e2,sign2,step2,h);
- h = 0;
- }
- } else {
- while(1) {
- if (x2 > x1)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x1, y + yoffset, x2 - x1, 1);
- else if (x1 > x2)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x2, y + yoffset, x1 - x2, 1);
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- }
- } else {
- if (x2 > x1)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x1, y + yoffset, x2 - x1, h);
- else if (x1 > x2)
- (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
- x2, y + yoffset, x1 - x2, h);
-
- y += h;
- h = 0;
- }
- if (y == maxy) break;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
-void
-XAAFillPolygonHelper(
- ScrnInfoPtr pScrn,
- DDXPointPtr ptsIn,
- int count,
- DDXPointPtr topPoint,
- int y,
- int maxy,
- int origin,
- RectFuncPtr RectFunc,
- TrapFuncPtr TrapFunc,
- int xorg,
- int yorg,
- XAACacheInfoPtr pCache
-){
- int *vertex1p, *vertex2p, *endp;
- int vertex1, vertex2;
- int x1 = 0, x2 = 0;
- int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
- int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
- int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
- int c, h, yoffset;
-
-
- endp = (int*)ptsIn + count;
- vertex2p = vertex1p = (int *)topPoint;
- yoffset = intToY(origin);
- origin = intToX(origin);
- vertex2 = vertex1 = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *)ptsIn;
-
- while(1) {
- if (y == intToY(vertex1)) {
- do {
- if (vertex1p == (int *) ptsIn)
- vertex1p = endp;
- c = *--vertex1p;
- Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
- } while (y >= intToY(vertex1));
- h = dy1;
- } else {
- Step(x1,dx1,dy1,e1,sign1,step1)
- h = intToY(vertex1) - y;
- }
- if (y == intToY(vertex2)) {
- do {
- c = *vertex2p++;
- if (vertex2p == endp)
- vertex2p = (int *) ptsIn;
- Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
- } while (y >= intToY(vertex2));
- if (dy2 < h)
- h = dy2;
- } else {
- Step(x2,dx2,dy2,e2,sign2,step2)
- if ((c = (intToY(vertex2) - y)) < h)
- h = c;
- }
-
- /* fill spans for this segment */
- if(DX1 | DX2) {
- if(TrapFunc && (h > 6)) {
- if(x1 == x2) {
- while(x1 == x2) {
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- if(y == maxy) break;
- if(!h) continue;
- }
-
- if(x1 < x2)
- (*TrapFunc)(pScrn, y + yoffset, h,
- x1, DX1, dy1, e1,
- x2 - 1, DX2, dy2, e2, xorg, yorg, pCache);
- else
- (*TrapFunc)(pScrn, y + yoffset, h,
- x2, DX2, dy2, e2,
- x1 - 1, DX1, dy1, e1, xorg, yorg, pCache);
- y += h;
- if(--h) {
- FixError(x1,dx1,dy1,e1,sign1,step1,h);
- FixError(x2,dx2,dy2,e2,sign2,step2,h);
- h = 0;
- }
- } else {
- while(1) {
- if (x2 > x1)
- (*RectFunc)(pScrn,
- x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache);
- else if (x1 > x2)
- (*RectFunc)(pScrn,
- x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache);
- y++;
- if (!--h) break;
- Step(x1,dx1,dy1,e1,sign1,step1)
- Step(x2,dx2,dy2,e2,sign2,step2)
- }
- }
- } else {
- if (x2 > x1)
- (*RectFunc)(pScrn,
- x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache);
- else if (x1 > x2)
- (*RectFunc)(pScrn,
- x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache);
-
- y += h;
- h = 0;
- }
- if (y == maxy) break;
- }
-}
-
- /*****************\
- | Solid Helpers |
- \*****************/
-
-static void
-SolidTrapHelper(
- ScrnInfoPtr pScrn,
- int y, int h,
- int x1, int dx1, int dy1, int e1,
- int x2, int dx2, int dy2, int e2,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentSolidFillTrap) (pScrn,
- y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
-}
-
-static void
-SolidRectHelper (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
-}
-
-
- /*********************\
- | Mono 8x8 Patterns |
- \*********************/
-
-static void
-Mono8x8PatternTrapHelper_ScreenOrigin(
- ScrnInfoPtr pScrn,
- int y, int h,
- int x1, int dx1, int dy1, int e1,
- int x2, int dx2, int dy2, int e2,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg,
- y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
-}
-
-static void
-Mono8x8PatternRectHelper_ScreenOrigin (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
- x, y, w, h);
-}
-
-static void
-Mono8x8PatternRectHelper (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- xorg = (x - xorg) & 0x07;
- yorg = (y - yorg) & 0x07;
-
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- int patx = pCache->pat0;
- int paty = pCache->pat1;
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- } else {
- int slot = (yorg << 3) + xorg;
- xorg = pCache->x + pCache->offsets[slot].x;
- yorg = pCache->y + pCache->offsets[slot].y;
- }
- }
-
-
- (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
- x, y, w, h);
-}
-
-
-
- /****************\
- | Cache Expand |
- \****************/
-
-
-static void
-CacheExpandRectHelper (
- ScrnInfoPtr pScrn,
- int X, int Y, int Width, int Height,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
- int cacheWidth;
-
- cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
- infoRec->CacheColorExpandDensity;
-
- phaseY = (Y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (X - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
-
- while(1) {
- w = Width; skipleft = phaseX; x = X;
- blit_h = pCache->h - phaseY;
- if(blit_h > Height) blit_h = Height;
-
- while(1) {
- blit_w = cacheWidth - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenColorExpandFill)(
- pScrn, x, Y, blit_w, blit_h,
- pCache->x, pCache->y + phaseY, skipleft);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- Height -= blit_h;
- if(!Height) break;
- Y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
-}
-
-
-
- /**************\
- | Cache Blit |
- \**************/
-
-
-static void
-CacheBltRectHelper (
- ScrnInfoPtr pScrn,
- int X, int Y, int Width, int Height,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
-
- phaseY = (Y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (X - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
-
- while(1) {
- w = Width; skipleft = phaseX; x = X;
- blit_h = pCache->h - phaseY;
- if(blit_h > Height) blit_h = Height;
-
- while(1) {
- blit_w = pCache->w - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + skipleft, pCache->y + phaseY,
- x, Y, blit_w, blit_h);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- Height -= blit_h;
- if(!Height) break;
- Y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
-}
-
-
- /**********************\
- | Stippled Polygons |
- \**********************/
-
-
-void
-XAAFillPolygonStippled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- int origin, type, patx, paty, fg, bg;
- int y, maxy, xorg, yorg;
- DDXPointPtr topPoint;
- XAACacheInfoPtr pCache = NULL;
- RectFuncPtr RectFunc = NULL;
- TrapFuncPtr TrapFunc = NULL;
-
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
- return;
-
- if (mode == CoordModePrevious) {
- register DDXPointPtr ppt = ptsIn + 1;
-
- for (origin = 1; origin < count; origin++, ppt++) {
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- mode = CoordModeOrigin;
- }
-
- if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
-
- if(pGC->fillStyle == FillStippled) {
- type = (*infoRec->StippledFillChooser)(pGC);
- fg = pGC->fgPixel; bg = -1;
- } else {
- type = (*infoRec->OpaqueStippledFillChooser)(pGC);
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- }
-
-
- if(!type) {
- (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- origin = pDraw->x;
-
- switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
- origin, &topPoint, &y, &maxy, shape) ) {
- case POLY_USE_MI:
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- case POLY_FULLY_CLIPPED:
- return;
- }
-
- xorg = (pDraw->x + pGC->patOrg.x);
- yorg = (pDraw->y + pGC->patOrg.y);
-
-
- if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) {
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg,
- pGC->alu, pGC->planemask);
-
- RectFunc = SolidRectHelper;
- TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL;
- } else
- switch(type) {
- case DO_MONO_8x8:
- patx = pPriv->pattern0; paty = pPriv->pattern1;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_SCREEN_ORIGIN) {
- xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
- RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
- if(infoRec->SubsequentMono8x8PatternFillTrap)
- TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
- } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- } else {
- pCache = &(infoRec->ScratchCacheInfoRec);
- pCache->pat0 = patx;
- pCache->pat1 = paty;
- }
- RectFunc = Mono8x8PatternRectHelper;
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
- patx, paty, fg, bg, pGC->alu, pGC->planemask);
- break;
- case DO_CACHE_EXPAND:
- pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple);
-
- (*infoRec->SetupForScreenToScreenColorExpandFill)(
- infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask);
-
- RectFunc = CacheExpandRectHelper;
- break;
- case DO_CACHE_BLT:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- fg, bg);
- (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, pCache->trans_color);
-
- RectFunc = CacheBltRectHelper;
- break;
- default:
- return;
- }
-
-
- XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
- y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
- /*******************\
- | Tiled Polygons |
- \*******************/
-
-
-void
-XAAFillPolygonTiled(
- DrawablePtr pDraw,
- GCPtr pGC,
- int shape,
- int mode,
- int count,
- DDXPointPtr ptsIn
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- int origin, type, patx, paty;
- int y, maxy, xorg, yorg;
- DDXPointPtr topPoint;
- XAACacheInfoPtr pCache = NULL;
- RectFuncPtr RectFunc = NULL;
- TrapFuncPtr TrapFunc = NULL;
-
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
- return;
-
- if (mode == CoordModePrevious) {
- register DDXPointPtr ppt = ptsIn + 1;
-
- for (origin = 1; origin < count; origin++, ppt++) {
- ppt->x += (ppt-1)->x;
- ppt->y += (ppt-1)->y;
- }
- mode = CoordModeOrigin;
- }
-
- if (REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
-
- type = (*infoRec->TiledFillChooser)(pGC);
-
- if(!type || (type == DO_IMAGE_WRITE)) {
- (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- if(type == DO_COLOR_8x8) {
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- return;
- }
-
- origin = pDraw->x;
-
- switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
- origin, &topPoint, &y, &maxy, shape) ) {
- case POLY_USE_MI:
- miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
- case POLY_FULLY_CLIPPED:
- return;
- }
-
- xorg = (pDraw->x + pGC->patOrg.x);
- yorg = (pDraw->y + pGC->patOrg.y);
-
- switch(type) {
- case DO_MONO_8x8:
- patx = pPriv->pattern0; paty = pPriv->pattern1;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_SCREEN_ORIGIN) {
- xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
- RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
- if(infoRec->SubsequentMono8x8PatternFillTrap)
- TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
- } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(
- infoRec->pScrn, patx, paty);
- patx = pCache->x; paty = pCache->y;
- }
- else {
- pCache = &(infoRec->ScratchCacheInfoRec);
- pCache->pat0 = patx;
- pCache->pat1 = paty;
- }
- RectFunc = Mono8x8PatternRectHelper;
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
- patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask);
- break;
- case DO_CACHE_BLT:
- pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
- (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, -1);
-
- RectFunc = CacheBltRectHelper;
- break;
- case DO_PIXMAP_COPY:
- pCache = &(infoRec->ScratchCacheInfoRec);
- pCache->x = pPriv->offscreenArea->box.x1;
- pCache->y = pPriv->offscreenArea->box.y1;
- pCache->w = pCache->orig_w =
- pPriv->offscreenArea->box.x2 - pCache->x;
- pCache->h = pCache->orig_h =
- pPriv->offscreenArea->box.y2 - pCache->y;
-
- (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, -1);
-
- RectFunc = CacheBltRectHelper;
- break;
- default:
- return;
- }
-
- XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
- y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
+
+/*
+ * Copyright 1996 The XFree86 Project
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * HARM HANEMAAYER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ */
+
+/*
+ * Written by Mark Vojkovich. Loosly based on an original version
+ * written by Harm Hanemaayer (H.Hanemaayer@inter.nl.net) which
+ * only did solid rectangles and didn't have trapezoid support.
+ *
+ */
+
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "micoord.h"
+
+#include "xaa.h"
+#include "xaalocal.h"
+
+#define POLY_USE_MI 0
+#define POLY_FULLY_CLIPPED 1
+#define POLY_IS_EASY 2
+
+
+#define Setup(c,x,vertex,dx,dy,e,sign,step,DX) {\
+ x = intToX(vertex); \
+ if ((dy = intToY(c) - y)) { \
+ DX = dx = intToX(c) - x; \
+ step = 0; \
+ if (dx >= 0) \
+ { \
+ e = 0; \
+ sign = 1; \
+ if (dx >= dy) {\
+ step = dx / dy; \
+ dx %= dy; \
+ } \
+ } \
+ else \
+ { \
+ e = 1 - dy; \
+ sign = -1; \
+ dx = -dx; \
+ if (dx >= dy) { \
+ step = - (dx / dy); \
+ dx %= dy; \
+ } \
+ } \
+ } \
+ x += origin; \
+ vertex = c; \
+}
+
+#define Step(x,dx,dy,e,sign,step) {\
+ x += step; \
+ if ((e += dx) > 0) \
+ { \
+ x += sign; \
+ e -= dy; \
+ } \
+}
+
+#define FixError(x, dx, dy, e, sign, step, h) { \
+ e += (h) * dx; \
+ x += (h) * step; \
+ if(e > 0) { \
+ x += e * sign/dy; \
+ e %= dy; \
+ if(e) { \
+ x += sign; \
+ e -= dy; \
+ } \
+ } \
+}
+
+
+/*
+ XAAIsEasyPoly -
+
+ Checks CoordModeOrigin one rect polygons to see if we need
+ to use Mi.
+ Returns: POLY_USE_MI, POLY_FULLY_CLIPPED or POLY_IS_EASY
+ as well as the pointer to the "top" point and the y
+ extents.
+*/
+
+int
+XAAIsEasyPolygon(
+ DDXPointPtr ptsIn,
+ int count,
+ BoxPtr extents,
+ int origin,
+ DDXPointPtr *topPoint, /* return */
+ int *topY, int *bottomY, /* return */
+ int shape
+){
+ int c = 0, vertex1, vertex2;
+
+ *topY = 32767;
+ *bottomY = 0;
+
+ origin -= (origin & 0x8000) << 1;
+ vertex1 = extents->x1 - origin;
+ vertex2 = extents->x2 - origin /* - 0x00010001 */;
+ /* I think this was an error in cfb ^ */
+
+ if (shape == Convex) {
+ while (count--) {
+ c = *((int*)ptsIn);
+ if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
+ return POLY_USE_MI;
+
+ c = intToY(c);
+ if (c < *topY) {
+ *topY = c;
+ *topPoint = ptsIn;
+ }
+ ptsIn++;
+ if (c > *bottomY) *bottomY = c;
+ }
+ } else {
+ int yFlip = 0;
+ int dx2, dx1, x1, x2;
+
+ x2 = x1 = -1;
+ dx2 = dx1 = 1;
+
+ while (count--) {
+ c = *((int*)ptsIn);
+ if (((c - vertex1) | (vertex2 - c)) & 0x80008000)
+ return POLY_USE_MI;
+ c = intToY(c);
+ if (c < *topY) {
+ *topY = c;
+ *topPoint = ptsIn;
+ }
+ ptsIn++;
+ if (c > *bottomY) *bottomY = c;
+ if (c == x1)
+ continue;
+ if (dx1 > 0) {
+ if (x2 < 0) x2 = c;
+ else dx2 = dx1 = (c - x1) >> 31;
+ } else if ((c - x1) >> 31 != dx1) {
+ dx1 = ~dx1;
+ yFlip++;
+ }
+ x1 = c;
+ }
+ x1 = (x2 - c) >> 31;
+ if (x1 != dx1) yFlip++;
+ if (x1 != dx2) yFlip++;
+ if (yFlip != 2) {
+ if(*topY == *bottomY)
+ return POLY_FULLY_CLIPPED;
+ else
+ return POLY_USE_MI;
+ }
+ }
+ if (*topY == *bottomY)
+ return POLY_FULLY_CLIPPED;
+
+ return POLY_IS_EASY;
+}
+
+void
+XAAFillPolygonSolid(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int origin, vertex1, vertex2;
+ int *vertex1p, *vertex2p, *endp;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
+ int c, y, maxy, h, yoffset;
+ DDXPointPtr topPoint;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = coordToInt(pDraw->x, pDraw->y);
+
+ switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape) ) {
+ case POLY_USE_MI:
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ endp = (int*)ptsIn + count;
+ vertex2p = vertex1p = (int *)topPoint;
+ origin = pDraw->x;
+ yoffset = pDraw->y;
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ while(1) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ } else {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ } else {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+
+ /* fill spans for this segment */
+ if(DX1 | DX2) {
+ if(infoRec->SubsequentSolidFillTrap && (h > 6)) {
+ if(x1 == x2) {
+ while(x1 == x2) {
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if(y == maxy) break;
+ if(!h) continue;
+ }
+
+ if(x1 < x2)
+ (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
+ y + yoffset, h,
+ x1, DX1, dy1, e1,
+ x2 - 1, DX2, dy2, e2);
+ else
+ (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn,
+ y + yoffset, h,
+ x2, DX2, dy2, e2,
+ x1 - 1, DX1, dy1, e1);
+ y += h;
+ if(--h) {
+ FixError(x1,dx1,dy1,e1,sign1,step1,h);
+ FixError(x2,dx2,dy2,e2,sign2,step2,h);
+ h = 0;
+ }
+ } else {
+ while(1) {
+ if (x2 > x1)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x1, y + yoffset, x2 - x1, 1);
+ else if (x1 > x2)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x2, y + yoffset, x1 - x2, 1);
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ }
+ } else {
+ if (x2 > x1)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x1, y + yoffset, x2 - x1, h);
+ else if (x1 > x2)
+ (*infoRec->SubsequentSolidFillRect)(infoRec->pScrn,
+ x2, y + yoffset, x1 - x2, h);
+
+ y += h;
+ h = 0;
+ }
+ if (y == maxy) break;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+void
+XAAFillPolygonHelper(
+ ScrnInfoPtr pScrn,
+ DDXPointPtr ptsIn,
+ int count,
+ DDXPointPtr topPoint,
+ int y,
+ int maxy,
+ int origin,
+ RectFuncPtr RectFunc,
+ TrapFuncPtr TrapFunc,
+ int xorg,
+ int yorg,
+ XAACacheInfoPtr pCache
+){
+ int *vertex1p, *vertex2p, *endp;
+ int vertex1, vertex2;
+ int x1 = 0, x2 = 0;
+ int dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
+ int DX1 = 0, DX2 = 0, e1 = 0, e2 = 0;
+ int step1 = 0, step2 = 0, sign1 = 0, sign2 = 0;
+ int c, h, yoffset;
+
+
+ endp = (int*)ptsIn + count;
+ vertex2p = vertex1p = (int *)topPoint;
+ yoffset = intToY(origin);
+ origin = intToX(origin);
+ vertex2 = vertex1 = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *)ptsIn;
+
+ while(1) {
+ if (y == intToY(vertex1)) {
+ do {
+ if (vertex1p == (int *) ptsIn)
+ vertex1p = endp;
+ c = *--vertex1p;
+ Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1,DX1)
+ } while (y >= intToY(vertex1));
+ h = dy1;
+ } else {
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ h = intToY(vertex1) - y;
+ }
+ if (y == intToY(vertex2)) {
+ do {
+ c = *vertex2p++;
+ if (vertex2p == endp)
+ vertex2p = (int *) ptsIn;
+ Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2,DX2)
+ } while (y >= intToY(vertex2));
+ if (dy2 < h)
+ h = dy2;
+ } else {
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ if ((c = (intToY(vertex2) - y)) < h)
+ h = c;
+ }
+
+ /* fill spans for this segment */
+ if(DX1 | DX2) {
+ if(TrapFunc && (h > 6)) {
+ if(x1 == x2) {
+ while(x1 == x2) {
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ if(y == maxy) break;
+ if(!h) continue;
+ }
+
+ if(x1 < x2)
+ (*TrapFunc)(pScrn, y + yoffset, h,
+ x1, DX1, dy1, e1,
+ x2 - 1, DX2, dy2, e2, xorg, yorg, pCache);
+ else
+ (*TrapFunc)(pScrn, y + yoffset, h,
+ x2, DX2, dy2, e2,
+ x1 - 1, DX1, dy1, e1, xorg, yorg, pCache);
+ y += h;
+ if(--h) {
+ FixError(x1,dx1,dy1,e1,sign1,step1,h);
+ FixError(x2,dx2,dy2,e2,sign2,step2,h);
+ h = 0;
+ }
+ } else {
+ while(1) {
+ if (x2 > x1)
+ (*RectFunc)(pScrn,
+ x1, y + yoffset, x2 - x1, 1, xorg, yorg, pCache);
+ else if (x1 > x2)
+ (*RectFunc)(pScrn,
+ x2, y + yoffset, x1 - x2, 1, xorg, yorg, pCache);
+ y++;
+ if (!--h) break;
+ Step(x1,dx1,dy1,e1,sign1,step1)
+ Step(x2,dx2,dy2,e2,sign2,step2)
+ }
+ }
+ } else {
+ if (x2 > x1)
+ (*RectFunc)(pScrn,
+ x1, y + yoffset, x2 - x1, h, xorg, yorg, pCache);
+ else if (x1 > x2)
+ (*RectFunc)(pScrn,
+ x2, y + yoffset, x1 - x2, h, xorg, yorg, pCache);
+
+ y += h;
+ h = 0;
+ }
+ if (y == maxy) break;
+ }
+}
+
+ /*****************\
+ | Solid Helpers |
+ \*****************/
+
+static void
+SolidTrapHelper(
+ ScrnInfoPtr pScrn,
+ int y, int h,
+ int x1, int dx1, int dy1, int e1,
+ int x2, int dx2, int dy2, int e2,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentSolidFillTrap) (pScrn,
+ y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
+}
+
+static void
+SolidRectHelper (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentSolidFillRect) (pScrn, x, y, w, h);
+}
+
+
+ /*********************\
+ | Mono 8x8 Patterns |
+ \*********************/
+
+static void
+Mono8x8PatternTrapHelper_ScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int y, int h,
+ int x1, int dx1, int dy1, int e1,
+ int x2, int dx2, int dy2, int e2,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentMono8x8PatternFillTrap) (pScrn, xorg, yorg,
+ y, h, x1, dx1, dy1, e1, x2, dx2, dy2, e2);
+}
+
+static void
+Mono8x8PatternRectHelper_ScreenOrigin (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
+ x, y, w, h);
+}
+
+static void
+Mono8x8PatternRectHelper (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ xorg = (x - xorg) & 0x07;
+ yorg = (y - yorg) & 0x07;
+
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ int patx = pCache->pat0;
+ int paty = pCache->pat1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ } else {
+ int slot = (yorg << 3) + xorg;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ }
+ }
+
+
+ (*infoRec->SubsequentMono8x8PatternFillRect) (pScrn, xorg, yorg,
+ x, y, w, h);
+}
+
+
+
+ /****************\
+ | Cache Expand |
+ \****************/
+
+
+static void
+CacheExpandRectHelper (
+ ScrnInfoPtr pScrn,
+ int X, int Y, int Width, int Height,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
+ int cacheWidth;
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ phaseY = (Y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (X - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+
+ while(1) {
+ w = Width; skipleft = phaseX; x = X;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > Height) blit_h = Height;
+
+ while(1) {
+ blit_w = cacheWidth - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenColorExpandFill)(
+ pScrn, x, Y, blit_w, blit_h,
+ pCache->x, pCache->y + phaseY, skipleft);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ Height -= blit_h;
+ if(!Height) break;
+ Y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+}
+
+
+
+ /**************\
+ | Cache Blit |
+ \**************/
+
+
+static void
+CacheBltRectHelper (
+ ScrnInfoPtr pScrn,
+ int X, int Y, int Width, int Height,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, skipleft, w, blit_w, blit_h;
+
+ phaseY = (Y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (X - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+
+ while(1) {
+ w = Width; skipleft = phaseX; x = X;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > Height) blit_h = Height;
+
+ while(1) {
+ blit_w = pCache->w - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + skipleft, pCache->y + phaseY,
+ x, Y, blit_w, blit_h);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ Height -= blit_h;
+ if(!Height) break;
+ Y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+}
+
+
+ /**********************\
+ | Stippled Polygons |
+ \**********************/
+
+
+void
+XAAFillPolygonStippled(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ int origin, type, patx, paty, fg, bg;
+ int y, maxy, xorg, yorg;
+ DDXPointPtr topPoint;
+ XAACacheInfoPtr pCache = NULL;
+ RectFuncPtr RectFunc = NULL;
+ TrapFuncPtr TrapFunc = NULL;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+
+ if(pGC->fillStyle == FillStippled) {
+ type = (*infoRec->StippledFillChooser)(pGC);
+ fg = pGC->fgPixel; bg = -1;
+ } else {
+ type = (*infoRec->OpaqueStippledFillChooser)(pGC);
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ }
+
+
+ if(!type) {
+ (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if((type == DO_COLOR_EXPAND) || (type == DO_COLOR_8x8)) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = pDraw->x;
+
+ switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape) ) {
+ case POLY_USE_MI:
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ xorg = (pDraw->x + pGC->patOrg.x);
+ yorg = (pDraw->y + pGC->patOrg.y);
+
+
+ if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) {
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, fg,
+ pGC->alu, pGC->planemask);
+
+ RectFunc = SolidRectHelper;
+ TrapFunc = infoRec->SubsequentSolidFillTrap ? SolidTrapHelper : NULL;
+ } else
+ switch(type) {
+ case DO_MONO_8x8:
+ patx = pPriv->pattern0; paty = pPriv->pattern1;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_SCREEN_ORIGIN) {
+ xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+ RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
+ if(infoRec->SubsequentMono8x8PatternFillTrap)
+ TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
+ } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ } else {
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->pat0 = patx;
+ pCache->pat1 = paty;
+ }
+ RectFunc = Mono8x8PatternRectHelper;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
+ patx, paty, fg, bg, pGC->alu, pGC->planemask);
+ break;
+ case DO_CACHE_EXPAND:
+ pCache = (*infoRec->CacheMonoStipple)(infoRec->pScrn, pGC->stipple);
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill)(
+ infoRec->pScrn, fg, bg, pGC->alu, pGC->planemask);
+
+ RectFunc = CacheExpandRectHelper;
+ break;
+ case DO_CACHE_BLT:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ fg, bg);
+ (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, pCache->trans_color);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ default:
+ return;
+ }
+
+
+ XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
+ y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+ /*******************\
+ | Tiled Polygons |
+ \*******************/
+
+
+void
+XAAFillPolygonTiled(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int shape,
+ int mode,
+ int count,
+ DDXPointPtr ptsIn
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ int origin, type, patx, paty;
+ int y, maxy, xorg, yorg;
+ DDXPointPtr topPoint;
+ XAACacheInfoPtr pCache = NULL;
+ RectFuncPtr RectFunc = NULL;
+ TrapFuncPtr TrapFunc = NULL;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if (mode == CoordModePrevious) {
+ register DDXPointPtr ppt = ptsIn + 1;
+
+ for (origin = 1; origin < count; origin++, ppt++) {
+ ppt->x += (ppt-1)->x;
+ ppt->y += (ppt-1)->y;
+ }
+ mode = CoordModeOrigin;
+ }
+
+ if (RegionNumRects(pGC->pCompositeClip) != 1) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+
+ type = (*infoRec->TiledFillChooser)(pGC);
+
+ if(!type || (type == DO_IMAGE_WRITE)) {
+ (*XAAFallbackOps.FillPolygon)(pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ if(type == DO_COLOR_8x8) {
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ return;
+ }
+
+ origin = pDraw->x;
+
+ switch( XAAIsEasyPolygon(ptsIn, count, &pGC->pCompositeClip->extents,
+ origin, &topPoint, &y, &maxy, shape) ) {
+ case POLY_USE_MI:
+ miFillPolygon (pDraw, pGC, shape, mode, count, ptsIn);
+ case POLY_FULLY_CLIPPED:
+ return;
+ }
+
+ xorg = (pDraw->x + pGC->patOrg.x);
+ yorg = (pDraw->y + pGC->patOrg.y);
+
+ switch(type) {
+ case DO_MONO_8x8:
+ patx = pPriv->pattern0; paty = pPriv->pattern1;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_SCREEN_ORIGIN) {
+ xorg = (-xorg) & 0x07; yorg = (-yorg) & 0x07;
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)) {
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+ RectFunc = Mono8x8PatternRectHelper_ScreenOrigin;
+ if(infoRec->SubsequentMono8x8PatternFillTrap)
+ TrapFunc = Mono8x8PatternTrapHelper_ScreenOrigin;
+ } else { /* !HARDWARE_PATTERN_SCREEN_ORIGIN */
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(
+ infoRec->pScrn, patx, paty);
+ patx = pCache->x; paty = pCache->y;
+ }
+ else {
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->pat0 = patx;
+ pCache->pat1 = paty;
+ }
+ RectFunc = Mono8x8PatternRectHelper;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(infoRec->pScrn,
+ patx, paty, pPriv->fg, pPriv->bg, pGC->alu, pGC->planemask);
+ break;
+ case DO_CACHE_BLT:
+ pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
+ (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, -1);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ case DO_PIXMAP_COPY:
+ pCache = &(infoRec->ScratchCacheInfoRec);
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w =
+ pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h =
+ pPriv->offscreenArea->box.y2 - pCache->y;
+
+ (*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
+ pGC->alu, pGC->planemask, -1);
+
+ RectFunc = CacheBltRectHelper;
+ break;
+ default:
+ return;
+ }
+
+ XAAFillPolygonHelper(infoRec->pScrn, ptsIn, count, topPoint,
+ y, maxy, origin, RectFunc, TrapFunc, xorg, yorg, pCache);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaFillRect.c b/xorg-server/hw/xfree86/xaa/xaaFillRect.c
index 0b83ef3ee..724ff37a2 100644
--- a/xorg-server/hw/xfree86/xaa/xaaFillRect.c
+++ b/xorg-server/hw/xfree86/xaa/xaaFillRect.c
@@ -1,1095 +1,1095 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int);
-static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int);
-
-void
-XAAPolyFillRect(
- DrawablePtr pDraw,
- GCPtr pGC,
- int nrectFill, /* number of rectangles to fill */
- xRectangle *prectInit /* Pointer to first rectangle to fill */
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int xorg = pDraw->x;
- int yorg = pDraw->y;
- int type = 0;
- ClipAndRenderRectsFunc function;
-
- if((nrectFill <= 0) || !pGC->planemask)
- return;
-
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
- return;
-
- switch(pGC->fillStyle) {
- case FillSolid:
- type = DO_SOLID;
- break;
- case FillStippled:
- type = (*infoRec->StippledFillChooser)(pGC);
- break;
- case FillOpaqueStippled:
- if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects &&
- CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) &&
- CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) &&
- CHECK_FG(pGC,infoRec->FillSolidRectsFlags))
- type = DO_SOLID;
- else
- type = (*infoRec->OpaqueStippledFillChooser)(pGC);
- break;
- case FillTiled:
- type = (*infoRec->TiledFillChooser)(pGC);
- break;
- }
-
- switch(type) {
- case DO_SOLID:
- function = XAARenderSolidRects;
- break;
- case DO_COLOR_8x8:
- function = XAARenderColor8x8Rects;
- break;
- case DO_MONO_8x8:
- function = XAARenderMono8x8Rects;
- break;
- case DO_CACHE_BLT:
- function = XAARenderCacheBltRects;
- break;
- case DO_COLOR_EXPAND:
- function = XAARenderColorExpandRects;
- break;
- case DO_CACHE_EXPAND:
- function = XAARenderCacheExpandRects;
- break;
- case DO_IMAGE_WRITE:
- function = XAARenderImageWriteRects;
- break;
- case DO_PIXMAP_COPY:
- function = XAARenderPixmapCopyRects;
- break;
- default:
- (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
- return;
- }
-
- if(xorg | yorg) {
- int n = nrectFill;
- xRectangle *prect = prectInit;
-
- while(n--) {
- prect->x += xorg;
- prect->y += yorg;
- prect++;
- }
- }
-
-
- XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg);
-}
-
-
-
- /*********************\
- | Solid Rects |
- \*********************/
-
-static void
-XAARenderSolidRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- (*infoRec->FillSolidRects) (infoRec->pScrn,
- pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes);
-}
-
-
- /************************\
- | Mono 8x8 Rects |
- \************************/
-
-static void
-XAARenderMono8x8Rects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- fg = pPriv->fg; bg = pPriv->bg;
- break;
- default: /* Muffle compiler */
- pPriv = NULL; /* Kaboom */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn,
- fg, bg, pGC->alu, pGC->planemask,
- nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-}
-
- /*************************\
- | Color 8x8 Rects |
- \*************************/
-
-static void
-XAARenderColor8x8Rects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
- PixmapPtr pPix;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPix = pGC->tile.pixmap;
- fg = -1; bg = -1;
- break;
- default: /* Muffle compiler */
- pPix = NULL;
- fg = -1; bg = -1;
- break;
- }
-
- pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
- (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn,
- pGC->alu, pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
-}
-
-
- /****************************\
- | Color Expand Rects |
- \****************************/
-
-static void
-XAARenderColorExpandRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-}
-
-
- /*************************\
- | Cache Blt Rects |
- \*************************/
-
-static void
-XAARenderCacheBltRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, -1);
- break;
- case FillOpaqueStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, pGC->bgPixel);
- break;
- case FillTiled:
- pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
- break;
- default: /* Muffle compiler */
- pCache = NULL;
- break;
- }
-
- (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
- pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
-}
-
-
- /****************************\
- | Cache Expand Rects |
- \****************************/
-
-static void
-XAARenderCacheExpandRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-}
-
-
-
- /***************************\
- | Image Write Rects |
- \***************************/
-
-static void
-XAARenderImageWriteRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu,
- pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->tile.pixmap);
-}
-
-
-
- /***************************\
- | Pixmap Copy Rects |
- \***************************/
-
-static void
-XAARenderPixmapCopyRects(
- GCPtr pGC,
- int nboxes,
- BoxPtr pClipBoxes,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
-
- pCache->x = pPriv->offscreenArea->box.x1;
- pCache->y = pPriv->offscreenArea->box.y1;
- pCache->w = pCache->orig_w =
- pPriv->offscreenArea->box.x2 - pCache->x;
- pCache->h = pCache->orig_h =
- pPriv->offscreenArea->box.y2 - pCache->y;
- pCache->trans_color = -1;
-
- (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
- pGC->planemask, nboxes, pClipBoxes,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pCache);
-}
-
-
-
- /************\
- | Solid |
- \************/
-
-void
-XAAFillSolidRects(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int nBox, /* number of rectangles to fill */
- BoxPtr pBox /* Pointer to first rectangle to fill */
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
- while(nBox--) {
- (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
- /*********************\
- | 8x8 Mono Patterns |
- \*********************/
-
-
-void
-XAAFillMono8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
-
- if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache =
- (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
- while(nBox--) {
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-void
-XAAFillMono8x8PatternRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg, yorg;
- XAACacheInfoPtr pCache = NULL;
-
-
- if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- }
-
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
-
- while(nBox--) {
- xorg = (pBox->x1 - xorigin) & 0x07;
- yorg = (pBox->y1 - yorigin) & 0x07;
-
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- patx = pattern0; paty = pattern1;
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- } else {
- int slot = (yorg << 3) + xorg;
- xorg = patx + pCache->offsets[slot].x;
- yorg = paty + pCache->offsets[slot].y;
- }
- }
-
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /**********************\
- | 8x8 Color Patterns |
- \**********************/
-
-
-void
-XAAFillColor8x8PatternRectsScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pCache->x, paty = pCache->y;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- paty += pCache->offsets[slot].y;
- patx += pCache->offsets[slot].x;
- xorg = patx; yorg = paty;
- }
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
- rop, planemask, pCache->trans_color);
-
- while(nBox--) {
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
- SET_SYNC_FLAG(infoRec);
-}
-
-void
-XAAFillColor8x8PatternRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorigin, int yorigin,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int xorg, yorg;
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
- rop, planemask, pCache->trans_color);
-
- while(nBox--) {
- xorg = (pBox->x1 - xorigin) & 0x07;
- yorg = (pBox->y1 - yorigin) & 0x07;
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- yorg = pCache->y + pCache->offsets[slot].y;
- xorg = pCache->x + pCache->offsets[slot].x;
- }
-
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, pBox->x1, pBox->y1,
- pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /***************\
- | Cache Blits |
- \***************/
-
-void
-XAAFillCacheBltRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- XAACacheInfoPtr pCache
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
-
- (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
- pCache->trans_color);
-
- while(nBox--) {
- y = pBox->y1;
- phaseY = (y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (pBox->x1 - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- height = pBox->y2 - y;
- width = pBox->x2 - pBox->x1;
-
-#if 0
- if (rop == GXcopy) {
- while(1) {
- w = width; skipleft = phaseX; x = pBox->x1;
- blit_h = pCache->h - phaseY;
- if(blit_h > height) blit_h = height;
-
- while(1) {
- blit_w = pCache->w - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + skipleft, pCache->y + phaseY,
- x, y, blit_w, blit_h);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- if(blit_w >= pCache->orig_w) break;
- }
-
- /* Expand horizontally */
- if (w) {
- skipleft -= phaseX;
- if (skipleft < 0) skipleft += pCache->orig_w;
- blit_w = x - pBox->x1 - skipleft;
- while(w) {
- if (blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pBox->x1 + skipleft, y, x, y, blit_w, blit_h);
- w -= blit_w;
- x += blit_w;
- blit_w <<= 1;
- }
- }
-
- height -= blit_h;
- if(!height) break;
- y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- if(blit_h >= pCache->orig_h) break;
- }
-
- /* Expand vertically */
- if (height) {
- blit_w = pBox->x2 - pBox->x1;
- phaseY -= (pBox->y1 - yorg) % pCache->orig_h;
- if (phaseY < 0) phaseY += pCache->orig_h;
- blit_h = y - pBox->y1 - phaseY;
- while(height) {
- if (blit_h > height) blit_h = height;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1,
- pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h);
- height -= blit_h;
- y += blit_h;
- blit_h <<= 1;
- }
- }
- } else
-#endif
- {
- while(1) {
- w = width; skipleft = phaseX; x = pBox->x1;
- blit_h = pCache->h - phaseY;
- if(blit_h > height) blit_h = height;
-
- while(1) {
- blit_w = pCache->w - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + skipleft, pCache->y + phaseY,
- x, y, blit_w, blit_h);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- height -= blit_h;
- if(!height) break;
- y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
- }
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
- /*******************\
- | Cache Expansion |
- \*******************/
-
-
-
-void
-XAAFillCacheExpandRects(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
- int cacheWidth;
- XAACacheInfoPtr pCache;
-
- pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
-
- cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
- infoRec->CacheColorExpandDensity;
-
- (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
- planemask);
-
- while(nBox--) {
- y = pBox->y1;
- phaseY = (y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
- phaseX = (pBox->x1 - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- height = pBox->y2 - y;
- width = pBox->x2 - pBox->x1;
-
- while(1) {
- w = width; skipleft = phaseX; x = pBox->x1;
- blit_h = pCache->h - phaseY;
- if(blit_h > height) blit_h = height;
-
- while(1) {
- blit_w = cacheWidth - skipleft;
- if(blit_w > w) blit_w = w;
- (*infoRec->SubsequentScreenToScreenColorExpandFill)(
- pScrn, x, y, blit_w, blit_h,
- pCache->x, pCache->y + phaseY, skipleft);
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- skipleft = (skipleft + blit_w) % pCache->orig_w;
- }
- height -= blit_h;
- if(!height) break;
- y += blit_h;
- phaseY = (phaseY + blit_h) % pCache->orig_h;
- }
- pBox++;
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /******************\
- | Image Writes |
- \******************/
-
-
-
-/* This requires all LEFT_EDGE clipping. You get too many problems
- with reading past the edge of the pattern otherwise */
-
-static void
-WriteColumn(
- ScrnInfoPtr pScrn,
- unsigned char *pSrc,
- int x, int y, int w, int h,
- int xoff, int yoff,
- int pHeight,
- int srcwidth,
- int Bpp
-) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- unsigned char *src;
- Bool PlusOne = FALSE;
- int skipleft, dwords;
-
- pSrc += (Bpp * xoff);
-
- if((skipleft = (long)pSrc & 0x03L)) {
- if(Bpp == 3)
- skipleft = 4 - skipleft;
- else
- skipleft /= Bpp;
-
- x -= skipleft;
- w += skipleft;
-
- if(Bpp == 3)
- pSrc -= 3 * skipleft;
- else /* is this Alpha friendly ? */
- pSrc = (unsigned char*)((long)pSrc & ~0x03L);
- }
-
- src = pSrc + (yoff * srcwidth);
-
- dwords = bytes_to_int32(w * Bpp);
-
- if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((dwords * h) & 0x01)) {
- PlusOne = TRUE;
- }
-
- (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft);
-
- if(dwords > infoRec->ImageWriteRange) {
- while(h--) {
- XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src += srcwidth;
- yoff++;
- if(yoff >= pHeight) {
- yoff = 0;
- src = pSrc;
- }
- }
- } else {
- if(srcwidth == (dwords << 2)) {
- int maxLines = infoRec->ImageWriteRange/dwords;
- int step;
-
- while(h) {
- step = pHeight - yoff;
- if(step > maxLines) step = maxLines;
- if(step > h) step = h;
-
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords * step);
-
- src += (srcwidth * step);
- yoff += step;
- if(yoff >= pHeight) {
- yoff = 0;
- src = pSrc;
- }
- h -= step;
- }
- } else {
- while(h--) {
- XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
- (CARD32*)src, dwords);
- src += srcwidth;
- yoff++;
- if(yoff >= pHeight) {
- yoff = 0;
- src = pSrc;
- }
- }
- }
- }
-
- if(PlusOne) {
- CARD32* base = (CARD32*)infoRec->ImageWriteBase;
- *base = 0x00000000;
- }
-}
-
-void
-XAAFillImageWriteRects(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int nBox,
- BoxPtr pBox,
- int xorg, int yorg,
- PixmapPtr pPix
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, phaseY, phaseX, height, width, blit_w;
- int pHeight = pPix->drawable.height;
- int pWidth = pPix->drawable.width;
- int Bpp = pPix->drawable.bitsPerPixel >> 3;
- int srcwidth = pPix->devKind;
-
- (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1,
- pPix->drawable.bitsPerPixel, pPix->drawable.depth);
-
- while(nBox--) {
- x = pBox->x1;
- phaseY = (pBox->y1 - yorg) % pHeight;
- if(phaseY < 0) phaseY += pHeight;
- phaseX = (x - xorg) % pWidth;
- if(phaseX < 0) phaseX += pWidth;
- height = pBox->y2 - pBox->y1;
- width = pBox->x2 - x;
-
- while(1) {
- blit_w = pWidth - phaseX;
- if(blit_w > width) blit_w = width;
-
- WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1,
- blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp);
-
- width -= blit_w;
- if(!width) break;
- x += blit_w;
- phaseX = (phaseX + blit_w) % pWidth;
- }
- pBox++;
- }
-
- if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
- (*infoRec->Sync)(pScrn);
- else SET_SYNC_FLAG(infoRec);
-}
-
-
- /*************\
- | Utilities |
- \*************/
-
-
-void
-XAAClipAndRenderRects(
- GCPtr pGC,
- ClipAndRenderRectsFunc BoxFunc,
- int nrectFill,
- xRectangle *prect,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int Right, Bottom, MaxBoxes;
- BoxPtr pextent, pboxClipped, pboxClippedBase;
-
- MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec);
- pboxClippedBase = (BoxPtr)infoRec->PreAllocMem;
- pboxClipped = pboxClippedBase;
-
- if (REGION_NUM_RECTS(pGC->pCompositeClip) == 1) {
- pextent = REGION_RECTS(pGC->pCompositeClip);
- while (nrectFill--) {
- pboxClipped->x1 = max(pextent->x1, prect->x);
- pboxClipped->y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- pboxClipped->x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- pboxClipped->y2 = min(pextent->y2, Bottom);
-
- prect++;
- if ((pboxClipped->x1 < pboxClipped->x2) &&
- (pboxClipped->y1 < pboxClipped->y2)) {
- pboxClipped++;
- if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
- (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
- pboxClipped = pboxClippedBase;
- }
- }
- }
- } else {
- pextent = REGION_EXTENTS(pGC->pScreen, pGC->pCompositeClip);
- while (nrectFill--) {
- int n;
- BoxRec box, *pbox;
-
- box.x1 = max(pextent->x1, prect->x);
- box.y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- box.x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- box.y2 = min(pextent->y2, Bottom);
-
- prect++;
-
- if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
- continue;
-
- n = REGION_NUM_RECTS (pGC->pCompositeClip);
- pbox = REGION_RECTS(pGC->pCompositeClip);
-
- /* clip the rectangle to each box in the clip region
- this is logically equivalent to calling Intersect()
- */
- while(n--) {
- pboxClipped->x1 = max(box.x1, pbox->x1);
- pboxClipped->y1 = max(box.y1, pbox->y1);
- pboxClipped->x2 = min(box.x2, pbox->x2);
- pboxClipped->y2 = min(box.y2, pbox->y2);
- pbox++;
-
- /* see if clipping left anything */
- if(pboxClipped->x1 < pboxClipped->x2 &&
- pboxClipped->y1 < pboxClipped->y2) {
- pboxClipped++;
- if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
- (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
- pboxClipped = pboxClippedBase;
- }
- }
- }
- }
- }
-
- if(pboxClipped != pboxClippedBase)
- (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase,
- xorg, yorg);
-}
-
-
-int
-XAAGetRectClipBoxes(
- GCPtr pGC,
- BoxPtr pboxClippedBase,
- int nrectFill,
- xRectangle *prectInit
-){
- int Right, Bottom;
- BoxPtr pextent, pboxClipped = pboxClippedBase;
- xRectangle *prect = prectInit;
- RegionPtr prgnClip = pGC->pCompositeClip;
-
- if (REGION_NUM_RECTS(prgnClip) == 1) {
- pextent = REGION_RECTS(prgnClip);
- while (nrectFill--) {
- pboxClipped->x1 = max(pextent->x1, prect->x);
- pboxClipped->y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- pboxClipped->x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- pboxClipped->y2 = min(pextent->y2, Bottom);
-
- prect++;
- if ((pboxClipped->x1 < pboxClipped->x2) &&
- (pboxClipped->y1 < pboxClipped->y2)) {
- pboxClipped++;
- }
- }
- } else {
- pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
- while (nrectFill--) {
- int n;
- BoxRec box, *pbox;
-
- box.x1 = max(pextent->x1, prect->x);
- box.y1 = max(pextent->y1, prect->y);
-
- Right = (int)prect->x + (int)prect->width;
- box.x2 = min(pextent->x2, Right);
-
- Bottom = (int)prect->y + (int)prect->height;
- box.y2 = min(pextent->y2, Bottom);
-
- prect++;
-
- if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
- continue;
-
- n = REGION_NUM_RECTS (prgnClip);
- pbox = REGION_RECTS(prgnClip);
-
- /* clip the rectangle to each box in the clip region
- this is logically equivalent to calling Intersect()
- */
- while(n--) {
- pboxClipped->x1 = max(box.x1, pbox->x1);
- pboxClipped->y1 = max(box.y1, pbox->y1);
- pboxClipped->x2 = min(box.x2, pbox->x2);
- pboxClipped->y2 = min(box.y2, pbox->y2);
- pbox++;
-
- /* see if clipping left anything */
- if(pboxClipped->x1 < pboxClipped->x2 &&
- pboxClipped->y1 < pboxClipped->y2) {
- pboxClipped++;
- }
- }
- }
- }
-
- return(pboxClipped - pboxClippedBase);
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+static void XAARenderSolidRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderColor8x8Rects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderMono8x8Rects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderColorExpandRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderCacheExpandRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderCacheBltRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderImageWriteRects(GCPtr, int, BoxPtr, int, int);
+static void XAARenderPixmapCopyRects(GCPtr, int, BoxPtr, int, int);
+
+void
+XAAPolyFillRect(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nrectFill, /* number of rectangles to fill */
+ xRectangle *prectInit /* Pointer to first rectangle to fill */
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int xorg = pDraw->x;
+ int yorg = pDraw->y;
+ int type = 0;
+ ClipAndRenderRectsFunc function;
+
+ if((nrectFill <= 0) || !pGC->planemask)
+ return;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ switch(pGC->fillStyle) {
+ case FillSolid:
+ type = DO_SOLID;
+ break;
+ case FillStippled:
+ type = (*infoRec->StippledFillChooser)(pGC);
+ break;
+ case FillOpaqueStippled:
+ if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSolidRects &&
+ CHECK_PLANEMASK(pGC,infoRec->FillSolidRectsFlags) &&
+ CHECK_ROP(pGC,infoRec->FillSolidRectsFlags) &&
+ CHECK_ROPSRC(pGC,infoRec->FillSolidRectsFlags) &&
+ CHECK_FG(pGC,infoRec->FillSolidRectsFlags))
+ type = DO_SOLID;
+ else
+ type = (*infoRec->OpaqueStippledFillChooser)(pGC);
+ break;
+ case FillTiled:
+ type = (*infoRec->TiledFillChooser)(pGC);
+ break;
+ }
+
+ switch(type) {
+ case DO_SOLID:
+ function = XAARenderSolidRects;
+ break;
+ case DO_COLOR_8x8:
+ function = XAARenderColor8x8Rects;
+ break;
+ case DO_MONO_8x8:
+ function = XAARenderMono8x8Rects;
+ break;
+ case DO_CACHE_BLT:
+ function = XAARenderCacheBltRects;
+ break;
+ case DO_COLOR_EXPAND:
+ function = XAARenderColorExpandRects;
+ break;
+ case DO_CACHE_EXPAND:
+ function = XAARenderCacheExpandRects;
+ break;
+ case DO_IMAGE_WRITE:
+ function = XAARenderImageWriteRects;
+ break;
+ case DO_PIXMAP_COPY:
+ function = XAARenderPixmapCopyRects;
+ break;
+ default:
+ (*XAAFallbackOps.PolyFillRect)(pDraw, pGC, nrectFill, prectInit);
+ return;
+ }
+
+ if(xorg | yorg) {
+ int n = nrectFill;
+ xRectangle *prect = prectInit;
+
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+
+ XAAClipAndRenderRects(pGC, function, nrectFill, prectInit, xorg, yorg);
+}
+
+
+
+ /*********************\
+ | Solid Rects |
+ \*********************/
+
+static void
+XAARenderSolidRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillSolidRects) (infoRec->pScrn,
+ pGC->fgPixel, pGC->alu, pGC->planemask, nboxes, pClipBoxes);
+}
+
+
+ /************************\
+ | Mono 8x8 Rects |
+ \************************/
+
+static void
+XAARenderMono8x8Rects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ fg = pPriv->fg; bg = pPriv->bg;
+ break;
+ default: /* Muffle compiler */
+ pPriv = NULL; /* Kaboom */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillMono8x8PatternRects) (infoRec->pScrn,
+ fg, bg, pGC->alu, pGC->planemask,
+ nboxes, pClipBoxes, pPriv->pattern0, pPriv->pattern1,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+}
+
+ /*************************\
+ | Color 8x8 Rects |
+ \*************************/
+
+static void
+XAARenderColor8x8Rects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+ PixmapPtr pPix;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPix = pGC->tile.pixmap;
+ fg = -1; bg = -1;
+ break;
+ default: /* Muffle compiler */
+ pPix = NULL;
+ fg = -1; bg = -1;
+ break;
+ }
+
+ pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
+ (*infoRec->FillColor8x8PatternRects) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
+}
+
+
+ /****************************\
+ | Color Expand Rects |
+ \****************************/
+
+static void
+XAARenderColorExpandRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillColorExpandRects) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+}
+
+
+ /*************************\
+ | Cache Blt Rects |
+ \*************************/
+
+static void
+XAARenderCacheBltRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, -1);
+ break;
+ case FillOpaqueStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, pGC->bgPixel);
+ break;
+ case FillTiled:
+ pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
+ break;
+ default: /* Muffle compiler */
+ pCache = NULL;
+ break;
+ }
+
+ (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y), pCache);
+}
+
+
+ /****************************\
+ | Cache Expand Rects |
+ \****************************/
+
+static void
+XAARenderCacheExpandRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillCacheExpandRects) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+}
+
+
+
+ /***************************\
+ | Image Write Rects |
+ \***************************/
+
+static void
+XAARenderImageWriteRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillImageWriteRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->tile.pixmap);
+}
+
+
+
+ /***************************\
+ | Pixmap Copy Rects |
+ \***************************/
+
+static void
+XAARenderPixmapCopyRects(
+ GCPtr pGC,
+ int nboxes,
+ BoxPtr pClipBoxes,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w =
+ pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h =
+ pPriv->offscreenArea->box.y2 - pCache->y;
+ pCache->trans_color = -1;
+
+ (*infoRec->FillCacheBltRects) (infoRec->pScrn, pGC->alu,
+ pGC->planemask, nboxes, pClipBoxes,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pCache);
+}
+
+
+
+ /************\
+ | Solid |
+ \************/
+
+void
+XAAFillSolidRects(
+ ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int nBox, /* number of rectangles to fill */
+ BoxPtr pBox /* Pointer to first rectangle to fill */
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
+ while(nBox--) {
+ (*infoRec->SubsequentSolidFillRect)(pScrn, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+ /*********************\
+ | 8x8 Mono Patterns |
+ \*********************/
+
+
+void
+XAAFillMono8x8PatternRectsScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+
+ if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ while(nBox--) {
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillMono8x8PatternRects(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg, yorg;
+ XAACacheInfoPtr pCache = NULL;
+
+
+ if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ }
+
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+
+ while(nBox--) {
+ xorg = (pBox->x1 - xorigin) & 0x07;
+ yorg = (pBox->y1 - yorigin) & 0x07;
+
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ patx = pattern0; paty = pattern1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ } else {
+ int slot = (yorg << 3) + xorg;
+ xorg = patx + pCache->offsets[slot].x;
+ yorg = paty + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /**********************\
+ | 8x8 Color Patterns |
+ \**********************/
+
+
+void
+XAAFillColor8x8PatternRectsScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pCache->x, paty = pCache->y;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ paty += pCache->offsets[slot].y;
+ patx += pCache->offsets[slot].x;
+ xorg = patx; yorg = paty;
+ }
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
+ rop, planemask, pCache->trans_color);
+
+ while(nBox--) {
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+ SET_SYNC_FLAG(infoRec);
+}
+
+void
+XAAFillColor8x8PatternRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorigin, int yorigin,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int xorg, yorg;
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
+ rop, planemask, pCache->trans_color);
+
+ while(nBox--) {
+ xorg = (pBox->x1 - xorigin) & 0x07;
+ yorg = (pBox->y1 - yorigin) & 0x07;
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ }
+
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, pBox->x1, pBox->y1,
+ pBox->x2 - pBox->x1, pBox->y2 - pBox->y1);
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /***************\
+ | Cache Blits |
+ \***************/
+
+void
+XAAFillCacheBltRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ XAACacheInfoPtr pCache
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
+
+ (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
+ pCache->trans_color);
+
+ while(nBox--) {
+ y = pBox->y1;
+ phaseY = (y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (pBox->x1 - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ height = pBox->y2 - y;
+ width = pBox->x2 - pBox->x1;
+
+#if 0
+ if (rop == GXcopy) {
+ while(1) {
+ w = width; skipleft = phaseX; x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > height) blit_h = height;
+
+ while(1) {
+ blit_w = pCache->w - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + skipleft, pCache->y + phaseY,
+ x, y, blit_w, blit_h);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ if(blit_w >= pCache->orig_w) break;
+ }
+
+ /* Expand horizontally */
+ if (w) {
+ skipleft -= phaseX;
+ if (skipleft < 0) skipleft += pCache->orig_w;
+ blit_w = x - pBox->x1 - skipleft;
+ while(w) {
+ if (blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pBox->x1 + skipleft, y, x, y, blit_w, blit_h);
+ w -= blit_w;
+ x += blit_w;
+ blit_w <<= 1;
+ }
+ }
+
+ height -= blit_h;
+ if(!height) break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ if(blit_h >= pCache->orig_h) break;
+ }
+
+ /* Expand vertically */
+ if (height) {
+ blit_w = pBox->x2 - pBox->x1;
+ phaseY -= (pBox->y1 - yorg) % pCache->orig_h;
+ if (phaseY < 0) phaseY += pCache->orig_h;
+ blit_h = y - pBox->y1 - phaseY;
+ while(height) {
+ if (blit_h > height) blit_h = height;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn, pBox->x1,
+ pBox->y1 + phaseY, pBox->x1, y, blit_w, blit_h);
+ height -= blit_h;
+ y += blit_h;
+ blit_h <<= 1;
+ }
+ }
+ } else
+#endif
+ {
+ while(1) {
+ w = width; skipleft = phaseX; x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > height) blit_h = height;
+
+ while(1) {
+ blit_w = pCache->w - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + skipleft, pCache->y + phaseY,
+ x, y, blit_w, blit_h);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ height -= blit_h;
+ if(!height) break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+ }
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+ /*******************\
+ | Cache Expansion |
+ \*******************/
+
+
+
+void
+XAAFillCacheExpandRects(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h;
+ int cacheWidth;
+ XAACacheInfoPtr pCache;
+
+ pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
+ planemask);
+
+ while(nBox--) {
+ y = pBox->y1;
+ phaseY = (y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+ phaseX = (pBox->x1 - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ height = pBox->y2 - y;
+ width = pBox->x2 - pBox->x1;
+
+ while(1) {
+ w = width; skipleft = phaseX; x = pBox->x1;
+ blit_h = pCache->h - phaseY;
+ if(blit_h > height) blit_h = height;
+
+ while(1) {
+ blit_w = cacheWidth - skipleft;
+ if(blit_w > w) blit_w = w;
+ (*infoRec->SubsequentScreenToScreenColorExpandFill)(
+ pScrn, x, y, blit_w, blit_h,
+ pCache->x, pCache->y + phaseY, skipleft);
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ skipleft = (skipleft + blit_w) % pCache->orig_w;
+ }
+ height -= blit_h;
+ if(!height) break;
+ y += blit_h;
+ phaseY = (phaseY + blit_h) % pCache->orig_h;
+ }
+ pBox++;
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /******************\
+ | Image Writes |
+ \******************/
+
+
+
+/* This requires all LEFT_EDGE clipping. You get too many problems
+ with reading past the edge of the pattern otherwise */
+
+static void
+WriteColumn(
+ ScrnInfoPtr pScrn,
+ unsigned char *pSrc,
+ int x, int y, int w, int h,
+ int xoff, int yoff,
+ int pHeight,
+ int srcwidth,
+ int Bpp
+) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ unsigned char *src;
+ Bool PlusOne = FALSE;
+ int skipleft, dwords;
+
+ pSrc += (Bpp * xoff);
+
+ if((skipleft = (long)pSrc & 0x03L)) {
+ if(Bpp == 3)
+ skipleft = 4 - skipleft;
+ else
+ skipleft /= Bpp;
+
+ x -= skipleft;
+ w += skipleft;
+
+ if(Bpp == 3)
+ pSrc -= 3 * skipleft;
+ else /* is this Alpha friendly ? */
+ pSrc = (unsigned char*)((long)pSrc & ~0x03L);
+ }
+
+ src = pSrc + (yoff * srcwidth);
+
+ dwords = bytes_to_int32(w * Bpp);
+
+ if((infoRec->ImageWriteFlags & CPU_TRANSFER_PAD_QWORD) &&
+ ((dwords * h) & 0x01)) {
+ PlusOne = TRUE;
+ }
+
+ (*infoRec->SubsequentImageWriteRect)(pScrn, x, y, w, h, skipleft);
+
+ if(dwords > infoRec->ImageWriteRange) {
+ while(h--) {
+ XAAMoveDWORDS_FixedBase((CARD32*)infoRec->ImageWriteBase,
+ (CARD32*)src, dwords);
+ src += srcwidth;
+ yoff++;
+ if(yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ }
+ } else {
+ if(srcwidth == (dwords << 2)) {
+ int maxLines = infoRec->ImageWriteRange/dwords;
+ int step;
+
+ while(h) {
+ step = pHeight - yoff;
+ if(step > maxLines) step = maxLines;
+ if(step > h) step = h;
+
+ XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
+ (CARD32*)src, dwords * step);
+
+ src += (srcwidth * step);
+ yoff += step;
+ if(yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ h -= step;
+ }
+ } else {
+ while(h--) {
+ XAAMoveDWORDS((CARD32*)infoRec->ImageWriteBase,
+ (CARD32*)src, dwords);
+ src += srcwidth;
+ yoff++;
+ if(yoff >= pHeight) {
+ yoff = 0;
+ src = pSrc;
+ }
+ }
+ }
+ }
+
+ if(PlusOne) {
+ CARD32* base = (CARD32*)infoRec->ImageWriteBase;
+ *base = 0x00000000;
+ }
+}
+
+void
+XAAFillImageWriteRects(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int nBox,
+ BoxPtr pBox,
+ int xorg, int yorg,
+ PixmapPtr pPix
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, phaseY, phaseX, height, width, blit_w;
+ int pHeight = pPix->drawable.height;
+ int pWidth = pPix->drawable.width;
+ int Bpp = pPix->drawable.bitsPerPixel >> 3;
+ int srcwidth = pPix->devKind;
+
+ (*infoRec->SetupForImageWrite)(pScrn, rop, planemask, -1,
+ pPix->drawable.bitsPerPixel, pPix->drawable.depth);
+
+ while(nBox--) {
+ x = pBox->x1;
+ phaseY = (pBox->y1 - yorg) % pHeight;
+ if(phaseY < 0) phaseY += pHeight;
+ phaseX = (x - xorg) % pWidth;
+ if(phaseX < 0) phaseX += pWidth;
+ height = pBox->y2 - pBox->y1;
+ width = pBox->x2 - x;
+
+ while(1) {
+ blit_w = pWidth - phaseX;
+ if(blit_w > width) blit_w = width;
+
+ WriteColumn(pScrn, pPix->devPrivate.ptr, x, pBox->y1,
+ blit_w, height, phaseX, phaseY, pHeight, srcwidth, Bpp);
+
+ width -= blit_w;
+ if(!width) break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pWidth;
+ }
+ pBox++;
+ }
+
+ if(infoRec->ImageWriteFlags & SYNC_AFTER_IMAGE_WRITE)
+ (*infoRec->Sync)(pScrn);
+ else SET_SYNC_FLAG(infoRec);
+}
+
+
+ /*************\
+ | Utilities |
+ \*************/
+
+
+void
+XAAClipAndRenderRects(
+ GCPtr pGC,
+ ClipAndRenderRectsFunc BoxFunc,
+ int nrectFill,
+ xRectangle *prect,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int Right, Bottom, MaxBoxes;
+ BoxPtr pextent, pboxClipped, pboxClippedBase;
+
+ MaxBoxes = infoRec->PreAllocSize/sizeof(BoxRec);
+ pboxClippedBase = (BoxPtr)infoRec->PreAllocMem;
+ pboxClipped = pboxClippedBase;
+
+ if (RegionNumRects(pGC->pCompositeClip) == 1) {
+ pextent = RegionRects(pGC->pCompositeClip);
+ while (nrectFill--) {
+ pboxClipped->x1 = max(pextent->x1, prect->x);
+ pboxClipped->y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ pboxClipped->x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ pboxClipped->y2 = min(pextent->y2, Bottom);
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
+ (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
+ pboxClipped = pboxClippedBase;
+ }
+ }
+ }
+ } else {
+ pextent = RegionExtents(pGC->pCompositeClip);
+ while (nrectFill--) {
+ int n;
+ BoxRec box, *pbox;
+
+ box.x1 = max(pextent->x1, prect->x);
+ box.y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ box.x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ box.y2 = min(pextent->y2, Bottom);
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = RegionNumRects (pGC->pCompositeClip);
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ if(pboxClipped >= (pboxClippedBase + MaxBoxes)) {
+ (*BoxFunc)(pGC, MaxBoxes, pboxClippedBase, xorg, yorg);
+ pboxClipped = pboxClippedBase;
+ }
+ }
+ }
+ }
+ }
+
+ if(pboxClipped != pboxClippedBase)
+ (*BoxFunc)(pGC, pboxClipped - pboxClippedBase, pboxClippedBase,
+ xorg, yorg);
+}
+
+
+int
+XAAGetRectClipBoxes(
+ GCPtr pGC,
+ BoxPtr pboxClippedBase,
+ int nrectFill,
+ xRectangle *prectInit
+){
+ int Right, Bottom;
+ BoxPtr pextent, pboxClipped = pboxClippedBase;
+ xRectangle *prect = prectInit;
+ RegionPtr prgnClip = pGC->pCompositeClip;
+
+ if (RegionNumRects(prgnClip) == 1) {
+ pextent = RegionRects(prgnClip);
+ while (nrectFill--) {
+ pboxClipped->x1 = max(pextent->x1, prect->x);
+ pboxClipped->y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ pboxClipped->x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ pboxClipped->y2 = min(pextent->y2, Bottom);
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2)) {
+ pboxClipped++;
+ }
+ }
+ } else {
+ pextent = RegionExtents(prgnClip);
+ while (nrectFill--) {
+ int n;
+ BoxRec box, *pbox;
+
+ box.x1 = max(pextent->x1, prect->x);
+ box.y1 = max(pextent->y1, prect->y);
+
+ Right = (int)prect->x + (int)prect->width;
+ box.x2 = min(pextent->x2, Right);
+
+ Bottom = (int)prect->y + (int)prect->height;
+ box.y2 = min(pextent->y2, Bottom);
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = RegionNumRects (prgnClip);
+ pbox = RegionRects(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--) {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2) {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+
+ return pboxClipped - pboxClippedBase;
+}
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaGC.c b/xorg-server/hw/xfree86/xaa/xaaGC.c
index d029d982b..4bd3750cb 100644
--- a/xorg-server/hw/xfree86/xaa/xaaGC.c
+++ b/xorg-server/hw/xfree86/xaa/xaaGC.c
@@ -243,8 +243,7 @@ XAADestroyGC(GCPtr pGC)
if(pGCPriv->XAAOps != &XAAFallbackOps)
free(pGCPriv->XAAOps);
- if(pGCPriv->DashPattern)
- free(pGCPriv->DashPattern);
+ free(pGCPriv->DashPattern);
(*pGC->funcs->DestroyGC)(pGC);
XAA_GC_FUNC_EPILOGUE (pGC);
diff --git a/xorg-server/hw/xfree86/xaa/xaaImage.c b/xorg-server/hw/xfree86/xaa/xaaImage.c
index c8d98c7d0..1967c5e0e 100644
--- a/xorg-server/hw/xfree86/xaa/xaaImage.c
+++ b/xorg-server/hw/xfree86/xaa/xaaImage.c
@@ -406,7 +406,7 @@ XAAPutImage(
Bool depthBug = FALSE;
if(!w || !h) return;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
depthBug = XAA_DEPTH_BUG(pGC);
@@ -431,7 +431,7 @@ XAAPutImage(
!(infoRec->WriteBitmapFlags & NO_PLANEMASK) &&
!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))){
- int MaxBoxes = REGION_NUM_RECTS(pGC->pCompositeClip);
+ int MaxBoxes = RegionNumRects(pGC->pCompositeClip);
BoxPtr pbox, pClipBoxes;
int nboxes, srcx, srcy, srcwidth;
xRectangle TheRect;
diff --git a/xorg-server/hw/xfree86/xaa/xaaInit.c b/xorg-server/hw/xfree86/xaa/xaaInit.c
index 58efb6a82..a4b235acf 100644
--- a/xorg-server/hw/xfree86/xaa/xaaInit.c
+++ b/xorg-server/hw/xfree86/xaa/xaaInit.c
@@ -42,12 +42,12 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
static void XAAEnableDisableFBAccess (int index, Bool enable);
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
-static int XAAScreenKeyIndex;
-static DevPrivateKey XAAScreenKey = &XAAScreenKeyIndex;
-static int XAAGCKeyIndex;
-static DevPrivateKey XAAGCKey = &XAAGCKeyIndex;
-static int XAAPixmapKeyIndex;
-static DevPrivateKey XAAPixmapKey = &XAAPixmapKeyIndex;
+static DevPrivateKeyRec XAAScreenKeyRec;
+#define XAAScreenKey (&XAAScreenKeyRec)
+static DevPrivateKeyRec XAAGCKeyRec;
+#define XAAGCKey (&XAAGCKeyRec)
+static DevPrivateKeyRec XAAPixmapKeyRec;
+#define XAAPixmapKey (&XAAPixmapKeyRec)
DevPrivateKey XAAGetScreenKey(void) {
return XAAScreenKey;
@@ -84,11 +84,9 @@ XAADestroyInfoRec(XAAInfoRecPtr infoRec)
if(infoRec->ClosePixmapCache)
(*infoRec->ClosePixmapCache)(infoRec->pScrn->pScreen);
- if(infoRec->PreAllocMem)
- free(infoRec->PreAllocMem);
+ free(infoRec->PreAllocMem);
- if(infoRec->PixmapCachePrivate)
- free(infoRec->PixmapCachePrivate);
+ free(infoRec->PixmapCachePrivate);
free(infoRec);
}
@@ -106,10 +104,13 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
if (!infoRec)
return TRUE;
- if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec)))
+ if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
return FALSE;
- if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec)))
+ if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))
diff --git a/xorg-server/hw/xfree86/xaa/xaaLine.c b/xorg-server/hw/xfree86/xaa/xaaLine.c
index 7469de179..d94f1f4e0 100644
--- a/xorg-server/hw/xfree86/xaa/xaaLine.c
+++ b/xorg-server/hw/xfree86/xaa/xaaLine.c
@@ -1,394 +1,394 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-
-#include <X11/X.h>
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "miline.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-void
-#ifdef POLYSEGMENT
-XAAPolySegment(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nseg,
- xSegment *pSeg
-#else
-XAAPolyLines(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode, /* Origin or Previous */
- int npt, /* number of points */
- DDXPointPtr pptInit
-#endif
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
- int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
- unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
- int xorg = pDrawable->x;
- int yorg = pDrawable->y;
- int nbox;
- BoxPtr pbox;
-#ifndef POLYSEGMENT
- DDXPointPtr ppt;
-#endif
- int x1, x2, y1, y2, tmp, len;
-
- if(!nboxInit)
- return;
-
- if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) {
- int minValX = infoRec->SolidLineLimits.x1;
- int maxValX = infoRec->SolidLineLimits.x2;
- int minValY = infoRec->SolidLineLimits.y1;
- int maxValY = infoRec->SolidLineLimits.y2;
-#ifdef POLYSEGMENT
- int n = nseg;
- xSegment *s = pSeg;
-
- while (n--)
-#else
- int n = npt;
- int xorgtmp = xorg;
- int yorgtmp = yorg;
-
- ppt = pptInit;
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
- while (--n)
-#endif
- {
-#ifdef POLYSEGMENT
- x1 = s->x1 + xorg;
- y1 = s->y1 + yorg;
- x2 = s->x2 + xorg;
- y2 = s->y2 + yorg;
- s++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorgtmp = x1;
- yorgtmp = y1;
- }
- x2 = ppt->x + xorgtmp;
- y2 = ppt->y + yorgtmp;
-#endif
- if (x1 > maxValX || x1 < minValX ||
- x2 > maxValX || x2 < minValX ||
- y1 > maxValY || y1 < minValY ||
- y2 > maxValY || y2 < minValY) {
-#ifdef POLYSEGMENT
- XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
-#else
- XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
-#endif
- return;
- }
- }
- }
-
- (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel,
- pGC->alu, pGC->planemask);
-
-#ifdef POLYSEGMENT
- while (nseg--)
-#else
- ppt = pptInit;
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
- while(--npt)
-#endif
- {
- nbox = nboxInit;
- pbox = pboxInit;
-
-#ifdef POLYSEGMENT
- x1 = pSeg->x1 + xorg;
- y1 = pSeg->y1 + yorg;
- x2 = pSeg->x2 + xorg;
- y2 = pSeg->y2 + yorg;
- pSeg++;
-#else
- x1 = x2;
- y1 = y2;
- ++ppt;
- if (mode == CoordModePrevious) {
- xorg = x1;
- yorg = y1;
- }
- x2 = ppt->x + xorg;
- y2 = ppt->y + yorg;
-#endif
-
- if (x1 == x2) { /* vertical line */
- /* make the line go top to bottom of screen, keeping
- endpoint semantics
- */
- if (y1 > y2) {
- tmp = y2;
- y2 = y1 + 1;
- y1 = tmp + 1;
-#ifdef POLYSEGMENT
- if (pGC->capStyle != CapNotLast) y1--;
-#endif
- }
-#ifdef POLYSEGMENT
- else if (pGC->capStyle != CapNotLast) y2++;
-#endif
- /* get to first band that might contain part of line */
- while(nbox && (pbox->y2 <= y1)) {
- pbox++;
- nbox--;
- }
-
- /* stop when lower edge of box is beyond end of line */
- while(nbox && (y2 >= pbox->y1)) {
- if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
- tmp = max(y1, pbox->y1);
- len = min(y2, pbox->y2) - tmp;
- if (len) (*infoRec->SubsequentSolidHorVertLine)(
- infoRec->pScrn, x1, tmp, len, DEGREES_270);
- }
- nbox--;
- pbox++;
- }
-#ifndef POLYSEGMENT
- y2 = ppt->y + yorg;
-#endif
- } else if (y1 == y2) { /* horizontal line */
- /* force line from left to right, keeping endpoint semantics */
- if (x1 > x2) {
- tmp = x2;
- x2 = x1 + 1;
- x1 = tmp + 1;
-#ifdef POLYSEGMENT
- if (pGC->capStyle != CapNotLast) x1--;
-#endif
- }
-#ifdef POLYSEGMENT
- else if (pGC->capStyle != CapNotLast) x2++;
-#endif
-
- /* find the correct band */
- while(nbox && (pbox->y2 <= y1)) {
- pbox++;
- nbox--;
- }
-
- /* try to draw the line, if we haven't gone beyond it */
- if (nbox && (pbox->y1 <= y1)) {
- int orig_y = pbox->y1;
- /* when we leave this band, we're done */
- while(nbox && (orig_y == pbox->y1)) {
- if (pbox->x2 <= x1) {
- /* skip boxes until one might contain start point */
- nbox--;
- pbox++;
- continue;
- }
-
- /* stop if left of box is beyond right of line */
- if (pbox->x1 >= x2) {
- nbox = 0;
- break;
- }
-
- tmp = max(x1, pbox->x1);
- len = min(x2, pbox->x2) - tmp;
- if (len) (*infoRec->SubsequentSolidHorVertLine)(
- infoRec->pScrn, tmp, y1, len, DEGREES_0);
- nbox--;
- pbox++;
- }
- }
-#ifndef POLYSEGMENT
- x2 = ppt->x + xorg;
-#endif
- } else{ /* sloped line */
- unsigned int oc1, oc2;
- int dmin, dmaj, e, octant;
-
- if (infoRec->SubsequentSolidBresenhamLine) {
- if((dmaj = x2 - x1) < 0) {
- dmaj = -dmaj;
- octant = XDECREASING;
- } else octant = 0;
-
- if((dmin = y2 - y1) < 0) {
- dmin = -dmin;
- octant |= YDECREASING;
- }
-
- if(dmin >= dmaj){
- tmp = dmin; dmin = dmaj; dmaj = tmp;
- octant |= YMAJOR;
- }
-
- e = -dmaj - ((bias >> octant) & 1);
- len = dmaj;
- dmin <<= 1;
- dmaj <<= 1;
- } else { /* Muffle compiler */
- dmin = dmaj = e = octant = len = 0;
- }
-
- while(nbox--) {
- oc1 = oc2 = 0;
- OUTCODES(oc1, x1, y1, pbox);
- OUTCODES(oc2, x2, y2, pbox);
- if (!(oc1 | oc2)) { /* unclipped */
- if(infoRec->SubsequentSolidTwoPointLine) {
- (*infoRec->SubsequentSolidTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST
- );
- } else {
- (*infoRec->SubsequentSolidBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant);
- }
- break;
- } else if (oc1 & oc2) { /* completely clipped */
- pbox++;
- } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) {
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
-
- if(infoRec->SubsequentSolidBresenhamLine) {
- (*infoRec->SubsequentSolidBresenhamLine)(
- infoRec->pScrn, x1, y1, dmaj, dmin, e,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? (len+1) :
-#endif
- len, octant);
- } else {
- (*infoRec->SubsequentSolidTwoPointLine)(
- infoRec->pScrn, x1, y1, x2, y2,
-#ifdef POLYSEGMENT
- (pGC->capStyle != CapNotLast) ? 0 :
-#endif
- OMIT_LAST
- );
- }
- (*infoRec->DisableClipping)(infoRec->pScrn);
- pbox++;
- } else {
- int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
- int clip1 = 0, clip2 = 0;
- int err, adx, ady;
-
- if(octant & YMAJOR) {
- ady = dmaj >> 1;
- adx = dmin >> 1;
- } else {
- ady = dmin >> 1;
- adx = dmaj >> 1;
- }
-
- if (miZeroClipLine(pbox->x1, pbox->y1,
- pbox->x2 - 1, pbox->y2 - 1,
- &new_x1, &new_y1, &new_x2, &new_y2,
- adx, ady, &clip1, &clip2,
- octant, bias, oc1, oc2) == -1)
- {
- pbox++;
- continue;
- }
-
- if (octant & YMAJOR)
- len = abs(new_y2 - new_y1);
- else
- len = abs(new_x2 - new_x1);
-#ifdef POLYSEGMENT
- if (clip2 != 0 || pGC->capStyle != CapNotLast)
- len++;
-#else
- len += (clip2 != 0);
-#endif
- if (len) {
- int abserr, clipdx, clipdy;
- /* unwind bresenham error term to first point */
- if (clip1) {
- clipdx = abs(new_x1 - x1);
- clipdy = abs(new_y1 - y1);
-
- if (octant & YMAJOR)
- err = e + clipdy*dmin - clipdx*dmaj;
- else
- err = e + clipdx*dmin - clipdy*dmaj;
- } else
- err = e;
-
-#define range infoRec->SolidBresenhamLineErrorTermBits
- abserr = abs(err);
- while((abserr & range) ||
- (dmaj & range) ||
- (dmin & range)) {
- dmin >>= 1;
- dmaj >>= 1;
- abserr >>= 1;
- err /= 2;
- }
-
- (*infoRec->SubsequentSolidBresenhamLine)(
- infoRec->pScrn, new_x1, new_y1,
- dmaj, dmin, err, len, octant);
- }
- pbox++;
- }
- } /* while (nbox--) */
- } /* sloped line */
- } /* while (nline--) */
-
-#ifndef POLYSEGMENT
- /* paint the last point if the end style isn't CapNotLast.
- (Assume that a projecting, butt, or round cap that is one
- pixel wide is the same as the single pixel of the endpoint.)
- */
-
- if ((pGC->capStyle != CapNotLast) &&
- ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
- (ppt->y + yorg != pptInit->y + pDrawable->y) ||
- (ppt == pptInit + 1)))
- {
- nbox = nboxInit;
- pbox = pboxInit;
- while (nbox--)
- {
- if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
- (x2 < pbox->x2) && (y2 < pbox->y2))
- {
- (*infoRec->SubsequentSolidHorVertLine)(
- infoRec->pScrn, x2, y2, 1, DEGREES_0);
- break;
- }
- else
- pbox++;
- }
- }
-#endif
-
- SET_SYNC_FLAG(infoRec);
-}
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <stdlib.h>
+
+#include <X11/X.h>
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "miline.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+void
+#ifdef POLYSEGMENT
+XAAPolySegment(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+#else
+XAAPolyLines(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode, /* Origin or Previous */
+ int npt, /* number of points */
+ DDXPointPtr pptInit
+#endif
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr pboxInit = RegionRects(pGC->pCompositeClip);
+ int nboxInit = RegionNumRects(pGC->pCompositeClip);
+ unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ int nbox;
+ BoxPtr pbox;
+#ifndef POLYSEGMENT
+ DDXPointPtr ppt;
+#endif
+ int x1, x2, y1, y2, tmp, len;
+
+ if(!nboxInit)
+ return;
+
+ if (infoRec->SolidLineFlags & LINE_LIMIT_COORDS) {
+ int minValX = infoRec->SolidLineLimits.x1;
+ int maxValX = infoRec->SolidLineLimits.x2;
+ int minValY = infoRec->SolidLineLimits.y1;
+ int maxValY = infoRec->SolidLineLimits.y2;
+#ifdef POLYSEGMENT
+ int n = nseg;
+ xSegment *s = pSeg;
+
+ while (n--)
+#else
+ int n = npt;
+ int xorgtmp = xorg;
+ int yorgtmp = yorg;
+
+ ppt = pptInit;
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+ while (--n)
+#endif
+ {
+#ifdef POLYSEGMENT
+ x1 = s->x1 + xorg;
+ y1 = s->y1 + yorg;
+ x2 = s->x2 + xorg;
+ y2 = s->y2 + yorg;
+ s++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorgtmp = x1;
+ yorgtmp = y1;
+ }
+ x2 = ppt->x + xorgtmp;
+ y2 = ppt->y + yorgtmp;
+#endif
+ if (x1 > maxValX || x1 < minValX ||
+ x2 > maxValX || x2 < minValX ||
+ y1 > maxValY || y1 < minValY ||
+ y2 > maxValY || y2 < minValY) {
+#ifdef POLYSEGMENT
+ XAAFallbackOps.PolySegment(pDrawable, pGC, nseg, pSeg);
+#else
+ XAAFallbackOps.Polylines(pDrawable, pGC, mode, npt, pptInit);
+#endif
+ return;
+ }
+ }
+ }
+
+ (*infoRec->SetupForSolidLine)(infoRec->pScrn, pGC->fgPixel,
+ pGC->alu, pGC->planemask);
+
+#ifdef POLYSEGMENT
+ while (nseg--)
+#else
+ ppt = pptInit;
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+ while(--npt)
+#endif
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+
+#ifdef POLYSEGMENT
+ x1 = pSeg->x1 + xorg;
+ y1 = pSeg->y1 + yorg;
+ x2 = pSeg->x2 + xorg;
+ y2 = pSeg->y2 + yorg;
+ pSeg++;
+#else
+ x1 = x2;
+ y1 = y2;
+ ++ppt;
+ if (mode == CoordModePrevious) {
+ xorg = x1;
+ yorg = y1;
+ }
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+#endif
+
+ if (x1 == x2) { /* vertical line */
+ /* make the line go top to bottom of screen, keeping
+ endpoint semantics
+ */
+ if (y1 > y2) {
+ tmp = y2;
+ y2 = y1 + 1;
+ y1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast) y1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast) y2++;
+#endif
+ /* get to first band that might contain part of line */
+ while(nbox && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* stop when lower edge of box is beyond end of line */
+ while(nbox && (y2 >= pbox->y1)) {
+ if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ tmp = max(y1, pbox->y1);
+ len = min(y2, pbox->y2) - tmp;
+ if (len) (*infoRec->SubsequentSolidHorVertLine)(
+ infoRec->pScrn, x1, tmp, len, DEGREES_270);
+ }
+ nbox--;
+ pbox++;
+ }
+#ifndef POLYSEGMENT
+ y2 = ppt->y + yorg;
+#endif
+ } else if (y1 == y2) { /* horizontal line */
+ /* force line from left to right, keeping endpoint semantics */
+ if (x1 > x2) {
+ tmp = x2;
+ x2 = x1 + 1;
+ x1 = tmp + 1;
+#ifdef POLYSEGMENT
+ if (pGC->capStyle != CapNotLast) x1--;
+#endif
+ }
+#ifdef POLYSEGMENT
+ else if (pGC->capStyle != CapNotLast) x2++;
+#endif
+
+ /* find the correct band */
+ while(nbox && (pbox->y2 <= y1)) {
+ pbox++;
+ nbox--;
+ }
+
+ /* try to draw the line, if we haven't gone beyond it */
+ if (nbox && (pbox->y1 <= y1)) {
+ int orig_y = pbox->y1;
+ /* when we leave this band, we're done */
+ while(nbox && (orig_y == pbox->y1)) {
+ if (pbox->x2 <= x1) {
+ /* skip boxes until one might contain start point */
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ /* stop if left of box is beyond right of line */
+ if (pbox->x1 >= x2) {
+ nbox = 0;
+ break;
+ }
+
+ tmp = max(x1, pbox->x1);
+ len = min(x2, pbox->x2) - tmp;
+ if (len) (*infoRec->SubsequentSolidHorVertLine)(
+ infoRec->pScrn, tmp, y1, len, DEGREES_0);
+ nbox--;
+ pbox++;
+ }
+ }
+#ifndef POLYSEGMENT
+ x2 = ppt->x + xorg;
+#endif
+ } else{ /* sloped line */
+ unsigned int oc1, oc2;
+ int dmin, dmaj, e, octant;
+
+ if (infoRec->SubsequentSolidBresenhamLine) {
+ if((dmaj = x2 - x1) < 0) {
+ dmaj = -dmaj;
+ octant = XDECREASING;
+ } else octant = 0;
+
+ if((dmin = y2 - y1) < 0) {
+ dmin = -dmin;
+ octant |= YDECREASING;
+ }
+
+ if(dmin >= dmaj){
+ tmp = dmin; dmin = dmaj; dmaj = tmp;
+ octant |= YMAJOR;
+ }
+
+ e = -dmaj - ((bias >> octant) & 1);
+ len = dmaj;
+ dmin <<= 1;
+ dmaj <<= 1;
+ } else { /* Muffle compiler */
+ dmin = dmaj = e = octant = len = 0;
+ }
+
+ while(nbox--) {
+ oc1 = oc2 = 0;
+ OUTCODES(oc1, x1, y1, pbox);
+ OUTCODES(oc2, x2, y2, pbox);
+ if (!(oc1 | oc2)) { /* unclipped */
+ if(infoRec->SubsequentSolidTwoPointLine) {
+ (*infoRec->SubsequentSolidTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST
+ );
+ } else {
+ (*infoRec->SubsequentSolidBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant);
+ }
+ break;
+ } else if (oc1 & oc2) { /* completely clipped */
+ pbox++;
+ } else if (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_LINE) {
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ pbox->x1, pbox->y1, pbox->x2 - 1, pbox->y2 - 1);
+
+ if(infoRec->SubsequentSolidBresenhamLine) {
+ (*infoRec->SubsequentSolidBresenhamLine)(
+ infoRec->pScrn, x1, y1, dmaj, dmin, e,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? (len+1) :
+#endif
+ len, octant);
+ } else {
+ (*infoRec->SubsequentSolidTwoPointLine)(
+ infoRec->pScrn, x1, y1, x2, y2,
+#ifdef POLYSEGMENT
+ (pGC->capStyle != CapNotLast) ? 0 :
+#endif
+ OMIT_LAST
+ );
+ }
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+ pbox++;
+ } else {
+ int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
+ int clip1 = 0, clip2 = 0;
+ int err, adx, ady;
+
+ if(octant & YMAJOR) {
+ ady = dmaj >> 1;
+ adx = dmin >> 1;
+ } else {
+ ady = dmin >> 1;
+ adx = dmaj >> 1;
+ }
+
+ if (miZeroClipLine(pbox->x1, pbox->y1,
+ pbox->x2 - 1, pbox->y2 - 1,
+ &new_x1, &new_y1, &new_x2, &new_y2,
+ adx, ady, &clip1, &clip2,
+ octant, bias, oc1, oc2) == -1)
+ {
+ pbox++;
+ continue;
+ }
+
+ if (octant & YMAJOR)
+ len = abs(new_y2 - new_y1);
+ else
+ len = abs(new_x2 - new_x1);
+#ifdef POLYSEGMENT
+ if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ len++;
+#else
+ len += (clip2 != 0);
+#endif
+ if (len) {
+ int abserr, clipdx, clipdy;
+ /* unwind bresenham error term to first point */
+ if (clip1) {
+ clipdx = abs(new_x1 - x1);
+ clipdy = abs(new_y1 - y1);
+
+ if (octant & YMAJOR)
+ err = e + clipdy*dmin - clipdx*dmaj;
+ else
+ err = e + clipdx*dmin - clipdy*dmaj;
+ } else
+ err = e;
+
+#define range infoRec->SolidBresenhamLineErrorTermBits
+ abserr = abs(err);
+ while((abserr & range) ||
+ (dmaj & range) ||
+ (dmin & range)) {
+ dmin >>= 1;
+ dmaj >>= 1;
+ abserr >>= 1;
+ err /= 2;
+ }
+
+ (*infoRec->SubsequentSolidBresenhamLine)(
+ infoRec->pScrn, new_x1, new_y1,
+ dmaj, dmin, err, len, octant);
+ }
+ pbox++;
+ }
+ } /* while (nbox--) */
+ } /* sloped line */
+ } /* while (nline--) */
+
+#ifndef POLYSEGMENT
+ /* paint the last point if the end style isn't CapNotLast.
+ (Assume that a projecting, butt, or round cap that is one
+ pixel wide is the same as the single pixel of the endpoint.)
+ */
+
+ if ((pGC->capStyle != CapNotLast) &&
+ ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ (ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ (ppt == pptInit + 1)))
+ {
+ nbox = nboxInit;
+ pbox = pboxInit;
+ while (nbox--)
+ {
+ if ((x2 >= pbox->x1) && (y2 >= pbox->y1) &&
+ (x2 < pbox->x2) && (y2 < pbox->y2))
+ {
+ (*infoRec->SubsequentSolidHorVertLine)(
+ infoRec->pScrn, x2, y2, 1, DEGREES_0);
+ break;
+ }
+ else
+ pbox++;
+ }
+ }
+#endif
+
+ SET_SYNC_FLAG(infoRec);
+}
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c
index 3e5330fd3..44048674e 100644
--- a/xorg-server/hw/xfree86/xaa/xaaLineMisc.c
+++ b/xorg-server/hw/xfree86/xaa/xaaLineMisc.c
@@ -74,8 +74,7 @@ XAAComputeDash(GCPtr pGC)
int shift, value, direction;
Bool set;
- if(pGCPriv->DashPattern)
- free(pGCPriv->DashPattern);
+ free(pGCPriv->DashPattern);
pGCPriv->DashPattern = NULL;
pGCPriv->DashLength = 0;
diff --git a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c
index eb798a82b..519bda0e7 100644
--- a/xorg-server/hw/xfree86/xaa/xaaNonTEText.c
+++ b/xorg-server/hw/xfree86/xaa/xaaNonTEText.c
@@ -82,7 +82,7 @@ XAAPolyText8NonTEColorExpansion(
infoRec->CharInfo);
}
- return (x + width);
+ return x + width;
}
@@ -112,7 +112,7 @@ XAAPolyText16NonTEColorExpansion(
infoRec->CharInfo);
}
- return (x + width);
+ return x + width;
}
@@ -128,7 +128,7 @@ XAAImageText8NonTEColorExpansion(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
@@ -153,7 +153,7 @@ XAAImageText16NonTEColorExpansion(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(
@@ -188,7 +188,7 @@ XAAImageGlyphBltNonTEColorExpansion(
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
ImageGlyphBltNonTEColorExpansion(
@@ -208,7 +208,7 @@ XAAPolyGlyphBltNonTEColorExpansion(
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
PolyGlyphBltNonTEColorExpansion(
@@ -368,8 +368,8 @@ ImageGlyphBltNonTEColorExpansion(
int skippix, skipglyph, width, n, i;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge, ytop, ybot;
- int nbox = REGION_NUM_RECTS(cclip);
- BoxPtr pbox = REGION_RECTS(cclip);
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
Bool AlreadySetup = FALSE;
width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
@@ -405,8 +405,8 @@ ImageGlyphBltNonTEColorExpansion(
nbox--; pbox++;
}
- nbox = REGION_NUM_RECTS(cclip);
- pbox = REGION_RECTS(cclip);
+ nbox = RegionNumRects(cclip);
+ pbox = RegionRects(cclip);
if(infoRec->WriteBitmap && (nglyph > 1) &&
((FONTMAXBOUNDS(font, rightSideBearing) -
@@ -477,8 +477,8 @@ PolyGlyphBltNonTEColorExpansion(
int skippix, skipglyph, width, n, i;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge;
- int nbox = REGION_NUM_RECTS(cclip);
- BoxPtr pbox = REGION_RECTS(cclip);
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
width = CollectCharacterInfo(infoRec->GlyphInfo, nglyph, ppci, font);
diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlay.c b/xorg-server/hw/xfree86/xaa/xaaOverlay.c
index b7122a58f..176a2d891 100644
--- a/xorg-server/hw/xfree86/xaa/xaaOverlay.c
+++ b/xorg-server/hw/xfree86/xaa/xaaOverlay.c
@@ -54,23 +54,23 @@ XAACopyWindow8_32(
return;
}
- pwinRoot = WindowTable[pScreen->myNum];
+ pwinRoot = pScreen->root;
if(doUnderlay)
freeReg = miOverlayCollectUnderlayRegions(pWin, &borderClip);
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pScreen, &rgnDst, borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, borderClip, prgnSrc);
- pbox = REGION_RECTS(&rgnDst);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
if(!nbox ||
!(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
return;
}
ppt = pptSrc;
@@ -88,9 +88,9 @@ XAACopyWindow8_32(
&(infoRec->ScratchGC), &rgnDst, pptSrc);
free(pptSrc);
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if(freeReg)
- REGION_DESTROY(pScreen, borderClip);
+ RegionDestroy(borderClip);
}
static void
diff --git a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c
index 4548935fd..309ec9fa4 100644
--- a/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/xorg-server/hw/xfree86/xaa/xaaOverlayDF.c
@@ -151,8 +151,8 @@ typedef struct {
int (*TiledFillChooser)(GCPtr);
} XAAOverlayRec, *XAAOverlayPtr;
-static int XAAOverlayKeyIndex;
-static DevPrivateKey XAAOverlayKey = &XAAOverlayKeyIndex;
+static DevPrivateKeyRec XAAOverlayKeyRec;
+#define XAAOverlayKey (&XAAOverlayKeyRec)
#define GET_OVERLAY_PRIV(pScreen) \
(XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
@@ -173,6 +173,9 @@ XAAInitDualFramebufferOverlay(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAOverlayPtr pOverPriv;
+ if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
+ return FALSE;
+
if(!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
return FALSE;
@@ -324,7 +327,7 @@ XAAOverCopyWindow(
RegionRec rgnDst;
BoxPtr pbox;
int i, nbox, dx, dy;
- WindowPtr pRoot = WindowTable[pScreen->myNum];
+ WindowPtr pRoot = pScreen->root;
if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) {
@@ -341,18 +344,18 @@ XAAOverCopyWindow(
infoRec->ScratchGC.alu = GXcopy;
infoRec->ScratchGC.planemask = ~0;
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
- REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ RegionTranslate(prgnSrc, -dx, -dy);
+ RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ nbox = RegionNumRects(&rgnDst);
if(nbox &&
(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))) {
- pbox = REGION_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
ppt->x = pbox->x1 + dx;
ppt->y = pbox->y1 + dy;
@@ -371,18 +374,18 @@ XAAOverCopyWindow(
free(pptSrc);
}
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
if(pWin->drawable.depth == 8) {
- REGION_NULL(pScreen, &rgnDst);
+ RegionNull(&rgnDst);
miSegregateChildren(pWin, &rgnDst, pScrn->depth);
- if(REGION_NOTEMPTY(pScreen, &rgnDst)) {
- REGION_INTERSECT(pScreen, &rgnDst, &rgnDst, prgnSrc);
- nbox = REGION_NUM_RECTS(&rgnDst);
+ if(RegionNotEmpty(&rgnDst)) {
+ RegionIntersect(&rgnDst, &rgnDst, prgnSrc);
+ nbox = RegionNumRects(&rgnDst);
if(nbox &&
(pptSrc = (DDXPointPtr )malloc(nbox * sizeof(DDXPointRec)))){
- pbox = REGION_RECTS(&rgnDst);
+ pbox = RegionRects(&rgnDst);
for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
ppt->x = pbox->x1 + dx;
ppt->y = pbox->y1 + dy;
@@ -394,7 +397,7 @@ XAAOverCopyWindow(
free(pptSrc);
}
}
- REGION_UNINIT(pScreen, &rgnDst);
+ RegionUninit(&rgnDst);
}
}
@@ -409,13 +412,13 @@ XAAOverWindowExposures(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
if((pWin->drawable.bitsPerPixel != 8) && infoRec->pScrn->vtSema) {
- if(REGION_NUM_RECTS(pReg) && infoRec->FillSolidRects) {
+ if(RegionNumRects(pReg) && infoRec->FillSolidRects) {
XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen);
SWITCH_DEPTH(8);
(*infoRec->FillSolidRects)(infoRec->pScrn,
infoRec->pScrn->colorKey, GXcopy, ~0,
- REGION_NUM_RECTS(pReg), REGION_RECTS(pReg));
+ RegionNumRects(pReg), RegionRects(pReg));
miWindowExposures(pWin, pReg, pOtherReg);
return;
} else if(infoRec->NeedToSync) {
diff --git a/xorg-server/hw/xfree86/xaa/xaaPCache.c b/xorg-server/hw/xfree86/xaa/xaaPCache.c
index 62726d539..ff3f9ef56 100644
--- a/xorg-server/hw/xfree86/xaa/xaaPCache.c
+++ b/xorg-server/hw/xfree86/xaa/xaaPCache.c
@@ -144,18 +144,12 @@ FreePixmapCachePrivate(XAAPixmapCachePrivatePtr pPriv)
{
if(!pPriv) return;
- if(pPriv->Info512)
- free(pPriv->Info512);
- if(pPriv->Info256)
- free(pPriv->Info256);
- if(pPriv->Info128)
- free(pPriv->Info128);
- if(pPriv->InfoColor)
- free(pPriv->InfoColor);
- if(pPriv->InfoMono)
- free(pPriv->InfoMono);
- if(pPriv->InfoPartial)
- free(pPriv->InfoPartial);
+ free(pPriv->Info512);
+ free(pPriv->Info256);
+ free(pPriv->Info128);
+ free(pPriv->InfoColor);
+ free(pPriv->InfoMono);
+ free(pPriv->InfoPartial);
free(pPriv);
}
@@ -639,8 +633,8 @@ XAAInitPixmapCache(
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XAAInfoRecPtr infoRec = (XAAInfoRecPtr)data;
XAAPixmapCachePrivatePtr pCachePriv;
- BoxPtr pBox = REGION_RECTS(areas);
- int nBox = REGION_NUM_RECTS(areas);
+ BoxPtr pBox = RegionRects(areas);
+ int nBox = RegionNumRects(areas);
int Num512, Num256, Num128, NumPartial, NumColor, NumMono;
int Target512, Target256;
CacheLinkPtr List512, List256, List128, ListPartial, ListColor, ListMono;
diff --git a/xorg-server/hw/xfree86/xaa/xaaPict.c b/xorg-server/hw/xfree86/xaa/xaaPict.c
index b66291458..1ad75835b 100644
--- a/xorg-server/hw/xfree86/xaa/xaaPict.c
+++ b/xorg-server/hw/xfree86/xaa/xaaPict.c
@@ -215,7 +215,7 @@ XAADoComposite (
BoxPtr pbox;
int nbox, w, h;
- if(!REGION_NUM_RECTS(pDst->pCompositeClip))
+ if(!RegionNumRects(pDst->pCompositeClip))
return TRUE;
if(!infoRec->pScrn->vtSema || !DRAWABLE_IS_ON_CARD(pDst->pDrawable))
@@ -273,8 +273,8 @@ XAADoComposite (
width, height))
return TRUE;
- nbox = REGION_NUM_RECTS(&region);
- pbox = REGION_RECTS(&region);
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
if(!nbox)
return TRUE;
@@ -298,7 +298,7 @@ XAADoComposite (
}
/* WriteBitmap sets the Sync flag */
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return TRUE;
}
@@ -340,11 +340,11 @@ XAADoComposite (
width, height))
return TRUE;
- nbox = REGION_NUM_RECTS(&region);
- pbox = REGION_RECTS(&region);
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
if(!nbox) {
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return TRUE;
}
@@ -355,7 +355,7 @@ XAADoComposite (
((PixmapPtr)(pMask->pDrawable))->devKind,
w, h, flags))
{
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return FALSE;
}
@@ -371,7 +371,7 @@ XAADoComposite (
}
SET_SYNC_FLAG(infoRec);
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return TRUE;
}
} else {
@@ -409,11 +409,11 @@ XAADoComposite (
width, height))
return TRUE;
- nbox = REGION_NUM_RECTS(&region);
- pbox = REGION_RECTS(&region);
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
if(!nbox) {
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return TRUE;
}
@@ -423,7 +423,7 @@ XAADoComposite (
((PixmapPtr)(pSrc->pDrawable))->devKind,
w, h, flags))
{
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return FALSE;
}
@@ -440,7 +440,7 @@ XAADoComposite (
}
SET_SYNC_FLAG(infoRec);
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return TRUE;
}
@@ -476,16 +476,16 @@ XAACompositeSrcCopy (PicturePtr pSrc,
width, height))
return;
- nbox = REGION_NUM_RECTS(&region);
- pbox = REGION_RECTS(&region);
+ nbox = RegionNumRects(&region);
+ pbox = RegionRects(&region);
if(!nbox) {
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return;
}
pptSrc = malloc(sizeof(DDXPointRec) * nbox);
if (!pptSrc) {
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return;
}
xoff = xSrc - xDst;
@@ -502,7 +502,7 @@ XAACompositeSrcCopy (PicturePtr pSrc,
pptSrc);
free(pptSrc);
- REGION_UNINIT(pScreen, &region);
+ RegionUninit(&region);
return;
}
@@ -588,7 +588,7 @@ XAADoGlyphs (CARD8 op,
ScreenPtr pScreen = pDst->pDrawable->pScreen;
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
- if(!REGION_NUM_RECTS(pDst->pCompositeClip))
+ if(!RegionNumRects(pDst->pCompositeClip))
return TRUE;
if(!infoRec->pScrn->vtSema ||
diff --git a/xorg-server/hw/xfree86/xaa/xaaRect.c b/xorg-server/hw/xfree86/xaa/xaaRect.c
index 0a7e174b7..988dbf608 100644
--- a/xorg-server/hw/xfree86/xaa/xaaRect.c
+++ b/xorg-server/hw/xfree86/xaa/xaaRect.c
@@ -1,136 +1,136 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-/*
- Much of this file based on code by
- Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
-*/
-
-
-void
-XAAPolyRectangleThinSolid(
- DrawablePtr pDrawable,
- GCPtr pGC,
- int nRectsInit,
- xRectangle *pRectsInit )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int nClipRects; /* number of clip rectangles */
- BoxPtr pClipRects; /* points to the list of clip rects */
- int xOrigin; /* Drawables x origin */
- int yOrigin; /* Drawables x origin */
- xRectangle *pRect; /* list of rects */
- int nRects; /* running count of number of rects */
- int origX1, origY1; /* original rectangle's U/L corner */
- int origX2, origY2; /* original rectangle's L/R corner */
- int clippedX1; /* clipped rectangle's left x */
- int clippedY1; /* clipped rectangle's top y */
- int clippedX2; /* clipped rectangle's right x */
- int clippedY2; /* clipped rectangle's bottom y */
- int clipXMin; /* upper left corner of clip rect */
- int clipYMin; /* upper left corner of clip rect */
- int clipXMax; /* lower right corner of clip rect */
- int clipYMax; /* lower right corner of clip rect */
- int width, height; /* width and height of rect */
-
- nClipRects = REGION_NUM_RECTS(pGC->pCompositeClip);
- pClipRects = REGION_RECTS(pGC->pCompositeClip);
-
- if(!nClipRects) return;
-
- xOrigin = pDrawable->x;
- yOrigin = pDrawable->y;
-
-
- (*infoRec->SetupForSolidLine)(infoRec->pScrn,
- pGC->fgPixel, pGC->alu, pGC->planemask);
-
-
- for ( ; nClipRects > 0;
- nClipRects--, pClipRects++ )
- {
- clipYMin = pClipRects->y1;
- clipYMax = pClipRects->y2 - 1;
- clipXMin = pClipRects->x1;
- clipXMax = pClipRects->x2 - 1;
-
- for (pRect = pRectsInit, nRects = nRectsInit;
- nRects > 0;
- nRects--, pRect++ )
- {
- /* translate rectangle data over to the drawable */
- origX1 = pRect->x + xOrigin;
- origY1 = pRect->y + yOrigin;
- origX2 = origX1 + pRect->width;
- origY2 = origY1 + pRect->height;
-
- /* reject entire rectangle if completely outside clip rect */
- if ((origX1 > clipXMax) || (origX2 < clipXMin) ||
- (origY1 > clipYMax) || (origY2 < clipYMin))
- continue;
-
- /* clip the rectangle */
- clippedX1 = max (origX1, clipXMin);
- clippedX2 = min (origX2, clipXMax);
- clippedY1 = max (origY1, clipYMin);
- clippedY2 = min (origY2, clipYMax);
-
- width = clippedX2 - clippedX1 + 1;
-
- if (origY1 >= clipYMin) {
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX1, clippedY1, width, DEGREES_0);
-
- /* don't overwrite corner */
- clippedY1++;
- }
-
- if ((origY2 <= clipYMax) && (origY1 != origY2)) {
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX1, clippedY2, width, DEGREES_0);
-
- /* don't overwrite corner */
- clippedY2--;
- }
-
- if (clippedY2 < clippedY1) continue;
-
- height = clippedY2 - clippedY1 + 1;
-
- /* draw vertical edges using lines if not clipped out */
- if (origX1 >= clipXMin)
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX1, clippedY1, height, DEGREES_270);
-
- if ((origX2 <= clipXMax) && (origX2 != origX1))
- (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
- clippedX2, clippedY1, height, DEGREES_270);
- }
- }
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-
-
-
-
-
-
-
-
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+/*
+ Much of this file based on code by
+ Harm Hanemaayer (H.Hanemaayer@inter.nl.net).
+*/
+
+
+void
+XAAPolyRectangleThinSolid(
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int nRectsInit,
+ xRectangle *pRectsInit )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int nClipRects; /* number of clip rectangles */
+ BoxPtr pClipRects; /* points to the list of clip rects */
+ int xOrigin; /* Drawables x origin */
+ int yOrigin; /* Drawables x origin */
+ xRectangle *pRect; /* list of rects */
+ int nRects; /* running count of number of rects */
+ int origX1, origY1; /* original rectangle's U/L corner */
+ int origX2, origY2; /* original rectangle's L/R corner */
+ int clippedX1; /* clipped rectangle's left x */
+ int clippedY1; /* clipped rectangle's top y */
+ int clippedX2; /* clipped rectangle's right x */
+ int clippedY2; /* clipped rectangle's bottom y */
+ int clipXMin; /* upper left corner of clip rect */
+ int clipYMin; /* upper left corner of clip rect */
+ int clipXMax; /* lower right corner of clip rect */
+ int clipYMax; /* lower right corner of clip rect */
+ int width, height; /* width and height of rect */
+
+ nClipRects = RegionNumRects(pGC->pCompositeClip);
+ pClipRects = RegionRects(pGC->pCompositeClip);
+
+ if(!nClipRects) return;
+
+ xOrigin = pDrawable->x;
+ yOrigin = pDrawable->y;
+
+
+ (*infoRec->SetupForSolidLine)(infoRec->pScrn,
+ pGC->fgPixel, pGC->alu, pGC->planemask);
+
+
+ for ( ; nClipRects > 0;
+ nClipRects--, pClipRects++ )
+ {
+ clipYMin = pClipRects->y1;
+ clipYMax = pClipRects->y2 - 1;
+ clipXMin = pClipRects->x1;
+ clipXMax = pClipRects->x2 - 1;
+
+ for (pRect = pRectsInit, nRects = nRectsInit;
+ nRects > 0;
+ nRects--, pRect++ )
+ {
+ /* translate rectangle data over to the drawable */
+ origX1 = pRect->x + xOrigin;
+ origY1 = pRect->y + yOrigin;
+ origX2 = origX1 + pRect->width;
+ origY2 = origY1 + pRect->height;
+
+ /* reject entire rectangle if completely outside clip rect */
+ if ((origX1 > clipXMax) || (origX2 < clipXMin) ||
+ (origY1 > clipYMax) || (origY2 < clipYMin))
+ continue;
+
+ /* clip the rectangle */
+ clippedX1 = max (origX1, clipXMin);
+ clippedX2 = min (origX2, clipXMax);
+ clippedY1 = max (origY1, clipYMin);
+ clippedY2 = min (origY2, clipYMax);
+
+ width = clippedX2 - clippedX1 + 1;
+
+ if (origY1 >= clipYMin) {
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX1, clippedY1, width, DEGREES_0);
+
+ /* don't overwrite corner */
+ clippedY1++;
+ }
+
+ if ((origY2 <= clipYMax) && (origY1 != origY2)) {
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX1, clippedY2, width, DEGREES_0);
+
+ /* don't overwrite corner */
+ clippedY2--;
+ }
+
+ if (clippedY2 < clippedY1) continue;
+
+ height = clippedY2 - clippedY1 + 1;
+
+ /* draw vertical edges using lines if not clipped out */
+ if (origX1 >= clipXMin)
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX1, clippedY1, height, DEGREES_270);
+
+ if ((origX2 <= clipXMax) && (origX2 != origX1))
+ (*infoRec->SubsequentSolidHorVertLine)(infoRec->pScrn,
+ clippedX2, clippedY1, height, DEGREES_270);
+ }
+ }
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/xorg-server/hw/xfree86/xaa/xaaSpans.c b/xorg-server/hw/xfree86/xaa/xaaSpans.c
index 46d6d0740..1e6ef3a18 100644
--- a/xorg-server/hw/xfree86/xaa/xaaSpans.c
+++ b/xorg-server/hw/xfree86/xaa/xaaSpans.c
@@ -1,882 +1,882 @@
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "xf86str.h"
-#include "mi.h"
-#include "mispans.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-
-static void XAARenderSolidSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderColor8x8Spans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderMono8x8Spans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderCacheBltSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderColorExpandSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderCacheExpandSpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-static void XAARenderPixmapCopySpans(
- GCPtr, int, DDXPointPtr, int*, int, int, int);
-
-void
-XAAFillSpans(
- DrawablePtr pDraw,
- GC *pGC,
- int nInit, /* number of spans to fill */
- DDXPointPtr pptInit, /* pointer to list of start points */
- int *pwidthInit, /* pointer to list of n widths */
- int fSorted
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int type = 0;
- ClipAndRenderSpansFunc function;
- Bool fastClip = FALSE;
-
- if((nInit <= 0) || !pGC->planemask)
- return;
-
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
- return;
-
- switch(pGC->fillStyle) {
- case FillSolid:
- type = DO_SOLID;
- break;
- case FillStippled:
- type = (*infoRec->StippledFillChooser)(pGC);
- break;
- case FillOpaqueStippled:
- if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid &&
- CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) &&
- CHECK_FG(pGC,infoRec->FillSpansSolidFlags))
- type = DO_SOLID;
- else
- type = (*infoRec->OpaqueStippledFillChooser)(pGC);
- break;
- case FillTiled:
- type = (*infoRec->TiledFillChooser)(pGC);
- break;
- }
-
- switch(type) {
- case DO_SOLID:
- function = XAARenderSolidSpans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL)
- fastClip = TRUE;
- break;
- case DO_COLOR_8x8:
- function = XAARenderColor8x8Spans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL)
- fastClip = TRUE;
- break;
- case DO_MONO_8x8:
- function = XAARenderMono8x8Spans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL)
- fastClip = TRUE;
- break;
- case DO_CACHE_BLT:
- function = XAARenderCacheBltSpans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
- fastClip = TRUE;
- break;
- case DO_COLOR_EXPAND:
- function = XAARenderColorExpandSpans;
- break;
- case DO_CACHE_EXPAND:
- function = XAARenderCacheExpandSpans;
- if(infoRec->ClippingFlags &
- HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND)
- fastClip = TRUE;
- break;
- case DO_PIXMAP_COPY:
- function = XAARenderPixmapCopySpans;
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
- fastClip = TRUE;
- break;
- case DO_IMAGE_WRITE:
- default:
- (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit,
- pwidthInit, fSorted);
- return;
- }
-
-
- if((nInit < 10) || (REGION_NUM_RECTS(pGC->pCompositeClip) != 1))
- fastClip = FALSE;
-
- if(fastClip) {
- infoRec->ClipBox = &pGC->pCompositeClip->extents;
- (*function)(pGC, nInit, pptInit, pwidthInit, fSorted,
- pDraw->x, pDraw->y);
- infoRec->ClipBox = NULL;
- } else
- XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted,
- function, pDraw->x, pDraw->y);
-}
-
-
- /*********************\
- | Solid Spans |
- \*********************/
-
-
-static void
-XAARenderSolidSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
-
- (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted);
-}
-
-
- /************************\
- | Mono 8x8 Spans |
- \************************/
-
-
-static void
-XAARenderMono8x8Spans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAPixmapPtr pPriv;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
- fg = pPriv->fg; bg = pPriv->bg;
- break;
- default: /* Muffle compiler */
- pPriv = NULL; /* Kaboom */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn,
- fg, bg, pGC->alu, pGC->planemask,
- n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-}
-
-
- /*************************\
- | Color 8x8 Spans |
- \*************************/
-
-
-static void
-XAARenderColor8x8Spans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
- PixmapPtr pPix;
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- pPix = pGC->stipple;
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- case FillTiled:
- pPix = pGC->tile.pixmap;
- fg = -1; bg = -1;
- break;
- default: /* Muffle compiler */
- pPix = NULL;
- fg = -1; bg = -1;
- break;
- }
-
- pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
-
- (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
- (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y));
-}
-
-
- /****************************\
- | Color Expand Spans |
- \****************************/
-
-
-static void
-XAARenderColorExpandSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-
-}
-
-
- /*************************\
- | Cache Blt Spans |
- \*************************/
-
-
-static void
-XAARenderCacheBltSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, -1);
- break;
- case FillOpaqueStippled:
- pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
- pGC->fgPixel, pGC->bgPixel);
- break;
- case FillTiled:
- pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
- break;
- default: /* Muffle compiler */
- pCache = NULL;
- break;
- }
-
- (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-
-}
-
-
- /****************************\
- | Cache Expand Spans |
- \****************************/
-
-
-static void
-XAARenderCacheExpandSpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int fg, bg;
-
- switch(pGC->fillStyle) {
- case FillStippled:
- fg = pGC->fgPixel; bg = -1;
- break;
- case FillOpaqueStippled:
- fg = pGC->fgPixel; bg = pGC->bgPixel;
- break;
- default: /* Muffle compiler */
- fg = -1; bg = -1;
- break;
- }
-
- (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
- pGC->stipple);
-}
-
-
- /***************************\
- | Pixmap Copy Spans |
- \***************************/
-
-
-static void
-XAARenderPixmapCopySpans(
- GCPtr pGC,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
- XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
-
- pCache->x = pPriv->offscreenArea->box.x1;
- pCache->y = pPriv->offscreenArea->box.y1;
- pCache->w = pCache->orig_w =
- pPriv->offscreenArea->box.x2 - pCache->x;
- pCache->h = pCache->orig_h =
- pPriv->offscreenArea->box.y2 - pCache->y;
- pCache->trans_color = -1;
-
- (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
- pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
- (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
-}
-
-
-
-
-
- /****************\
- | Solid |
- \****************/
-
-
-void
-XAAFillSolidSpans(
- ScrnInfoPtr pScrn,
- int fg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
-
- (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- if (*pwidth > 0)
- (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y,
- *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
- /***************\
- | Mono 8x8 |
- \***************/
-
-
-void
-XAAFillMono8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
-
- if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- }
- } else {
- XAACacheInfoPtr pCache =
- (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- patx += pCache->offsets[slot].x;
- paty += pCache->offsets[slot].y;
- xorg = patx; yorg = paty;
- }
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAFillMono8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- int pattern0, int pattern1,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pattern0, paty = pattern1;
- int xorg, yorg, slot;
- XAACacheInfoPtr pCache = NULL;
-
-
- if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
- pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
- patx = pCache->x; paty = pCache->y;
- }
-
- (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
- fg, bg, rop, planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- xorg = (ppt->x - xorigin) & 0x07;
- yorg = (ppt->y - yorigin) & 0x07;
-
- if(!(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- if(infoRec->Mono8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_BITS) {
- patx = pattern0; paty = pattern1;
- XAARotateMonoPattern(&patx, &paty, xorg, yorg,
- (infoRec->Mono8x8PatternFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST));
- xorg = patx; yorg = paty;
- } else {
- slot = (yorg << 3) + xorg;
- xorg = patx + pCache->offsets[slot].x;
- yorg = paty + pCache->offsets[slot].y;
- }
- }
-
- (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
- /****************\
- | Color 8x8 |
- \****************/
-
-
-void
-XAAFillColor8x8PatternSpansScreenOrigin(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr pCache,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int patx = pCache->x, paty = pCache->y;
- int xorg = (-xorigin) & 0x07;
- int yorg = (-yorigin) & 0x07;
-
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- int slot = (yorg << 3) + xorg;
- paty += pCache->offsets[slot].y;
- patx += pCache->offsets[slot].x;
- xorg = patx; yorg = paty;
- }
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
- rop, planemask, pCache->trans_color);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-void
-XAAFillColor8x8PatternSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth, int fSorted,
- XAACacheInfoPtr pCache,
- int xorigin, int yorigin
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int xorg, yorg, slot;
-
- (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
- rop, planemask, pCache->trans_color);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- xorg = (ppt->x - xorigin) & 0x07;
- yorg = (ppt->y - yorigin) & 0x07;
-
- if(!(infoRec->Color8x8PatternFillFlags &
- HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
- slot = (yorg << 3) + xorg;
- yorg = pCache->y + pCache->offsets[slot].y;
- xorg = pCache->x + pCache->offsets[slot].x;
- }
-
- (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
- xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
- /*****************\
- | Cache Blit |
- \*****************/
-
-
-void
-XAAFillCacheBltSpans(
- ScrnInfoPtr pScrn,
- int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- XAACacheInfoPtr pCache,
- int xorg, int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, w, phaseX, phaseY, blit_w;
-
- (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
- pCache->trans_color);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- x = ppt->x;
- w = *pwidth;
- phaseX = (x - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- phaseY = (ppt->y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
-
- while(1) {
- blit_w = pCache->w - phaseX;
- if(blit_w > w) blit_w = w;
-
- (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
- pCache->x + phaseX, pCache->y + phaseY,
- x, ppt->y, blit_w, 1);
-
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- phaseX = (phaseX + blit_w) % pCache->orig_w;
- }
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
- /****************\
- | Cache Expand |
- \****************/
-
-
-void
-XAAFillCacheExpandSpans(
- ScrnInfoPtr pScrn,
- int fg, int bg, int rop,
- unsigned int planemask,
- int n,
- DDXPointPtr ppt,
- int *pwidth,
- int fSorted,
- int xorg, int yorg,
- PixmapPtr pPix
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int x, w, phaseX, phaseY, blit_w, cacheWidth;
- XAACacheInfoPtr pCache;
-
- pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
-
- cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
- infoRec->CacheColorExpandDensity;
-
- (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
- planemask);
-
- if(infoRec->ClipBox)
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
-
- while(n--) {
- x = ppt->x;
- w = *pwidth;
- phaseX = (x - xorg) % pCache->orig_w;
- if(phaseX < 0) phaseX += pCache->orig_w;
- phaseY = (ppt->y - yorg) % pCache->orig_h;
- if(phaseY < 0) phaseY += pCache->orig_h;
-
- while(1) {
- blit_w = cacheWidth - phaseX;
- if(blit_w > w) blit_w = w;
-
- (*infoRec->SubsequentScreenToScreenColorExpandFill)(
- pScrn, x, ppt->y, blit_w, 1,
- pCache->x, pCache->y + phaseY, phaseX);
-
- w -= blit_w;
- if(!w) break;
- x += blit_w;
- phaseX = (phaseX + blit_w) % pCache->orig_w;
- }
- ppt++; pwidth++;
- }
-
- if(infoRec->ClipBox)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
-
-
-
-void
-XAAClipAndRenderSpans(
- GCPtr pGC,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- int fSorted,
- ClipAndRenderSpansFunc func,
- int xorg,
- int yorg
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- DDXPointPtr pptNew, pptBase;
- int *pwidthBase, *pwidthNew;
- int Right, numRects, MaxBoxes;
-
- MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int));
- pptBase = (DDXPointRec*)infoRec->PreAllocMem;
- pwidthBase = (int*)(&pptBase[MaxBoxes]);
-
- pptNew = pptBase;
- pwidthNew = pwidthBase;
-
- numRects = REGION_NUM_RECTS(pGC->pCompositeClip);
-
- if(numRects == 1) {
- BoxPtr pextent = REGION_RECTS(pGC->pCompositeClip);
-
- while(nspans--) {
- if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) {
- pptNew->x = max(pextent->x1, ppt->x);
- Right = ppt->x + *pwidth;
- *pwidthNew = min(pextent->x2, Right) - pptNew->x;
-
- if (*pwidthNew > 0) {
- pptNew->y = ppt->y;
- pptNew++;
- pwidthNew++;
-
- if(pptNew >= (pptBase + MaxBoxes)) {
- (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted,
- xorg, yorg);
- pptNew = pptBase;
- pwidthNew = pwidthBase;
- }
- }
- }
- ppt++;
- pwidth++;
- }
- } else if (numRects) {
- BoxPtr pbox;
- int nbox;
-
- while(nspans--) {
- nbox = numRects;
- pbox = REGION_RECTS(pGC->pCompositeClip);
-
- /* find the first band */
- while(nbox && (pbox->y2 <= ppt->y)) {
- pbox++;
- nbox--;
- }
-
- if(nbox && (pbox->y1 <= ppt->y)) {
- int orig_y = pbox->y1;
- Right = ppt->x + *pwidth;
- while(nbox && (orig_y == pbox->y1)) {
- if(pbox->x2 <= ppt->x) {
- nbox--;
- pbox++;
- continue;
- }
-
- if(pbox->x1 >= Right) {
- nbox = 0;
- break;
- }
-
- pptNew->x = max(pbox->x1, ppt->x);
- *pwidthNew = min(pbox->x2, Right) - pptNew->x;
- if(*pwidthNew > 0) {
- pptNew->y = ppt->y;
- pptNew++;
- pwidthNew++;
-
- if(pptNew >= (pptBase + MaxBoxes)) {
- (*func)(pGC, MaxBoxes, pptBase, pwidthBase,
- fSorted, xorg, yorg);
- pptNew = pptBase;
- pwidthNew = pwidthBase;
- }
- }
- pbox++;
- nbox--;
- }
- }
- ppt++;
- pwidth++;
- }
- }
-
- if(pptNew != pptBase)
- (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted,
- xorg, yorg);
-}
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "xf86str.h"
+#include "mi.h"
+#include "mispans.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+
+static void XAARenderSolidSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderColor8x8Spans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderMono8x8Spans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderCacheBltSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderColorExpandSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderCacheExpandSpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+static void XAARenderPixmapCopySpans(
+ GCPtr, int, DDXPointPtr, int*, int, int, int);
+
+void
+XAAFillSpans(
+ DrawablePtr pDraw,
+ GC *pGC,
+ int nInit, /* number of spans to fill */
+ DDXPointPtr pptInit, /* pointer to list of start points */
+ int *pwidthInit, /* pointer to list of n widths */
+ int fSorted
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int type = 0;
+ ClipAndRenderSpansFunc function;
+ Bool fastClip = FALSE;
+
+ if((nInit <= 0) || !pGC->planemask)
+ return;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ switch(pGC->fillStyle) {
+ case FillSolid:
+ type = DO_SOLID;
+ break;
+ case FillStippled:
+ type = (*infoRec->StippledFillChooser)(pGC);
+ break;
+ case FillOpaqueStippled:
+ if((pGC->fgPixel == pGC->bgPixel) && infoRec->FillSpansSolid &&
+ CHECK_PLANEMASK(pGC,infoRec->FillSpansSolidFlags) &&
+ CHECK_ROP(pGC,infoRec->FillSpansSolidFlags) &&
+ CHECK_ROPSRC(pGC,infoRec->FillSpansSolidFlags) &&
+ CHECK_FG(pGC,infoRec->FillSpansSolidFlags))
+ type = DO_SOLID;
+ else
+ type = (*infoRec->OpaqueStippledFillChooser)(pGC);
+ break;
+ case FillTiled:
+ type = (*infoRec->TiledFillChooser)(pGC);
+ break;
+ }
+
+ switch(type) {
+ case DO_SOLID:
+ function = XAARenderSolidSpans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_COLOR_8x8:
+ function = XAARenderColor8x8Spans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_COLOR_8x8_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_MONO_8x8:
+ function = XAARenderMono8x8Spans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_MONO_8x8_FILL)
+ fastClip = TRUE;
+ break;
+ case DO_CACHE_BLT:
+ function = XAARenderCacheBltSpans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
+ fastClip = TRUE;
+ break;
+ case DO_COLOR_EXPAND:
+ function = XAARenderColorExpandSpans;
+ break;
+ case DO_CACHE_EXPAND:
+ function = XAARenderCacheExpandSpans;
+ if(infoRec->ClippingFlags &
+ HARDWARE_CLIP_SCREEN_TO_SCREEN_COLOR_EXPAND)
+ fastClip = TRUE;
+ break;
+ case DO_PIXMAP_COPY:
+ function = XAARenderPixmapCopySpans;
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY)
+ fastClip = TRUE;
+ break;
+ case DO_IMAGE_WRITE:
+ default:
+ (*XAAFallbackOps.FillSpans)(pDraw, pGC, nInit, pptInit,
+ pwidthInit, fSorted);
+ return;
+ }
+
+
+ if((nInit < 10) || (RegionNumRects(pGC->pCompositeClip) != 1))
+ fastClip = FALSE;
+
+ if(fastClip) {
+ infoRec->ClipBox = &pGC->pCompositeClip->extents;
+ (*function)(pGC, nInit, pptInit, pwidthInit, fSorted,
+ pDraw->x, pDraw->y);
+ infoRec->ClipBox = NULL;
+ } else
+ XAAClipAndRenderSpans(pGC, pptInit, pwidthInit, nInit, fSorted,
+ function, pDraw->x, pDraw->y);
+}
+
+
+ /*********************\
+ | Solid Spans |
+ \*********************/
+
+
+static void
+XAARenderSolidSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+
+ (*infoRec->FillSolidSpans) (infoRec->pScrn, pGC->fgPixel,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted);
+}
+
+
+ /************************\
+ | Mono 8x8 Spans |
+ \************************/
+
+
+static void
+XAARenderMono8x8Spans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAAPixmapPtr pPriv;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->stipple);
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+ fg = pPriv->fg; bg = pPriv->bg;
+ break;
+ default: /* Muffle compiler */
+ pPriv = NULL; /* Kaboom */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillMono8x8PatternSpans) (infoRec->pScrn,
+ fg, bg, pGC->alu, pGC->planemask,
+ n, ppt, pwidth, fSorted, pPriv->pattern0, pPriv->pattern1,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+}
+
+
+ /*************************\
+ | Color 8x8 Spans |
+ \*************************/
+
+
+static void
+XAARenderColor8x8Spans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+ PixmapPtr pPix;
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ pPix = pGC->stipple;
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ case FillTiled:
+ pPix = pGC->tile.pixmap;
+ fg = -1; bg = -1;
+ break;
+ default: /* Muffle compiler */
+ pPix = NULL;
+ fg = -1; bg = -1;
+ break;
+ }
+
+ pCache = (*infoRec->CacheColor8x8Pattern)(infoRec->pScrn, pPix, fg, bg);
+
+ (*infoRec->FillColor8x8PatternSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
+ (yorg + pGC->patOrg.x), (xorg + pGC->patOrg.y));
+}
+
+
+ /****************************\
+ | Color Expand Spans |
+ \****************************/
+
+
+static void
+XAARenderColorExpandSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillColorExpandSpans) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+
+}
+
+
+ /*************************\
+ | Cache Blt Spans |
+ \*************************/
+
+
+static void
+XAARenderCacheBltSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, -1);
+ break;
+ case FillOpaqueStippled:
+ pCache = (*infoRec->CacheStipple)(infoRec->pScrn, pGC->stipple,
+ pGC->fgPixel, pGC->bgPixel);
+ break;
+ case FillTiled:
+ pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
+ break;
+ default: /* Muffle compiler */
+ pCache = NULL;
+ break;
+ }
+
+ (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+
+}
+
+
+ /****************************\
+ | Cache Expand Spans |
+ \****************************/
+
+
+static void
+XAARenderCacheExpandSpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int fg, bg;
+
+ switch(pGC->fillStyle) {
+ case FillStippled:
+ fg = pGC->fgPixel; bg = -1;
+ break;
+ case FillOpaqueStippled:
+ fg = pGC->fgPixel; bg = pGC->bgPixel;
+ break;
+ default: /* Muffle compiler */
+ fg = -1; bg = -1;
+ break;
+ }
+
+ (*infoRec->FillCacheExpandSpans) (infoRec->pScrn, fg, bg,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y),
+ pGC->stipple);
+}
+
+
+ /***************************\
+ | Pixmap Copy Spans |
+ \***************************/
+
+
+static void
+XAARenderPixmapCopySpans(
+ GCPtr pGC,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ XAACacheInfoPtr pCache = &(infoRec->ScratchCacheInfoRec);
+ XAAPixmapPtr pPriv = XAA_GET_PIXMAP_PRIVATE(pGC->tile.pixmap);
+
+ pCache->x = pPriv->offscreenArea->box.x1;
+ pCache->y = pPriv->offscreenArea->box.y1;
+ pCache->w = pCache->orig_w =
+ pPriv->offscreenArea->box.x2 - pCache->x;
+ pCache->h = pCache->orig_h =
+ pPriv->offscreenArea->box.y2 - pCache->y;
+ pCache->trans_color = -1;
+
+ (*infoRec->FillCacheBltSpans) (infoRec->pScrn,
+ pGC->alu, pGC->planemask, n, ppt, pwidth, fSorted, pCache,
+ (xorg + pGC->patOrg.x), (yorg + pGC->patOrg.y));
+}
+
+
+
+
+
+ /****************\
+ | Solid |
+ \****************/
+
+
+void
+XAAFillSolidSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+
+ (*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ if (*pwidth > 0)
+ (*infoRec->SubsequentSolidFillRect)(pScrn, ppt->x, ppt->y,
+ *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /***************\
+ | Mono 8x8 |
+ \***************/
+
+
+void
+XAAFillMono8x8PatternSpansScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+
+ if(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ }
+ } else {
+ XAACacheInfoPtr pCache =
+ (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ patx += pCache->offsets[slot].x;
+ paty += pCache->offsets[slot].y;
+ xorg = patx; yorg = paty;
+ }
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+void
+XAAFillMono8x8PatternSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ int pattern0, int pattern1,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pattern0, paty = pattern1;
+ int xorg, yorg, slot;
+ XAACacheInfoPtr pCache = NULL;
+
+
+ if(!(infoRec->Mono8x8PatternFillFlags & HARDWARE_PATTERN_PROGRAMMED_BITS)){
+ pCache = (*infoRec->CacheMono8x8Pattern)(pScrn, pattern0, pattern1);
+ patx = pCache->x; paty = pCache->y;
+ }
+
+ (*infoRec->SetupForMono8x8PatternFill)(pScrn, patx, paty,
+ fg, bg, rop, planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ xorg = (ppt->x - xorigin) & 0x07;
+ yorg = (ppt->y - yorigin) & 0x07;
+
+ if(!(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ if(infoRec->Mono8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_BITS) {
+ patx = pattern0; paty = pattern1;
+ XAARotateMonoPattern(&patx, &paty, xorg, yorg,
+ (infoRec->Mono8x8PatternFillFlags &
+ BIT_ORDER_IN_BYTE_MSBFIRST));
+ xorg = patx; yorg = paty;
+ } else {
+ slot = (yorg << 3) + xorg;
+ xorg = patx + pCache->offsets[slot].x;
+ yorg = paty + pCache->offsets[slot].y;
+ }
+ }
+
+ (*infoRec->SubsequentMono8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+ /****************\
+ | Color 8x8 |
+ \****************/
+
+
+void
+XAAFillColor8x8PatternSpansScreenOrigin(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int patx = pCache->x, paty = pCache->y;
+ int xorg = (-xorigin) & 0x07;
+ int yorg = (-yorigin) & 0x07;
+
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ int slot = (yorg << 3) + xorg;
+ paty += pCache->offsets[slot].y;
+ patx += pCache->offsets[slot].x;
+ xorg = patx; yorg = paty;
+ }
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, patx, paty,
+ rop, planemask, pCache->trans_color);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+void
+XAAFillColor8x8PatternSpans(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth, int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorigin, int yorigin
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int xorg, yorg, slot;
+
+ (*infoRec->SetupForColor8x8PatternFill)(pScrn, pCache->x, pCache->y,
+ rop, planemask, pCache->trans_color);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ xorg = (ppt->x - xorigin) & 0x07;
+ yorg = (ppt->y - yorigin) & 0x07;
+
+ if(!(infoRec->Color8x8PatternFillFlags &
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN)){
+ slot = (yorg << 3) + xorg;
+ yorg = pCache->y + pCache->offsets[slot].y;
+ xorg = pCache->x + pCache->offsets[slot].x;
+ }
+
+ (*infoRec->SubsequentColor8x8PatternFillRect)(pScrn,
+ xorg, yorg, ppt->x, ppt->y, *pwidth, 1);
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+ /*****************\
+ | Cache Blit |
+ \*****************/
+
+
+void
+XAAFillCacheBltSpans(
+ ScrnInfoPtr pScrn,
+ int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ XAACacheInfoPtr pCache,
+ int xorg, int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, w, phaseX, phaseY, blit_w;
+
+ (*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
+ pCache->trans_color);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ x = ppt->x;
+ w = *pwidth;
+ phaseX = (x - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ phaseY = (ppt->y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+
+ while(1) {
+ blit_w = pCache->w - phaseX;
+ if(blit_w > w) blit_w = w;
+
+ (*infoRec->SubsequentScreenToScreenCopy)(pScrn,
+ pCache->x + phaseX, pCache->y + phaseY,
+ x, ppt->y, blit_w, 1);
+
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pCache->orig_w;
+ }
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+ /****************\
+ | Cache Expand |
+ \****************/
+
+
+void
+XAAFillCacheExpandSpans(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask,
+ int n,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int fSorted,
+ int xorg, int yorg,
+ PixmapPtr pPix
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ int x, w, phaseX, phaseY, blit_w, cacheWidth;
+ XAACacheInfoPtr pCache;
+
+ pCache = (*infoRec->CacheMonoStipple)(pScrn, pPix);
+
+ cacheWidth = (pCache->w * pScrn->bitsPerPixel) /
+ infoRec->CacheColorExpandDensity;
+
+ (*infoRec->SetupForScreenToScreenColorExpandFill)(pScrn, fg, bg, rop,
+ planemask);
+
+ if(infoRec->ClipBox)
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+
+ while(n--) {
+ x = ppt->x;
+ w = *pwidth;
+ phaseX = (x - xorg) % pCache->orig_w;
+ if(phaseX < 0) phaseX += pCache->orig_w;
+ phaseY = (ppt->y - yorg) % pCache->orig_h;
+ if(phaseY < 0) phaseY += pCache->orig_h;
+
+ while(1) {
+ blit_w = cacheWidth - phaseX;
+ if(blit_w > w) blit_w = w;
+
+ (*infoRec->SubsequentScreenToScreenColorExpandFill)(
+ pScrn, x, ppt->y, blit_w, 1,
+ pCache->x, pCache->y + phaseY, phaseX);
+
+ w -= blit_w;
+ if(!w) break;
+ x += blit_w;
+ phaseX = (phaseX + blit_w) % pCache->orig_w;
+ }
+ ppt++; pwidth++;
+ }
+
+ if(infoRec->ClipBox)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
+
+
+
+void
+XAAClipAndRenderSpans(
+ GCPtr pGC,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted,
+ ClipAndRenderSpansFunc func,
+ int xorg,
+ int yorg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ DDXPointPtr pptNew, pptBase;
+ int *pwidthBase, *pwidthNew;
+ int Right, numRects, MaxBoxes;
+
+ MaxBoxes = infoRec->PreAllocSize/(sizeof(DDXPointRec) + sizeof(int));
+ pptBase = (DDXPointRec*)infoRec->PreAllocMem;
+ pwidthBase = (int*)(&pptBase[MaxBoxes]);
+
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+
+ numRects = RegionNumRects(pGC->pCompositeClip);
+
+ if(numRects == 1) {
+ BoxPtr pextent = RegionRects(pGC->pCompositeClip);
+
+ while(nspans--) {
+ if ((pextent->y1 <= ppt->y) && (ppt->y < pextent->y2)) {
+ pptNew->x = max(pextent->x1, ppt->x);
+ Right = ppt->x + *pwidth;
+ *pwidthNew = min(pextent->x2, Right) - pptNew->x;
+
+ if (*pwidthNew > 0) {
+ pptNew->y = ppt->y;
+ pptNew++;
+ pwidthNew++;
+
+ if(pptNew >= (pptBase + MaxBoxes)) {
+ (*func)(pGC, MaxBoxes, pptBase, pwidthBase, fSorted,
+ xorg, yorg);
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+ }
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ } else if (numRects) {
+ BoxPtr pbox;
+ int nbox;
+
+ while(nspans--) {
+ nbox = numRects;
+ pbox = RegionRects(pGC->pCompositeClip);
+
+ /* find the first band */
+ while(nbox && (pbox->y2 <= ppt->y)) {
+ pbox++;
+ nbox--;
+ }
+
+ if(nbox && (pbox->y1 <= ppt->y)) {
+ int orig_y = pbox->y1;
+ Right = ppt->x + *pwidth;
+ while(nbox && (orig_y == pbox->y1)) {
+ if(pbox->x2 <= ppt->x) {
+ nbox--;
+ pbox++;
+ continue;
+ }
+
+ if(pbox->x1 >= Right) {
+ nbox = 0;
+ break;
+ }
+
+ pptNew->x = max(pbox->x1, ppt->x);
+ *pwidthNew = min(pbox->x2, Right) - pptNew->x;
+ if(*pwidthNew > 0) {
+ pptNew->y = ppt->y;
+ pptNew++;
+ pwidthNew++;
+
+ if(pptNew >= (pptBase + MaxBoxes)) {
+ (*func)(pGC, MaxBoxes, pptBase, pwidthBase,
+ fSorted, xorg, yorg);
+ pptNew = pptBase;
+ pwidthNew = pwidthBase;
+ }
+ }
+ pbox++;
+ nbox--;
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ }
+
+ if(pptNew != pptBase)
+ (*func)(pGC, pptNew - pptBase, pptBase, pwidthBase, fSorted,
+ xorg, yorg);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaStateChange.c b/xorg-server/hw/xfree86/xaa/xaaStateChange.c
index 9c98a32f2..4eb15125b 100644
--- a/xorg-server/hw/xfree86/xaa/xaaStateChange.c
+++ b/xorg-server/hw/xfree86/xaa/xaaStateChange.c
@@ -272,8 +272,8 @@ typedef struct _XAAStateWrapRec {
int width, int height, int flags);
} XAAStateWrapRec, *XAAStateWrapPtr;
-static int XAAStateKeyIndex;
-static DevPrivateKey XAAStateKey = &XAAStateKeyIndex;
+static DevPrivateKeyRec XAAStateKeyRec;
+#define XAAStateKey (&XAAStateKeyRec)
/* Wrap functions start here */
#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
@@ -1500,6 +1500,7 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
XAAStateWrapPtr pStatePriv;
int i = 0;
+ if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0)) return FALSE;
if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE;
dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;
diff --git a/xorg-server/hw/xfree86/xaa/xaaTEText.c b/xorg-server/hw/xfree86/xaa/xaaTEText.c
index 1e28d3103..2cc5fc1e6 100644
--- a/xorg-server/hw/xfree86/xaa/xaaTEText.c
+++ b/xorg-server/hw/xfree86/xaa/xaaTEText.c
@@ -110,7 +110,7 @@ XAAImageText8TEColorExpansion(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(pGC->font, (unsigned long)count,
@@ -134,7 +134,7 @@ XAAImageText16TEColorExpansion(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
unsigned long n;
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
(*pGC->font->get_glyphs)(
@@ -169,7 +169,7 @@ XAAImageGlyphBltTEColorExpansion(
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
XAAGlyphBltTEColorExpansion(
@@ -189,7 +189,7 @@ XAAPolyGlyphBltTEColorExpansion(
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
+ if(!RegionNumRects(pGC->pCompositeClip))
return;
XAAGlyphBltTEColorExpansion(
@@ -229,8 +229,8 @@ XAAGlyphBltTEColorExpansion(
int skippix, skipglyphs;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge, ytop, ybot;
- int nbox = REGION_NUM_RECTS(cclip);
- BoxPtr pbox = REGION_RECTS(cclip);
+ int nbox = RegionNumRects(cclip);
+ BoxPtr pbox = RegionRects(cclip);
unsigned int **glyphs = NULL;
int glyphWidth = FONTMAXBOUNDS(font, characterWidth);
@@ -299,8 +299,7 @@ XAAGlyphBltTEColorExpansion(
skippix, ytop - Top, glyphs + skipglyphs, glyphWidth,
fg, bg, rop, planemask);
- if (fallbackBits)
- free(fallbackBits);
+ free(fallbackBits);
}
nbox--; pbox++;
diff --git a/xorg-server/hw/xfree86/xaa/xaaWideLine.c b/xorg-server/hw/xfree86/xaa/xaaWideLine.c
index a684d6676..f73e04f17 100644
--- a/xorg-server/hw/xfree86/xaa/xaaWideLine.c
+++ b/xorg-server/hw/xfree86/xaa/xaaWideLine.c
@@ -1,921 +1,921 @@
-/*
-
-XAAPolylinesWideSolid does not maintain a span list and subsequently does
-not follow the "touch-each-pixel-once" rules for wide lines and arcs.
-This means it can only be used in the case where we have
-miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we
-limited usage of this function to one rect situations. This
-function is used only for solid lines.
-
- Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu)
-Original mi code written by Keith Packard.
-
-*/
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <math.h>
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-
-#include <X11/X.h>
-#include "windowstr.h"
-#include "gcstruct.h"
-#include "regionstr.h"
-#include "miwideline.h"
-#include "mi.h"
-#include "xf86str.h"
-#include "xaa.h"
-#include "xaalocal.h"
-
-#define DRAW_POINT(pScrn, x, y) \
- if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \
- else XAAPointHelper(pScrn, x, y)
-
-#define FILL_RECT(pScrn, x, y, w, h) \
- if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \
- else XAAFillRectHelper(pScrn, x, y, w, h)
-
-#define FILL_SPAN(pScrn, x, y, w) \
- if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \
- else XAASpanHelper(pScrn, x, y, w)
-
-
-#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
- if (ybase == edgey) { \
- if (edgeleft) { \
- if (edge->x > xcl) \
- xcl = edge->x; \
- } else { \
- if (edge->x < xcr) \
- xcr = edge->x; \
- } \
- edgey++; \
- edge->x += edge->stepx; \
- edge->e += edge->dx; \
- if (edge->e > 0) { \
- edge->x += edge->signdx; \
- edge->e -= edge->dy; \
- } \
- }
-
-static void
-XAAPointHelper(ScrnInfoPtr pScrn, int x, int y)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- BoxPtr extents = infoRec->ClipBox;
-
- if((x >= extents->x1) && (x < extents->x2) &&
- (y >= extents->y1) && (y < extents->y2))
- (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1);
-}
-
-static void
-XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- BoxPtr extents = infoRec->ClipBox;
- int x2 = x1 + dx;
- int y2 = y1 + dy;
-
- if(x1 < extents->x1) x1 = extents->x1;
- if(x2 >= extents->x2) x2 = extents->x2;
- if((dx = x2 - x1)<1) return;
- if(y1 < extents->y1) y1 = extents->y1;
- if(y2 >= extents->y2) y2 = extents->y2;
- if((dy = y2 - y1)<1) return;
-
- (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy);
-}
-
-
-static void
-XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- BoxPtr extents = infoRec->ClipBox;
- int x2;
-
- if((y < extents->y1) || (y >= extents->y2)) return;
-
- x2 = x1 + width;
- if(x1 < extents->x1) x1 = extents->x1;
- if(x2 > extents->x2) x2 = extents->x2;
- width = x2 - x1;
-
- if(width > 0)
- (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1);
-
-}
-
-#define FixError(x, dx, dy, e, sign, step, h) { \
- e += (h) * dx; \
- x += (h) * step; \
- if(e > 0) { \
- x += e * sign/dy; \
- e %= dy; \
- if(e) { \
- x += sign; \
- e -= dy; \
- } \
- } \
-}
-
-
-static void
-XAAFillPolyHelper (
- GCPtr pGC,
- int y, /* start y coordinate */
- int overall_height, /* height of entire segment */
- PolyEdgePtr left, PolyEdgePtr right,
- int left_count, int right_count )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- BoxPtr extents = infoRec->ClipBox;
- int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx;
- int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx;
- int height, left_height, right_height;
- int xorg;
- Bool hardClip;
-
- if((y >= extents->y2) || ((y + overall_height) <= extents->y1))
- return;
-
- /* Muffle compiler */
- left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0;
- right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0;
-
- left_height = right_height = 0;
- xorg = 0;
-
- hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
- while ((left_count || left_height) && (right_count || right_height)) {
- if (!left_height && left_count) {
- left_height = left->height;
- left_x = left->x + xorg;
- left_stepx = left->stepx;
- left_signdx = left->signdx;
- left_e = left->e;
- left_dy = left->dy;
- left_dx = left->dx;
- left_count--;
- left++;
- }
- if (!right_height && right_count) {
- right_height = right->height;
- right_x = right->x + xorg + 1;
- right_stepx = right->stepx;
- right_signdx = right->signdx;
- right_e = right->e;
- right_dy = right->dy;
- right_dx = right->dx;
- right_count--;
- right++;
- }
-
- height = (left_height > right_height) ? right_height : left_height;
-
- left_height -= height;
- right_height -= height;
-
- if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) {
- int right_DX, left_DX;
-
- right_DX = (right_dx * right_signdx) + (right_stepx * right_dy);
- left_DX = (left_dx * left_signdx) + (left_stepx * left_dy);
-
- (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height,
- left_x, left_DX, left_dy, left_e,
- right_x - 1, right_DX, right_dy, right_e);
-
- FixError(left_x, left_dx, left_dy, left_e, left_signdx,
- left_stepx, height);
- FixError(right_x, right_dx, right_dy, right_e, right_signdx,
- right_stepx, height);
- y += height;
- continue;
- }
-
- while (height--) {
- if(right_x > left_x) {
- FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x);
- }
- y++;
-
- left_x += left_stepx;
- left_e += left_dx;
- if (left_e > 0) {
- left_x += left_signdx;
- left_e -= left_dy;
- }
- right_x += right_stepx;
- right_e += right_dx;
- if (right_e > 0) {
- right_x += right_signdx;
- right_e -= right_dy;
- }
-
- }
- }
-}
-
-
-
-static void
-XAAWideSegment (
- GCPtr pGC,
- int x1, int y1, int x2, int y2,
- Bool projectLeft, Bool projectRight,
- LineFacePtr leftFace, LineFacePtr rightFace )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- double l, L, r;
- double xa, ya;
- double projectXoff, projectYoff;
- double k;
- double maxy;
- int x, y;
- int dx, dy;
- int finaly;
- PolyEdgePtr left, right;
- PolyEdgePtr top, bottom;
- int lefty, righty, topy, bottomy;
- int signdx;
- PolyEdgeRec lefts[2], rights[2];
- LineFacePtr tface;
- int lw = pGC->lineWidth;
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
- /* draw top-to-bottom always */
- if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) {
- x = x1;
- x1 = x2;
- x2 = x;
-
- y = y1;
- y1 = y2;
- y2 = y;
-
- x = projectLeft;
- projectLeft = projectRight;
- projectRight = x;
-
- tface = leftFace;
- leftFace = rightFace;
- rightFace = tface;
- }
-
- dy = y2 - y1;
- signdx = 1;
- dx = x2 - x1;
- if (dx < 0)
- signdx = -1;
-
- leftFace->x = x1;
- leftFace->y = y1;
- leftFace->dx = dx;
- leftFace->dy = dy;
-
- rightFace->x = x2;
- rightFace->y = y2;
- rightFace->dx = -dx;
- rightFace->dy = -dy;
-
- if (!dy) {
- rightFace->xa = 0;
- rightFace->ya = (double) lw / 2.0;
- rightFace->k = -(double) (lw * dx) / 2.0;
- leftFace->xa = 0;
- leftFace->ya = -rightFace->ya;
- leftFace->k = rightFace->k;
- x = x1;
- if (projectLeft)
- x -= (lw >> 1);
- y = y1 - (lw >> 1);
- dx = x2 - x;
- if (projectRight)
- dx += ((lw + 1) >> 1);
- dy = lw;
- FILL_RECT(infoRec->pScrn, x, y, dx, dy);
- } else if (!dx) {
- leftFace->xa = (double) lw / 2.0;
- leftFace->ya = 0;
- leftFace->k = (double) (lw * dy) / 2.0;
- rightFace->xa = -leftFace->xa;
- rightFace->ya = 0;
- rightFace->k = leftFace->k;
- y = y1;
- if (projectLeft)
- y -= lw >> 1;
- x = x1 - (lw >> 1);
- dy = y2 - y;
- if (projectRight)
- dy += ((lw + 1) >> 1);
- dx = lw;
- FILL_RECT(infoRec->pScrn, x, y, dx, dy);
- } else {
- l = ((double) lw) / 2.0;
- L = sqrt((double)(dx*dx + dy*dy));
-
- if (dx < 0) {
- right = &rights[1];
- left = &lefts[0];
- top = &rights[0];
- bottom = &lefts[1];
- } else {
- right = &rights[0];
- left = &lefts[1];
- top = &lefts[0];
- bottom = &rights[1];
- }
- r = l / L;
-
- /* coord of upper bound at integral y */
- ya = -r * dx;
- xa = r * dy;
-
- projectXoff = -ya;
- projectYoff = xa;
-
- /* xa * dy - ya * dx */
- k = l * L;
-
- leftFace->xa = xa;
- leftFace->ya = ya;
- leftFace->k = k;
- rightFace->xa = -xa;
- rightFace->ya = -ya;
- rightFace->k = k;
-
- if (projectLeft)
- righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
- k, dx, dy, x1, y1, 0, right);
- else
- righty = miPolyBuildEdge (xa, ya,
- k, dx, dy, x1, y1, 0, right);
-
- /* coord of lower bound at integral y */
- ya = -ya;
- xa = -xa;
-
- /* xa * dy - ya * dx */
- k = - k;
-
- if (projectLeft)
- lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
- k, dx, dy, x1, y1, 1, left);
- else
- lefty = miPolyBuildEdge (xa, ya,
- k, dx, dy, x1, y1, 1, left);
-
- /* coord of top face at integral y */
-
- if (signdx > 0) {
- ya = -ya;
- xa = -xa;
- }
-
- if (projectLeft) {
- double xap = xa - projectXoff;
- double yap = ya - projectYoff;
- topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
- -dy, dx, x1, y1, dx > 0, top);
- }
- else
- topy = miPolyBuildEdge(xa, ya, 0.0,
- -dy, dx, x1, y1, dx > 0, top);
-
- /* coord of bottom face at integral y */
-
- if (projectRight) {
- double xap = xa + projectXoff;
- double yap = ya + projectYoff;
- bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
- -dy, dx, x2, y2, dx < 0, bottom);
- maxy = -ya + projectYoff;
- } else {
- bottomy = miPolyBuildEdge (xa, ya, 0.0,
- -dy, dx, x2, y2, dx < 0, bottom);
- maxy = -ya;
- }
-
- finaly = ICEIL (maxy) + y2;
-
- if (dx < 0) {
- left->height = bottomy - lefty;
- right->height = finaly - righty;
- top->height = righty - topy;
- } else {
- right->height = bottomy - righty;
- left->height = finaly - lefty;
- top->height = lefty - topy;
- }
- bottom->height = finaly - bottomy;
- XAAFillPolyHelper (pGC, topy,
- bottom->height + bottomy - topy, lefts, rights, 2, 2);
- }
-}
-
-
-static void
-XAALineArcI (GCPtr pGC, int xorg, int yorg)
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int x, y, e, ex;
- int slw = pGC->lineWidth;
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
- y = (slw >> 1) + 1;
- if (slw & 1)
- e = - ((y << 2) + 3);
- else
- e = - (y << 3);
- ex = -4;
- x = 0;
- while (y) {
- e += (y << 3) - 4;
- while (e >= 0) {
- x++;
- e += (ex = -((x << 3) + 4));
- }
- y--;
- slw = (x << 1) + 1;
- if ((e == ex) && (slw > 1))
- slw--;
-
- FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw);
-
- if ((y != 0) && ((slw > 1) || (e != ex))) {
- FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw);
- }
- }
-}
-
-
-static void
-XAALineArcD (
- GCPtr pGC,
- double xorg,
- double yorg,
- PolyEdgePtr edge1,
- int edgey1,
- Bool edgeleft1,
- PolyEdgePtr edge2,
- int edgey2,
- Bool edgeleft2 )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- double radius, x0, y0, el, er, yk, xlk, xrk, k;
- int xbase, ybase, y, boty, xl, xr, xcl, xcr;
- int ymin, ymax;
- Bool edge1IsMin, edge2IsMin;
- int ymin1, ymin2;
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
-
-
- xbase = floor(xorg);
- x0 = xorg - xbase;
- ybase = ICEIL (yorg);
- y0 = yorg - ybase;
-
- xlk = x0 + x0 + 1.0;
- xrk = x0 + x0 - 1.0;
- yk = y0 + y0 - 1.0;
- radius = ((double)pGC->lineWidth) / 2.0;
- y = floor(radius - y0 + 1.0);
- ybase -= y;
- ymin = ybase;
- ymax = 65536;
- edge1IsMin = FALSE;
- ymin1 = edgey1;
- if (edge1->dy >= 0) {
- if (!edge1->dy) {
- if (edgeleft1)
- edge1IsMin = TRUE;
- else
- ymax = edgey1;
- edgey1 = 65536;
- } else if ((edge1->signdx < 0) == edgeleft1)
- edge1IsMin = TRUE;
- }
- edge2IsMin = FALSE;
- ymin2 = edgey2;
- if (edge2->dy >= 0) {
- if (!edge2->dy) {
- if (edgeleft2)
- edge2IsMin = TRUE;
- else
- ymax = edgey2;
- edgey2 = 65536;
- } else if ((edge2->signdx < 0) == edgeleft2)
- edge2IsMin = TRUE;
- }
- if (edge1IsMin) {
- ymin = ymin1;
- if (edge2IsMin && (ymin1 > ymin2))
- ymin = ymin2;
- } else if (edge2IsMin)
- ymin = ymin2;
- el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);
- er = el + xrk;
- xl = 1;
- xr = 0;
- if (x0 < 0.5) {
- xl = 0;
- el -= xlk;
- }
- boty = (y0 < -0.5) ? 1 : 0;
- if (ybase + y - boty > ymax)
- boty = ymax - ybase - y;
- while (y > boty) {
- k = (y << 1) + yk;
- er += k;
- while (er > 0.0) {
- xr++;
- er += xrk - (xr << 1);
- }
- el += k;
- while (el >= 0.0) {
- xl--;
- el += (xl << 1) - xlk;
- }
- y--;
- ybase++;
- if (ybase < ymin)
- continue;
- xcl = xl + xbase;
- xcr = xr + xbase;
- CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
- CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
- if(xcr >= xcl) {
- FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
- }
- }
- er = xrk - (xr << 1) - er;
- el = (xl << 1) - xlk - el;
- boty = floor(-y0 - radius + 1.0);
- if (ybase + y - boty > ymax)
- boty = ymax - ybase - y;
- while (y > boty) {
- k = (y << 1) + yk;
- er -= k;
- while ((er >= 0.0) && (xr >= 0)) {
- xr--;
- er += xrk - (xr << 1);
- }
- el -= k;
- while ((el > 0.0) && (xl <= 0)) {
- xl++;
- el += (xl << 1) - xlk;
- }
- y--;
- ybase++;
- if (ybase < ymin)
- continue;
- xcl = xl + xbase;
- xcr = xr + xbase;
- CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
- CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
- if(xcr >= xcl) {
- FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
- }
- }
-}
-
-
-static void
-XAALineArc (
- GCPtr pGC,
- LineFacePtr leftFace,
- LineFacePtr rightFace,
- double xorg,
- double yorg,
- Bool isInt )
-{
- int xorgi, yorgi;
- PolyEdgeRec edge1, edge2;
- int edgey1, edgey2;
- Bool edgeleft1, edgeleft2;
-
- if (isInt) {
- xorgi = leftFace ? leftFace->x : rightFace->x;
- yorgi = leftFace ? leftFace->y : rightFace->y;
- } else { /* Muffle compiler */
- xorgi = yorgi = 0;
- }
- edgey1 = 65536;
- edgey2 = 65536;
- edge1.x = 0; /* not used, keep memory checkers happy */
- edge1.dy = -1;
- edge2.x = 0; /* not used, keep memory checkers happy */
- edge2.dy = -1;
- edgeleft1 = FALSE;
- edgeleft2 = FALSE;
-
- if ((pGC->lineWidth > 2) &&
- ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) ||
- (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) {
- if (isInt) {
- xorg = (double) xorgi;
- yorg = (double) yorgi;
- }
-
- if (leftFace && rightFace)
- miRoundJoinClip (leftFace, rightFace, &edge1, &edge2,
- &edgey1, &edgey2, &edgeleft1, &edgeleft2);
- else if (leftFace)
- edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1);
- else if (rightFace)
- edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2);
-
- isInt = FALSE;
- }
-
- if (isInt) {
- if(pGC->lineWidth == 1) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
- DRAW_POINT(infoRec->pScrn, xorgi, yorgi);
- } else
- XAALineArcI(pGC, xorgi, yorgi);
- } else
- XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1,
- &edge2, edgey2, edgeleft2);
-
-}
-
-
-static void
-XAALineJoin (
- GCPtr pGC,
- LineFacePtr pLeft,
- LineFacePtr pRight )
-{
- double mx = 0, my = 0;
- double denom = 0;
- PolyVertexRec vertices[4];
- PolySlopeRec slopes[4];
- int edgecount;
- PolyEdgeRec left[4], right[4];
- int nleft, nright;
- int y, height;
- int swapslopes;
- int joinStyle = pGC->joinStyle;
- int lw = pGC->lineWidth;
-
- if (lw == 1) {
- /* Lines going in the same direction have no join */
- if ((pLeft->dx >= 0) == (pRight->dx <= 0))
- return;
- if (joinStyle != JoinRound) {
- denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
- (double)pLeft->dy;
- if (denom == 0.0)
- return; /* no join to draw */
- }
- if (joinStyle != JoinMiter) {
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
- DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y);
- return;
- }
- } else {
- if (joinStyle == JoinRound) {
- XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE);
- return;
- }
- denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
- (double)pLeft->dy;
- if (denom == 0.0)
- return; /* no join to draw */
- }
-
- swapslopes = 0;
- if (denom > 0) {
- pLeft->xa = -pLeft->xa;
- pLeft->ya = -pLeft->ya;
- pLeft->dx = -pLeft->dx;
- pLeft->dy = -pLeft->dy;
- } else {
- swapslopes = 1;
- pRight->xa = -pRight->xa;
- pRight->ya = -pRight->ya;
- pRight->dx = -pRight->dx;
- pRight->dy = -pRight->dy;
- }
-
- vertices[0].x = pRight->xa;
- vertices[0].y = pRight->ya;
- slopes[0].dx = -pRight->dy;
- slopes[0].dy = pRight->dx;
- slopes[0].k = 0;
-
- vertices[1].x = 0;
- vertices[1].y = 0;
- slopes[1].dx = pLeft->dy;
- slopes[1].dy = -pLeft->dx;
- slopes[1].k = 0;
-
- vertices[2].x = pLeft->xa;
- vertices[2].y = pLeft->ya;
-
- if (joinStyle == JoinMiter) {
- my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) -
- pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/
- denom;
- if (pLeft->dy != 0)
- mx = pLeft->xa + (my - pLeft->ya) *
- (double) pLeft->dx / (double) pLeft->dy;
- else
- mx = pRight->xa + (my - pRight->ya) *
- (double) pRight->dx / (double) pRight->dy;
-
- /* check miter limit */
- if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw)
- joinStyle = JoinBevel;
- }
-
- if (joinStyle == JoinMiter) {
- slopes[2].dx = pLeft->dx;
- slopes[2].dy = pLeft->dy;
- slopes[2].k = pLeft->k;
- if (swapslopes) {
- slopes[2].dx = -slopes[2].dx;
- slopes[2].dy = -slopes[2].dy;
- slopes[2].k = -slopes[2].k;
- }
- vertices[3].x = mx;
- vertices[3].y = my;
- slopes[3].dx = pRight->dx;
- slopes[3].dy = pRight->dy;
- slopes[3].k = pRight->k;
- if (swapslopes) {
- slopes[3].dx = -slopes[3].dx;
- slopes[3].dy = -slopes[3].dy;
- slopes[3].k = -slopes[3].k;
- }
- edgecount = 4;
- } else {
- double scale, dx, dy, adx, ady;
-
- adx = dx = pRight->xa - pLeft->xa;
- ady = dy = pRight->ya - pLeft->ya;
- if (adx < 0)
- adx = -adx;
- if (ady < 0)
- ady = -ady;
- scale = ady;
- if (adx > ady)
- scale = adx;
- slopes[2].dx = (dx * 65536) / scale;
- slopes[2].dy = (dy * 65536) / scale;
- slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
- (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
- edgecount = 3;
- }
-
- y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y,
- left, right, &nleft, &nright, &height);
- XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright);
-}
-
-
-void
-XAAPolylinesWideSolid (
- DrawablePtr pDrawable,
- GCPtr pGC,
- int mode,
- int npt,
- DDXPointPtr pPts )
-{
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- int x1, y1, x2, y2;
- Bool projectLeft, projectRight;
- LineFaceRec leftFace, rightFace, prevRightFace, firstFace;
- int first = TRUE;
- Bool somethingDrawn = FALSE;
- Bool selfJoin = FALSE;
- int xorg = pDrawable->x;
- int yorg = pDrawable->y;
- Bool hardClip = FALSE;
-
- if(!REGION_NUM_RECTS(pGC->pCompositeClip))
- return;
-
- if(REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
- miWideLine(pDrawable, pGC, mode, npt, pPts);
- return;
- }
-
- x2 = pPts->x;
- y2 = pPts->y;
- if (npt > 1) {
- if (mode == CoordModePrevious) {
- int nptTmp;
- register DDXPointPtr pPtsTmp;
-
- x1 = x2;
- y1 = y2;
- nptTmp = npt;
- pPtsTmp = pPts + 1;
- while (--nptTmp) {
- x1 += pPtsTmp->x;
- y1 += pPtsTmp->y;
- ++pPtsTmp;
- }
- if ((x2 == x1) && (y2 == y1))
- selfJoin = TRUE;
- } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y))
- selfJoin = TRUE;
- }
-
- projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin);
- projectRight = FALSE;
-
- (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
- pGC->planemask);
-
- infoRec->ClipBox = &pGC->pCompositeClip->extents;
-
- if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) {
- hardClip = TRUE;
- (*infoRec->SetClippingRectangle)(infoRec->pScrn,
- infoRec->ClipBox->x1, infoRec->ClipBox->y1,
- infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
- }
-
- x2 += xorg;
- y2 += yorg;
- while (--npt) {
- x1 = x2;
- y1 = y2;
- ++pPts;
- x2 = pPts->x;
- y2 = pPts->y;
- if (mode == CoordModePrevious) {
- x2 += x1;
- y2 += y1;
- } else {
- x2 += xorg;
- y2 += yorg;
- }
- if ((x1 != x2) || (y1 != y2)) {
- somethingDrawn = TRUE;
- if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin)
- projectRight = TRUE;
- XAAWideSegment(pGC, x1, y1, x2, y2,
- projectLeft, projectRight, &leftFace, &rightFace);
- if (first) {
- if (selfJoin)
- firstFace = leftFace;
- else if (pGC->capStyle == CapRound) {
- if (pGC->lineWidth == 1) {
- DRAW_POINT(infoRec->pScrn, x1, y1);
- } else
- XAALineArc(pGC,&leftFace, (LineFacePtr) NULL,
- (double)0.0, (double)0.0,TRUE);
- }
- } else
- XAALineJoin (pGC, &leftFace, &prevRightFace);
-
- prevRightFace = rightFace;
- first = FALSE;
- projectLeft = FALSE;
- }
- if (npt == 1 && somethingDrawn) {
- if (selfJoin)
- XAALineJoin (pGC, &firstFace, &rightFace);
- else if (pGC->capStyle == CapRound) {
- if (pGC->lineWidth == 1) {
- DRAW_POINT(infoRec->pScrn, x2, y2);
- } else
- XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
- (double)0.0, (double)0.0,TRUE);
- }
- }
- }
- /* handle crock where all points are coincedent */
- if (!somethingDrawn) {
- projectLeft = (pGC->capStyle == CapProjecting);
- XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft,
- &leftFace, &rightFace);
- if (pGC->capStyle == CapRound) {
- XAALineArc (pGC, &leftFace, (LineFacePtr) NULL,
- (double)0.0, (double)0.0, TRUE);
- rightFace.dx = -1; /* sleezy hack to make it work */
- XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
- (double)0.0, (double)0.0, TRUE);
- }
- }
-
- infoRec->ClipBox = NULL;
- if(hardClip)
- (*infoRec->DisableClipping)(infoRec->pScrn);
-
- SET_SYNC_FLAG(infoRec);
-}
+/*
+
+XAAPolylinesWideSolid does not maintain a span list and subsequently does
+not follow the "touch-each-pixel-once" rules for wide lines and arcs.
+This means it can only be used in the case where we have
+miSpansEasyRop(pGC->alu). Since we clip spans on the fly, we
+limited usage of this function to one rect situations. This
+function is used only for solid lines.
+
+ Adapted from miWideLine by Mark Vojkovich (mvojkovi@ucsd.edu)
+Original mi code written by Keith Packard.
+
+*/
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <math.h>
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+
+#include <X11/X.h>
+#include "windowstr.h"
+#include "gcstruct.h"
+#include "regionstr.h"
+#include "miwideline.h"
+#include "mi.h"
+#include "xf86str.h"
+#include "xaa.h"
+#include "xaalocal.h"
+
+#define DRAW_POINT(pScrn, x, y) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1); \
+ else XAAPointHelper(pScrn, x, y)
+
+#define FILL_RECT(pScrn, x, y, w, h) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); \
+ else XAAFillRectHelper(pScrn, x, y, w, h)
+
+#define FILL_SPAN(pScrn, x, y, w) \
+ if(hardClip) (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, 1); \
+ else XAASpanHelper(pScrn, x, y, w)
+
+
+#define CLIPSTEPEDGE(edgey,edge,edgeleft) \
+ if (ybase == edgey) { \
+ if (edgeleft) { \
+ if (edge->x > xcl) \
+ xcl = edge->x; \
+ } else { \
+ if (edge->x < xcr) \
+ xcr = edge->x; \
+ } \
+ edgey++; \
+ edge->x += edge->stepx; \
+ edge->e += edge->dx; \
+ if (edge->e > 0) { \
+ edge->x += edge->signdx; \
+ edge->e -= edge->dy; \
+ } \
+ }
+
+static void
+XAAPointHelper(ScrnInfoPtr pScrn, int x, int y)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+
+ if((x >= extents->x1) && (x < extents->x2) &&
+ (y >= extents->y1) && (y < extents->y2))
+ (*infoRec->SubsequentSolidFillRect)(pScrn, x, y, 1, 1);
+}
+
+static void
+XAAFillRectHelper(ScrnInfoPtr pScrn, int x1, int y1, int dx, int dy)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+ int x2 = x1 + dx;
+ int y2 = y1 + dy;
+
+ if(x1 < extents->x1) x1 = extents->x1;
+ if(x2 >= extents->x2) x2 = extents->x2;
+ if((dx = x2 - x1)<1) return;
+ if(y1 < extents->y1) y1 = extents->y1;
+ if(y2 >= extents->y2) y2 = extents->y2;
+ if((dy = y2 - y1)<1) return;
+
+ (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y1, dx, dy);
+}
+
+
+static void
+XAASpanHelper(ScrnInfoPtr pScrn, int x1, int y, int width)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ BoxPtr extents = infoRec->ClipBox;
+ int x2;
+
+ if((y < extents->y1) || (y >= extents->y2)) return;
+
+ x2 = x1 + width;
+ if(x1 < extents->x1) x1 = extents->x1;
+ if(x2 > extents->x2) x2 = extents->x2;
+ width = x2 - x1;
+
+ if(width > 0)
+ (*infoRec->SubsequentSolidFillRect)(pScrn, x1, y, width, 1);
+
+}
+
+#define FixError(x, dx, dy, e, sign, step, h) { \
+ e += (h) * dx; \
+ x += (h) * step; \
+ if(e > 0) { \
+ x += e * sign/dy; \
+ e %= dy; \
+ if(e) { \
+ x += sign; \
+ e -= dy; \
+ } \
+ } \
+}
+
+
+static void
+XAAFillPolyHelper (
+ GCPtr pGC,
+ int y, /* start y coordinate */
+ int overall_height, /* height of entire segment */
+ PolyEdgePtr left, PolyEdgePtr right,
+ int left_count, int right_count )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ BoxPtr extents = infoRec->ClipBox;
+ int left_x, left_e, left_stepx, left_signdx, left_dy, left_dx;
+ int right_x, right_e, right_stepx, right_signdx, right_dy, right_dx;
+ int height, left_height, right_height;
+ int xorg;
+ Bool hardClip;
+
+ if((y >= extents->y2) || ((y + overall_height) <= extents->y1))
+ return;
+
+ /* Muffle compiler */
+ left_x = left_e = left_stepx = left_signdx = left_dy = left_dx = 0;
+ right_x = right_e = right_stepx = right_signdx = right_dy = right_dx = 0;
+
+ left_height = right_height = 0;
+ xorg = 0;
+
+ hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ while ((left_count || left_height) && (right_count || right_height)) {
+ if (!left_height && left_count) {
+ left_height = left->height;
+ left_x = left->x + xorg;
+ left_stepx = left->stepx;
+ left_signdx = left->signdx;
+ left_e = left->e;
+ left_dy = left->dy;
+ left_dx = left->dx;
+ left_count--;
+ left++;
+ }
+ if (!right_height && right_count) {
+ right_height = right->height;
+ right_x = right->x + xorg + 1;
+ right_stepx = right->stepx;
+ right_signdx = right->signdx;
+ right_e = right->e;
+ right_dy = right->dy;
+ right_dx = right->dx;
+ right_count--;
+ right++;
+ }
+
+ height = (left_height > right_height) ? right_height : left_height;
+
+ left_height -= height;
+ right_height -= height;
+
+ if(hardClip && infoRec->SubsequentSolidFillTrap && (height > 6)) {
+ int right_DX, left_DX;
+
+ right_DX = (right_dx * right_signdx) + (right_stepx * right_dy);
+ left_DX = (left_dx * left_signdx) + (left_stepx * left_dy);
+
+ (*infoRec->SubsequentSolidFillTrap)(infoRec->pScrn, y, height,
+ left_x, left_DX, left_dy, left_e,
+ right_x - 1, right_DX, right_dy, right_e);
+
+ FixError(left_x, left_dx, left_dy, left_e, left_signdx,
+ left_stepx, height);
+ FixError(right_x, right_dx, right_dy, right_e, right_signdx,
+ right_stepx, height);
+ y += height;
+ continue;
+ }
+
+ while (height--) {
+ if(right_x > left_x) {
+ FILL_SPAN(infoRec->pScrn, left_x, y, right_x - left_x);
+ }
+ y++;
+
+ left_x += left_stepx;
+ left_e += left_dx;
+ if (left_e > 0) {
+ left_x += left_signdx;
+ left_e -= left_dy;
+ }
+ right_x += right_stepx;
+ right_e += right_dx;
+ if (right_e > 0) {
+ right_x += right_signdx;
+ right_e -= right_dy;
+ }
+
+ }
+ }
+}
+
+
+
+static void
+XAAWideSegment (
+ GCPtr pGC,
+ int x1, int y1, int x2, int y2,
+ Bool projectLeft, Bool projectRight,
+ LineFacePtr leftFace, LineFacePtr rightFace )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ double l, L, r;
+ double xa, ya;
+ double projectXoff, projectYoff;
+ double k;
+ double maxy;
+ int x, y;
+ int dx, dy;
+ int finaly;
+ PolyEdgePtr left, right;
+ PolyEdgePtr top, bottom;
+ int lefty, righty, topy, bottomy;
+ int signdx;
+ PolyEdgeRec lefts[2], rights[2];
+ LineFacePtr tface;
+ int lw = pGC->lineWidth;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ /* draw top-to-bottom always */
+ if ((y2 < y1) || ((y2 == y1) && (x2 < x1))) {
+ x = x1;
+ x1 = x2;
+ x2 = x;
+
+ y = y1;
+ y1 = y2;
+ y2 = y;
+
+ x = projectLeft;
+ projectLeft = projectRight;
+ projectRight = x;
+
+ tface = leftFace;
+ leftFace = rightFace;
+ rightFace = tface;
+ }
+
+ dy = y2 - y1;
+ signdx = 1;
+ dx = x2 - x1;
+ if (dx < 0)
+ signdx = -1;
+
+ leftFace->x = x1;
+ leftFace->y = y1;
+ leftFace->dx = dx;
+ leftFace->dy = dy;
+
+ rightFace->x = x2;
+ rightFace->y = y2;
+ rightFace->dx = -dx;
+ rightFace->dy = -dy;
+
+ if (!dy) {
+ rightFace->xa = 0;
+ rightFace->ya = (double) lw / 2.0;
+ rightFace->k = -(double) (lw * dx) / 2.0;
+ leftFace->xa = 0;
+ leftFace->ya = -rightFace->ya;
+ leftFace->k = rightFace->k;
+ x = x1;
+ if (projectLeft)
+ x -= (lw >> 1);
+ y = y1 - (lw >> 1);
+ dx = x2 - x;
+ if (projectRight)
+ dx += ((lw + 1) >> 1);
+ dy = lw;
+ FILL_RECT(infoRec->pScrn, x, y, dx, dy);
+ } else if (!dx) {
+ leftFace->xa = (double) lw / 2.0;
+ leftFace->ya = 0;
+ leftFace->k = (double) (lw * dy) / 2.0;
+ rightFace->xa = -leftFace->xa;
+ rightFace->ya = 0;
+ rightFace->k = leftFace->k;
+ y = y1;
+ if (projectLeft)
+ y -= lw >> 1;
+ x = x1 - (lw >> 1);
+ dy = y2 - y;
+ if (projectRight)
+ dy += ((lw + 1) >> 1);
+ dx = lw;
+ FILL_RECT(infoRec->pScrn, x, y, dx, dy);
+ } else {
+ l = ((double) lw) / 2.0;
+ L = sqrt((double)(dx*dx + dy*dy));
+
+ if (dx < 0) {
+ right = &rights[1];
+ left = &lefts[0];
+ top = &rights[0];
+ bottom = &lefts[1];
+ } else {
+ right = &rights[0];
+ left = &lefts[1];
+ top = &lefts[0];
+ bottom = &rights[1];
+ }
+ r = l / L;
+
+ /* coord of upper bound at integral y */
+ ya = -r * dx;
+ xa = r * dy;
+
+ projectXoff = -ya;
+ projectYoff = xa;
+
+ /* xa * dy - ya * dx */
+ k = l * L;
+
+ leftFace->xa = xa;
+ leftFace->ya = ya;
+ leftFace->k = k;
+ rightFace->xa = -xa;
+ rightFace->ya = -ya;
+ rightFace->k = k;
+
+ if (projectLeft)
+ righty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 0, right);
+ else
+ righty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, x1, y1, 0, right);
+
+ /* coord of lower bound at integral y */
+ ya = -ya;
+ xa = -xa;
+
+ /* xa * dy - ya * dx */
+ k = - k;
+
+ if (projectLeft)
+ lefty = miPolyBuildEdge (xa - projectXoff, ya - projectYoff,
+ k, dx, dy, x1, y1, 1, left);
+ else
+ lefty = miPolyBuildEdge (xa, ya,
+ k, dx, dy, x1, y1, 1, left);
+
+ /* coord of top face at integral y */
+
+ if (signdx > 0) {
+ ya = -ya;
+ xa = -xa;
+ }
+
+ if (projectLeft) {
+ double xap = xa - projectXoff;
+ double yap = ya - projectYoff;
+ topy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, x1, y1, dx > 0, top);
+ }
+ else
+ topy = miPolyBuildEdge(xa, ya, 0.0,
+ -dy, dx, x1, y1, dx > 0, top);
+
+ /* coord of bottom face at integral y */
+
+ if (projectRight) {
+ double xap = xa + projectXoff;
+ double yap = ya + projectYoff;
+ bottomy = miPolyBuildEdge (xap, yap, xap * dx + yap * dy,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya + projectYoff;
+ } else {
+ bottomy = miPolyBuildEdge (xa, ya, 0.0,
+ -dy, dx, x2, y2, dx < 0, bottom);
+ maxy = -ya;
+ }
+
+ finaly = ICEIL (maxy) + y2;
+
+ if (dx < 0) {
+ left->height = bottomy - lefty;
+ right->height = finaly - righty;
+ top->height = righty - topy;
+ } else {
+ right->height = bottomy - righty;
+ left->height = finaly - lefty;
+ top->height = lefty - topy;
+ }
+ bottom->height = finaly - bottomy;
+ XAAFillPolyHelper (pGC, topy,
+ bottom->height + bottomy - topy, lefts, rights, 2, 2);
+ }
+}
+
+
+static void
+XAALineArcI (GCPtr pGC, int xorg, int yorg)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int x, y, e, ex;
+ int slw = pGC->lineWidth;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+ y = (slw >> 1) + 1;
+ if (slw & 1)
+ e = - ((y << 2) + 3);
+ else
+ e = - (y << 3);
+ ex = -4;
+ x = 0;
+ while (y) {
+ e += (y << 3) - 4;
+ while (e >= 0) {
+ x++;
+ e += (ex = -((x << 3) + 4));
+ }
+ y--;
+ slw = (x << 1) + 1;
+ if ((e == ex) && (slw > 1))
+ slw--;
+
+ FILL_SPAN(infoRec->pScrn, xorg - x, yorg - y, slw);
+
+ if ((y != 0) && ((slw > 1) || (e != ex))) {
+ FILL_SPAN(infoRec->pScrn, xorg - x, yorg + y, slw);
+ }
+ }
+}
+
+
+static void
+XAALineArcD (
+ GCPtr pGC,
+ double xorg,
+ double yorg,
+ PolyEdgePtr edge1,
+ int edgey1,
+ Bool edgeleft1,
+ PolyEdgePtr edge2,
+ int edgey2,
+ Bool edgeleft2 )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ double radius, x0, y0, el, er, yk, xlk, xrk, k;
+ int xbase, ybase, y, boty, xl, xr, xcl, xcr;
+ int ymin, ymax;
+ Bool edge1IsMin, edge2IsMin;
+ int ymin1, ymin2;
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+
+
+ xbase = floor(xorg);
+ x0 = xorg - xbase;
+ ybase = ICEIL (yorg);
+ y0 = yorg - ybase;
+
+ xlk = x0 + x0 + 1.0;
+ xrk = x0 + x0 - 1.0;
+ yk = y0 + y0 - 1.0;
+ radius = ((double)pGC->lineWidth) / 2.0;
+ y = floor(radius - y0 + 1.0);
+ ybase -= y;
+ ymin = ybase;
+ ymax = 65536;
+ edge1IsMin = FALSE;
+ ymin1 = edgey1;
+ if (edge1->dy >= 0) {
+ if (!edge1->dy) {
+ if (edgeleft1)
+ edge1IsMin = TRUE;
+ else
+ ymax = edgey1;
+ edgey1 = 65536;
+ } else if ((edge1->signdx < 0) == edgeleft1)
+ edge1IsMin = TRUE;
+ }
+ edge2IsMin = FALSE;
+ ymin2 = edgey2;
+ if (edge2->dy >= 0) {
+ if (!edge2->dy) {
+ if (edgeleft2)
+ edge2IsMin = TRUE;
+ else
+ ymax = edgey2;
+ edgey2 = 65536;
+ } else if ((edge2->signdx < 0) == edgeleft2)
+ edge2IsMin = TRUE;
+ }
+ if (edge1IsMin) {
+ ymin = ymin1;
+ if (edge2IsMin && (ymin1 > ymin2))
+ ymin = ymin2;
+ } else if (edge2IsMin)
+ ymin = ymin2;
+ el = radius * radius - ((y + y0) * (y + y0)) - (x0 * x0);
+ er = el + xrk;
+ xl = 1;
+ xr = 0;
+ if (x0 < 0.5) {
+ xl = 0;
+ el -= xlk;
+ }
+ boty = (y0 < -0.5) ? 1 : 0;
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty) {
+ k = (y << 1) + yk;
+ er += k;
+ while (er > 0.0) {
+ xr++;
+ er += xrk - (xr << 1);
+ }
+ el += k;
+ while (el >= 0.0) {
+ xl--;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if(xcr >= xcl) {
+ FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
+ }
+ }
+ er = xrk - (xr << 1) - er;
+ el = (xl << 1) - xlk - el;
+ boty = floor(-y0 - radius + 1.0);
+ if (ybase + y - boty > ymax)
+ boty = ymax - ybase - y;
+ while (y > boty) {
+ k = (y << 1) + yk;
+ er -= k;
+ while ((er >= 0.0) && (xr >= 0)) {
+ xr--;
+ er += xrk - (xr << 1);
+ }
+ el -= k;
+ while ((el > 0.0) && (xl <= 0)) {
+ xl++;
+ el += (xl << 1) - xlk;
+ }
+ y--;
+ ybase++;
+ if (ybase < ymin)
+ continue;
+ xcl = xl + xbase;
+ xcr = xr + xbase;
+ CLIPSTEPEDGE(edgey1, edge1, edgeleft1);
+ CLIPSTEPEDGE(edgey2, edge2, edgeleft2);
+ if(xcr >= xcl) {
+ FILL_SPAN(infoRec->pScrn, xcl, ybase, xcr - xcl + 1);
+ }
+ }
+}
+
+
+static void
+XAALineArc (
+ GCPtr pGC,
+ LineFacePtr leftFace,
+ LineFacePtr rightFace,
+ double xorg,
+ double yorg,
+ Bool isInt )
+{
+ int xorgi, yorgi;
+ PolyEdgeRec edge1, edge2;
+ int edgey1, edgey2;
+ Bool edgeleft1, edgeleft2;
+
+ if (isInt) {
+ xorgi = leftFace ? leftFace->x : rightFace->x;
+ yorgi = leftFace ? leftFace->y : rightFace->y;
+ } else { /* Muffle compiler */
+ xorgi = yorgi = 0;
+ }
+ edgey1 = 65536;
+ edgey2 = 65536;
+ edge1.x = 0; /* not used, keep memory checkers happy */
+ edge1.dy = -1;
+ edge2.x = 0; /* not used, keep memory checkers happy */
+ edge2.dy = -1;
+ edgeleft1 = FALSE;
+ edgeleft2 = FALSE;
+
+ if ((pGC->lineWidth > 2) &&
+ ((pGC->capStyle == CapRound && pGC->joinStyle != JoinRound) ||
+ (pGC->joinStyle == JoinRound && pGC->capStyle == CapButt))) {
+ if (isInt) {
+ xorg = (double) xorgi;
+ yorg = (double) yorgi;
+ }
+
+ if (leftFace && rightFace)
+ miRoundJoinClip (leftFace, rightFace, &edge1, &edge2,
+ &edgey1, &edgey2, &edgeleft1, &edgeleft2);
+ else if (leftFace)
+ edgey1 = miRoundCapClip (leftFace, isInt, &edge1, &edgeleft1);
+ else if (rightFace)
+ edgey2 = miRoundCapClip (rightFace, isInt, &edge2, &edgeleft2);
+
+ isInt = FALSE;
+ }
+
+ if (isInt) {
+ if(pGC->lineWidth == 1) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+ DRAW_POINT(infoRec->pScrn, xorgi, yorgi);
+ } else
+ XAALineArcI(pGC, xorgi, yorgi);
+ } else
+ XAALineArcD(pGC, xorg, yorg, &edge1, edgey1, edgeleft1,
+ &edge2, edgey2, edgeleft2);
+
+}
+
+
+static void
+XAALineJoin (
+ GCPtr pGC,
+ LineFacePtr pLeft,
+ LineFacePtr pRight )
+{
+ double mx = 0, my = 0;
+ double denom = 0;
+ PolyVertexRec vertices[4];
+ PolySlopeRec slopes[4];
+ int edgecount;
+ PolyEdgeRec left[4], right[4];
+ int nleft, nright;
+ int y, height;
+ int swapslopes;
+ int joinStyle = pGC->joinStyle;
+ int lw = pGC->lineWidth;
+
+ if (lw == 1) {
+ /* Lines going in the same direction have no join */
+ if ((pLeft->dx >= 0) == (pRight->dx <= 0))
+ return;
+ if (joinStyle != JoinRound) {
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
+ (double)pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+ if (joinStyle != JoinMiter) {
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ Bool hardClip = (infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL);
+ DRAW_POINT(infoRec->pScrn, pLeft->x, pLeft->y);
+ return;
+ }
+ } else {
+ if (joinStyle == JoinRound) {
+ XAALineArc(pGC, pLeft, pRight,(double)0.0, (double)0.0, TRUE);
+ return;
+ }
+ denom = - pLeft->dx * (double)pRight->dy + pRight->dx *
+ (double)pLeft->dy;
+ if (denom == 0.0)
+ return; /* no join to draw */
+ }
+
+ swapslopes = 0;
+ if (denom > 0) {
+ pLeft->xa = -pLeft->xa;
+ pLeft->ya = -pLeft->ya;
+ pLeft->dx = -pLeft->dx;
+ pLeft->dy = -pLeft->dy;
+ } else {
+ swapslopes = 1;
+ pRight->xa = -pRight->xa;
+ pRight->ya = -pRight->ya;
+ pRight->dx = -pRight->dx;
+ pRight->dy = -pRight->dy;
+ }
+
+ vertices[0].x = pRight->xa;
+ vertices[0].y = pRight->ya;
+ slopes[0].dx = -pRight->dy;
+ slopes[0].dy = pRight->dx;
+ slopes[0].k = 0;
+
+ vertices[1].x = 0;
+ vertices[1].y = 0;
+ slopes[1].dx = pLeft->dy;
+ slopes[1].dy = -pLeft->dx;
+ slopes[1].k = 0;
+
+ vertices[2].x = pLeft->xa;
+ vertices[2].y = pLeft->ya;
+
+ if (joinStyle == JoinMiter) {
+ my = (pLeft->dy * (pRight->xa * pRight->dy - pRight->ya * pRight->dx) -
+ pRight->dy * (pLeft->xa * pLeft->dy - pLeft->ya * pLeft->dx ))/
+ denom;
+ if (pLeft->dy != 0)
+ mx = pLeft->xa + (my - pLeft->ya) *
+ (double) pLeft->dx / (double) pLeft->dy;
+ else
+ mx = pRight->xa + (my - pRight->ya) *
+ (double) pRight->dx / (double) pRight->dy;
+
+ /* check miter limit */
+ if ((mx * mx + my * my) * 4 > SQSECANT * lw * lw)
+ joinStyle = JoinBevel;
+ }
+
+ if (joinStyle == JoinMiter) {
+ slopes[2].dx = pLeft->dx;
+ slopes[2].dy = pLeft->dy;
+ slopes[2].k = pLeft->k;
+ if (swapslopes) {
+ slopes[2].dx = -slopes[2].dx;
+ slopes[2].dy = -slopes[2].dy;
+ slopes[2].k = -slopes[2].k;
+ }
+ vertices[3].x = mx;
+ vertices[3].y = my;
+ slopes[3].dx = pRight->dx;
+ slopes[3].dy = pRight->dy;
+ slopes[3].k = pRight->k;
+ if (swapslopes) {
+ slopes[3].dx = -slopes[3].dx;
+ slopes[3].dy = -slopes[3].dy;
+ slopes[3].k = -slopes[3].k;
+ }
+ edgecount = 4;
+ } else {
+ double scale, dx, dy, adx, ady;
+
+ adx = dx = pRight->xa - pLeft->xa;
+ ady = dy = pRight->ya - pLeft->ya;
+ if (adx < 0)
+ adx = -adx;
+ if (ady < 0)
+ ady = -ady;
+ scale = ady;
+ if (adx > ady)
+ scale = adx;
+ slopes[2].dx = (dx * 65536) / scale;
+ slopes[2].dy = (dy * 65536) / scale;
+ slopes[2].k = ((pLeft->xa + pRight->xa) * slopes[2].dy -
+ (pLeft->ya + pRight->ya) * slopes[2].dx) / 2.0;
+ edgecount = 3;
+ }
+
+ y = miPolyBuildPoly (vertices, slopes, edgecount, pLeft->x, pLeft->y,
+ left, right, &nleft, &nright, &height);
+ XAAFillPolyHelper(pGC, y, height, left, right, nleft, nright);
+}
+
+
+void
+XAAPolylinesWideSolid (
+ DrawablePtr pDrawable,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pPts )
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ int x1, y1, x2, y2;
+ Bool projectLeft, projectRight;
+ LineFaceRec leftFace, rightFace, prevRightFace, firstFace;
+ int first = TRUE;
+ Bool somethingDrawn = FALSE;
+ Bool selfJoin = FALSE;
+ int xorg = pDrawable->x;
+ int yorg = pDrawable->y;
+ Bool hardClip = FALSE;
+
+ if(!RegionNumRects(pGC->pCompositeClip))
+ return;
+
+ if(RegionNumRects(pGC->pCompositeClip) != 1) {
+ miWideLine(pDrawable, pGC, mode, npt, pPts);
+ return;
+ }
+
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (npt > 1) {
+ if (mode == CoordModePrevious) {
+ int nptTmp;
+ register DDXPointPtr pPtsTmp;
+
+ x1 = x2;
+ y1 = y2;
+ nptTmp = npt;
+ pPtsTmp = pPts + 1;
+ while (--nptTmp) {
+ x1 += pPtsTmp->x;
+ y1 += pPtsTmp->y;
+ ++pPtsTmp;
+ }
+ if ((x2 == x1) && (y2 == y1))
+ selfJoin = TRUE;
+ } else if ((x2 == pPts[npt-1].x) && (y2 == pPts[npt-1].y))
+ selfJoin = TRUE;
+ }
+
+ projectLeft = ((pGC->capStyle == CapProjecting) && !selfJoin);
+ projectRight = FALSE;
+
+ (*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel, pGC->alu,
+ pGC->planemask);
+
+ infoRec->ClipBox = &pGC->pCompositeClip->extents;
+
+ if(infoRec->ClippingFlags & HARDWARE_CLIP_SOLID_FILL) {
+ hardClip = TRUE;
+ (*infoRec->SetClippingRectangle)(infoRec->pScrn,
+ infoRec->ClipBox->x1, infoRec->ClipBox->y1,
+ infoRec->ClipBox->x2 - 1, infoRec->ClipBox->y2 - 1);
+ }
+
+ x2 += xorg;
+ y2 += yorg;
+ while (--npt) {
+ x1 = x2;
+ y1 = y2;
+ ++pPts;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (mode == CoordModePrevious) {
+ x2 += x1;
+ y2 += y1;
+ } else {
+ x2 += xorg;
+ y2 += yorg;
+ }
+ if ((x1 != x2) || (y1 != y2)) {
+ somethingDrawn = TRUE;
+ if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin)
+ projectRight = TRUE;
+ XAAWideSegment(pGC, x1, y1, x2, y2,
+ projectLeft, projectRight, &leftFace, &rightFace);
+ if (first) {
+ if (selfJoin)
+ firstFace = leftFace;
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ DRAW_POINT(infoRec->pScrn, x1, y1);
+ } else
+ XAALineArc(pGC,&leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0,TRUE);
+ }
+ } else
+ XAALineJoin (pGC, &leftFace, &prevRightFace);
+
+ prevRightFace = rightFace;
+ first = FALSE;
+ projectLeft = FALSE;
+ }
+ if (npt == 1 && somethingDrawn) {
+ if (selfJoin)
+ XAALineJoin (pGC, &firstFace, &rightFace);
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ DRAW_POINT(infoRec->pScrn, x2, y2);
+ } else
+ XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0,TRUE);
+ }
+ }
+ }
+ /* handle crock where all points are coincedent */
+ if (!somethingDrawn) {
+ projectLeft = (pGC->capStyle == CapProjecting);
+ XAAWideSegment (pGC, x2, y2, x2, y2, projectLeft, projectLeft,
+ &leftFace, &rightFace);
+ if (pGC->capStyle == CapRound) {
+ XAALineArc (pGC, &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0, TRUE);
+ rightFace.dx = -1; /* sleezy hack to make it work */
+ XAALineArc (pGC, (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0, TRUE);
+ }
+ }
+
+ infoRec->ClipBox = NULL;
+ if(hardClip)
+ (*infoRec->DisableClipping)(infoRec->pScrn);
+
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xorg-server/hw/xfree86/xaa/xaaWrapper.c b/xorg-server/hw/xfree86/xaa/xaaWrapper.c
index f709d0b35..09644c9ac 100644
--- a/xorg-server/hw/xfree86/xaa/xaaWrapper.c
+++ b/xorg-server/hw/xfree86/xaa/xaaWrapper.c
@@ -125,10 +125,10 @@ typedef struct _xaaWrapperGCPriv {
#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
-static int xaaWrapperScrPrivateKeyIndex;
-static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKeyIndex;
-static int xaaWrapperGCPrivateKeyIndex;
-static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKeyIndex;
+static DevPrivateKeyRec xaaWrapperScrPrivateKeyRec;
+#define xaaWrapperScrPrivateKey (&xaaWrapperScrPrivateKeyRec)
+static DevPrivateKeyRec xaaWrapperGCPrivateKeyRec;
+#define xaaWrapperGCPrivateKey (&xaaWrapperGCPrivateKeyRec)
static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen)
@@ -268,7 +268,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
xaaWrapperScrPrivPtr pScrPriv;
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
- if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec)))
+ if (!dixRegisterPrivateKey(&xaaWrapperGCPrivateKeyRec, PRIVATE_GC, sizeof(xaaWrapperGCPrivRec)))
+ return FALSE;
+
+ if (!dixRegisterPrivateKey(&xaaWrapperScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) malloc(sizeof (xaaWrapperScrPrivRec));
diff --git a/xorg-server/hw/xfree86/xaa/xaawrap.h b/xorg-server/hw/xfree86/xaa/xaawrap.h
index 86ba003d6..1b7595e95 100644
--- a/xorg-server/hw/xfree86/xaa/xaawrap.h
+++ b/xorg-server/hw/xfree86/xaa/xaawrap.h
@@ -1,79 +1,79 @@
-
-#define XAA_SCREEN_PROLOGUE(pScreen, field)\
- ((pScreen)->field = \
- ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
-
-#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\
- ((pScreen)->field = wrapper)
-
-
-#define XAA_GC_FUNC_PROLOGUE(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
- (pGC)->funcs = pGCPriv->wrapFuncs;\
- if(pGCPriv->flags)\
- (pGC)->ops = pGCPriv->wrapOps
-
-#define XAA_GC_FUNC_EPILOGUE(pGC)\
- pGCPriv->wrapFuncs = (pGC)->funcs;\
- (pGC)->funcs = &XAAGCFuncs;\
- if(pGCPriv->flags) {\
- pGCPriv->wrapOps = (pGC)->ops;\
- (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\
- &XAAPixmapOps;\
- }
-
-
-#define XAA_GC_OP_PROLOGUE(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
- GCFuncs *oldFuncs = pGC->funcs;\
- pGC->funcs = pGCPriv->wrapFuncs;\
- pGC->ops = pGCPriv->wrapOps
-
-#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
- GCFuncs *oldFuncs = pGC->funcs;\
- if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \
- pGC->funcs = pGCPriv->wrapFuncs;\
- pGC->ops = pGCPriv->wrapOps
-
-
-#define XAA_GC_OP_EPILOGUE(pGC)\
- pGCPriv->wrapOps = pGC->ops;\
- pGC->funcs = oldFuncs;\
- pGC->ops = pGCPriv->XAAOps
-
-
-#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\
- XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
- XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\
- GCFuncs *oldFuncs = pGC->funcs;\
- pGC->funcs = pGCPriv->wrapFuncs;\
- pGC->ops = pGCPriv->wrapOps; \
- SYNC_CHECK(pGC)
-
-#define XAA_PIXMAP_OP_EPILOGUE(pGC)\
- pGCPriv->wrapOps = pGC->ops;\
- pGC->funcs = oldFuncs;\
- pGC->ops = &XAAPixmapOps;\
- pixPriv->flags |= DIRTY
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#define XAA_RENDER_PROLOGUE(pScreen,field)\
- (GetPictureScreen(pScreen)->field = \
- ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
-
-#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\
- (GetPictureScreen(pScreen)->field = wrapper)
-
-/* This also works fine for drawables */
-
-#define SYNC_CHECK(pGC) {\
- XAAInfoRecPtr infoRec =\
-((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \
- if(infoRec->NeedToSync) {\
- (*infoRec->Sync)(infoRec->pScrn);\
- infoRec->NeedToSync = FALSE;\
- }}
+
+#define XAA_SCREEN_PROLOGUE(pScreen, field)\
+ ((pScreen)->field = \
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
+
+#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\
+ ((pScreen)->field = wrapper)
+
+
+#define XAA_GC_FUNC_PROLOGUE(pGC)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ (pGC)->funcs = pGCPriv->wrapFuncs;\
+ if(pGCPriv->flags)\
+ (pGC)->ops = pGCPriv->wrapOps
+
+#define XAA_GC_FUNC_EPILOGUE(pGC)\
+ pGCPriv->wrapFuncs = (pGC)->funcs;\
+ (pGC)->funcs = &XAAGCFuncs;\
+ if(pGCPriv->flags) {\
+ pGCPriv->wrapOps = (pGC)->ops;\
+ (pGC)->ops = (pGCPriv->flags & OPS_ARE_ACCEL) ? pGCPriv->XAAOps :\
+ &XAAPixmapOps;\
+ }
+
+
+#define XAA_GC_OP_PROLOGUE(pGC)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ GCFuncs *oldFuncs = pGC->funcs;\
+ pGC->funcs = pGCPriv->wrapFuncs;\
+ pGC->ops = pGCPriv->wrapOps
+
+#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ GCFuncs *oldFuncs = pGC->funcs;\
+ if(!RegionNumRects(pGC->pCompositeClip)) return; \
+ pGC->funcs = pGCPriv->wrapFuncs;\
+ pGC->ops = pGCPriv->wrapOps
+
+
+#define XAA_GC_OP_EPILOGUE(pGC)\
+ pGCPriv->wrapOps = pGC->ops;\
+ pGC->funcs = oldFuncs;\
+ pGC->ops = pGCPriv->XAAOps
+
+
+#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
+ XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\
+ GCFuncs *oldFuncs = pGC->funcs;\
+ pGC->funcs = pGCPriv->wrapFuncs;\
+ pGC->ops = pGCPriv->wrapOps; \
+ SYNC_CHECK(pGC)
+
+#define XAA_PIXMAP_OP_EPILOGUE(pGC)\
+ pGCPriv->wrapOps = pGC->ops;\
+ pGC->funcs = oldFuncs;\
+ pGC->ops = &XAAPixmapOps;\
+ pixPriv->flags |= DIRTY
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#define XAA_RENDER_PROLOGUE(pScreen,field)\
+ (GetPictureScreen(pScreen)->field = \
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
+
+#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\
+ (GetPictureScreen(pScreen)->field = wrapper)
+
+/* This also works fine for drawables */
+
+#define SYNC_CHECK(pGC) {\
+ XAAInfoRecPtr infoRec =\
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \
+ if(infoRec->NeedToSync) {\
+ (*infoRec->Sync)(infoRec->pScrn);\
+ infoRec->NeedToSync = FALSE;\
+ }}