summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2014-04-04 17:54:58 +0100
committerEric Anholt <eric@anholt.net>2014-08-06 20:12:20 -0700
commite7dde86f2343832c52ef74f5c4fe44a72054c79b (patch)
tree1b0b129c927b3b68464bc52e81f3a6d492e60284
parenta146c6d4212ed199002e40419b4aa22da8f49e3a (diff)
xv: Move the DDX XV screen private allocation into the DDXes.
XV was going against convention by having the core infrastructure allocate the private on behalf of the DDX. I was interested in this because I was trying to make multiple pieces of DDX be able to allocate adaptors, and that wasn't going to work if DDX-specific code was hung off of a single global screen private. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Keith Packard <keithp@keithp.com>
-rw-r--r--Xext/xvdix.h1
-rw-r--r--hw/kdrive/src/kxv.c12
-rw-r--r--hw/xfree86/common/xf86xv.c14
3 files changed, 12 insertions, 15 deletions
diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 7afa88a87..2437eb4a6 100644
--- a/Xext/xvdix.h
+++ b/Xext/xvdix.h
@@ -214,7 +214,6 @@ typedef struct {
DestroyPixmapProcPtr DestroyPixmap;
CloseScreenProcPtr CloseScreen;
Bool (*ddCloseScreen) (ScreenPtr);
- DevUnion devPriv;
} XvScreenRec, *XvScreenPtr;
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 0896c8170..ad51cf971 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -103,6 +103,7 @@ static DevPrivateKeyRec KdXVWindowKeyRec;
#define KdXVWindowKey (&KdXVWindowKeyRec)
static DevPrivateKey KdXvScreenKey;
+static DevPrivateKeyRec KdXVScreenPrivateKey;
static unsigned long KdXVGeneration = 0;
static unsigned long PortResource = 0;
@@ -110,7 +111,7 @@ static unsigned long PortResource = 0;
dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
#define GET_KDXV_SCREEN(pScreen) \
- ((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((KdXVScreenPtr)(dixGetPrivate(&pScreen->devPrivates, &KdXVScreenPrivateKey)))
#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
@@ -143,6 +144,8 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
+ if (!dixRegisterPrivateKey(&KdXVScreenPrivateKey, PRIVATE_SCREEN, 0))
+ return FALSE;
if (Success != XvScreenInit(pScreen))
return FALSE;
@@ -157,13 +160,8 @@ KdXVScreenInit(ScreenPtr pScreen, KdVideoAdaptorPtr adaptors, int num)
pxvs->ddCloseScreen = KdXVCloseScreen;
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
-
ScreenPriv = malloc(sizeof(KdXVScreenRec));
- pxvs->devPriv.ptr = (void *) ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, &KdXVScreenPrivateKey, ScreenPriv);
if (!ScreenPriv)
return FALSE;
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 35dd664e9..0f3b09bfe 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -112,7 +112,10 @@ static DevPrivateKeyRec XF86XVWindowKeyRec;
#define XF86XVWindowKey (&XF86XVWindowKeyRec)
+/* dixmain.c XvScreenPtr screen private */
DevPrivateKey XF86XvScreenKey;
+/** xf86xv.c XF86XVScreenPtr screen private */
+static DevPrivateKeyRec XF86XVScreenPrivateKey;
static unsigned long PortResource = 0;
@@ -120,7 +123,7 @@ static unsigned long PortResource = 0;
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
#define GET_XF86XV_SCREEN(pScreen) \
- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((XF86XVScreenPtr)(dixGetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey)))
#define GET_XF86XV_WINDOW(pWin) \
((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
@@ -241,6 +244,8 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
+ if (!dixRegisterPrivateKey(&XF86XVScreenPrivateKey, PRIVATE_SCREEN, 0))
+ return FALSE;
XF86XvScreenKey = XvGetScreenKey();
@@ -253,13 +258,8 @@ xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * adaptors, int num)
pxvs->ddCloseScreen = xf86XVCloseScreen;
- /* The Xv di layer provides us with a private hook so that we don't
- have to allocate our own screen private. They also provide
- a CloseScreen hook so that we don't have to wrap it. I'm not
- sure that I appreciate that. */
-
ScreenPriv = malloc(sizeof(XF86XVScreenRec));
- pxvs->devPriv.ptr = (void *) ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, &XF86XVScreenPrivateKey, ScreenPriv);
if (!ScreenPriv)
return FALSE;