diff options
Diffstat (limited to 'Xext/xvdisp.c')
-rw-r--r-- | Xext/xvdisp.c | 2252 |
1 files changed, 1106 insertions, 1146 deletions
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c index 0795a1475..8abd51c11 100644 --- a/Xext/xvdisp.c +++ b/Xext/xvdisp.c @@ -55,215 +55,189 @@ unsigned long XvXRTPort; #endif static int -SWriteQueryExtensionReply( - ClientPtr client, - xvQueryExtensionReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swaps(&rep->version); - swaps(&rep->revision); - - (void)WriteToClient(client, sz_xvQueryExtensionReply, (char *)rep); +SWriteQueryExtensionReply(ClientPtr client, xvQueryExtensionReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swaps(&rep->version); + swaps(&rep->revision); + + (void) WriteToClient(client, sz_xvQueryExtensionReply, (char *) rep); - return Success; + return Success; } static int -SWriteQueryAdaptorsReply( - ClientPtr client, - xvQueryAdaptorsReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swaps(&rep->num_adaptors); - - (void)WriteToClient(client, sz_xvQueryAdaptorsReply, (char *)rep); +SWriteQueryAdaptorsReply(ClientPtr client, xvQueryAdaptorsReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swaps(&rep->num_adaptors); + + (void) WriteToClient(client, sz_xvQueryAdaptorsReply, (char *) rep); - return Success; + return Success; } static int -SWriteQueryEncodingsReply( - ClientPtr client, - xvQueryEncodingsReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swaps(&rep->num_encodings); - - (void)WriteToClient(client, sz_xvQueryEncodingsReply, (char *)rep); +SWriteQueryEncodingsReply(ClientPtr client, xvQueryEncodingsReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swaps(&rep->num_encodings); + + (void) WriteToClient(client, sz_xvQueryEncodingsReply, (char *) rep); - return Success; + return Success; } static int -SWriteAdaptorInfo( - ClientPtr client, - xvAdaptorInfo *pAdaptor -){ - swapl(&pAdaptor->base_id); - swaps(&pAdaptor->name_size); - swaps(&pAdaptor->num_ports); - swaps(&pAdaptor->num_formats); +SWriteAdaptorInfo(ClientPtr client, xvAdaptorInfo * pAdaptor) +{ + swapl(&pAdaptor->base_id); + swaps(&pAdaptor->name_size); + swaps(&pAdaptor->num_ports); + swaps(&pAdaptor->num_formats); - (void)WriteToClient(client, sz_xvAdaptorInfo, (char *)pAdaptor); + (void) WriteToClient(client, sz_xvAdaptorInfo, (char *) pAdaptor); - return Success; + return Success; } static int -SWriteEncodingInfo( - ClientPtr client, - xvEncodingInfo *pEncoding -){ - - swapl(&pEncoding->encoding); - swaps(&pEncoding->name_size); - swaps(&pEncoding->width); - swaps(&pEncoding->height); - swapl(&pEncoding->rate.numerator); - swapl(&pEncoding->rate.denominator); - (void)WriteToClient(client, sz_xvEncodingInfo, (char *)pEncoding); - - return Success; +SWriteEncodingInfo(ClientPtr client, xvEncodingInfo * pEncoding) +{ + + swapl(&pEncoding->encoding); + swaps(&pEncoding->name_size); + swaps(&pEncoding->width); + swaps(&pEncoding->height); + swapl(&pEncoding->rate.numerator); + swapl(&pEncoding->rate.denominator); + (void) WriteToClient(client, sz_xvEncodingInfo, (char *) pEncoding); + + return Success; } static int -SWriteFormat( - ClientPtr client, - xvFormat *pFormat -){ - swapl(&pFormat->visual); - (void)WriteToClient(client, sz_xvFormat, (char *)pFormat); +SWriteFormat(ClientPtr client, xvFormat * pFormat) +{ + swapl(&pFormat->visual); + (void) WriteToClient(client, sz_xvFormat, (char *) pFormat); - return Success; + return Success; } static int -SWriteAttributeInfo( - ClientPtr client, - xvAttributeInfo *pAtt -){ - swapl(&pAtt->flags); - swapl(&pAtt->size); - swapl(&pAtt->min); - swapl(&pAtt->max); - (void)WriteToClient(client, sz_xvAttributeInfo, (char *)pAtt); +SWriteAttributeInfo(ClientPtr client, xvAttributeInfo * pAtt) +{ + swapl(&pAtt->flags); + swapl(&pAtt->size); + swapl(&pAtt->min); + swapl(&pAtt->max); + (void) WriteToClient(client, sz_xvAttributeInfo, (char *) pAtt); - return Success; + return Success; } static int -SWriteImageFormatInfo( - ClientPtr client, - xvImageFormatInfo *pImage -){ - swapl(&pImage->id); - swapl(&pImage->red_mask); - swapl(&pImage->green_mask); - swapl(&pImage->blue_mask); - swapl(&pImage->y_sample_bits); - swapl(&pImage->u_sample_bits); - swapl(&pImage->v_sample_bits); - swapl(&pImage->horz_y_period); - swapl(&pImage->horz_u_period); - swapl(&pImage->horz_v_period); - swapl(&pImage->vert_y_period); - swapl(&pImage->vert_u_period); - swapl(&pImage->vert_v_period); - - (void)WriteToClient(client, sz_xvImageFormatInfo, (char *)pImage); - - return Success; +SWriteImageFormatInfo(ClientPtr client, xvImageFormatInfo * pImage) +{ + swapl(&pImage->id); + swapl(&pImage->red_mask); + swapl(&pImage->green_mask); + swapl(&pImage->blue_mask); + swapl(&pImage->y_sample_bits); + swapl(&pImage->u_sample_bits); + swapl(&pImage->v_sample_bits); + swapl(&pImage->horz_y_period); + swapl(&pImage->horz_u_period); + swapl(&pImage->horz_v_period); + swapl(&pImage->vert_y_period); + swapl(&pImage->vert_u_period); + swapl(&pImage->vert_v_period); + + (void) WriteToClient(client, sz_xvImageFormatInfo, (char *) pImage); + + return Success; } static int -SWriteGrabPortReply( - ClientPtr client, - xvGrabPortReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); +SWriteGrabPortReply(ClientPtr client, xvGrabPortReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); - (void)WriteToClient(client, sz_xvGrabPortReply, (char *)rep); + (void) WriteToClient(client, sz_xvGrabPortReply, (char *) rep); - return Success; + return Success; } static int -SWriteGetPortAttributeReply( - ClientPtr client, - xvGetPortAttributeReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swapl(&rep->value); +SWriteGetPortAttributeReply(ClientPtr client, xvGetPortAttributeReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swapl(&rep->value); - (void)WriteToClient(client, sz_xvGetPortAttributeReply, (char *)rep); + (void) WriteToClient(client, sz_xvGetPortAttributeReply, (char *) rep); - return Success; + return Success; } static int -SWriteQueryBestSizeReply( - ClientPtr client, - xvQueryBestSizeReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swaps(&rep->actual_width); - swaps(&rep->actual_height); +SWriteQueryBestSizeReply(ClientPtr client, xvQueryBestSizeReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swaps(&rep->actual_width); + swaps(&rep->actual_height); - (void)WriteToClient(client, sz_xvQueryBestSizeReply, (char *)rep); + (void) WriteToClient(client, sz_xvQueryBestSizeReply, (char *) rep); - return Success; + return Success; } static int -SWriteQueryPortAttributesReply( - ClientPtr client, - xvQueryPortAttributesReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swapl(&rep->num_attributes); - swapl(&rep->text_size); +SWriteQueryPortAttributesReply(ClientPtr client, + xvQueryPortAttributesReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swapl(&rep->num_attributes); + swapl(&rep->text_size); - (void)WriteToClient(client, sz_xvQueryPortAttributesReply, (char *)rep); + (void) WriteToClient(client, sz_xvQueryPortAttributesReply, (char *) rep); - return Success; + return Success; } static int -SWriteQueryImageAttributesReply( - ClientPtr client, - xvQueryImageAttributesReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swapl(&rep->num_planes); - swapl(&rep->data_size); - swaps(&rep->width); - swaps(&rep->height); +SWriteQueryImageAttributesReply(ClientPtr client, + xvQueryImageAttributesReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swapl(&rep->num_planes); + swapl(&rep->data_size); + swaps(&rep->width); + swaps(&rep->height); - (void)WriteToClient(client, sz_xvQueryImageAttributesReply, (char *)rep); + (void) WriteToClient(client, sz_xvQueryImageAttributesReply, (char *) rep); - return Success; + return Success; } static int -SWriteListImageFormatsReply( - ClientPtr client, - xvListImageFormatsReply *rep -){ - swaps(&rep->sequenceNumber); - swapl(&rep->length); - swapl(&rep->num_formats); +SWriteListImageFormatsReply(ClientPtr client, xvListImageFormatsReply * rep) +{ + swaps(&rep->sequenceNumber); + swapl(&rep->length); + swapl(&rep->num_formats); - (void)WriteToClient(client, sz_xvListImageFormatsReply, (char *)rep); + (void) WriteToClient(client, sz_xvListImageFormatsReply, (char *) rep); - return Success; + return Success; } #define _WriteQueryAdaptorsReply(_c,_d) \ @@ -328,662 +302,638 @@ SWriteListImageFormatsReply( static int ProcXvQueryExtension(ClientPtr client) { - xvQueryExtensionReply rep; - /* REQUEST(xvQueryExtensionReq); */ - REQUEST_SIZE_MATCH(xvQueryExtensionReq); + xvQueryExtensionReply rep; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.version = XvVersion; - rep.revision = XvRevision; + /* REQUEST(xvQueryExtensionReq); */ + REQUEST_SIZE_MATCH(xvQueryExtensionReq); - _WriteQueryExtensionReply(client, &rep); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.version = XvVersion; + rep.revision = XvRevision; - return Success; + _WriteQueryExtensionReply(client, &rep); + + return Success; } static int ProcXvQueryAdaptors(ClientPtr client) { - xvFormat format; - xvAdaptorInfo ainfo; - xvQueryAdaptorsReply rep; - int totalSize, na, nf, rc; - int nameSize; - XvAdaptorPtr pa; - XvFormatPtr pf; - WindowPtr pWin; - ScreenPtr pScreen; - XvScreenPtr pxvs; - - REQUEST(xvQueryAdaptorsReq); - REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); - - rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); - if (rc != Success) - return rc; - - pScreen = pWin->drawable.pScreen; - pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, - XvGetScreenKey()); - if (!pxvs) - { - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_adaptors = 0; - rep.length = 0; - - _WriteQueryAdaptorsReply(client, &rep); - - return Success; + xvFormat format; + xvAdaptorInfo ainfo; + xvQueryAdaptorsReply rep; + int totalSize, na, nf, rc; + int nameSize; + XvAdaptorPtr pa; + XvFormatPtr pf; + WindowPtr pWin; + ScreenPtr pScreen; + XvScreenPtr pxvs; + + REQUEST(xvQueryAdaptorsReq); + REQUEST_SIZE_MATCH(xvQueryAdaptorsReq); + + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, + XvGetScreenKey()); + if (!pxvs) { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_adaptors = 0; + rep.length = 0; + + _WriteQueryAdaptorsReply(client, &rep); + + return Success; } - (* pxvs->ddQueryAdaptors)(pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors); + (*pxvs->ddQueryAdaptors) (pScreen, &pxvs->pAdaptors, &pxvs->nAdaptors); - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_adaptors = pxvs->nAdaptors; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_adaptors = pxvs->nAdaptors; - /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ + /* CALCULATE THE TOTAL SIZE OF THE REPLY IN BYTES */ - totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo; + totalSize = pxvs->nAdaptors * sz_xvAdaptorInfo; - /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */ + /* FOR EACH ADPATOR ADD UP THE BYTES FOR ENCODINGS AND FORMATS */ - na = pxvs->nAdaptors; - pa = pxvs->pAdaptors; - while (na--) - { - totalSize += pad_to_int32(strlen(pa->name)); - totalSize += pa->nFormats * sz_xvFormat; - pa++; + na = pxvs->nAdaptors; + pa = pxvs->pAdaptors; + while (na--) { + totalSize += pad_to_int32(strlen(pa->name)); + totalSize += pa->nFormats * sz_xvFormat; + pa++; } - rep.length = bytes_to_int32(totalSize); + rep.length = bytes_to_int32(totalSize); - _WriteQueryAdaptorsReply(client, &rep); + _WriteQueryAdaptorsReply(client, &rep); - na = pxvs->nAdaptors; - pa = pxvs->pAdaptors; - while (na--) - { + na = pxvs->nAdaptors; + pa = pxvs->pAdaptors; + while (na--) { - ainfo.base_id = pa->base_id; - ainfo.num_ports = pa->nPorts; - ainfo.type = pa->type; - ainfo.name_size = nameSize = strlen(pa->name); - ainfo.num_formats = pa->nFormats; + ainfo.base_id = pa->base_id; + ainfo.num_ports = pa->nPorts; + ainfo.type = pa->type; + ainfo.name_size = nameSize = strlen(pa->name); + ainfo.num_formats = pa->nFormats; - _WriteAdaptorInfo(client, &ainfo); + _WriteAdaptorInfo(client, &ainfo); - WriteToClient(client, nameSize, pa->name); + WriteToClient(client, nameSize, pa->name); - nf = pa->nFormats; - pf = pa->pFormats; - while (nf--) - { - format.depth = pf->depth; - format.visual = pf->visual; - _WriteFormat(client, &format); - pf++; - } + nf = pa->nFormats; + pf = pa->pFormats; + while (nf--) { + format.depth = pf->depth; + format.visual = pf->visual; + _WriteFormat(client, &format); + pf++; + } - pa++; + pa++; } - return Success; + return Success; } static int ProcXvQueryEncodings(ClientPtr client) { - xvEncodingInfo einfo; - xvQueryEncodingsReply rep; - int totalSize; - int nameSize; - XvPortPtr pPort; - int ne; - XvEncodingPtr pe; - int status; - - REQUEST(xvQueryEncodingsReq); - REQUEST_SIZE_MATCH(xvQueryEncodingsReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + xvEncodingInfo einfo; + xvQueryEncodingsReply rep; + int totalSize; + int nameSize; + XvPortPtr pPort; + int ne; + XvEncodingPtr pe; + int status; + + REQUEST(xvQueryEncodingsReq); + REQUEST_SIZE_MATCH(xvQueryEncodingsReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_encodings = pPort->pAdaptor->nEncodings; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_encodings = pPort->pAdaptor->nEncodings; - /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ + /* FOR EACH ENCODING ADD UP THE BYTES FOR ENCODING NAMES */ - ne = pPort->pAdaptor->nEncodings; - pe = pPort->pAdaptor->pEncodings; - totalSize = ne * sz_xvEncodingInfo; - while (ne--) - { - totalSize += pad_to_int32(strlen(pe->name)); - pe++; + ne = pPort->pAdaptor->nEncodings; + pe = pPort->pAdaptor->pEncodings; + totalSize = ne * sz_xvEncodingInfo; + while (ne--) { + totalSize += pad_to_int32(strlen(pe->name)); + pe++; } - rep.length = bytes_to_int32(totalSize); - - _WriteQueryEncodingsReply(client, &rep); - - ne = pPort->pAdaptor->nEncodings; - pe = pPort->pAdaptor->pEncodings; - while (ne--) - { - einfo.encoding = pe->id; - einfo.name_size = nameSize = strlen(pe->name); - einfo.width = pe->width; - einfo.height = pe->height; - einfo.rate.numerator = pe->rate.numerator; - einfo.rate.denominator = pe->rate.denominator; - _WriteEncodingInfo(client, &einfo); - WriteToClient(client, nameSize, pe->name); - pe++; + rep.length = bytes_to_int32(totalSize); + + _WriteQueryEncodingsReply(client, &rep); + + ne = pPort->pAdaptor->nEncodings; + pe = pPort->pAdaptor->pEncodings; + while (ne--) { + einfo.encoding = pe->id; + einfo.name_size = nameSize = strlen(pe->name); + einfo.width = pe->width; + einfo.height = pe->height; + einfo.rate.numerator = pe->rate.numerator; + einfo.rate.denominator = pe->rate.denominator; + _WriteEncodingInfo(client, &einfo); + WriteToClient(client, nameSize, pe->name); + pe++; } - return Success; + return Success; } static int ProcXvPutVideo(ClientPtr client) { - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; - REQUEST(xvPutVideoReq); - REQUEST_SIZE_MATCH(xvPutVideoReq); + REQUEST(xvPutVideoReq); + REQUEST_SIZE_MATCH(xvPutVideoReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!(pPort->pAdaptor->type & XvInputMask) || - !(pPort->pAdaptor->type & XvVideoMask)) - { - client->errorValue = stuff->port; - return BadMatch; + if (!(pPort->pAdaptor->type & XvInputMask) || + !(pPort->pAdaptor->type & XvVideoMask)) { + client->errorValue = stuff->port; + return BadMatch; } - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) { + return status; } - return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiPutVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int ProcXvPutStill(ClientPtr client) { - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; - REQUEST(xvPutStillReq); - REQUEST_SIZE_MATCH(xvPutStillReq); + REQUEST(xvPutStillReq); + REQUEST_SIZE_MATCH(xvPutStillReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!(pPort->pAdaptor->type & XvInputMask) || - !(pPort->pAdaptor->type & XvStillMask)) - { - client->errorValue = stuff->port; - return BadMatch; + if (!(pPort->pAdaptor->type & XvInputMask) || + !(pPort->pAdaptor->type & XvStillMask)) { + client->errorValue = stuff->port; + return BadMatch; } - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) { + return status; } - return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiPutStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int ProcXvGetVideo(ClientPtr client) { - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; - REQUEST(xvGetVideoReq); - REQUEST_SIZE_MATCH(xvGetVideoReq); + REQUEST(xvGetVideoReq); + REQUEST_SIZE_MATCH(xvGetVideoReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!(pPort->pAdaptor->type & XvOutputMask) || - !(pPort->pAdaptor->type & XvVideoMask)) - { - client->errorValue = stuff->port; - return BadMatch; + if (!(pPort->pAdaptor->type & XvOutputMask) || + !(pPort->pAdaptor->type & XvVideoMask)) { + client->errorValue = stuff->port; + return BadMatch; } - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) { + return status; } - return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiGetVideo(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int ProcXvGetStill(ClientPtr client) { - DrawablePtr pDraw; - XvPortPtr pPort; - GCPtr pGC; - int status; + DrawablePtr pDraw; + XvPortPtr pPort; + GCPtr pGC; + int status; - REQUEST(xvGetStillReq); - REQUEST_SIZE_MATCH(xvGetStillReq); + REQUEST(xvGetStillReq); + REQUEST_SIZE_MATCH(xvGetStillReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!(pPort->pAdaptor->type & XvOutputMask) || - !(pPort->pAdaptor->type & XvStillMask)) - { - client->errorValue = stuff->port; - return BadMatch; + if (!(pPort->pAdaptor->type & XvOutputMask) || + !(pPort->pAdaptor->type & XvStillMask)) { + client->errorValue = stuff->port; + return BadMatch; } - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) { + return status; } - return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, - stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h); + return XvdiGetStill(client, pDraw, pPort, pGC, stuff->vid_x, stuff->vid_y, + stuff->vid_w, stuff->vid_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h); } static int ProcXvSelectVideoNotify(ClientPtr client) { - DrawablePtr pDraw; - int rc; - REQUEST(xvSelectVideoNotifyReq); - REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); + DrawablePtr pDraw; + int rc; + + REQUEST(xvSelectVideoNotifyReq); + REQUEST_SIZE_MATCH(xvSelectVideoNotifyReq); - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixReceiveAccess); - if (rc != Success) - return rc; + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, + DixReceiveAccess); + if (rc != Success) + return rc; - return XvdiSelectVideoNotify(client, pDraw, stuff->onoff); + return XvdiSelectVideoNotify(client, pDraw, stuff->onoff); } static int ProcXvSelectPortNotify(ClientPtr client) { - int status; - XvPortPtr pPort; - REQUEST(xvSelectPortNotifyReq); - REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); + int status; + XvPortPtr pPort; + + REQUEST(xvSelectPortNotifyReq); + REQUEST_SIZE_MATCH(xvSelectPortNotifyReq); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - return XvdiSelectPortNotify(client, pPort, stuff->onoff); + return XvdiSelectPortNotify(client, pPort, stuff->onoff); } static int ProcXvGrabPort(ClientPtr client) { - int result, status; - XvPortPtr pPort; - xvGrabPortReply rep; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); + int result, status; + XvPortPtr pPort; + xvGrabPortReply rep; - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + REQUEST(xvGrabPortReq); + REQUEST_SIZE_MATCH(xvGrabPortReq); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - status = XvdiGrabPort(client, pPort, stuff->time, &result); + status = XvdiGrabPort(client, pPort, stuff->time, &result); - if (status != Success) - { - return status; + if (status != Success) { + return status; } - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.result = result; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.result = result; - _WriteGrabPortReply(client, &rep); + _WriteGrabPortReply(client, &rep); - return Success; + return Success; } static int ProcXvUngrabPort(ClientPtr client) { - int status; - XvPortPtr pPort; - REQUEST(xvGrabPortReq); - REQUEST_SIZE_MATCH(xvGrabPortReq); + int status; + XvPortPtr pPort; + + REQUEST(xvGrabPortReq); + REQUEST_SIZE_MATCH(xvGrabPortReq); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - return XvdiUngrabPort(client, pPort, stuff->time); + return XvdiUngrabPort(client, pPort, stuff->time); } static int ProcXvStopVideo(ClientPtr client) { - int status, rc; - DrawablePtr pDraw; - XvPortPtr pPort; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); + int status, rc; + DrawablePtr pDraw; + XvPortPtr pPort; - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + REQUEST(xvStopVideoReq); + REQUEST_SIZE_MATCH(xvStopVideoReq); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); - if (rc != Success) - return rc; + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); + if (rc != Success) + return rc; - return XvdiStopVideo(client, pPort, pDraw); + return XvdiStopVideo(client, pPort, pDraw); } static int ProcXvSetPortAttribute(ClientPtr client) { - int status; - XvPortPtr pPort; - REQUEST(xvSetPortAttributeReq); - REQUEST_SIZE_MATCH(xvSetPortAttributeReq); + int status; + XvPortPtr pPort; - VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess); + REQUEST(xvSetPortAttributeReq); + REQUEST_SIZE_MATCH(xvSetPortAttributeReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixSetAttrAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!ValidAtom(stuff->attribute)) - { - client->errorValue = stuff->attribute; - return BadAtom; + if (!ValidAtom(stuff->attribute)) { + client->errorValue = stuff->attribute; + return BadAtom; } - status = XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value); + status = + XvdiSetPortAttribute(client, pPort, stuff->attribute, stuff->value); - if (status == BadMatch) - client->errorValue = stuff->attribute; - else - client->errorValue = stuff->value; + if (status == BadMatch) + client->errorValue = stuff->attribute; + else + client->errorValue = stuff->value; - return status; + return status; } static int ProcXvGetPortAttribute(ClientPtr client) { - INT32 value; - int status; - XvPortPtr pPort; - xvGetPortAttributeReply rep; - REQUEST(xvGetPortAttributeReq); - REQUEST_SIZE_MATCH(xvGetPortAttributeReq); + INT32 value; + int status; + XvPortPtr pPort; + xvGetPortAttributeReply rep; + + REQUEST(xvGetPortAttributeReq); + REQUEST_SIZE_MATCH(xvGetPortAttributeReq); - VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!ValidAtom(stuff->attribute)) - { - client->errorValue = stuff->attribute; - return BadAtom; + if (!ValidAtom(stuff->attribute)) { + client->errorValue = stuff->attribute; + return BadAtom; } - status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value); - if (status != Success) - { - client->errorValue = stuff->attribute; - return status; + status = XvdiGetPortAttribute(client, pPort, stuff->attribute, &value); + if (status != Success) { + client->errorValue = stuff->attribute; + return status; } - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; - rep.value = value; - - _WriteGetPortAttributeReply(client, &rep); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.value = value; - return Success; + _WriteGetPortAttributeReply(client, &rep); + + return Success; } static int ProcXvQueryBestSize(ClientPtr client) { - int status; - unsigned int actual_width, actual_height; - XvPortPtr pPort; - xvQueryBestSizeReply rep; - REQUEST(xvQueryBestSizeReq); - REQUEST_SIZE_MATCH(xvQueryBestSizeReq); + int status; + unsigned int actual_width, actual_height; + XvPortPtr pPort; + xvQueryBestSizeReply rep; + + REQUEST(xvQueryBestSizeReq); + REQUEST_SIZE_MATCH(xvQueryBestSizeReq); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = 0; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; - (* pPort->pAdaptor->ddQueryBestSize)(client, pPort, stuff->motion, - stuff->vid_w, stuff->vid_h, - stuff->drw_w, stuff->drw_h, - &actual_width, &actual_height); + (*pPort->pAdaptor->ddQueryBestSize) (client, pPort, stuff->motion, + stuff->vid_w, stuff->vid_h, + stuff->drw_w, stuff->drw_h, + &actual_width, &actual_height); - rep.actual_width = actual_width; - rep.actual_height = actual_height; - - _WriteQueryBestSizeReply(client, &rep); + rep.actual_width = actual_width; + rep.actual_height = actual_height; - return Success; -} + _WriteQueryBestSizeReply(client, &rep); + return Success; +} static int ProcXvQueryPortAttributes(ClientPtr client) { - int status, size, i; - XvPortPtr pPort; - XvAttributePtr pAtt; - xvQueryPortAttributesReply rep; - xvAttributeInfo Info; - REQUEST(xvQueryPortAttributesReq); - REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); + int status, size, i; + XvPortPtr pPort; + XvAttributePtr pAtt; + xvQueryPortAttributesReply rep; + xvAttributeInfo Info; - VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); + REQUEST(xvQueryPortAttributesReq); + REQUEST_SIZE_MATCH(xvQueryPortAttributesReq); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + VALIDATE_XV_PORT(stuff->port, pPort, DixGetAttrAccess); + + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_attributes = pPort->pAdaptor->nAttributes; - rep.text_size = 0; + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_attributes = pPort->pAdaptor->nAttributes; + rep.text_size = 0; - for(i = 0, pAtt = pPort->pAdaptor->pAttributes; - i < pPort->pAdaptor->nAttributes; i++, pAtt++) - { - rep.text_size += pad_to_int32(strlen(pAtt->name) + 1); - } + for (i = 0, pAtt = pPort->pAdaptor->pAttributes; + i < pPort->pAdaptor->nAttributes; i++, pAtt++) { + rep.text_size += pad_to_int32(strlen(pAtt->name) + 1); + } - rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo) - + rep.text_size; - rep.length >>= 2; + rep.length = (pPort->pAdaptor->nAttributes * sz_xvAttributeInfo) + + rep.text_size; + rep.length >>= 2; - _WriteQueryPortAttributesReply(client, &rep); + _WriteQueryPortAttributesReply(client, &rep); - for(i = 0, pAtt = pPort->pAdaptor->pAttributes; - i < pPort->pAdaptor->nAttributes; i++, pAtt++) - { - size = strlen(pAtt->name) + 1; /* pass the NULL */ - Info.flags = pAtt->flags; - Info.min = pAtt->min_value; - Info.max = pAtt->max_value; - Info.size = pad_to_int32(size); + for (i = 0, pAtt = pPort->pAdaptor->pAttributes; + i < pPort->pAdaptor->nAttributes; i++, pAtt++) { + size = strlen(pAtt->name) + 1; /* pass the NULL */ + Info.flags = pAtt->flags; + Info.min = pAtt->min_value; + Info.max = pAtt->max_value; + Info.size = pad_to_int32(size); - _WriteAttributeInfo(client, &Info); + _WriteAttributeInfo(client, &Info); - WriteToClient(client, size, pAtt->name); - } + WriteToClient(client, size, pAtt->name); + } - return Success; + return Success; } -static int +static int ProcXvPutImage(ClientPtr client) { - DrawablePtr pDraw; - XvPortPtr pPort; - XvImagePtr pImage = NULL; - GCPtr pGC; - int status, i, size; - CARD16 width, height; + DrawablePtr pDraw; + XvPortPtr pPort; + XvImagePtr pImage = NULL; + GCPtr pGC; + int status, i, size; + CARD16 width, height; - REQUEST(xvPutImageReq); - REQUEST_AT_LEAST_SIZE(xvPutImageReq); + REQUEST(xvPutImageReq); + REQUEST_AT_LEAST_SIZE(xvPutImageReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!(pPort->pAdaptor->type & XvImageMask) || - !(pPort->pAdaptor->type & XvInputMask)) - { - client->errorValue = stuff->port; - return BadMatch; + if (!(pPort->pAdaptor->type & XvImageMask) || + !(pPort->pAdaptor->type & XvInputMask)) { + client->errorValue = stuff->port; + return BadMatch; } - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) { + return status; } - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } + for (i = 0; i < pPort->pAdaptor->nImages; i++) { + if (pPort->pAdaptor->pImages[i].id == stuff->id) { + pImage = &(pPort->pAdaptor->pImages[i]); + break; + } + } + + if (!pImage) + return BadMatch; - if(!pImage) - return BadMatch; + width = stuff->width; + height = stuff->height; + size = (*pPort->pAdaptor->ddQueryImageAttributes) (client, + pPort, pImage, &width, + &height, NULL, NULL); + size += sizeof(xvPutImageReq); + size = bytes_to_int32(size); - width = stuff->width; - height = stuff->height; - size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, - pPort, pImage, &width, &height, NULL, NULL); - size += sizeof(xvPutImageReq); - size = bytes_to_int32(size); - - if((width < stuff->width) || (height < stuff->height)) - return BadValue; + if ((width < stuff->width) || (height < stuff->height)) + return BadValue; - if(client->req_len < size) - return BadLength; + if (client->req_len < size) + return BadLength; - return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, pImage, - (unsigned char*)(&stuff[1]), FALSE, - stuff->width, stuff->height); + return XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, + stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, + stuff->drw_w, stuff->drw_h, pImage, + (unsigned char *) (&stuff[1]), FALSE, + stuff->width, stuff->height); } #ifdef MITSHM @@ -1000,74 +950,73 @@ typedef struct _ShmDesc { extern RESTYPE ShmSegType; extern int ShmCompletionCode; -static int +static int ProcXvShmPutImage(ClientPtr client) { - ShmDescPtr shmdesc; - DrawablePtr pDraw; - XvPortPtr pPort; - XvImagePtr pImage = NULL; - GCPtr pGC; - int status, size_needed, i; - CARD16 width, height; + ShmDescPtr shmdesc; + DrawablePtr pDraw; + XvPortPtr pPort; + XvImagePtr pImage = NULL; + GCPtr pGC; + int status, size_needed, i; + CARD16 width, height; - REQUEST(xvShmPutImageReq); - REQUEST_SIZE_MATCH(xvShmPutImageReq); + REQUEST(xvShmPutImageReq); + REQUEST_SIZE_MATCH(xvShmPutImageReq); - VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - if ((status = _AllocatePort(stuff->port, pPort)) != Success) - { - client->errorValue = stuff->port; - return status; + if ((status = _AllocatePort(stuff->port, pPort)) != Success) { + client->errorValue = stuff->port; + return status; } - if (!(pPort->pAdaptor->type & XvImageMask) || - !(pPort->pAdaptor->type & XvInputMask)) - { - client->errorValue = stuff->port; - return BadMatch; + if (!(pPort->pAdaptor->type & XvImageMask) || + !(pPort->pAdaptor->type & XvInputMask)) { + client->errorValue = stuff->port; + return BadMatch; } - status = XvdiMatchPort(pPort, pDraw); - if (status != Success) - { - return status; + status = XvdiMatchPort(pPort, pDraw); + if (status != Success) { + return status; } - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } - - if(!pImage) - return BadMatch; - - status = dixLookupResourceByType((pointer *)&shmdesc, stuff->shmseg, - ShmSegType, serverClient, DixReadAccess); - if (status != Success) - return status; - - width = stuff->width; - height = stuff->height; - size_needed = (*pPort->pAdaptor->ddQueryImageAttributes)(client, - pPort, pImage, &width, &height, NULL, NULL); - if((size_needed + stuff->offset) > shmdesc->size) - return BadAccess; - - if((width < stuff->width) || (height < stuff->height)) - return BadValue; - - status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, - stuff->src_w, stuff->src_h, stuff->drw_x, stuff->drw_y, - stuff->drw_w, stuff->drw_h, pImage, - (unsigned char *)shmdesc->addr + stuff->offset, - stuff->send_event, stuff->width, stuff->height); - - if((status == Success) && stuff->send_event) { + for (i = 0; i < pPort->pAdaptor->nImages; i++) { + if (pPort->pAdaptor->pImages[i].id == stuff->id) { + pImage = &(pPort->pAdaptor->pImages[i]); + break; + } + } + + if (!pImage) + return BadMatch; + + status = dixLookupResourceByType((pointer *) &shmdesc, stuff->shmseg, + ShmSegType, serverClient, DixReadAccess); + if (status != Success) + return status; + + width = stuff->width; + height = stuff->height; + size_needed = (*pPort->pAdaptor->ddQueryImageAttributes) (client, + pPort, pImage, + &width, &height, + NULL, NULL); + if ((size_needed + stuff->offset) > shmdesc->size) + return BadAccess; + + if ((width < stuff->width) || (height < stuff->height)) + return BadValue; + + status = XvdiPutImage(client, pDraw, pPort, pGC, stuff->src_x, stuff->src_y, + stuff->src_w, stuff->src_h, stuff->drw_x, + stuff->drw_y, stuff->drw_w, stuff->drw_h, pImage, + (unsigned char *) shmdesc->addr + stuff->offset, + stuff->send_event, stuff->width, stuff->height); + + if ((status == Success) && stuff->send_event) { xShmCompletionEvent ev; ev.type = ShmCompletionCode; @@ -1077,11 +1026,11 @@ ProcXvShmPutImage(ClientPtr client) ev.shmseg = stuff->shmseg; ev.offset = stuff->offset; WriteEventsToClient(client, 1, (xEvent *) &ev); - } + } - return status; + return status; } -#else /* !MITSHM */ +#else /* !MITSHM */ static int ProcXvShmPutImage(ClientPtr client) { @@ -1094,156 +1043,157 @@ ProcXvShmPutImage(ClientPtr client) #include "xvmcext.h" #endif -static int +static int ProcXvQueryImageAttributes(ClientPtr client) { - xvQueryImageAttributesReply rep; - int size, num_planes, i; - CARD16 width, height; - XvImagePtr pImage = NULL; - XvPortPtr pPort; - int *offsets; - int *pitches; - int planeLength; - REQUEST(xvQueryImageAttributesReq); - - REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - for(i = 0; i < pPort->pAdaptor->nImages; i++) { - if(pPort->pAdaptor->pImages[i].id == stuff->id) { - pImage = &(pPort->pAdaptor->pImages[i]); - break; - } - } + xvQueryImageAttributesReply rep; + int size, num_planes, i; + CARD16 width, height; + XvImagePtr pImage = NULL; + XvPortPtr pPort; + int *offsets; + int *pitches; + int planeLength; + + REQUEST(xvQueryImageAttributesReq); + + REQUEST_SIZE_MATCH(xvQueryImageAttributesReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + for (i = 0; i < pPort->pAdaptor->nImages; i++) { + if (pPort->pAdaptor->pImages[i].id == stuff->id) { + pImage = &(pPort->pAdaptor->pImages[i]); + break; + } + } #ifdef XvMCExtension - if(!pImage) - pImage = XvMCFindXvImage(pPort, stuff->id); + if (!pImage) + pImage = XvMCFindXvImage(pPort, stuff->id); #endif - if(!pImage) - return BadMatch; + if (!pImage) + return BadMatch; + + num_planes = pImage->num_planes; - num_planes = pImage->num_planes; + if (!(offsets = malloc(num_planes << 3))) + return BadAlloc; + pitches = offsets + num_planes; - if(!(offsets = malloc(num_planes << 3))) - return BadAlloc; - pitches = offsets + num_planes; + width = stuff->width; + height = stuff->height; - width = stuff->width; - height = stuff->height; + size = (*pPort->pAdaptor->ddQueryImageAttributes) (client, pPort, pImage, + &width, &height, offsets, + pitches); - size = (*pPort->pAdaptor->ddQueryImageAttributes)(client, pPort, pImage, - &width, &height, offsets, pitches); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = planeLength = num_planes << 1; + rep.num_planes = num_planes; + rep.width = width; + rep.height = height; + rep.data_size = size; - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.length = planeLength = num_planes << 1; - rep.num_planes = num_planes; - rep.width = width; - rep.height = height; - rep.data_size = size; - - _WriteQueryImageAttributesReply(client, &rep); - if(client->swapped) - SwapLongs((CARD32*)offsets, planeLength); - WriteToClient(client, planeLength << 2, (char*)offsets); + _WriteQueryImageAttributesReply(client, &rep); + if (client->swapped) + SwapLongs((CARD32 *) offsets, planeLength); + WriteToClient(client, planeLength << 2, (char *) offsets); - free(offsets); + free(offsets); - return Success; + return Success; } -static int +static int ProcXvListImageFormats(ClientPtr client) { - XvPortPtr pPort; - XvImagePtr pImage; - int i; - xvListImageFormatsReply rep; - xvImageFormatInfo info; - REQUEST(xvListImageFormatsReq); - - REQUEST_SIZE_MATCH(xvListImageFormatsReq); - - VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); - - rep.type = X_Reply; - rep.sequenceNumber = client->sequence; - rep.num_formats = pPort->pAdaptor->nImages; - rep.length = bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo); - - _WriteListImageFormatsReply(client, &rep); - - pImage = pPort->pAdaptor->pImages; - - for(i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) { - info.id = pImage->id; - info.type = pImage->type; - info.byte_order = pImage->byte_order; - memcpy(&info.guid, pImage->guid, 16); - info.bpp = pImage->bits_per_pixel; - info.num_planes = pImage->num_planes; - info.depth = pImage->depth; - info.red_mask = pImage->red_mask; - info.green_mask = pImage->green_mask; - info.blue_mask = pImage->blue_mask; - info.format = pImage->format; - info.y_sample_bits = pImage->y_sample_bits; - info.u_sample_bits = pImage->u_sample_bits; - info.v_sample_bits = pImage->v_sample_bits; - info.horz_y_period = pImage->horz_y_period; - info.horz_u_period = pImage->horz_u_period; - info.horz_v_period = pImage->horz_v_period; - info.vert_y_period = pImage->vert_y_period; - info.vert_u_period = pImage->vert_u_period; - info.vert_v_period = pImage->vert_v_period; - memcpy(&info.comp_order, pImage->component_order, 32); - info.scanline_order = pImage->scanline_order; - _WriteImageFormatInfo(client, &info); - } - - return Success; -} - -static int (*XvProcVector[xvNumRequests])(ClientPtr) = { - ProcXvQueryExtension, - ProcXvQueryAdaptors, - ProcXvQueryEncodings, - ProcXvGrabPort, - ProcXvUngrabPort, - ProcXvPutVideo, - ProcXvPutStill, - ProcXvGetVideo, - ProcXvGetStill, - ProcXvStopVideo, - ProcXvSelectVideoNotify, - ProcXvSelectPortNotify, - ProcXvQueryBestSize, - ProcXvSetPortAttribute, - ProcXvGetPortAttribute, - ProcXvQueryPortAttributes, - ProcXvListImageFormats, - ProcXvQueryImageAttributes, - ProcXvPutImage, - ProcXvShmPutImage, -}; + XvPortPtr pPort; + XvImagePtr pImage; + int i; + xvListImageFormatsReply rep; + xvImageFormatInfo info; + + REQUEST(xvListImageFormatsReq); + + REQUEST_SIZE_MATCH(xvListImageFormatsReq); + + VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.num_formats = pPort->pAdaptor->nImages; + rep.length = + bytes_to_int32(pPort->pAdaptor->nImages * sz_xvImageFormatInfo); + + _WriteListImageFormatsReply(client, &rep); + + pImage = pPort->pAdaptor->pImages; + + for (i = 0; i < pPort->pAdaptor->nImages; i++, pImage++) { + info.id = pImage->id; + info.type = pImage->type; + info.byte_order = pImage->byte_order; + memcpy(&info.guid, pImage->guid, 16); + info.bpp = pImage->bits_per_pixel; + info.num_planes = pImage->num_planes; + info.depth = pImage->depth; + info.red_mask = pImage->red_mask; + info.green_mask = pImage->green_mask; + info.blue_mask = pImage->blue_mask; + info.format = pImage->format; + info.y_sample_bits = pImage->y_sample_bits; + info.u_sample_bits = pImage->u_sample_bits; + info.v_sample_bits = pImage->v_sample_bits; + info.horz_y_period = pImage->horz_y_period; + info.horz_u_period = pImage->horz_u_period; + info.horz_v_period = pImage->horz_v_period; + info.vert_y_period = pImage->vert_y_period; + info.vert_u_period = pImage->vert_u_period; + info.vert_v_period = pImage->vert_v_period; + memcpy(&info.comp_order, pImage->component_order, 32); + info.scanline_order = pImage->scanline_order; + _WriteImageFormatInfo(client, &info); + } + + return Success; +} + +static int (*XvProcVector[xvNumRequests]) (ClientPtr) = { +ProcXvQueryExtension, + ProcXvQueryAdaptors, + ProcXvQueryEncodings, + ProcXvGrabPort, + ProcXvUngrabPort, + ProcXvPutVideo, + ProcXvPutStill, + ProcXvGetVideo, + ProcXvGetStill, + ProcXvStopVideo, + ProcXvSelectVideoNotify, + ProcXvSelectPortNotify, + ProcXvQueryBestSize, + ProcXvSetPortAttribute, + ProcXvGetPortAttribute, + ProcXvQueryPortAttributes, + ProcXvListImageFormats, + ProcXvQueryImageAttributes, ProcXvPutImage, ProcXvShmPutImage,}; int ProcXvDispatch(ClientPtr client) { - REQUEST(xReq); + REQUEST(xReq); - UpdateCurrentTime(); + UpdateCurrentTime(); - if (stuff->data >= xvNumRequests) { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return BadRequest; - } + if (stuff->data >= xvNumRequests) { + SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); + return BadRequest; + } - return XvProcVector[stuff->data](client); + return XvProcVector[stuff->data] (client); } /* Swapped Procs */ @@ -1251,333 +1201,331 @@ ProcXvDispatch(ClientPtr client) static int SProcXvQueryExtension(ClientPtr client) { - REQUEST(xvQueryExtensionReq); - swaps(&stuff->length); - return XvProcVector[xv_QueryExtension](client); + REQUEST(xvQueryExtensionReq); + swaps(&stuff->length); + return XvProcVector[xv_QueryExtension] (client); } static int SProcXvQueryAdaptors(ClientPtr client) { - REQUEST(xvQueryAdaptorsReq); - swaps(&stuff->length); - swapl(&stuff->window); - return XvProcVector[xv_QueryAdaptors](client); + REQUEST(xvQueryAdaptorsReq); + swaps(&stuff->length); + swapl(&stuff->window); + return XvProcVector[xv_QueryAdaptors] (client); } static int SProcXvQueryEncodings(ClientPtr client) { - REQUEST(xvQueryEncodingsReq); - swaps(&stuff->length); - swapl(&stuff->port); - return XvProcVector[xv_QueryEncodings](client); + REQUEST(xvQueryEncodingsReq); + swaps(&stuff->length); + swapl(&stuff->port); + return XvProcVector[xv_QueryEncodings] (client); } static int SProcXvGrabPort(ClientPtr client) { - REQUEST(xvGrabPortReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->time); - return XvProcVector[xv_GrabPort](client); + REQUEST(xvGrabPortReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->time); + return XvProcVector[xv_GrabPort] (client); } static int SProcXvUngrabPort(ClientPtr client) { - REQUEST(xvUngrabPortReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->time); - return XvProcVector[xv_UngrabPort](client); + REQUEST(xvUngrabPortReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->time); + return XvProcVector[xv_UngrabPort] (client); } static int SProcXvPutVideo(ClientPtr client) { - REQUEST(xvPutVideoReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - swapl(&stuff->gc); - swaps(&stuff->vid_x); - swaps(&stuff->vid_y); - swaps(&stuff->vid_w); - swaps(&stuff->vid_h); - swaps(&stuff->drw_x); - swaps(&stuff->drw_y); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - return XvProcVector[xv_PutVideo](client); + REQUEST(xvPutVideoReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->vid_x); + swaps(&stuff->vid_y); + swaps(&stuff->vid_w); + swaps(&stuff->vid_h); + swaps(&stuff->drw_x); + swaps(&stuff->drw_y); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + return XvProcVector[xv_PutVideo] (client); } static int SProcXvPutStill(ClientPtr client) { - REQUEST(xvPutStillReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - swapl(&stuff->gc); - swaps(&stuff->vid_x); - swaps(&stuff->vid_y); - swaps(&stuff->vid_w); - swaps(&stuff->vid_h); - swaps(&stuff->drw_x); - swaps(&stuff->drw_y); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - return XvProcVector[xv_PutStill](client); + REQUEST(xvPutStillReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->vid_x); + swaps(&stuff->vid_y); + swaps(&stuff->vid_w); + swaps(&stuff->vid_h); + swaps(&stuff->drw_x); + swaps(&stuff->drw_y); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + return XvProcVector[xv_PutStill] (client); } static int SProcXvGetVideo(ClientPtr client) { - REQUEST(xvGetVideoReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - swapl(&stuff->gc); - swaps(&stuff->vid_x); - swaps(&stuff->vid_y); - swaps(&stuff->vid_w); - swaps(&stuff->vid_h); - swaps(&stuff->drw_x); - swaps(&stuff->drw_y); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - return XvProcVector[xv_GetVideo](client); + REQUEST(xvGetVideoReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->vid_x); + swaps(&stuff->vid_y); + swaps(&stuff->vid_w); + swaps(&stuff->vid_h); + swaps(&stuff->drw_x); + swaps(&stuff->drw_y); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + return XvProcVector[xv_GetVideo] (client); } static int SProcXvGetStill(ClientPtr client) { - REQUEST(xvGetStillReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - swapl(&stuff->gc); - swaps(&stuff->vid_x); - swaps(&stuff->vid_y); - swaps(&stuff->vid_w); - swaps(&stuff->vid_h); - swaps(&stuff->drw_x); - swaps(&stuff->drw_y); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - return XvProcVector[xv_GetStill](client); + REQUEST(xvGetStillReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swaps(&stuff->vid_x); + swaps(&stuff->vid_y); + swaps(&stuff->vid_w); + swaps(&stuff->vid_h); + swaps(&stuff->drw_x); + swaps(&stuff->drw_y); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + return XvProcVector[xv_GetStill] (client); } static int SProcXvPutImage(ClientPtr client) { - REQUEST(xvPutImageReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - swapl(&stuff->gc); - swapl(&stuff->id); - swaps(&stuff->src_x); - swaps(&stuff->src_y); - swaps(&stuff->src_w); - swaps(&stuff->src_h); - swaps(&stuff->drw_x); - swaps(&stuff->drw_y); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - swaps(&stuff->width); - swaps(&stuff->height); - return XvProcVector[xv_PutImage](client); + REQUEST(xvPutImageReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swapl(&stuff->id); + swaps(&stuff->src_x); + swaps(&stuff->src_y); + swaps(&stuff->src_w); + swaps(&stuff->src_h); + swaps(&stuff->drw_x); + swaps(&stuff->drw_y); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + swaps(&stuff->width); + swaps(&stuff->height); + return XvProcVector[xv_PutImage] (client); } #ifdef MITSHM static int SProcXvShmPutImage(ClientPtr client) { - REQUEST(xvShmPutImageReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - swapl(&stuff->gc); - swapl(&stuff->shmseg); - swapl(&stuff->id); - swapl(&stuff->offset); - swaps(&stuff->src_x); - swaps(&stuff->src_y); - swaps(&stuff->src_w); - swaps(&stuff->src_h); - swaps(&stuff->drw_x); - swaps(&stuff->drw_y); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - swaps(&stuff->width); - swaps(&stuff->height); - return XvProcVector[xv_ShmPutImage](client); -} -#else /* MITSHM */ + REQUEST(xvShmPutImageReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + swapl(&stuff->gc); + swapl(&stuff->shmseg); + swapl(&stuff->id); + swapl(&stuff->offset); + swaps(&stuff->src_x); + swaps(&stuff->src_y); + swaps(&stuff->src_w); + swaps(&stuff->src_h); + swaps(&stuff->drw_x); + swaps(&stuff->drw_y); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + swaps(&stuff->width); + swaps(&stuff->height); + return XvProcVector[xv_ShmPutImage] (client); +} +#else /* MITSHM */ #define SProcXvShmPutImage ProcXvShmPutImage #endif static int SProcXvSelectVideoNotify(ClientPtr client) { - REQUEST(xvSelectVideoNotifyReq); - swaps(&stuff->length); - swapl(&stuff->drawable); - return XvProcVector[xv_SelectVideoNotify](client); + REQUEST(xvSelectVideoNotifyReq); + swaps(&stuff->length); + swapl(&stuff->drawable); + return XvProcVector[xv_SelectVideoNotify] (client); } static int SProcXvSelectPortNotify(ClientPtr client) { - REQUEST(xvSelectPortNotifyReq); - swaps(&stuff->length); - swapl(&stuff->port); - return XvProcVector[xv_SelectPortNotify](client); + REQUEST(xvSelectPortNotifyReq); + swaps(&stuff->length); + swapl(&stuff->port); + return XvProcVector[xv_SelectPortNotify] (client); } static int SProcXvStopVideo(ClientPtr client) { - REQUEST(xvStopVideoReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->drawable); - return XvProcVector[xv_StopVideo](client); + REQUEST(xvStopVideoReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->drawable); + return XvProcVector[xv_StopVideo] (client); } static int SProcXvSetPortAttribute(ClientPtr client) { - REQUEST(xvSetPortAttributeReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->attribute); - swapl(&stuff->value); - return XvProcVector[xv_SetPortAttribute](client); + REQUEST(xvSetPortAttributeReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->attribute); + swapl(&stuff->value); + return XvProcVector[xv_SetPortAttribute] (client); } static int SProcXvGetPortAttribute(ClientPtr client) { - REQUEST(xvGetPortAttributeReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->attribute); - return XvProcVector[xv_GetPortAttribute](client); + REQUEST(xvGetPortAttributeReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->attribute); + return XvProcVector[xv_GetPortAttribute] (client); } static int SProcXvQueryBestSize(ClientPtr client) { - REQUEST(xvQueryBestSizeReq); - swaps(&stuff->length); - swapl(&stuff->port); - swaps(&stuff->vid_w); - swaps(&stuff->vid_h); - swaps(&stuff->drw_w); - swaps(&stuff->drw_h); - return XvProcVector[xv_QueryBestSize](client); + REQUEST(xvQueryBestSizeReq); + swaps(&stuff->length); + swapl(&stuff->port); + swaps(&stuff->vid_w); + swaps(&stuff->vid_h); + swaps(&stuff->drw_w); + swaps(&stuff->drw_h); + return XvProcVector[xv_QueryBestSize] (client); } static int SProcXvQueryPortAttributes(ClientPtr client) { - REQUEST(xvQueryPortAttributesReq); - swaps(&stuff->length); - swapl(&stuff->port); - return XvProcVector[xv_QueryPortAttributes](client); + REQUEST(xvQueryPortAttributesReq); + swaps(&stuff->length); + swapl(&stuff->port); + return XvProcVector[xv_QueryPortAttributes] (client); } static int SProcXvQueryImageAttributes(ClientPtr client) { - REQUEST(xvQueryImageAttributesReq); - swaps(&stuff->length); - swapl(&stuff->port); - swapl(&stuff->id); - swaps(&stuff->width); - swaps(&stuff->height); - return XvProcVector[xv_QueryImageAttributes](client); + REQUEST(xvQueryImageAttributesReq); + swaps(&stuff->length); + swapl(&stuff->port); + swapl(&stuff->id); + swaps(&stuff->width); + swaps(&stuff->height); + return XvProcVector[xv_QueryImageAttributes] (client); } static int SProcXvListImageFormats(ClientPtr client) { - REQUEST(xvListImageFormatsReq); - swaps(&stuff->length); - swapl(&stuff->port); - return XvProcVector[xv_ListImageFormats](client); -} - -static int (*SXvProcVector[xvNumRequests])(ClientPtr) = { - SProcXvQueryExtension, - SProcXvQueryAdaptors, - SProcXvQueryEncodings, - SProcXvGrabPort, - SProcXvUngrabPort, - SProcXvPutVideo, - SProcXvPutStill, - SProcXvGetVideo, - SProcXvGetStill, - SProcXvStopVideo, - SProcXvSelectVideoNotify, - SProcXvSelectPortNotify, - SProcXvQueryBestSize, - SProcXvSetPortAttribute, - SProcXvGetPortAttribute, - SProcXvQueryPortAttributes, - SProcXvListImageFormats, - SProcXvQueryImageAttributes, - SProcXvPutImage, - SProcXvShmPutImage, -}; + REQUEST(xvListImageFormatsReq); + swaps(&stuff->length); + swapl(&stuff->port); + return XvProcVector[xv_ListImageFormats] (client); +} + +static int (*SXvProcVector[xvNumRequests]) (ClientPtr) = { +SProcXvQueryExtension, + SProcXvQueryAdaptors, + SProcXvQueryEncodings, + SProcXvGrabPort, + SProcXvUngrabPort, + SProcXvPutVideo, + SProcXvPutStill, + SProcXvGetVideo, + SProcXvGetStill, + SProcXvStopVideo, + SProcXvSelectVideoNotify, + SProcXvSelectPortNotify, + SProcXvQueryBestSize, + SProcXvSetPortAttribute, + SProcXvGetPortAttribute, + SProcXvQueryPortAttributes, + SProcXvListImageFormats, + SProcXvQueryImageAttributes, SProcXvPutImage, SProcXvShmPutImage,}; int SProcXvDispatch(ClientPtr client) { - REQUEST(xReq); + REQUEST(xReq); - UpdateCurrentTime(); + UpdateCurrentTime(); - if (stuff->data >= xvNumRequests) { - SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); - return BadRequest; - } + if (stuff->data >= xvNumRequests) { + SendErrorToClient(client, XvReqCode, stuff->data, 0, BadRequest); + return BadRequest; + } - return SXvProcVector[stuff->data](client); + return SXvProcVector[stuff->data] (client); } #ifdef PANORAMIX static int XineramaXvStopVideo(ClientPtr client) { - int result, i; - PanoramiXRes *draw, *port; - REQUEST(xvStopVideoReq); - REQUEST_SIZE_MATCH(xvStopVideoReq); + int result, i; + PanoramiXRes *draw, *port; - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); - if (result != Success) - return (result == BadValue) ? BadDrawable : result; + REQUEST(xvStopVideoReq); + REQUEST_SIZE_MATCH(xvStopVideoReq); - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); - if (result != Success) - return result; + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); + if (result != Success) + return (result == BadValue) ? BadDrawable : result; + + result = dixLookupResourceByType((pointer *) &port, stuff->port, + XvXRTPort, client, DixReadAccess); + if (result != Success) + return result; - FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - result = ProcXvStopVideo(client); - } - } + FOR_NSCREENS_BACKWARD(i) { + if (port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + result = ProcXvStopVideo(client); + } + } - return result; + return result; } static int @@ -1589,22 +1537,22 @@ XineramaXvSetPortAttribute(ClientPtr client) REQUEST_SIZE_MATCH(xvSetPortAttributeReq); - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &port, stuff->port, + XvXRTPort, client, DixReadAccess); if (result != Success) - return result; + return result; FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->port = port->info[i].id; - result = ProcXvSetPortAttribute(client); - } + if (port->info[i].id) { + stuff->port = port->info[i].id; + result = ProcXvSetPortAttribute(client); + } } return result; } #ifdef MITSHM -static int +static int XineramaXvShmPutImage(ClientPtr client) { REQUEST(xvShmPutImageReq); @@ -1615,41 +1563,41 @@ XineramaXvShmPutImage(ClientPtr client) REQUEST_SIZE_MATCH(xvShmPutImageReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, + XRT_GC, client, DixReadAccess); if (result != Success) return result; - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &port, stuff->port, + XvXRTPort, client, DixReadAccess); if (result != Success) - return result; - + return result; + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; x = stuff->drw_x; y = stuff->drw_y; FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= screenInfo.screens[i]->x; - stuff->drw_y -= screenInfo.screens[i]->y; - } - stuff->send_event = (send_event && !i) ? 1 : 0; - - result = ProcXvShmPutImage(client); - } + if (port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if (isRoot) { + stuff->drw_x -= screenInfo.screens[i]->x; + stuff->drw_y -= screenInfo.screens[i]->y; + } + stuff->send_event = (send_event && !i) ? 1 : 0; + + result = ProcXvShmPutImage(client); + } } return result; } @@ -1657,7 +1605,7 @@ XineramaXvShmPutImage(ClientPtr client) #define XineramaXvShmPutImage ProcXvShmPutImage #endif -static int +static int XineramaXvPutImage(ClientPtr client) { REQUEST(xvPutImageReq); @@ -1667,40 +1615,40 @@ XineramaXvPutImage(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutImageReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, + XRT_GC, client, DixReadAccess); if (result != Success) return result; - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &port, stuff->port, + XvXRTPort, client, DixReadAccess); if (result != Success) - return result; - + return result; + isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; x = stuff->drw_x; y = stuff->drw_y; FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { - stuff->drw_x -= screenInfo.screens[i]->x; - stuff->drw_y -= screenInfo.screens[i]->y; - } - - result = ProcXvPutImage(client); - } + if (port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if (isRoot) { + stuff->drw_x -= screenInfo.screens[i]->x; + stuff->drw_y -= screenInfo.screens[i]->y; + } + + result = ProcXvPutImage(client); + } } return result; } @@ -1715,20 +1663,20 @@ XineramaXvPutVideo(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutVideoReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, + XRT_GC, client, DixReadAccess); if (result != Success) return result; - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &port, stuff->port, + XvXRTPort, client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1736,18 +1684,18 @@ XineramaXvPutVideo(ClientPtr client) y = stuff->drw_y; FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { + if (port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if (isRoot) { stuff->drw_x -= screenInfo.screens[i]->x; stuff->drw_y -= screenInfo.screens[i]->y; - } + } - result = ProcXvPutVideo(client); + result = ProcXvPutVideo(client); } } return result; @@ -1763,20 +1711,20 @@ XineramaXvPutStill(ClientPtr client) REQUEST_AT_LEAST_SIZE(xvPutImageReq); - result = dixLookupResourceByClass((pointer *)&draw, stuff->drawable, - XRC_DRAWABLE, client, DixWriteAccess); + result = dixLookupResourceByClass((pointer *) &draw, stuff->drawable, + XRC_DRAWABLE, client, DixWriteAccess); if (result != Success) - return (result == BadValue) ? BadDrawable : result; + return (result == BadValue) ? BadDrawable : result; - result = dixLookupResourceByType((pointer *)&gc, stuff->gc, - XRT_GC, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &gc, stuff->gc, + XRT_GC, client, DixReadAccess); if (result != Success) return result; - result = dixLookupResourceByType((pointer *)&port, stuff->port, - XvXRTPort, client, DixReadAccess); + result = dixLookupResourceByType((pointer *) &port, stuff->port, + XvXRTPort, client, DixReadAccess); if (result != Success) - return result; + return result; isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root; @@ -1784,18 +1732,18 @@ XineramaXvPutStill(ClientPtr client) y = stuff->drw_y; FOR_NSCREENS_BACKWARD(i) { - if(port->info[i].id) { - stuff->drawable = draw->info[i].id; - stuff->port = port->info[i].id; - stuff->gc = gc->info[i].id; - stuff->drw_x = x; - stuff->drw_y = y; - if(isRoot) { + if (port->info[i].id) { + stuff->drawable = draw->info[i].id; + stuff->port = port->info[i].id; + stuff->gc = gc->info[i].id; + stuff->drw_x = x; + stuff->drw_y = y; + if (isRoot) { stuff->drw_x -= screenInfo.screens[i]->x; stuff->drw_y -= screenInfo.screens[i]->y; - } + } - result = ProcXvPutStill(client); + result = ProcXvPutStill(client); } } return result; @@ -1811,9 +1759,10 @@ static Bool hasOverlay(XvAdaptorPtr pAdapt) { int i; - for(i = 0; i < pAdapt->nAttributes; i++) - if(!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY")) - return TRUE; + + for (i = 0; i < pAdapt->nAttributes; i++) + if (!strcmp(pAdapt->pAttributes[i].name, "XV_COLORKEY")) + return TRUE; return FALSE; } @@ -1821,94 +1770,105 @@ static XvAdaptorPtr matchAdaptor(ScreenPtr pScreen, XvAdaptorPtr refAdapt, Bool isOverlay) { int i; - XvScreenPtr xvsp = dixLookupPrivate(&pScreen->devPrivates, XvGetScreenKey()); + 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 (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; + 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; + 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; + 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; + for (i = 0; i < xvsp->nAdaptors; i++) { + XvAdaptorPtr pAdapt = xvsp->pAdaptors + i; + + if (isImageAdaptor(pAdapt)) + return pAdapt; } return NULL; } -void XineramifyXv(void) +void +XineramifyXv(void) { - XvScreenPtr xvsp0 = dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey()); - XvAdaptorPtr MatchingAdaptors[MAXSCREENS]; - int i, j, k; - - XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort"); - - if (!xvsp0 || !XvXRTPort) return; - SetResourceTypeErrorValue(XvXRTPort, _XvBadPort); - - for(i = 0; i < xvsp0->nAdaptors; i++) { - Bool isOverlay; - XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i; - if(!(refAdapt->type & XvInputMask)) continue; - - MatchingAdaptors[0] = refAdapt; - isOverlay = hasOverlay(refAdapt); - FOR_NSCREENS_FORWARD_SKIP(j) - MatchingAdaptors[j] = matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay); - - /* now create a resource for each port */ - for(j = 0; j < refAdapt->nPorts; j++) { - PanoramiXRes *port = malloc(sizeof(PanoramiXRes)); - if(!port) - break; - - FOR_NSCREENS(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); - } - } + XvScreenPtr xvsp0 = + dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey()); + XvAdaptorPtr MatchingAdaptors[MAXSCREENS]; + int i, j, k; + + XvXRTPort = CreateNewResourceType(XineramaDeleteResource, "XvXRTPort"); + + if (!xvsp0 || !XvXRTPort) + return; + SetResourceTypeErrorValue(XvXRTPort, _XvBadPort); + + for (i = 0; i < xvsp0->nAdaptors; i++) { + Bool isOverlay; + XvAdaptorPtr refAdapt = xvsp0->pAdaptors + i; + + if (!(refAdapt->type & XvInputMask)) + continue; + + MatchingAdaptors[0] = refAdapt; + isOverlay = hasOverlay(refAdapt); + FOR_NSCREENS_FORWARD_SKIP(j) + MatchingAdaptors[j] = + matchAdaptor(screenInfo.screens[j], refAdapt, isOverlay); + + /* now create a resource for each port */ + for (j = 0; j < refAdapt->nPorts; j++) { + PanoramiXRes *port = malloc(sizeof(PanoramiXRes)); + + if (!port) + break; + + FOR_NSCREENS(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); + } + } - /* munge the dispatch vector */ - XvProcVector[xv_PutVideo] = XineramaXvPutVideo; - XvProcVector[xv_PutStill] = XineramaXvPutStill; - XvProcVector[xv_StopVideo] = XineramaXvStopVideo; - XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute; - XvProcVector[xv_PutImage] = XineramaXvPutImage; - XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage; + /* munge the dispatch vector */ + XvProcVector[xv_PutVideo] = XineramaXvPutVideo; + XvProcVector[xv_PutStill] = XineramaXvPutStill; + XvProcVector[xv_StopVideo] = XineramaXvStopVideo; + XvProcVector[xv_SetPortAttribute] = XineramaXvSetPortAttribute; + XvProcVector[xv_PutImage] = XineramaXvPutImage; + XvProcVector[xv_ShmPutImage] = XineramaXvShmPutImage; } -#endif /* PANORAMIX */ +#endif /* PANORAMIX */ void XvResetProcVector(void) { #ifdef PANORAMIX - XvProcVector[xv_PutVideo] = ProcXvPutVideo; - XvProcVector[xv_PutStill] = ProcXvPutStill; - XvProcVector[xv_StopVideo] = ProcXvStopVideo; - XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute; - XvProcVector[xv_PutImage] = ProcXvPutImage; - XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage; + XvProcVector[xv_PutVideo] = ProcXvPutVideo; + XvProcVector[xv_PutStill] = ProcXvPutStill; + XvProcVector[xv_StopVideo] = ProcXvStopVideo; + XvProcVector[xv_SetPortAttribute] = ProcXvSetPortAttribute; + XvProcVector[xv_PutImage] = ProcXvPutImage; + XvProcVector[xv_ShmPutImage] = ProcXvShmPutImage; #endif } |