* This function, in turn, loads a specific DRI driver (ex: r200_dri.so).
*/
_EGLDriver *
-_eglMain(_EGLDisplay *dpy)
+_eglMain(_EGLDisplay *dpy, const char *args)
{
#if 1
const char *displayString = (const char *) dpy->NativeDisplay;
- const int card = atoi(displayString + 1);
+ const int card = atoi(args);
_EGLDriver *driver = NULL;
char driverName[1000];
#include "egldriver.h"
#include "eglglobals.h"
#include "eglhash.h"
-
-
-static char *
-my_strdup(const char *s)
-{
- if (s) {
- int l = strlen(s);
- char *s2 = malloc(l + 1);
- if (s2)
- strcpy(s2, s);
- return s2;
- }
- return NULL;
-}
+#include "eglstring.h"
/**
* Allocate a new _EGLDisplay object for the given nativeDisplay handle.
* We'll also try to determine the device driver name at this time.
+ *
+ * Note that nativeDisplay may be an X Display ptr, or a string.
*/
_EGLDisplay *
_eglNewDisplay(NativeDisplayType nativeDisplay)
dpy->Xdpy = (Display *) nativeDisplay;
#endif
- dpy->DriverName = my_strdup(_eglChooseDriver(dpy));
+ dpy->DriverName = _eglstrdup(_eglChooseDriver(dpy));
if (!dpy->DriverName) {
free(dpy);
return NULL;
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "eglconfig.h"
#include "eglcontext.h"
#include "egllog.h"
#include "eglmode.h"
#include "eglscreen.h"
+#include "eglstring.h"
#include "eglsurface.h"
#if defined(_EGL_PLATFORM_X)
/* XXX to do */
#endif
-const char *DefaultDriverName = "demodriver";
+const char *DefaultDriverName = ":0";
/**
const char *
_eglChooseDriver(_EGLDisplay *dpy)
{
- const char *name = (const char *) dpy->NativeDisplay;
+ const char *displayString = (const char *) dpy->NativeDisplay;
const char *driverName = NULL;
- if (!dpy->NativeDisplay) {
+ if (!displayString) {
/* choose a default */
- driverName = DefaultDriverName;
+ displayString = DefaultDriverName;
}
- else if (name && name[0] == ':' &&
- (name[1] >= '0' && name[1] <= '9') && !name[2]) {
+
+ /* extract default DriverArgs = whatever follows ':' */
+ if (displayString[0] == '!' ||
+ displayString[0] == ':') {
+ const char *args = strchr(displayString, ':');
+ if (args)
+ dpy->DriverArgs = _eglstrdup(args + 1);
+ }
+
+
+ if (displayString && displayString[0] == ':' &&
+ (displayString[1] >= '0' && displayString[1] <= '9') &&
+ !displayString[2]) {
/* XXX probe hardware here to determine which driver to open */
driverName = "libEGLdri";
}
- else if (name && name[0] == '!') {
+ else if (displayString && displayString[0] == '!') {
/* use specified driver name */
- driverName = name + 1;
+ driverName = displayString + 1;
}
else {
+ /* NativeDisplay is not a string! */
+
#if defined(_EGL_PLATFORM_X)
driverName = _xeglChooseDriver(dpy);
#elif defined(_EGL_PLATFORM_WINDOWS)
* \return new _EGLDriver object.
*/
_EGLDriver *
-_eglOpenDriver(_EGLDisplay *dpy, const char *driverName)
+_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args)
{
_EGLDriver *drv;
_EGLMain_t mainFunc;
return NULL;
}
- drv = mainFunc(dpy);
+ drv = mainFunc(dpy, args);
if (!drv) {
dlclose(lib);
return NULL;