summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2009-08-26 16:39:29 +0800
committerBrian Paul <[email protected]>2009-08-26 16:40:22 -0600
commit49f245ea6bc2f9b7ee0345ff42cb00aa969cd316 (patch)
treea56a76775b14c331709725a3a506c158fe993ed7 /src/gallium/state_trackers
parent74b55970dc25d6b2a65f385fd298f141176cd4d3 (diff)
EGL_i915: Make struct drm_device per display.
This is to allow a driver to drive multiple displays. Signed-off-by: Chia-I Wu <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/egl/egl_context.c2
-rw-r--r--src/gallium/state_trackers/egl/egl_surface.c18
-rw-r--r--src/gallium/state_trackers/egl/egl_tracker.c67
-rw-r--r--src/gallium/state_trackers/egl/egl_tracker.h11
4 files changed, 55 insertions, 43 deletions
diff --git a/src/gallium/state_trackers/egl/egl_context.c b/src/gallium/state_trackers/egl/egl_context.c
index 52b6453d291..c4f7361ca0b 100644
--- a/src/gallium/state_trackers/egl/egl_context.c
+++ b/src/gallium/state_trackers/egl/egl_context.c
@@ -86,7 +86,7 @@ const struct dri_extension card_extensions[] = {
_EGLContext *
drm_create_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, _EGLContext *share_list, const EGLint *attrib_list)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev = lookup_drm_device(dpy);
struct drm_context *ctx;
struct drm_context *share = NULL;
struct st_context *st_share = NULL;
diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c
index 0cca68dc36f..3ef1945b93c 100644
--- a/src/gallium/state_trackers/egl/egl_surface.c
+++ b/src/gallium/state_trackers/egl/egl_surface.c
@@ -67,11 +67,11 @@ drm_create_framebuffer(const __GLcontextModes *visual,
}
static void
-drm_create_texture(_EGLDriver *drv,
+drm_create_texture(_EGLDisplay *dpy,
struct drm_screen *scrn,
unsigned w, unsigned h)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev = lookup_drm_device(dpy);
struct pipe_screen *screen = dev->screen;
struct pipe_surface *surface;
struct pipe_texture *texture;
@@ -137,9 +137,9 @@ err_tex:
*/
void
-drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen)
+drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev = lookup_drm_device(dpy);
screen->surf = NULL;
@@ -244,17 +244,17 @@ drm_show_screen_surface_mesa(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLScreen *screen,
_EGLSurface *surface, _EGLMode *mode)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev = lookup_drm_device(dpy);
struct drm_surface *surf = lookup_drm_surface(surface);
struct drm_screen *scrn = lookup_drm_screen(screen);
int ret;
unsigned int i, k;
if (scrn->shown)
- drm_takedown_shown_screen(drv, scrn);
+ drm_takedown_shown_screen(dpy, scrn);
- drm_create_texture(drv, scrn, mode->Width, mode->Height);
+ drm_create_texture(dpy, scrn, mode->Width, mode->Height);
if (!scrn->buffer)
return EGL_FALSE;
@@ -341,7 +341,7 @@ drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface)
struct drm_surface *surf = lookup_drm_surface(surface);
if (!_eglIsSurfaceBound(&surf->base)) {
if (surf->screen)
- drm_takedown_shown_screen(drv, surf->screen);
+ drm_takedown_shown_screen(dpy, surf->screen);
st_unreference_framebuffer(surf->stfb);
free(surf);
}
@@ -351,7 +351,7 @@ drm_destroy_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface)
EGLBoolean
drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev = lookup_drm_device(dpy);
struct drm_surface *surf = lookup_drm_surface(draw);
struct pipe_surface *back_surf;
diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c
index 57c81da767a..5140755001c 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.c
+++ b/src/gallium/state_trackers/egl/egl_tracker.c
@@ -26,9 +26,7 @@ extern const struct dri_extension card_extensions[];
static void
drm_unload(_EGLDriver *drv)
{
- struct drm_device *dev = (struct drm_device *)drv;
- dev->api->destroy(dev->api);
- free(dev);
+ free(drv);
}
/**
@@ -38,35 +36,33 @@ drm_unload(_EGLDriver *drv)
_EGLDriver *
_eglMain(const char *args)
{
- struct drm_device *drm;
+ _EGLDriver *drv;
- drm = (struct drm_device *) calloc(1, sizeof(struct drm_device));
- if (!drm) {
+ drv = (_EGLDriver *) calloc(1, sizeof(_EGLDriver));
+ if (!drv) {
return NULL;
}
- drm->api = drm_api_create();
-
/* First fill in the dispatch table with defaults */
- _eglInitDriverFallbacks(&drm->base);
+ _eglInitDriverFallbacks(drv);
/* then plug in our Drm-specific functions */
- drm->base.API.Initialize = drm_initialize;
- drm->base.API.Terminate = drm_terminate;
- drm->base.API.CreateContext = drm_create_context;
- drm->base.API.MakeCurrent = drm_make_current;
- drm->base.API.CreateWindowSurface = drm_create_window_surface;
- drm->base.API.CreatePixmapSurface = drm_create_pixmap_surface;
- drm->base.API.CreatePbufferSurface = drm_create_pbuffer_surface;
- drm->base.API.DestroySurface = drm_destroy_surface;
- drm->base.API.DestroyContext = drm_destroy_context;
- drm->base.API.CreateScreenSurfaceMESA = drm_create_screen_surface_mesa;
- drm->base.API.ShowScreenSurfaceMESA = drm_show_screen_surface_mesa;
- drm->base.API.SwapBuffers = drm_swap_buffers;
-
- drm->base.Name = "DRM/Gallium/Win";
- drm->base.Unload = drm_unload;
-
- return &drm->base;
+ drv->API.Initialize = drm_initialize;
+ drv->API.Terminate = drm_terminate;
+ drv->API.CreateContext = drm_create_context;
+ drv->API.MakeCurrent = drm_make_current;
+ drv->API.CreateWindowSurface = drm_create_window_surface;
+ drv->API.CreatePixmapSurface = drm_create_pixmap_surface;
+ drv->API.CreatePbufferSurface = drm_create_pbuffer_surface;
+ drv->API.DestroySurface = drm_destroy_surface;
+ drv->API.DestroyContext = drm_destroy_context;
+ drv->API.CreateScreenSurfaceMESA = drm_create_screen_surface_mesa;
+ drv->API.ShowScreenSurfaceMESA = drm_show_screen_surface_mesa;
+ drv->API.SwapBuffers = drm_swap_buffers;
+
+ drv->Name = "DRM/Gallium/Win";
+ drv->Unload = drm_unload;
+
+ return drv;
}
static void
@@ -145,7 +141,7 @@ static int drm_open_minor(int minor)
EGLBoolean
drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev;
struct drm_screen *screen = NULL;
drmModeConnectorPtr connector = NULL;
drmModeResPtr res = NULL;
@@ -154,6 +150,11 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
EGLint i;
int fd;
+ dev = (struct drm_device *) calloc(1, sizeof(struct drm_device));
+ if (!dev)
+ return EGL_FALSE;
+ dev->api = drm_api_create();
+
/* try the first node */
fd = drm_open_minor(0);
if (fd < 0)
@@ -200,6 +201,8 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
}
dev->count_screens = num_screens;
+ disp->DriverData = dev;
+
/* for now we only have one config */
_EGLConfig *config = calloc(1, sizeof(*config));
memset(config, 1, sizeof(*config));
@@ -227,17 +230,19 @@ drm_initialize(_EGLDriver *drv, _EGLDisplay *disp, EGLint *major, EGLint *minor)
err_screen:
drmClose(fd);
err_fd:
+ free(dev);
return EGL_FALSE;
}
EGLBoolean
drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
- struct drm_device *dev = (struct drm_device *)drv;
+ struct drm_device *dev = lookup_drm_device(dpy);
struct drm_screen *screen;
int i = 0;
_eglReleaseDisplayResources(drv, dpy);
+ _eglCleanupDisplay(dpy);
drmFreeVersion(dev->version);
@@ -245,7 +250,7 @@ drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
screen = dev->screens[i];
if (screen->shown)
- drm_takedown_shown_screen(drv, screen);
+ drm_takedown_shown_screen(dpy, screen);
drmModeFreeProperty(screen->dpms);
drmModeFreeConnector(screen->connector);
@@ -258,7 +263,9 @@ drm_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
drmClose(dev->drmFD);
- _eglCleanupDisplay(dpy);
+ dev->api->destroy(dev->api);
+ free(dev);
+ dpy->DriverData = NULL;
return EGL_TRUE;
}
diff --git a/src/gallium/state_trackers/egl/egl_tracker.h b/src/gallium/state_trackers/egl/egl_tracker.h
index 25f70d885e0..dd4730f9579 100644
--- a/src/gallium/state_trackers/egl/egl_tracker.h
+++ b/src/gallium/state_trackers/egl/egl_tracker.h
@@ -32,8 +32,6 @@ struct drm_context;
struct drm_device
{
- _EGLDriver base; /* base class/object */
-
/*
* pipe
*/
@@ -136,6 +134,13 @@ struct drm_screen
};
+static INLINE struct drm_device *
+lookup_drm_device(_EGLDisplay *d)
+{
+ return (struct drm_device *) d->DriverData;
+}
+
+
static INLINE struct drm_context *
lookup_drm_context(_EGLContext *c)
{
@@ -168,7 +173,7 @@ __GLcontextModes* drm_visual_from_config(_EGLConfig *conf);
* egl_surface.h
*/
/*@{*/
-void drm_takedown_shown_screen(_EGLDriver *drv, struct drm_screen *screen);
+void drm_takedown_shown_screen(_EGLDisplay *dpy, struct drm_screen *screen);
/*@}*/
/**