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>
This commit is contained in:
Chris Wilson 2013-04-09 20:43:19 +01:00
parent 540802595f
commit 092e30de8a
3 changed files with 42 additions and 43 deletions

View File

@ -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");

View File

@ -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;
}

View File

@ -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