diff options
author | Jakob Bornecrantz <[email protected]> | 2008-07-07 14:29:11 +0200 |
---|---|---|
committer | Jakob Bornecrantz <[email protected]> | 2008-07-07 14:29:11 +0200 |
commit | 687c8d8941bb62fdb4fbdbb0ff5f359851c290b5 (patch) | |
tree | 0d087c30e46286a445d5fe8b444f2ab5c3eec7b9 | |
parent | 1315f720ba80596b866103a7e153bfc2f2bd267b (diff) |
i915: Fetch the real deviceID for EGL
-rw-r--r-- | src/gallium/winsys/egl_drm/intel/intel_egl.c | 30 | ||||
-rw-r--r-- | src/gallium/winsys/egl_drm/intel/intel_egl.h | 5 | ||||
-rw-r--r-- | src/gallium/winsys/egl_drm/intel/intel_screen.c | 3 |
3 files changed, 34 insertions, 4 deletions
diff --git a/src/gallium/winsys/egl_drm/intel/intel_egl.c b/src/gallium/winsys/egl_drm/intel/intel_egl.c index 9e12a024eb0..ed96703e37e 100644 --- a/src/gallium/winsys/egl_drm/intel/intel_egl.c +++ b/src/gallium/winsys/egl_drm/intel/intel_egl.c @@ -13,6 +13,7 @@ #include "eglmode.h" #include "eglscreen.h" #include "eglsurface.h" +#include "egllog.h" #include "intel_egl.h" @@ -23,15 +24,38 @@ #include "state_tracker/st_public.h" -struct egl_drm_device* egl_drm_create_device(int drmFD); +static void +drm_get_device_id(struct egl_drm_device *device) +{ + char path[512]; + FILE *file; + + /* TODO get the real minor */ + int minor = 0; + + snprintf(path, sizeof(path), "/sys/class/drm/card%d/device/device", minor); + file = fopen(path, "r"); + if (!file) { + _eglLog(_EGL_WARNING, "Could not retrive device ID\n"); + return; + } -struct egl_drm_device* + fgets(path, sizeof( path ), file); + sscanf(path, "%x", &device->deviceID); + fclose(file); +} + +static struct egl_drm_device* egl_drm_create_device(int drmFD) { struct egl_drm_device *device = malloc(sizeof(*device)); memset(device, 0, sizeof(*device)); device->drmFD = drmFD; + device->version = drmGetVersion(device->drmFD); + + drm_get_device_id(device); + if (!intel_create_device(device)) { free(device); return NULL; @@ -105,6 +129,7 @@ drm_add_modes_from_connector(_EGLScreen *screen, drmModeConnectorPtr connector) } } + static EGLBoolean drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor) { @@ -183,6 +208,7 @@ drm_terminate(_EGLDriver *drv, EGLDisplay dpy) struct drm_driver *drm_drv = (struct drm_driver *)drv; intel_destroy_device(drm_drv->device); + drmFreeVersion(drm_drv->device->version); drmClose(drm_drv->device->drmFD); diff --git a/src/gallium/winsys/egl_drm/intel/intel_egl.h b/src/gallium/winsys/egl_drm/intel/intel_egl.h index 84b6c212bfd..1ee27e0847a 100644 --- a/src/gallium/winsys/egl_drm/intel/intel_egl.h +++ b/src/gallium/winsys/egl_drm/intel/intel_egl.h @@ -2,10 +2,15 @@ #ifndef _INTEL_EGL_H_ #define _INTEL_EGL_H_ +#include <xf86drm.h> + struct egl_drm_device { void *priv; int drmFD; + + drmVersionPtr version; + int deviceID; }; struct egl_drm_context diff --git a/src/gallium/winsys/egl_drm/intel/intel_screen.c b/src/gallium/winsys/egl_drm/intel/intel_screen.c index 12f605e0bea..8e6d184440e 100644 --- a/src/gallium/winsys/egl_drm/intel/intel_screen.c +++ b/src/gallium/winsys/egl_drm/intel/intel_screen.c @@ -53,8 +53,7 @@ intel_create_device(struct egl_drm_device *device) device->priv = (void *)intel_screen; intel_screen->device = device; - /** TODO JB: ugly hack */ - intel_screen->deviceID = PCI_CHIP_I945_GM; + intel_screen->deviceID = device->deviceID; intel_be_init_device(&intel_screen->base, device->drmFD, PCI_CHIP_I945_GM); |