[PATCH 3/4] xfree86: Provide Xv driver callback to free data at server reset

Keith Packard keithp at keithp.com
Wed Aug 6 22:12:38 PDT 2014


For drivers which allocates per-port resources, this provides a simple
place to free them at reset time.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/xfree86/common/xf86xv.c     | 6 ++++++
 hw/xfree86/common/xf86xv.h     | 3 +++
 hw/xfree86/common/xf86xvpriv.h | 1 +
 3 files changed, 10 insertions(+)

diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index e212a73..26129ef 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -521,6 +521,7 @@ xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
         adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
         adaptorPriv->PutImage = adaptorPtr->PutImage;
         adaptorPriv->ReputImage = adaptorPtr->ReputImage;       /* image/still */
+        adaptorPriv->FreePort = adaptorPtr->FreePort;
 
         pa->devPriv.ptr = (void *) adaptorPriv;
 
@@ -1370,6 +1371,11 @@ xf86XVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
 static int
 xf86XVFreePort(XvPortPtr pPort)
 {
+    XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+    if (portPriv->AdaptorRec->FreePort)
+        (*portPriv->AdaptorRec->FreePort)(portPriv->pScrn,
+                                          portPriv->DevPriv.ptr);
     return Success;
 }
 
diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h
index de17eb1..8e7fe36 100644
--- a/hw/xfree86/common/xf86xv.h
+++ b/hw/xfree86/common/xf86xv.h
@@ -100,6 +100,8 @@ typedef int (*QueryImageAttributesFuncPtr) (ScrnInfoPtr pScrn, int image,
 typedef void (*ClipNotifyFuncPtr) (ScrnInfoPtr pScrn, void *data,
                                    WindowPtr window, int dx, int dy);
 
+typedef void (*FreePortFuncPtr)(ScrnInfoPtr scrn, void *data);
+
 typedef enum {
     XV_OFF,
     XV_PENDING,
@@ -148,6 +150,7 @@ typedef struct {
     ReputImageFuncPtr ReputImage;       /* image/still */
     QueryImageAttributesFuncPtr QueryImageAttributes;
     ClipNotifyFuncPtr ClipNotify;
+    FreePortFuncPtr FreePort;
 } XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
 
 typedef struct {
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
index e95f959..8997268 100644
--- a/hw/xfree86/common/xf86xvpriv.h
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -61,6 +61,7 @@ typedef struct {
     ReputImageFuncPtr ReputImage;
     QueryImageAttributesFuncPtr QueryImageAttributes;
     ClipNotifyFuncPtr ClipNotify;
+    FreePortFuncPtr FreePort;
 } XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
 
 typedef struct {
-- 
2.0.1



More information about the xorg-devel mailing list