示例#1
0
int 
via_decoder_futex(DRM_IOCTL_ARGS)
{
	DRM_DEVICE;
	drm_via_futex_t fx;
	volatile int *lock;
	drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
	drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
	int ret = 0;

	DRM_DEBUG("%s\n", __FUNCTION__);

	DRM_COPY_FROM_USER_IOCTL(fx, (drm_via_futex_t __user *) data,
				 sizeof(fx));

	if (fx.lock > VIA_NR_XVMC_LOCKS)
		return -EFAULT;

	lock = (int *)XVMCLOCKPTR(sAPriv, fx.lock);

	switch (fx.func) {
	case VIA_FUTEX_WAIT:
		DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx.lock],
			    (fx.ms / 10) * (DRM_HZ / 100), *lock != fx.val);
		return ret;
	case VIA_FUTEX_WAKE:
		DRM_WAKEUP(&(dev_priv->decoder_queue[fx.lock]));
		return 0;
	}
	return 0;
}
示例#2
0
int via_decoder_futex(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	drm_via_futex_t *fx = data;
	volatile int *lock;
	drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private;
	drm_via_sarea_t *sAPriv = dev_priv->sarea_priv;
	int ret = 0;

	DRM_DEBUG("\n");

	if (fx->lock >= VIA_NR_XVMC_LOCKS)
		return -EFAULT;

	lock = (volatile int *)XVMCLOCKPTR(sAPriv, fx->lock);

	switch (fx->func) {
	case VIA_FUTEX_WAIT:
		DRM_WAIT_ON(ret, dev_priv->decoder_queue[fx->lock],
			    (fx->ms / 10) * (DRM_HZ / 100), *lock != fx->val);
		return ret;
	case VIA_FUTEX_WAKE:
		DRM_WAKEUP(&(dev_priv->decoder_queue[fx->lock]));
		return 0;
	}
	return 0;
}
示例#3
0
void via_init_futex(drm_via_private_t * dev_priv)
{
	unsigned int i;

	DRM_DEBUG("\n");

	for (i = 0; i < VIA_NR_XVMC_LOCKS; ++i) {
		DRM_INIT_WAITQUEUE(&(dev_priv->decoder_queue[i]));
		XVMCLOCKPTR(dev_priv->sarea_priv, i)->lock = 0;
	}
}
示例#4
0
void
via_release_futex(drm_via_private_t *dev_priv, int context)
{
	unsigned int i;
	volatile int *lock;

	for (i=0; i < VIA_NR_XVMC_LOCKS; ++i) {
	        lock = (int *) XVMCLOCKPTR(dev_priv->sarea_priv, i);
		if ( (_DRM_LOCKING_CONTEXT( *lock ) == context)) {
			if (_DRM_LOCK_IS_HELD( *lock ) && (*lock & _DRM_LOCK_CONT)) {
				DRM_WAKEUP( &(dev_priv->decoder_queue[i]));
			}
			*lock = 0;
		}
	}	
}	
void
ViaInitXVMC(ScreenPtr pScreen)
{
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    VIAPtr pVia = VIAPTR(pScrn);
    ViaXvMCPtr vXvMC = &(pVia->xvmc);
    volatile ViaXvMCSAreaPriv *saPriv;

    pVia->XvMCEnabled = 0;

    if ((pVia->Chipset == VIA_KM400) ||
        (pVia->Chipset == VIA_CX700) ||
        (pVia->Chipset == VIA_K8M890) ||
        (pVia->Chipset == VIA_P4M900) ||
        (pVia->Chipset == VIA_VX800) ||
        (pVia->Chipset == VIA_VX855) ||
        (pVia->Chipset == VIA_VX900)) {
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "[XvMC] XvMC is not supported on this chipset.\n");
        return;
    }

    if (!pVia->directRenderingType) {
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "[XvMC] Cannot use XvMC without DRI!\n");
        return;
    }

    if (((pVia->drmVerMajor <= 2) && (pVia->drmVerMinor < 4))) {
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "[XvMC] Kernel drm is not compatible with XvMC.\n");
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "[XvMC] Kernel drm version is %d.%d.%d; "
                   "at least version 2.4.0 is needed.\n",
                   pVia->drmVerMajor, pVia->drmVerMinor, pVia->drmVerPL);
        xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
                   "[XvMC] Please update. Disabling XvMC.\n");
        return;
    }

    vXvMC->mmioBase = pVia->registerHandle;

    if (drmAddMap(pVia->drmmode.fd,
                  (drm_handle_t) pVia->FrameBufferBase,
                  pVia->videoRambytes, DRM_FRAME_BUFFER, 0,
                  &(vXvMC->fbBase)) < 0) {
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                   "[XvMC] drmAddMap(FB) failed. Disabling XvMC.\n");
        return;
    }

    initViaXvMC(vXvMC);

    if (!xf86XvMCScreenInit(pScreen, 1, ((pVia->Chipset == VIA_PM800)
                                         ? ppAdapt_pga : ppAdapt))) {
        xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
                   "[XvMC] XvMCScreenInit failed. Disabling XvMC.\n");
        drmRmMap(pVia->drmmode.fd, vXvMC->fbBase);
        return;
    }
#if (XvMCVersion > 1) || (XvMCRevision > 0)
    {
        DRIInfoPtr pDRIInfo = pVia->pDRIInfo;

        if (pVia->ChipId != PCI_CHIP_VT3259 &&
            pVia->ChipId != PCI_CHIP_VT3364) {
            xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                       "[XvMC] Registering chromeXvMC.\n");
            xf86XvMCRegisterDRInfo(pScreen, "chromeXvMC", pDRIInfo->busIdString,
                                   VIAXVMC_MAJOR, VIAXVMC_MINOR, VIAXVMC_PL);
        } else {
            xf86DrvMsg(pScrn->scrnIndex, X_INFO,
                       "[XvMC] Registering chromeXvMCPro.\n");
            xf86XvMCRegisterDRInfo(pScreen, "chromeXvMCPro",
                                   pDRIInfo->busIdString, VIAXVMC_MAJOR,
                                   VIAXVMC_MINOR, VIAXVMC_PL);
        }
    }
#endif

    vXvMC->activePorts = 0;
    saPriv = (ViaXvMCSAreaPriv *) DRIGetSAREAPrivate(pScreen);
    saPriv->XvMCCtxNoGrabbed = ~0;

    XVMCLOCKPTR(saPriv, UNICHROME_LOCK_DECODER1)->lock = 0;

    xf86DrvMsg(pScrn->scrnIndex, X_INFO,
               "[XvMC] Initialized XvMC extension.\n");
    pVia->XvMCEnabled = 1;
}