Module: Mesa
Branch: gallium-xorg-driver
Commit: 4e5e0ff231e8a886770ea07ae67a41e10872f7f0
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e5e0ff231e8a886770ea07ae67a41e10872f7f0

Author: Jakob Bornecrantz <[email protected]>
Date:   Sun Feb  1 22:59:23 2009 +0100

intel: Initial commit of Xorg Driver

---

 src/gallium/winsys/drm/intel/xorg/Makefile        |   46 +++++++++++
 src/gallium/winsys/drm/intel/xorg/intel_api.c     |   10 +++
 src/gallium/winsys/drm/intel/xorg/intel_api.h     |   14 ++++
 src/gallium/winsys/drm/intel/xorg/intel_context.c |   83 +++++++++++++++++++++
 src/gallium/winsys/drm/intel/xorg/intel_device.c  |   57 ++++++++++++++
 5 files changed, 210 insertions(+), 0 deletions(-)

diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile 
b/src/gallium/winsys/drm/intel/xorg/Makefile
new file mode 100644
index 0000000..dc73966
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/Makefile
@@ -0,0 +1,46 @@
+TARGET     = modesetting_drv.so
+CFILES     = $(wildcard ./*.c)
+OBJECTS    = $(patsubst ./%.c,./%.o,$(CFILES))
+GALLIUMDIR = ../../../..
+TOP        = ../../../../../..
+
+include ${TOP}/configs/current
+
+CFLAGS = -DHAVE_CONFIG_H \
+         -g -Wall -Wimplicit-function-declaration -fPIC \
+         $(shell pkg-config --cflags pixman-1 xorg-server libdrm) \
+        -I../gem \
+         -I${GALLIUMDIR}/include \
+         -I${GALLIUMDIR}/drivers \
+         -I${GALLIUMDIR}/auxiliary \
+         -I${TOP}/src/mesa \
+         -I$(TOP)/include \
+         -I$(TOP)/src/egl/main
+
+LIBS = \
+       $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \
+       $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+       $(TOP)/src/gallium/drivers/i915simple/libi915simple.a \
+       $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+       $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \
+       $(GALLIUM_AUXILIARIES)
+#      --whole-archive \
+#      --no-whole-archive
+
+#############################################
+
+
+
+all: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile
+       $(TOP)/bin/mklib -noprefix -o $@ \
+       $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+
+clean:
+       rm -rf $(OBJECTS) $(TARGET)
+
+install:
+       cp $(TARGET) /opt/gem/lib/xorg/modules/drivers
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_api.c 
b/src/gallium/winsys/drm/intel/xorg/intel_api.c
new file mode 100644
index 0000000..5dc4a7b
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_api.c
@@ -0,0 +1,10 @@
+
+#include "intel_api.h"
+
+struct drm_api drm_api_hocks =
+{
+       .create_screen = intel_create_screen,
+       .create_context = intel_create_context,
+       .buffer_from_handle = intel_be_buffer_from_handle,
+       .handle_from_buffer = intel_be_handle_from_buffer,
+};
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_api.h 
b/src/gallium/winsys/drm/intel/xorg/intel_api.h
new file mode 100644
index 0000000..8ec165a
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_api.h
@@ -0,0 +1,14 @@
+
+#ifndef _INTEL_API_H_
+#define _INTEL_API_H_
+
+#include "pipe/p_compiler.h"
+
+#include "state_tracker/drm_api.h"
+
+#include "intel_be_device.h"
+
+struct pipe_screen *intel_create_screen(int drmFD, int pciID);
+struct pipe_context *intel_create_context(struct pipe_screen *screen);
+
+#endif
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_context.c 
b/src/gallium/winsys/drm/intel/xorg/intel_context.c
new file mode 100644
index 0000000..57e5ff7
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_context.c
@@ -0,0 +1,83 @@
+
+#include "i915simple/i915_screen.h"
+
+#include "intel_be_device.h"
+#include "intel_be_context.h"
+
+#include "pipe/p_defines.h"
+#include "pipe/p_context.h"
+
+#include "intel_api.h"
+
+struct intel_context
+{
+       struct intel_be_context base;
+
+       /* stuff */
+};
+
+/*
+ * Hardware lock functions.
+ * Doesn't do anything in EGL
+ */
+
+static void
+intel_lock_hardware(struct intel_be_context *context)
+{
+       (void)context;
+}
+
+static void
+intel_unlock_hardware(struct intel_be_context *context)
+{
+       (void)context;
+}
+
+static boolean
+intel_locked_hardware(struct intel_be_context *context)
+{
+       (void)context;
+       return FALSE;
+}
+
+
+/*
+ * Misc functions.
+ */
+static void
+intel_destroy_be_context(struct i915_winsys *winsys)
+{
+       struct intel_context *intel = (struct intel_context *)winsys;
+
+       intel_be_destroy_context(&intel->base);
+       free(intel);
+}
+
+struct pipe_context *
+intel_create_context(struct pipe_screen *screen)
+{
+       struct intel_context *intel;
+       struct pipe_context *pipe;
+       struct intel_be_device *device = (struct intel_be_device 
*)screen->winsys;
+
+       intel = (struct intel_context *)malloc(sizeof(*intel));
+       memset(intel, 0, sizeof(*intel));
+
+       intel->base.hardware_lock = intel_lock_hardware;
+       intel->base.hardware_unlock = intel_unlock_hardware;
+       intel->base.hardware_locked = intel_locked_hardware;
+
+       intel_be_init_context(&intel->base, device);
+
+       intel->base.base.destroy = intel_destroy_be_context;
+
+#if 0
+       pipe = intel_create_softpipe(intel, screen->winsys);
+#else
+       pipe = i915_create_context(screen, &device->base, &intel->base.base);
+#endif
+
+       pipe->priv = intel;
+
+       return pipe;
+}
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_device.c 
b/src/gallium/winsys/drm/intel/xorg/intel_device.c
new file mode 100644
index 0000000..74d23ad
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_device.c
@@ -0,0 +1,57 @@
+
+#include <stdio.h>
+#include "pipe/p_defines.h"
+#include "intel_be_device.h"
+#include "i915simple/i915_screen.h"
+
+#include "intel_api.h"
+
+struct intel_device
+{
+       struct intel_be_device base;
+
+       int deviceID;
+};
+
+static void
+intel_destroy_winsys(struct pipe_winsys *winsys)
+{
+       struct intel_device *dev = (struct intel_device *)winsys;
+
+       intel_be_destroy_device(&dev->base);
+
+       free(dev);
+}
+
+extern unsigned modesetting;
+extern unsigned modesettingModuleData;
+
+struct pipe_screen *
+intel_create_screen(int drmFD, int deviceID)
+{
+       struct intel_device *dev;
+       struct pipe_screen *screen;
+
+       /* HACK */
+       void *ptr1 = &modesetting;
+       void *ptr2 = &modesettingModuleData;
+       (void)ptr1;
+       (void)ptr2;
+
+       /* Allocate the private area */
+       dev = malloc(sizeof(*dev));
+       if (!dev)
+               return NULL;
+       memset(dev, 0, sizeof(*dev));
+
+       dev->deviceID = deviceID;
+
+       intel_be_init_device(&dev->base, drmFD, deviceID);
+
+       /* we need to hock our own destroy function in here */
+       dev->base.base.destroy = intel_destroy_winsys;
+
+       screen = i915_create_screen(&dev->base.base, deviceID);
+
+       return screen;
+}

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to