/* * Given a display pointer and screen number, determine the name of * the DRI driver for the screen. (I.e. "r128", "tdfx", etc). * Return True for success, False for failure. */ static Bool GetDriverName(Display *dpy, int scrNum, char **driverName) { int directCapable; Bool b; int driverMajor, driverMinor, driverPatch; *driverName = NULL; if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) { ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n"); return False; } if (!directCapable) { ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n"); return False; } b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor, &driverPatch, driverName); if (!b) { ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum); return False; } InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", driverMajor, driverMinor, driverPatch, *driverName, scrNum); return True; }
/* * Xephyr - A kdrive X server thats runs in a host X window. * Authored by Matthew Allum <*****@*****.**> * * Copyright © 2007 OpenedHand Ltd * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of OpenedHand Ltd not be used in * advertising or publicity pertaining to distribution of the software without * specific, written prior permission. OpenedHand Ltd makes no * representations about the suitability of this software for any purpose. It * is provided "as is" without express or implied warranty. * * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. * * Authors: * Dodji Seketeli <*****@*****.**> */ #ifdef HAVE_CONFIG_H #include <kdrive-config.h> #endif #include <X11/Xutil.h> #include <X11/Xlibint.h> #include <GL/glx.h> #include "xf86dri.h" #include "hostx.h" #include "ephyrdri.h" #define _HAVE_XALLOC_DECLS #include "ephyrlog.h" #include "dixstruct.h" #include "pixmapstr.h" #ifndef TRUE #define TRUE 1 #endif /*TRUE*/ #ifndef FALSE #define FALSE 0 #endif /*FALSE*/ Bool ephyrDRIQueryDirectRenderingCapable(int a_screen, Bool *a_is_capable) { Display *dpy = hostx_get_display(); Bool is_ok = FALSE; EPHYR_RETURN_VAL_IF_FAIL(a_is_capable, FALSE); EPHYR_LOG("enter\n"); is_ok = XF86DRIQueryDirectRenderingCapable(dpy, DefaultScreen(dpy), a_is_capable); EPHYR_LOG("leave. is_capable:%d, is_ok=%d\n", *a_is_capable, is_ok); return is_ok; }
/* * Given a display pointer and screen number, determine the name of * the DRI driver for the screen (i.e., "i965", "radeon", "nouveau", etc). * Return True for success, False for failure. */ static Bool driGetDriverName(Display * dpy, int scrNum, char **driverName) { int directCapable; Bool b; int event, error; int driverMajor, driverMinor, driverPatch; *driverName = NULL; if (XF86DRIQueryExtension(dpy, &event, &error)) { /* DRI1 */ if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) { ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n"); return False; } if (!directCapable) { ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n"); return False; } b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor, &driverPatch, driverName); if (!b) { ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum); return False; } InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n", driverMajor, driverMinor, driverPatch, *driverName, scrNum); return True; } else if (DRI2QueryExtension(dpy, &event, &error)) { /* DRI2 */ char *dev; Bool ret = DRI2Connect(dpy, RootWindow(dpy, scrNum), driverName, &dev); if (ret) free(dev); return ret; } return False; }