Bool vivante_dri2_ScreenInit(ScreenPtr pScreen)
{
	struct vivante *vivante = vivante_get_screen_priv(pScreen);
	struct vivante_dri2_info *dri;
	DRI2InfoRec info;
	int dri2_major = 0;
	int dri2_minor = 0;
	const char *driverNames[1];

	if (xf86LoaderCheckSymbol("DRI2Version"))
		DRI2Version(&dri2_major, &dri2_minor);

	if (dri2_major < 1 || (dri2_major == 1 && dri2_minor < 1)) {
		xf86DrvMsg(vivante->scrnIndex, X_WARNING,
			   "DRI2 requires DRI2 module version 1.1.0 or later\n");
		return FALSE;
	}

	if (!vivante_dri2_register_private())
		return FALSE;

	if (dri2_server_generation != serverGeneration) {
		dri2_server_generation = serverGeneration;

		wait_client_restype = CreateNewResourceType(vivante_dri2_client_gone,
							"Frame Event Client");
		wait_drawable_restype = CreateNewResourceType(vivante_dri2_drawable_gone,
							  "Frame Event Drawable");

		if (!wait_client_restype || !wait_drawable_restype) {
			xf86DrvMsg(vivante->scrnIndex, X_WARNING,
				   "Can not register DRI2 frame event resources\n");
			return FALSE;
		}
	}

	dri = xnfcalloc(1, sizeof *dri);
	dri->devname = drmGetDeviceNameFromFd(vivante->drm_fd);

	vivante->dri2 = dri;

	memset(&info, 0, sizeof(info));
	info.version = 4;
	info.fd = vivante->drm_fd;
	info.driverName = "galdri";
	info.deviceName = dri->devname;

	info.CreateBuffer = vivante_dri2_CreateBuffer;
	info.DestroyBuffer = vivante_dri2_DestroyBuffer;
	info.CopyRegion = vivante_dri2_CopyRegion;

	info.ScheduleSwap = vivante_dri2_ScheduleSwap;
	info.GetMSC = vivante_dri2_GetMSC;
	info.ScheduleWaitMSC = vivante_dri2_ScheduleWaitMSC;
	info.numDrivers = 1;
	info.driverNames = driverNames;
	driverNames[0] = info.driverName;

	return DRI2ScreenInit(pScreen, &info);
}
예제 #2
0
/** As long as we are using our fake DRI driver inside of Mesa, we only want
 *  to implement the minimum here to make Mesa load it.  Notably we just set
 *  "DRI2Info.fd" to -1 as we do not need authentication to work. */
Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox)
{
    DRI2InfoRec DRI2Info;

    memset(&DRI2Info, 0, sizeof(DRI2Info));
    DRI2Info.version = 3;
    DRI2Info.fd = -1;
    DRI2Info.driverName = VBOX_DRI_DRIVER_NAME;
    DRI2Info.deviceName = "/dev/dri/card0";  /** @todo: do this right. */
    DRI2Info.CopyRegion = VBOXDRICopyRegion;
    DRI2Info.Wait = NULL;
    DRI2Info.CreateBuffer = VBOXDRICreateBuffer;
    DRI2Info.DestroyBuffer = VBOXDRIDestroyBuffer;
    return DRI2ScreenInit(pScreen, &DRI2Info);
}
예제 #3
0
void TegraDRI2ScreenInit(ScreenPtr pScreen)
{
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
    TegraPtr tegra = TegraPTR(pScrn);
    DRI2InfoRec info = {
        .version = 6,
        .fd = tegra->fd,
        .driverName = "tegra",
        .deviceName = tegra->path,
        .CreateBuffer = TegraDRI2CreateBuffer,
        .DestroyBuffer = TegraDRI2DestroyBuffer,
        .CopyRegion = TegraDRI2CopyRegion,
        .ScheduleSwap = TegraDRI2ScheduleSwap,
        .GetMSC = TegraDRI2GetMSC,
        .ScheduleWaitMSC = TegraDRI2ScheduleWaitMSC,
        .AuthMagic = drmAuthMagic,
    };

    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "> %s(pScreen=%p)\n", __func__,
               pScreen);

    if (xf86LoaderCheckSymbol("DRI2Version")) {
        int major = 0, minor = 0;

        DRI2Version(&major, &minor);

        xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DRI2 v%d.%d\n", major,
                   minor);
    }

    DRI2ScreenInit(pScreen, &info);

    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "< %s()\n", __func__);
}

