Exemplo n.º 1
0
Bool drmmode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
{
	xf86CrtcConfigPtr   xf86_config;
	drmmode_ptr drmmode;
	int i;

	drmmode = xnfalloc(sizeof *drmmode);
	drmmode->fd = fd;
	drmmode->fb_id = 0;

	xf86CrtcConfigInit(scrn, &drmmode_xf86crtc_config_funcs);
	xf86_config = XF86_CRTC_CONFIG_PTR(scrn);

	drmmode->cpp = cpp;
	drmmode->mode_res = drmModeGetResources(drmmode->fd);
	if (!drmmode->mode_res) {
		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
			   "failed to get resources: %s\n", strerror(errno));
		return FALSE;
	}

	xf86CrtcSetSizeRange(scrn, 320, 200, drmmode->mode_res->max_width,
			     drmmode->mode_res->max_height);
	for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
		drmmode_crtc_init(scrn, drmmode, i);

	for (i = 0; i < drmmode->mode_res->count_connectors; i++)
		drmmode_output_init(scrn, drmmode, i);

	xf86InitialConfiguration(scrn, TRUE);

	return TRUE;
}
Exemplo n.º 2
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
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;
}