Пример #1
0
/*
 * Allocate, initialize and return a __DRIdisplayPrivate object.
 * This is called from __glXInitialize() when we are given a new
 * display pointer.
 */
_X_HIDDEN __GLXDRIdisplay *
dri2CreateDisplay(Display * dpy)
{
    __GLXDRIdisplayPrivate *pdp;
    int eventBase, errorBase;

    if (!DRI2QueryExtension(dpy, &eventBase, &errorBase))
        return NULL;

    pdp = Xmalloc(sizeof *pdp);
    if (pdp == NULL)
        return NULL;

    if (!DRI2QueryVersion(dpy, &pdp->driMajor, &pdp->driMinor)) {
        Xfree(pdp);
        return NULL;
    }

    pdp->driPatch = 0;
    pdp->swapAvailable = (pdp->driMinor >= 2);
    pdp->invalidateAvailable = (pdp->driMinor >= 3);

    pdp->base.destroyDisplay = dri2DestroyDisplay;
    pdp->base.createScreen = dri2CreateScreen;

    return &pdp->base;
}
Пример #2
0
static int dri2_connect(Display *dpy, char **driver)
{
	int eventBase, errorBase, major, minor;
	char *device;
	drm_magic_t magic;
	Window root;
	int fd;

	if (!DRI2InitDisplay(dpy, &ops)) {
		ERROR_MSG("DRI2InitDisplay failed");
		return -1;
	}

	if (!DRI2QueryExtension(dpy, &eventBase, &errorBase)) {
		ERROR_MSG("DRI2QueryExtension failed");
		return -1;
	}

	MSG("DRI2QueryExtension: eventBase=%d, errorBase=%d", eventBase, errorBase);

	if (!DRI2QueryVersion(dpy, &major, &minor)) {
		ERROR_MSG("DRI2QueryVersion failed");
		return -1;
	}

	MSG("DRI2QueryVersion: major=%d, minor=%d", major, minor);

	root = RootWindow(dpy, DefaultScreen(dpy));

	if (!DRI2Connect(dpy, root, driver, &device)) {
		ERROR_MSG("DRI2Connect failed");
		return -1;
	}

	MSG("DRI2Connect: driver=%s, device=%s", *driver, device);

	fd = open(device, O_RDWR);
	if (fd < 0) {
		ERROR_MSG("open failed");
		return fd;
	}

	if (drmGetMagic(fd, &magic)) {
		ERROR_MSG("drmGetMagic failed");
		return -1;
	}

	if (!DRI2Authenticate(dpy, root, magic)) {
		ERROR_MSG("DRI2Authenticate failed");
		return -1;
	}

	return fd;
}
Пример #3
0
static boolean
x11_screen_init_dri2(struct x11_screen *xscr)
{
   if (xscr->dri_major < 0) {
      int eventBase, errorBase;

      if (!DRI2QueryExtension(xscr->dpy, &eventBase, &errorBase) ||
          !DRI2QueryVersion(xscr->dpy, &xscr->dri_major, &xscr->dri_minor))
         xscr->dri_major = -1;
   }
   return (xscr->dri_major >= 0);
}