summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2010-05-27 00:38:30 +0200
committerJakob Bornecrantz <[email protected]>2010-06-06 12:29:28 +0100
commitf9d9574913c5edb92191ac3f5e8d011452427852 (patch)
treeabdab8c910f4c07e3e11b05bce997df3a9ae3ae3
parent76aed4b070be8950fd8ea5caff59321885ff0a06 (diff)
gallium: Convert state trackers to drm driver interface
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.h2
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c5
-rw-r--r--src/gallium/state_trackers/dri/sw/drisw.c1
-rw-r--r--src/gallium/state_trackers/egl/kms/native_kms.c41
-rw-r--r--src/gallium/state_trackers/egl/kms/native_kms.h2
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c15
-rw-r--r--src/gallium/state_trackers/egl/x11/native_x11.c30
-rw-r--r--src/gallium/state_trackers/egl/x11/native_x11.h4
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c1
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c2
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c27
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h2
-rw-r--r--src/gallium/targets/xorg-radeon/Makefile1
13 files changed, 35 insertions, 98 deletions
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.h b/src/gallium/state_trackers/dri/common/dri_screen.h
index 9ff925d4bef..087ae8d2a4a 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.h
+++ b/src/gallium/state_trackers/dri/common/dri_screen.h
@@ -39,7 +39,6 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
#include "state_tracker/st_api.h"
-#include "state_tracker/drm_api.h"
struct dri_context;
struct dri_drawable;
@@ -75,7 +74,6 @@ struct dri_screen
enum st_attachment_type statt);
/* gallium */
- struct drm_api *api;
boolean d_depth_bits_last;
boolean sd_depth_bits_last;
boolean auto_fake_front;
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index f4cc8d77ebd..b3bf21f49b8 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -33,7 +33,7 @@
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_debug.h"
-#include "state_tracker/drm_api.h"
+#include "state_tracker/drm_driver.h"
#include "dri_screen.h"
#include "dri_context.h"
@@ -508,7 +508,6 @@ dri2_init_screen(__DRIscreen * sPriv)
if (!screen)
return NULL;
- screen->api = drm_api_create();
screen->sPriv = sPriv;
screen->fd = sPriv->fd;
screen->lookup_egl_image = dri2_lookup_egl_image;
@@ -518,7 +517,7 @@ dri2_init_screen(__DRIscreen * sPriv)
sPriv->private = (void *)screen;
sPriv->extensions = dri_screen_extensions;
- pscreen = screen->api->create_screen(screen->api, screen->fd);
+ pscreen = driver_descriptor.create_screen(screen->fd);
/* dri_init_screen_helper checks pscreen for us */
configs = dri_init_screen_helper(screen, pscreen, 32);
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index dcf645593fb..23e99aa0add 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -255,7 +255,6 @@ drisw_init_screen(__DRIscreen * sPriv)
if (!screen)
return NULL;
- screen->api = NULL; /* not needed */
screen->sPriv = sPriv;
screen->fd = -1;
screen->allocate_textures = drisw_allocate_textures;
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c
index bfb4a9d2588..8f667f1ec13 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.c
+++ b/src/gallium/state_trackers/egl/kms/native_kms.c
@@ -33,6 +33,7 @@
#include "egllog.h"
#include "native_kms.h"
+#include "state_tracker/drm_driver.h"
static boolean
kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
@@ -657,8 +658,6 @@ kms_display_destroy(struct native_display *ndpy)
if (kdpy->fd >= 0)
drmClose(kdpy->fd);
- if (kdpy->api && kdpy->api->destroy)
- kdpy->api->destroy(kdpy->api);
FREE(kdpy);
}
@@ -674,7 +673,7 @@ kms_display_init_screen(struct native_display *ndpy)
fd = kdpy->fd;
if (fd >= 0) {
drmVersionPtr version = drmGetVersion(fd);
- if (!version || strcmp(version->name, kdpy->api->driver_name)) {
+ if (!version || strcmp(version->name, driver_descriptor.driver_name)) {
if (version) {
_eglLog(_EGL_WARNING, "unknown driver name %s", version->name);
drmFreeVersion(version);
@@ -689,7 +688,7 @@ kms_display_init_screen(struct native_display *ndpy)
drmFreeVersion(version);
}
else {
- fd = drmOpen(kdpy->api->driver_name, NULL);
+ fd = drmOpen(driver_descriptor.driver_name, NULL);
}
if (fd < 0) {
@@ -704,7 +703,7 @@ kms_display_init_screen(struct native_display *ndpy)
}
#endif
- kdpy->base.screen = kdpy->api->create_screen(kdpy->api, fd);
+ kdpy->base.screen = driver_descriptor.create_screen(fd);
if (!kdpy->base.screen) {
_eglLog(_EGL_WARNING, "failed to create DRM screen");
drmClose(fd);
@@ -724,8 +723,7 @@ static struct native_display_modeset kms_display_modeset = {
};
static struct native_display *
-kms_create_display(int fd, struct native_event_handler *event_handler,
- struct drm_api *api)
+kms_create_display(int fd, struct native_event_handler *event_handler)
{
struct kms_display *kdpy;
@@ -734,14 +732,6 @@ kms_create_display(int fd, struct native_event_handler *event_handler,
return NULL;
kdpy->event_handler = event_handler;
-
- kdpy->api = api;
- if (!kdpy->api) {
- _eglLog(_EGL_WARNING, "failed to create DRM API");
- FREE(kdpy);
- return NULL;
- }
-
kdpy->fd = fd;
if (!kms_display_init_screen(&kdpy->base)) {
kms_display_destroy(&kdpy->base);
@@ -790,21 +780,13 @@ native_get_probe_result(struct native_probe *nprobe)
return NATIVE_PROBE_UNKNOWN;
}
-/* the api is destroyed with the native display */
-static struct drm_api *drm_api;
-
const char *
native_get_name(void)
{
static char kms_name[32];
- if (!drm_api)
- drm_api = drm_api_create();
- if (drm_api)
- util_snprintf(kms_name, sizeof(kms_name), "KMS/%s", drm_api->name);
- else
- util_snprintf(kms_name, sizeof(kms_name), "KMS");
+ util_snprintf(kms_name, sizeof(kms_name), "KMS/%s", driver_descriptor.name);
return kms_name;
}
@@ -816,15 +798,8 @@ native_create_display(EGLNativeDisplayType dpy,
struct native_display *ndpy = NULL;
int fd;
- if (!drm_api)
- drm_api = drm_api_create();
-
- if (drm_api) {
- /* well, this makes fd 0 being ignored */
- fd = (dpy != EGL_DEFAULT_DISPLAY) ?
- (int) pointer_to_intptr((void *) dpy) : -1;
- ndpy = kms_create_display(fd, event_handler, drm_api);
- }
+ fd = (dpy != EGL_DEFAULT_DISPLAY) ? (int) pointer_to_intptr((void *) dpy) : -1;
+ ndpy = kms_create_display(fd, event_handler);
return ndpy;
}
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h
index d69c8d38c83..14cf5a641a8 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.h
+++ b/src/gallium/state_trackers/egl/kms/native_kms.h
@@ -32,7 +32,6 @@
#include "pipe/p_compiler.h"
#include "util/u_format.h"
#include "pipe/p_state.h"
-#include "state_tracker/drm_api.h"
#include "common/native.h"
#include "common/native_helper.h"
@@ -53,7 +52,6 @@ struct kms_display {
struct native_event_handler *event_handler;
int fd;
- struct drm_api *api;
drmModeResPtr resources;
struct kms_config *config;
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 3f802dd713f..0ce7c0be64b 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -32,7 +32,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "state_tracker/drm_api.h"
+#include "state_tracker/drm_driver.h"
#include "egllog.h"
#include "native_x11.h"
@@ -50,7 +50,6 @@ struct dri2_display {
struct native_event_handler *event_handler;
- struct drm_api *api;
struct x11_screen *xscr;
int xscr_number;
const char *dri_driver;
@@ -662,8 +661,6 @@ dri2_display_destroy(struct native_display *ndpy)
x11_screen_destroy(dri2dpy->xscr);
if (dri2dpy->own_dpy)
XCloseDisplay(dri2dpy->dpy);
- if (dri2dpy->api && dri2dpy->api->destroy)
- dri2dpy->api->destroy(dri2dpy->api);
FREE(dri2dpy);
}
@@ -695,7 +692,7 @@ static boolean
dri2_display_init_screen(struct native_display *ndpy)
{
struct dri2_display *dri2dpy = dri2_display(ndpy);
- const char *driver = dri2dpy->api->name;
+ const char *driver = driver_descriptor.name;
int fd;
if (!x11_screen_support(dri2dpy->xscr, X11_SCREEN_EXTENSION_DRI2) ||
@@ -709,7 +706,7 @@ dri2_display_init_screen(struct native_display *ndpy)
if (!dri2dpy->dri_driver || !driver ||
strcmp(dri2dpy->dri_driver, driver) != 0) {
_eglLog(_EGL_WARNING, "Driver mismatch: %s != %s",
- dri2dpy->dri_driver, dri2dpy->api->name);
+ dri2dpy->dri_driver, driver);
return FALSE;
}
@@ -718,7 +715,7 @@ dri2_display_init_screen(struct native_display *ndpy)
if (fd < 0)
return FALSE;
- dri2dpy->base.screen = dri2dpy->api->create_screen(dri2dpy->api, fd);
+ dri2dpy->base.screen = driver_descriptor.create_screen(fd);
if (!dri2dpy->base.screen) {
_eglLog(_EGL_WARNING, "failed to create DRM screen");
return FALSE;
@@ -742,8 +739,7 @@ dri2_display_hash_table_compare(void *key1, void *key2)
struct native_display *
x11_create_dri2_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler,
- struct drm_api *api)
+ struct native_event_handler *event_handler)
{
struct dri2_display *dri2dpy;
@@ -752,7 +748,6 @@ x11_create_dri2_display(EGLNativeDisplayType dpy,
return NULL;
dri2dpy->event_handler = event_handler;
- dri2dpy->api = api;
dri2dpy->dpy = dpy;
if (!dri2dpy->dpy) {
diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c
index b6d51bbf9fb..5d71778410b 100644
--- a/src/gallium/state_trackers/egl/x11/native_x11.c
+++ b/src/gallium/state_trackers/egl/x11/native_x11.c
@@ -27,15 +27,14 @@
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_string.h"
-#include "state_tracker/drm_api.h"
#include "egllog.h"
#include "native_x11.h"
#include "x11_screen.h"
-#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */
+#include "state_tracker/drm_driver.h"
-static struct drm_api *api;
+#define X11_PROBE_MAGIC 0x11980BE /* "X11PROBE" */
static void
x11_probe_destroy(struct native_probe *nprobe)
@@ -96,15 +95,12 @@ native_get_probe_result(struct native_probe *nprobe)
if (!nprobe || nprobe->magic != X11_PROBE_MAGIC)
return NATIVE_PROBE_UNKNOWN;
- if (!api)
- api = drm_api_create();
-
/* this is a software driver */
- if (!api)
+ if (!driver_descriptor.create_screen)
return NATIVE_PROBE_SUPPORTED;
/* the display does not support DRI2 or the driver mismatches */
- if (!nprobe->data || strcmp(api->name, (const char *) nprobe->data) != 0)
+ if (!nprobe->data || strcmp(driver_descriptor.name, (const char *) nprobe->data) != 0)
return NATIVE_PROBE_FALLBACK;
return NATIVE_PROBE_EXACT;
@@ -115,13 +111,7 @@ native_get_name(void)
{
static char x11_name[32];
- if (!api)
- api = drm_api_create();
-
- if (api)
- util_snprintf(x11_name, sizeof(x11_name), "X11/%s", api->name);
- else
- util_snprintf(x11_name, sizeof(x11_name), "X11");
+ util_snprintf(x11_name, sizeof(x11_name), "X11/%s", driver_descriptor.name);
return x11_name;
}
@@ -133,12 +123,12 @@ native_create_display(EGLNativeDisplayType dpy,
struct native_display *ndpy = NULL;
boolean force_sw;
- if (!api)
- api = drm_api_create();
-
force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE);
- if (api && !force_sw) {
- ndpy = x11_create_dri2_display(dpy, event_handler, api);
+ if (!driver_descriptor.create_screen)
+ force_sw = TRUE;
+
+ if (!force_sw) {
+ ndpy = x11_create_dri2_display(dpy, event_handler);
}
if (!ndpy) {
diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h
index 1678403b459..e16da935c0b 100644
--- a/src/gallium/state_trackers/egl/x11/native_x11.h
+++ b/src/gallium/state_trackers/egl/x11/native_x11.h
@@ -26,7 +26,6 @@
#ifndef _NATIVE_X11_H_
#define _NATIVE_X11_H_
-#include "state_tracker/drm_api.h"
#include "common/native.h"
struct native_display *
@@ -35,7 +34,6 @@ x11_create_ximage_display(EGLNativeDisplayType dpy,
struct native_display *
x11_create_dri2_display(EGLNativeDisplayType dpy,
- struct native_event_handler *event_handler,
- struct drm_api *api);
+ struct native_event_handler *event_handler);
#endif /* _NATIVE_X11_H_ */
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index f1a07bd863b..627754a0a4f 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -50,6 +50,7 @@
#include <X11/extensions/dpms.h>
#endif
+#include "state_tracker/drm_driver.h"
#include "util/u_inlines.h"
#include "util/u_rect.h"
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index 4e01bd10306..704aed6a82c 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -42,6 +42,8 @@
#include "util/u_format.h"
+#include "state_tracker/drm_driver.h"
+
/* Make all the #if cases in the code esier to read */
#ifndef DRI2INFOREC_VERSION
#define DRI2INFOREC_VERSION 1
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index 6b6e2009fea..9357cd5763f 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -51,6 +51,7 @@
#include <pciaccess.h>
+#include "state_tracker/drm_driver.h"
#include "pipe/p_context.h"
#include "xorg_tracker.h"
#include "xorg_winsys.h"
@@ -267,18 +268,12 @@ drv_init_drm(ScrnInfoPtr pScrn)
);
- ms->api = drm_api_create();
- ms->fd = drmOpen(ms->api ? ms->api->driver_name : NULL, BusID);
+ ms->fd = drmOpen(driver_descriptor.driver_name, BusID);
xfree(BusID);
if (ms->fd >= 0)
return TRUE;
- if (ms->api && ms->api->destroy)
- ms->api->destroy(ms->api);
-
- ms->api = NULL;
-
return FALSE;
}
@@ -290,10 +285,6 @@ drv_close_drm(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
- if (ms->api && ms->api->destroy)
- ms->api->destroy(ms->api);
- ms->api = NULL;
-
drmClose(ms->fd);
ms->fd = -1;
@@ -314,17 +305,10 @@ drv_init_resource_management(ScrnInfoPtr pScrn)
if (ms->screen || ms->kms)
return TRUE;
- if (ms->api) {
- ms->screen = ms->api->create_screen(ms->api, ms->fd);
-
- if (ms->screen)
- return TRUE;
+ ms->screen = driver_descriptor.create_screen(ms->fd);
- if (ms->api->destroy)
- ms->api->destroy(ms->api);
-
- ms->api = NULL;
- }
+ if (ms->screen)
+ return TRUE;
#ifdef HAVE_LIBKMS
if (!kms_create(ms->fd, &ms->kms))
@@ -430,7 +414,6 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
}
ms->fd = -1;
- ms->api = NULL;
if (!drv_init_drm(pScrn))
return FALSE;
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index 25da9b1a3bd..cc2d379af15 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -49,7 +49,6 @@
#include "pipe/p_screen.h"
#include "util/u_inlines.h"
#include "util/u_debug.h"
-#include "state_tracker/drm_api.h"
#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg);
@@ -123,7 +122,6 @@ typedef struct _modesettingRec
struct kms_bo *root_bo;
/* gallium */
- struct drm_api *api;
struct pipe_screen *screen;
struct pipe_context *ctx;
boolean d_depth_bits_last;
diff --git a/src/gallium/targets/xorg-radeon/Makefile b/src/gallium/targets/xorg-radeon/Makefile
index a4951c4bba0..c438ec48473 100644
--- a/src/gallium/targets/xorg-radeon/Makefile
+++ b/src/gallium/targets/xorg-radeon/Makefile
@@ -4,6 +4,7 @@ include $(TOP)/configs/current
LIBNAME = radeon_drv.so
C_SOURCES = \
+ radeon_target.c \
radeon_xorg.c
DRIVER_DEFINES = \