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);
/*@}*/
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,
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;
struct dri_context *dummyContext;
/* drm */
- int deviceID;
int fd;
- int minor;
/* gallium */
struct pipe_winsys *pipe_winsys;
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;
}
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");
#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
#include "softpipe/sp_winsys.h"
#include "intel_be_api.h"
+#include <stdio.h>
/*
* Buffer
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));
return NULL;
memset(dev, 0, sizeof(*dev));
+ intel_be_get_device_id(&deviceID);
intel_be_init_device(dev, drmFD, deviceID);
if (dev->softpipe) {
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;
#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;
#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);
#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);