[PATCH 2/4] ephyr: Free glamor xv data at server reset time

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


Add a FreePort callback hook to kdrive and implement that in ephyr to
call glamor_xv_fini_port.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 hw/kdrive/ephyr/ephyr_glamor_xv.c | 8 ++++++++
 hw/kdrive/src/kxv.c               | 5 +++++
 hw/kdrive/src/kxv.h               | 4 ++++
 3 files changed, 17 insertions(+)

diff --git a/hw/kdrive/ephyr/ephyr_glamor_xv.c b/hw/kdrive/ephyr/ephyr_glamor_xv.c
index b9c3464..6d8144d 100644
--- a/hw/kdrive/ephyr/ephyr_glamor_xv.c
+++ b/hw/kdrive/ephyr/ephyr_glamor_xv.c
@@ -105,6 +105,13 @@ ephyr_glamor_xv_put_image(KdScreenInfo *screen,
                                id, buf, width, height, sync, clipBoxes);
 }
 
+static void
+ephyr_glamor_xv_free_port(KdScreenInfo *screen,
+                          void *data)
+{
+    glamor_xv_fini_port(data);
+}
+
 void
 ephyr_glamor_xv_init(ScreenPtr screen)
 {
@@ -156,6 +163,7 @@ ephyr_glamor_xv_init(ScreenPtr screen)
     adaptor->QueryBestSize = ephyr_glamor_xv_query_best_size;
     adaptor->PutImage = ephyr_glamor_xv_put_image;
     adaptor->QueryImageAttributes = ephyr_glamor_xv_query_image_attributes;
+    adaptor->FreePort = ephyr_glamor_xv_free_port;
 
     KdXVScreenInit(screen, adaptor, 1);
 }
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index 60a8345..8f1889e 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -414,6 +414,7 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number)
         adaptorPriv->QueryImageAttributes = adaptorPtr->QueryImageAttributes;
         adaptorPriv->PutImage = adaptorPtr->PutImage;
         adaptorPriv->ReputImage = adaptorPtr->ReputImage;
+        adaptorPriv->FreePort = adaptorPtr->FreePort;
 
         pa->devPriv.ptr = (void *) adaptorPriv;
 
@@ -1148,6 +1149,10 @@ KdXVAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr * ppPort)
 static int
 KdXVFreePort(XvPortPtr pPort)
 {
+    XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) (pPort->devPriv.ptr);
+
+    if (portPriv->AdaptorRec->FreePort != NULL)
+        (*portPriv->AdaptorRec->FreePort)(portPriv->screen, portPriv->DevPriv.ptr);
     return Success;
 }
 
diff --git a/hw/kdrive/src/kxv.h b/hw/kdrive/src/kxv.h
index 3a49a65..70dc51b 100644
--- a/hw/kdrive/src/kxv.h
+++ b/hw/kdrive/src/kxv.h
@@ -109,6 +109,8 @@ typedef int (*QueryImageAttributesFuncPtr) (KdScreenInfo * screen, int image,
                                             unsigned short *height,
                                             int *pitches, int *offsets);
 
+typedef void (*FreePortFuncPtr)(KdScreenInfo *screen, void *data);
+
 typedef enum {
     XV_OFF,
     XV_PENDING,
@@ -154,6 +156,7 @@ typedef struct {
     PutImageFuncPtr PutImage;
     ReputImageFuncPtr ReputImage;
     QueryImageAttributesFuncPtr QueryImageAttributes;
+    FreePortFuncPtr FreePort;
 } KdVideoAdaptorRec, *KdVideoAdaptorPtr;
 
 Bool
@@ -205,6 +208,7 @@ typedef struct {
     PutImageFuncPtr PutImage;
     ReputImageFuncPtr ReputImage;
     QueryImageAttributesFuncPtr QueryImageAttributes;
+    FreePortFuncPtr FreePort;
 } XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
 
 typedef struct {
-- 
2.0.1



More information about the xorg-devel mailing list