summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-05-28 12:56:36 -0600
committerBrian Paul <[email protected]>2008-05-28 12:56:36 -0600
commit0c8908c411c434eda318b41b4f2a370a1e794831 (patch)
treed8a1fd0e24383fb3f5e279f33da4c5f8b4c271c5
parente94d383b9ba7964da9fefac2a55e10c00ee72392 (diff)
egl: added args string to _eglMain()
-rw-r--r--src/egl/drivers/demo/demo.c2
-rw-r--r--src/egl/drivers/dri/egldri.c4
-rw-r--r--src/egl/main/eglapi.c4
-rw-r--r--src/egl/main/egldisplay.c19
-rw-r--r--src/egl/main/egldisplay.h1
-rw-r--r--src/egl/main/egldriver.c35
-rw-r--r--src/egl/main/egldriver.h4
-rw-r--r--src/egl/main/egltypedefs.h2
8 files changed, 39 insertions, 32 deletions
diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c
index 1033f1b4ed6..6b8b71d16ba 100644
--- a/src/egl/drivers/demo/demo.c
+++ b/src/egl/drivers/demo/demo.c
@@ -286,7 +286,7 @@ demoMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface rea
* plug in API functions.
*/
_EGLDriver *
-_eglMain(_EGLDisplay *dpy)
+_eglMain(_EGLDisplay *dpy, const char *args)
{
DemoDriver *demo;
diff --git a/src/egl/drivers/dri/egldri.c b/src/egl/drivers/dri/egldri.c
index f00625a0593..677073fb3a0 100644
--- a/src/egl/drivers/dri/egldri.c
+++ b/src/egl/drivers/dri/egldri.c
@@ -79,11 +79,11 @@ driver_name_from_card_number(int card, char *driverName, int maxDriverName)
* 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];
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index fe63d36b803..984af4ea22e 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -68,7 +68,9 @@ eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor)
if (!dpyPriv) {
return EGL_FALSE;
}
- dpyPriv->Driver = _eglOpenDriver(dpyPriv, dpyPriv->DriverName);
+ dpyPriv->Driver = _eglOpenDriver(dpyPriv,
+ dpyPriv->DriverName,
+ dpyPriv->DriverArgs);
if (!dpyPriv->Driver) {
return EGL_FALSE;
}
diff --git a/src/egl/main/egldisplay.c b/src/egl/main/egldisplay.c
index 9c42194c611..b2d30d42749 100644
--- a/src/egl/main/egldisplay.c
+++ b/src/egl/main/egldisplay.c
@@ -11,25 +11,14 @@
#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)
@@ -46,7 +35,7 @@ _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;
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index be134374ca4..e2ebab0b218 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -14,6 +14,7 @@ struct _egl_display
EGLDisplay Handle;
const char *DriverName;
+ const char *DriverArgs;
_EGLDriver *Driver;
EGLint NumScreens;
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index cbdd47948db..599077190af 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -6,6 +6,7 @@
#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "eglconfig.h"
#include "eglcontext.h"
@@ -15,6 +16,7 @@
#include "egllog.h"
#include "eglmode.h"
#include "eglscreen.h"
+#include "eglstring.h"
#include "eglsurface.h"
#if defined(_EGL_PLATFORM_X)
@@ -25,7 +27,7 @@
/* XXX to do */
#endif
-const char *DefaultDriverName = "demodriver";
+const char *DefaultDriverName = ":0";
/**
@@ -44,23 +46,36 @@ const char *DefaultDriverName = "demodriver";
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)
@@ -83,7 +98,7 @@ _eglChooseDriver(_EGLDisplay *dpy)
* \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;
@@ -110,7 +125,7 @@ _eglOpenDriver(_EGLDisplay *dpy, const char *driverName)
return NULL;
}
- drv = mainFunc(dpy);
+ drv = mainFunc(dpy, args);
if (!drv) {
dlclose(lib);
return NULL;
diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h
index bde726e25e0..9c505880b7a 100644
--- a/src/egl/main/egldriver.h
+++ b/src/egl/main/egldriver.h
@@ -42,7 +42,7 @@ struct _egl_driver
};
-extern _EGLDriver *_eglMain(_EGLDisplay *dpy);
+extern _EGLDriver *_eglMain(_EGLDisplay *dpy, const char *args);
extern const char *
@@ -50,7 +50,7 @@ _eglChooseDriver(_EGLDisplay *dpy);
extern _EGLDriver *
-_eglOpenDriver(_EGLDisplay *dpy, const char *DriverName);
+_eglOpenDriver(_EGLDisplay *dpy, const char *driverName, const char *args);
extern EGLBoolean
diff --git a/src/egl/main/egltypedefs.h b/src/egl/main/egltypedefs.h
index 53810a5a440..b1c8ec1f02e 100644
--- a/src/egl/main/egltypedefs.h
+++ b/src/egl/main/egltypedefs.h
@@ -30,7 +30,7 @@ typedef struct _egl_thread_info _EGLThreadInfo;
typedef void (*_EGLProc)();
-typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy);
+typedef _EGLDriver *(*_EGLMain_t)(_EGLDisplay *dpy, const char *args);
#endif /* EGLTYPEDEFS_INCLUDED */