void TegraDRI2ScreenExit(ScreenPtr pScreen)
{
    ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);

    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "> %s(pScreen=%p)\n", __func__,
               pScreen);

    DRI2CloseScreen(pScreen);

    xf86DrvMsg(pScrn->scrnIndex, X_INFO, "< %s()\n", __func__);
}
/** As long as we are using our fake DRI driver inside of Mesa, we only want
 *  to implement the minimum here to make Mesa load it. */
Bool VBOXDRIScreenInit(ScrnInfoPtr pScrn, ScreenPtr pScreen, VBOXPtr pVBox)
{
    DRI2InfoRec DRI2Info;
    unsigned i;

    memset(&DRI2Info, 0, sizeof(DRI2Info));
    pVBox->drmFD = -1;
    for (i = 0; i < RT_ELEMENTS(devicePaths); ++i)
    {
        int fd = open(devicePaths[i], O_RDWR);
        if (fd >= 0)
        {
            drmVersionPtr pVersion = drmGetVersion(fd);
            if (   pVersion
                && pVersion->name_len
                && !strcmp(pVersion->name, VBOX_DRM_DRIVER_NAME)
                && drmSetMaster(fd) == 0)
            {
                TRACE_LOG("Opened drm device %s\n", devicePaths[i]);
                DRI2Info.deviceName = devicePaths[i];
                /* Keep the driver open and hope that the path won't change. */
                pVBox->drmFD = fd;
                drmFreeVersion(pVersion);
                break;
            }
            close(fd);
            drmFreeVersion(pVersion);
        }
    }
    if (!DRI2Info.deviceName)
        return FALSE;
    DRI2Info.version = 3;
    DRI2Info.fd = pVBox->drmFD;
    DRI2Info.driverName = VBOX_DRI_DRIVER_NAME;
    DRI2Info.CopyRegion = VBOXDRICopyRegion;
    DRI2Info.Wait = NULL;
    DRI2Info.CreateBuffer = VBOXDRICreateBuffer;
    DRI2Info.DestroyBuffer = VBOXDRIDestroyBuffer;
    return DRI2ScreenInit(pScreen, &DRI2Info);
}
예제 #5
0
Rk30MaliDRI2 *Rk30MaliDRI2_Init(ScreenPtr pScreen)
{
    int drm_fd;
    DRI2InfoRec info;

    if (!xf86LoadSubModule(xf86Screens[pScreen->myNum], "dri2"))
        return FALSE;

    if ((drm_fd = drmOpen("mali_drm", NULL)) < 0) {
        ErrorF("Rk30MaliDRI2_Init: drmOpen failed!\n");
        return FALSE;
    }

    if (ump_open() != UMP_OK) {
        drmClose(drm_fd);
        ErrorF("Rk30MaliDRI2_Init: ump_open() != UMP_OK\n");
        return FALSE;
    }

    info.version = 3;

    info.driverName = "rk30-mali";
    info.deviceName = "/dev/dri/card0";
    info.fd = drm_fd;

    info.CreateBuffer = MaliDRI2CreateBuffer;
    info.DestroyBuffer = MaliDRI2DestroyBuffer;
    info.CopyRegion = MaliDRI2CopyRegion;

    if (!DRI2ScreenInit(pScreen, &info)) {
        drmClose(drm_fd);
        return NULL;
    }
    else {
        Rk30MaliDRI2 *private = calloc(1, sizeof(Rk30MaliDRI2));
        private->drm_fd = drm_fd;
        return private;
    }
예제 #6
0
void Rk30MaliDRI2_Init(ScreenPtr pScreen)
{
    int drm_fd;
    DRI2InfoRec info;
    ump_secure_id ump_id1, ump_id2;
    ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
    FBDevPtr pMxv = FBDEVPTR(pScrn);
    Bool isOverlay = TRUE;

#if DRI2INFOREC_VERSION >= 4
    const char *driverNames[1];
#endif

    pMxv->Rk30Mali = NULL;
    if(pMxv->OvlHW == NULL){
    	xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: Overlay not found!\n");
        return;
    }

    OvlHWPtr overlay = pMxv->OvlHW;

    if (!xf86LoadKernelModule("ump"))
        xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'ump' kernel module\n");
    if (!xf86LoadKernelModule("disp_ump"))
        xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'disp_ump' kernel module\n");
    if (!xf86LoadKernelModule("mali"))
        xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'mali' kernel module\n");
    if (!xf86LoadKernelModule("drm"))
        xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'drm' kernel module\n");
    if (!xf86LoadKernelModule("mali_drm"))
        xf86DrvMsg(pScreen->myNum, X_INFO, "can't load 'mali_drm' kernel module\n");

    if (!xf86LoadSubModule(xf86Screens[pScreen->myNum], "dri2"))
        return;

    if ((drm_fd = drmOpen("mali_drm", NULL)) < 0) {
        xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: drmOpen failed!\n");
        return;
    }

    if (ump_open() != UMP_OK) {
        xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: ump_open() != UMP_OK\n");
        goto err0;
    }

    if(!(pMxv->Rk30Mali = calloc(1, sizeof(Rk30MaliRec) ))){
        xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: Mem alloc failed!\n");
        goto err0;
    }

    Rk30MaliPtr	rk_3d = pMxv->Rk30Mali;

    rk_3d->PMemBuf = OvlAllocMemPg(pScrn, BUF_MEM);
    if(rk_3d->PMemBuf == NULL){
	xf86DrvMsg(pScreen->myNum, X_INFO, "Alloc fb buf failed\n");
        goto err1;
    }

    ump_id1 = rk_3d->PMemBuf->ump_fb_secure_id;
    if (ump_id1 == UMP_INVALID_SECURE_ID) {
        xf86DrvMsg(pScreen->myNum, X_INFO, "GET_UMP_SECURE_ID failed\n");
        goto err1;
    }

    if (isOverlay){
        xf86DrvMsg(pScreen->myNum, X_INFO, "HW overlay for 3D activated\n");
    }
    else
        xf86DrvMsg(pScreen->myNum, X_INFO, "HW overlay for 3D not usable\n");


    info.version = 3;

    info.driverName = "rk30-mali";
    info.deviceName = "/dev/dri/card0";
    info.fd = drm_fd;

    info.CreateBuffer = MaliDRI2CreateBuffer;
    info.DestroyBuffer = MaliDRI2DestroyBuffer;
    info.CopyRegion = MaliDRI2CopyRegion;

/*
#if DRI2INFOREC_VERSION >= 4
Bool USE_PAGEFLIP = TRUE;
    if (USE_PAGEFLIP)
    {
	info.version = 4;
	info.ScheduleSwap = MaliDRI2ScheduleSwap;
	info.GetMSC = NULL;
	info.ScheduleWaitMSC = NULL;
	info.numDrivers = 1;
	info.driverNames = driverNames;
	driverNames[0] = info.driverName;
    }
#endif
*/
    if (DRI2ScreenInit(pScreen, &info)){
        /* Wrap the current DestroyWindow function */
        rk_3d->DestroyWindow = pScreen->DestroyWindow;
        pScreen->DestroyWindow = DestroyWindow;
        /* Wrap the current PostValidateTree function */
//        rk_3d->PostValidateTree = pScreen->PostValidateTree;
//        pScreen->PostValidateTree = PostValidateTree;
        /* Wrap the current GetImage function */
//        rk_3d->GetImage = pScreen->GetImage;
//        pScreen->GetImage = GetImage;
        /* Wrap the current DestroyPixmap function */
        rk_3d->DestroyPixmap = pScreen->DestroyPixmap;
        pScreen->DestroyPixmap = DestroyPixmap;

        rk_3d->ump_fb_secure_id1 = ump_id1;
//        rk_3d->ump_fb_secure_id2 = ump_id2;
        rk_3d->drm_fd = drm_fd;
	rk_3d->ovl_x = 0;
	rk_3d->ovl_y = 0;
	rk_3d->ovl_w = 0;
	rk_3d->ovl_h = 0;
//	rk_3d->lstatus = ST_INIT;
//	rk_3d->ovl_cr = FALSE;
	rk_3d->buf_back = NULL;
	rk_3d->OvlPg = ERRORL;

        return;
    }

    xf86DrvMsg(pScreen->myNum, X_ERROR, "Rk30MaliDRI2_Init: DRI2ScreenInit failed!\n");
err2:
    OvlFreeMemPg(pScrn, rk_3d->PMemBuf);
err1:
    free(rk_3d);
err0:
    drmClose(drm_fd);
}