static void
ViaXvMCDestroySurface(ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf)
{
    VIAPtr pVia = VIAPTR(pScrn);
    ViaXvMCPtr vXvMC = &(pVia->xvmc);
    int i;
    volatile ViaXvMCSAreaPriv *sAPriv;
    XvMCContextPtr pContext = pSurf->context;
    XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) pContext->port_priv;
    viaPortPrivPtr pPriv = (viaPortPrivPtr) portPriv->DevPriv.ptr;
    ViaXvMCXVPriv *vx = (ViaXvMCXVPriv *) pPriv->xvmc_priv;

    for (i = 0; i < VIA_XVMC_MAX_SURFACES; i++) {
        if (vXvMC->surfaces[i] == pSurf->surface_id) {

            sAPriv = (ViaXvMCSAreaPriv *) DRIGetSAREAPrivate(pScrn->pScreen);
            {
                DRM_CAS_RESULT(__ret);
                DRM_CAS(&(sAPriv->XvMCDisplaying[vx->xvmc_port]),
                        i | VIA_XVMC_VALID, 0, __ret);
                if (!__ret)
                    ViaOverlayHide(pScrn);
            }
            drm_bo_free(pScrn, vXvMC->sPrivs[i]->memory_ref);
            free(vXvMC->sPrivs[i]);
            vXvMC->nSurfaces--;
            vXvMC->sPrivs[i] = 0;
            vXvMC->surfaces[i] = 0;
            return;
        }
    }
    return;
}
Esempio n. 2
0
static __DRIcontext *
dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config,
		      __DRIcontext *shared, void *data)
{
    drm_context_t hwContext;
    DRM_CAS_RESULT(ret);

    /* DRI2 doesn't use kernel with context IDs, we just need an ID that's
     * different from the kernel context ID to make drmLock() happy. */

    do {
	hwContext = screen->dri2.lock->next_id;
	DRM_CAS(&screen->dri2.lock->next_id, hwContext, hwContext + 1, ret);
    } while (ret);

    return driCreateNewContext(screen, config, 0, shared, hwContext, data);
}
static void
ViaXvMCDestroySubpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp)
{
    VIAPtr pVia = VIAPTR(pScrn);
    ViaXvMCPtr vXvMC = &(pVia->xvmc);
    int i;
    volatile ViaXvMCSAreaPriv *sAPriv;
    XvMCContextPtr pContext = pSubp->context;
    XvPortRecPrivatePtr portPriv = (XvPortRecPrivatePtr) pContext->port_priv;
    viaPortPrivPtr pPriv = (viaPortPrivPtr) portPriv->DevPriv.ptr;
    ViaXvMCXVPriv *vx = (ViaXvMCXVPriv *) pPriv->xvmc_priv;

    for (i = 0; i < VIA_XVMC_MAX_SURFACES; i++) {
        if (vXvMC->surfaces[i] == pSubp->subpicture_id) {

            sAPriv = (ViaXvMCSAreaPriv *) DRIGetSAREAPrivate(pScrn->pScreen);

            {
                DRM_CAS_RESULT(__ret);

                DRM_CAS(&(sAPriv->XvMCSubPicOn[vx->xvmc_port]),
                        i | VIA_XVMC_VALID, 0, __ret);
                if (!__ret) {
                    /* Turn subpicture off. */
                    while (VIAGETREG(V_COMPOSE_MODE) &
                           (V1_COMMAND_FIRE | V3_COMMAND_FIRE)) ;
                    VIASETREG(SUBP_CONTROL_STRIDE,
                            VIAGETREG(SUBP_CONTROL_STRIDE) & ~SUBP_HQV_ENABLE);
                }
            }

            drm_bo_free(pScrn, vXvMC->sPrivs[i]->memory_ref);
            free(vXvMC->sPrivs[i]);
            vXvMC->nSurfaces--;
            vXvMC->sPrivs[i] = 0;
            vXvMC->surfaces[i] = 0;

            return;
        }
    }
    return;
}
static int
viaXvMCInterceptPutImage(ScrnInfoPtr pScrn, 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 clipBoxes,
                         pointer data, DrawablePtr pDraw)
{
    viaPortPrivPtr pPriv = (viaPortPrivPtr) data;
    ViaXvMCXVPriv *vx = (ViaXvMCXVPriv *) pPriv->xvmc_priv;

    if (VIAPTR(pScrn)->XvMCEnabled) {
        if (FOURCC_XVMC == id) {
            volatile ViaXvMCSAreaPriv *sAPriv;
            ViaXvMCCommandBuffer *vXvMCData = (ViaXvMCCommandBuffer *) buf;

            sAPriv = (ViaXvMCSAreaPriv *) DRIGetSAREAPrivate(pScrn->pScreen);

            switch (vXvMCData->command) {
            case VIA_XVMC_COMMAND_ATTRIBUTES:
                if ((vXvMCData->ctxNo | VIA_XVMC_VALID) != vx->ctxDisplaying)
                    return 1;
                viaXvMCDisplayAttributes(pScrn, &vXvMCData->attrib, pPriv);
                return 0;
            case VIA_XVMC_COMMAND_FDISPLAY:
                if (sAPriv->XvMCDisplaying[vx->xvmc_port] != vXvMCData->srfNo)
                    return 1;
                viaXvMCDisplayAttributes(pScrn, &vXvMCData->attrib, pPriv);
                vx->ctxDisplaying = vXvMCData->ctxNo;
                break;
            case VIA_XVMC_COMMAND_DISPLAY:
                if ((vXvMCData->ctxNo | VIA_XVMC_VALID) != vx->ctxDisplaying) {
                    viaXvMCDisplayAttributes(pScrn, &vXvMCData->attrib, pPriv);
                }
                if (sAPriv->XvMCDisplaying[vx->xvmc_port] != vXvMCData->srfNo)
                    return 1;
                vx->ctxDisplaying = vXvMCData->ctxNo;
                break;
            case VIA_XVMC_COMMAND_UNDISPLAY:
                {
                    DRM_CAS_RESULT(__ret);
                    DRM_CAS(&(sAPriv->XvMCDisplaying[vx->xvmc_port]),
                        vXvMCData->srfNo, 0, __ret);
                    if (!__ret)
                        ViaOverlayHide(pScrn);
                }
                return Success;
            default:
                break;
            }
        } else {
            if ((VIA_XVMC_MAX_CONTEXTS | VIA_XVMC_VALID) != vx->ctxDisplaying) {
                viaXvMCDisplayAttributes(pScrn, &vx->xvAttr, pPriv);
                vx->ctxDisplaying = VIA_XVMC_MAX_CONTEXTS | VIA_XVMC_VALID;
            } else if (vx->newAttribute) {
                vx->newAttribute = 0;
                viaXvMCDisplayAttributes(pScrn, &vx->xvAttr, pPriv);
            }
            viaXvMCSetDisplayLock(pScrn, vx);
        }
    }
    return vx->PutImage(pScrn, src_x, src_y, drw_x, drw_y, src_w, src_h,
                        drw_w, drw_h, id, buf, width, height, sync, clipBoxes,
                        data, pDraw);
}