i915: Fetch the real deviceID for EGL

This commit is contained in:
Jakob Bornecrantz 2008-07-07 14:29:11 +02:00
parent 1315f720ba
commit 687c8d8941
3 changed files with 34 additions and 4 deletions

View file

@ -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;
struct egl_drm_device*
/* 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;
}
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);

View file

@ -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

View file

@ -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);