diff options
-rw-r--r-- | src/gallium/include/state_tracker/drm_api.h | 19 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri2/dri_screen.c | 35 | ||||
-rw-r--r-- | src/gallium/state_trackers/dri2/dri_screen.h | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/egl_tracker.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/xorg/xorg_driver.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_api.h | 3 | ||||
-rw-r--r-- | src/gallium/winsys/drm/intel/gem/intel_be_device.c | 35 | ||||
-rw-r--r-- | src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 2 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_drm.c | 3 | ||||
-rw-r--r-- | src/gallium/winsys/drm/radeon/core/radeon_drm.h | 3 |
11 files changed, 63 insertions, 45 deletions
diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index 435435da29..5790b2f6c7 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -10,13 +10,30 @@ struct pipe_buffer; struct pipe_context; struct pipe_texture; +enum drm_create_screen_mode { + DRM_CREATE_NORMAL = 0, + DRM_CREATE_DRI1, + DRM_CREATE_DRIVER = 1024, + DRM_CREATE_MAX +}; + +/** + * Modes other than DRM_CREATE_NORMAL derive from this struct. + */ +/*@{*/ +struct drm_create_screen_arg { + enum drm_create_screen_mode mode; +}; +/*@}*/ + struct drm_api { /** * Special buffer functions */ /*@{*/ - struct pipe_screen* (*create_screen)(int drmFB, int pciID); + struct pipe_screen* (*create_screen)(int drm_fd, + struct drm_create_screen_arg *arg); struct pipe_context* (*create_context)(struct pipe_screen *screen); /*@}*/ diff --git a/src/gallium/state_trackers/dri2/dri_screen.c b/src/gallium/state_trackers/dri2/dri_screen.c index ab5878a4bc..ab33003f51 100644 --- a/src/gallium/state_trackers/dri2/dri_screen.c +++ b/src/gallium/state_trackers/dri2/dri_screen.c @@ -67,37 +67,6 @@ static const __DRIextension *dri_screen_extensions[] = { NULL }; - -static void -dri_get_drm_minor(struct dri_screen *screen) -{ - /* TODO get the real minor */ - screen->minor = 0; -} - - -static void -dri_get_device_id(struct dri_screen *screen) -{ - char path[512]; - FILE *file; - - /* - * There must be a better way to get the deviceID. - * XXX this only works on Linux. - */ - snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", screen->minor); - file = fopen(path, "r"); - if (!file) { - return; - } - - fgets(path, sizeof(path), file); - sscanf(path, "%x", &screen->deviceID); - fclose(file); -} - - static const __DRIconfig ** dri_fill_in_modes(__DRIscreenPrivate *psp, unsigned pixel_bits, unsigned depth_bits, @@ -212,13 +181,11 @@ dri_init_screen2(__DRIscreenPrivate *sPriv) screen->sPriv = sPriv; screen->fd = sPriv->fd; - dri_get_drm_minor(screen); - dri_get_device_id(screen); sPriv->private = (void *) screen; sPriv->extensions = dri_screen_extensions; - screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, screen->deviceID); + screen->pipe_screen = drm_api_hooks.create_screen(screen->fd, NULL); if (!screen->pipe_screen) { debug_printf("%s: failed to create pipe_screen\n", __FUNCTION__); goto fail; diff --git a/src/gallium/state_trackers/dri2/dri_screen.h b/src/gallium/state_trackers/dri2/dri_screen.h index fe2676d0be..3751ec6121 100644 --- a/src/gallium/state_trackers/dri2/dri_screen.h +++ b/src/gallium/state_trackers/dri2/dri_screen.h @@ -54,9 +54,7 @@ struct dri_screen struct dri_context *dummyContext; /* drm */ - int deviceID; int fd; - int minor; /* gallium */ struct pipe_winsys *pipe_winsys; diff --git a/src/gallium/state_trackers/egl/egl_tracker.c b/src/gallium/state_trackers/egl/egl_tracker.c index abdf84544f..8e62008461 100644 --- a/src/gallium/state_trackers/egl/egl_tracker.c +++ b/src/gallium/state_trackers/egl/egl_tracker.c @@ -146,7 +146,7 @@ drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) dev->drmFD = fd; drm_get_device_id(dev); - dev->screen = drm_api_hooks.create_screen(dev->drmFD, dev->deviceID); + dev->screen = drm_api_hooks.create_screen(dev->drmFD, NULL); if (!dev->screen) goto err_screen; dev->winsys = dev->screen->winsys; diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 8a2711e70c..45e831f0c2 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -476,7 +476,7 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) } if (!ms->screen) { - ms->screen = drm_api_hooks.create_screen(ms->fd, ms->PciInfo->device_id); + ms->screen = drm_api_hooks.create_screen(ms->fd, NULL); if (!ms->screen) { FatalError("Could not init pipe_screen\n"); diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.h b/src/gallium/winsys/drm/intel/gem/intel_be_api.h index 73e458d4ba..1c622f3b97 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_api.h +++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.h @@ -8,7 +8,8 @@ #include "intel_be_device.h" -struct pipe_screen *intel_be_create_screen(int drmFD, int pciID); +struct pipe_screen *intel_be_create_screen(int drmFD, + struct drm_create_screen_arg *arg); struct pipe_context *intel_be_create_context(struct pipe_screen *screen); #endif diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c index c866c2a2f1..907ac86637 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c +++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c @@ -14,6 +14,7 @@ #include "softpipe/sp_winsys.h" #include "intel_be_api.h" +#include <stdio.h> /* * Buffer @@ -290,11 +291,42 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id) return true; } +static void +intel_be_get_device_id(unsigned int *device_id) +{ + char path[512]; + FILE *file; + + /* + * FIXME: Fix this up to use a drm ioctl or whatever. + */ + + snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device"); + file = fopen(path, "r"); + if (!file) { + return; + } + + fgets(path, sizeof(path), file); + sscanf(path, "%x", device_id); + fclose(file); +} + struct pipe_screen * -intel_be_create_screen(int drmFD, int deviceID) +intel_be_create_screen(int drmFD, struct drm_create_screen_arg *arg) { struct intel_be_device *dev; struct pipe_screen *screen; + unsigned int deviceID; + + if (arg != NULL) { + switch(arg->mode) { + case DRM_CREATE_NORMAL: + break; + default: + return NULL; + } + } /* Allocate the private area */ dev = malloc(sizeof(*dev)); @@ -302,6 +334,7 @@ intel_be_create_screen(int drmFD, int deviceID) return NULL; memset(dev, 0, sizeof(*dev)); + intel_be_get_device_id(&deviceID); intel_be_init_device(dev, drmFD, deviceID); if (dev->softpipe) { diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c index 0b45b1ff1f..4e9b76a909 100644 --- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c +++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c @@ -267,7 +267,7 @@ nouveau_screen_create(__DRIscreenPrivate *psp) nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0); - nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, 0); + nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, NULL); if (!nv_screen->pscreen) { FREE(nv_screen); return NULL; diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index c0127e803f..a558fda140 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -8,7 +8,7 @@ #include "nouveau_bo.h" static struct pipe_screen * -nouveau_drm_create_screen(int fd, int pciid) +nouveau_drm_create_screen(int fd, struct drm_create_screen_arg *arg) { struct pipe_winsys *ws; struct nouveau_winsys *nvws; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 3446654e28..1f89d1b1d1 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -31,7 +31,8 @@ #include "radeon_drm.h" /* Create a pipe_screen. */ -struct pipe_screen* radeon_create_screen(int drmFB, int pciID) +struct pipe_screen* radeon_create_screen(int drmFB, + struct drm_create_screen_arg *arg ) { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index ca2d98ed1a..049f9984db 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -40,7 +40,8 @@ #include "radeon_r300.h" #include "radeon_winsys_softpipe.h" -struct pipe_screen* radeon_create_screen(int drmFB, int pciID); +struct pipe_screen* radeon_create_screen(int drmFB, + struct drm_create_screen_arg *arg); struct pipe_context* radeon_create_context(struct pipe_screen* screen); |