Example #1
0
void
qxl_init_randr (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
{
    char                name[32];
    qxl_output_private *qxl_output;
    qxl_crtc_private *  qxl_crtc;
    int                 i;
    xf86OutputPtr       output;

    xf86CrtcConfigInit (pScrn, &qxl_xf86crtc_config_funcs);

    /* CHECKME: This is actually redundant, it's overwritten by a later call via
     * xf86InitialConfiguration */
    xf86CrtcSetSizeRange (pScrn, 320, 200, 8192, 8192);

    qxl->crtcs = xnfcalloc (sizeof (xf86CrtcPtr), qxl->num_heads);
    qxl->outputs = xnfcalloc (sizeof (xf86OutputPtr), qxl->num_heads);

    for (i = 0 ; i < qxl->num_heads; ++i)
    {
	qxl->crtcs[i] = xf86CrtcCreate (pScrn, &qxl_crtc_funcs);
	if (!qxl->crtcs[i])
	    xf86DrvMsg (pScrn->scrnIndex, X_ERROR, "failed to create Crtc %d", i);

	qxl_crtc = xnfcalloc (sizeof (qxl_crtc_private), 1);
	qxl->crtcs[i]->driver_private = qxl_crtc;
	qxl_crtc->head = i;
	qxl_crtc->qxl = qxl;
	snprintf (name, sizeof (name), "qxl-%d", i);
	qxl->outputs[i] = output = xf86OutputCreate (pScrn, &qxl_output_funcs, name);
	if (!output)
	    xf86DrvMsg (pScrn->scrnIndex, X_ERROR, "failed to create Output %d", i);

	output->possible_crtcs = (1 << i); /* bitrange of allowed outputs - do a 1:1 */
	output->possible_clones = 0; /* TODO: not? */
	qxl_output = xnfcalloc (sizeof (qxl_output_private), 1);
	output->driver_private = qxl_output;
	qxl_output->head = i;
	qxl_output->qxl = qxl;
	qxl_output->status = i ? XF86OutputStatusDisconnected : XF86OutputStatusConnected;
	qxl_crtc->output = output;
    }

    xf86InitialConfiguration (pScrn, TRUE);

    qxl->virtual_x = pScrn->virtualX;
    qxl->virtual_y = pScrn->virtualY;
    /* all crtcs are enabled here, but their mode is 0,
       resulting monitor config empty atm */
}
Bool FBDEV_lcd_init(ScrnInfoPtr pScrn)
{
	xf86CrtcPtr crtc;
	xf86OutputPtr output;

	crtc = xf86CrtcCreate(pScrn, &fbdev_lcd_crtc_funcs);

	if(crtc == NULL) return FALSE;

	output = xf86OutputCreate(pScrn, &fbdev_lcd_output_funcs, "LCD");

	if(output == NULL) return FALSE;

	output->possible_crtcs = (1 << 0);

	return TRUE;
}
static void
drmmode_crtc_init(ScrnInfoPtr scrn, drmmode_ptr drmmode, int num)
{
	xf86CrtcPtr crtc;
	drmmode_crtc_private_ptr drmmode_crtc;

	crtc = xf86CrtcCreate(scrn, &drmmode_crtc_funcs);
	if (crtc == NULL)
		return;

	drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
	drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd,
						 drmmode->mode_res->crtcs[num]);
	drmmode_crtc->drmmode = drmmode;
	crtc->driver_private = drmmode_crtc;

	return;
}
Example #4
0
void
xorg_crtc_init(ScrnInfoPtr pScrn)
{
    modesettingPtr ms = modesettingPTR(pScrn);
    xf86CrtcPtr crtc;
    drmModeResPtr res;
    drmModeCrtcPtr drm_crtc = NULL;
    struct crtc_private *crtcp;
    int c;

    res = drmModeGetResources(ms->fd);
    if (res == 0) {
	ErrorF("Failed drmModeGetResources %d\n", errno);
	return;
    }

    for (c = 0; c < res->count_crtcs; c++) {
	drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]);

	if (!drm_crtc)
	    continue;

	crtc = xf86CrtcCreate(pScrn, &crtc_funcs);
	if (crtc == NULL)
	    goto out;

	crtcp = calloc(1, sizeof(struct crtc_private));
	if (!crtcp) {
	    xf86CrtcDestroy(crtc);
	    goto out;
	}

	crtcp->drm_crtc = drm_crtc;
	crtcp->entry.pixmap = NULL;
	WSBMINITLISTHEAD(&crtcp->entry.scanout_head);

	crtc->driver_private = crtcp;
    }

  out:
    drmModeFreeResources(res);
}
Bool
imxDisplayPreInit(ScrnInfoPtr pScrn)
{
	/* Access driver private screen data */
	ImxPtr imxPtr = IMXPTR(pScrn);

	/* Private data structure must not already be in use. */
	if (NULL != imxPtr->displayPrivate) {
		return FALSE;
	}
	
	/* Allocate memory for display private data */
	imxPtr->displayPrivate = calloc(sizeof(ImxDisplayRec), 1);
	if (NULL == imxPtr->displayPrivate) {
		return FALSE;
	}
	ImxDisplayPtr fPtr = IMXDISPLAYPTR(imxPtr);

	/* Initialize display private data structure. */
	fPtr->crtcPtr = NULL;
	fPtr->outputPtr = NULL;
	fPtr->atomEdid = 0;
	fPtr->fbShadowAllocated = FALSE;

	/* Access all the modes supported by frame buffer driver. */
	fPtr->fbModesList = imxDisplayGetModes(pScrn, imxPtr->fbDeviceName);

	/* Compute the range of sizes supported by frame buffer. */
	if (NULL != fPtr->fbModesList) {

		DisplayModePtr mode = fPtr->fbModesList;

		fPtr->fbMinWidth = mode->HDisplay;
		fPtr->fbMaxWidth = mode->HDisplay;
		fPtr->fbMinHeight = mode->VDisplay;
		fPtr->fbMaxHeight = mode->VDisplay;

		while (NULL != (mode = mode->next)) {

			if (mode->HDisplay < fPtr->fbMinWidth) {

				fPtr->fbMinWidth = mode->HDisplay;

			} else if (mode->HDisplay > fPtr->fbMaxWidth) {

				fPtr->fbMaxWidth = mode->HDisplay;
			}

			if (mode->VDisplay < fPtr->fbMinHeight) {

				fPtr->fbMinHeight = mode->VDisplay;

			} else if (mode->VDisplay > fPtr->fbMaxHeight) {

				fPtr->fbMaxHeight = mode->VDisplay;
			}
		}

	/* If modes not available from frame buffer, then use builtin mode */
	} else {

		DisplayModePtr mode = fbdevHWGetBuildinMode(pScrn);

		fPtr->fbMinWidth = mode->HDisplay;
		fPtr->fbMaxWidth = mode->HDisplay;
		fPtr->fbMinHeight = mode->VDisplay;
		fPtr->fbMaxHeight = mode->VDisplay;
	}

	/* Initialize display private data structure. */
	fPtr->crtcPtr = NULL;
	fPtr->outputPtr = NULL;

	fPtr->imxCrtcConfigFuncs.resize = imxCrtcResize;

	xf86CrtcConfigInit(pScrn, &fPtr->imxCrtcConfigFuncs);

	xf86CrtcSetSizeRange(
		pScrn,
		fPtr->fbMinWidth,
		fPtr->fbMinHeight,
		fPtr->fbMaxWidth,
		fPtr->fbMaxHeight);

	/* Establish CRTC callbacks */
	fPtr->imxCrtcFuncs.dpms = imxCrtcDPMS;
	fPtr->imxCrtcFuncs.save = imxCrtcSave;
	fPtr->imxCrtcFuncs.restore = imxCrtcRestore;
	fPtr->imxCrtcFuncs.lock = imxCrtcLock;
	fPtr->imxCrtcFuncs.unlock = imxCrtcUnlock;
	fPtr->imxCrtcFuncs.mode_fixup = imxCrtcModeFixup;
	fPtr->imxCrtcFuncs.prepare = imxCrtcPrepare;
	fPtr->imxCrtcFuncs.mode_set = imxCrtcModeSet;
	fPtr->imxCrtcFuncs.commit = imxCrtcCommit;
//	fPtr->imxCrtcFuncs.gamma_set = imxCrtcGammaSet;
	fPtr->imxCrtcFuncs.shadow_allocate = imxCrtcShadowAllocate;
	fPtr->imxCrtcFuncs.shadow_create = imxCrtcShadowCreate;
	fPtr->imxCrtcFuncs.shadow_destroy = imxCrtcShadowDestroy;
	fPtr->imxCrtcFuncs.destroy = imxCrtcDestroy;

	/* Allocate and initialize CRTC */
	fPtr->crtcPtr = xf86CrtcCreate(pScrn, &fPtr->imxCrtcFuncs);
	if (NULL == fPtr->crtcPtr) {

		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
				"xf86CrtcCreate failed\n");
		return FALSE;
	}

	/* Establish output callbacks. */
	fPtr->imxOutputFuncs.create_resources = imxOutputCreateResources;
	fPtr->imxOutputFuncs.dpms = imxOutputDPMS;
	fPtr->imxOutputFuncs.save = imxOutputSave;
	fPtr->imxOutputFuncs.restore = imxOutputRestore;
	fPtr->imxOutputFuncs.mode_valid = imxOutputModeValid;
	fPtr->imxOutputFuncs.mode_fixup = imxOutputModeFixup;
	fPtr->imxOutputFuncs.prepare = imxOutputPrepare;
	fPtr->imxOutputFuncs.mode_set = imxOutputModeSet;
	fPtr->imxOutputFuncs.commit = imxOutputCommit;
	fPtr->imxOutputFuncs.detect = imxOutputDetect;
	fPtr->imxOutputFuncs.get_modes = imxOutputGetModes;
#ifdef RANDR_13_INTERFACE
	fPtr->imxOutputFuncs.get_property = imxOutputGetProperty;
#endif
	fPtr->imxOutputFuncs.destroy = imxOutputDestroy;

	/* Allocate and initialize output */
	fPtr->outputPtr =
		xf86OutputCreate(pScrn, &fPtr->imxOutputFuncs, imxPtr->fbId);
	if (NULL == fPtr->outputPtr) {

		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
				"xf86OutputCreate failed\n");
		return FALSE;
	}
	fPtr->outputPtr->possible_crtcs = 1;

	/* Compute initial configuration */
	const Bool bCanGrow = TRUE;
	if (!xf86InitialConfiguration(pScrn, bCanGrow)) {

		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
				"xf86InitialConfiguration failed\n");
		return FALSE;
	}

	return TRUE;
}