diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-08-08 08:17:15 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-08-08 08:26:08 +0100 |
commit | afea9ba0790a951c6a00b57d0d71876dd1ce98c3 (patch) | |
tree | 5d403f9fa7bf9d7bd84cfa4944d946f37009adea | |
parent | 6f69188cb2959abfb2fcd3f81cd4146aa3876bb5 (diff) |
Prepare for spurious Xv ABI changes
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/compat-api.h | 22 | ||||
-rw-r--r-- | src/sna/sna_driver.c | 1 | ||||
-rw-r--r-- | src/sna/sna_video.c | 40 | ||||
-rw-r--r-- | src/sna/sna_video.h | 1 | ||||
-rw-r--r-- | src/sna/sna_video_overlay.c | 50 | ||||
-rw-r--r-- | src/sna/sna_video_sprite.c | 51 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 47 |
7 files changed, 89 insertions, 123 deletions
diff --git a/src/compat-api.h b/src/compat-api.h index 7e82b78a..46a755b9 100644 --- a/src/compat-api.h +++ b/src/compat-api.h @@ -191,4 +191,26 @@ static inline void FreePixmap(PixmapPtr pixmap) #define DamageUnregister(d, dd) DamageUnregister(dd) #endif +#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,16,99,1,0) + +#define XORG_XV_VERSION 2 +#define ddStopVideo_ARGS XvPortPtr port, DrawablePtr draw +#define ddSetPortAttribute_ARGS XvPortPtr port, Atom attribute, INT32 value +#define ddGetPortAttribute_ARGS XvPortPtr port, Atom attribute, INT32 *value +#define ddQueryBestSize_ARGS XvPortPtr port, CARD8 motion, CARD16 vid_w, CARD16 vid_h, CARD16 drw_w, CARD16 drw_h, unsigned int *p_w, unsigned int *p_h +#define ddPutImage_ARGS DrawablePtr draw, XvPortPtr port, GCPtr gc, INT16 src_x, INT16 src_y, CARD16 src_w, CARD16 src_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h, XvImagePtr format, unsigned char *buf, Bool sync, CARD16 width, CARD16 height +#define ddQueryImageAttributes_ARGS XvPortPtr port, XvImagePtr format, unsigned short *w, unsigned short *h, int *pitches, int *offsets + +#else + +#define XORG_XV_VERSION 1 +#define ddStopVideo_ARGS ClientPtr client, XvPortPtr port, DrawablePtr draw +#define ddSetPortAttribute_ARGS ClientPtr client, XvPortPtr port, Atom attribute, INT32 value +#define ddGetPortAttribute_ARGS ClientPtr client, XvPortPtr port, Atom attribute, INT32 *value +#define ddQueryBestSize_ARGS ClientPtr client, XvPortPtr port, CARD8 motion, CARD16 vid_w, CARD16 vid_h, CARD16 drw_w, CARD16 drw_h, unsigned int *p_w, unsigned int *p_h +#define ddPutImage_ARGS ClientPtr client, DrawablePtr draw, XvPortPtr port, GCPtr gc, INT16 src_x, INT16 src_y, CARD16 src_w, CARD16 src_h, INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h, XvImagePtr format, unsigned char *buf, Bool sync, CARD16 width, CARD16 height +#define ddQueryImageAttributes_ARGS ClientPtr client, XvPortPtr port, XvImagePtr format, unsigned short *w, unsigned short *h, int *pitches, int *offsets + +#endif + #endif diff --git a/src/sna/sna_driver.c b/src/sna/sna_driver.c index 322e9514..dc0a6593 100644 --- a/src/sna/sna_driver.c +++ b/src/sna/sna_driver.c @@ -955,6 +955,7 @@ static Bool sna_late_close_screen(CLOSE_SCREEN_ARGS_DECL) DBG(("%s\n", __FUNCTION__)); sna_accel_close(sna); + sna_video_close(sna); depths = screen->allowedDepths; for (d = 0; d < screen->numDepths; d++) diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index 7534fe32..b36c1a25 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -67,6 +67,7 @@ #else static inline void sna_video_xvmc_setup(struct sna *sna, ScreenPtr ptr) { + DBG(("%s: XvMC not compiled in\n")); } #endif @@ -656,6 +657,7 @@ sna_xv_fixup_formats(ScreenPtr screen, XvFormatPtr formats, int num_formats) return count; } +#if XORG_XV_VERSION < 2 static int sna_xv_query_adaptors(ScreenPtr screen, XvAdaptorPtr *adaptors, @@ -672,20 +674,10 @@ static Bool sna_xv_close_screen(CLOSE_SCREEN_ARGS_DECL) { struct sna *sna = to_sna_from_screen(screen); - int i; - - for (i = 0; i < sna->xv.num_adaptors; i++) { - free(sna->xv.adaptors[i].pPorts->devPriv.ptr); - free(sna->xv.adaptors[i].pPorts); - free(sna->xv.adaptors[i].pEncodings); - } - free(sna->xv.adaptors); - - sna->xv.adaptors = NULL; - sna->xv.num_adaptors = 0; - + sna_video_close(sna); return TRUE; } +#endif void sna_video_init(struct sna *sna, ScreenPtr screen) { @@ -707,8 +699,10 @@ void sna_video_init(struct sna *sna, ScreenPtr screen) return; xv = to_xv(screen); +#if XORG_XV_VERSION < 2 xv->ddCloseScreen = sna_xv_close_screen; xv->ddQueryAdaptors = sna_xv_query_adaptors; +#endif sna_video_textured_setup(sna, screen); sna_video_sprite_setup(sna, screen); @@ -734,7 +728,27 @@ void sna_video_destroy_window(WindowPtr win) XvPortPtr port; port = sna_window_get_port(win); - if (port) + if (port) { +#if XORG_XV_VERSION < 2 port->pAdaptor->ddStopVideo(NULL, port, &win->drawable); +#else + port->pAdaptor->ddStopVideo(port, &win->drawable); +#endif + } assert(sna_window_get_port(win) == NULL); } + +void sna_video_close(struct sna *sna) +{ + int i; + + for (i = 0; i < sna->xv.num_adaptors; i++) { + free(sna->xv.adaptors[i].pPorts->devPriv.ptr); + free(sna->xv.adaptors[i].pPorts); + free(sna->xv.adaptors[i].pEncodings); + } + free(sna->xv.adaptors); + + sna->xv.adaptors = NULL; + sna->xv.num_adaptors = 0; +} diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h index d46c0159..f21605fc 100644 --- a/src/sna/sna_video.h +++ b/src/sna/sna_video.h @@ -131,6 +131,7 @@ void sna_video_overlay_setup(struct sna *sna, ScreenPtr screen); void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen); void sna_video_textured_setup(struct sna *sna, ScreenPtr screen); void sna_video_destroy_window(WindowPtr win); +void sna_video_close(struct sna *sna); XvAdaptorPtr sna_xv_adaptor_alloc(struct sna *sna); int sna_xv_fixup_formats(ScreenPtr screen, diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c index a8147739..ac81f1a0 100644 --- a/src/sna/sna_video_overlay.c +++ b/src/sna/sna_video_overlay.c @@ -122,9 +122,7 @@ static bool sna_video_overlay_update_attrs(struct sna_video *video) return drmIoctl(video->sna->kgem.fd, DRM_IOCTL_I915_OVERLAY_ATTRS, &attrs) == 0; } -static int sna_video_overlay_stop(ClientPtr client, - XvPortPtr port, - DrawablePtr draw) +static int sna_video_overlay_stop(ddStopVideo_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -149,10 +147,7 @@ static int sna_video_overlay_stop(ClientPtr client, } static int -sna_video_overlay_set_attribute(ClientPtr client, - XvPortPtr port, - Atom attribute, - INT32 value) +sna_video_overlay_set_attribute(ddSetPortAttribute_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -223,10 +218,7 @@ sna_video_overlay_set_attribute(ClientPtr client, } static int -sna_video_overlay_get_attribute(ClientPtr client, - XvPortPtr port, - Atom attribute, - INT32 *value) +sna_video_overlay_get_attribute(ddGetPortAttribute_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -269,12 +261,7 @@ sna_video_overlay_get_attribute(ClientPtr client, } static int -sna_video_overlay_best_size(ClientPtr client, - XvPortPtr port, - CARD8 motion, - CARD16 vid_w, CARD16 vid_h, - CARD16 drw_w, CARD16 drw_h, - unsigned int *p_w, unsigned int *p_h) +sna_video_overlay_best_size(ddQueryBestSize_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -463,18 +450,7 @@ sna_video_overlay_show(struct sna *sna, } static int -sna_video_overlay_put_image(ClientPtr client, - DrawablePtr draw, - XvPortPtr port, - GCPtr gc, - INT16 src_x, INT16 src_y, - CARD16 src_w, CARD16 src_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h, - XvImagePtr format, - unsigned char *buf, - Bool sync, - CARD16 width, CARD16 height) +sna_video_overlay_put_image(ddPutImage_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -602,18 +578,16 @@ invisible: /* * If the video isn't visible on any CRTC, turn it off */ +#if XORG_XV_VERSION < 2 sna_video_overlay_stop(client, port, draw); +#else + sna_video_overlay_stop(port, draw); +#endif return Success; } static int -sna_video_overlay_query(ClientPtr client, - XvPortPtr port, - XvImagePtr format, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) +sna_video_overlay_query(ddQueryImageAttributes_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna_video_frame frame; @@ -770,8 +744,10 @@ void sna_video_overlay_setup(struct sna *sna, ScreenPtr screen) adaptor->pAttributes = (XvAttributeRec *)Attributes; adaptor->nImages = ARRAY_SIZE(Images); adaptor->pImages = (XvImageRec *)Images; +#if XORG_XV_VERSION < 2 adaptor->ddAllocatePort = sna_xv_alloc_port; adaptor->ddFreePort = sna_xv_free_port; +#endif adaptor->ddPutVideo = NULL; adaptor->ddPutStill = NULL; adaptor->ddGetVideo = NULL; @@ -841,4 +817,6 @@ void sna_video_overlay_setup(struct sna *sna, ScreenPtr screen) } sna_video_overlay_update_attrs(video); + + DBG(("%s: '%s' initialized %d ports\n", __FUNCTION__, adaptor->name, adaptor->nPorts)); } diff --git a/src/sna/sna_video_sprite.c b/src/sna/sna_video_sprite.c index 80fa43f9..92230f97 100644 --- a/src/sna/sna_video_sprite.c +++ b/src/sna/sna_video_sprite.c @@ -74,9 +74,7 @@ static const XvAttributeRec attribs[] = { { XvSettable | XvGettable, 0, 1, (char *)"XV_ALWAYS_ON_TOP" }, }; -static int sna_video_sprite_stop(ClientPtr client, - XvPortPtr port, - DrawablePtr draw) +static int sna_video_sprite_stop(ddStopVideo_ARGS) { struct sna_video *video = port->devPriv.ptr; struct local_mode_set_plane s; @@ -110,10 +108,7 @@ static int sna_video_sprite_stop(ClientPtr client, return Success; } -static int sna_video_sprite_set_attr(ClientPtr client, - XvPortPtr port, - Atom attribute, - INT32 value) +static int sna_video_sprite_set_attr(ddSetPortAttribute_ARGS) { struct sna_video *video = port->devPriv.ptr; @@ -137,10 +132,7 @@ static int sna_video_sprite_set_attr(ClientPtr client, return Success; } -static int sna_video_sprite_get_attr(ClientPtr client, - XvPortPtr port, - Atom attribute, - INT32 *value) +static int sna_video_sprite_get_attr(ddGetPortAttribute_ARGS) { struct sna_video *video = port->devPriv.ptr; @@ -156,13 +148,7 @@ static int sna_video_sprite_get_attr(ClientPtr client, return Success; } -static int sna_video_sprite_best_size(ClientPtr client, - XvPortPtr port, - CARD8 motion, - CARD16 vid_w, CARD16 vid_h, - CARD16 drw_w, CARD16 drw_h, - unsigned int *p_w, - unsigned int *p_h) +static int sna_video_sprite_best_size(ddQueryBestSize_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -382,18 +368,7 @@ sna_video_sprite_show(struct sna *sna, return true; } -static int sna_video_sprite_put_image(ClientPtr client, - DrawablePtr draw, - XvPortPtr port, - GCPtr gc, - INT16 src_x, INT16 src_y, - CARD16 src_w, CARD16 src_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h, - XvImagePtr format, - unsigned char *buf, - Bool sync, - CARD16 width, CARD16 height) +static int sna_video_sprite_put_image(ddPutImage_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -565,17 +540,15 @@ off: return Success; err: +#if XORG_XV_VERSION < 2 (void)sna_video_sprite_stop(client, port, draw); +#else + (void)sna_video_sprite_stop(port, draw); +#endif return ret; } -static int sna_video_sprite_query(ClientPtr client, - XvPortPtr port, - XvImagePtr format, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) +static int sna_video_sprite_query(ddQueryImageAttributes_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna_video_frame frame; @@ -698,8 +671,10 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) if (sna->kgem.gen == 071) adaptor->nImages = 4; +#if XORG_XV_VERSION < 2 adaptor->ddAllocatePort = sna_xv_alloc_port; adaptor->ddFreePort = sna_xv_free_port; +#endif adaptor->ddPutVideo = NULL; adaptor->ddPutStill = NULL; adaptor->ddGetVideo = NULL; @@ -745,4 +720,6 @@ void sna_video_sprite_setup(struct sna *sna, ScreenPtr screen) xvColorKey = MAKE_ATOM("XV_COLORKEY"); xvAlwaysOnTop = MAKE_ATOM("XV_ALWAYS_ON_TOP"); xvSyncToVblank = MAKE_ATOM("XV_SYNC_TO_VBLANK"); + + DBG(("%s: '%s' initialized %d ports\n", __FUNCTION__, adaptor->name, adaptor->nPorts)); } diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index d06aafd8..81833960 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -56,9 +56,7 @@ static const XvImageRec Images[] = { XVMC_YUV, }; -static int sna_video_textured_stop(ClientPtr client, - XvPortPtr port, - DrawablePtr draw) +static int sna_video_textured_stop(ddStopVideo_ARGS) { struct sna_video *video = port->devPriv.ptr; @@ -71,10 +69,7 @@ static int sna_video_textured_stop(ClientPtr client, } static int -sna_video_textured_set_attribute(ClientPtr client, - XvPortPtr port, - Atom attribute, - INT32 value) +sna_video_textured_set_attribute(ddSetPortAttribute_ARGS) { struct sna_video *video = port->devPriv.ptr; @@ -100,10 +95,7 @@ sna_video_textured_set_attribute(ClientPtr client, } static int -sna_video_textured_get_attribute(ClientPtr client, - XvPortPtr port, - Atom attribute, - INT32 *value) +sna_video_textured_get_attribute(ddGetPortAttribute_ARGS) { struct sna_video *video = port->devPriv.ptr; @@ -120,13 +112,7 @@ sna_video_textured_get_attribute(ClientPtr client, } static int -sna_video_textured_best_size(ClientPtr client, - XvPortPtr port, - CARD8 motion, - CARD16 vid_w, CARD16 vid_h, - CARD16 drw_w, CARD16 drw_h, - unsigned int *p_w, - unsigned int *p_h) +sna_video_textured_best_size(ddQueryBestSize_ARGS) { if (vid_w > (drw_w << 1)) drw_w = vid_w >> 1; @@ -153,18 +139,7 @@ sna_video_textured_best_size(ClientPtr client, * compositing. It's a new argument to the function in the 1.1 server. */ static int -sna_video_textured_put_image(ClientPtr client, - DrawablePtr draw, - XvPortPtr port, - GCPtr gc, - INT16 src_x, INT16 src_y, - CARD16 src_w, CARD16 src_h, - INT16 drw_x, INT16 drw_y, - CARD16 drw_w, CARD16 drw_h, - XvImagePtr format, - unsigned char *buf, - Bool sync, - CARD16 width, CARD16 height) +sna_video_textured_put_image(ddPutImage_ARGS) { struct sna_video *video = port->devPriv.ptr; struct sna *sna = video->sna; @@ -275,13 +250,7 @@ sna_video_textured_put_image(ClientPtr client, } static int -sna_video_textured_query(ClientPtr client, - XvPortPtr port, - XvImagePtr format, - unsigned short *w, - unsigned short *h, - int *pitches, - int *offsets) +sna_video_textured_query(ddQueryImageAttributes_ARGS) { int size, tmp; @@ -390,8 +359,10 @@ void sna_video_textured_setup(struct sna *sna, ScreenPtr screen) adaptor->pAttributes = (XvAttributeRec *)Attributes; adaptor->nImages = ARRAY_SIZE(Images); adaptor->pImages = (XvImageRec *)Images; +#if XORG_XV_VERSION < 2 adaptor->ddAllocatePort = sna_xv_alloc_port; adaptor->ddFreePort = sna_xv_free_port; +#endif adaptor->ddPutVideo = NULL; adaptor->ddPutStill = NULL; adaptor->ddGetVideo = NULL; @@ -431,4 +402,6 @@ void sna_video_textured_setup(struct sna *sna, ScreenPtr screen) xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); xvContrast = MAKE_ATOM("XV_CONTRAST"); xvSyncToVblank = MAKE_ATOM("XV_SYNC_TO_VBLANK"); + + DBG(("%s: '%s' initialized %d ports\n", __FUNCTION__, adaptor->name, adaptor->nPorts)); } |