diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-04-09 20:43:19 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-04-10 12:17:29 +0100 |
commit | 092e30de8a3476ab99446264edaf9b250a41736b (patch) | |
tree | b7604b8eadeca4fa7e4f821c27b278dd7c824a7b /src | |
parent | 540802595fee7f8b2c73e74c2b44e9a21f6471ae (diff) |
sna/xvmc: Wrap each output adaptor
Each of the overlay, sprite and textured video can support XvMC
passthrough, so we need to setup an XvMC adaptor for each of our Xv
adaptors.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/sna/sna_video.c | 10 | ||||
-rw-r--r-- | src/sna/sna_video_hwmc.c | 73 | ||||
-rw-r--r-- | src/sna/sna_video_hwmc.h | 4 |
3 files changed, 43 insertions, 44 deletions
diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index a0eb0f4e..6d067c76 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -66,11 +66,8 @@ #define _SNA_XVMC_SERVER_ #include "sna_video_hwmc.h" #else -static inline bool sna_video_xvmc_setup(struct sna *sna, - ScreenPtr ptr, - XF86VideoAdaptorPtr target) +static inline void sna_video_xvmc_setup(struct sna *sna, ScreenPtr ptr) { - return false; } #endif @@ -574,9 +571,8 @@ void sna_video_init(struct sna *sna, ScreenPtr screen) adaptors[num_adaptors++] = overlay; if (num_adaptors) { - Bool ok = xf86XVScreenInit(screen, adaptors, num_adaptors); - if (ok && textured) - sna_video_xvmc_setup(sna, screen, textured); + 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"); diff --git a/src/sna/sna_video_hwmc.c b/src/sna/sna_video_hwmc.c index b3e065d9..573fda58 100644 --- a/src/sna/sna_video_hwmc.c +++ b/src/sna/sna_video_hwmc.c @@ -197,14 +197,13 @@ static XvMCSurfaceInfoPtr surface_info_vld[] = { /* check chip type and load xvmc driver */ Bool sna_video_xvmc_setup(struct sna *sna, - ScreenPtr screen, - XF86VideoAdaptorPtr target) + ScreenPtr screen) { XvMCAdaptorRec *adaptors; XvScreenPtr xv; const char *name; char bus[64]; - int i; + int i, j; if (!xf86LoaderCheckSymbol("XvMCScreenInit")) return FALSE; @@ -217,43 +216,42 @@ Bool sna_video_xvmc_setup(struct sna *sna, if (sna->kgem.gen >= 060) return FALSE; - adaptors = calloc(1, sizeof(XvMCAdaptorRec)); + xv = dixLookupPrivate(&screen->devPrivates, XF86XvScreenKey); + + adaptors = calloc(xv->nAdaptors, sizeof(XvMCAdaptorRec)); if (adaptors == NULL) return FALSE; - xv = dixLookupPrivate(&screen->devPrivates, XF86XvScreenKey); - for (i = 0; i< xv->nAdaptors;i++) { - if (strcmp(xv->pAdaptors[i].name, target->name) == 0) { - adaptors->xv_adaptor = &xv->pAdaptors[i]; - break; + for (i = j = 0; i< xv->nAdaptors;i++) { + if (strncmp(xv->pAdaptors[i].name, "Intel(R)", 8)) + continue; + + adaptors[j].xv_adaptor = &xv->pAdaptors[i]; + + 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[j].num_surfaces = ARRAY_SIZE(surface_info_vld); + adaptors[j].surfaces = surface_info_vld; + } else if (sna->kgem.gen >= 040) { + adaptors[j].num_surfaces = ARRAY_SIZE(surface_info_i965); + adaptors[j].surfaces = surface_info_i965; + } else { + adaptors[j].num_surfaces = ARRAY_SIZE(surface_info_i915); + adaptors[j].surfaces = surface_info_i915; } - } - assert(adaptors->xv_adaptor); - - adaptors->num_subpictures = 0; - adaptors->subpictures = NULL; - adaptors->CreateContext = create_context; - adaptors->DestroyContext = destroy_context; - adaptors->CreateSurface = create_surface; - adaptors->DestroySurface = destroy_surface; - adaptors->CreateSubpicture = create_subpicture; - adaptors->DestroySubpicture = destroy_subpicture; - - if (sna->kgem.gen >= 045) { - name = "xvmc_vld", - adaptors->num_surfaces = ARRAY_SIZE(surface_info_vld); - adaptors->surfaces = surface_info_vld; - } else if (sna->kgem.gen >= 040) { - name = "i965_xvmc", - adaptors->num_surfaces = ARRAY_SIZE(surface_info_i965); - adaptors->surfaces = surface_info_i965; - } else { - name = "i915_xvmc", - adaptors->num_surfaces = ARRAY_SIZE(surface_info_i915); - adaptors->surfaces = surface_info_i915; + + j++; } - if (XvMCScreenInit(screen, 1, adaptors) != Success) { + if (XvMCScreenInit(screen, j, adaptors) != Success) { xf86DrvMsg(sna->scrn->scrnIndex, X_INFO, "[XvMC] Failed to initialize XvMC.\n"); free(adaptors); @@ -268,8 +266,15 @@ Bool sna_video_xvmc_setup(struct sna *sna, SNA_XVMC_MAJOR, SNA_XVMC_MINOR, SNA_XVMC_PATCHLEVEL); + if (sna->kgem.gen >= 045) + name = "xvmc_vld"; + else if (sna->kgem.gen >= 040) + name = "i965_xvmc"; + else + name = "i915_xvmc"; 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 44de456e..8b0d2cdf 100644 --- a/src/sna/sna_video_hwmc.h +++ b/src/sna/sna_video_hwmc.h @@ -40,9 +40,7 @@ #ifdef _SNA_XVMC_SERVER_ #include <xf86xvmc.h> -Bool sna_video_xvmc_setup(struct sna *sna, - ScreenPtr screen, - XF86VideoAdaptorPtr target); +Bool sna_video_xvmc_setup(struct sna *sna, ScreenPtr screen); #endif #endif |