[PATCH 2/2] xfree86: make screens structures run-time adjustable
Tiago Vignatti
tiago.vignatti at nokia.com
Mon Apr 12 07:54:27 PDT 2010
Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
hw/xfree86/common/xf86Cursor.c | 68 ++++++++++++++++++---------------
hw/xfree86/common/xf86xv.c | 5 +-
hw/xfree86/dixmods/extmod/xf86dga2.c | 7 ++-
hw/xfree86/os-support/bsd/arm_video.c | 5 +-
4 files changed, 48 insertions(+), 37 deletions(-)
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 6740faf..58f38cc 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -77,7 +77,7 @@ static miPointerScreenFuncRec xf86PointerScreenFuncs = {
NULL
};
-static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
+static xf86ScreenLayoutRec *xf86ScreenLayout;
static Bool HardEdges;
@@ -572,14 +572,18 @@ FillOutEdge(xf86EdgePtr pEdge, int limit)
}
/*
- * xf86InitOrigins() can deal with a maximum of 32 screens
- * on 32 bit architectures, 64 on 64 bit architectures.
+ * xf86InitOrigins() used to use a bitmask so that it was limited to 32
+ * screens on a 32-bit architecture, and 64 screens on a 64-bit
+ * architecture. Instead of using a bitmask, we use an array; instead
+ * of copying screensLeft to prevScreensLeft and comparing to see if
+ * anything changed, we introduce the "changed" variable. Another way
+ * to implement this function is presented in
+ * Xserver/hw/dmx/dmxcursor.c.
*/
-
void
xf86InitOrigins(void)
{
- unsigned long screensLeft, prevScreensLeft, mask;
+ int *screensLeft = NULL;
screenLayoutPtr screen;
ScreenPtr pScreen;
int x1, x2, y1, y2, left, right, top, bottom;
@@ -590,19 +594,21 @@ xf86InitOrigins(void)
/* need to have this set up with a config file option */
HardEdges = FALSE;
- bzero(xf86ScreenLayout, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
-
- screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
+ MAXSCREENSALLOC_FATAL(xf86ScreenLayout, xf86NumScreens);
+ MAXSCREENSALLOC_FATAL(screensLeft, xf86NumScreens);
+ for (i = 0; i < xf86NumScreens; i++)
+ screensLeft[i] = 1;
while(1) {
- for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
- if(!(mask & 1L)) continue;
+ int changed = 0;
+ for (i = 0; i < xf86NumScreens; i++) {
+ if (!screensLeft[i]) continue;
screen = &xf86ConfigLayout.screens[i];
if (screen->refscreen != NULL &&
screen->refscreen->screennum >= xf86NumScreens) {
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;
xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n",
screen->screen->id);
continue;
@@ -660,7 +666,7 @@ xf86InitOrigins(void)
case PosAbsolute:
dixScreenOrigins[i].x = screen->x;
dixScreenOrigins[i].y = screen->y;
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;
break;
case PosRelative:
ref = screen->refscreen->screennum;
@@ -668,10 +674,10 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- if(screensLeft & (1 << ref)) break;
+ if(screensLeft[ref]) break;
dixScreenOrigins[i].x = dixScreenOrigins[ref].x + screen->x;
dixScreenOrigins[i].y = dixScreenOrigins[ref].y + screen->y;
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;;
break;
case PosRightOf:
ref = screen->refscreen->screennum;
@@ -679,12 +685,12 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- if(screensLeft & (1 << ref)) break;
+ if(screensLeft[ref]) break;
pScreen = xf86Screens[ref]->pScreen;
dixScreenOrigins[i].x =
dixScreenOrigins[ref].x + pScreen->width;
dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;
break;
case PosLeftOf:
ref = screen->refscreen->screennum;
@@ -692,12 +698,12 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- if(screensLeft & (1 << ref)) break;
+ if(screensLeft[ref]) break;
pScreen = xf86Screens[i]->pScreen;
dixScreenOrigins[i].x =
dixScreenOrigins[ref].x - pScreen->width;
dixScreenOrigins[i].y = dixScreenOrigins[ref].y;
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;
break;
case PosBelow:
ref = screen->refscreen->screennum;
@@ -705,12 +711,12 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- if(screensLeft & (1 << ref)) break;
+ if(screensLeft[ref]) break;
pScreen = xf86Screens[ref]->pScreen;
dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
dixScreenOrigins[i].y =
dixScreenOrigins[ref].y + pScreen->height;
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;
break;
case PosAbove:
ref = screen->refscreen->screennum;
@@ -718,12 +724,12 @@ xf86InitOrigins(void)
ErrorF("Referenced uninitialized screen in Layout!\n");
break;
}
- if(screensLeft & (1 << ref)) break;
+ if(screensLeft[ref]) break;
pScreen = xf86Screens[i]->pScreen;
dixScreenOrigins[i].x = dixScreenOrigins[ref].x;
dixScreenOrigins[i].y =
dixScreenOrigins[ref].y - pScreen->height;
- screensLeft &= ~(1 << i);
+ ++changed, screensLeft[i] = 0;
break;
default:
ErrorF("Illegal placement keyword in Layout!\n");
@@ -732,21 +738,21 @@ xf86InitOrigins(void)
}
- if(!screensLeft) break;
-
- if(screensLeft == prevScreensLeft) {
+ if(!changed) {
+ int n, count;
/* All the remaining screens are referencing each other.
Assign a value to one of them and go through again */
- i = 0;
- while(!((1 << i) & screensLeft)){ i++; }
+ for (i = 0; i < xf86NumScreens; i++)
+ if (screensLeft[i]) break;
+
+ if (i >= xf86NumScreens) break; /* Finished */
ref = xf86ConfigLayout.screens[i].refscreen->screennum;
dixScreenOrigins[ref].x = dixScreenOrigins[ref].y = 0;
- screensLeft &= ~(1 << ref);
+ screensLeft[ref] = 0;
}
-
- prevScreensLeft = screensLeft;
}
+ MAXSCREENSFREE(screensLeft);
/* justify the topmost and leftmost to (0,0) */
minX = dixScreenOrigins[0].x;
@@ -847,7 +853,7 @@ xf86ReconfigureLayout(void)
{
int i;
- for (i = 0; i < MAXSCREENS; i++) {
+ for (i = 0; i < xf86NumScreens; i++) {
xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
/* we don't have to zero these, xf86InitOrigins() takes care of that */
if (sl->left) xfree(sl->left);
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index bdcc4fc..c36d9c2 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -55,7 +55,7 @@
#include "xvmodproc.h"
#include "xf86xvpriv.h"
-
+#include "xf86Priv.h"
/* XvScreenRec fields */
@@ -186,7 +186,7 @@ typedef struct {
int num;
} OffscreenImageRec;
-static OffscreenImageRec OffscreenImages[MAXSCREENS];
+static OffscreenImageRec *OffscreenImages;
Bool
xf86XVRegisterOffscreenImages(
@@ -194,6 +194,7 @@ xf86XVRegisterOffscreenImages(
XF86OffscreenImagePtr images,
int num
){
+ MAXSCREENSALLOC_FATAL(OffscreenImages, xf86NumScreens);
OffscreenImages[pScreen->myNum].num = num;
OffscreenImages[pScreen->myNum].images = images;
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index 5367bcc..924a83d 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -27,10 +27,12 @@
#include "dgaproc.h"
#include "xf86dgaext.h"
#include "protocol-versions.h"
+#include "globals.h"
#include <string.h>
#include "modinit.h"
+#include "xf86Priv.h"
#define DGA_PROTOCOL_OLD_SUPPORT 1
@@ -57,7 +59,7 @@ static void XDGAResetProc(ExtensionEntry *extEntry);
static void DGAClientStateChange (CallbackListPtr*, pointer, pointer);
-static ClientPtr DGAClients[MAXSCREENS];
+static ClientPtr *DGAClients;
unsigned char DGAReqCode = 0;
int DGAErrorBase;
@@ -93,7 +95,8 @@ XFree86DGAExtensionInit(INITARGS)
StandardMinorOpcode))) {
int i;
- for(i = 0; i < MAXSCREENS; i++)
+ MAXSCREENSALLOC_FATAL(DGAClients, xf86NumScreens);
+ for(i = 0; i < xf86NumScreens; i++)
DGAClients[i] = NULL;
DGAReqCode = (unsigned char)extEntry->base;
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index 466a8a0..c68591a 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -533,7 +533,7 @@ xf86DisableIO()
#define DEV_MEM_IOBASE 0x43000000
#endif
-static Bool ScreenEnabled[MAXSCREENS];
+static Bool *ScreenEnabled;
static Bool ExtendedEnabled = FALSE;
static Bool InitDone = FALSE;
@@ -549,7 +549,7 @@ int ScreenNum;
struct memAccess *memInfoP;
int *Size;
#endif
-
+ MAXSCREENSALLOC_FATAL(ScreenEnabled);
ScreenEnabled[ScreenNum] = TRUE;
if (ExtendedEnabled)
@@ -635,6 +635,7 @@ int ScreenNum;
struct memAccess *memInfoP;
#endif
+ MAXSCREENSALLOC_FATAL(ScreenEnabled);
ScreenEnabled[ScreenNum] = FALSE;
#ifdef __arm32__
--
1.6.0.4
More information about the xorg-devel
mailing list