#include "eglmode.h"
#include "eglscreen.h"
#include "eglsurface.h"
+#include "egllog.h"
#include "intel_egl.h"
#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;
}
}
+
static EGLBoolean
drm_initialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
{
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);
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);