summaryrefslogtreecommitdiff
path: root/Xext
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-04-30 12:40:53 -0700
committerKeith Packard <keithp@keithp.com>2010-04-30 12:40:53 -0700
commit986d46144b183a36b4e98aed95eca0c55a8b4251 (patch)
tree2c82ce4ec7e20d85a04b6e659716fdf6604f9985 /Xext
parenta974c8e7cba40c8d7d1b91e07de8c414627b71a2 (diff)
parentb5b8f91b82d7b150c926dd3fecee6c3aafff6e39 (diff)
Merge remote branch 'jamey/for-keith'
Conflicts: hw/xfree86/common/xf86xv.c
Diffstat (limited to 'Xext')
-rw-r--r--Xext/xvdisp.c147
1 files changed, 64 insertions, 83 deletions
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index b6fc34ff9..4345672ab 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -1850,110 +1850,91 @@ XineramaXvPutStill(ClientPtr client)
return result;
}
+static Bool
+isImageAdaptor(XvAdaptorPtr pAdapt)
+{
+ return (pAdapt->type & XvImageMask) && (pAdapt->nImages > 0);
+}
+
+static Bool
+hasOverlay(XvAdaptorPtr pAdapt)
+{
+ int i;
+ for(i = 0; i < pAdapt->nAttributes; i++)
+ if(!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY"))
+ return TRUE;
+ return FALSE;
+}
+
+static XvAdaptorPtr
+matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay)
+{
+ int i;
+ XvScreenPtr xvsp = dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey());
+ /* Do not try to go on if xv is not supported on this screen */
+ if(xvsp == NULL)
+ return NULL;
+
+ /* if the adaptor has the same name it's a perfect match */
+ for(i = 0; i < xvsp->nAdaptors; i++) {
+ XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
+ if(!strcmp(refAdapt->name, pAdapt->name))
+ return pAdapt;
+ }
+
+ /* otherwise we only look for XvImage adaptors */
+ if(!isImageAdaptor(refAdapt))
+ return NULL;
+
+ /* prefer overlay/overlay non-overlay/non-overlay pairing */
+ for(i = 0; i < xvsp->nAdaptors; i++) {
+ XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
+ if(isImageAdaptor(pAdapt) && isOverlay == hasOverlay(pAdapt))
+ return pAdapt;
+ }
+
+ /* but we'll take any XvImage pairing if we can get it */
+ for(i = 0; i < xvsp->nAdaptors; i++) {
+ XvAdaptorPtr pAdapt = xvsp->pAdaptors + i;
+ if(isImageAdaptor(pAdapt))
+ return pAdapt;
+ }
+ return NULL;
+}
+
void XineramifyXv(void)
{
- ScreenPtr pScreen, screen0 = screenInfo.screens[0];
- XvScreenPtr xvsp0 = (XvScreenPtr)dixLookupPrivate(&screen0->devPrivates,
- XvGetScreenKey());
- XvAdaptorPtr refAdapt, pAdapt;
- XvAttributePtr pAttr;
- XvScreenPtr xvsp;
- Bool isOverlay, hasOverlay;
- PanoramiXRes *port;
+ XvScreenPtr xvsp0 = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey());
XvAdaptorPtr MatchingAdaptors[MAXSCREENS];
- int i, j, k, l;
+ int i, j, k;
XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort");
if (!xvsp0 || !XvXRTPort) return;
for(i = 0; i < xvsp0->nAdaptors; i++) {
- refAdapt = xvsp0->pAdaptors + i;
+ Bool isOverlay;
+ XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i;
+ if(!(refAdapt->type & XvInputMask)) continue;
- bzero(MatchingAdaptors, sizeof(XvAdaptorPtr) * MAXSCREENS);
-
MatchingAdaptors[0] = refAdapt;
-
- if(!(refAdapt->type & XvInputMask)) continue;
-
- isOverlay = FALSE;
- for(j = 0; j < refAdapt->nAttributes; j++) {
- pAttr = refAdapt->pAttributes + j;
- if(!strcmp(pAttr->name, "XV_COLORKEY")) {
- isOverlay = TRUE;
- break;
- }
- }
-
- for(j = 1; j < PanoramiXNumScreens; j++) {
- pScreen = screenInfo.screens[j];
- xvsp = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
- XvGetScreenKey());
- /* Do not try to go on if xv is not supported on this screen */
- if (xvsp==NULL) continue ;
-
- /* if the adaptor has the same name it's a perfect match */
- for(k = 0; k < xvsp->nAdaptors; k++) {
- pAdapt = xvsp->pAdaptors + k;
- if(!strcmp(refAdapt->name, pAdapt->name)) {
- MatchingAdaptors[j] = pAdapt;
- break;
- }
- }
- if(MatchingAdaptors[j]) continue; /* found it */
-
- /* otherwise we only look for XvImage adaptors */
- if(!(refAdapt->type & XvImageMask)) continue;
- if(refAdapt->nImages <= 0) continue;
-
- /* prefer overlay/overlay non-overlay/non-overlay pairing */
- for(k = 0; k < xvsp->nAdaptors; k++) {
- pAdapt = xvsp->pAdaptors + k;
- if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
- hasOverlay = FALSE;
- for(l = 0; l < pAdapt->nAttributes; l++) {
- if(!strcmp(pAdapt->pAttributes[l].name, "XV_COLORKEY")) {
- hasOverlay = TRUE;
- break;
- }
- }
- if(isOverlay && hasOverlay) {
- MatchingAdaptors[j] = pAdapt;
- break;
- }
- else if(!isOverlay && !hasOverlay) {
- MatchingAdaptors[j] = pAdapt;
- break;
- }
- }
- }
-
- if(MatchingAdaptors[j]) continue; /* found it */
-
- /* but we'll take any XvImage pairing if we can get it */
-
- for(k = 0; k < xvsp->nAdaptors; k++) {
- pAdapt = xvsp->pAdaptors + k;
- if((pAdapt->type & XvImageMask) && (pAdapt->nImages > 0)) {
- MatchingAdaptors[j] = pAdapt;
- break;
- }
- }
- }
+ isOverlay = hasOverlay(refAdapt);
+ for(j = 1; j < PanoramiXNumScreens; j++)
+ MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay);
/* now create a resource for each port */
for(j = 0; j < refAdapt->nPorts; j++) {
- if(!(port = xalloc(sizeof(PanoramiXRes))))
+ PanoramiXRes *port = xalloc(sizeof(PanoramiXRes));
+ if(!port)
break;
- port->info[0].id = MatchingAdaptors[0]->base_id + j;
- AddResource(port->info[0].id, XvXRTPort, port);
- for(k = 1; k < PanoramiXNumScreens; k++) {
+ for(k = 0; k < PanoramiXNumScreens; k++) {
if(MatchingAdaptors[k] && (MatchingAdaptors[k]->nPorts > j))
port->info[k].id = MatchingAdaptors[k]->base_id + j;
else
port->info[k].id = 0;
}
+ AddResource(port->info[0].id, XvXRTPort, port);
}
}