diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-04-17 15:32:49 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-04-17 15:32:58 +0100 |
commit | 6668f68054cb33e0cd3425f5403d14092a4a17f8 (patch) | |
tree | 626e49eb1fa753bf1d82705d90ea006d540c2434 | |
parent | 1bf0d869ae07ffc5b9cd79904b421cd37997ae8c (diff) |
Revert "xgvevent"
This reverts commit ddd75d6539dcf692cb76747cd63d1f301180f18a.
This is a WIP patch, not ready for upstream. The danger of mixing topic
branches.
-rw-r--r-- | src/sna/sna.h | 6 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 2 | ||||
-rw-r--r-- | src/sna/sna_video.c | 134 | ||||
-rw-r--r-- | src/sna/sna_video.h | 13 | ||||
-rw-r--r-- | src/sna/sna_video_hwmc.c | 64 | ||||
-rw-r--r-- | src/sna/sna_video_hwmc.h | 2 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 243 |
7 files changed, 187 insertions, 277 deletions
diff --git a/src/sna/sna.h b/src/sna/sna.h index ee6578be..20981b3b 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -57,7 +57,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <glyphstr.h> #include <picturestr.h> #include <gcstruct.h> -#include <xvdix.h> #include <pciaccess.h> @@ -249,11 +248,6 @@ struct sna { void *flip_pending; } dri; - struct sna_xv { - XvAdaptorPtr adaptors; - int num_adaptors; - } xv; - unsigned int tiling; #define SNA_TILING_FB 0x1 #define SNA_TILING_2D 0x2 diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index c337de7e..c363a3c5 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -57,7 +57,7 @@ #define FORCE_INPLACE 0 #define FORCE_FALLBACK 0 #define FORCE_FLUSH 0 -#define FORCE_FULL_SYNC 0 /* https://bugs.freedesktop.org/show_bug.cgi?id=61628 */ +#define FORCE_FULL_SYNC 1 /* https://bugs.freedesktop.org/show_bug.cgi?id=61628 */ #define DEFAULT_TILING I915_TILING_X diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index b7534905..6d067c76 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -532,118 +532,50 @@ sna_video_copy_data(struct sna *sna, return true; } -struct xXvEvent_Intel { - uint8_t type; /* GenericEvent */ - uint8_t extension; /* XvReqCode */ - uint16_t seqno; - uint32_t length; /* 0 */ - uint16_t evtype; - uint16_t pad; - uint32_t frame; - uint32_t name; -}; -#define XvFrameRelease_Intel 0x100 - -void sna_video_send_frame_release(ClientPtr client, - uint32_t frame, - uint32_t name) -{ - //GEMaskIsSet - struct xXvEvent_Intel ev = { - .type = GenericEvent, - .extension = XvReqCode, - .seqno = client->sequence, - .length = 0, - .evtype = XvFrameRelease_Intel, - .frame = frame, - .name = name - }; - assert(!client->swapped); - WriteToClient(client, sizeof(ev), &ev); -} - -XvAdaptorPtr sna_xv_adaptor_alloc(struct sna *sna) -{ - XvAdaptorPtr new_adaptors; - - new_adaptors = realloc(sna->xv.adaptors, - (sna->xv.num_adaptors+1)*sizeof(XvAdaptorRec)); - if (new_adaptors == NULL) - return NULL; - - sna->xv.adaptors = new_adaptors; - return &sna->xv.adaptors[sna->xv.num_adaptors++]; -} - -int -sna_xv_alloc_port(unsigned long port, XvPortPtr in, XvPortPtr *out) -{ - *out = in; - return Success; -} - -int -sna_xv_free_port(XvPortPtr port) -{ - return Success; -} - -static int -sna_xv_query_adaptors(ScreenPtr screen, - XvAdaptorPtr *adaptors, - int *num_adaptors) -{ - struct sna *sna = to_sna_from_screen(screen); - - *num_adaptors = sna->xv.num_adaptors; - *adaptors = sna->xv.adaptors; - return Success; -} - -static Bool -sna_xv_close_screen(ScreenPtr screen) -{ - return TRUE; -} - void sna_video_init(struct sna *sna, ScreenPtr screen) { - XvScreenPtr xv; + XF86VideoAdaptorPtr *adaptors, *newAdaptors; + XF86VideoAdaptorPtr textured, overlay; + int num_adaptors; + int prefer_overlay = + xf86ReturnOptValBool(sna->Options, OPTION_PREFER_OVERLAY, false); - if (noXvExtension) + if (!xf86LoaderCheckSymbol("xf86XVListGenericAdaptors")) return; - if (xf86LoaderCheckSymbol("xf86XVListGenericAdaptors")) { - XF86VideoAdaptorPtr *adaptors = NULL; - int num_adaptors = xf86XVListGenericAdaptors(sna->scrn, &adaptors); - if (num_adaptors) - xf86DrvMsg(sna->scrn->scrnIndex, X_ERROR, - "Ignoring generic xf86XV adaptors"); + adaptors = NULL; + num_adaptors = xf86XVListGenericAdaptors(sna->scrn, &adaptors); + newAdaptors = realloc(adaptors, + (num_adaptors + 2) * sizeof(XF86VideoAdaptorPtr)); + if (newAdaptors == NULL) { free(adaptors); - } - - if (XvScreenInit(screen) != Success) return; + } + adaptors = newAdaptors; - xv = to_xv(screen); - xv->ddCloseScreen = sna_xv_close_screen; - xv->ddQueryAdaptors = sna_xv_query_adaptors; + /* Set up textured video if we can do it at this depth and we are on + * supported hardware. + */ + textured = sna_video_textured_setup(sna, screen); + overlay = sna_video_sprite_setup(sna, screen); + if (overlay == NULL) + overlay = sna_video_overlay_setup(sna, screen); - sna_video_textured_setup(sna, screen); - if (!sna_video_sprite_setup(sna, screen)) - sna_video_overlay_setup(sna, screen); + if (overlay && prefer_overlay) + adaptors[num_adaptors++] = overlay; - if (sna->xv.num_adaptors >= 2 && - xf86ReturnOptValBool(sna->Options, OPTION_PREFER_OVERLAY, false)) { - XvAdaptorRec tmp; + if (textured) + adaptors[num_adaptors++] = textured; - tmp = sna->xv.adaptors[0]; - sna->xv.adaptors[0] = sna->xv.adaptors[1]; - sna->xv.adaptors[1] = tmp; - } + if (overlay && !prefer_overlay) + adaptors[num_adaptors++] = overlay; - xv->nAdaptors = sna->xv.num_adaptors; - xv->pAdaptors = sna->xv.adaptors; + if (num_adaptors) { + if (xf86XVScreenInit(screen, adaptors, num_adaptors)) + sna_video_xvmc_setup(sna, screen); + } else + xf86DrvMsg(sna->scrn->scrnIndex, X_WARNING, + "Disabling Xv because no adaptors could be initialized.\n"); - sna_video_xvmc_setup(sna, screen); + free(adaptors); } diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h index d39fa5f2..2e7144ec 100644 --- a/src/sna/sna_video.h +++ b/src/sna/sna_video.h @@ -50,8 +50,6 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE. } struct sna_video { - struct sna *sna; - int brightness; int contrast; int saturation; @@ -97,19 +95,10 @@ struct sna_video_frame { BoxRec src; }; -static inline XvScreenPtr to_xv(ScreenPtr screen) -{ - return dixLookupPrivate(&screen->devPrivates, XvGetScreenKey()); -} - void sna_video_init(struct sna *sna, ScreenPtr screen); XF86VideoAdaptorPtr sna_video_overlay_setup(struct sna *sna, ScreenPtr screen); XF86VideoAdaptorPtr sna_video_sprite_setup(struct sna *sna, ScreenPtr screen); -void sna_video_textured_setup(struct sna *sna, ScreenPtr screen); - -XvAdaptorPtr sna_xv_adaptor_alloc(struct sna *sna); -int sna_xv_alloc_port(unsigned long port, XvPortPtr in, XvPortPtr *out); -int sna_xv_free_port(XvPortPtr port); +XF86VideoAdaptorPtr sna_video_textured_setup(struct sna *sna, ScreenPtr screen); #define FOURCC_XVMC (('C' << 24) + ('M' << 16) + ('V' << 8) + 'X') diff --git a/src/sna/sna_video_hwmc.c b/src/sna/sna_video_hwmc.c index 15a7844a..55aa8546 100644 --- a/src/sna/sna_video_hwmc.c +++ b/src/sna/sna_video_hwmc.c @@ -196,60 +196,66 @@ static XvMCSurfaceInfoPtr surface_info_vld[] = { }; /* check chip type and load xvmc driver */ -void sna_video_xvmc_setup(struct sna *sna, ScreenPtr screen) +Bool sna_video_xvmc_setup(struct sna *sna, + ScreenPtr screen) { XvMCAdaptorRec *adaptors; + XvScreenPtr xv; const char *name; char bus[64]; - int i; - - if (!sna->xv.num_adaptors) - return; + int i, j; if (!xf86LoaderCheckSymbol("XvMCScreenInit")) - return; + return FALSE; /* Needs KMS support. */ if (sna->kgem.gen < 031) - return; + return FALSE; /* Not implemented */ if (sna->kgem.gen >= 060) - return; + return FALSE; + + xv = dixLookupPrivate(&screen->devPrivates, XF86XvScreenKey); - adaptors = calloc(sna->xv.num_adaptors, sizeof(XvMCAdaptorRec)); + adaptors = calloc(xv->nAdaptors, sizeof(XvMCAdaptorRec)); if (adaptors == NULL) - return; + return FALSE; + + for (i = j = 0; i< xv->nAdaptors;i++) { + if (strncmp(xv->pAdaptors[i].name, "Intel(R)", 8)) + continue; - for (i = 0; i< sna->xv.num_adaptors; i++) { - adaptors[i].xv_adaptor = &sna->xv.adaptors[i]; + adaptors[j].xv_adaptor = &xv->pAdaptors[i]; - adaptors[i].num_subpictures = 0; - adaptors[i].subpictures = NULL; - adaptors[i].CreateContext = create_context; - adaptors[i].DestroyContext = destroy_context; - adaptors[i].CreateSurface = create_surface; - adaptors[i].DestroySurface = destroy_surface; - adaptors[i].CreateSubpicture = create_subpicture; - adaptors[i].DestroySubpicture = destroy_subpicture; + adaptors[j].num_subpictures = 0; + adaptors[j].subpictures = NULL; + adaptors[j].CreateContext = create_context; + adaptors[j].DestroyContext = destroy_context; + adaptors[j].CreateSurface = create_surface; + adaptors[j].DestroySurface = destroy_surface; + adaptors[j].CreateSubpicture = create_subpicture; + adaptors[j].DestroySubpicture = destroy_subpicture; if (sna->kgem.gen >= 045) { - adaptors[i].num_surfaces = ARRAY_SIZE(surface_info_vld); - adaptors[i].surfaces = surface_info_vld; + adaptors[j].num_surfaces = ARRAY_SIZE(surface_info_vld); + adaptors[j].surfaces = surface_info_vld; } else if (sna->kgem.gen >= 040) { - adaptors[i].num_surfaces = ARRAY_SIZE(surface_info_i965); - adaptors[i].surfaces = surface_info_i965; + adaptors[j].num_surfaces = ARRAY_SIZE(surface_info_i965); + adaptors[j].surfaces = surface_info_i965; } else { - adaptors[i].num_surfaces = ARRAY_SIZE(surface_info_i915); - adaptors[i].surfaces = surface_info_i915; + adaptors[j].num_surfaces = ARRAY_SIZE(surface_info_i915); + adaptors[j].surfaces = surface_info_i915; } + + j++; } - if (XvMCScreenInit(screen, i, adaptors) != Success) { + if (XvMCScreenInit(screen, j, adaptors) != Success) { xf86DrvMsg(sna->scrn->scrnIndex, X_INFO, "[XvMC] Failed to initialize XvMC.\n"); free(adaptors); - return; + return FALSE; } sprintf(bus, "pci:%04x:%02x:%02x.%d", @@ -269,4 +275,6 @@ void sna_video_xvmc_setup(struct sna *sna, ScreenPtr screen) xf86DrvMsg(sna->scrn->scrnIndex, X_INFO, "[XvMC] %s driver initialized.\n", name); + + return TRUE; } diff --git a/src/sna/sna_video_hwmc.h b/src/sna/sna_video_hwmc.h index a6469a01..8b0d2cdf 100644 --- a/src/sna/sna_video_hwmc.h +++ b/src/sna/sna_video_hwmc.h @@ -40,7 +40,7 @@ #ifdef _SNA_XVMC_SERVER_ #include <xf86xvmc.h> -void sna_video_xvmc_setup(struct sna *sna, ScreenPtr screen); +Bool sna_video_xvmc_setup(struct sna *sna, ScreenPtr screen); #endif #endif diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 5f907441..8278606c 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -43,19 +43,20 @@ static Atom xvBrightness, xvContrast, xvSyncToVblank; -static const XvFormatRec Formats[] = { +#define NUM_FORMATS 3 +static const XF86VideoFormatRec Formats[NUM_FORMATS] = { {15, TrueColor}, {16, TrueColor}, {24, TrueColor} }; -#define NUM_FORMATS ARRAY_SIZE(Formats) -static const XvAttributeRec TexturedAttributes[] = { +//#define NUM_TEXTURED_ATTRIBUTES 3 +#define NUM_TEXTURED_ATTRIBUTES 1 +static const XF86AttributeRec TexturedAttributes[] = { {XvSettable | XvGettable, -1, 1, "XV_SYNC_TO_VBLANK"}, - //{XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, - //{XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}, + {XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, + {XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}, }; -#define NUM_TEXTURED_ATTRIBUTES ARRAY_SIZE(TexturedAttributes) -static const XvImageRec Images[] = { +static const XF86ImageRec Images[] = { XVIMAGE_YUY2, XVIMAGE_YV12, XVIMAGE_I420, @@ -63,27 +64,30 @@ static const XvImageRec Images[] = { XVMC_YUV, }; -static int sna_video_textured_stop(ClientPtr client, - XvPortPtr port, - DrawablePtr draw) +static void sna_video_textured_stop(ScrnInfoPtr scrn, + pointer data, + Bool shutdown) { - struct sna_video *video = port->devPriv.ptr; + struct sna *sna = to_sna(scrn); + struct sna_video *video = data; DBG(("%s()\n", __FUNCTION__)); - RegionUninit(&video->clip); - sna_video_free_buffers(video->sna, video); + REGION_EMPTY(scrn->pScreen, &video->clip); - return Success; + if (!shutdown) + return; + + sna_video_free_buffers(sna, video); } static int -sna_video_textured_set_attribute(ClientPtr client, - XvPortPtr port, +sna_video_textured_set_attribute(ScrnInfoPtr scrn, Atom attribute, - INT32 value) + INT32 value, + pointer data) { - struct sna_video *video = port->devPriv.ptr; + struct sna_video *video = data; if (attribute == xvBrightness) { if (value < -128 || value > 127) @@ -107,12 +111,12 @@ sna_video_textured_set_attribute(ClientPtr client, } static int -sna_video_textured_get_attribute(ClientPtr client, - XvPortPtr port, +sna_video_textured_get_attribute(ScrnInfoPtr scrn, Atom attribute, - INT32 *value) + INT32 *value, + pointer data) { - struct sna_video *video = port->devPriv.ptr; + struct sna_video *video = data; if (attribute == xvBrightness) *value = video->brightness; @@ -126,14 +130,14 @@ sna_video_textured_get_attribute(ClientPtr client, return Success; } -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, +static void +sna_video_textured_best_size(ScrnInfoPtr scrn, + Bool motion, + short vid_w, short vid_h, + short drw_w, short drw_h, unsigned int *p_w, - unsigned int *p_h) + unsigned int *p_h, + pointer data) { if (vid_w > (drw_w << 1)) drw_w = vid_w >> 1; @@ -142,8 +146,6 @@ sna_video_textured_best_size(ClientPtr client, *p_w = drw_w; *p_h = drw_h; - - return Success; } /* @@ -160,49 +162,35 @@ 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(ScrnInfoPtr scrn, + short src_x, short src_y, + short drw_x, short drw_y, + short src_w, short src_h, + short drw_w, short drw_h, + int id, unsigned char *buf, + short width, short height, + Bool sync, RegionPtr clip, pointer data, + DrawablePtr drawable) { - struct sna_video *video = port->devPriv.ptr; - struct sna *sna = video->sna; + struct sna *sna = to_sna(scrn); + struct sna_video *video = data; struct sna_video_frame frame; - PixmapPtr pixmap = get_drawable_pixmap(draw); + PixmapPtr pixmap = get_drawable_pixmap(drawable); BoxRec dstBox; - RegionRec clip; xf86CrtcPtr crtc; bool flush = false; bool ret; - clip.extents.x1 = draw->x + drw_x; - clip.extents.y1 = draw->y + drw_y; - clip.extents.x2 = clip.extents.x1 + drw_w; - clip.extents.y2 = clip.extents.y1 + drw_h; - clip.data = NULL; - - RegionIntersect(&clip, &clip, gc->pCompositeClip); - if (!RegionNotEmpty(&clip)) - return Success; - DBG(("%s: src=(%d, %d),(%d, %d), dst=(%d, %d),(%d, %d), id=%d, sizep=%dx%d, sync?=%d\n", __FUNCTION__, src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h, - format->id, width, height, sync)); + id, width, height, sync)); DBG(("%s: region %d:(%d, %d), (%d, %d)\n", __FUNCTION__, - RegionNumRects(&clip), - clip.extents.x1, clip.extents.y1, - clip.extents.x2, clip.extents.y2)); + RegionNumRects(clip), + clip->extents.x1, clip->extents.y1, + clip->extents.x2, clip->extents.y2)); if (buf == 0) { DBG(("%s: garbage video buffer\n", __FUNCTION__)); @@ -215,16 +203,16 @@ sna_video_textured_put_image(ClientPtr client, return BadAlloc; } - sna_video_frame_init(sna, video, format->id, width, height, &frame); + sna_video_frame_init(sna, video, id, width, height, &frame); - if (!sna_video_clip_helper(sna->scrn, video, &frame, + if (!sna_video_clip_helper(scrn, video, &frame, &crtc, &dstBox, - src_x, src_y, drw_x + draw->x, drw_y + draw->y, + src_x, src_y, drw_x, drw_y, src_w, src_h, drw_w, drw_h, - &clip)) + clip)) return Success; - if (xvmc_passthrough(format->id)) { + if (xvmc_passthrough(id)) { DBG(("%s: using passthough, name=%d\n", __FUNCTION__, *(uint32_t *)buf)); @@ -247,19 +235,19 @@ sna_video_textured_put_image(ClientPtr client, } } - if (crtc && sync && video->SyncToVblank != 0 && + if (crtc && video->SyncToVblank != 0 && sna_pixmap_is_scanout(sna, pixmap)) { kgem_set_mode(&sna->kgem, KGEM_RENDER, sna_pixmap(pixmap)->gpu_bo); flush = sna_wait_for_scanline(sna, pixmap, crtc, - &clip.extents); + &clip->extents); } ret = Success; - if (!sna->render.video(sna, video, &frame, &clip, pixmap)) { + if (!sna->render.video(sna, video, &frame, clip, pixmap)) { DBG(("%s: failed to render video\n", __FUNCTION__)); ret = BadAlloc; } else - DamageDamageRegion(draw, &clip); + DamageDamageRegion(drawable, clip); kgem_bo_destroy(&sna->kgem, frame.bo); @@ -269,19 +257,14 @@ sna_video_textured_put_image(ClientPtr client, if (flush) kgem_submit(&sna->kgem); - RegionUninit(&clip); - return ret; } 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(ScrnInfoPtr scrn, + int id, + unsigned short *w, unsigned short *h, + int *pitches, int *offsets) { int size, tmp; @@ -294,7 +277,7 @@ sna_video_textured_query(ClientPtr client, if (offsets) offsets[0] = 0; - switch (format->id) { + switch (id) { /* IA44 is for XvMC only */ case FOURCC_IA44: case FOURCC_AI44: @@ -339,73 +322,87 @@ sna_video_textured_query(ClientPtr client, return size; } -void sna_video_textured_setup(struct sna *sna, ScreenPtr screen) +XF86VideoAdaptorPtr sna_video_textured_setup(struct sna *sna, + ScreenPtr screen) { - XvAdaptorPtr adaptor; + XF86VideoAdaptorPtr adaptor; + XF86AttributePtr attrs; struct sna_video *video; + DevUnion *devUnions; int nports = 16, i; if (!sna->render.video) { - xf86DrvMsg(sna->scrn->scrnIndex, X_INFO, + xf86DrvMsg(sna->scrn->scrnIndex, X_WARNING, "Textured video not supported on this hardware\n"); - return; + return NULL; } if (wedged(sna)) { xf86DrvMsg(sna->scrn->scrnIndex, X_WARNING, "cannot enable XVideo whilst the GPU is wedged\n"); - return; + return NULL; } - adaptor = sna_xv_adaptor_alloc(sna); - if (adaptor == NULL) - return; - + adaptor = calloc(1, sizeof(XF86VideoAdaptorRec)); video = calloc(nports, sizeof(struct sna_video)); - if ( video == NULL) { - sna->xv.num_adaptors--; + devUnions = calloc(nports, sizeof(DevUnion)); +#if NUM_TEXTURED_ATTRIBUTES + attrs = calloc(NUM_TEXTURED_ATTRIBUTES, sizeof(XF86AttributeRec)); + if (adaptor == NULL || + video == NULL || + devUnions == NULL || + attrs == NULL) { + free(adaptor); free(video); - return; + free(devUnions); + free(attrs); + return NULL; + } +#else + if (adaptor == NULL || video == NULL || devUnions == NULL) { + free(adaptor); + free(video); + free(devUnions); + return NULL; } + attrs = NULL; +#endif - adaptor->type = XvInputMask | XvImageMask; - adaptor->pScreen = screen; + adaptor->type = XvWindowMask | XvInputMask | XvImageMask; + adaptor->flags = 0; adaptor->name = "Intel(R) Textured Video"; adaptor->nEncodings = 1; - adaptor->pEncodings = xnfalloc(sizeof(XvEncodingRec)); + adaptor->pEncodings = xnfalloc(sizeof(XF86VideoEncodingRec)); adaptor->pEncodings[0].id = 0; - adaptor->pEncodings[0].pScreen = screen; adaptor->pEncodings[0].name = "XV_IMAGE"; adaptor->pEncodings[0].width = sna->render.max_3d_size; adaptor->pEncodings[0].height = sna->render.max_3d_size; adaptor->pEncodings[0].rate.numerator = 1; adaptor->pEncodings[0].rate.denominator = 1; adaptor->nFormats = NUM_FORMATS; - adaptor->pFormats = Formats; + adaptor->pFormats = (XF86VideoFormatPtr)Formats; + adaptor->nPorts = nports; + adaptor->pPortPrivates = devUnions; adaptor->nAttributes = NUM_TEXTURED_ATTRIBUTES; - adaptor->pAttributes = TexturedAttributes; + adaptor->pAttributes = attrs; + memcpy(attrs, TexturedAttributes, + NUM_TEXTURED_ATTRIBUTES * sizeof(XF86AttributeRec)); adaptor->nImages = ARRAY_SIZE(Images); - adaptor->pImages = Images; - adaptor->ddAllocatePort = sna_xv_alloc_port; - adaptor->ddFreePort = sna_xv_free_port; - adaptor->ddPutVideo = NULL; - adaptor->ddPutStill = NULL; - adaptor->ddGetVideo = NULL; - adaptor->ddGetStill = NULL; - adaptor->ddStopVideo = sna_video_textured_stop; - adaptor->ddSetPortAttribute = sna_video_textured_set_attribute; - adaptor->ddGetPortAttribute = sna_video_textured_get_attribute; - adaptor->ddQueryBestSize = sna_video_textured_best_size; - adaptor->ddPutImage = sna_video_textured_put_image; - adaptor->ddQueryImageAttributes = sna_video_textured_query; + adaptor->pImages = (XF86ImagePtr)Images; + adaptor->PutVideo = NULL; + adaptor->PutStill = NULL; + adaptor->GetVideo = NULL; + adaptor->GetStill = NULL; + adaptor->StopVideo = sna_video_textured_stop; + adaptor->SetPortAttribute = sna_video_textured_set_attribute; + adaptor->GetPortAttribute = sna_video_textured_get_attribute; + adaptor->QueryBestSize = sna_video_textured_best_size; + adaptor->PutImage = sna_video_textured_put_image; + adaptor->QueryImageAttributes = sna_video_textured_query; - adaptor->nPorts = nports; - adaptor->pPorts = calloc(nports, sizeof(XvPortRec)); for (i = 0; i < nports; i++) { struct sna_video *v = &video[i]; - XvPortPtr port = &adaptor->pPorts[i]; - v->sna = sna; v->textured = true; v->alignment = 4; v->rotation = RR_Rotate_0; @@ -414,22 +411,12 @@ void sna_video_textured_setup(struct sna *sna, ScreenPtr screen) /* gotta uninit this someplace, XXX: shouldn't be necessary for textured */ RegionNull(&v->clip); - port->id = FakeClientID(0); - AddResource(port->id, XvGetRTPort(), port); - - port->pAdaptor = adaptor; - port->pNotify = NULL; - port->pDraw = NULL; - port->client = NULL; - port->grab.client = NULL; - port->time = currentTime; - port->devPriv.ptr = v; - - port++; + adaptor->pPortPrivates[i].ptr = v; } - adaptor->base_id = adaptor->pPorts[0].id; xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); xvContrast = MAKE_ATOM("XV_CONTRAST"); xvSyncToVblank = MAKE_ATOM("XV_SYNC_TO_VBLANK"); + + return adaptor; } |