summaryrefslogtreecommitdiff
path: root/src/gallium/winsys/drm
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/winsys/drm')
-rw-r--r--src/gallium/winsys/drm/Makefile32
-rw-r--r--src/gallium/winsys/drm/Makefile.template19
-rw-r--r--src/gallium/winsys/drm/intel/Makefile21
-rw-r--r--src/gallium/winsys/drm/intel/common/Makefile23
-rw-r--r--src/gallium/winsys/drm/intel/common/Makefile.template64
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c429
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h69
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_context.c107
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_context.h40
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.c296
-rw-r--r--src/gallium/winsys/drm/intel/common/intel_be_device.h72
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c949
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h138
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h102
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c268
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c377
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h115
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c161
-rw-r--r--src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c968
-rw-r--r--src/gallium/winsys/drm/intel/dri/Makefile33
-rw-r--r--src/gallium/winsys/drm/intel/dri/SConscript41
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h24
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_context.c337
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_context.h164
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_lock.c102
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_reg.h53
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_screen.c703
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_screen.h122
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c260
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h47
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c82
-rw-r--r--src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h39
-rw-r--r--src/gallium/winsys/drm/intel/dri/server/i830_common.h255
-rw-r--r--src/gallium/winsys/drm/intel/dri/server/i830_dri.h62
-rw-r--r--src/gallium/winsys/drm/intel/dri2/Makefile22
-rw-r--r--src/gallium/winsys/drm/intel/egl/Makefile13
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_api.c10
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_api.h14
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_context.c83
-rw-r--r--src/gallium/winsys/drm/intel/egl/intel_device.c48
-rw-r--r--src/gallium/winsys/drm/intel/gem/Makefile12
-rw-r--r--src/gallium/winsys/drm/intel/gem/Makefile.template64
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_api.c15
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_api.h14
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c7
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_context.c44
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_context.h17
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_device.c111
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_device.h32
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_be_fence.h18
-rw-r--r--src/gallium/winsys/drm/intel/xorg/Makefile43
-rw-r--r--src/gallium/winsys/drm/intel/xorg/intel_xorg.c156
-rw-r--r--src/gallium/winsys/drm/nouveau/Makefile21
-rw-r--r--src/gallium/winsys/drm/nouveau/common/Makefile22
-rw-r--r--src/gallium/winsys/drm/nouveau/common/Makefile.template59
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_context.c206
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_context.h59
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_local.h19
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_screen.c31
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_screen.h27
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c242
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h44
-rw-r--r--src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c101
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/Makefile10
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_context.c (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.c)62
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_context.h (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.h)14
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h (renamed from src/gallium/winsys/drm/nouveau/common/nouveau_dri.h)0
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c (renamed from src/gallium/winsys/drm/nouveau/common/nouveau_lock.c)5
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.c)94
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h (renamed from src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.h)9
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c32
-rw-r--r--src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h11
-rw-r--r--src/gallium/winsys/drm/nouveau/dri2/Makefile26
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/Makefile13
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c194
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h5
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c (renamed from src/gallium/winsys/drm/nouveau/common/nouveau_winsys.c)73
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c204
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h52
-rw-r--r--src/gallium/winsys/drm/radeon/Makefile36
-rw-r--r--src/gallium/winsys/drm/radeon/core/Makefile18
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.c (renamed from src/gallium/winsys/drm/radeon/radeon_buffer.c)106
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.h (renamed from src/gallium/winsys/drm/radeon/radeon_buffer.h)25
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.c122
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.h (renamed from src/gallium/winsys/drm/radeon/radeon_context.h)63
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.c (renamed from src/gallium/winsys/drm/radeon/radeon_r300.c)7
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.h (renamed from src/gallium/winsys/drm/radeon/radeon_r300.h)3
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c (renamed from src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c)26
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h (renamed from src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h)11
-rw-r--r--src/gallium/winsys/drm/radeon/dri2/Makefile25
-rw-r--r--src/gallium/winsys/drm/radeon/egl/Makefile25
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_context.c306
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_screen.c288
-rw-r--r--src/gallium/winsys/drm/radeon/radeon_screen.h41
-rw-r--r--src/gallium/winsys/drm/radeon/xorg/Makefile42
-rw-r--r--src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c157
96 files changed, 1622 insertions, 8611 deletions
diff --git a/src/gallium/winsys/drm/Makefile b/src/gallium/winsys/drm/Makefile
index a84fcd8418..fee0191643 100644
--- a/src/gallium/winsys/drm/Makefile
+++ b/src/gallium/winsys/drm/Makefile
@@ -1,38 +1,12 @@
-# src/gallium/winsys/drm/Makefile
-
+# src/gallium/winsys/Makefile
TOP = ../../../..
-
include $(TOP)/configs/current
SUBDIRS = $(GALLIUM_WINSYS_DRM_DIRS)
-default: $(TOP)/$(LIB_DIR)/gallium subdirs
-
-
-$(TOP)/$(LIB_DIR)/gallium:
- -mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-
-subdirs:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
- fi \
- done
-
-
-install:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) install) || exit 1 ; \
- fi \
- done
-
-
-clean:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) clean) ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
- -rm -f common/*.o
diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template
index cccf8abdfd..9f92cb4207 100644
--- a/src/gallium/winsys/drm/Makefile.template
+++ b/src/gallium/winsys/drm/Makefile.template
@@ -79,25 +79,24 @@ SHARED_INCLUDES = \
##### TARGETS #####
-default: depend symlinks $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) $(LIBNAME_EGL) $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME_EGL)
-
+default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME)
$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
- $(TOP)/bin/mklib -noprefix -o $@ \
+ $(MKLIB) -noprefix -o $@ \
$(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
$(LIBNAME_EGL): $(WINSYS_OBJECTS) $(LIBS)
- $(TOP)/bin/mklib -o $(LIBNAME_EGL) \
+ $(MKLIB) -o $(LIBNAME_EGL) \
-linker "$(CC)" \
-noprefix \
$(OBJECTS) $(MKLIB_OPTIONS) $(WINSYS_OBJECTS) $(PIPE_DRIVERS) $(WINOBJ) $(DRI_LIB_DEPS) \
--whole-archive $(LIBS) $(GALLIUM_AUXILIARIES) --no-whole-archive $(DRIVER_EXTRAS)
-$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(LIBNAME)
- $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+$(TOP)/$(LIB_DIR)/gallium:
+ mkdir -p $@
-$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME_EGL): $(LIBNAME_EGL)
- $(INSTALL) $(LIBNAME_EGL) $(TOP)/$(LIB_DIR)/gallium
+$(TOP)/$(LIB_DIR)/gallium/$(LIBNAME): $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
+ $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR)/gallium
depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
rm -f depend
@@ -118,8 +117,8 @@ clean:
install: $(LIBNAME)
- $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
- $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
+ $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
+ $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
include depend
diff --git a/src/gallium/winsys/drm/intel/Makefile b/src/gallium/winsys/drm/intel/Makefile
index eede9fc866..d8feef6824 100644
--- a/src/gallium/winsys/drm/intel/Makefile
+++ b/src/gallium/winsys/drm/intel/Makefile
@@ -1,25 +1,12 @@
+# src/gallium/winsys/drm/intel/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
+SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
-SUBDIRS = gem egl
-
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
- rm -f `find . -name depend`
-
-
-# Dummy install target
-install:
diff --git a/src/gallium/winsys/drm/intel/common/Makefile b/src/gallium/winsys/drm/intel/common/Makefile
deleted file mode 100644
index bf1a7d691f..0000000000
--- a/src/gallium/winsys/drm/intel/common/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = inteldrm
-
-C_SOURCES = \
- intel_be_batchbuffer.c \
- intel_be_context.c \
- intel_be_device.c \
- ws_dri_bufmgr.c \
- ws_dri_drmpool.c \
- ws_dri_fencemgr.c \
- ws_dri_mallocpool.c \
- ws_dri_slabpool.c
-
-
-include ./Makefile.template
-
-DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
- && pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-symlinks:
-
diff --git a/src/gallium/winsys/drm/intel/common/Makefile.template b/src/gallium/winsys/drm/intel/common/Makefile.template
deleted file mode 100644
index 02ed363a43..0000000000
--- a/src/gallium/winsys/drm/intel/common/Makefile.template
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*-makefile-*-
-
-
-# We still have a dependency on the "dri" buffer manager. Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
-#
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks $(LIBNAME)
-
-
-$(LIBNAME): $(OBJECTS) Makefile Makefile.template
- $(TOP)/bin/mklib -o $@ -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c
deleted file mode 100644
index bc13a5761e..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.c
+++ /dev/null
@@ -1,429 +0,0 @@
-
-#include "intel_be_batchbuffer.h"
-#include "intel_be_context.h"
-#include "intel_be_device.h"
-#include <errno.h>
-
-#include "xf86drm.h"
-
-static void
-intel_realloc_relocs(struct intel_be_batchbuffer *batch, int num_relocs)
-{
- unsigned long size = num_relocs * I915_RELOC0_STRIDE + I915_RELOC_HEADER;
-
- size *= sizeof(uint32_t);
- batch->reloc = realloc(batch->reloc, size);
- batch->reloc_size = num_relocs;
-}
-
-
-void
-intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch)
-{
- /*
- * Get a new, free batchbuffer.
- */
- drmBO *bo;
- struct drm_bo_info_req *req;
-
- driBOUnrefUserList(batch->list);
- driBOResetList(batch->list);
-
- /* base.size is the size available to the i915simple driver */
- batch->base.size = batch->device->max_batch_size - BATCH_RESERVED;
- batch->base.actual_size = batch->device->max_batch_size;
- driBOData(batch->buffer, batch->base.actual_size, NULL, NULL, 0);
-
- /*
- * Add the batchbuffer to the validate list.
- */
-
- driBOAddListItem(batch->list, batch->buffer,
- DRM_BO_FLAG_EXE | DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_EXE | DRM_BO_MASK_MEM,
- &batch->dest_location, &batch->node);
-
- req = &batch->node->bo_arg.d.req.bo_req;
-
- /*
- * Set up information needed for us to make relocations
- * relative to the underlying drm buffer objects.
- */
-
- driReadLockKernelBO();
- bo = driBOKernel(batch->buffer);
- req->presumed_offset = (uint64_t) bo->offset;
- req->hint = DRM_BO_HINT_PRESUMED_OFFSET;
- batch->drmBOVirtual = (uint8_t *) bo->virtual;
- driReadUnlockKernelBO();
-
- /*
- * Adjust the relocation buffer size.
- */
-
- if (batch->reloc_size > INTEL_MAX_RELOCS ||
- batch->reloc == NULL)
- intel_realloc_relocs(batch, INTEL_DEFAULT_RELOCS);
-
- assert(batch->reloc != NULL);
- batch->reloc[0] = 0; /* No relocs yet. */
- batch->reloc[1] = 1; /* Reloc type 1 */
- batch->reloc[2] = 0; /* Only a single relocation list. */
- batch->reloc[3] = 0; /* Only a single relocation list. */
-
- batch->base.map = driBOMap(batch->buffer, DRM_BO_FLAG_WRITE, 0);
- batch->poolOffset = driBOPoolOffset(batch->buffer);
- batch->base.ptr = batch->base.map;
- batch->dirty_state = ~0;
- batch->nr_relocs = 0;
- batch->flags = 0;
- batch->id = 0;//batch->intel->intelScreen->batch_id++;
-}
-
-/*======================================================================
- * Public functions
- */
-struct intel_be_batchbuffer *
-intel_be_batchbuffer_alloc(struct intel_be_context *intel)
-{
- struct intel_be_batchbuffer *batch = calloc(sizeof(*batch), 1);
-
- batch->intel = intel;
- batch->device = intel->device;
-
- driGenBuffers(intel->device->batchPool, "batchbuffer", 1,
- &batch->buffer, 4096,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_EXE, 0);
- batch->last_fence = NULL;
- batch->list = driBOCreateList(20);
- batch->reloc = NULL;
- intel_be_batchbuffer_reset(batch);
- return batch;
-}
-
-void
-intel_be_batchbuffer_free(struct intel_be_batchbuffer *batch)
-{
- if (batch->last_fence) {
- driFenceFinish(batch->last_fence,
- DRM_FENCE_TYPE_EXE, FALSE);
- driFenceUnReference(&batch->last_fence);
- }
- if (batch->base.map) {
- driBOUnmap(batch->buffer);
- batch->base.map = NULL;
- }
- driBOUnReference(batch->buffer);
- driBOFreeList(batch->list);
- if (batch->reloc)
- free(batch->reloc);
- batch->buffer = NULL;
- free(batch);
-}
-
-void
-intel_be_offset_relocation(struct intel_be_batchbuffer *batch,
- unsigned pre_add,
- struct _DriBufferObject *driBO,
- uint64_t val_flags,
- uint64_t val_mask)
-{
- int itemLoc;
- struct _drmBONode *node;
- uint32_t *reloc;
- struct drm_bo_info_req *req;
-
- driBOAddListItem(batch->list, driBO, val_flags, val_mask,
- &itemLoc, &node);
- req = &node->bo_arg.d.req.bo_req;
-
- if (!(req->hint & DRM_BO_HINT_PRESUMED_OFFSET)) {
-
- /*
- * Stop other threads from tampering with the underlying
- * drmBO while we're reading its offset.
- */
-
- driReadLockKernelBO();
- req->presumed_offset = (uint64_t) driBOKernel(driBO)->offset;
- driReadUnlockKernelBO();
- req->hint = DRM_BO_HINT_PRESUMED_OFFSET;
- }
-
- pre_add += driBOPoolOffset(driBO);
-
- if (batch->nr_relocs == batch->reloc_size)
- intel_realloc_relocs(batch, batch->reloc_size * 2);
-
- reloc = batch->reloc +
- (I915_RELOC_HEADER + batch->nr_relocs * I915_RELOC0_STRIDE);
-
- reloc[0] = ((uint8_t *)batch->base.ptr - batch->drmBOVirtual);
- i915_batchbuffer_dword(&batch->base, req->presumed_offset + pre_add);
- reloc[1] = pre_add;
- reloc[2] = itemLoc;
- reloc[3] = batch->dest_location;
- batch->nr_relocs++;
-}
-
-static void
-i915_drm_copy_reply(const struct drm_bo_info_rep * rep, drmBO * buf)
-{
- buf->handle = rep->handle;
- buf->flags = rep->flags;
- buf->size = rep->size;
- buf->offset = rep->offset;
- buf->mapHandle = rep->arg_handle;
- buf->proposedFlags = rep->proposed_flags;
- buf->start = rep->buffer_start;
- buf->fenceFlags = rep->fence_flags;
- buf->replyFlags = rep->rep_flags;
- buf->pageAlignment = rep->page_alignment;
-}
-
-static int
-i915_execbuf(struct intel_be_batchbuffer *batch,
- unsigned int used,
- boolean ignore_cliprects,
- drmBOList *list,
- struct drm_i915_execbuffer *ea)
-{
-// struct intel_be_context *intel = batch->intel;
- drmBONode *node;
- drmMMListHead *l;
- struct drm_i915_op_arg *arg, *first;
- struct drm_bo_op_req *req;
- struct drm_bo_info_rep *rep;
- uint64_t *prevNext = NULL;
- drmBO *buf;
- int ret = 0;
- uint32_t count = 0;
-
- first = NULL;
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
-
- arg = &node->bo_arg;
- req = &arg->d.req;
-
- if (!first)
- first = arg;
-
- if (prevNext)
- *prevNext = (unsigned long)arg;
-
- prevNext = &arg->next;
- req->bo_req.handle = node->buf->handle;
- req->op = drm_bo_validate;
- req->bo_req.flags = node->arg0;
- req->bo_req.mask = node->arg1;
- req->bo_req.hint |= 0;
- count++;
- }
-
- memset(ea, 0, sizeof(*ea));
- ea->num_buffers = count;
- ea->batch.start = batch->poolOffset;
- ea->batch.used = used;
-#if 0 /* ZZZ JB: no cliprects used */
- ea->batch.cliprects = intel->pClipRects;
- ea->batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects;
- ea->batch.DR1 = 0;
- ea->batch.DR4 = 0;((((GLuint) intel->drawX) & 0xffff) |
- (((GLuint) intel->drawY) << 16));
-#else
- ea->batch.cliprects = NULL;
- ea->batch.num_cliprects = 0;
- ea->batch.DR1 = 0;
- ea->batch.DR4 = 0;
-#endif
- ea->fence_arg.flags = DRM_I915_FENCE_FLAG_FLUSHED;
- ea->ops_list = (unsigned long) first;
- first->reloc_ptr = (unsigned long) batch->reloc;
- batch->reloc[0] = batch->nr_relocs;
-
- //return -EFAULT;
- do {
- ret = drmCommandWriteRead(batch->device->fd, DRM_I915_EXECBUFFER, ea,
- sizeof(*ea));
- } while (ret == -EAGAIN);
-
- if (ret != 0)
- return ret;
-
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
- arg = &node->bo_arg;
- rep = &arg->d.rep.bo_info;
-
- if (!arg->handled) {
- return -EFAULT;
- }
- if (arg->d.rep.ret)
- return arg->d.rep.ret;
-
- buf = node->buf;
- i915_drm_copy_reply(rep, buf);
- }
- return 0;
-}
-
-/* TODO: Push this whole function into bufmgr.
- */
-static struct _DriFenceObject *
-do_flush_locked(struct intel_be_batchbuffer *batch,
- unsigned int used,
- boolean ignore_cliprects, boolean allow_unlock)
-{
- struct intel_be_context *intel = batch->intel;
- struct _DriFenceObject *fo;
- drmFence fence;
- drmBOList *boList;
- struct drm_i915_execbuffer ea;
- int ret = 0;
-
- driBOValidateUserList(batch->list);
- boList = driGetdrmBOList(batch->list);
-
-#if 0 /* ZZZ JB Allways run */
- if (!(intel->numClipRects == 0 && !ignore_cliprects)) {
-#else
- if (1) {
-#endif
- ret = i915_execbuf(batch, used, ignore_cliprects, boList, &ea);
- } else {
- driPutdrmBOList(batch->list);
- fo = NULL;
- goto out;
- }
- driPutdrmBOList(batch->list);
- if (ret)
- abort();
-
- if (ea.fence_arg.error != 0) {
-
- /*
- * The hardware has been idled by the kernel.
- * Don't fence the driBOs.
- */
-
- if (batch->last_fence)
- driFenceUnReference(&batch->last_fence);
-#if 0 /* ZZZ JB: no _mesa_* funcs in gallium */
- _mesa_printf("fence error\n");
-#endif
- batch->last_fence = NULL;
- fo = NULL;
- goto out;
- }
-
- fence.handle = ea.fence_arg.handle;
- fence.fence_class = ea.fence_arg.fence_class;
- fence.type = ea.fence_arg.type;
- fence.flags = ea.fence_arg.flags;
- fence.signaled = ea.fence_arg.signaled;
-
- fo = driBOFenceUserList(batch->device->fenceMgr, batch->list,
- "SuperFence", &fence);
-
- if (driFenceType(fo) & DRM_I915_FENCE_TYPE_RW) {
- if (batch->last_fence)
- driFenceUnReference(&batch->last_fence);
- /*
- * FIXME: Context last fence??
- */
- batch->last_fence = fo;
- driFenceReference(fo);
- }
- out:
-#if 0 /* ZZZ JB: fix this */
- intel->vtbl.lost_hardware(intel);
-#else
- (void)intel;
-#endif
- return fo;
-}
-
-
-struct _DriFenceObject *
-intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch)
-{
- struct intel_be_context *intel = batch->intel;
- unsigned int used = batch->base.ptr - batch->base.map;
- boolean was_locked = batch->intel->hardware_locked(intel);
- struct _DriFenceObject *fence;
-
- if (used == 0) {
- driFenceReference(batch->last_fence);
- return batch->last_fence;
- }
-
- /* Add the MI_BATCH_BUFFER_END. Always add an MI_FLUSH - this is a
- * performance drain that we would like to avoid.
- */
-#if 0 /* ZZZ JB: what should we do here? */
- if (used & 4) {
- ((int *) batch->base.ptr)[0] = intel->vtbl.flush_cmd();
- ((int *) batch->base.ptr)[1] = 0;
- ((int *) batch->base.ptr)[2] = MI_BATCH_BUFFER_END;
- used += 12;
- }
- else {
- ((int *) batch->base.ptr)[0] = intel->vtbl.flush_cmd();
- ((int *) batch->base.ptr)[1] = MI_BATCH_BUFFER_END;
- used += 8;
- }
-#else
- if (used & 4) {
- ((int *) batch->base.ptr)[0] = ((0<<29)|(4<<23)); // MI_FLUSH;
- ((int *) batch->base.ptr)[1] = 0;
- ((int *) batch->base.ptr)[2] = (0xA<<23); // MI_BATCH_BUFFER_END;
- used += 12;
- }
- else {
- ((int *) batch->base.ptr)[0] = ((0<<29)|(4<<23)); // MI_FLUSH;
- ((int *) batch->base.ptr)[1] = (0xA<<23); // MI_BATCH_BUFFER_END;
- used += 8;
- }
-#endif
- driBOUnmap(batch->buffer);
- batch->base.ptr = NULL;
- batch->base.map = NULL;
-
- /* TODO: Just pass the relocation list and dma buffer up to the
- * kernel.
- */
- if (!was_locked)
- intel->hardware_lock(intel);
-
- fence = do_flush_locked(batch, used, !(batch->flags & INTEL_BATCH_CLIPRECTS),
- FALSE);
-
- if (!was_locked)
- intel->hardware_unlock(intel);
-
- /* Reset the buffer:
- */
- intel_be_batchbuffer_reset(batch);
- return fence;
-}
-
-void
-intel_be_batchbuffer_finish(struct intel_be_batchbuffer *batch)
-{
- struct _DriFenceObject *fence = intel_be_batchbuffer_flush(batch);
- driFenceFinish(fence, driFenceType(fence), FALSE);
- driFenceUnReference(&fence);
-}
-
-#if 0
-void
-intel_be_batchbuffer_data(struct intel_be_batchbuffer *batch,
- const void *data, unsigned int bytes, unsigned int flags)
-{
- assert((bytes & 3) == 0);
- intel_batchbuffer_require_space(batch, bytes, flags);
- memcpy(batch->base.ptr, data, bytes);
- batch->base.ptr += bytes;
-}
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h b/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h
deleted file mode 100644
index f150e3a674..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_batchbuffer.h
+++ /dev/null
@@ -1,69 +0,0 @@
-
-#ifndef INTEL_BE_BATCHBUFFER_H
-#define INTEL_BE_BATCHBUFFER_H
-
-#include "i915simple/i915_batch.h"
-
-#include "ws_dri_bufmgr.h"
-
-#define BATCH_RESERVED 16
-
-#define INTEL_DEFAULT_RELOCS 100
-#define INTEL_MAX_RELOCS 400
-
-#define INTEL_BATCH_NO_CLIPRECTS 0x1
-#define INTEL_BATCH_CLIPRECTS 0x2
-
-struct intel_be_context;
-struct intel_be_device;
-
-struct intel_be_batchbuffer
-{
- struct i915_batchbuffer base;
-
- struct intel_be_context *intel;
- struct intel_be_device *device;
-
- struct _DriBufferObject *buffer;
- struct _DriFenceObject *last_fence;
- uint32_t flags;
-
- struct _DriBufferList *list;
- size_t list_count;
-
- uint32_t *reloc;
- size_t reloc_size;
- size_t nr_relocs;
-
- uint32_t dirty_state;
- uint32_t id;
-
- uint32_t poolOffset;
- uint8_t *drmBOVirtual;
- struct _drmBONode *node; /* Validation list node for this buffer */
- int dest_location; /* Validation list sequence for this buffer */
-};
-
-struct intel_be_batchbuffer *
-intel_be_batchbuffer_alloc(struct intel_be_context *intel);
-
-void
-intel_be_batchbuffer_free(struct intel_be_batchbuffer *batch);
-
-void
-intel_be_batchbuffer_finish(struct intel_be_batchbuffer *batch);
-
-struct _DriFenceObject *
-intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch);
-
-void
-intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch);
-
-void
-intel_be_offset_relocation(struct intel_be_batchbuffer *batch,
- unsigned pre_add,
- struct _DriBufferObject *driBO,
- uint64_t val_flags,
- uint64_t val_mask);
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_context.c b/src/gallium/winsys/drm/intel/common/intel_be_context.c
deleted file mode 100644
index 1af39674f4..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_context.c
+++ /dev/null
@@ -1,107 +0,0 @@
-
-/*
- * Authors: Jakob Bornecrantz <jakob-at-tungstengraphics.com>
- */
-
-#include "ws_dri_fencemgr.h"
-#include "intel_be_device.h"
-#include "intel_be_context.h"
-#include "intel_be_batchbuffer.h"
-
-static INLINE struct intel_be_context *
-intel_be_context(struct i915_winsys *sws)
-{
- return (struct intel_be_context *)sws;
-}
-
-/* Simple batchbuffer interface:
- */
-
-static struct i915_batchbuffer*
-intel_i915_batch_get(struct i915_winsys *sws)
-{
- struct intel_be_context *intel = intel_be_context(sws);
- return &intel->batch->base;
-}
-
-static void intel_i915_batch_reloc(struct i915_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta)
-{
- struct intel_be_context *intel = intel_be_context(sws);
-
- unsigned flags = DRM_BO_FLAG_MEM_TT;
- unsigned mask = DRM_BO_MASK_MEM;
-
- if (access_flags & I915_BUFFER_ACCESS_WRITE) {
- flags |= DRM_BO_FLAG_WRITE;
- mask |= DRM_BO_FLAG_WRITE;
- }
-
- if (access_flags & I915_BUFFER_ACCESS_READ) {
- flags |= DRM_BO_FLAG_READ;
- mask |= DRM_BO_FLAG_READ;
- }
-
- intel_be_offset_relocation(intel->batch,
- delta,
- dri_bo(buf),
- flags,
- mask);
-}
-
-static void intel_i915_batch_flush(struct i915_winsys *sws,
- struct pipe_fence_handle **fence)
-{
- struct intel_be_context *intel = intel_be_context(sws);
-
- union {
- struct _DriFenceObject *dri;
- struct pipe_fence_handle *pipe;
- } fu;
-
- if (fence)
- assert(!*fence);
-
- fu.dri = intel_be_batchbuffer_flush(intel->batch);
-
- if (!fu.dri) {
- assert(0);
- *fence = NULL;
- return;
- }
-
- if (fu.dri) {
- if (fence)
- *fence = fu.pipe;
- else
- driFenceUnReference(&fu.dri);
- }
-
-}
-
-boolean
-intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
-{
- assert(intel);
- assert(device);
-
- intel->device = device;
-
- /* TODO move framebuffer createion to the driver */
-
- intel->base.batch_get = intel_i915_batch_get;
- intel->base.batch_reloc = intel_i915_batch_reloc;
- intel->base.batch_flush = intel_i915_batch_flush;
-
- intel->batch = intel_be_batchbuffer_alloc(intel);
-
- return true;
-}
-
-void
-intel_be_destroy_context(struct intel_be_context *intel)
-{
- intel_be_batchbuffer_free(intel->batch);
-}
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_context.h b/src/gallium/winsys/drm/intel/common/intel_be_context.h
deleted file mode 100644
index d5cbc93594..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_context.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* These need to be diffrent from the intel winsys */
-#ifndef INTEL_BE_CONTEXT_H
-#define INTEL_BE_CONTEXT_H
-
-#include "i915simple/i915_winsys.h"
-
-struct intel_be_context
-{
- /** Interface to i915simple driver */
- struct i915_winsys base;
-
- struct intel_be_device *device;
- struct intel_be_batchbuffer *batch;
-
- /*
- * Hardware lock functions.
- *
- * Needs to be filled in by the winsys.
- */
- void (*hardware_lock)(struct intel_be_context *context);
- void (*hardware_unlock)(struct intel_be_context *context);
- boolean (*hardware_locked)(struct intel_be_context *context);
-};
-
-/**
- * Intialize a allocated intel_be_context struct.
- *
- * Remember to set the hardware_* functions.
- */
-boolean
-intel_be_init_context(struct intel_be_context *intel,
- struct intel_be_device *device);
-
-/**
- * Destroy a intel_be_context.
- * Does not free the struct that is up to the winsys.
- */
-void
-intel_be_destroy_context(struct intel_be_context *intel);
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_device.c b/src/gallium/winsys/drm/intel/common/intel_be_device.c
deleted file mode 100644
index 85ab1a2684..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_device.c
+++ /dev/null
@@ -1,296 +0,0 @@
-
-
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- * Jakob Bornecrantz <jakob-at-tungstengraphics-dot-com>
- */
-
-#include "intel_be_device.h"
-#include "ws_dri_bufmgr.h"
-#include "ws_dri_bufpool.h"
-#include "ws_dri_fencemgr.h"
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
-#include "util/u_memory.h"
-
-#include "i915simple/i915_screen.h"
-
-/* Turn a pipe winsys into an intel/pipe winsys:
- */
-static INLINE struct intel_be_device *
-intel_be_device( struct pipe_winsys *winsys )
-{
- return (struct intel_be_device *)winsys;
-}
-
-
-/*
- * Buffer functions.
- *
- * Most callbacks map direcly onto dri_bufmgr operations:
- */
-
-static void *intel_be_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags )
-{
- unsigned drm_flags = 0;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- drm_flags |= DRM_BO_FLAG_WRITE;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ)
- drm_flags |= DRM_BO_FLAG_READ;
-
- return driBOMap( dri_bo(buf), drm_flags, 0 );
-}
-
-static void intel_be_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- driBOUnmap( dri_bo(buf) );
-}
-
-static void
-intel_be_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- driBOUnReference( dri_bo(buf) );
- FREE(buf);
-}
-
-static struct pipe_buffer *
-intel_be_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size )
-{
- struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
- struct intel_be_device *iws = intel_be_device(winsys);
- unsigned flags = 0;
- struct _DriBufferPool *pool;
-
- buffer->base.refcount = 1;
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
- flags |= DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
- pool = iws->mallocPool;
- } else if (usage & PIPE_BUFFER_USAGE_CUSTOM) {
- /* For vertex buffers */
- flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
- pool = iws->vertexPool;
- } else {
- flags |= DRM_BO_FLAG_MEM_VRAM | DRM_BO_FLAG_MEM_TT;
- pool = iws->regionPool;
- }
-
- if (usage & PIPE_BUFFER_USAGE_GPU_READ)
- flags |= DRM_BO_FLAG_READ;
-
- if (usage & PIPE_BUFFER_USAGE_GPU_WRITE)
- flags |= DRM_BO_FLAG_WRITE;
-
- /* drm complains if we don't set any read/write flags.
- */
- if ((flags & (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE)) == 0)
- flags |= DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
-
- buffer->pool = pool;
- driGenBuffers( buffer->pool,
- "pipe buffer", 1, &buffer->driBO, alignment, flags, 0 );
-
- driBOData( buffer->driBO, size, NULL, buffer->pool, 0 );
-
- return &buffer->base;
-}
-
-
-static struct pipe_buffer *
-intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes)
-{
- struct intel_be_buffer *buffer = CALLOC_STRUCT( intel_be_buffer );
- struct intel_be_device *iws = intel_be_device(winsys);
-
- driGenUserBuffer( iws->regionPool,
- "pipe user buffer", &buffer->driBO, ptr, bytes );
-
- buffer->base.refcount = 1;
-
- return &buffer->base;
-}
-
-struct pipe_buffer *
-intel_be_buffer_from_handle(struct intel_be_device *device,
- const char* name, unsigned handle)
-{
- struct intel_be_buffer *be_buf = malloc(sizeof(*be_buf));
- struct pipe_buffer *buffer;
-
- if (!be_buf)
- goto err;
-
- memset(be_buf, 0, sizeof(*be_buf));
-
- driGenBuffers(device->staticPool, name, 1, &be_buf->driBO, 0, 0, 0);
- driBOSetReferenced(be_buf->driBO, handle);
-
- if (0) /** XXX TODO check error */
- goto err_bo;
-
- buffer = &be_buf->base;
- buffer->refcount = 1;
- buffer->alignment = 0;
- buffer->usage = 0;
- buffer->size = driBOSize(be_buf->driBO);
-
- return buffer;
-err_bo:
- free(be_buf);
-err:
- return NULL;
-}
-
-
-static struct pipe_buffer *
-intel_i915_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned *stride)
-{
- const unsigned alignment = 64;
- struct pipe_format_block block;
- unsigned nblocksx, nblocksy;
-
- pf_get_block(format, &block);
- nblocksx = pf_get_nblocksx(&block, width);
- nblocksy = pf_get_nblocksy(&block, height);
- *stride = round_up(nblocksx * block.size, alignment);
-
- return winsys->buffer_create(winsys, alignment,
- usage,
- *stride * nblocksy);
-}
-
-
-/*
- * Fence functions
- */
-
-static void
-intel_be_fence_reference( struct pipe_winsys *sws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence )
-{
- if (*ptr)
- driFenceUnReference((struct _DriFenceObject **)ptr);
-
- if (fence)
- *ptr = (struct pipe_fence_handle *)driFenceReference((struct _DriFenceObject *)fence);
-}
-
-static int
-intel_be_fence_signalled( struct pipe_winsys *sws,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- return driFenceSignaled((struct _DriFenceObject *)fence, flag);
-}
-
-static int
-intel_be_fence_finish( struct pipe_winsys *sws,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- return driFenceFinish((struct _DriFenceObject *)fence, flag, 0);
-}
-
-
-/*
- * Misc functions
- */
-
-boolean
-intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
-{
- dev->fd = fd;
- dev->max_batch_size = 16 * 4096;
- dev->max_vertex_size = 128 * 4096;
-
- dev->base.buffer_create = intel_be_buffer_create;
- dev->base.user_buffer_create = intel_be_user_buffer_create;
- dev->base.buffer_map = intel_be_buffer_map;
- dev->base.buffer_unmap = intel_be_buffer_unmap;
- dev->base.buffer_destroy = intel_be_buffer_destroy;
- dev->base.surface_buffer_create = intel_i915_surface_buffer_create;
- dev->base.fence_reference = intel_be_fence_reference;
- dev->base.fence_signalled = intel_be_fence_signalled;
- dev->base.fence_finish = intel_be_fence_finish;
-
-#if 0 /* Set by the winsys */
- dev->base.flush_frontbuffer = intel_flush_frontbuffer;
- dev->base.get_name = intel_get_name;
-#endif
-
- dev->fMan = driInitFreeSlabManager(10, 10);
- dev->fenceMgr = driFenceMgrTTMInit(dev->fd);
-
- dev->mallocPool = driMallocPoolInit();
- dev->staticPool = driDRMPoolInit(dev->fd);
- /* Sizes: 64 128 256 512 1024 2048 4096 8192 16384 32768 */
- dev->regionPool = driSlabPoolInit(dev->fd,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- 64,
- 10, 120, 4096 * 64, 0,
- dev->fMan);
-
- dev->vertexPool = driSlabPoolInit(dev->fd,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_READ |
- DRM_BO_FLAG_WRITE |
- DRM_BO_FLAG_MEM_TT,
- dev->max_vertex_size,
- 1, 120, dev->max_vertex_size * 4, 0,
- dev->fMan);
-
- dev->batchPool = driSlabPoolInit(dev->fd,
- DRM_BO_FLAG_EXE |
- DRM_BO_FLAG_MEM_TT,
- DRM_BO_FLAG_EXE |
- DRM_BO_FLAG_MEM_TT,
- dev->max_batch_size,
- 1, 40, dev->max_batch_size * 16, 0,
- dev->fMan);
-
- /* Fill in this struct with callbacks that i915simple will need to
- * communicate with the window system, buffer manager, etc.
- */
- dev->screen = i915_create_screen(&dev->base, id);
-
- return true;
-}
-
-void
-intel_be_destroy_device(struct intel_be_device *dev)
-{
- driPoolTakeDown(dev->mallocPool);
- driPoolTakeDown(dev->staticPool);
- driPoolTakeDown(dev->regionPool);
- driPoolTakeDown(dev->vertexPool);
- driPoolTakeDown(dev->batchPool);
-
- /** TODO takedown fenceMgr and fMan */
-}
diff --git a/src/gallium/winsys/drm/intel/common/intel_be_device.h b/src/gallium/winsys/drm/intel/common/intel_be_device.h
deleted file mode 100644
index 534d638b6a..0000000000
--- a/src/gallium/winsys/drm/intel/common/intel_be_device.h
+++ /dev/null
@@ -1,72 +0,0 @@
-#ifndef INTEL_DRM_DEVICE_H
-#define INTEL_DRM_DEVICE_H
-
-#include "pipe/internal/p_winsys_screen.h"
-#include "pipe/p_context.h"
-
-/*
- * Device
- */
-
-struct intel_be_device
-{
- struct pipe_winsys base;
-
- /**
- * Hw level screen
- */
- struct pipe_screen *screen;
-
- int fd; /**< Drm file discriptor */
-
- size_t max_batch_size;
- size_t max_vertex_size;
-
- struct _DriFenceMgr *fenceMgr;
-
- struct _DriBufferPool *batchPool;
- struct _DriBufferPool *regionPool;
- struct _DriBufferPool *mallocPool;
- struct _DriBufferPool *vertexPool;
- struct _DriBufferPool *staticPool;
- struct _DriFreeSlabManager *fMan;
-};
-
-boolean
-intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);
-
-void
-intel_be_destroy_device(struct intel_be_device *dev);
-
-/*
- * Buffer
- */
-
-struct intel_be_buffer {
- struct pipe_buffer base;
- struct _DriBufferPool *pool;
- struct _DriBufferObject *driBO;
-};
-
-/**
- * Create a be buffer from a drm bo handle
- *
- * Takes a reference
- */
-struct pipe_buffer *
-intel_be_buffer_from_handle(struct intel_be_device *device,
- const char* name, unsigned handle);
-
-static INLINE struct intel_be_buffer *
-intel_be_buffer(struct pipe_buffer *buf)
-{
- return (struct intel_be_buffer *)buf;
-}
-
-static INLINE struct _DriBufferObject *
-dri_bo(struct pipe_buffer *buf)
-{
- return intel_be_buffer(buf)->driBO;
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
deleted file mode 100644
index 517a97b3ee..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.c
+++ /dev/null
@@ -1,949 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- * Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "pipe/p_thread.h"
-#include "errno.h"
-#include "ws_dri_bufmgr.h"
-#include "string.h"
-#include "pipe/p_debug.h"
-#include "ws_dri_bufpool.h"
-#include "ws_dri_fencemgr.h"
-
-
-/*
- * This lock is here to protect drmBO structs changing underneath us during a
- * validate list call, since validatelist cannot take individiual locks for
- * each drmBO. Validatelist takes this lock in write mode. Any access to an
- * individual drmBO should take this lock in read mode, since in that case, the
- * driBufferObject mutex will protect the access. Locking order is
- * driBufferObject mutex - > this rw lock.
- */
-
-pipe_static_mutex(bmMutex);
-pipe_static_condvar(bmCond);
-
-static int kernelReaders = 0;
-static int num_buffers = 0;
-static int num_user_buffers = 0;
-
-static drmBO *drmBOListBuf(void *iterator)
-{
- drmBONode *node;
- drmMMListHead *l = (drmMMListHead *) iterator;
- node = DRMLISTENTRY(drmBONode, l, head);
- return node->buf;
-}
-
-static void *drmBOListIterator(drmBOList *list)
-{
- void *ret = list->list.next;
-
- if (ret == &list->list)
- return NULL;
- return ret;
-}
-
-static void *drmBOListNext(drmBOList *list, void *iterator)
-{
- void *ret;
-
- drmMMListHead *l = (drmMMListHead *) iterator;
- ret = l->next;
- if (ret == &list->list)
- return NULL;
- return ret;
-}
-
-static drmBONode *drmAddListItem(drmBOList *list, drmBO *item,
- uint64_t arg0,
- uint64_t arg1)
-{
- drmBONode *node;
- drmMMListHead *l;
-
- l = list->free.next;
- if (l == &list->free) {
- node = (drmBONode *) malloc(sizeof(*node));
- if (!node) {
- return NULL;
- }
- list->numCurrent++;
- }
- else {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- }
- node->buf = item;
- node->arg0 = arg0;
- node->arg1 = arg1;
- DRMLISTADD(&node->head, &list->list);
- list->numOnList++;
- return node;
-}
-
-static int drmAddValidateItem(drmBOList *list, drmBO *buf, uint64_t flags,
- uint64_t mask, int *newItem)
-{
- drmBONode *node, *cur;
- drmMMListHead *l;
-
- *newItem = 0;
- cur = NULL;
-
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
- if (node->buf == buf) {
- cur = node;
- break;
- }
- }
- if (!cur) {
- cur = drmAddListItem(list, buf, flags, mask);
- if (!cur) {
- return -ENOMEM;
- }
- *newItem = 1;
- cur->arg0 = flags;
- cur->arg1 = mask;
- }
- else {
- uint64_t memFlags = cur->arg0 & flags & DRM_BO_MASK_MEM;
- uint64_t accFlags = (cur->arg0 | flags) & ~DRM_BO_MASK_MEM;
-
- if (mask & cur->arg1 & ~DRM_BO_MASK_MEM & (cur->arg0 ^ flags)) {
- return -EINVAL;
- }
-
- cur->arg1 |= mask;
- cur->arg0 = (cur->arg0 & ~mask) | ((memFlags | accFlags) & mask);
-
- if (((cur->arg1 & DRM_BO_MASK_MEM) != 0) &&
- (cur->arg0 & DRM_BO_MASK_MEM) == 0) {
- return -EINVAL;
- }
- }
- return 0;
-}
-
-static void drmBOFreeList(drmBOList *list)
-{
- drmBONode *node;
- drmMMListHead *l;
-
- l = list->list.next;
- while(l != &list->list) {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- free(node);
- l = list->list.next;
- list->numCurrent--;
- list->numOnList--;
- }
-
- l = list->free.next;
- while(l != &list->free) {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- free(node);
- l = list->free.next;
- list->numCurrent--;
- }
-}
-
-static int drmAdjustListNodes(drmBOList *list)
-{
- drmBONode *node;
- drmMMListHead *l;
- int ret = 0;
-
- while(list->numCurrent < list->numTarget) {
- node = (drmBONode *) malloc(sizeof(*node));
- if (!node) {
- ret = -ENOMEM;
- break;
- }
- list->numCurrent++;
- DRMLISTADD(&node->head, &list->free);
- }
-
- while(list->numCurrent > list->numTarget) {
- l = list->free.next;
- if (l == &list->free)
- break;
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- free(node);
- list->numCurrent--;
- }
- return ret;
-}
-
-static int drmBOCreateList(int numTarget, drmBOList *list)
-{
- DRMINITLISTHEAD(&list->list);
- DRMINITLISTHEAD(&list->free);
- list->numTarget = numTarget;
- list->numCurrent = 0;
- list->numOnList = 0;
- return drmAdjustListNodes(list);
-}
-
-static int drmBOResetList(drmBOList *list)
-{
- drmMMListHead *l;
- int ret;
-
- ret = drmAdjustListNodes(list);
- if (ret)
- return ret;
-
- l = list->list.next;
- while (l != &list->list) {
- DRMLISTDEL(l);
- DRMLISTADD(l, &list->free);
- list->numOnList--;
- l = list->list.next;
- }
- return drmAdjustListNodes(list);
-}
-
-void driWriteLockKernelBO(void)
-{
- pipe_mutex_lock(bmMutex);
- while(kernelReaders != 0)
- pipe_condvar_wait(bmCond, bmMutex);
-}
-
-void driWriteUnlockKernelBO(void)
-{
- pipe_mutex_unlock(bmMutex);
-}
-
-void driReadLockKernelBO(void)
-{
- pipe_mutex_lock(bmMutex);
- kernelReaders++;
- pipe_mutex_unlock(bmMutex);
-}
-
-void driReadUnlockKernelBO(void)
-{
- pipe_mutex_lock(bmMutex);
- if (--kernelReaders == 0)
- pipe_condvar_broadcast(bmCond);
- pipe_mutex_unlock(bmMutex);
-}
-
-
-
-
-/*
- * TODO: Introduce fence pools in the same way as
- * buffer object pools.
- */
-
-typedef struct _DriBufferObject
-{
- DriBufferPool *pool;
- pipe_mutex mutex;
- int refCount;
- const char *name;
- uint64_t flags;
- unsigned hint;
- unsigned alignment;
- unsigned createdByReference;
- void *private;
- /* user-space buffer: */
- unsigned userBuffer;
- void *userData;
- unsigned userSize;
-} DriBufferObject;
-
-typedef struct _DriBufferList {
- drmBOList drmBuffers; /* List of kernel buffers needing validation */
- drmBOList driBuffers; /* List of user-space buffers needing validation */
-} DriBufferList;
-
-
-void
-bmError(int val, const char *file, const char *function, int line)
-{
- printf("Fatal video memory manager error \"%s\".\n"
- "Check kernel logs or set the LIBGL_DEBUG\n"
- "environment variable to \"verbose\" for more info.\n"
- "Detected in file %s, line %d, function %s.\n",
- strerror(-val), file, line, function);
-#ifndef NDEBUG
- abort();
-#else
- abort();
-#endif
-}
-
-extern drmBO *
-driBOKernel(struct _DriBufferObject *buf)
-{
- drmBO *ret;
-
- driReadLockKernelBO();
- pipe_mutex_lock(buf->mutex);
- assert(buf->private != NULL);
- ret = buf->pool->kernel(buf->pool, buf->private);
- if (!ret)
- BM_CKFATAL(-EINVAL);
- pipe_mutex_unlock(buf->mutex);
- driReadUnlockKernelBO();
-
- return ret;
-}
-
-void
-driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
-{
-
- /*
- * This function may block. Is it sane to keep the mutex held during
- * that time??
- */
-
- pipe_mutex_lock(buf->mutex);
- BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, &buf->mutex, lazy));
- pipe_mutex_unlock(buf->mutex);
-}
-
-void *
-driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
-{
- void *virtual;
- int retval;
-
- if (buf->userBuffer) {
- return buf->userData;
- }
-
- pipe_mutex_lock(buf->mutex);
- assert(buf->private != NULL);
- retval = buf->pool->map(buf->pool, buf->private, flags, hint,
- &buf->mutex, &virtual);
- pipe_mutex_unlock(buf->mutex);
-
- return retval == 0 ? virtual : NULL;
-}
-
-void
-driBOUnmap(struct _DriBufferObject *buf)
-{
- if (buf->userBuffer)
- return;
-
- assert(buf->private != NULL);
- pipe_mutex_lock(buf->mutex);
- BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- pipe_mutex_unlock(buf->mutex);
-}
-
-unsigned long
-driBOOffset(struct _DriBufferObject *buf)
-{
- unsigned long ret;
-
- assert(buf->private != NULL);
-
- pipe_mutex_lock(buf->mutex);
- ret = buf->pool->offset(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
- return ret;
-}
-
-unsigned long
-driBOPoolOffset(struct _DriBufferObject *buf)
-{
- unsigned long ret;
-
- assert(buf->private != NULL);
-
- pipe_mutex_lock(buf->mutex);
- ret = buf->pool->poolOffset(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
- return ret;
-}
-
-uint64_t
-driBOFlags(struct _DriBufferObject *buf)
-{
- uint64_t ret;
-
- assert(buf->private != NULL);
-
- driReadLockKernelBO();
- pipe_mutex_lock(buf->mutex);
- ret = buf->pool->flags(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
- driReadUnlockKernelBO();
- return ret;
-}
-
-struct _DriBufferObject *
-driBOReference(struct _DriBufferObject *buf)
-{
- pipe_mutex_lock(buf->mutex);
- if (++buf->refCount == 1) {
- pipe_mutex_unlock(buf->mutex);
- BM_CKFATAL(-EINVAL);
- }
- pipe_mutex_unlock(buf->mutex);
- return buf;
-}
-
-void
-driBOUnReference(struct _DriBufferObject *buf)
-{
- int tmp;
-
- if (!buf)
- return;
-
- pipe_mutex_lock(buf->mutex);
- tmp = --buf->refCount;
- if (!tmp) {
- pipe_mutex_unlock(buf->mutex);
- if (buf->private) {
- if (buf->createdByReference)
- buf->pool->unreference(buf->pool, buf->private);
- else
- buf->pool->destroy(buf->pool, buf->private);
- }
- if (buf->userBuffer)
- num_user_buffers--;
- else
- num_buffers--;
- free(buf);
- } else
- pipe_mutex_unlock(buf->mutex);
-
-}
-
-
-int
-driBOData(struct _DriBufferObject *buf,
- unsigned size, const void *data,
- DriBufferPool *newPool,
- uint64_t flags)
-{
- void *virtual = NULL;
- int newBuffer;
- int retval = 0;
- struct _DriBufferPool *pool;
-
- assert(!buf->userBuffer); /* XXX just do a memcpy? */
-
- pipe_mutex_lock(buf->mutex);
- pool = buf->pool;
-
- if (pool == NULL && newPool != NULL) {
- buf->pool = newPool;
- pool = newPool;
- }
- if (newPool == NULL)
- newPool = pool;
-
- if (!pool->create) {
- assert((size_t)"driBOData called on invalid buffer\n" & 0);
- BM_CKFATAL(-EINVAL);
- }
-
- newBuffer = (!buf->private || pool != newPool ||
- pool->size(pool, buf->private) < size);
-
- if (!flags)
- flags = buf->flags;
-
- if (newBuffer) {
-
- if (buf->createdByReference) {
- assert((size_t)"driBOData requiring resizing called on shared buffer.\n" & 0);
- BM_CKFATAL(-EINVAL);
- }
-
- if (buf->private)
- buf->pool->destroy(buf->pool, buf->private);
-
- pool = newPool;
- buf->pool = newPool;
- buf->private = pool->create(pool, size, flags, DRM_BO_HINT_DONT_FENCE,
- buf->alignment);
- if (!buf->private)
- retval = -ENOMEM;
-
- if (retval == 0)
- retval = pool->map(pool, buf->private,
- DRM_BO_FLAG_WRITE,
- DRM_BO_HINT_DONT_BLOCK, &buf->mutex, &virtual);
- } else if (pool->map(pool, buf->private, DRM_BO_FLAG_WRITE,
- DRM_BO_HINT_DONT_BLOCK, &buf->mutex, &virtual)) {
- /*
- * Buffer is busy. need to create a new one.
- */
-
- void *newBuf;
-
- newBuf = pool->create(pool, size, flags, DRM_BO_HINT_DONT_FENCE,
- buf->alignment);
- if (newBuf) {
- buf->pool->destroy(buf->pool, buf->private);
- buf->private = newBuf;
- }
-
- retval = pool->map(pool, buf->private,
- DRM_BO_FLAG_WRITE, 0, &buf->mutex, &virtual);
- } else {
- uint64_t flag_diff = flags ^ buf->flags;
-
- /*
- * We might need to change buffer flags.
- */
-
- if (flag_diff){
- assert(pool->setStatus != NULL);
- BM_CKFATAL(pool->unmap(pool, buf->private));
- BM_CKFATAL(pool->setStatus(pool, buf->private, flag_diff,
- buf->flags));
- if (!data)
- goto out;
-
- retval = pool->map(pool, buf->private,
- DRM_BO_FLAG_WRITE, 0, &buf->mutex, &virtual);
- }
- }
-
- if (retval == 0) {
- if (data)
- memcpy(virtual, data, size);
-
- BM_CKFATAL(pool->unmap(pool, buf->private));
- }
-
- out:
- pipe_mutex_unlock(buf->mutex);
-
- return retval;
-}
-
-void
-driBOSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size, const void *data)
-{
- void *virtual;
-
- assert(!buf->userBuffer); /* XXX just do a memcpy? */
-
- pipe_mutex_lock(buf->mutex);
- if (size && data) {
- BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
- DRM_BO_FLAG_WRITE, 0, &buf->mutex,
- &virtual));
- memcpy((unsigned char *) virtual + offset, data, size);
- BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- }
- pipe_mutex_unlock(buf->mutex);
-}
-
-void
-driBOGetSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size, void *data)
-{
- void *virtual;
-
- assert(!buf->userBuffer); /* XXX just do a memcpy? */
-
- pipe_mutex_lock(buf->mutex);
- if (size && data) {
- BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
- DRM_BO_FLAG_READ, 0, &buf->mutex, &virtual));
- memcpy(data, (unsigned char *) virtual + offset, size);
- BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
- }
- pipe_mutex_unlock(buf->mutex);
-}
-
-void
-driBOSetReferenced(struct _DriBufferObject *buf,
- unsigned long handle)
-{
- pipe_mutex_lock(buf->mutex);
- if (buf->private != NULL) {
- assert((size_t)"Invalid buffer for setReferenced\n" & 0);
- BM_CKFATAL(-EINVAL);
-
- }
- if (buf->pool->reference == NULL) {
- assert((size_t)"Invalid buffer pool for setReferenced\n" & 0);
- BM_CKFATAL(-EINVAL);
- }
- buf->private = buf->pool->reference(buf->pool, handle);
- if (!buf->private) {
- assert((size_t)"Invalid buffer pool for setStatic\n" & 0);
- BM_CKFATAL(-ENOMEM);
- }
- buf->createdByReference = TRUE;
- buf->flags = buf->pool->kernel(buf->pool, buf->private)->flags;
- pipe_mutex_unlock(buf->mutex);
-}
-
-int
-driGenBuffers(struct _DriBufferPool *pool,
- const char *name,
- unsigned n,
- struct _DriBufferObject *buffers[],
- unsigned alignment, uint64_t flags, unsigned hint)
-{
- struct _DriBufferObject *buf;
- int i;
-
- flags = (flags) ? flags : DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_MEM_VRAM |
- DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
-
- ++num_buffers;
-
- assert(pool);
-
- for (i = 0; i < n; ++i) {
- buf = (struct _DriBufferObject *) calloc(1, sizeof(*buf));
- if (!buf)
- return -ENOMEM;
-
- pipe_mutex_init(buf->mutex);
- pipe_mutex_lock(buf->mutex);
- buf->refCount = 1;
- buf->flags = flags;
- buf->hint = hint;
- buf->name = name;
- buf->alignment = alignment;
- buf->pool = pool;
- buf->createdByReference = 0;
- pipe_mutex_unlock(buf->mutex);
- buffers[i] = buf;
- }
- return 0;
-}
-
-void
-driGenUserBuffer(struct _DriBufferPool *pool,
- const char *name,
- struct _DriBufferObject **buffers,
- void *ptr, unsigned bytes)
-{
- const unsigned alignment = 1, flags = 0, hint = 0;
-
- --num_buffers; /* JB: is inced in GenBuffes */
- driGenBuffers(pool, name, 1, buffers, alignment, flags, hint);
- ++num_user_buffers;
-
- (*buffers)->userBuffer = 1;
- (*buffers)->userData = ptr;
- (*buffers)->userSize = bytes;
-}
-
-void
-driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[])
-{
- int i;
-
- for (i = 0; i < n; ++i) {
- driBOUnReference(buffers[i]);
- }
-}
-
-
-void
-driInitBufMgr(int fd)
-{
- ;
-}
-
-/*
- * Note that lists are per-context and don't need mutex protection.
- */
-
-struct _DriBufferList *
-driBOCreateList(int target)
-{
- struct _DriBufferList *list = calloc(sizeof(*list), 1);
-
- BM_CKFATAL(drmBOCreateList(target, &list->drmBuffers));
- BM_CKFATAL(drmBOCreateList(target, &list->driBuffers));
- return list;
-}
-
-int
-driBOResetList(struct _DriBufferList * list)
-{
- int ret;
- ret = drmBOResetList(&list->drmBuffers);
- if (ret)
- return ret;
- ret = drmBOResetList(&list->driBuffers);
- return ret;
-}
-
-void
-driBOFreeList(struct _DriBufferList * list)
-{
- drmBOFreeList(&list->drmBuffers);
- drmBOFreeList(&list->driBuffers);
- free(list);
-}
-
-
-/*
- * Copied from libdrm, because it is needed by driAddValidateItem.
- */
-
-static drmBONode *
-driAddListItem(drmBOList * list, drmBO * item,
- uint64_t arg0, uint64_t arg1)
-{
- drmBONode *node;
- drmMMListHead *l;
-
- l = list->free.next;
- if (l == &list->free) {
- node = (drmBONode *) malloc(sizeof(*node));
- if (!node) {
- return NULL;
- }
- list->numCurrent++;
- } else {
- DRMLISTDEL(l);
- node = DRMLISTENTRY(drmBONode, l, head);
- }
- memset(&node->bo_arg, 0, sizeof(node->bo_arg));
- node->buf = item;
- node->arg0 = arg0;
- node->arg1 = arg1;
- DRMLISTADDTAIL(&node->head, &list->list);
- list->numOnList++;
- return node;
-}
-
-/*
- * Slightly modified version compared to the libdrm version.
- * This one returns the list index of the buffer put on the list.
- */
-
-static int
-driAddValidateItem(drmBOList * list, drmBO * buf, uint64_t flags,
- uint64_t mask, int *itemLoc,
- struct _drmBONode **pnode)
-{
- drmBONode *node, *cur;
- drmMMListHead *l;
- int count = 0;
-
- cur = NULL;
-
- for (l = list->list.next; l != &list->list; l = l->next) {
- node = DRMLISTENTRY(drmBONode, l, head);
- if (node->buf == buf) {
- cur = node;
- break;
- }
- count++;
- }
- if (!cur) {
- cur = driAddListItem(list, buf, flags, mask);
- if (!cur)
- return -ENOMEM;
-
- cur->arg0 = flags;
- cur->arg1 = mask;
- } else {
- uint64_t memFlags = cur->arg0 & flags & DRM_BO_MASK_MEM;
- uint64_t accFlags = (cur->arg0 | flags) & ~DRM_BO_MASK_MEM;
-
- if (mask & cur->arg1 & ~DRM_BO_MASK_MEM & (cur->arg0 ^ flags)) {
- return -EINVAL;
- }
-
- cur->arg1 |= mask;
- cur->arg0 = (cur->arg0 & ~mask) | ((memFlags | accFlags) & mask);
-
- if (((cur->arg1 & DRM_BO_MASK_MEM) != 0) &&
- (cur->arg0 & DRM_BO_MASK_MEM) == 0) {
- return -EINVAL;
- }
- }
- *itemLoc = count;
- *pnode = cur;
- return 0;
-}
-
-
-void
-driBOAddListItem(struct _DriBufferList * list, struct _DriBufferObject *buf,
- uint64_t flags, uint64_t mask, int *itemLoc,
- struct _drmBONode **node)
-{
- int newItem;
-
- pipe_mutex_lock(buf->mutex);
- BM_CKFATAL(driAddValidateItem(&list->drmBuffers,
- buf->pool->kernel(buf->pool, buf->private),
- flags, mask, itemLoc, node));
- BM_CKFATAL(drmAddValidateItem(&list->driBuffers, (drmBO *) buf,
- flags, mask, &newItem));
- if (newItem)
- buf->refCount++;
-
- pipe_mutex_unlock(buf->mutex);
-}
-
-drmBOList *driGetdrmBOList(struct _DriBufferList *list)
-{
- driWriteLockKernelBO();
- return &list->drmBuffers;
-}
-
-void driPutdrmBOList(struct _DriBufferList *list)
-{
- driWriteUnlockKernelBO();
-}
-
-
-void
-driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
-{
- pipe_mutex_lock(buf->mutex);
- if (buf->pool->fence)
- BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
- pipe_mutex_unlock(buf->mutex);
-
-}
-
-void
-driBOUnrefUserList(struct _DriBufferList *list)
-{
- struct _DriBufferObject *buf;
- void *curBuf;
-
- curBuf = drmBOListIterator(&list->driBuffers);
- while (curBuf) {
- buf = (struct _DriBufferObject *)drmBOListBuf(curBuf);
- driBOUnReference(buf);
- curBuf = drmBOListNext(&list->driBuffers, curBuf);
- }
-}
-
-struct _DriFenceObject *
-driBOFenceUserList(struct _DriFenceMgr *mgr,
- struct _DriBufferList *list, const char *name,
- drmFence *kFence)
-{
- struct _DriFenceObject *fence;
- struct _DriBufferObject *buf;
- void *curBuf;
-
- fence = driFenceCreate(mgr, kFence->fence_class, kFence->type,
- kFence, sizeof(*kFence));
- curBuf = drmBOListIterator(&list->driBuffers);
-
- /*
- * User-space fencing callbacks.
- */
-
- while (curBuf) {
- buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
- driBOFence(buf, fence);
- driBOUnReference(buf);
- curBuf = drmBOListNext(&list->driBuffers, curBuf);
- }
-
- driBOResetList(list);
- return fence;
-}
-
-void
-driBOValidateUserList(struct _DriBufferList * list)
-{
- void *curBuf;
- struct _DriBufferObject *buf;
-
- curBuf = drmBOListIterator(&list->driBuffers);
-
- /*
- * User-space validation callbacks.
- */
-
- while (curBuf) {
- buf = (struct _DriBufferObject *) drmBOListBuf(curBuf);
- pipe_mutex_lock(buf->mutex);
- if (buf->pool->validate)
- BM_CKFATAL(buf->pool->validate(buf->pool, buf->private, &buf->mutex));
- pipe_mutex_unlock(buf->mutex);
- curBuf = drmBOListNext(&list->driBuffers, curBuf);
- }
-}
-
-
-void
-driPoolTakeDown(struct _DriBufferPool *pool)
-{
- pool->takeDown(pool);
-
-}
-
-unsigned long
-driBOSize(struct _DriBufferObject *buf)
-{
- unsigned long size;
-
- pipe_mutex_lock(buf->mutex);
- size = buf->pool->size(buf->pool, buf->private);
- pipe_mutex_unlock(buf->mutex);
-
- return size;
-
-}
-
-drmBOList *driBOGetDRMBuffers(struct _DriBufferList *list)
-{
- return &list->drmBuffers;
-}
-
-drmBOList *driBOGetDRIBuffers(struct _DriBufferList *list)
-{
- return &list->driBuffers;
-}
-
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h
deleted file mode 100644
index e6c0cff0a0..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufmgr.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- * Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#ifndef _PSB_BUFMGR_H_
-#define _PSB_BUFMGR_H_
-#include <xf86mm.h>
-#include "i915_drm.h"
-#include "ws_dri_fencemgr.h"
-
-typedef struct _drmBONode
-{
- drmMMListHead head;
- drmBO *buf;
- struct drm_i915_op_arg bo_arg;
- uint64_t arg0;
- uint64_t arg1;
-} drmBONode;
-
-typedef struct _drmBOList {
- unsigned numTarget;
- unsigned numCurrent;
- unsigned numOnList;
- drmMMListHead list;
- drmMMListHead free;
-} drmBOList;
-
-
-struct _DriFenceObject;
-struct _DriBufferObject;
-struct _DriBufferPool;
-struct _DriBufferList;
-
-/*
- * Return a pointer to the libdrm buffer object this DriBufferObject
- * uses.
- */
-
-extern drmBO *driBOKernel(struct _DriBufferObject *buf);
-extern void *driBOMap(struct _DriBufferObject *buf, unsigned flags,
- unsigned hint);
-extern void driBOUnmap(struct _DriBufferObject *buf);
-extern unsigned long driBOOffset(struct _DriBufferObject *buf);
-extern unsigned long driBOPoolOffset(struct _DriBufferObject *buf);
-
-extern uint64_t driBOFlags(struct _DriBufferObject *buf);
-extern struct _DriBufferObject *driBOReference(struct _DriBufferObject *buf);
-extern void driBOUnReference(struct _DriBufferObject *buf);
-
-extern int driBOData(struct _DriBufferObject *r_buf,
- unsigned size, const void *data,
- struct _DriBufferPool *pool, uint64_t flags);
-
-extern void driBOSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size,
- const void *data);
-extern void driBOGetSubData(struct _DriBufferObject *buf,
- unsigned long offset, unsigned long size,
- void *data);
-extern int driGenBuffers(struct _DriBufferPool *pool,
- const char *name,
- unsigned n,
- struct _DriBufferObject *buffers[],
- unsigned alignment, uint64_t flags, unsigned hint);
-extern void driGenUserBuffer(struct _DriBufferPool *pool,
- const char *name,
- struct _DriBufferObject *buffers[],
- void *ptr, unsigned bytes);
-extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]);
-extern void driInitBufMgr(int fd);
-extern struct _DriBufferList *driBOCreateList(int target);
-extern int driBOResetList(struct _DriBufferList * list);
-extern void driBOAddListItem(struct _DriBufferList * list,
- struct _DriBufferObject *buf,
- uint64_t flags, uint64_t mask, int *itemLoc,
- struct _drmBONode **node);
-
-extern void driBOValidateList(int fd, struct _DriBufferList * list);
-extern void driBOFreeList(struct _DriBufferList * list);
-extern struct _DriFenceObject *driBOFenceUserList(struct _DriFenceMgr *mgr,
- struct _DriBufferList *list,
- const char *name,
- drmFence *kFence);
-extern void driBOUnrefUserList(struct _DriBufferList *list);
-extern void driBOValidateUserList(struct _DriBufferList * list);
-extern drmBOList *driGetdrmBOList(struct _DriBufferList *list);
-extern void driPutdrmBOList(struct _DriBufferList *list);
-
-extern void driBOFence(struct _DriBufferObject *buf,
- struct _DriFenceObject *fence);
-
-extern void driPoolTakeDown(struct _DriBufferPool *pool);
-extern void driBOSetReferenced(struct _DriBufferObject *buf,
- unsigned long handle);
-unsigned long driBOSize(struct _DriBufferObject *buf);
-extern void driBOWaitIdle(struct _DriBufferObject *buf, int lazy);
-extern void driPoolTakeDown(struct _DriBufferPool *pool);
-
-extern void driReadLockKernelBO(void);
-extern void driReadUnlockKernelBO(void);
-extern void driWriteLockKernelBO(void);
-extern void driWriteUnlockKernelBO(void);
-
-/*
- * For debugging purposes.
- */
-
-extern drmBOList *driBOGetDRMBuffers(struct _DriBufferList *list);
-extern drmBOList *driBOGetDRIBuffers(struct _DriBufferList *list);
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h b/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
deleted file mode 100644
index ad3b6f3931..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_bufpool.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#ifndef _PSB_BUFPOOL_H_
-#define _PSB_BUFPOOL_H_
-
-#include <xf86drm.h>
-#include "pipe/p_thread.h"
-struct _DriFenceObject;
-
-typedef struct _DriBufferPool
-{
- int fd;
- int (*map) (struct _DriBufferPool * pool, void *private,
- unsigned flags, int hint, pipe_mutex *mutex,
- void **virtual);
- int (*unmap) (struct _DriBufferPool * pool, void *private);
- int (*destroy) (struct _DriBufferPool * pool, void *private);
- unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
- unsigned long (*poolOffset) (struct _DriBufferPool * pool, void *private);
- uint64_t (*flags) (struct _DriBufferPool * pool, void *private);
- unsigned long (*size) (struct _DriBufferPool * pool, void *private);
- void *(*create) (struct _DriBufferPool * pool, unsigned long size,
- uint64_t flags, unsigned hint, unsigned alignment);
- void *(*reference) (struct _DriBufferPool * pool, unsigned handle);
- int (*unreference) (struct _DriBufferPool * pool, void *private);
- int (*fence) (struct _DriBufferPool * pool, void *private,
- struct _DriFenceObject * fence);
- drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
- int (*validate) (struct _DriBufferPool * pool, void *private, pipe_mutex *mutex);
- int (*waitIdle) (struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
- int lazy);
- int (*setStatus) (struct _DriBufferPool *pool, void *private,
- uint64_t flag_diff, uint64_t old_flags);
- void (*takeDown) (struct _DriBufferPool * pool);
- void *data;
-} DriBufferPool;
-
-extern void bmError(int val, const char *file, const char *function,
- int line);
-#define BM_CKFATAL(val) \
- do{ \
- int tstVal = (val); \
- if (tstVal) \
- bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
- } while(0);
-
-
-/*
- * Builtin pools.
- */
-
-/*
- * Kernel buffer objects. Size in multiples of page size. Page size aligned.
- */
-
-extern struct _DriBufferPool *driDRMPoolInit(int fd);
-extern struct _DriBufferPool *driMallocPoolInit(void);
-
-struct _DriFreeSlabManager;
-extern struct _DriBufferPool * driSlabPoolInit(int fd, uint64_t flags,
- uint64_t validMask,
- uint32_t smallestSize,
- uint32_t numSizes,
- uint32_t desiredNumBuffers,
- uint32_t maxSlabSize,
- uint32_t pageAlignment,
- struct _DriFreeSlabManager *fMan);
-extern void driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan);
-extern struct _DriFreeSlabManager *
-driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec);
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
deleted file mode 100644
index 54618b1c82..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_drmpool.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include "ws_dri_bufpool.h"
-#include "ws_dri_bufmgr.h"
-#include "assert.h"
-
-/*
- * Buffer pool implementation using DRM buffer objects as DRI buffer objects.
- */
-
-static void *
-pool_create(struct _DriBufferPool *pool,
- unsigned long size, uint64_t flags, unsigned hint,
- unsigned alignment)
-{
- drmBO *buf = (drmBO *) malloc(sizeof(*buf));
- int ret;
- unsigned pageSize = getpagesize();
-
- if (!buf)
- return NULL;
-
- if ((alignment > pageSize) && (alignment % pageSize)) {
- free(buf);
- return NULL;
- }
-
- ret = drmBOCreate(pool->fd, size, alignment / pageSize,
- NULL,
- flags, hint, buf);
- if (ret) {
- free(buf);
- return NULL;
- }
-
- return (void *) buf;
-}
-
-static void *
-pool_reference(struct _DriBufferPool *pool, unsigned handle)
-{
- drmBO *buf = (drmBO *) malloc(sizeof(*buf));
- int ret;
-
- if (!buf)
- return NULL;
-
- ret = drmBOReference(pool->fd, handle, buf);
-
- if (ret) {
- free(buf);
- return NULL;
- }
-
- return (void *) buf;
-}
-
-static int
-pool_destroy(struct _DriBufferPool *pool, void *private)
-{
- int ret;
- drmBO *buf = (drmBO *) private;
- driReadLockKernelBO();
- ret = drmBOUnreference(pool->fd, buf);
- free(buf);
- driReadUnlockKernelBO();
- return ret;
-}
-
-static int
-pool_unreference(struct _DriBufferPool *pool, void *private)
-{
- int ret;
- drmBO *buf = (drmBO *) private;
- driReadLockKernelBO();
- ret = drmBOUnreference(pool->fd, buf);
- free(buf);
- driReadUnlockKernelBO();
- return ret;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, pipe_mutex *mutex, void **virtual)
-{
- drmBO *buf = (drmBO *) private;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOMap(pool->fd, buf, flags, hint, virtual);
- driReadUnlockKernelBO();
- return ret;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOUnmap(pool->fd, buf);
- driReadUnlockKernelBO();
-
- return ret;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- unsigned long offset;
-
- driReadLockKernelBO();
- assert(buf->flags & DRM_BO_FLAG_NO_MOVE);
- offset = buf->offset;
- driReadUnlockKernelBO();
-
- return buf->offset;
-}
-
-static unsigned long
-pool_poolOffset(struct _DriBufferPool *pool, void *private)
-{
- return 0;
-}
-
-static uint64_t
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- uint64_t flags;
-
- driReadLockKernelBO();
- flags = buf->flags;
- driReadUnlockKernelBO();
-
- return flags;
-}
-
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- drmBO *buf = (drmBO *) private;
- unsigned long size;
-
- driReadLockKernelBO();
- size = buf->size;
- driReadUnlockKernelBO();
-
- return buf->size;
-}
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- /*
- * Noop. The kernel handles all fencing.
- */
-
- return 0;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- return (drmBO *) private;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private, pipe_mutex *mutex,
- int lazy)
-{
- drmBO *buf = (drmBO *) private;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOWaitIdle(pool->fd, buf, (lazy) ? DRM_BO_HINT_WAIT_LAZY:0);
- driReadUnlockKernelBO();
-
- return ret;
-}
-
-
-static void
-pool_takedown(struct _DriBufferPool *pool)
-{
- free(pool);
-}
-
-/*static int
-pool_setStatus(struct _DriBufferPool *pool, void *private,
- uint64_t flag_diff, uint64_t old_flags)
-{
- drmBO *buf = (drmBO *) private;
- uint64_t new_flags = old_flags ^ flag_diff;
- int ret;
-
- driReadLockKernelBO();
- ret = drmBOSetStatus(pool->fd, buf, new_flags, flag_diff,
- 0, 0, 0);
- driReadUnlockKernelBO();
- return ret;
-}*/
-
-struct _DriBufferPool *
-driDRMPoolInit(int fd)
-{
- struct _DriBufferPool *pool;
-
- pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
-
- if (!pool)
- return NULL;
-
- pool->fd = fd;
- pool->map = &pool_map;
- pool->unmap = &pool_unmap;
- pool->destroy = &pool_destroy;
- pool->offset = &pool_offset;
- pool->poolOffset = &pool_poolOffset;
- pool->flags = &pool_flags;
- pool->size = &pool_size;
- pool->create = &pool_create;
- pool->fence = &pool_fence;
- pool->kernel = &pool_kernel;
- pool->validate = NULL;
- pool->waitIdle = &pool_waitIdle;
- pool->takeDown = &pool_takedown;
- pool->reference = &pool_reference;
- pool->unreference = &pool_unreference;
- pool->data = NULL;
- return pool;
-}
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
deleted file mode 100644
index 831c75d30c..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.c
+++ /dev/null
@@ -1,377 +0,0 @@
-#include "ws_dri_fencemgr.h"
-#include "pipe/p_thread.h"
-#include <xf86mm.h>
-#include <string.h>
-#include <unistd.h>
-
-/*
- * Note: Locking order is
- * _DriFenceObject::mutex
- * _DriFenceMgr::mutex
- */
-
-struct _DriFenceMgr {
- /*
- * Constant members. Need no mutex protection.
- */
- struct _DriFenceMgrCreateInfo info;
- void *private;
-
- /*
- * These members are protected by this->mutex
- */
- pipe_mutex mutex;
- int refCount;
- drmMMListHead *heads;
- int num_fences;
-};
-
-struct _DriFenceObject {
-
- /*
- * These members are constant and need no mutex protection.
- */
- struct _DriFenceMgr *mgr;
- uint32_t fence_class;
- uint32_t fence_type;
-
- /*
- * These members are protected by mgr->mutex.
- */
- drmMMListHead head;
- int refCount;
-
- /*
- * These members are protected by this->mutex.
- */
- pipe_mutex mutex;
- uint32_t signaled_type;
- void *private;
-};
-
-uint32_t
-driFenceType(struct _DriFenceObject *fence)
-{
- return fence->fence_type;
-}
-
-struct _DriFenceMgr *
-driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info)
-{
- struct _DriFenceMgr *tmp;
- uint32_t i;
-
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
-
- pipe_mutex_init(tmp->mutex);
- pipe_mutex_lock(tmp->mutex);
- tmp->refCount = 1;
- tmp->info = *info;
- tmp->num_fences = 0;
- tmp->heads = calloc(tmp->info.num_classes, sizeof(*tmp->heads));
- if (!tmp->heads)
- goto out_err;
-
- for (i=0; i<tmp->info.num_classes; ++i) {
- DRMINITLISTHEAD(&tmp->heads[i]);
- }
- pipe_mutex_unlock(tmp->mutex);
- return tmp;
-
- out_err:
- if (tmp)
- free(tmp);
- return NULL;
-}
-
-static void
-driFenceMgrUnrefUnlock(struct _DriFenceMgr **pMgr)
-{
- struct _DriFenceMgr *mgr = *pMgr;
-
- *pMgr = NULL;
- if (--mgr->refCount == 0)
- free(mgr);
- else
- pipe_mutex_unlock(mgr->mutex);
-}
-
-void
-driFenceMgrUnReference(struct _DriFenceMgr **pMgr)
-{
- pipe_mutex_lock((*pMgr)->mutex);
- driFenceMgrUnrefUnlock(pMgr);
-}
-
-static void
-driFenceUnReferenceLocked(struct _DriFenceObject **pFence)
-{
- struct _DriFenceObject *fence = *pFence;
- struct _DriFenceMgr *mgr = fence->mgr;
-
- *pFence = NULL;
- if (--fence->refCount == 0) {
- DRMLISTDELINIT(&fence->head);
- if (fence->private)
- mgr->info.unreference(mgr, &fence->private);
- --mgr->num_fences;
- fence->mgr = NULL;
- --mgr->refCount;
- free(fence);
-
- }
-}
-
-
-static void
-driSignalPreviousFencesLocked(struct _DriFenceMgr *mgr,
- drmMMListHead *list,
- uint32_t fence_class,
- uint32_t fence_type)
-{
- struct _DriFenceObject *entry;
- drmMMListHead *prev;
-
- while(list != &mgr->heads[fence_class]) {
- entry = DRMLISTENTRY(struct _DriFenceObject, list, head);
-
- /*
- * Up refcount so that entry doesn't disappear from under us
- * when we unlock-relock mgr to get the correct locking order.
- */
-
- ++entry->refCount;
- pipe_mutex_unlock(mgr->mutex);
- pipe_mutex_lock(entry->mutex);
- pipe_mutex_lock(mgr->mutex);
-
- prev = list->prev;
-
-
-
- if (list->prev == list) {
-
- /*
- * Somebody else removed the entry from the list.
- */
-
- pipe_mutex_unlock(entry->mutex);
- driFenceUnReferenceLocked(&entry);
- return;
- }
-
- entry->signaled_type |= (fence_type & entry->fence_type);
- if (entry->signaled_type == entry->fence_type) {
- DRMLISTDELINIT(list);
- mgr->info.unreference(mgr, &entry->private);
- }
- pipe_mutex_unlock(entry->mutex);
- driFenceUnReferenceLocked(&entry);
- list = prev;
- }
-}
-
-
-int
-driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
- int lazy_hint)
-{
- struct _DriFenceMgr *mgr = fence->mgr;
- int ret = 0;
-
- pipe_mutex_lock(fence->mutex);
-
- if ((fence->signaled_type & fence_type) == fence_type)
- goto out0;
-
- ret = mgr->info.finish(mgr, fence->private, fence_type, lazy_hint);
- if (ret)
- goto out0;
-
- pipe_mutex_lock(mgr->mutex);
- pipe_mutex_unlock(fence->mutex);
-
- driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
- fence_type);
- pipe_mutex_unlock(mgr->mutex);
- return 0;
-
- out0:
- pipe_mutex_unlock(fence->mutex);
- return ret;
-}
-
-uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence)
-{
- uint32_t ret;
-
- pipe_mutex_lock(fence->mutex);
- ret = fence->signaled_type;
- pipe_mutex_unlock(fence->mutex);
-
- return ret;
-}
-
-int
-driFenceSignaledType(struct _DriFenceObject *fence, uint32_t flush_type,
- uint32_t *signaled)
-{
- int ret = 0;
- struct _DriFenceMgr *mgr;
-
- pipe_mutex_lock(fence->mutex);
- mgr = fence->mgr;
- *signaled = fence->signaled_type;
- if ((fence->signaled_type & flush_type) == flush_type)
- goto out0;
-
- ret = mgr->info.signaled(mgr, fence->private, flush_type, signaled);
- if (ret) {
- *signaled = fence->signaled_type;
- goto out0;
- }
-
- if ((fence->signaled_type | *signaled) == fence->signaled_type)
- goto out0;
-
- pipe_mutex_lock(mgr->mutex);
- pipe_mutex_unlock(fence->mutex);
-
- driSignalPreviousFencesLocked(mgr, &fence->head, fence->fence_class,
- *signaled);
-
- pipe_mutex_unlock(mgr->mutex);
- return 0;
- out0:
- pipe_mutex_unlock(fence->mutex);
- return ret;
-}
-
-struct _DriFenceObject *
-driFenceReference(struct _DriFenceObject *fence)
-{
- pipe_mutex_lock(fence->mgr->mutex);
- ++fence->refCount;
- pipe_mutex_unlock(fence->mgr->mutex);
- return fence;
-}
-
-void
-driFenceUnReference(struct _DriFenceObject **pFence)
-{
- struct _DriFenceMgr *mgr;
-
- if (*pFence == NULL)
- return;
-
- mgr = (*pFence)->mgr;
- pipe_mutex_lock(mgr->mutex);
- ++mgr->refCount;
- driFenceUnReferenceLocked(pFence);
- driFenceMgrUnrefUnlock(&mgr);
-}
-
-struct _DriFenceObject
-*driFenceCreate(struct _DriFenceMgr *mgr, uint32_t fence_class,
- uint32_t fence_type, void *private, size_t private_size)
-{
- struct _DriFenceObject *fence;
- size_t fence_size = sizeof(*fence);
-
- if (private_size)
- fence_size = ((fence_size + 15) & ~15);
-
- fence = calloc(1, fence_size + private_size);
-
- if (!fence) {
- int ret = mgr->info.finish(mgr, private, fence_type, 0);
-
- if (ret)
- usleep(10000000);
-
- return NULL;
- }
-
- pipe_mutex_init(fence->mutex);
- pipe_mutex_lock(fence->mutex);
- pipe_mutex_lock(mgr->mutex);
- fence->refCount = 1;
- DRMLISTADDTAIL(&fence->head, &mgr->heads[fence_class]);
- fence->mgr = mgr;
- ++mgr->refCount;
- ++mgr->num_fences;
- pipe_mutex_unlock(mgr->mutex);
- fence->fence_class = fence_class;
- fence->fence_type = fence_type;
- fence->signaled_type = 0;
- fence->private = private;
- if (private_size) {
- fence->private = (void *)(((uint8_t *) fence) + fence_size);
- memcpy(fence->private, private, private_size);
- }
-
- pipe_mutex_unlock(fence->mutex);
- return fence;
-}
-
-
-static int
-tSignaled(struct _DriFenceMgr *mgr, void *private, uint32_t flush_type,
- uint32_t *signaled_type)
-{
- long fd = (long) mgr->private;
- int dummy;
- drmFence *fence = (drmFence *) private;
- int ret;
-
- *signaled_type = 0;
- ret = drmFenceSignaled((int) fd, fence, flush_type, &dummy);
- if (ret)
- return ret;
-
- *signaled_type = fence->signaled;
-
- return 0;
-}
-
-static int
-tFinish(struct _DriFenceMgr *mgr, void *private, uint32_t fence_type,
- int lazy_hint)
-{
- long fd = (long) mgr->private;
- unsigned flags = lazy_hint ? DRM_FENCE_FLAG_WAIT_LAZY : 0;
-
- return drmFenceWait((int)fd, flags, (drmFence *) private, fence_type);
-}
-
-static int
-tUnref(struct _DriFenceMgr *mgr, void **private)
-{
- long fd = (long) mgr->private;
- drmFence *fence = (drmFence *) *private;
- *private = NULL;
-
- return drmFenceUnreference(fd, fence);
-}
-
-struct _DriFenceMgr *driFenceMgrTTMInit(int fd)
-{
- struct _DriFenceMgrCreateInfo info;
- struct _DriFenceMgr *mgr;
-
- info.flags = DRI_FENCE_CLASS_ORDERED;
- info.num_classes = 4;
- info.signaled = tSignaled;
- info.finish = tFinish;
- info.unreference = tUnref;
-
- mgr = driFenceMgrCreate(&info);
- if (mgr == NULL)
- return NULL;
-
- mgr->private = (void *) (long) fd;
- return mgr;
-}
-
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h b/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h
deleted file mode 100644
index 4ea58dfe18..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_fencemgr.h
+++ /dev/null
@@ -1,115 +0,0 @@
-#ifndef DRI_FENCEMGR_H
-#define DRI_FENCEMGR_H
-
-#include <stdint.h>
-#include <stdlib.h>
-
-struct _DriFenceObject;
-struct _DriFenceMgr;
-
-/*
- * Do a quick check to see if the fence manager has registered the fence
- * object as signaled. Note that this function may return a false negative
- * answer.
- */
-extern uint32_t driFenceSignaledTypeCached(struct _DriFenceObject *fence);
-
-/*
- * Check if the fence object is signaled. This function can be substantially
- * more expensive to call than the above function, but will not return a false
- * negative answer. The argument "flush_type" sets the types that the
- * underlying mechanism must make sure will eventually signal.
- */
-extern int driFenceSignaledType(struct _DriFenceObject *fence,
- uint32_t flush_type, uint32_t *signaled);
-
-/*
- * Convenience functions.
- */
-
-static inline int driFenceSignaled(struct _DriFenceObject *fence,
- uint32_t flush_type)
-{
- uint32_t signaled_types;
- int ret = driFenceSignaledType(fence, flush_type, &signaled_types);
- if (ret)
- return 0;
- return ((signaled_types & flush_type) == flush_type);
-}
-
-static inline int driFenceSignaledCached(struct _DriFenceObject *fence,
- uint32_t flush_type)
-{
- uint32_t signaled_types =
- driFenceSignaledTypeCached(fence);
-
- return ((signaled_types & flush_type) == flush_type);
-}
-
-/*
- * Reference a fence object.
- */
-extern struct _DriFenceObject *driFenceReference(struct _DriFenceObject *fence);
-
-/*
- * Unreference a fence object. The fence object pointer will be reset to NULL.
- */
-
-extern void driFenceUnReference(struct _DriFenceObject **pFence);
-
-
-/*
- * Wait for a fence to signal the indicated fence_type.
- * If "lazy_hint" is true, it indicates that the wait may sleep to avoid
- * busy-wait polling.
- */
-extern int driFenceFinish(struct _DriFenceObject *fence, uint32_t fence_type,
- int lazy_hint);
-
-/*
- * Create a DriFenceObject for manager "mgr".
- *
- * "private" is a pointer that should be used for the callbacks in
- * struct _DriFenceMgrCreateInfo.
- *
- * if private_size is nonzero, then the info stored at *private, with size
- * private size will be copied and the fence manager will instead use a
- * pointer to the copied data for the callbacks in
- * struct _DriFenceMgrCreateInfo. In that case, the object pointed to by
- * "private" may be destroyed after the call to driFenceCreate.
- */
-extern struct _DriFenceObject *driFenceCreate(struct _DriFenceMgr *mgr,
- uint32_t fence_class,
- uint32_t fence_type,
- void *private,
- size_t private_size);
-
-extern uint32_t driFenceType(struct _DriFenceObject *fence);
-
-/*
- * Fence creations are ordered. If a fence signals a fence_type,
- * it is safe to assume that all fences of the same class that was
- * created before that fence has signaled the same type.
- */
-
-#define DRI_FENCE_CLASS_ORDERED (1 << 0)
-
-struct _DriFenceMgrCreateInfo {
- uint32_t flags;
- uint32_t num_classes;
- int (*signaled) (struct _DriFenceMgr *mgr, void *private, uint32_t flush_type,
- uint32_t *signaled_type);
- int (*finish) (struct _DriFenceMgr *mgr, void *private, uint32_t fence_type, int lazy_hint);
- int (*unreference) (struct _DriFenceMgr *mgr, void **private);
-};
-
-extern struct _DriFenceMgr *
-driFenceMgrCreate(const struct _DriFenceMgrCreateInfo *info);
-
-void
-driFenceMgrUnReference(struct _DriFenceMgr **pMgr);
-
-extern struct _DriFenceMgr *
-driFenceMgrTTMInit(int fd);
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
deleted file mode 100644
index 60924eac9e..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_mallocpool.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellström <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <xf86drm.h>
-#include <stdlib.h>
-#include <errno.h>
-#include "pipe/p_debug.h"
-#include "pipe/p_thread.h"
-#include "ws_dri_bufpool.h"
-#include "ws_dri_bufmgr.h"
-
-static void *
-pool_create(struct _DriBufferPool *pool,
- unsigned long size, uint64_t flags, unsigned hint,
- unsigned alignment)
-{
- unsigned long *private = malloc(size + 2*sizeof(unsigned long));
- if ((flags & DRM_BO_MASK_MEM) != DRM_BO_FLAG_MEM_LOCAL)
- abort();
-
- *private = size;
- return (void *)private;
-}
-
-
-static int
-pool_destroy(struct _DriBufferPool *pool, void *private)
-{
- free(private);
- return 0;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *pool, void *private,
- pipe_mutex *mutex, int lazy)
-{
- return 0;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, pipe_mutex *mutex, void **virtual)
-{
- *virtual = (void *)((unsigned long *)private + 2);
- return 0;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- return 0;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- /*
- * BUG
- */
- abort();
- return 0UL;
-}
-
-static unsigned long
-pool_poolOffset(struct _DriBufferPool *pool, void *private)
-{
- /*
- * BUG
- */
- abort();
-}
-
-static uint64_t
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- return DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_CACHED;
-}
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- return *(unsigned long *) private;
-}
-
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- abort();
- return 0UL;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- abort();
- return NULL;
-}
-
-static void
-pool_takedown(struct _DriBufferPool *pool)
-{
- free(pool);
-}
-
-
-struct _DriBufferPool *
-driMallocPoolInit(void)
-{
- struct _DriBufferPool *pool;
-
- pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
- if (!pool)
- return NULL;
-
- pool->data = NULL;
- pool->fd = -1;
- pool->map = &pool_map;
- pool->unmap = &pool_unmap;
- pool->destroy = &pool_destroy;
- pool->offset = &pool_offset;
- pool->poolOffset = &pool_poolOffset;
- pool->flags = &pool_flags;
- pool->size = &pool_size;
- pool->create = &pool_create;
- pool->fence = &pool_fence;
- pool->kernel = &pool_kernel;
- pool->validate = NULL;
- pool->waitIdle = &pool_waitIdle;
- pool->takeDown = &pool_takedown;
- return pool;
-}
diff --git a/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c b/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
deleted file mode 100644
index 391cea50a7..0000000000
--- a/src/gallium/winsys/drm/intel/common/ws_dri_slabpool.c
+++ /dev/null
@@ -1,968 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Thomas Hellstrom <thomas-at-tungstengraphics-dot-com>
- */
-
-#include <stdint.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <unistd.h>
-#include <assert.h>
-#include "ws_dri_bufpool.h"
-#include "ws_dri_fencemgr.h"
-#include "ws_dri_bufmgr.h"
-#include "pipe/p_thread.h"
-
-#define DRI_SLABPOOL_ALLOC_RETRIES 100
-
-struct _DriSlab;
-
-struct _DriSlabBuffer {
- int isSlabBuffer;
- drmBO *bo;
- struct _DriFenceObject *fence;
- struct _DriSlab *parent;
- drmMMListHead head;
- uint32_t mapCount;
- uint32_t start;
- uint32_t fenceType;
- int unFenced;
- pipe_condvar event;
-};
-
-struct _DriKernelBO {
- int fd;
- drmBO bo;
- drmMMListHead timeoutHead;
- drmMMListHead head;
- struct timeval timeFreed;
- uint32_t pageAlignment;
- void *virtual;
-};
-
-struct _DriSlab{
- drmMMListHead head;
- drmMMListHead freeBuffers;
- uint32_t numBuffers;
- uint32_t numFree;
- struct _DriSlabBuffer *buffers;
- struct _DriSlabSizeHeader *header;
- struct _DriKernelBO *kbo;
-};
-
-
-struct _DriSlabSizeHeader {
- drmMMListHead slabs;
- drmMMListHead freeSlabs;
- drmMMListHead delayedBuffers;
- uint32_t numDelayed;
- struct _DriSlabPool *slabPool;
- uint32_t bufSize;
- pipe_mutex mutex;
-};
-
-struct _DriFreeSlabManager {
- struct timeval slabTimeout;
- struct timeval checkInterval;
- struct timeval nextCheck;
- drmMMListHead timeoutList;
- drmMMListHead unCached;
- drmMMListHead cached;
- pipe_mutex mutex;
-};
-
-
-struct _DriSlabPool {
-
- /*
- * The data of this structure remains constant after
- * initialization and thus needs no mutex protection.
- */
-
- struct _DriFreeSlabManager *fMan;
- uint64_t proposedFlags;
- uint64_t validMask;
- uint32_t *bucketSizes;
- uint32_t numBuckets;
- uint32_t pageSize;
- int fd;
- int pageAlignment;
- int maxSlabSize;
- int desiredNumBuffers;
- struct _DriSlabSizeHeader *headers;
-};
-
-/*
- * FIXME: Perhaps arrange timeout slabs in size buckets for fast
- * retreival??
- */
-
-
-static inline int
-driTimeAfterEq(struct timeval *arg1, struct timeval *arg2)
-{
- return ((arg1->tv_sec > arg2->tv_sec) ||
- ((arg1->tv_sec == arg2->tv_sec) &&
- (arg1->tv_usec > arg2->tv_usec)));
-}
-
-static inline void
-driTimeAdd(struct timeval *arg, struct timeval *add)
-{
- unsigned int sec;
-
- arg->tv_sec += add->tv_sec;
- arg->tv_usec += add->tv_usec;
- sec = arg->tv_usec / 1000000;
- arg->tv_sec += sec;
- arg->tv_usec -= sec*1000000;
-}
-
-static void
-driFreeKernelBO(struct _DriKernelBO *kbo)
-{
- if (!kbo)
- return;
-
- (void) drmBOUnreference(kbo->fd, &kbo->bo);
- free(kbo);
-}
-
-
-static void
-driFreeTimeoutKBOsLocked(struct _DriFreeSlabManager *fMan,
- struct timeval *time)
-{
- drmMMListHead *list, *next;
- struct _DriKernelBO *kbo;
-
- if (!driTimeAfterEq(time, &fMan->nextCheck))
- return;
-
- for (list = fMan->timeoutList.next, next = list->next;
- list != &fMan->timeoutList;
- list = next, next = list->next) {
-
- kbo = DRMLISTENTRY(struct _DriKernelBO, list, timeoutHead);
-
- if (!driTimeAfterEq(time, &kbo->timeFreed))
- break;
-
- DRMLISTDELINIT(&kbo->timeoutHead);
- DRMLISTDELINIT(&kbo->head);
- driFreeKernelBO(kbo);
- }
-
- fMan->nextCheck = *time;
- driTimeAdd(&fMan->nextCheck, &fMan->checkInterval);
-}
-
-
-/*
- * Add a _DriKernelBO to the free slab manager.
- * This means that it is available for reuse, but if it's not
- * reused in a while, it will be freed.
- */
-
-static void
-driSetKernelBOFree(struct _DriFreeSlabManager *fMan,
- struct _DriKernelBO *kbo)
-{
- struct timeval time;
-
- pipe_mutex_lock(fMan->mutex);
- gettimeofday(&time, NULL);
- driTimeAdd(&time, &fMan->slabTimeout);
-
- kbo->timeFreed = time;
-
- if (kbo->bo.flags & DRM_BO_FLAG_CACHED)
- DRMLISTADD(&kbo->head, &fMan->cached);
- else
- DRMLISTADD(&kbo->head, &fMan->unCached);
-
- DRMLISTADDTAIL(&kbo->timeoutHead, &fMan->timeoutList);
- driFreeTimeoutKBOsLocked(fMan, &time);
-
- pipe_mutex_unlock(fMan->mutex);
-}
-
-/*
- * Get a _DriKernelBO for us to use as storage for a slab.
- *
- */
-
-static struct _DriKernelBO *
-driAllocKernelBO(struct _DriSlabSizeHeader *header)
-
-{
- struct _DriSlabPool *slabPool = header->slabPool;
- struct _DriFreeSlabManager *fMan = slabPool->fMan;
- drmMMListHead *list, *next, *head;
- uint32_t size = header->bufSize * slabPool->desiredNumBuffers;
- struct _DriKernelBO *kbo;
- struct _DriKernelBO *kboTmp;
- int ret;
-
- /*
- * FIXME: We should perhaps allow some variation in slabsize in order
- * to efficiently reuse slabs.
- */
-
- size = (size <= slabPool->maxSlabSize) ? size : slabPool->maxSlabSize;
- size = (size + slabPool->pageSize - 1) & ~(slabPool->pageSize - 1);
- pipe_mutex_lock(fMan->mutex);
-
- kbo = NULL;
-
- retry:
- head = (slabPool->proposedFlags & DRM_BO_FLAG_CACHED) ?
- &fMan->cached : &fMan->unCached;
-
- for (list = head->next, next = list->next;
- list != head;
- list = next, next = list->next) {
-
- kboTmp = DRMLISTENTRY(struct _DriKernelBO, list, head);
-
- if ((kboTmp->bo.size == size) &&
- (slabPool->pageAlignment == 0 ||
- (kboTmp->pageAlignment % slabPool->pageAlignment) == 0)) {
-
- if (!kbo)
- kbo = kboTmp;
-
- if ((kbo->bo.proposedFlags ^ slabPool->proposedFlags) == 0)
- break;
-
- }
- }
-
- if (kbo) {
- DRMLISTDELINIT(&kbo->head);
- DRMLISTDELINIT(&kbo->timeoutHead);
- }
-
- pipe_mutex_unlock(fMan->mutex);
-
- if (kbo) {
- uint64_t new_mask = kbo->bo.proposedFlags ^ slabPool->proposedFlags;
-
- ret = 0;
- if (new_mask) {
- ret = drmBOSetStatus(kbo->fd, &kbo->bo, slabPool->proposedFlags,
- new_mask, DRM_BO_HINT_DONT_FENCE, 0, 0);
- }
- if (ret == 0)
- return kbo;
-
- driFreeKernelBO(kbo);
- kbo = NULL;
- goto retry;
- }
-
- kbo = calloc(1, sizeof(struct _DriKernelBO));
- if (!kbo)
- return NULL;
-
- kbo->fd = slabPool->fd;
- DRMINITLISTHEAD(&kbo->head);
- DRMINITLISTHEAD(&kbo->timeoutHead);
- ret = drmBOCreate(kbo->fd, size, slabPool->pageAlignment, NULL,
- slabPool->proposedFlags,
- DRM_BO_HINT_DONT_FENCE, &kbo->bo);
- if (ret)
- goto out_err0;
-
- ret = drmBOMap(kbo->fd, &kbo->bo,
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0, &kbo->virtual);
-
- if (ret)
- goto out_err1;
-
- ret = drmBOUnmap(kbo->fd, &kbo->bo);
- if (ret)
- goto out_err1;
-
- return kbo;
-
- out_err1:
- drmBOUnreference(kbo->fd, &kbo->bo);
- out_err0:
- free(kbo);
- return NULL;
-}
-
-
-static int
-driAllocSlab(struct _DriSlabSizeHeader *header)
-{
- struct _DriSlab *slab;
- struct _DriSlabBuffer *buf;
- uint32_t numBuffers;
- int ret;
- int i;
-
- slab = calloc(1, sizeof(*slab));
- if (!slab)
- return -ENOMEM;
-
- slab->kbo = driAllocKernelBO(header);
- if (!slab->kbo) {
- ret = -ENOMEM;
- goto out_err0;
- }
-
- numBuffers = slab->kbo->bo.size / header->bufSize;
-
- slab->buffers = calloc(numBuffers, sizeof(*slab->buffers));
- if (!slab->buffers) {
- ret = -ENOMEM;
- goto out_err1;
- }
-
- DRMINITLISTHEAD(&slab->head);
- DRMINITLISTHEAD(&slab->freeBuffers);
- slab->numBuffers = numBuffers;
- slab->numFree = 0;
- slab->header = header;
-
- buf = slab->buffers;
- for (i=0; i < numBuffers; ++i) {
- buf->parent = slab;
- buf->start = i* header->bufSize;
- buf->mapCount = 0;
- buf->isSlabBuffer = 1;
- pipe_condvar_init(buf->event);
- DRMLISTADDTAIL(&buf->head, &slab->freeBuffers);
- slab->numFree++;
- buf++;
- }
-
- DRMLISTADDTAIL(&slab->head, &header->slabs);
-
- return 0;
-
- out_err1:
- driSetKernelBOFree(header->slabPool->fMan, slab->kbo);
- free(slab->buffers);
- out_err0:
- free(slab);
- return ret;
-}
-
-/*
- * Delete a buffer from the slab header delayed list and put
- * it on the slab free list.
- */
-
-static void
-driSlabFreeBufferLocked(struct _DriSlabBuffer *buf)
-{
- struct _DriSlab *slab = buf->parent;
- struct _DriSlabSizeHeader *header = slab->header;
- drmMMListHead *list = &buf->head;
-
- DRMLISTDEL(list);
- DRMLISTADDTAIL(list, &slab->freeBuffers);
- slab->numFree++;
-
- if (slab->head.next == &slab->head)
- DRMLISTADDTAIL(&slab->head, &header->slabs);
-
- if (slab->numFree == slab->numBuffers) {
- list = &slab->head;
- DRMLISTDEL(list);
- DRMLISTADDTAIL(list, &header->freeSlabs);
- }
-
- if (header->slabs.next == &header->slabs ||
- slab->numFree != slab->numBuffers) {
-
- drmMMListHead *next;
- struct _DriFreeSlabManager *fMan = header->slabPool->fMan;
-
- for (list = header->freeSlabs.next, next = list->next;
- list != &header->freeSlabs;
- list = next, next = list->next) {
-
- slab = DRMLISTENTRY(struct _DriSlab, list, head);
-
- DRMLISTDELINIT(list);
- driSetKernelBOFree(fMan, slab->kbo);
- free(slab->buffers);
- free(slab);
- }
- }
-}
-
-static void
-driSlabCheckFreeLocked(struct _DriSlabSizeHeader *header, int wait)
-{
- drmMMListHead *list, *prev, *first;
- struct _DriSlabBuffer *buf;
- struct _DriSlab *slab;
- int firstWasSignaled = 1;
- int signaled;
- int i;
- int ret;
-
- /*
- * Rerun the freeing test if the youngest tested buffer
- * was signaled, since there might be more idle buffers
- * in the delay list.
- */
-
- while (firstWasSignaled) {
- firstWasSignaled = 0;
- signaled = 0;
- first = header->delayedBuffers.next;
-
- /* Only examine the oldest 1/3 of delayed buffers:
- */
- if (header->numDelayed > 3) {
- for (i = 0; i < header->numDelayed; i += 3) {
- first = first->next;
- }
- }
-
- for (list = first, prev = list->prev;
- list != &header->delayedBuffers;
- list = prev, prev = list->prev) {
- buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
- slab = buf->parent;
-
- if (!signaled) {
- if (wait) {
- ret = driFenceFinish(buf->fence, buf->fenceType, 0);
- if (ret)
- break;
- signaled = 1;
- wait = 0;
- } else {
- signaled = driFenceSignaled(buf->fence, buf->fenceType);
- }
- if (signaled) {
- if (list == first)
- firstWasSignaled = 1;
- driFenceUnReference(&buf->fence);
- header->numDelayed--;
- driSlabFreeBufferLocked(buf);
- }
- } else if (driFenceSignaledCached(buf->fence, buf->fenceType)) {
- driFenceUnReference(&buf->fence);
- header->numDelayed--;
- driSlabFreeBufferLocked(buf);
- }
- }
- }
-}
-
-
-static struct _DriSlabBuffer *
-driSlabAllocBuffer(struct _DriSlabSizeHeader *header)
-{
- static struct _DriSlabBuffer *buf;
- struct _DriSlab *slab;
- drmMMListHead *list;
- int count = DRI_SLABPOOL_ALLOC_RETRIES;
-
- pipe_mutex_lock(header->mutex);
- while(header->slabs.next == &header->slabs && count > 0) {
- driSlabCheckFreeLocked(header, 0);
- if (header->slabs.next != &header->slabs)
- break;
-
- pipe_mutex_unlock(header->mutex);
- if (count != DRI_SLABPOOL_ALLOC_RETRIES)
- usleep(1);
- pipe_mutex_lock(header->mutex);
- (void) driAllocSlab(header);
- count--;
- }
-
- list = header->slabs.next;
- if (list == &header->slabs) {
- pipe_mutex_unlock(header->mutex);
- return NULL;
- }
- slab = DRMLISTENTRY(struct _DriSlab, list, head);
- if (--slab->numFree == 0)
- DRMLISTDELINIT(list);
-
- list = slab->freeBuffers.next;
- DRMLISTDELINIT(list);
-
- pipe_mutex_unlock(header->mutex);
- buf = DRMLISTENTRY(struct _DriSlabBuffer, list, head);
- return buf;
-}
-
-static void *
-pool_create(struct _DriBufferPool *driPool, unsigned long size,
- uint64_t flags, unsigned hint, unsigned alignment)
-{
- struct _DriSlabPool *pool = (struct _DriSlabPool *) driPool->data;
- struct _DriSlabSizeHeader *header;
- struct _DriSlabBuffer *buf;
- void *dummy;
- int i;
- int ret;
-
- /*
- * FIXME: Check for compatibility.
- */
-
- header = pool->headers;
- for (i=0; i<pool->numBuckets; ++i) {
- if (header->bufSize >= size)
- break;
- header++;
- }
-
- if (i < pool->numBuckets)
- return driSlabAllocBuffer(header);
-
-
- /*
- * Fall back to allocate a buffer object directly from DRM.
- * and wrap it in a driBO structure.
- */
-
-
- buf = calloc(1, sizeof(*buf));
-
- if (!buf)
- return NULL;
-
- buf->bo = calloc(1, sizeof(*buf->bo));
- if (!buf->bo)
- goto out_err0;
-
- if (alignment) {
- if ((alignment < pool->pageSize) && (pool->pageSize % alignment))
- goto out_err1;
- if ((alignment > pool->pageSize) && (alignment % pool->pageSize))
- goto out_err1;
- }
-
- ret = drmBOCreate(pool->fd, size, alignment / pool->pageSize, NULL,
- flags, hint, buf->bo);
- if (ret)
- goto out_err1;
-
- ret = drmBOMap(pool->fd, buf->bo, DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE,
- 0, &dummy);
- if (ret)
- goto out_err2;
-
- ret = drmBOUnmap(pool->fd, buf->bo);
- if (ret)
- goto out_err2;
-
- return buf;
- out_err2:
- drmBOUnreference(pool->fd, buf->bo);
- out_err1:
- free(buf->bo);
- out_err0:
- free(buf);
- return NULL;
-}
-
-static int
-pool_destroy(struct _DriBufferPool *driPool, void *private)
-{
- struct _DriSlabBuffer *buf =
- (struct _DriSlabBuffer *) private;
- struct _DriSlab *slab;
- struct _DriSlabSizeHeader *header;
-
- if (!buf->isSlabBuffer) {
- struct _DriSlabPool *pool = (struct _DriSlabPool *) driPool->data;
- int ret;
-
- ret = drmBOUnreference(pool->fd, buf->bo);
- free(buf->bo);
- free(buf);
- return ret;
- }
-
- slab = buf->parent;
- header = slab->header;
-
- pipe_mutex_lock(header->mutex);
- buf->unFenced = 0;
- buf->mapCount = 0;
-
- if (buf->fence && !driFenceSignaledCached(buf->fence, buf->fenceType)) {
- DRMLISTADDTAIL(&buf->head, &header->delayedBuffers);
- header->numDelayed++;
- } else {
- if (buf->fence)
- driFenceUnReference(&buf->fence);
- driSlabFreeBufferLocked(buf);
- }
-
- pipe_mutex_unlock(header->mutex);
- return 0;
-}
-
-static int
-pool_waitIdle(struct _DriBufferPool *driPool, void *private,
- pipe_mutex *mutex, int lazy)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- while(buf->unFenced)
- pipe_condvar_wait(buf->event, *mutex);
-
- if (!buf->fence)
- return 0;
-
- driFenceFinish(buf->fence, buf->fenceType, lazy);
- driFenceUnReference(&buf->fence);
-
- return 0;
-}
-
-static int
-pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
- int hint, pipe_mutex *mutex, void **virtual)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- int busy;
-
- if (buf->isSlabBuffer)
- busy = buf->unFenced || (buf->fence && !driFenceSignaledCached(buf->fence, buf->fenceType));
- else
- busy = buf->fence && !driFenceSignaled(buf->fence, buf->fenceType);
-
-
- if (busy) {
- if (hint & DRM_BO_HINT_DONT_BLOCK)
- return -EBUSY;
- else {
- (void) pool_waitIdle(pool, private, mutex, 0);
- }
- }
-
- ++buf->mapCount;
- *virtual = (buf->isSlabBuffer) ?
- (void *) ((uint8_t *) buf->parent->kbo->virtual + buf->start) :
- (void *) buf->bo->virtual;
-
- return 0;
-}
-
-static int
-pool_unmap(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- --buf->mapCount;
- if (buf->mapCount == 0 && buf->isSlabBuffer)
- pipe_condvar_broadcast(buf->event);
-
- return 0;
-}
-
-static unsigned long
-pool_offset(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- struct _DriSlab *slab;
- struct _DriSlabSizeHeader *header;
-
- if (!buf->isSlabBuffer) {
- assert(buf->bo->proposedFlags & DRM_BO_FLAG_NO_MOVE);
- return buf->bo->offset;
- }
-
- slab = buf->parent;
- header = slab->header;
-
- (void) header;
- assert(header->slabPool->proposedFlags & DRM_BO_FLAG_NO_MOVE);
- return slab->kbo->bo.offset + buf->start;
-}
-
-static unsigned long
-pool_poolOffset(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- return buf->start;
-}
-
-static uint64_t
-pool_flags(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- if (!buf->isSlabBuffer)
- return buf->bo->flags;
-
- return buf->parent->kbo->bo.flags;
-}
-
-static unsigned long
-pool_size(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- if (!buf->isSlabBuffer)
- return buf->bo->size;
-
- return buf->parent->header->bufSize;
-}
-
-static int
-pool_fence(struct _DriBufferPool *pool, void *private,
- struct _DriFenceObject *fence)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
- drmBO *bo;
-
- if (buf->fence)
- driFenceUnReference(&buf->fence);
-
- buf->fence = driFenceReference(fence);
- bo = (buf->isSlabBuffer) ?
- &buf->parent->kbo->bo:
- buf->bo;
- buf->fenceType = bo->fenceFlags;
-
- buf->unFenced = 0;
- pipe_condvar_broadcast(buf->event);
-
- return 0;
-}
-
-static drmBO *
-pool_kernel(struct _DriBufferPool *pool, void *private)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- return (buf->isSlabBuffer) ? &buf->parent->kbo->bo : buf->bo;
-}
-
-static int
-pool_validate(struct _DriBufferPool *pool, void *private,
- pipe_mutex *mutex)
-{
- struct _DriSlabBuffer *buf = (struct _DriSlabBuffer *) private;
-
- if (!buf->isSlabBuffer)
- return 0;
-
- while(buf->mapCount != 0)
- pipe_condvar_wait(buf->event, *mutex);
-
- buf->unFenced = 1;
- return 0;
-}
-
-
-struct _DriFreeSlabManager *
-driInitFreeSlabManager(uint32_t checkIntervalMsec, uint32_t slabTimeoutMsec)
-{
- struct _DriFreeSlabManager *tmp;
-
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
-
- pipe_mutex_init(tmp->mutex);
- pipe_mutex_lock(tmp->mutex);
- tmp->slabTimeout.tv_usec = slabTimeoutMsec*1000;
- tmp->slabTimeout.tv_sec = tmp->slabTimeout.tv_usec / 1000000;
- tmp->slabTimeout.tv_usec -= tmp->slabTimeout.tv_sec*1000000;
-
- tmp->checkInterval.tv_usec = checkIntervalMsec*1000;
- tmp->checkInterval.tv_sec = tmp->checkInterval.tv_usec / 1000000;
- tmp->checkInterval.tv_usec -= tmp->checkInterval.tv_sec*1000000;
-
- gettimeofday(&tmp->nextCheck, NULL);
- driTimeAdd(&tmp->nextCheck, &tmp->checkInterval);
- DRMINITLISTHEAD(&tmp->timeoutList);
- DRMINITLISTHEAD(&tmp->unCached);
- DRMINITLISTHEAD(&tmp->cached);
- pipe_mutex_unlock(tmp->mutex);
-
- return tmp;
-}
-
-void
-driFinishFreeSlabManager(struct _DriFreeSlabManager *fMan)
-{
- struct timeval time;
-
- time = fMan->nextCheck;
- driTimeAdd(&time, &fMan->checkInterval);
-
- pipe_mutex_lock(fMan->mutex);
- driFreeTimeoutKBOsLocked(fMan, &time);
- pipe_mutex_unlock(fMan->mutex);
-
- assert(fMan->timeoutList.next == &fMan->timeoutList);
- assert(fMan->unCached.next == &fMan->unCached);
- assert(fMan->cached.next == &fMan->cached);
-
- free(fMan);
-}
-
-static void
-driInitSizeHeader(struct _DriSlabPool *pool, uint32_t size,
- struct _DriSlabSizeHeader *header)
-{
- pipe_mutex_init(header->mutex);
- pipe_mutex_lock(header->mutex);
-
- DRMINITLISTHEAD(&header->slabs);
- DRMINITLISTHEAD(&header->freeSlabs);
- DRMINITLISTHEAD(&header->delayedBuffers);
-
- header->numDelayed = 0;
- header->slabPool = pool;
- header->bufSize = size;
-
- pipe_mutex_unlock(header->mutex);
-}
-
-static void
-driFinishSizeHeader(struct _DriSlabSizeHeader *header)
-{
- drmMMListHead *list, *next;
- struct _DriSlabBuffer *buf;
-
- pipe_mutex_lock(header->mutex);
- for (list = header->delayedBuffers.next, next = list->next;
- list != &header->delayedBuffers;
- list = next, next = list->next) {
-
- buf = DRMLISTENTRY(struct _DriSlabBuffer, list , head);
- if (buf->fence) {
- (void) driFenceFinish(buf->fence, buf->fenceType, 0);
- driFenceUnReference(&buf->fence);
- }
- header->numDelayed--;
- driSlabFreeBufferLocked(buf);
- }
- pipe_mutex_unlock(header->mutex);
-}
-
-static void
-pool_takedown(struct _DriBufferPool *driPool)
-{
- struct _DriSlabPool *pool = driPool->data;
- int i;
-
- for (i=0; i<pool->numBuckets; ++i) {
- driFinishSizeHeader(&pool->headers[i]);
- }
-
- free(pool->headers);
- free(pool->bucketSizes);
- free(pool);
- free(driPool);
-}
-
-struct _DriBufferPool *
-driSlabPoolInit(int fd, uint64_t flags,
- uint64_t validMask,
- uint32_t smallestSize,
- uint32_t numSizes,
- uint32_t desiredNumBuffers,
- uint32_t maxSlabSize,
- uint32_t pageAlignment,
- struct _DriFreeSlabManager *fMan)
-{
- struct _DriBufferPool *driPool;
- struct _DriSlabPool *pool;
- uint32_t i;
-
- driPool = calloc(1, sizeof(*driPool));
- if (!driPool)
- return NULL;
-
- pool = calloc(1, sizeof(*pool));
- if (!pool)
- goto out_err0;
-
- pool->bucketSizes = calloc(numSizes, sizeof(*pool->bucketSizes));
- if (!pool->bucketSizes)
- goto out_err1;
-
- pool->headers = calloc(numSizes, sizeof(*pool->headers));
- if (!pool->headers)
- goto out_err2;
-
- pool->fMan = fMan;
- pool->proposedFlags = flags;
- pool->validMask = validMask;
- pool->numBuckets = numSizes;
- pool->pageSize = getpagesize();
- pool->fd = fd;
- pool->pageAlignment = pageAlignment;
- pool->maxSlabSize = maxSlabSize;
- pool->desiredNumBuffers = desiredNumBuffers;
-
- for (i=0; i<pool->numBuckets; ++i) {
- pool->bucketSizes[i] = (smallestSize << i);
- driInitSizeHeader(pool, pool->bucketSizes[i],
- &pool->headers[i]);
- }
-
- driPool->data = (void *) pool;
- driPool->map = &pool_map;
- driPool->unmap = &pool_unmap;
- driPool->destroy = &pool_destroy;
- driPool->offset = &pool_offset;
- driPool->poolOffset = &pool_poolOffset;
- driPool->flags = &pool_flags;
- driPool->size = &pool_size;
- driPool->create = &pool_create;
- driPool->fence = &pool_fence;
- driPool->kernel = &pool_kernel;
- driPool->validate = &pool_validate;
- driPool->waitIdle = &pool_waitIdle;
- driPool->takeDown = &pool_takedown;
-
- return driPool;
-
- out_err2:
- free(pool->bucketSizes);
- out_err1:
- free(pool);
- out_err0:
- free(driPool);
-
- return NULL;
-}
diff --git a/src/gallium/winsys/drm/intel/dri/Makefile b/src/gallium/winsys/drm/intel/dri/Makefile
deleted file mode 100644
index 2046441a22..0000000000
--- a/src/gallium/winsys/drm/intel/dri/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i915_dri.so
-LIBNAME_EGL = egl_i915_dri.so
-
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- ../common/libinteldrm.a \
- $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
-
-
-DRIVER_SOURCES = \
- intel_winsys_softpipe.c \
- intel_swapbuffers.c \
- intel_context.c \
- intel_lock.c \
- intel_screen.c
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../common $(shell pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-
-include ../../Makefile.template
-
-#intel_tex_layout.o: $(TOP)/src/mesa/drivers/dri/intel/intel_tex_layout.c
-
-symlinks:
diff --git a/src/gallium/winsys/drm/intel/dri/SConscript b/src/gallium/winsys/drm/intel/dri/SConscript
deleted file mode 100644
index 6a4f50afcc..0000000000
--- a/src/gallium/winsys/drm/intel/dri/SConscript
+++ /dev/null
@@ -1,41 +0,0 @@
-Import('*')
-
-if 'mesa' in env['statetrackers']:
-
- env = drienv.Clone()
-
- env.Append(CPPPATH = [
- '../intel',
- 'server'
- ])
-
- #MINIGLX_SOURCES = server/intel_dri.c
-
- DRIVER_SOURCES = [
- 'intel_winsys_pipe.c',
- 'intel_winsys_softpipe.c',
- 'intel_winsys_i915.c',
- 'intel_batchbuffer.c',
- 'intel_swapbuffers.c',
- 'intel_context.c',
- 'intel_lock.c',
- 'intel_screen.c',
- 'intel_batchpool.c',
- ]
-
- sources = \
- COMMON_GALLIUM_SOURCES + \
- COMMON_BM_SOURCES + \
- DRIVER_SOURCES
-
- drivers = [
- softpipe,
- i915simple
- ]
-
- # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions
- env.SharedLibrary(
- target ='i915tex_dri.so',
- source = sources,
- LIBS = drivers + mesa + auxiliaries + env['LIBS'],
- )
diff --git a/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h b/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h
deleted file mode 100644
index 3e95326168..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_batchbuffer.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef INTEL_BATCHBUFFER_H
-#define INTEL_BATCHBUFFER_H
-
-#include "intel_be_batchbuffer.h"
-
-/*
- * Need to redefine the BATCH defines
- */
-
-#undef BEGIN_BATCH
-#define BEGIN_BATCH(dwords, relocs) \
- (i915_batchbuffer_check(&intel->base.batch->base, dwords, relocs))
-
-#undef OUT_BATCH
-#define OUT_BATCH(d) \
- i915_batchbuffer_dword(&intel->base.batch->base, d)
-
-#undef OUT_RELOC
-#define OUT_RELOC(buf,flags,mask,delta) do { \
- assert((delta) >= 0); \
- intel_be_offset_relocation(intel->base.batch, delta, buf, flags, mask); \
-} while (0)
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_context.c b/src/gallium/winsys/drm/intel/dri/intel_context.c
deleted file mode 100644
index 97ef731aaa..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_context.c
+++ /dev/null
@@ -1,337 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "i830_dri.h"
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_swapbuffers.h"
-#include "intel_batchbuffer.h"
-#include "intel_winsys_softpipe.h"
-
-#include "i915simple/i915_screen.h"
-
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-
-#include "utils.h"
-
-
-#ifdef DEBUG
-int __intel_debug = 0;
-#endif
-
-
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_window_pos
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_NV_vertex_program
-#include "extension_helper.h"
-
-
-/**
- * Extension strings exported by the intel driver.
- *
- * \note
- * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
- * old i830-specific driver.
- */
-const struct dri_extension card_extensions[] = {
- {"GL_ARB_multisample", GL_ARB_multisample_functions},
- {"GL_ARB_multitexture", NULL},
- {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
- {"GL_ARB_texture_border_clamp", NULL},
- {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
- {"GL_ARB_texture_cube_map", NULL},
- {"GL_ARB_texture_env_add", NULL},
- {"GL_ARB_texture_env_combine", NULL},
- {"GL_ARB_texture_env_dot3", NULL},
- {"GL_ARB_texture_mirrored_repeat", NULL},
- {"GL_ARB_texture_rectangle", NULL},
- {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
- {"GL_ARB_pixel_buffer_object", NULL},
- {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
- {"GL_ARB_window_pos", GL_ARB_window_pos_functions},
- {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
- {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
- {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
- {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
- {"GL_EXT_blend_subtract", NULL},
- {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
- {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
- {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
- {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
- {"GL_EXT_packed_depth_stencil", NULL},
- {"GL_EXT_pixel_buffer_object", NULL},
- {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
- {"GL_EXT_stencil_wrap", NULL},
- {"GL_EXT_texture_edge_clamp", NULL},
- {"GL_EXT_texture_env_combine", NULL},
- {"GL_EXT_texture_env_dot3", NULL},
- {"GL_EXT_texture_filter_anisotropic", NULL},
- {"GL_EXT_texture_lod_bias", NULL},
- {"GL_3DFX_texture_compression_FXT1", NULL},
- {"GL_APPLE_client_storage", NULL},
- {"GL_MESA_pack_invert", NULL},
- {"GL_MESA_ycbcr_texture", NULL},
- {"GL_NV_blend_square", NULL},
- {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
- {"GL_NV_vertex_program1_1", NULL},
- {"GL_SGIS_generate_mipmap", NULL },
- {NULL, NULL}
-};
-
-
-
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
- {"ioctl", DEBUG_IOCTL},
- {"bat", DEBUG_BATCH},
- {"lock", DEBUG_LOCK},
- {"swap", DEBUG_SWAP},
- {NULL, 0}
-};
-#endif
-
-
-
-static void
-intel_lock_hardware(struct intel_be_context *context)
-{
- struct intel_context *intel = (struct intel_context *)context;
- LOCK_HARDWARE(intel);
-}
-
-static void
-intel_unlock_hardware(struct intel_be_context *context)
-{
- struct intel_context *intel = (struct intel_context *)context;
- UNLOCK_HARDWARE(intel);
-}
-
-static boolean
-intel_locked_hardware(struct intel_be_context *context)
-{
- struct intel_context *intel = (struct intel_context *)context;
- return intel->locked ? TRUE : FALSE;
-}
-
-GLboolean
-intelCreateContext(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate)
-{
- struct intel_context *intel = CALLOC_STRUCT(intel_context);
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
- struct intel_screen *intelScreen = intel_screen(sPriv);
- drmI830Sarea *saPriv = intelScreen->sarea;
- int fthrottle_mode;
- GLboolean havePools;
- struct pipe_context *pipe;
- struct st_context *st_share = NULL;
-
- if (sharedContextPrivate) {
- st_share = ((struct intel_context *) sharedContextPrivate)->st;
- }
-
- driContextPriv->driverPrivate = intel;
- intel->intelScreen = intelScreen;
- intel->driScreen = sPriv;
- intel->sarea = saPriv;
-
- driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
- intel->driScreen->myNum, "i915");
-
-
- /*
- * memory pools
- */
- DRM_LIGHT_LOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
- // ZZZ JB should be per screen and not be done per context
- havePools = intelCreatePools(sPriv);
- DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, driContextPriv->hHWContext);
- if (!havePools)
- return GL_FALSE;
-
-
- /* Dri stuff */
- intel->hHWContext = driContextPriv->hHWContext;
- intel->driFd = sPriv->fd;
- intel->driHwLock = (drmLock *) & sPriv->pSAREA->lock;
-
- fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
- intel->iw.irq_seq = -1;
- intel->irqsEmitted = 0;
-
- intel->last_swap_fence = NULL;
- intel->first_swap_fence = NULL;
-
-#ifdef DEBUG
- __intel_debug = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
-#endif
- 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, &intelScreen->base);
-
- /*
- * Pipe-related setup
- */
- if (getenv("INTEL_SP")) {
- /* use softpipe driver instead of hw */
- pipe = intel_create_softpipe( intel, &intelScreen->base.base );
- }
- else {
- switch (intel->intelScreen->deviceID) {
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
- case PCI_CHIP_I945_GME:
- case PCI_CHIP_G33_G:
- case PCI_CHIP_Q33_G:
- case PCI_CHIP_Q35_G:
- case PCI_CHIP_I915_G:
- case PCI_CHIP_I915_GM:
- pipe = i915_create_context(intelScreen->base.screen,
- &intelScreen->base.base,
- &intel->base.base);
- break;
- default:
- fprintf(stderr, "Unknown PCIID %x in %s, using software driver\n",
- intel->intelScreen->deviceID, __FUNCTION__);
-
- pipe = intel_create_softpipe( intel, &intelScreen->base.base );
- break;
- }
- }
-
- pipe->priv = intel;
-
- intel->st = st_create_context(pipe, visual, st_share);
-
- driInitExtensions( intel->st->ctx, card_extensions, GL_TRUE );
-
- return GL_TRUE;
-}
-
-
-void
-intelDestroyContext(__DRIcontextPrivate * driContextPriv)
-{
- struct intel_context *intel = intel_context(driContextPriv);
-
- assert(intel); /* should never be null */
- if (intel) {
- st_finish(intel->st);
-
- if (intel->last_swap_fence) {
- driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
- driFenceUnReference(&intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- if (intel->first_swap_fence) {
- driFenceFinish(intel->first_swap_fence, DRM_FENCE_TYPE_EXE, GL_TRUE);
- driFenceUnReference(&intel->first_swap_fence);
- intel->first_swap_fence = NULL;
- }
-
- if (intel->intelScreen->dummyContext == intel)
- intel->intelScreen->dummyContext = NULL;
-
- st_destroy_context(intel->st);
- intel_be_destroy_context(&intel->base);
- free(intel);
- }
-}
-
-
-GLboolean
-intelUnbindContext(__DRIcontextPrivate * driContextPriv)
-{
- struct intel_context *intel = intel_context(driContextPriv);
- st_flush(intel->st, PIPE_FLUSH_RENDER_CACHE, NULL);
- /* XXX make_current(NULL)? */
- return GL_TRUE;
-}
-
-
-GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv)
-{
- if (driContextPriv) {
- struct intel_context *intel = intel_context(driContextPriv);
- struct intel_framebuffer *draw_fb = intel_framebuffer(driDrawPriv);
- struct intel_framebuffer *read_fb = intel_framebuffer(driReadPriv);
-
- assert(draw_fb->stfb);
- assert(read_fb->stfb);
-
- /* This is for situations in which we need a rendering context but
- * there may not be any currently bound.
- */
- intel->intelScreen->dummyContext = intel;
-
- st_make_current(intel->st, draw_fb->stfb, read_fb->stfb);
-
- if ((intel->driDrawable != driDrawPriv) ||
- (intel->lastStamp != driDrawPriv->lastStamp)) {
- intel->driDrawable = driDrawPriv;
- intelUpdateWindowSize(driDrawPriv);
- intel->lastStamp = driDrawPriv->lastStamp;
- }
-
- /* The size of the draw buffer will have been updated above.
- * If the readbuffer is a different window, check/update its size now.
- */
- if (driReadPriv != driDrawPriv) {
- intelUpdateWindowSize(driReadPriv);
- }
-
- }
- else {
- st_make_current(NULL, NULL, NULL);
- }
-
- return GL_TRUE;
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_context.h b/src/gallium/winsys/drm/intel/dri/intel_context.h
deleted file mode 100644
index 5d22a422af..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_context.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_CONTEXT_H
-#define INTEL_CONTEXT_H
-
-#include <stdint.h>
-#include "drm.h"
-
-#include "pipe/p_debug.h"
-
-#include "intel_screen.h"
-#include "i915_drm.h"
-
-#include "intel_be_context.h"
-
-
-struct pipe_context;
-struct intel_context;
-struct _DriBufferObject;
-struct st_context;
-
-
-#define INTEL_MAX_FIXUP 64
-
-/**
- * Intel rendering context, contains a state tracker and intel-specific info.
- */
-struct intel_context
-{
- struct intel_be_context base;
- struct st_context *st;
-
- struct _DriFenceObject *last_swap_fence;
- struct _DriFenceObject *first_swap_fence;
-
-// struct intel_batchbuffer *batch;
-
- boolean locked;
- char *prevLockFile;
- int prevLockLine;
-
- uint irqsEmitted;
- drm_i915_irq_wait_t iw;
-
- drm_context_t hHWContext;
- drmLock *driHwLock;
- int driFd;
-
- __DRIdrawablePrivate *driDrawable;
- __DRIscreenPrivate *driScreen;
- struct intel_screen *intelScreen;
- drmI830Sarea *sarea;
-
- uint lastStamp;
-
- /**
- * Configuration cache
- */
- driOptionCache optionCache;
-};
-
-
-
-/**
- * Intel framebuffer.
- */
-struct intel_framebuffer
-{
- struct st_framebuffer *stfb;
-
- /* other fields TBD */
- int other;
-};
-
-
-
-
-/* These are functions now:
- */
-void LOCK_HARDWARE( struct intel_context *intel );
-void UNLOCK_HARDWARE( struct intel_context *intel );
-
-extern char *__progname;
-
-
-
-/* ================================================================
- * Debugging:
- */
-#ifdef DEBUG
-extern int __intel_debug;
-
-#define DEBUG_SWAP 0x1
-#define DEBUG_LOCK 0x2
-#define DEBUG_IOCTL 0x4
-#define DEBUG_BATCH 0x8
-
-#define DBG(flag, ...) do { \
- if (__intel_debug & (DEBUG_##flag)) \
- printf(__VA_ARGS__); \
-} while(0)
-
-#else
-#define DBG(flag, ...)
-#endif
-
-
-
-#define PCI_CHIP_845_G 0x2562
-#define PCI_CHIP_I830_M 0x3577
-#define PCI_CHIP_I855_GM 0x3582
-#define PCI_CHIP_I865_G 0x2572
-#define PCI_CHIP_I915_G 0x2582
-#define PCI_CHIP_I915_GM 0x2592
-#define PCI_CHIP_I945_G 0x2772
-#define PCI_CHIP_I945_GM 0x27A2
-#define PCI_CHIP_I945_GME 0x27AE
-#define PCI_CHIP_G33_G 0x29C2
-#define PCI_CHIP_Q35_G 0x29B2
-#define PCI_CHIP_Q33_G 0x29D2
-
-
-/** Cast wrapper */
-static INLINE struct intel_context *
-intel_context(__DRIcontextPrivate *driContextPriv)
-{
- return (struct intel_context *) driContextPriv->driverPrivate;
-}
-
-
-/** Cast wrapper */
-static INLINE struct intel_framebuffer *
-intel_framebuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- return (struct intel_framebuffer *) driDrawPriv->driverPrivate;
-}
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_lock.c b/src/gallium/winsys/drm/intel/dri/intel_lock.c
deleted file mode 100644
index ad1c202429..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_lock.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "main/glheader.h"
-#include "pipe/p_thread.h"
-#include <GL/internal/glcore.h>
-#include "state_tracker/st_public.h"
-#include "intel_context.h"
-#include "i830_dri.h"
-
-
-
-pipe_static_mutex( lockMutex );
-
-
-static void
-intelContendedLock(struct intel_context *intel, uint flags)
-{
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- __DRIscreenPrivate *sPriv = intel->driScreen;
- struct intel_screen *intelScreen = intel_screen(sPriv);
- drmI830Sarea *sarea = intel->sarea;
-
- drmGetLock(intel->driFd, intel->hHWContext, flags);
-
- DBG(LOCK, "%s - got contended lock\n", __progname);
-
- /* If the window moved, may need to set a new cliprect now.
- *
- * NOTE: This releases and regains the hw lock, so all state
- * checking must be done *after* this call:
- */
- if (dPriv)
- DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-
- if (sarea->width != intelScreen->front.width ||
- sarea->height != intelScreen->front.height) {
-
- intelUpdateScreenRotation(sPriv, sarea);
- }
-}
-
-
-/* Lock the hardware and validate our state.
- */
-void LOCK_HARDWARE( struct intel_context *intel )
-{
- char __ret = 0;
-
- pipe_mutex_lock(lockMutex);
- assert(!intel->locked);
-
- DRM_CAS(intel->driHwLock, intel->hHWContext,
- (DRM_LOCK_HELD|intel->hHWContext), __ret);
-
- if (__ret)
- intelContendedLock( intel, 0 );
-
- DBG(LOCK, "%s - locked\n", __progname);
-
- intel->locked = 1;
-}
-
-
-/* Unlock the hardware using the global current context
- */
-void UNLOCK_HARDWARE( struct intel_context *intel )
-{
- assert(intel->locked);
- intel->locked = 0;
-
- DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
-
- pipe_mutex_unlock(lockMutex);
-
- DBG(LOCK, "%s - unlocked\n", __progname);
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_reg.h b/src/gallium/winsys/drm/intel/dri/intel_reg.h
deleted file mode 100644
index 4f33bee438..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_reg.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef _INTEL_REG_H_
-#define _INTEL_REG_H_
-
-
-#define BR00_BITBLT_CLIENT 0x40000000
-#define BR00_OP_COLOR_BLT 0x10000000
-#define BR00_OP_SRC_COPY_BLT 0x10C00000
-#define BR13_SOLID_PATTERN 0x80000000
-
-#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|0x4)
-#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
-#define XY_COLOR_BLT_WRITE_RGB (1<<20)
-
-#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
-#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
-#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
-
-#define MI_WAIT_FOR_EVENT ((0x3<<23))
-#define MI_WAIT_FOR_PLANE_B_FLIP (1<<6)
-#define MI_WAIT_FOR_PLANE_A_FLIP (1<<2)
-
-#define MI_BATCH_BUFFER_END (0xA<<23)
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_screen.c b/src/gallium/winsys/drm/intel/dri/intel_screen.c
deleted file mode 100644
index ed75368982..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_screen.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "utils.h"
-#include "vblank.h"
-#include "xmlpool.h"
-
-#include "intel_context.h"
-#include "intel_screen.h"
-#include "intel_batchbuffer.h"
-#include "intel_swapbuffers.h"
-
-#include "i830_dri.h"
-#include "ws_dri_bufpool.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_screen.h"
-#include "pipe/p_inlines.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_cb_fbo.h"
-
-static void
-intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle);
-
-static void
-intelCreateSurface(struct intel_screen *intelScreen, struct pipe_winsys *winsys, unsigned handle)
-{
- struct pipe_screen *screen = intelScreen->base.screen;
- struct pipe_texture *texture;
- struct pipe_texture templat;
- struct pipe_surface *surface;
- struct pipe_buffer *buffer;
- unsigned pitch;
-
- assert(intelScreen->front.cpp == 4);
-
- buffer = intel_be_buffer_from_handle(&intelScreen->base,
- "front", handle);
-
- if (!buffer)
- return;
-
- intelScreen->front.buffer = dri_bo(buffer);
-
- memset(&templat, 0, sizeof(templat));
- templat.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
- templat.target = PIPE_TEXTURE_2D;
- templat.last_level = 0;
- templat.depth[0] = 1;
- templat.format = PIPE_FORMAT_A8R8G8B8_UNORM;
- templat.width[0] = intelScreen->front.width;
- templat.height[0] = intelScreen->front.height;
- pf_get_block(templat.format, &templat.block);
- pitch = intelScreen->front.pitch;
-
- texture = screen->texture_blanket(screen,
- &templat,
- &pitch,
- buffer);
-
- /* Unref the buffer we don't need it anyways */
- pipe_buffer_reference(screen, &buffer, NULL);
-
- surface = screen->get_tex_surface(screen,
- texture,
- 0,
- 0,
- 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- intelScreen->front.texture = texture;
- intelScreen->front.surface = surface;
-}
-
-PUBLIC const char __driConfigOptions[] =
- DRI_CONF_BEGIN DRI_CONF_SECTION_PERFORMANCE
- DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
- DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
- DRI_CONF_SECTION_END DRI_CONF_SECTION_QUALITY
-// DRI_CONF_FORCE_S3TC_ENABLE(false)
- DRI_CONF_ALLOW_LARGE_TEXTURES(1)
- DRI_CONF_SECTION_END DRI_CONF_END;
-
-const uint __driNConfigOptions = 3;
-
-#ifdef USE_NEW_INTERFACE
-static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
-#endif /*USE_NEW_INTERFACE */
-
-extern const struct dri_extension card_extensions[];
-
-static GLboolean
-intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
-{
- int ret;
- struct drm_i915_getparam gp;
-
- gp.param = param;
- gp.value = value;
-
- ret = drmCommandWriteRead(psp->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
- if (ret) {
- fprintf(stderr, "drm_i915_getparam: %d\n", ret);
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-static void
-intelSetTexOffset(__DRIcontext *pDRICtx, int texname,
- unsigned long long offset, int depth, uint pitch)
-{
- abort();
-#if 0
- struct intel_context *intel = (struct intel_context*)
- ((__DRIcontextPrivate*)pDRICtx->private)->driverPrivate;
- struct gl_texture_object *tObj = _mesa_lookup_texture(&intel->ctx, texname);
- struct st_texture_object *stObj = st_texture_object(tObj);
-
- if (!stObj)
- return;
-
- if (stObj->pt)
- st->pipe->texture_release(intel->st->pipe, &stObj->pt);
-
- stObj->imageOverride = GL_TRUE;
- stObj->depthOverride = depth;
- stObj->pitchOverride = pitch;
-
- if (offset)
- stObj->textureOffset = offset;
-#endif
-}
-
-
-#if 0
-static void
-intelHandleDrawableConfig(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *pcp,
- __DRIDrawableConfigEvent *event)
-{
- (void) dPriv;
- (void) pcp;
- (void) event;
-}
-#endif
-
-#if 0
-static void
-intelHandleBufferAttach(__DRIdrawablePrivate *dPriv,
- __DRIcontextPrivate *pcp,
- __DRIBufferAttachEvent *ba)
-{
- struct intel_screen *intelScreen = intel_screen(dPriv->driScreenPriv);
-
- switch (ba->buffer.attachment) {
- case DRI_DRAWABLE_BUFFER_FRONT_LEFT:
- intelScreen->front.width = dPriv->w;
- intelScreen->front.height = dPriv->h;
- intelScreen->front.cpp = ba->buffer.cpp;
- intelScreen->front.pitch = ba->buffer.pitch;
- driGenBuffers(intelScreen->base.staticPool, "front", 1, &intelScreen->front.buffer, 0, 0, 0);
- driBOSetReferenced(intelScreen->front.buffer, ba->buffer.handle);
- break;
-
- case DRI_DRAWABLE_BUFFER_BACK_LEFT:
- case DRI_DRAWABLE_BUFFER_DEPTH:
- case DRI_DRAWABLE_BUFFER_STENCIL:
- case DRI_DRAWABLE_BUFFER_ACCUM:
- /* anything ?? */
- break;
-
- default:
- fprintf(stderr, "unhandled buffer attach event, attachment type %d\n",
- ba->buffer.attachment);
- return;
- }
-}
-#endif
-
-static const __DRItexOffsetExtension intelTexOffsetExtension = {
- { __DRI_TEX_OFFSET },
- intelSetTexOffset,
-};
-
-#if 0
-static const __DRItexBufferExtension intelTexBufferExtension = {
- { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION },
- intelSetTexBuffer,
-};
-#endif
-
-static const __DRIextension *intelScreenExtensions[] = {
- &driReadDrawableExtension,
- &driCopySubBufferExtension.base,
- &driSwapControlExtension.base,
- &driFrameTrackingExtension.base,
- &driMediaStreamCounterExtension.base,
- &intelTexOffsetExtension.base,
-// &intelTexBufferExtension.base,
- NULL
-};
-
-
-static void
-intelPrintDRIInfo(struct intel_screen * intelScreen,
- __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
-{
- fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
- intelScreen->front.size, intelScreen->front.offset,
- intelScreen->front.pitch);
- fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
-}
-
-
-#if 0
-static void
-intelPrintSAREA(const drmI830Sarea * sarea)
-{
- fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width,
- sarea->height);
- fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
- fprintf(stderr,
- "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->front_offset, sarea->front_size,
- (unsigned) sarea->front_handle);
- fprintf(stderr,
- "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->back_offset, sarea->back_size,
- (unsigned) sarea->back_handle);
- fprintf(stderr, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->depth_offset, sarea->depth_size,
- (unsigned) sarea->depth_handle);
- fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
- fprintf(stderr, "SAREA: rotation: %d\n", sarea->rotation);
- fprintf(stderr,
- "SAREA: rotated offset: 0x%08x size: 0x%x\n",
- sarea->rotated_offset, sarea->rotated_size);
- fprintf(stderr, "SAREA: rotated pitch: %d\n", sarea->rotated_pitch);
-}
-#endif
-
-
-/**
- * Use the information in the sarea to update the screen parameters
- * related to screen rotation. Needs to be called locked.
- */
-void
-intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea)
-{
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- if (intelScreen->front.map) {
- drmUnmap(intelScreen->front.map, intelScreen->front.size);
- intelScreen->front.map = NULL;
- }
-
- if (intelScreen->front.buffer)
- driDeleteBuffers(1, &intelScreen->front.buffer);
-
- intelScreen->front.width = sarea->width;
- intelScreen->front.height = sarea->height;
- intelScreen->front.offset = sarea->front_offset;
- intelScreen->front.pitch = sarea->pitch * intelScreen->front.cpp;
- intelScreen->front.size = sarea->front_size;
- intelScreen->front.handle = sarea->front_handle;
-
- assert( sarea->front_size >=
- intelScreen->front.pitch * intelScreen->front.height );
-
-#if 0 /* JB not important */
- if (!sarea->front_handle)
- return;
-
- if (drmMap(sPriv->fd,
- sarea->front_handle,
- intelScreen->front.size,
- (drmAddress *) & intelScreen->front.map) != 0) {
- fprintf(stderr, "drmMap(frontbuffer) failed!\n");
- return;
- }
-#endif
-
-#if 0 /* JB */
- if (intelScreen->staticPool) {
- driGenBuffers(intelScreen->staticPool, "static region", 1,
- &intelScreen->front.buffer, 64,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_NO_MOVE |
- DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE, 0);
-
- driBOSetStatic(intelScreen->front.buffer,
- intelScreen->front.offset,
- intelScreen->front.pitch * intelScreen->front.height,
- intelScreen->front.map, 0);
- }
-#else
- if (intelScreen->base.staticPool) {
- if (intelScreen->front.buffer) {
- driBOUnReference(intelScreen->front.buffer);
- pipe_surface_reference(&intelScreen->front.surface, NULL);
- pipe_texture_reference(&intelScreen->front.texture, NULL);
- }
- intelCreateSurface(intelScreen, &intelScreen->base.base, sarea->front_bo_handle);
- }
-#endif
-}
-
-
-boolean
-intelCreatePools(__DRIscreenPrivate * sPriv)
-{
- //unsigned batchPoolSize = 1024*1024;
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- if (intelScreen->havePools)
- return GL_TRUE;
-
- intelScreen->havePools = GL_TRUE;
-
- if (intelScreen->sarea)
- intelUpdateScreenRotation(sPriv, intelScreen->sarea);
-
- return GL_TRUE;
-}
-
-static const char *
-intel_get_name( struct pipe_winsys *winsys )
-{
- return "Intel/DRI/ttm";
-}
-
-/*
- * The state tracker (should!) keep track of whether the fake
- * frontbuffer has been touched by any rendering since the last time
- * we copied its contents to the real frontbuffer. Our task is easy:
- */
-static void
-intel_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- struct intel_context *intel = (struct intel_context *) context_private;
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
- intelDisplaySurface(dPriv, surf, NULL);
-}
-
-static boolean
-intelInitDriver(__DRIscreenPrivate * sPriv)
-{
- struct intel_screen *intelScreen;
- I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
-
- if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
- fprintf(stderr,
- "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
- return GL_FALSE;
- }
-
- /* Allocate the private area */
- intelScreen = CALLOC_STRUCT(intel_screen);
- if (!intelScreen)
- return GL_FALSE;
-
- /* parse information in __driConfigOptions */
- driParseOptionInfo(&intelScreen->optionCache,
- __driConfigOptions, __driNConfigOptions);
-
- sPriv->private = (void *) intelScreen;
- intelScreen->sarea = (drmI830Sarea *) (((GLubyte *) sPriv->pSAREA) +
- gDRIPriv->sarea_priv_offset);
-
- intelScreen->deviceID = gDRIPriv->deviceID;
-
- intelScreen->front.cpp = gDRIPriv->cpp;
- intelScreen->drmMinor = sPriv->drm_version.minor;
- intelUpdateScreenRotation(sPriv, intelScreen->sarea);
-
- if (0)
- intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
-
- sPriv->extensions = intelScreenExtensions;
-
- intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
- intelScreen->base.base.get_name = intel_get_name;
- intel_be_init_device(&intelScreen->base, sPriv->fd, intelScreen->deviceID);
-
- return GL_TRUE;
-}
-
-
-static void
-intelDestroyScreen(__DRIscreenPrivate * sPriv)
-{
- struct intel_screen *intelScreen = intel_screen(sPriv);
-
- intel_be_destroy_device(&intelScreen->base);
- /* intelUnmapScreenRegions(intelScreen); */
-
- FREE(intelScreen);
- sPriv->private = NULL;
-}
-
-
-/**
- * This is called when we need to set up GL rendering to a new X window.
- */
-static boolean
-intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
- __DRIdrawablePrivate * driDrawPriv,
- const __GLcontextModes * visual, boolean isPixmap)
-{
- if (isPixmap) {
- return GL_FALSE; /* not implemented */
- }
- else {
- enum pipe_format colorFormat, depthFormat, stencilFormat;
- struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer);
-
- if (!intelfb)
- return GL_FALSE;
-
- if (visual->redBits == 5)
- colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
- else
- colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
-
- if (visual->depthBits == 16)
- depthFormat = PIPE_FORMAT_Z16_UNORM;
- else if (visual->depthBits == 24)
- depthFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- depthFormat = PIPE_FORMAT_NONE;
-
- if (visual->stencilBits == 8)
- stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
- else
- stencilFormat = PIPE_FORMAT_NONE;
-
- intelfb->stfb = st_create_framebuffer(visual,
- colorFormat,
- depthFormat,
- stencilFormat,
- driDrawPriv->w,
- driDrawPriv->h,
- (void*) intelfb);
- if (!intelfb->stfb) {
- free(intelfb);
- return GL_FALSE;
- }
-
- driDrawPriv->driverPrivate = (void *) intelfb;
- return GL_TRUE;
- }
-}
-
-static void
-intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- struct intel_framebuffer *intelfb = intel_framebuffer(driDrawPriv);
- assert(intelfb->stfb);
- st_unreference_framebuffer(intelfb->stfb);
- free(intelfb);
-}
-
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
-{
- if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
- || (sInfo == NULL)) {
- return -1;
- }
-
- return 0;
-}
-
-static __DRIconfig **
-intelFillInModes(__DRIscreenPrivate *psp,
- unsigned pixel_bits, unsigned depth_bits,
- unsigned stencil_bits, GLboolean have_back_buffer)
-{
- __DRIconfig **configs;
- __GLcontextModes *m;
- unsigned num_modes;
- unsigned depth_buffer_factor;
- unsigned back_buffer_factor;
- GLenum fb_format;
- GLenum fb_type;
- int i;
-
- /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
- * support pageflipping at all.
- */
- static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
- };
-
- uint8_t depth_bits_array[3];
- uint8_t stencil_bits_array[3];
- uint8_t msaa_samples_array[1];
-
-
- depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
- msaa_samples_array[0] = 0;
-
- /* Just like with the accumulation buffer, always provide some modes
- * with a stencil buffer. It will be a sw fallback, but some apps won't
- * care about that.
- */
- stencil_bits_array[0] = 0;
- stencil_bits_array[1] = 0;
- if (depth_bits == 24)
- stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
- back_buffer_factor = (have_back_buffer) ? 3 : 1;
-
- num_modes = depth_buffer_factor * back_buffer_factor * 4;
-
- if (pixel_bits == 16) {
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_SHORT_5_6_5;
- }
- else {
- fb_format = GL_BGRA;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- configs = driCreateConfigs(fb_format, fb_type,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor, msaa_samples_array, 1);
- if (configs == NULL) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
- __LINE__);
- return NULL;
- }
-
- /* Mark the visual as slow if there are "fake" stencil bits.
- */
- for (i = 0; configs[i]; i++) {
- m = &configs[i]->modes;
- if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
- m->visualRating = GLX_SLOW_CONFIG;
- }
- }
-
- return configs;
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
- *
- * \todo maybe fold this into intelInitDriver
- *
- * \return the __GLcontextModes supported by this driver
- */
-static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
-{
-#ifdef I915
- static const __DRIversion ddx_expected = { 1, 5, 0 };
-#else
- static const __DRIversion ddx_expected = { 1, 6, 0 };
-#endif
- static const __DRIversion dri_expected = { 4, 0, 0 };
- static const __DRIversion drm_expected = { 1, 5, 0 };
- I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
-
- if (!driCheckDriDdxDrmVersions2("i915",
- &psp->dri_version, &dri_expected,
- &psp->ddx_version, &ddx_expected,
- &psp->drm_version, &drm_expected)) {
- return NULL;
- }
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- driInitExtensions( NULL, card_extensions, GL_FALSE );
- //intelInitExtensions(NULL, GL_TRUE);
-
- if (!intelInitDriver(psp))
- return NULL;
-
- psp->extensions = intelScreenExtensions;
-
- return (const __DRIconfig **)
- intelFillInModes(psp, dri_priv->cpp * 8,
- (dri_priv->cpp == 2) ? 16 : 24,
- (dri_priv->cpp == 2) ? 0 : 8, 1);
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
- *
- * \return the __GLcontextModes supported by this driver
- */
-static const
-__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
-{
- struct intel_screen *intelScreen;
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- //intelInitExtensions(NULL, GL_TRUE);
-
- /* Allocate the private area */
- intelScreen = CALLOC_STRUCT(intel_screen);
- if (!intelScreen) {
- fprintf(stderr, "\nERROR! Allocating private area failed\n");
- return GL_FALSE;
- }
- /* parse information in __driConfigOptions */
- driParseOptionInfo(&intelScreen->optionCache,
- __driConfigOptions, __driNConfigOptions);
-
- psp->private = (void *) intelScreen;
-
- intelScreen->drmMinor = psp->drm_version.minor;
-
- /* Determine chipset ID? */
- if (!intel_get_param(psp, I915_PARAM_CHIPSET_ID,
- &intelScreen->deviceID))
- return GL_FALSE;
-
- psp->extensions = intelScreenExtensions;
-
- intel_be_init_device(&intelScreen->base, psp->fd, intelScreen->deviceID);
- intelScreen->base.base.flush_frontbuffer = intel_flush_frontbuffer;
- intelScreen->base.base.get_name = intel_get_name;
-
- return driConcatConfigs(intelFillInModes(psp, 16, 16, 0, 1),
- intelFillInModes(psp, 32, 24, 8, 1));
-}
-
-const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = intelInitScreen,
- .DestroyScreen = intelDestroyScreen,
- .CreateContext = intelCreateContext,
- .DestroyContext = intelDestroyContext,
- .CreateBuffer = intelCreateBuffer,
- .DestroyBuffer = intelDestroyBuffer,
- .SwapBuffers = intelSwapBuffers,
- .MakeCurrent = intelMakeCurrent,
- .UnbindContext = intelUnbindContext,
- .GetSwapInfo = intelGetSwapInfo,
- .GetDrawableMSC = driDrawableGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .CopySubBuffer = intelCopySubBuffer,
-
- //.InitScreen2 = intelInitScreen2,
- //.HandleDrawableConfig = intelHandleDrawableConfig,
- //.HandleBufferAttach = intelHandleBufferAttach,
-};
diff --git a/src/gallium/winsys/drm/intel/dri/intel_screen.h b/src/gallium/winsys/drm/intel/dri/intel_screen.h
deleted file mode 100644
index 0bb43a915c..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_screen.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef _INTEL_SCREEN_H_
-#define _INTEL_SCREEN_H_
-
-#include "dri_util.h"
-#include "i830_common.h"
-#include "xmlconfig.h"
-#include "ws_dri_bufpool.h"
-
-#include "pipe/p_compiler.h"
-
-#include "intel_be_device.h"
-
-struct intel_screen
-{
- struct intel_be_device base;
-
- struct {
- drm_handle_t handle;
-
- /* We create a static dri buffer for the frontbuffer.
- */
- struct _DriBufferObject *buffer;
- struct pipe_surface *surface;
- struct pipe_texture *texture;
-
- char *map; /* memory map */
- int offset; /* from start of video mem, in bytes */
- int pitch; /* row stride, in bytes */
- int width;
- int height;
- int size;
- int cpp; /* for front and back buffers */
- } front;
-
- int deviceID;
- int drmMinor;
-
- drmI830Sarea *sarea;
-
- /**
- * Configuration cache with default values for all contexts
- */
- driOptionCache optionCache;
-
- boolean havePools;
-
- /**
- * Temporary(?) context to use for SwapBuffers or other situations in
- * which we need a rendering context, but none is currently bound.
- */
- struct intel_context *dummyContext;
-
- /*
- * New stuff form the i915tex integration
- */
- unsigned batch_id;
-
-
- struct pipe_winsys *winsys;
-};
-
-
-
-/** cast wrapper */
-static INLINE struct intel_screen *
-intel_screen(__DRIscreenPrivate *sPriv)
-{
- return (struct intel_screen *) sPriv->private;
-}
-
-
-extern void
-intelUpdateScreenRotation(__DRIscreenPrivate * sPriv, drmI830Sarea * sarea);
-
-
-extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
-
-extern boolean intelUnbindContext(__DRIcontextPrivate * driContextPriv);
-
-extern boolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv);
-
-
-extern boolean
-intelCreatePools(__DRIscreenPrivate *sPriv);
-
-extern boolean
-intelCreateContext(const __GLcontextModes * visual,
- __DRIcontextPrivate * driContextPriv,
- void *sharedContextPrivate);
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
deleted file mode 100644
index 34ad7eebe1..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "intel_screen.h"
-#include "intel_context.h"
-#include "intel_swapbuffers.h"
-
-#include "intel_reg.h"
-
-#include "pipe/p_context.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "state_tracker/st_cb_fbo.h"
-
-#include "ws_dri_bufmgr.h"
-#include "intel_batchbuffer.h"
-
-/**
- * Display a colorbuffer surface in an X window.
- * Used for SwapBuffers and flushing front buffer rendering.
- *
- * \param dPriv the window/drawable to display into
- * \param surf the surface to display
- * \param rect optional subrect of surface to display (may be NULL).
- */
-void
-intelDisplaySurface(__DRIdrawablePrivate *dPriv,
- struct pipe_surface *surf,
- const drm_clip_rect_t *rect)
-{
- struct intel_screen *intelScreen = intel_screen(dPriv->driScreenPriv);
- struct intel_context *intel = intelScreen->dummyContext;
-
- DBG(SWAP, "%s\n", __FUNCTION__);
-
- if (!intel) {
- /* XXX this is where some kind of extra/meta context could be useful */
- return;
- }
-
- if (intel->last_swap_fence) {
- driFenceFinish(intel->last_swap_fence, DRM_FENCE_TYPE_EXE, TRUE);
- driFenceUnReference(&intel->last_swap_fence);
- intel->last_swap_fence = NULL;
- }
- intel->last_swap_fence = intel->first_swap_fence;
- intel->first_swap_fence = NULL;
-
- /* The LOCK_HARDWARE is required for the cliprects. Buffer offsets
- * should work regardless.
- */
- LOCK_HARDWARE(intel);
- /* if this drawable isn't currently bound the LOCK_HARDWARE done on the
- * current context (which is what intelScreenContext should return) might
- * not get a contended lock and thus cliprects not updated (tests/manywin)
- */
- if (intel_context(dPriv->driContextPriv) != intel)
- DRI_VALIDATE_DRAWABLE_INFO(intel->driScreen, dPriv);
-
-
- if (dPriv && dPriv->numClipRects) {
- const int srcWidth = surf->width;
- const int srcHeight = surf->height;
- const int nbox = dPriv->numClipRects;
- const drm_clip_rect_t *pbox = dPriv->pClipRects;
- const int pitch = intelScreen->front.pitch / intelScreen->front.cpp;
- const int cpp = intelScreen->front.cpp;
- const int srcpitch = surf->stride / cpp;
- int BR13, CMD;
- int i;
-
- ASSERT(surf->buffer);
-
- DBG(SWAP, "screen pitch %d src surface pitch %d\n",
- pitch, surf->stride);
-
- if (cpp == 2) {
- BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24);
- CMD = XY_SRC_COPY_BLT_CMD;
- }
- else {
- BR13 = (pitch * cpp) | (0xCC << 16) | (1 << 24) | (1 << 25);
- CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB);
- }
-
- for (i = 0; i < nbox; i++, pbox++) {
- drm_clip_rect_t box;
- drm_clip_rect_t sbox;
-
- if (pbox->x1 > pbox->x2 ||
- pbox->y1 > pbox->y2 ||
- pbox->x2 > intelScreen->front.width ||
- pbox->y2 > intelScreen->front.height) {
- /* invalid cliprect, skip it */
- continue;
- }
-
- box = *pbox;
-
- if (rect) {
- /* intersect cliprect with user-provided src rect */
- drm_clip_rect_t rrect;
-
- rrect.x1 = dPriv->x + rect->x1;
- rrect.y1 = (dPriv->h - rect->y1 - rect->y2) + dPriv->y;
- rrect.x2 = rect->x2 + rrect.x1;
- rrect.y2 = rect->y2 + rrect.y1;
- if (rrect.x1 > box.x1)
- box.x1 = rrect.x1;
- if (rrect.y1 > box.y1)
- box.y1 = rrect.y1;
- if (rrect.x2 < box.x2)
- box.x2 = rrect.x2;
- if (rrect.y2 < box.y2)
- box.y2 = rrect.y2;
-
- if (box.x1 > box.x2 || box.y1 > box.y2)
- continue;
- }
-
- /* restrict blit to size of actually rendered area */
- if (box.x2 - box.x1 > srcWidth)
- box.x2 = srcWidth + box.x1;
- if (box.y2 - box.y1 > srcHeight)
- box.y2 = srcHeight + box.y1;
-
- DBG(SWAP, "box x1 x2 y1 y2 %d %d %d %d\n",
- box.x1, box.x2, box.y1, box.y2);
-
- sbox.x1 = box.x1 - dPriv->x;
- sbox.y1 = box.y1 - dPriv->y;
-
- assert(box.x1 < box.x2);
- assert(box.y1 < box.y2);
-
- /* XXX this could be done with pipe->surface_copy() */
- /* XXX should have its own batch buffer */
- if (!BEGIN_BATCH(8, 2)) {
- /*
- * Since we share this batch buffer with a context
- * we can't flush it since that risks a GPU lockup
- */
- assert(0);
- continue;
- }
-
- OUT_BATCH(CMD);
- OUT_BATCH(BR13);
- OUT_BATCH((box.y1 << 16) | box.x1);
- OUT_BATCH((box.y2 << 16) | box.x2);
-
- OUT_RELOC(intelScreen->front.buffer,
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
- OUT_BATCH((sbox.y1 << 16) | sbox.x1);
- OUT_BATCH((srcpitch * cpp) & 0xffff);
- OUT_RELOC(dri_bo(surf->buffer),
- DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
- DRM_BO_MASK_MEM | DRM_BO_FLAG_READ, 0);
-
- }
-
- if (intel->first_swap_fence)
- driFenceUnReference(&intel->first_swap_fence);
- intel->first_swap_fence = intel_be_batchbuffer_flush(intel->base.batch);
- }
-
- UNLOCK_HARDWARE(intel);
-
- if (intel->lastStamp != dPriv->lastStamp) {
- intelUpdateWindowSize(dPriv);
- intel->lastStamp = dPriv->lastStamp;
- }
-}
-
-
-
-/**
- * This will be called whenever the currently bound window is moved/resized.
- */
-void
-intelUpdateWindowSize(__DRIdrawablePrivate *dPriv)
-{
- struct intel_framebuffer *intelfb = intel_framebuffer(dPriv);
- assert(intelfb->stfb);
- st_resize_framebuffer(intelfb->stfb, dPriv->w, dPriv->h);
-}
-
-
-
-void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
- struct intel_framebuffer *intel_fb = intel_framebuffer(dPriv);
- struct pipe_surface *back_surf;
-
- assert(intel_fb);
- assert(intel_fb->stfb);
-
- back_surf = st_get_framebuffer_surface(intel_fb->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- st_notify_swapbuffers(intel_fb->stfb);
- intelDisplaySurface(dPriv, back_surf, NULL);
- st_notify_swapbuffers_complete(intel_fb->stfb);
- }
-}
-
-
-/**
- * Called via glXCopySubBufferMESA() to copy a subrect of the back
- * buffer to the front buffer/screen.
- */
-void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
-{
- struct intel_framebuffer *intel_fb = intel_framebuffer(dPriv);
- struct pipe_surface *back_surf;
-
- assert(intel_fb);
- assert(intel_fb->stfb);
-
- back_surf = st_get_framebuffer_surface(intel_fb->stfb,
- ST_SURFACE_BACK_LEFT);
- if (back_surf) {
- drm_clip_rect_t rect;
- rect.x1 = x;
- rect.y1 = y;
- rect.x2 = w;
- rect.y2 = h;
-
- st_notify_swapbuffers(intel_fb->stfb);
- intelDisplaySurface(dPriv, back_surf, &rect);
- }
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h b/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h
deleted file mode 100644
index 46c9bab3af..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_swapbuffers.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_SWAPBUFFERS_H
-#define INTEL_SWAPBUFFERS_H
-
-
-struct pipe_surface;
-
-
-extern void intelDisplaySurface(__DRIdrawablePrivate * dPriv,
- struct pipe_surface *surf,
- const drm_clip_rect_t * rect);
-
-extern void intelSwapBuffers(__DRIdrawablePrivate * dPriv);
-
-extern void intelCopySubBuffer(__DRIdrawablePrivate * dPriv,
- int x, int y, int w, int h);
-
-extern void intelUpdateWindowSize(__DRIdrawablePrivate *dPriv);
-
-
-#endif /* INTEL_SWAPBUFFERS_H */
diff --git a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c
deleted file mode 100644
index 20920a2052..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "intel_context.h"
-#include "intel_winsys_softpipe.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
-#include "util/u_memory.h"
-#include "softpipe/sp_winsys.h"
-
-
-struct intel_softpipe_winsys {
- struct softpipe_winsys sws;
- struct intel_context *intel;
-};
-
-/**
- * Return list of surface formats supported by this driver.
- */
-static boolean
-intel_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- switch(format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-
-/**
- * Create rendering context which uses software rendering.
- */
-struct pipe_context *
-intel_create_softpipe( struct intel_context *intel,
- struct pipe_winsys *winsys )
-{
- struct intel_softpipe_winsys *isws = CALLOC_STRUCT( intel_softpipe_winsys );
- struct pipe_screen *screen = softpipe_create_screen(winsys);
-
- /* Fill in this struct with callbacks that softpipe will need to
- * communicate with the window system, buffer manager, etc.
- */
- isws->sws.is_format_supported = intel_is_format_supported;
- isws->intel = intel;
-
- /* Create the softpipe context:
- */
- return softpipe_create( screen, winsys, &isws->sws );
-}
diff --git a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h b/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h
deleted file mode 100644
index 5fa14cb749..0000000000
--- a/src/gallium/winsys/drm/intel/dri/intel_winsys_softpipe.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef INTEL_SOFTPIPE_H
-#define INTEL_SOFTPIPE_H
-
-struct pipe_winsys;
-struct pipe_context;
-struct intel_context;
-
-struct pipe_context *
-intel_create_softpipe( struct intel_context *intel,
- struct pipe_winsys *winsys );
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri/server/i830_common.h b/src/gallium/winsys/drm/intel/dri/server/i830_common.h
deleted file mode 100644
index 3452ddb3c9..0000000000
--- a/src/gallium/winsys/drm/intel/dri/server/i830_common.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/**************************************************************************
-
-Copyright 2001 VA Linux Systems Inc., Fremont, California.
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, VA LINUX SYSTEMS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-
-#ifndef _I830_COMMON_H_
-#define _I830_COMMON_H_
-
-
-#define I830_NR_TEX_REGIONS 255 /* maximum due to use of chars for next/prev */
-#define I830_LOG_MIN_TEX_REGION_SIZE 14
-
-
-/* Driver specific DRM command indices
- * NOTE: these are not OS specific, but they are driver specific
- */
-#define DRM_I830_INIT 0x00
-#define DRM_I830_FLUSH 0x01
-#define DRM_I830_FLIP 0x02
-#define DRM_I830_BATCHBUFFER 0x03
-#define DRM_I830_IRQ_EMIT 0x04
-#define DRM_I830_IRQ_WAIT 0x05
-#define DRM_I830_GETPARAM 0x06
-#define DRM_I830_SETPARAM 0x07
-#define DRM_I830_ALLOC 0x08
-#define DRM_I830_FREE 0x09
-#define DRM_I830_INIT_HEAP 0x0a
-#define DRM_I830_CMDBUFFER 0x0b
-#define DRM_I830_DESTROY_HEAP 0x0c
-#define DRM_I830_SET_VBLANK_PIPE 0x0d
-#define DRM_I830_GET_VBLANK_PIPE 0x0e
-#define DRM_I830_MMIO 0x10
-
-typedef struct {
- enum {
- I830_INIT_DMA = 0x01,
- I830_CLEANUP_DMA = 0x02,
- I830_RESUME_DMA = 0x03
- } func;
- unsigned int mmio_offset;
- int sarea_priv_offset;
- unsigned int ring_start;
- unsigned int ring_end;
- unsigned int ring_size;
- unsigned int front_offset;
- unsigned int back_offset;
- unsigned int depth_offset;
- unsigned int w;
- unsigned int h;
- unsigned int pitch;
- unsigned int pitch_bits;
- unsigned int back_pitch;
- unsigned int depth_pitch;
- unsigned int cpp;
- unsigned int chipset;
-} drmI830Init;
-
-typedef struct {
- drmTextureRegion texList[I830_NR_TEX_REGIONS+1];
- int last_upload; /* last time texture was uploaded */
- int last_enqueue; /* last time a buffer was enqueued */
- int last_dispatch; /* age of the most recently dispatched buffer */
- int ctxOwner; /* last context to upload state */
- /** Last context that used the buffer manager. */
- int texAge;
- int pf_enabled; /* is pageflipping allowed? */
- int pf_active;
- int pf_current_page; /* which buffer is being displayed? */
- int perf_boxes; /* performance boxes to be displayed */
- int width, height; /* screen size in pixels */
-
- drm_handle_t front_handle;
- int front_offset;
- int front_size;
-
- drm_handle_t back_handle;
- int back_offset;
- int back_size;
-
- drm_handle_t depth_handle;
- int depth_offset;
- int depth_size;
-
- drm_handle_t tex_handle;
- int tex_offset;
- int tex_size;
- int log_tex_granularity;
- int pitch;
- int rotation; /* 0, 90, 180 or 270 */
- int rotated_offset;
- int rotated_size;
- int rotated_pitch;
- int virtualX, virtualY;
-
- unsigned int front_tiled;
- unsigned int back_tiled;
- unsigned int depth_tiled;
- unsigned int rotated_tiled;
- unsigned int rotated2_tiled;
-
- int planeA_x;
- int planeA_y;
- int planeA_w;
- int planeA_h;
- int planeB_x;
- int planeB_y;
- int planeB_w;
- int planeB_h;
-
- /* Triple buffering */
- drm_handle_t third_handle;
- int third_offset;
- int third_size;
- unsigned int third_tiled;
-
- /* buffer object handles for the static buffers. May change
- * over the lifetime of the client, though it doesn't in our current
- * implementation.
- */
- unsigned int front_bo_handle;
- unsigned int back_bo_handle;
- unsigned int third_bo_handle;
- unsigned int depth_bo_handle;
-} drmI830Sarea;
-
-/* Flags for perf_boxes
- */
-#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
-#define I830_BOX_FLIP 0x2 /* populated by kernel */
-#define I830_BOX_WAIT 0x4 /* populated by kernel & client */
-#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
-#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
-
-
-typedef struct {
- int start; /* agp offset */
- int used; /* nr bytes in use */
- int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
- int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
- int num_cliprects; /* mulitpass with multiple cliprects? */
- drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
-} drmI830BatchBuffer;
-
-typedef struct {
- char *buf; /* agp offset */
- int sz; /* nr bytes in use */
- int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
- int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
- int num_cliprects; /* mulitpass with multiple cliprects? */
- drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
-} drmI830CmdBuffer;
-
-typedef struct {
- int *irq_seq;
-} drmI830IrqEmit;
-
-typedef struct {
- int irq_seq;
-} drmI830IrqWait;
-
-typedef struct {
- int param;
- int *value;
-} drmI830GetParam;
-
-#define I830_PARAM_IRQ_ACTIVE 1
-#define I830_PARAM_ALLOW_BATCHBUFFER 2
-
-typedef struct {
- int param;
- int value;
-} drmI830SetParam;
-
-#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
-#define I830_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
-#define I830_SETPARAM_ALLOW_BATCHBUFFER 3
-
-
-/* A memory manager for regions of shared memory:
- */
-#define I830_MEM_REGION_AGP 1
-
-typedef struct {
- int region;
- int alignment;
- int size;
- int *region_offset; /* offset from start of fb or agp */
-} drmI830MemAlloc;
-
-typedef struct {
- int region;
- int region_offset;
-} drmI830MemFree;
-
-typedef struct {
- int region;
- int size;
- int start;
-} drmI830MemInitHeap;
-
-typedef struct {
- int region;
-} drmI830MemDestroyHeap;
-
-#define DRM_I830_VBLANK_PIPE_A 1
-#define DRM_I830_VBLANK_PIPE_B 2
-
-typedef struct {
- int pipe;
-} drmI830VBlankPipe;
-
-#define MMIO_READ 0
-#define MMIO_WRITE 1
-
-#define MMIO_REGS_IA_PRIMATIVES_COUNT 0
-#define MMIO_REGS_IA_VERTICES_COUNT 1
-#define MMIO_REGS_VS_INVOCATION_COUNT 2
-#define MMIO_REGS_GS_PRIMITIVES_COUNT 3
-#define MMIO_REGS_GS_INVOCATION_COUNT 4
-#define MMIO_REGS_CL_PRIMITIVES_COUNT 5
-#define MMIO_REGS_CL_INVOCATION_COUNT 6
-#define MMIO_REGS_PS_INVOCATION_COUNT 7
-#define MMIO_REGS_PS_DEPTH_COUNT 8
-
-typedef struct {
- unsigned int read_write:1;
- unsigned int reg:31;
- void __user *data;
-} drmI830MMIO;
-
-#endif /* _I830_DRM_H_ */
diff --git a/src/gallium/winsys/drm/intel/dri/server/i830_dri.h b/src/gallium/winsys/drm/intel/dri/server/i830_dri.h
deleted file mode 100644
index 0d514b6c38..0000000000
--- a/src/gallium/winsys/drm/intel/dri/server/i830_dri.h
+++ /dev/null
@@ -1,62 +0,0 @@
-
-#ifndef _I830_DRI_H
-#define _I830_DRI_H
-
-#include "xf86drm.h"
-#include "i830_common.h"
-
-#define I830_MAX_DRAWABLES 256
-
-#define I830_MAJOR_VERSION 1
-#define I830_MINOR_VERSION 7
-#define I830_PATCHLEVEL 2
-
-#define I830_REG_SIZE 0x80000
-
-typedef struct _I830DRIRec {
- drm_handle_t regs;
- drmSize regsSize;
-
- drmSize unused1; /* backbufferSize */
- drm_handle_t unused2; /* backbuffer */
-
- drmSize unused3; /* depthbufferSize */
- drm_handle_t unused4; /* depthbuffer */
-
- drmSize unused5; /* rotatedSize */
- drm_handle_t unused6; /* rotatedbuffer */
-
- drm_handle_t unused7; /* textures */
- int unused8; /* textureSize */
-
- drm_handle_t unused9; /* agp_buffers */
- drmSize unused10; /* agp_buf_size */
-
- int deviceID;
- int width;
- int height;
- int mem;
- int cpp;
- int bitsPerPixel;
-
- int unused11[8]; /* was front/back/depth/rotated offset/pitch */
-
- int unused12; /* logTextureGranularity */
- int unused13; /* textureOffset */
-
- int irq;
- int sarea_priv_offset;
-} I830DRIRec, *I830DRIPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} I830ConfigPrivRec, *I830ConfigPrivPtr;
-
-typedef struct {
- /* Nothing here yet */
- int dummy;
-} I830DRIContextRec, *I830DRIContextPtr;
-
-
-#endif
diff --git a/src/gallium/winsys/drm/intel/dri2/Makefile b/src/gallium/winsys/drm/intel/dri2/Makefile
new file mode 100644
index 0000000000..1a02109274
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/dri2/Makefile
@@ -0,0 +1,22 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i915_dri.so
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
+ $(TOP)/src/gallium/winsys/drm/intel/gem/libinteldrm.a \
+ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
+
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += -ldrm_intel
+
+symlinks:
diff --git a/src/gallium/winsys/drm/intel/egl/Makefile b/src/gallium/winsys/drm/intel/egl/Makefile
index 7147d89e0d..c5217ad2d6 100644
--- a/src/gallium/winsys/drm/intel/egl/Makefile
+++ b/src/gallium/winsys/drm/intel/egl/Makefile
@@ -1,19 +1,16 @@
TOP = ../../../../../..
+GALLIUMDIR = ../../../..
include $(TOP)/configs/current
LIBNAME = EGL_i915.so
PIPE_DRIVERS = \
- ../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)/winsys/drm/intel/gem/libinteldrm.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a
-
-DRIVER_SOURCES = \
- intel_context.c \
- intel_device.c \
- intel_api.c
+DRIVER_SOURCES =
C_SOURCES = \
$(COMMON_GALLIUM_SOURCES) \
diff --git a/src/gallium/winsys/drm/intel/egl/intel_api.c b/src/gallium/winsys/drm/intel/egl/intel_api.c
deleted file mode 100644
index 5dc4a7b052..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_api.c
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#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/egl/intel_api.h b/src/gallium/winsys/drm/intel/egl/intel_api.h
deleted file mode 100644
index 8ec165ab01..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_api.h
+++ /dev/null
@@ -1,14 +0,0 @@
-
-#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/egl/intel_context.c b/src/gallium/winsys/drm/intel/egl/intel_context.c
deleted file mode 100644
index 57e5ff7bc1..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_context.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-#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/egl/intel_device.c b/src/gallium/winsys/drm/intel/egl/intel_device.c
deleted file mode 100644
index 6b281402d5..0000000000
--- a/src/gallium/winsys/drm/intel/egl/intel_device.c
+++ /dev/null
@@ -1,48 +0,0 @@
-
-#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);
-}
-
-struct pipe_screen *
-intel_create_screen(int drmFD, int deviceID)
-{
- struct intel_device *dev;
- struct pipe_screen *screen;
-
- /* 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;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/Makefile b/src/gallium/winsys/drm/intel/gem/Makefile
index b25fc258f4..7ab1a2a771 100644
--- a/src/gallium/winsys/drm/intel/gem/Makefile
+++ b/src/gallium/winsys/drm/intel/gem/Makefile
@@ -6,13 +6,11 @@ LIBNAME = inteldrm
C_SOURCES = \
intel_be_batchbuffer.c \
intel_be_context.c \
- intel_be_device.c
+ intel_be_device.c \
+ intel_be_api.c
+LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
-include ./Makefile.template
-
-DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
- && pkg-config libdrm --atleast-version=2.3.1 \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-symlinks:
+LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/intel/gem/Makefile.template b/src/gallium/winsys/drm/intel/gem/Makefile.template
deleted file mode 100644
index b60e978894..0000000000
--- a/src/gallium/winsys/drm/intel/gem/Makefile.template
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*-makefile-*-
-
-
-# We still have a dependency on the "dri" buffer manager. Most likely
-# the interface can be reused in non-dri environments, and also as a
-# frontend to simpler memory managers.
-#
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks lib$(LIBNAME).a
-
-
-lib$(LIBNAME).a: $(OBJECTS) Makefile Makefile.template
- $(TOP)/bin/mklib -o $(LIBNAME) -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *.a *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.c b/src/gallium/winsys/drm/intel/gem/intel_be_api.c
new file mode 100644
index 0000000000..f4ef7c2d88
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.c
@@ -0,0 +1,15 @@
+
+#include "intel_be_api.h"
+#include "i915simple/i915_winsys.h"
+
+struct drm_api drm_api_hooks =
+{
+ /* intel_be_context.c */
+ .create_context = intel_be_create_context,
+ /* intel_be_device.c */
+ .create_screen = intel_be_create_screen,
+ .buffer_from_texture = i915_get_texture_buffer,
+ .buffer_from_handle = intel_be_buffer_from_handle,
+ .handle_from_buffer = intel_be_handle_from_buffer,
+ .global_handle_from_buffer = intel_be_global_handle_from_buffer,
+};
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_api.h b/src/gallium/winsys/drm/intel/gem/intel_be_api.h
new file mode 100644
index 0000000000..73e458d4ba
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_api.h
@@ -0,0 +1,14 @@
+
+#ifndef _INTEL_BE_API_H_
+#define _INTEL_BE_API_H_
+
+#include "pipe/p_compiler.h"
+
+#include "state_tracker/drm_api.h"
+
+#include "intel_be_device.h"
+
+struct pipe_screen *intel_be_create_screen(int drmFD, int pciID);
+struct pipe_context *intel_be_create_context(struct pipe_screen *screen);
+
+#endif
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c b/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
index d9556e1f38..d5e63c3bae 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_batchbuffer.c
@@ -21,7 +21,7 @@ intel_be_batchbuffer_alloc(struct intel_be_context *intel)
batch->base.size = 0;
batch->base.actual_size = intel->device->max_batch_size;
batch->base.relocs = 0;
- batch->base.max_relocs = INTEL_DEFAULT_RELOCS;
+ batch->base.max_relocs = 500;/*INTEL_DEFAULT_RELOCS;*/
batch->base.map = malloc(batch->base.actual_size);
memset(batch->base.map, 0, batch->base.actual_size);
@@ -47,7 +47,6 @@ intel_be_batchbuffer_reset(struct intel_be_batchbuffer *batch)
batch->base.size = batch->base.actual_size - BATCH_RESERVED;
batch->base.relocs = 0;
- batch->base.max_relocs = INTEL_DEFAULT_RELOCS;
batch->bo = drm_intel_bo_alloc(dev->pools.gem,
"gallium3d_batch_buffer",
@@ -115,10 +114,10 @@ intel_be_batchbuffer_flush(struct intel_be_batchbuffer *batch,
if (fence) {
if (*fence)
- intel_be_fence_unreference(*fence);
+ intel_be_fence_reference(fence, NULL);
(*fence) = CALLOC_STRUCT(intel_be_fence);
- (*fence)->refcount = 1;
+ pipe_reference_init(&(*fence)->reference, 1);
(*fence)->bo = NULL;
}
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.c b/src/gallium/winsys/drm/intel/gem/intel_be_context.c
index 95e761d78d..bb6f1b916c 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_context.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.c
@@ -1,10 +1,14 @@
+#include "pipe/p_screen.h"
+
#include "intel_be_device.h"
#include "intel_be_context.h"
#include "intel_be_batchbuffer.h"
#include "i915_drm.h"
+#include "intel_be_api.h"
+
static struct i915_batchbuffer *
intel_be_batch_get(struct i915_winsys *sws)
{
@@ -57,6 +61,21 @@ intel_be_batch_flush(struct i915_winsys *sws,
intel_be_batchbuffer_flush(intel->batch, f);
}
+
+/*
+ * Misc functions.
+ */
+
+static void
+intel_be_destroy_context(struct i915_winsys *winsys)
+{
+ struct intel_be_context *intel = intel_be_context(winsys);
+
+ intel_be_batchbuffer_free(intel->batch);
+
+ free(intel);
+}
+
boolean
intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *device)
{
@@ -68,13 +87,32 @@ intel_be_init_context(struct intel_be_context *intel, struct intel_be_device *de
intel->base.batch_reloc = intel_be_batch_reloc;
intel->base.batch_flush = intel_be_batch_flush;
+ intel->base.destroy = intel_be_destroy_context;
+
intel->batch = intel_be_batchbuffer_alloc(intel);
return true;
}
-void
-intel_be_destroy_context(struct intel_be_context *intel)
+struct pipe_context *
+intel_be_create_context(struct pipe_screen *screen)
{
- intel_be_batchbuffer_free(intel->batch);
+ struct intel_be_context *intel;
+ struct pipe_context *pipe;
+ struct intel_be_device *device = intel_be_device(screen->winsys);
+
+ intel = (struct intel_be_context *)malloc(sizeof(*intel));
+ memset(intel, 0, sizeof(*intel));
+
+ intel_be_init_context(intel, device);
+
+#if 0
+ pipe = intel_create_softpipe(intel, screen->winsys);
+#else
+ pipe = i915_create_context(screen, &device->base, &intel->base);
+#endif
+
+ pipe->priv = intel;
+
+ return pipe;
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_context.h b/src/gallium/winsys/drm/intel/gem/intel_be_context.h
index 9cee1a4e52..5a369669c0 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_context.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_context.h
@@ -11,15 +11,6 @@ struct intel_be_context
struct intel_be_device *device;
struct intel_be_batchbuffer *batch;
-
- /*
- * Hardware lock functions.
- *
- * Needs to be filled in by the winsys.
- */
- void (*hardware_lock)(struct intel_be_context *context);
- void (*hardware_unlock)(struct intel_be_context *context);
- boolean (*hardware_locked)(struct intel_be_context *context);
};
static INLINE struct intel_be_context *
@@ -37,12 +28,4 @@ boolean
intel_be_init_context(struct intel_be_context *intel,
struct intel_be_device *device);
-/**
- * Destroy a intel_be_context.
- *
- * Does not free the struct that is up to the winsys.
- */
-void
-intel_be_destroy_context(struct intel_be_context *intel);
-
#endif
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.c b/src/gallium/winsys/drm/intel/gem/intel_be_device.c
index 82c1cb2f32..0f6300323b 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_device.c
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.c
@@ -9,17 +9,9 @@
#include "intel_be_fence.h"
-#include "i915simple/i915_screen.h"
+#include "i915simple/i915_winsys.h"
-
-/**
- * Turn a pipe winsys into an intel/pipe winsys:
- */
-static INLINE struct intel_be_device *
-intel_be_device(struct pipe_winsys *winsys)
-{
- return (struct intel_be_device *)winsys;
-}
+#include "intel_be_api.h"
/*
* Buffer
@@ -34,6 +26,12 @@ intel_be_buffer_map(struct pipe_winsys *winsys,
int write = 0;
int ret;
+ if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ /* Remove this when drm_intel_bo_map supports DONTBLOCK
+ */
+ return NULL;
+ }
+
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
write = 1;
@@ -53,8 +51,7 @@ intel_be_buffer_unmap(struct pipe_winsys *winsys,
}
static void
-intel_be_buffer_destroy(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+intel_be_buffer_destroy(struct pipe_buffer *buf)
{
drm_intel_bo_unreference(intel_bo(buf));
free(buf);
@@ -74,10 +71,12 @@ intel_be_buffer_create(struct pipe_winsys *winsys,
if (!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = alignment;
buffer->base.usage = usage;
buffer->base.size = size;
+ buffer->flinked = FALSE;
+ buffer->flink = 0;
if (usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_CONSTANT)) {
/* Local buffer */
@@ -115,7 +114,7 @@ intel_be_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned byte
if (!buffer)
return NULL;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
buffer->base.alignment = 0;
buffer->base.usage = 0;
buffer->base.size = bytes;
@@ -141,10 +140,10 @@ err:
}
struct pipe_buffer *
-intel_be_buffer_from_handle(struct pipe_winsys *winsys,
+intel_be_buffer_from_handle(struct pipe_screen *screen,
const char* name, unsigned handle)
{
- struct intel_be_device *dev = intel_be_device(winsys);
+ struct intel_be_device *dev = intel_be_device(screen->winsys);
struct intel_be_buffer *buffer = CALLOC_STRUCT(intel_be_buffer);
if (!buffer)
@@ -155,7 +154,8 @@ intel_be_buffer_from_handle(struct pipe_winsys *winsys,
if (!buffer->bo)
goto err;
- buffer->base.refcount = 1;
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = screen;
buffer->base.alignment = buffer->bo->align;
buffer->base.usage = PIPE_BUFFER_USAGE_GPU_READ |
PIPE_BUFFER_USAGE_GPU_WRITE |
@@ -170,14 +170,39 @@ err:
return NULL;
}
-unsigned
-intel_be_handle_from_buffer(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
+boolean
+intel_be_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle)
{
- drm_intel_bo *bo = intel_bo(buf);
- return bo->handle;
+ drm_intel_bo *bo;
+
+ if (!buffer)
+ return FALSE;
+
+ *handle = intel_bo(buffer)->handle;
+ return TRUE;
}
+boolean
+intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle)
+{
+ struct intel_be_buffer *buf = intel_be_buffer(buffer);
+
+ if (!buffer)
+ return FALSE;
+
+ if (!buf->flinked) {
+ if (drm_intel_bo_flink(intel_bo(buffer), &buf->flink))
+ return FALSE;
+ buf->flinked = TRUE;
+ }
+
+ *handle = buf->flink;
+ return TRUE;
+}
/*
* Fence
*/
@@ -190,15 +215,7 @@ intel_be_fence_refunref(struct pipe_winsys *sws,
struct intel_be_fence **p = (struct intel_be_fence **)ptr;
struct intel_be_fence *f = (struct intel_be_fence *)fence;
- assert(p);
-
- if (f)
- intel_be_fence_reference(f);
-
- if (*p)
- intel_be_fence_unreference(*p);
-
- *p = f;
+ intel_be_fence_reference(p, f);
}
static int
@@ -233,10 +250,21 @@ intel_be_fence_finish(struct pipe_winsys *sws,
* Misc functions
*/
+static void
+intel_be_destroy_winsys(struct pipe_winsys *winsys)
+{
+ struct intel_be_device *dev = intel_be_device(winsys);
+
+ drm_intel_bufmgr_destroy(dev->pools.gem);
+
+ free(dev);
+}
+
boolean
intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
{
dev->fd = fd;
+ dev->id = id;
dev->max_batch_size = 16 * 4096;
dev->max_vertex_size = 128 * 4096;
@@ -253,13 +281,28 @@ intel_be_init_device(struct intel_be_device *dev, int fd, unsigned id)
dev->base.fence_signalled = intel_be_fence_signalled;
dev->base.fence_finish = intel_be_fence_finish;
+ dev->base.destroy = intel_be_destroy_winsys;
+
dev->pools.gem = drm_intel_bufmgr_gem_init(dev->fd, dev->max_batch_size);
return true;
}
-void
-intel_be_destroy_device(struct intel_be_device *dev)
+struct pipe_screen *
+intel_be_create_screen(int drmFD, int deviceID)
{
- drm_intel_bufmgr_destroy(dev->pools.gem);
+ struct intel_be_device *dev;
+ struct pipe_screen *screen;
+
+ /* Allocate the private area */
+ dev = malloc(sizeof(*dev));
+ if (!dev)
+ return NULL;
+ memset(dev, 0, sizeof(*dev));
+
+ intel_be_init_device(dev, drmFD, deviceID);
+
+ screen = i915_create_screen(&dev->base, deviceID);
+
+ return screen;
}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_device.h b/src/gallium/winsys/drm/intel/gem/intel_be_device.h
index f06890163c..47d2176cb4 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_device.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_device.h
@@ -18,6 +18,8 @@ struct intel_be_device
int fd; /**< Drm file discriptor */
+ unsigned id;
+
size_t max_batch_size;
size_t max_vertex_size;
@@ -26,12 +28,15 @@ struct intel_be_device
} pools;
};
+static INLINE struct intel_be_device *
+intel_be_device(struct pipe_winsys *winsys)
+{
+ return (struct intel_be_device *)winsys;
+}
+
boolean
intel_be_init_device(struct intel_be_device *device, int fd, unsigned id);
-void
-intel_be_destroy_device(struct intel_be_device *dev);
-
/*
* Buffer
*/
@@ -39,6 +44,8 @@ intel_be_destroy_device(struct intel_be_device *dev);
struct intel_be_buffer {
struct pipe_buffer base;
drm_intel_bo *bo;
+ boolean flinked;
+ unsigned flink;
};
/**
@@ -47,7 +54,7 @@ struct intel_be_buffer {
* Takes a reference.
*/
struct pipe_buffer *
-intel_be_buffer_from_handle(struct pipe_winsys *winsys,
+intel_be_buffer_from_handle(struct pipe_screen *screen,
const char* name, unsigned handle);
/**
@@ -55,9 +62,20 @@ intel_be_buffer_from_handle(struct pipe_winsys *winsys,
*
* If buffer is destroyed handle may become invalid.
*/
-unsigned
-intel_be_handle_from_buffer(struct pipe_winsys *winsys,
- struct pipe_buffer *buffer);
+boolean
+intel_be_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
+
+/**
+ * Gets the global handle from a buffer.
+ *
+ * If buffer is destroyed handle may become invalid.
+ */
+boolean
+intel_be_global_handle_from_buffer(struct pipe_screen *screen,
+ struct pipe_buffer *buffer,
+ unsigned *handle);
static INLINE struct intel_be_buffer *
intel_be_buffer(struct pipe_buffer *buf)
diff --git a/src/gallium/winsys/drm/intel/gem/intel_be_fence.h b/src/gallium/winsys/drm/intel/gem/intel_be_fence.h
index 0fe18f66f8..a8abb01a9e 100644
--- a/src/gallium/winsys/drm/intel/gem/intel_be_fence.h
+++ b/src/gallium/winsys/drm/intel/gem/intel_be_fence.h
@@ -15,23 +15,19 @@
*/
struct intel_be_fence
{
- uint32_t refcount;
+ struct pipe_reference reference;
drm_intel_bo *bo;
};
static INLINE void
-intel_be_fence_reference(struct intel_be_fence *f)
+intel_be_fence_reference(struct intel_be_fence **ptr, struct intel_be_fence *f)
{
- f->refcount++;
-}
+ struct intel_be_fence *old_fence = *ptr;
-static INLINE void
-intel_be_fence_unreference(struct intel_be_fence *f)
-{
- if (!--f->refcount) {
- if (f->bo)
- drm_intel_bo_unreference(f->bo);
- free(f);
+ if (pipe_reference((struct pipe_reference**)ptr, &f->reference)) {
+ if (old_fence->bo)
+ drm_intel_bo_unreference(old_fence->bo);
+ free(old_fence);
}
}
diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile
new file mode 100644
index 0000000000..a45ca570db
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/Makefile
@@ -0,0 +1,43 @@
+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 xproto) \
+ -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)/state_trackers/xorg/libxorgtracker.a \
+ $(GALLIUMDIR)/winsys/drm/intel/gem/libinteldrm.a \
+ $(TOP)/src/gallium/drivers/i915simple/libi915simple.a \
+ $(GALLIUM_AUXILIARIES)
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a
+ $(TOP)/bin/mklib -noprefix -o $@ \
+ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_intel
+
+clean:
+ rm -rf $(OBJECTS) $(TARGET)
+
+install:
+ $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+ $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/intel/xorg/intel_xorg.c b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
new file mode 100644
index 0000000000..aea39247e5
--- /dev/null
+++ b/src/gallium/winsys/drm/intel/xorg/intel_xorg.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ *
+ */
+
+#include "../../../../state_trackers/xorg/xorg_winsys.h"
+
+static void intel_xorg_identify(int flags);
+static Bool intel_xorg_pci_probe(DriverPtr driver,
+ int entity_num,
+ struct pci_device *device,
+ intptr_t match_data);
+
+static const struct pci_id_match intel_xorg_device_match[] = {
+ {0x8086, 0x2592, 0xffff, 0xffff, 0, 0, 0},
+ {0x8086, 0x27A2, 0xffff, 0xffff, 0, 0, 0},
+ {0, 0, 0},
+};
+
+static SymTabRec intel_xorg_chipsets[] = {
+ {0x2592, "Intel Graphics Device"},
+ {0x27A2, "Intel Graphics Device"},
+ {-1, NULL}
+};
+
+static PciChipsets intel_xorg_pci_devices[] = {
+ {0x2592, 0x2592, RES_SHARED_VGA},
+ {0x27A2, 0x27A2, RES_SHARED_VGA},
+ {-1, -1, RES_UNDEFINED}
+};
+
+static XF86ModuleVersionInfo intel_xorg_version = {
+ "modesetting",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 1, 0, /* major, minor, patch */
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+ 1,
+ "modesetting",
+ intel_xorg_identify,
+ NULL,
+ xorg_tracker_available_options,
+ NULL,
+ 0,
+ NULL,
+ intel_xorg_device_match,
+ intel_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(intel_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+ &intel_xorg_version,
+ intel_xorg_setup,
+ NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+intel_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = 0;
+
+ /* This module should be loaded only once, but check to be sure.
+ */
+ if (!setupDone) {
+ setupDone = 1;
+ xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+ /*
+ * Tell the loader about symbols from other modules that this module
+ * might refer to.
+ */
+ xorg_tracker_loader_ref_sym_lists();
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+static void
+intel_xorg_identify(int flags)
+{
+ xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+ intel_xorg_chipsets);
+}
+
+static Bool
+intel_xorg_pci_probe(DriverPtr driver,
+ int entity_num, struct pci_device *device, intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+ EntityInfoPtr entity;
+
+ scrn = xf86ConfigPciEntity(scrn, 0, entity_num, intel_xorg_pci_devices,
+ NULL, NULL, NULL, NULL, NULL);
+ if (scrn != NULL) {
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modesetting";
+ scrn->Probe = NULL;
+
+ entity = xf86GetEntityInfo(entity_num);
+
+ /* Use all the functions from the xorg tracker */
+ xorg_tracker_set_functions(scrn);
+ }
+ return scrn != NULL;
+}
diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile
index b5735329ec..f8c8135854 100644
--- a/src/gallium/winsys/drm/nouveau/Makefile
+++ b/src/gallium/winsys/drm/nouveau/Makefile
@@ -1,25 +1,12 @@
+# src/gallium/winsys/drm/nouveau/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
+SUBDIRS = drm dri dri2
-SUBDIRS = common dri
-
-
-default: subdirs
-
-
-subdirs:
+default install clean:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE)) || exit 1 ; \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
fi \
done
-
-
-clean:
- rm -f `find . -name \*.[oa]`
- rm -f `find . -name depend`
-
-
-# Dummy install target
-install:
diff --git a/src/gallium/winsys/drm/nouveau/common/Makefile b/src/gallium/winsys/drm/nouveau/common/Makefile
deleted file mode 100644
index c6dd6dd7f9..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/Makefile
+++ /dev/null
@@ -1,22 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveaudrm
-
-C_SOURCES = \
- nouveau_context.c \
- nouveau_lock.c \
- nouveau_screen.c \
- nouveau_winsys.c \
- nouveau_winsys_pipe.c \
- nouveau_winsys_softpipe.c
-
-include ./Makefile.template
-
-DRIVER_DEFINES = $(shell pkg-config libdrm --cflags \
- && pkg-config libdrm --atleast-version=2.3.1 \
- && pkg-config libdrm_nouveau --exact-version=0.5 \
- && pkg-config libdrm_nouveau --cflags \
- && echo "-DDRM_VBLANK_FLIP=DRM_VBLANK_FLIP")
-symlinks:
-
diff --git a/src/gallium/winsys/drm/nouveau/common/Makefile.template b/src/gallium/winsys/drm/nouveau/common/Makefile.template
deleted file mode 100644
index f0d098bb1c..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/Makefile.template
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*-makefile-*-
-
-COMMON_SOURCES =
-
-OBJECTS = $(C_SOURCES:.c=.o) \
- $(CPP_SOURCES:.cpp=.o) \
- $(ASM_SOURCES:.S=.o)
-
-
-### Include directories
-INCLUDES = \
- -I. \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/include \
- $(DRIVER_INCLUDES)
-
-
-##### RULES #####
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@
-
-
-##### TARGETS #####
-
-default: depend symlinks lib$(LIBNAME).a
-
-
-lib$(LIBNAME).a: $(OBJECTS) Makefile Makefile.template
- $(TOP)/bin/mklib -o $(LIBNAME) -static $(OBJECTS) $(DRIVER_LIBS)
-
-
-depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
- rm -f depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DRIVER_DEFINES) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) \
- $(ASM_SOURCES) 2> /dev/null
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` `find ../include`
-
-
-# Remove .o and backup files
-clean::
- -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
- -rm -f depend depend.bak
-
-
-include depend
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_context.c b/src/gallium/winsys/drm/nouveau/common/nouveau_context.c
deleted file mode 100644
index d6ae0827cd..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_context.c
+++ /dev/null
@@ -1,206 +0,0 @@
-#include <pipe/p_defines.h>
-#include <pipe/p_context.h>
-#include <pipe/p_screen.h>
-#include <util/u_memory.h>
-#include "nouveau_context.h"
-#include "nouveau_dri.h"
-#include "nouveau_local.h"
-#include "nouveau_screen.h"
-#include "nouveau_winsys_pipe.h"
-
-static void
-nouveau_channel_context_destroy(struct nouveau_channel_context *nvc)
-{
- nouveau_channel_free(&nvc->channel);
-
- FREE(nvc);
-}
-
-static struct nouveau_channel_context *
-nouveau_channel_context_create(struct nouveau_device *dev)
-{
- struct nouveau_channel_context *nvc;
- int ret;
-
- nvc = CALLOC_STRUCT(nouveau_channel_context);
- if (!nvc)
- return NULL;
-
- if ((ret = nouveau_channel_alloc(dev, 0x8003d001, 0x8003d002,
- &nvc->channel))) {
- NOUVEAU_ERR("Error creating GPU channel: %d\n", ret);
- nouveau_channel_context_destroy(nvc);
- return NULL;
- }
-
- nvc->next_handle = 0x77000000;
- return nvc;
-}
-
-int
-nouveau_context_init(struct nouveau_screen *nv_screen,
- drm_context_t hHWContext, drmLock *sarea_lock,
- struct nouveau_context *nv_share,
- struct nouveau_context *nv)
-{
- struct pipe_context *pipe = NULL;
- struct nouveau_channel_context *nvc = NULL;
- struct nouveau_device *dev = nv_screen->device;
- int i;
-
- switch (dev->chipset & 0xf0) {
- case 0x00:
- /* NV04 */
- case 0x10:
- case 0x20:
- /* NV10 */
- case 0x30:
- /* NV30 */
- case 0x40:
- case 0x60:
- /* NV40 */
- case 0x50:
- case 0x80:
- case 0x90:
- /* G80 */
- break;
- default:
- NOUVEAU_ERR("Unsupported chipset: NV%02x\n", dev->chipset);
- return 1;
- }
-
- nv->nv_screen = nv_screen;
-
- {
- struct nouveau_device_priv *nvdev = nouveau_device(dev);
-
- nvdev->ctx = hHWContext;
- nvdev->lock = sarea_lock;
- }
-
- /* Attempt to share a single channel between multiple contexts from
- * a single process.
- */
- nvc = nv_screen->nvc;
- if (!nvc && nv_share)
- nvc = nv_share->nvc;
-
- /*XXX: temporary - disable multi-context/single-channel on pre-NV4x */
- switch (dev->chipset & 0xf0) {
- case 0x40:
- case 0x60:
- /* NV40 class */
- case 0x50:
- case 0x80:
- case 0x90:
- /* G80 class */
- break;
- default:
- nvc = NULL;
- break;
- }
-
- if (!nvc) {
- nvc = nouveau_channel_context_create(dev);
- if (!nvc) {
- NOUVEAU_ERR("Failed initialising GPU context\n");
- return 1;
- }
- nv_screen->nvc = nvc;
- }
-
- nvc->refcount++;
- nv->nvc = nvc;
-
- /* Find a free slot for a pipe context, allocate a new one if needed */
- nv->pctx_id = -1;
- for (i = 0; i < nvc->nr_pctx; i++) {
- if (nvc->pctx[i] == NULL) {
- nv->pctx_id = i;
- break;
- }
- }
-
- if (nv->pctx_id < 0) {
- nv->pctx_id = nvc->nr_pctx++;
- nvc->pctx =
- realloc(nvc->pctx,
- sizeof(struct pipe_context *) * nvc->nr_pctx);
- }
-
- /* Create pipe */
- if (!getenv("NOUVEAU_FORCE_SOFTPIPE")) {
- struct pipe_screen *pscreen;
-
- pipe = nouveau_pipe_create(nv);
- if (!pipe)
- NOUVEAU_ERR("Couldn't create hw pipe\n");
- pscreen = nvc->pscreen;
-
- nv->cap.hw_vertex_buffer =
- pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF);
- nv->cap.hw_index_buffer =
- pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF);
- }
-
- if (!pipe) {
- NOUVEAU_MSG("Using softpipe\n");
- pipe = nouveau_create_softpipe(nv);
- if (!pipe) {
- NOUVEAU_ERR("Error creating pipe, bailing\n");
- return 1;
- }
- }
-
- {
- struct pipe_texture *fb_tex;
- struct pipe_surface *fb_surf;
- struct nouveau_pipe_buffer *fb_buf;
- enum pipe_format format;
-
- fb_buf = calloc(1, sizeof(struct nouveau_pipe_buffer));
- fb_buf->base.refcount = 1;
- fb_buf->base.usage = PIPE_BUFFER_USAGE_PIXEL;
-
- nouveau_bo_fake(dev, nv_screen->front_offset, NOUVEAU_BO_VRAM,
- nv_screen->front_pitch*nv_screen->front_height,
- NULL, &fb_buf->bo);
-
- if (nv_screen->front_cpp == 4)
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- else
- format = PIPE_FORMAT_R5G6B5_UNORM;
-
- fb_surf = nouveau_surface_buffer_ref(nv, &fb_buf->base, format,
- nv_screen->front_pitch /
- nv_screen->front_cpp,
- nv_screen->front_height,
- nv_screen->front_pitch,
- &fb_tex);
-
- nv->frontbuffer = fb_surf;
- nv->frontbuffer_texture = fb_tex;
- }
-
- pipe->priv = nv;
- return 0;
-}
-
-void
-nouveau_context_cleanup(struct nouveau_context *nv)
-{
- struct nouveau_channel_context *nvc = nv->nvc;
-
- assert(nv);
-
- if (nv->pctx_id >= 0) {
- nvc->pctx[nv->pctx_id] = NULL;
- if (--nvc->refcount <= 0) {
- nouveau_channel_context_destroy(nvc);
- nv->nv_screen->nvc = NULL;
- }
- }
-
- /* XXX: Who cleans up the pipe? */
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_context.h b/src/gallium/winsys/drm/nouveau/common/nouveau_context.h
deleted file mode 100644
index 02d2745680..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_context.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef __NOUVEAU_CONTEXT_H__
-#define __NOUVEAU_CONTEXT_H__
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau_drmif.h"
-#include "nouveau_device.h"
-#include "nouveau_channel.h"
-#include "nouveau_pushbuf.h"
-#include "nouveau_bo.h"
-#include "nouveau_grobj.h"
-#include "nouveau_notifier.h"
-#include "nouveau_class.h"
-#include "nouveau_local.h"
-
-struct nouveau_channel_context {
- struct pipe_screen *pscreen;
- int refcount;
-
- unsigned cur_pctx;
- unsigned nr_pctx;
- struct pipe_context **pctx;
-
- struct nouveau_channel *channel;
- unsigned next_handle;
-};
-
-struct nouveau_context {
- int locked;
- struct nouveau_screen *nv_screen;
- struct pipe_surface *frontbuffer;
- struct pipe_texture *frontbuffer_texture;
-
- struct {
- int hw_vertex_buffer;
- int hw_index_buffer;
- } cap;
-
- /* Hardware context */
- struct nouveau_channel_context *nvc;
- int pctx_id;
-};
-
-extern int nouveau_context_init(struct nouveau_screen *nv_screen,
- drm_context_t hHWContext, drmLock *sarea_lock,
- struct nouveau_context *nv_share,
- struct nouveau_context *nv);
-extern void nouveau_context_cleanup(struct nouveau_context *nv);
-
-extern void LOCK_HARDWARE(struct nouveau_context *);
-extern void UNLOCK_HARDWARE(struct nouveau_context *);
-
-extern uint32_t *nouveau_pipe_dma_beginp(struct nouveau_grobj *, int, int);
-extern void nouveau_pipe_dma_kickoff(struct nouveau_channel *);
-
-/* Must be provided by clients of common code */
-extern void
-nouveau_contended_lock(struct nouveau_context *nv);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_local.h b/src/gallium/winsys/drm/nouveau/common/nouveau_local.h
deleted file mode 100644
index 11175bce7a..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_local.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef __NOUVEAU_LOCAL_H__
-#define __NOUVEAU_LOCAL_H__
-
-#include "pipe/p_compiler.h"
-#include "nouveau_winsys_pipe.h"
-#include <stdio.h>
-
-/* Debug output */
-#define NOUVEAU_MSG(fmt, args...) do { \
- fprintf(stdout, "nouveau: "fmt, ##args); \
- fflush(stdout); \
-} while(0)
-
-#define NOUVEAU_ERR(fmt, args...) do { \
- fprintf(stderr, "%s:%d - "fmt, __func__, __LINE__, ##args); \
- fflush(stderr); \
-} while(0)
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.c b/src/gallium/winsys/drm/nouveau/common/nouveau_screen.c
deleted file mode 100644
index 422fbf0207..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <util/u_memory.h>
-#include "nouveau_dri.h"
-#include "nouveau_local.h"
-#include "nouveau_screen.h"
-
-int
-nouveau_screen_init(struct nouveau_dri *nv_dri, int dev_fd,
- struct nouveau_screen *nv_screen)
-{
- int ret;
-
- ret = nouveau_device_open_existing(&nv_screen->device, 0,
- dev_fd, 0);
- if (ret) {
- NOUVEAU_ERR("Failed opening nouveau device: %d\n", ret);
- return 1;
- }
-
- nv_screen->front_offset = nv_dri->front_offset;
- nv_screen->front_pitch = nv_dri->front_pitch * (nv_dri->bpp / 8);
- nv_screen->front_cpp = nv_dri->bpp / 8;
- nv_screen->front_height = nv_dri->height;
-
- return 0;
-}
-
-void
-nouveau_screen_cleanup(struct nouveau_screen *nv_screen)
-{
- nouveau_device_close(&nv_screen->device);
-}
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.h b/src/gallium/winsys/drm/nouveau/common/nouveau_screen.h
deleted file mode 100644
index 3e68e219d8..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_screen.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef __NOUVEAU_SCREEN_H__
-#define __NOUVEAU_SCREEN_H__
-
-#include <stdint.h>
-
-struct nouveau_device;
-struct nouveau_dri;
-
-struct nouveau_screen {
- struct nouveau_device *device;
-
- uint32_t front_offset;
- uint32_t front_pitch;
- uint32_t front_cpp;
- uint32_t front_height;
-
- void *nvc;
-};
-
-int
-nouveau_screen_init(struct nouveau_dri *nv_dri, int dev_fd,
- struct nouveau_screen *nv_screen);
-
-void
-nouveau_screen_cleanup(struct nouveau_screen *nv_screen);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c
deleted file mode 100644
index 881df98556..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.c
+++ /dev/null
@@ -1,242 +0,0 @@
-#include "pipe/internal/p_winsys_screen.h"
-#include <pipe/p_defines.h>
-#include <pipe/p_inlines.h>
-#include <util/u_memory.h>
-#include "nouveau_context.h"
-#include "nouveau_local.h"
-#include "nouveau_screen.h"
-#include "nouveau_winsys_pipe.h"
-
-static const char *
-nouveau_get_name(struct pipe_winsys *pws)
-{
- return "Nouveau/DRI";
-}
-
-static uint32_t
-nouveau_flags_from_usage(struct nouveau_context *nv, unsigned usage)
-{
- struct nouveau_device *dev = nv->nv_screen->device;
- uint32_t flags = NOUVEAU_BO_LOCAL;
-
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
- if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
- flags |= NOUVEAU_BO_GART;
- if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
- flags |= NOUVEAU_BO_VRAM;
-
- switch (dev->chipset & 0xf0) {
- case 0x50:
- case 0x80:
- case 0x90:
- flags |= NOUVEAU_BO_TILED;
- if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
- flags |= NOUVEAU_BO_ZTILE;
- break;
- default:
- break;
- }
- }
-
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
- if (nv->cap.hw_vertex_buffer)
- flags |= NOUVEAU_BO_GART;
- }
-
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
- if (nv->cap.hw_index_buffer)
- flags |= NOUVEAU_BO_GART;
- }
-
- return flags;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_create(struct pipe_winsys *pws, unsigned alignment,
- unsigned usage, unsigned size)
-{
- struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
- struct nouveau_context *nv = nvpws->nv;
- struct nouveau_device *dev = nv->nv_screen->device;
- struct nouveau_pipe_buffer *nvbuf;
- uint32_t flags;
-
- nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvbuf)
- return NULL;
- nvbuf->base.refcount = 1;
- nvbuf->base.alignment = alignment;
- nvbuf->base.usage = usage;
- nvbuf->base.size = size;
-
- flags = nouveau_flags_from_usage(nv, usage);
-
- if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
- FREE(nvbuf);
- return NULL;
- }
-
- return &nvbuf->base;
-}
-
-static struct pipe_buffer *
-nouveau_pipe_bo_user_create(struct pipe_winsys *pws, void *ptr, unsigned bytes)
-{
- struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
- struct nouveau_device *dev = nvpws->nv->nv_screen->device;
- struct nouveau_pipe_buffer *nvbuf;
-
- nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
- if (!nvbuf)
- return NULL;
- nvbuf->base.refcount = 1;
- nvbuf->base.size = bytes;
-
- if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
- FREE(nvbuf);
- return NULL;
- }
-
- return &nvbuf->base;
-}
-
-static void
-nouveau_pipe_bo_del(struct pipe_winsys *ws, struct pipe_buffer *buf)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
- nouveau_bo_ref(NULL, &nvbuf->bo);
- FREE(nvbuf);
-}
-
-static void *
-nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
- unsigned flags)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
- uint32_t map_flags = 0;
-
- if (flags & PIPE_BUFFER_USAGE_CPU_READ)
- map_flags |= NOUVEAU_BO_RD;
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
- map_flags |= NOUVEAU_BO_WR;
-
-#if 0
- if (flags & PIPE_BUFFER_USAGE_DISCARD &&
- !(flags & PIPE_BUFFER_USAGE_CPU_READ) &&
- nouveau_bo_busy(nvbuf->bo, map_flags)) {
- struct nouveau_pipe_winsys *nvpws = (struct nouveau_pipe_winsys *)pws;
- struct nouveau_context *nv = nvpws->nv;
- struct nouveau_device *dev = nv->nv_screen->device;
- struct nouveau_bo *rename;
- uint32_t flags = nouveau_flags_from_usage(nv, buf->usage);
-
- if (!nouveau_bo_new(dev, flags, buf->alignment, buf->size, &rename)) {
- nouveau_bo_ref(NULL, &nvbuf->bo);
- nvbuf->bo = rename;
- }
- }
-#endif
-
- if (nouveau_bo_map(nvbuf->bo, map_flags))
- return NULL;
- return nvbuf->bo->map;
-}
-
-static void
-nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
-{
- struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
-
- nouveau_bo_unmap(nvbuf->bo);
-}
-
-static void
-nouveau_pipe_fence_reference(struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *pfence)
-{
- *ptr = pfence;
-}
-
-static int
-nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence, unsigned flag)
-{
- return 0;
-}
-
-static int
-nouveau_pipe_fence_finish(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence, unsigned flag)
-{
- return 0;
-}
-
-struct pipe_surface *
-nouveau_surface_buffer_ref(struct nouveau_context *nv, struct pipe_buffer *pb,
- enum pipe_format format, int w, int h,
- unsigned pitch, struct pipe_texture **ppt)
-{
- struct pipe_screen *pscreen = nv->nvc->pscreen;
- struct pipe_texture tmpl, *pt;
- struct pipe_surface *ps;
-
- memset(&tmpl, 0, sizeof(tmpl));
- tmpl.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
- tmpl.target = PIPE_TEXTURE_2D;
- tmpl.width[0] = w;
- tmpl.height[0] = h;
- tmpl.depth[0] = 1;
- tmpl.format = format;
- pf_get_block(tmpl.format, &tmpl.block);
- tmpl.nblocksx[0] = pf_get_nblocksx(&tmpl.block, w);
- tmpl.nblocksy[0] = pf_get_nblocksy(&tmpl.block, h);
-
- pt = pscreen->texture_blanket(pscreen, &tmpl, &pitch, pb);
- if (!pt)
- return NULL;
-
- ps = pscreen->get_tex_surface(pscreen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
-
- *ppt = pt;
- return ps;
-}
-
-static void
-nouveau_destroy(struct pipe_winsys *pws)
-{
- FREE(pws);
-}
-
-struct pipe_winsys *
-nouveau_create_pipe_winsys(struct nouveau_context *nv)
-{
- struct nouveau_pipe_winsys *nvpws;
- struct pipe_winsys *pws;
-
- nvpws = CALLOC_STRUCT(nouveau_pipe_winsys);
- if (!nvpws)
- return NULL;
- nvpws->nv = nv;
- pws = &nvpws->pws;
-
- pws->flush_frontbuffer = nouveau_flush_frontbuffer;
-
- pws->buffer_create = nouveau_pipe_bo_create;
- pws->buffer_destroy = nouveau_pipe_bo_del;
- pws->user_buffer_create = nouveau_pipe_bo_user_create;
- pws->buffer_map = nouveau_pipe_bo_map;
- pws->buffer_unmap = nouveau_pipe_bo_unmap;
-
- pws->fence_reference = nouveau_pipe_fence_reference;
- pws->fence_signalled = nouveau_pipe_fence_signalled;
- pws->fence_finish = nouveau_pipe_fence_finish;
-
- pws->get_name = nouveau_get_name;
- pws->destroy = nouveau_destroy;
-
- return &nvpws->pws;
-}
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h
deleted file mode 100644
index 1eb8043478..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_pipe.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef NOUVEAU_PIPE_WINSYS_H
-#define NOUVEAU_PIPE_WINSYS_H
-
-#include "pipe/p_context.h"
-#include "pipe/internal/p_winsys_screen.h"
-#include "nouveau_context.h"
-
-struct nouveau_pipe_buffer {
- struct pipe_buffer base;
- struct nouveau_bo *bo;
-};
-
-static INLINE struct nouveau_pipe_buffer *
-nouveau_pipe_buffer(struct pipe_buffer *buf)
-{
- return (struct nouveau_pipe_buffer *)buf;
-}
-
-struct nouveau_pipe_winsys {
- struct pipe_winsys pws;
-
- struct nouveau_context *nv;
-};
-
-extern struct pipe_winsys *
-nouveau_create_pipe_winsys(struct nouveau_context *nv);
-
-struct pipe_context *
-nouveau_create_softpipe(struct nouveau_context *nv);
-
-struct pipe_context *
-nouveau_pipe_create(struct nouveau_context *nv);
-
-/* Must be provided by clients of common code */
-extern void
-nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
- void *context_private);
-
-struct pipe_surface *
-nouveau_surface_buffer_ref(struct nouveau_context *nv, struct pipe_buffer *pb,
- enum pipe_format format, int w, int h,
- unsigned pitch, struct pipe_texture **ppt);
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c b/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c
deleted file mode 100644
index 396e4f2a2e..0000000000
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys_softpipe.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "pipe/internal/p_winsys_screen.h"
-#include <pipe/p_screen.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_format.h>
-#include <softpipe/sp_winsys.h>
-#include <util/u_memory.h>
-#include "nouveau_context.h"
-#include "nouveau_winsys_pipe.h"
-
-struct nouveau_softpipe_winsys {
- struct softpipe_winsys sws;
- struct nouveau_context *nv;
-};
-
-/**
- * Return list of surface formats supported by this driver.
- */
-static boolean
-nouveau_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_Z24S8_UNORM:
- return TRUE;
- default:
- break;
- };
-
- return FALSE;
-}
-
-struct pipe_context *
-nouveau_create_softpipe(struct nouveau_context *nv)
-{
- struct nouveau_softpipe_winsys *nvsws;
- struct pipe_screen *pscreen;
- struct pipe_winsys *ws;
- struct pipe_context *pipe;
-
- ws = nouveau_create_pipe_winsys(nv);
- if (!ws)
- return NULL;
- pscreen = softpipe_create_screen(ws);
- if (!pscreen) {
- ws->destroy(ws);
- return NULL;
- }
- nvsws = CALLOC_STRUCT(nouveau_softpipe_winsys);
- if (!nvsws) {
- ws->destroy(ws);
- pscreen->destroy(pscreen);
- return NULL;
- }
-
- nvsws->sws.is_format_supported = nouveau_is_format_supported;
- nvsws->nv = nv;
-
- pipe = softpipe_create(pscreen, ws, &nvsws->sws);
- if (!pipe) {
- ws->destroy(ws);
- pscreen->destroy(pscreen);
- FREE(nvsws);
- return NULL;
- }
-
- return pipe;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
index 3f3553b61d..f7db6201fe 100644
--- a/src/gallium/winsys/drm/nouveau/dri/Makefile
+++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
@@ -6,19 +6,19 @@ LIBNAME = nouveau_dri.so
MINIGLX_SOURCES =
PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
$(TOP)/src/gallium/drivers/nv04/libnv04.a \
$(TOP)/src/gallium/drivers/nv10/libnv10.a \
$(TOP)/src/gallium/drivers/nv20/libnv20.a \
$(TOP)/src/gallium/drivers/nv30/libnv30.a \
$(TOP)/src/gallium/drivers/nv40/libnv40.a \
$(TOP)/src/gallium/drivers/nv50/libnv50.a
-
+
DRIVER_SOURCES = \
- nouveau_context_dri.c \
- nouveau_screen_dri.c \
+ nouveau_context.c \
+ nouveau_screen.c \
nouveau_swapbuffers.c \
- ../common/libnouveaudrm.a
+ nouveau_lock.c
C_SOURCES = \
$(COMMON_GALLIUM_SOURCES) \
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c
index aacfe984d1..deb6ffcff1 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.c
@@ -5,23 +5,15 @@
#include <state_tracker/st_public.h>
#include <state_tracker/st_context.h>
+#include <state_tracker/drm_api.h>
#include <pipe/p_defines.h>
#include <pipe/p_context.h>
#include <pipe/p_screen.h>
-#include "../common/nouveau_winsys_pipe.h"
-#include "../common/nouveau_dri.h"
-#include "../common/nouveau_local.h"
-#include "nouveau_context_dri.h"
-#include "nouveau_screen_dri.h"
+#include "nouveau_context.h"
+#include "nouveau_screen.h"
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
- { "bo", DEBUG_BO },
- { NULL, 0 }
-};
-int __nouveau_debug = 0;
-#endif
+#include "nouveau_drmif.h"
GLboolean
nouveau_context_create(const __GLcontextModes *glVis,
@@ -29,34 +21,38 @@ nouveau_context_create(const __GLcontextModes *glVis,
void *sharedContextPrivate)
{
__DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv;
- struct nouveau_screen_dri *nv_screen = driScrnPriv->private;
- struct nouveau_context_dri *nv = CALLOC_STRUCT(nouveau_context_dri);
- struct st_context *st_share = NULL;
- struct nouveau_context_dri *nv_share = NULL;
+ struct nouveau_screen *nv_screen = driScrnPriv->private;
+ struct nouveau_context *nv;
struct pipe_context *pipe;
+ struct st_context *st_share = NULL;
- if (sharedContextPrivate) {
- st_share = ((struct nouveau_context_dri *)sharedContextPrivate)->st;
- nv_share = st_share->pipe->priv;
+ if (sharedContextPrivate)
+ st_share = ((struct nouveau_context *)sharedContextPrivate)->st;
+
+ nv = CALLOC_STRUCT(nouveau_context);
+ if (!nv)
+ return GL_FALSE;
+
+ {
+ struct nouveau_device_priv *nvdev =
+ nouveau_device(nv_screen->device);
+
+ nvdev->ctx = driContextPriv->hHWContext;
+ nvdev->lock = (drmLock *)&driScrnPriv->pSAREA->lock;
}
- if (nouveau_context_init(&nv_screen->base, driContextPriv->hHWContext,
- (drmLock *)&driScrnPriv->pSAREA->lock,
- &nv_share->base, &nv->base)) {
+ pipe = drm_api_hooks.create_context(nv_screen->pscreen);
+ if (!pipe) {
+ FREE(nv);
return GL_FALSE;
}
+ pipe->priv = nv;
- pipe = nv->base.nvc->pctx[nv->base.pctx_id];
- driContextPriv->driverPrivate = (void *)nv;
- //nv->nv_screen = nv_screen;
+ driContextPriv->driverPrivate = nv;
nv->dri_screen = driScrnPriv;
driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
nv->dri_screen->myNum, "nouveau");
-#ifdef DEBUG
- __nouveau_debug = driParseDebugString(getenv("NOUVEAU_DEBUG"),
- debug_control);
-#endif
nv->st = st_create_context(pipe, glVis, st_share);
return GL_TRUE;
@@ -65,15 +61,13 @@ nouveau_context_create(const __GLcontextModes *glVis,
void
nouveau_context_destroy(__DRIcontextPrivate *driContextPriv)
{
- struct nouveau_context_dri *nv = driContextPriv->driverPrivate;
+ struct nouveau_context *nv = driContextPriv->driverPrivate;
assert(nv);
st_finish(nv->st);
st_destroy_context(nv->st);
- nouveau_context_cleanup(&nv->base);
-
FREE(nv);
}
@@ -82,7 +76,7 @@ nouveau_context_bind(__DRIcontextPrivate *driContextPriv,
__DRIdrawablePrivate *driDrawPriv,
__DRIdrawablePrivate *driReadPriv)
{
- struct nouveau_context_dri *nv;
+ struct nouveau_context *nv;
struct nouveau_framebuffer *draw, *read;
if (!driContextPriv) {
@@ -115,7 +109,7 @@ nouveau_context_bind(__DRIcontextPrivate *driContextPriv,
GLboolean
nouveau_context_unbind(__DRIcontextPrivate *driContextPriv)
{
- struct nouveau_context_dri *nv = driContextPriv->driverPrivate;
+ struct nouveau_context *nv = driContextPriv->driverPrivate;
(void)nv;
st_flush(nv->st, 0, NULL);
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h
index 64cf326411..2779b092e6 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_context_dri.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_context.h
@@ -3,15 +3,16 @@
#include <dri_util.h>
#include <xmlconfig.h>
-#include <nouveau/nouveau_winsys.h>
-#include "../common/nouveau_context.h"
+
+#include "nouveau/nouveau_winsys.h"
+
+#define NOUVEAU_ERR(fmt, args...) debug_printf("%s: "fmt, __func__, ##args)
struct nouveau_framebuffer {
struct st_framebuffer *stfb;
};
-struct nouveau_context_dri {
- struct nouveau_context base;
+struct nouveau_context {
struct st_context *st;
/* DRI stuff */
@@ -21,6 +22,7 @@ struct nouveau_context_dri {
driOptionCache dri_option_cache;
drm_context_t drm_context;
drmLock drm_lock;
+ int locked;
};
extern GLboolean nouveau_context_create(const __GLcontextModes *,
@@ -31,6 +33,10 @@ extern GLboolean nouveau_context_bind(__DRIcontextPrivate *,
__DRIdrawablePrivate *read);
extern GLboolean nouveau_context_unbind(__DRIcontextPrivate *);
+extern void nouveau_contended_lock(struct nouveau_context *nv);
+extern void LOCK_HARDWARE(struct nouveau_context *nv);
+extern void UNLOCK_HARDWARE(struct nouveau_context *nv);
+
#ifdef DEBUG
extern int __nouveau_debug;
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h
index 1207c2d609..1207c2d609 100644
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_dri.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_dri.h
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_lock.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c
index e8cf051ed9..92f5bd09c9 100644
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_lock.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_lock.c
@@ -28,6 +28,7 @@
#include <pipe/p_thread.h>
#include "nouveau_context.h"
#include "nouveau_screen.h"
+#include "nouveau_drmif.h"
pipe_static_mutex(lockMutex);
@@ -36,7 +37,7 @@ pipe_static_mutex(lockMutex);
void
LOCK_HARDWARE(struct nouveau_context *nv)
{
- struct nouveau_screen *nv_screen = nv->nv_screen;
+ struct nouveau_screen *nv_screen = nv->dri_screen->private;
struct nouveau_device *dev = nv_screen->device;
struct nouveau_device_priv *nvdev = nouveau_device(dev);
char __ret=0;
@@ -59,7 +60,7 @@ LOCK_HARDWARE(struct nouveau_context *nv)
void
UNLOCK_HARDWARE(struct nouveau_context *nv)
{
- struct nouveau_screen *nv_screen = nv->nv_screen;
+ struct nouveau_screen *nv_screen = nv->dri_screen->private;
struct nouveau_device *dev = nv_screen->device;
struct nouveau_device_priv *nvdev = nouveau_device(dev);
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c
index 964a9028aa..c4cbbc2124 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.c
@@ -5,12 +5,15 @@
#include <pipe/p_context.h>
#include <state_tracker/st_public.h>
#include <state_tracker/st_cb_fbo.h>
-#include <nouveau_drm.h>
-#include "../common/nouveau_dri.h"
-#include "../common/nouveau_local.h"
-#include "nouveau_context_dri.h"
-#include "nouveau_screen_dri.h"
+#include <state_tracker/drm_api.h>
+
+#include "nouveau_context.h"
+#include "nouveau_screen.h"
#include "nouveau_swapbuffers.h"
+#include "nouveau_dri.h"
+
+#include "nouveau_drm.h"
+#include "nouveau_drmif.h"
#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
#error nouveau_drm.h version does not match expected version
@@ -178,11 +181,58 @@ nouveau_fill_in_modes(__DRIscreenPrivate *psp,
return configs;
}
+static struct pipe_surface *
+dri_surface_from_handle(struct pipe_screen *screen,
+ unsigned handle,
+ enum pipe_format format,
+ unsigned width,
+ unsigned height,
+ unsigned pitch)
+{
+ struct pipe_surface *surface = NULL;
+ struct pipe_texture *texture = NULL;
+ struct pipe_texture templat;
+ struct pipe_buffer *buf = NULL;
+
+ buf = drm_api_hooks.buffer_from_handle(screen, "front buffer", handle);
+ if (!buf)
+ return NULL;
+
+ memset(&templat, 0, sizeof(templat));
+ templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templat.target = PIPE_TEXTURE_2D;
+ templat.last_level = 0;
+ templat.depth[0] = 1;
+ templat.format = format;
+ templat.width[0] = width;
+ templat.height[0] = height;
+ pf_get_block(templat.format, &templat.block);
+
+ texture = screen->texture_blanket(screen,
+ &templat,
+ &pitch,
+ buf);
+
+ /* we don't need the buffer from this point on */
+ pipe_buffer_reference(&buf, NULL);
+
+ if (!texture)
+ return NULL;
+
+ surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
+ PIPE_BUFFER_USAGE_GPU_READ |
+ PIPE_BUFFER_USAGE_GPU_WRITE);
+
+ /* we don't need the texture from this point on */
+ pipe_texture_reference(&texture, NULL);
+ return surface;
+}
+
static const __DRIconfig **
nouveau_screen_create(__DRIscreenPrivate *psp)
{
struct nouveau_dri *nv_dri = psp->pDevPriv;
- struct nouveau_screen_dri *nv_screen;
+ struct nouveau_screen *nv_screen;
static const __DRIversion ddx_expected =
{ 0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL };
static const __DRIversion dri_expected = { 4, 0, 0 };
@@ -210,17 +260,38 @@ nouveau_screen_create(__DRIscreenPrivate *psp)
return NULL;
}
- nv_screen = CALLOC_STRUCT(nouveau_screen_dri);
+ nv_screen = CALLOC_STRUCT(nouveau_screen);
if (!nv_screen)
return NULL;
- driParseOptionInfo(&nv_screen->option_cache,
- __driConfigOptions, __driNConfigOptions);
+ nouveau_device_open_existing(&nv_screen->device, 0, psp->fd, 0);
- if (nouveau_screen_init(nv_dri, psp->fd, &nv_screen->base)) {
+ nv_screen->pscreen = drm_api_hooks.create_screen(psp->fd, 0);
+ if (!nv_screen->pscreen) {
FREE(nv_screen);
return NULL;
}
+ nv_screen->pscreen->flush_frontbuffer = nouveau_flush_frontbuffer;
+
+ {
+ enum pipe_format format;
+
+ if (nv_dri->bpp == 16)
+ format = PIPE_FORMAT_R5G6B5_UNORM;
+ else
+ format = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+ nv_screen->fb = dri_surface_from_handle(nv_screen->pscreen,
+ nv_dri->front_offset,
+ format,
+ nv_dri->width,
+ nv_dri->height,
+ nv_dri->front_pitch *
+ nv_dri->bpp / 8);
+ }
+
+ driParseOptionInfo(&nv_screen->option_cache,
+ __driConfigOptions, __driNConfigOptions);
nv_screen->driScrnPriv = psp;
psp->private = (void *)nv_screen;
@@ -234,10 +305,9 @@ nouveau_screen_create(__DRIscreenPrivate *psp)
static void
nouveau_screen_destroy(__DRIscreenPrivate *driScrnPriv)
{
- struct nouveau_screen_dri *nv_screen = driScrnPriv->private;
+ struct nouveau_screen *nv_screen = driScrnPriv->private;
driScrnPriv->private = NULL;
- nouveau_screen_cleanup(&nv_screen->base);
FREE(nv_screen);
}
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h
index 1498087819..ac078f3c63 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_screen_dri.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_screen.h
@@ -1,13 +1,16 @@
#ifndef __NOUVEAU_SCREEN_DRI_H__
#define __NOUVEAU_SCREEN_DRI_H__
-#include "../common/nouveau_screen.h"
#include "xmlconfig.h"
-struct nouveau_screen_dri {
- struct nouveau_screen base;
+struct nouveau_screen {
__DRIscreenPrivate *driScrnPriv;
driOptionCache option_cache;
+
+ struct nouveau_device *device;
+
+ struct pipe_screen *pscreen;
+ struct pipe_surface *fb;
};
#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
index 58cb6f7265..9c841a0b2d 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.c
@@ -7,23 +7,25 @@
#include <state_tracker/st_context.h>
#include <state_tracker/st_cb_fbo.h>
-#include "../common/nouveau_local.h"
-#include "nouveau_context_dri.h"
-#include "nouveau_screen_dri.h"
+#include "nouveau_context.h"
+#include "nouveau_screen.h"
#include "nouveau_swapbuffers.h"
+#include "nouveau_pushbuf.h"
+
void
nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
const drm_clip_rect_t *rect)
{
- struct nouveau_context_dri *nv = dPriv->driContextPriv->driverPrivate;
- struct pipe_context *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
+ struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate;
+ struct nouveau_screen *nv_screen = nv->dri_screen->private;
+ struct pipe_context *pipe = nv->st->pipe;
drm_clip_rect_t *pbox;
int nbox, i;
- LOCK_HARDWARE(&nv->base);
+ LOCK_HARDWARE(nv);
if (!dPriv->numClipRects) {
- UNLOCK_HARDWARE(&nv->base);
+ UNLOCK_HARDWARE(nv);
return;
}
pbox = dPriv->pClipRects;
@@ -39,12 +41,12 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
w = pbox->x2 - pbox->x1;
h = pbox->y2 - pbox->y1;
- pipe->surface_copy(pipe, FALSE, nv->base.frontbuffer,
- dx, dy, surf, sx, sy, w, h);
+ pipe->surface_copy(pipe, nv_screen->fb, dx, dy, surf,
+ sx, sy, w, h);
}
- FIRE_RING(nv->base.nvc->channel);
- UNLOCK_HARDWARE(&nv->base);
+ pipe->flush(pipe, 0, NULL);
+ UNLOCK_HARDWARE(nv);
if (nv->last_stamp != dPriv->lastStamp) {
struct nouveau_framebuffer *nvfb = dPriv->driverPrivate;
@@ -86,19 +88,19 @@ nouveau_swap_buffers(__DRIdrawablePrivate *dPriv)
}
void
-nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
+nouveau_flush_frontbuffer(struct pipe_screen *pscreen, struct pipe_surface *ps,
void *context_private)
{
- struct nouveau_context_dri *nv = context_private;
+ struct nouveau_context *nv = context_private;
__DRIdrawablePrivate *dPriv = nv->dri_drawable;
- nouveau_copy_buffer(dPriv, surf, NULL);
+ nouveau_copy_buffer(dPriv, ps, NULL);
}
void
nouveau_contended_lock(struct nouveau_context *nv)
{
- struct nouveau_context_dri *nv_sub = (struct nouveau_context_dri*)nv;
+ struct nouveau_context *nv_sub = (struct nouveau_context*)nv;
__DRIdrawablePrivate *dPriv = nv_sub->dri_drawable;
__DRIscreenPrivate *sPriv = nv_sub->dri_screen;
diff --git a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
index 825d3da6da..4ca9cc2283 100644
--- a/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
+++ b/src/gallium/winsys/drm/nouveau/dri/nouveau_swapbuffers.h
@@ -1,10 +1,11 @@
#ifndef __NOUVEAU_SWAPBUFFERS_H__
#define __NOUVEAU_SWAPBUFFERS_H__
-extern void nouveau_copy_buffer(__DRIdrawablePrivate *, struct pipe_surface *,
- const drm_clip_rect_t *);
-extern void nouveau_copy_sub_buffer(__DRIdrawablePrivate *,
- int x, int y, int w, int h);
-extern void nouveau_swap_buffers(__DRIdrawablePrivate *);
+void nouveau_copy_buffer(__DRIdrawablePrivate *, struct pipe_surface *,
+ const drm_clip_rect_t *);
+void nouveau_copy_sub_buffer(__DRIdrawablePrivate *, int x, int y, int w, int h);
+void nouveau_swap_buffers(__DRIdrawablePrivate *);
+void nouveau_flush_frontbuffer(struct pipe_screen *, struct pipe_surface *,
+ void *context_private);
#endif
diff --git a/src/gallium/winsys/drm/nouveau/dri2/Makefile b/src/gallium/winsys/drm/nouveau/dri2/Makefile
new file mode 100644
index 0000000000..728870d2e1
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/dri2/Makefile
@@ -0,0 +1,26 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveau_dri2.so
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
+ $(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
+ $(TOP)/src/gallium/drivers/nv04/libnv04.a \
+ $(TOP)/src/gallium/drivers/nv10/libnv10.a \
+ $(TOP)/src/gallium/drivers/nv20/libnv20.a \
+ $(TOP)/src/gallium/drivers/nv30/libnv30.a \
+ $(TOP)/src/gallium/drivers/nv40/libnv40.a \
+ $(TOP)/src/gallium/drivers/nv50/libnv50.a
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += $(shell pkg-config libdrm_nouveau --libs)
+
+symlinks:
diff --git a/src/gallium/winsys/drm/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile
new file mode 100644
index 0000000000..2da78d8690
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/Makefile
@@ -0,0 +1,13 @@
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = nouveaudrm
+
+C_SOURCES = nouveau_drm_api.c \
+ nouveau_winsys_pipe.c \
+ nouveau_winsys.c
+
+LIBRARY_INCLUDES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-I)
+LIBRARY_DEFINES = $(shell pkg-config libdrm libdrm_nouveau --cflags-only-other)
+
+include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
new file mode 100644
index 0000000000..c0127e803f
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
@@ -0,0 +1,194 @@
+#include "util/u_memory.h"
+
+#include "nouveau_drm_api.h"
+#include "nouveau_winsys_pipe.h"
+
+#include "nouveau_drmif.h"
+#include "nouveau_channel.h"
+#include "nouveau_bo.h"
+
+static struct pipe_screen *
+nouveau_drm_create_screen(int fd, int pciid)
+{
+ struct pipe_winsys *ws;
+ struct nouveau_winsys *nvws;
+ struct nouveau_device *dev = NULL;
+ struct pipe_screen *(*init)(struct pipe_winsys *,
+ struct nouveau_winsys *);
+ int ret;
+
+ ret = nouveau_device_open_existing(&dev, 0, fd, 0);
+ if (ret)
+ return NULL;
+
+ switch (dev->chipset & 0xf0) {
+ case 0x00:
+ init = nv04_screen_create;
+ break;
+ case 0x10:
+ init = nv10_screen_create;
+ break;
+ case 0x20:
+ init = nv20_screen_create;
+ break;
+ case 0x30:
+ init = nv30_screen_create;
+ break;
+ case 0x40:
+ case 0x60:
+ init = nv40_screen_create;
+ break;
+ case 0x80:
+ case 0x90:
+ case 0xa0:
+ init = nv50_screen_create;
+ break;
+ default:
+ debug_printf("%s: unknown chipset nv%02x\n", __func__,
+ dev->chipset);
+ return NULL;
+ }
+
+ ws = nouveau_pipe_winsys_new(dev);
+ if (!ws) {
+ nouveau_device_close(&dev);
+ return NULL;
+ }
+
+ nvws = nouveau_winsys_new(ws);
+ if (!nvws) {
+ ws->destroy(ws);
+ return NULL;
+ }
+
+ nouveau_pipe_winsys(ws)->pscreen = init(ws, nvws);
+ if (!nouveau_pipe_winsys(ws)->pscreen) {
+ ws->destroy(ws);
+ return NULL;
+ }
+
+ return nouveau_pipe_winsys(ws)->pscreen;
+}
+
+static struct pipe_context *
+nouveau_drm_create_context(struct pipe_screen *pscreen)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
+ struct pipe_context *(*init)(struct pipe_screen *, unsigned);
+ unsigned chipset = nvpws->channel->device->chipset;
+ int i;
+
+ switch (chipset & 0xf0) {
+ case 0x00:
+ init = nv04_create;
+ break;
+ case 0x10:
+ init = nv10_create;
+ break;
+ case 0x20:
+ init = nv20_create;
+ break;
+ case 0x30:
+ init = nv30_create;
+ break;
+ case 0x40:
+ case 0x60:
+ init = nv40_create;
+ break;
+ case 0x80:
+ case 0x90:
+ case 0xa0:
+ init = nv50_create;
+ break;
+ default:
+ debug_printf("%s: unknown chipset nv%02x\n", __func__, chipset);
+ return NULL;
+ }
+
+ /* Find a free slot for a pipe context, allocate a new one if needed */
+ for (i = 0; i < nvpws->nr_pctx; i++) {
+ if (nvpws->pctx[i] == NULL)
+ break;
+ }
+
+ if (i == nvpws->nr_pctx) {
+ nvpws->nr_pctx++;
+ nvpws->pctx = realloc(nvpws->pctx,
+ sizeof(*nvpws->pctx) * nvpws->nr_pctx);
+ }
+
+ nvpws->pctx[i] = init(pscreen, i);
+ return nvpws->pctx[i];
+}
+
+static boolean
+nouveau_drm_pb_from_pt(struct pipe_texture *pt, struct pipe_buffer **ppb,
+ unsigned *stride)
+{
+ return false;
+}
+
+static struct pipe_buffer *
+nouveau_drm_pb_from_handle(struct pipe_screen *pscreen, const char *name,
+ unsigned handle)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_screen(pscreen);
+ struct nouveau_device *dev = nvpws->channel->device;
+ struct nouveau_pipe_buffer *nvpb;
+ int ret;
+
+ nvpb = CALLOC_STRUCT(nouveau_pipe_buffer);
+ if (!nvpb)
+ return NULL;
+
+ ret = nouveau_bo_handle_ref(dev, handle, &nvpb->bo);
+ if (ret) {
+ debug_printf("%s: ref name 0x%08x failed with %d\n",
+ __func__, handle, ret);
+ FREE(nvpb);
+ return NULL;
+ }
+
+ pipe_reference_init(&nvpb->base.reference, 1);
+ nvpb->base.screen = pscreen;
+ nvpb->base.alignment = 0;
+ nvpb->base.usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE |
+ PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ nvpb->base.size = nvpb->bo->size;
+ return &nvpb->base;
+}
+
+static boolean
+nouveau_drm_handle_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+ unsigned *handle)
+{
+ struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+
+ if (!nvpb)
+ return FALSE;
+
+ *handle = nvpb->bo->handle;
+ return TRUE;
+}
+
+static boolean
+nouveau_drm_name_from_pb(struct pipe_screen *pscreen, struct pipe_buffer *pb,
+ unsigned *handle)
+{
+ struct nouveau_pipe_buffer *nvpb = nouveau_pipe_buffer(pb);
+
+ if (!nvpb)
+ return FALSE;
+
+ return nouveau_bo_handle_get(nvpb->bo, handle) == 0;
+}
+
+struct drm_api drm_api_hooks = {
+ .create_screen = nouveau_drm_create_screen,
+ .create_context = nouveau_drm_create_context,
+ .buffer_from_texture = nouveau_drm_pb_from_pt,
+ .buffer_from_handle = nouveau_drm_pb_from_handle,
+ .handle_from_buffer = nouveau_drm_handle_from_pb,
+ .global_handle_from_buffer = nouveau_drm_name_from_pb,
+};
+
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
new file mode 100644
index 0000000000..2782c83c0e
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
@@ -0,0 +1,5 @@
+#ifndef __NOUVEAU_DRM_API_H__
+#define __NOUVEAU_DRM_API_H__
+#include "state_tracker/drm_api.h"
+
+#endif
diff --git a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
index b6199f8e6d..e3175fd775 100644
--- a/src/gallium/winsys/drm/nouveau/common/nouveau_winsys.c
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys.c
@@ -1,18 +1,14 @@
#include "util/u_memory.h"
-#include "nouveau_context.h"
-#include "nouveau_screen.h"
#include "nouveau_winsys_pipe.h"
-#include "nouveau/nouveau_winsys.h"
-
static int
nouveau_pipe_notifier_alloc(struct nouveau_winsys *nvws, int count,
struct nouveau_notifier **notify)
{
- struct nouveau_context *nv = nvws->nv;
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
- return nouveau_notifier_alloc(nv->nvc->channel, nv->nvc->next_handle++,
+ return nouveau_notifier_alloc(nvpws->channel, nvpws->next_handle++,
count, notify);
}
@@ -20,12 +16,11 @@ static int
nouveau_pipe_grobj_alloc(struct nouveau_winsys *nvws, int grclass,
struct nouveau_grobj **grobj)
{
- struct nouveau_context *nv = nvws->nv;
- struct nouveau_channel *chan = nv->nvc->channel;
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(nvws->ws);
+ struct nouveau_channel *chan = nvpws->channel;
int ret;
- ret = nouveau_grobj_alloc(chan, nv->nvc->next_handle++,
- grclass, grobj);
+ ret = nouveau_grobj_alloc(chan, nvpws->next_handle++, grclass, grobj);
if (ret)
return ret;
@@ -62,55 +57,18 @@ nouveau_pipe_get_bo(struct pipe_buffer *pb)
return nouveau_pipe_buffer(pb)->bo;
}
-struct pipe_context *
-nouveau_pipe_create(struct nouveau_context *nv)
+struct nouveau_winsys *
+nouveau_winsys_new(struct pipe_winsys *ws)
{
- struct nouveau_channel_context *nvc = nv->nvc;
- struct nouveau_winsys *nvws = CALLOC_STRUCT(nouveau_winsys);
- struct pipe_screen *(*hws_create)(struct pipe_winsys *,
- struct nouveau_winsys *);
- struct pipe_context *(*hw_create)(struct pipe_screen *, unsigned);
- struct pipe_winsys *ws;
- unsigned chipset = nv->nv_screen->device->chipset;
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct nouveau_winsys *nvws;
+ nvws = CALLOC_STRUCT(nouveau_winsys);
if (!nvws)
return NULL;
- switch (chipset & 0xf0) {
- case 0x00:
- hws_create = nv04_screen_create;
- hw_create = nv04_create;
- break;
- case 0x10:
- hws_create = nv10_screen_create;
- hw_create = nv10_create;
- break;
- case 0x20:
- hws_create = nv20_screen_create;
- hw_create = nv20_create;
- break;
- case 0x30:
- hws_create = nv30_screen_create;
- hw_create = nv30_create;
- break;
- case 0x40:
- case 0x60:
- hws_create = nv40_screen_create;
- hw_create = nv40_create;
- break;
- case 0x50:
- case 0x80:
- case 0x90:
- hws_create = nv50_screen_create;
- hw_create = nv50_create;
- break;
- default:
- NOUVEAU_ERR("Unknown chipset NV%02x\n", chipset);
- return NULL;
- }
-
- nvws->nv = nv;
- nvws->channel = nv->nvc->channel;
+ nvws->ws = ws;
+ nvws->channel = nvpws->channel;
nvws->res_init = nouveau_resource_init;
nvws->res_alloc = nouveau_resource_alloc;
@@ -131,11 +89,6 @@ nouveau_pipe_create(struct nouveau_context *nv)
nvws->get_bo = nouveau_pipe_get_bo;
- ws = nouveau_create_pipe_winsys(nv);
-
- if (!nvc->pscreen)
- nvc->pscreen = hws_create(ws, nvws);
- nvc->pctx[nv->pctx_id] = hw_create(nvc->pscreen, nv->pctx_id);
- return nvc->pctx[nv->pctx_id];
+ return nvws;
}
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
new file mode 100644
index 0000000000..9e03a9f5db
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.c
@@ -0,0 +1,204 @@
+#include "pipe/internal/p_winsys_screen.h"
+#include <pipe/p_defines.h>
+#include <pipe/p_inlines.h>
+#include <util/u_memory.h>
+
+#include "nouveau_winsys_pipe.h"
+
+#include "nouveau_drmif.h"
+#include "nouveau_bo.h"
+
+static const char *
+nouveau_get_name(struct pipe_winsys *pws)
+{
+ return "Nouveau/DRI";
+}
+
+static uint32_t
+nouveau_flags_from_usage(struct pipe_winsys *ws, unsigned usage)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct pipe_screen *pscreen = nvpws->pscreen;
+ uint32_t flags = NOUVEAU_BO_LOCAL;
+
+ if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
+ flags |= NOUVEAU_BO_GART;
+
+ if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+ if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
+ flags |= NOUVEAU_BO_GART;
+ if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
+ flags |= NOUVEAU_BO_VRAM;
+
+ switch (nvpws->channel->device->chipset & 0xf0) {
+ case 0x50:
+ case 0x80:
+ case 0x90:
+ flags |= NOUVEAU_BO_TILED;
+ if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
+ flags |= NOUVEAU_BO_ZTILE;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+ if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
+ flags |= NOUVEAU_BO_GART;
+ }
+
+ if (usage & PIPE_BUFFER_USAGE_INDEX) {
+ if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
+ flags |= NOUVEAU_BO_GART;
+ }
+
+ return flags;
+}
+
+static struct pipe_buffer *
+nouveau_pipe_bo_create(struct pipe_winsys *ws, unsigned alignment,
+ unsigned usage, unsigned size)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct nouveau_device *dev = nvpws->channel->device;
+ struct nouveau_pipe_buffer *nvbuf;
+ uint32_t flags;
+
+ nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
+ if (!nvbuf)
+ return NULL;
+ pipe_reference_init(&nvbuf->base.reference, 1);
+ nvbuf->base.alignment = alignment;
+ nvbuf->base.usage = usage;
+ nvbuf->base.size = size;
+
+ flags = nouveau_flags_from_usage(ws, usage);
+ if (nouveau_bo_new(dev, flags, alignment, size, &nvbuf->bo)) {
+ FREE(nvbuf);
+ return NULL;
+ }
+
+ return &nvbuf->base;
+}
+
+static struct pipe_buffer *
+nouveau_pipe_bo_user_create(struct pipe_winsys *ws, void *ptr, unsigned bytes)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+ struct nouveau_device *dev = nvpws->channel->device;
+ struct nouveau_pipe_buffer *nvbuf;
+
+ nvbuf = CALLOC_STRUCT(nouveau_pipe_buffer);
+ if (!nvbuf)
+ return NULL;
+ pipe_reference_init(&nvbuf->base.reference, 1);
+ nvbuf->base.size = bytes;
+
+ if (nouveau_bo_user(dev, ptr, bytes, &nvbuf->bo)) {
+ FREE(nvbuf);
+ return NULL;
+ }
+
+ return &nvbuf->base;
+}
+
+static void
+nouveau_pipe_bo_del(struct pipe_buffer *buf)
+{
+ struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
+
+ nouveau_bo_ref(NULL, &nvbuf->bo);
+ FREE(nvbuf);
+}
+
+static void *
+nouveau_pipe_bo_map(struct pipe_winsys *pws, struct pipe_buffer *buf,
+ unsigned flags)
+{
+ struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
+ uint32_t map_flags = 0;
+
+ if (flags & PIPE_BUFFER_USAGE_CPU_READ)
+ map_flags |= NOUVEAU_BO_RD;
+ if (flags & PIPE_BUFFER_USAGE_CPU_WRITE)
+ map_flags |= NOUVEAU_BO_WR;
+
+ if (nouveau_bo_map(nvbuf->bo, map_flags))
+ return NULL;
+ return nvbuf->bo->map;
+}
+
+static void
+nouveau_pipe_bo_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf)
+{
+ struct nouveau_pipe_buffer *nvbuf = nouveau_pipe_buffer(buf);
+
+ nouveau_bo_unmap(nvbuf->bo);
+}
+
+static void
+nouveau_pipe_fence_reference(struct pipe_winsys *ws,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *pfence)
+{
+ *ptr = pfence;
+}
+
+static int
+nouveau_pipe_fence_signalled(struct pipe_winsys *ws,
+ struct pipe_fence_handle *pfence, unsigned flag)
+{
+ return 0;
+}
+
+static int
+nouveau_pipe_fence_finish(struct pipe_winsys *ws,
+ struct pipe_fence_handle *pfence, unsigned flag)
+{
+ return 0;
+}
+
+static void
+nouveau_destroy(struct pipe_winsys *ws)
+{
+ struct nouveau_pipe_winsys *nvpws = nouveau_pipe_winsys(ws);
+
+ nouveau_device_close(&nvpws->channel->device);
+ FREE(nvpws);
+}
+
+struct pipe_winsys *
+nouveau_pipe_winsys_new(struct nouveau_device *dev)
+{
+ struct nouveau_pipe_winsys *nvpws;
+ int ret;
+
+ nvpws = CALLOC_STRUCT(nouveau_pipe_winsys);
+ if (!nvpws)
+ return NULL;
+
+ ret = nouveau_channel_alloc(dev, 0xbeef0201, 0xbeef0202,
+ &nvpws->channel);
+ if (ret) {
+ debug_printf("%s: error opening GPU channel: %d\n",
+ __func__, ret);
+ FREE(nvpws);
+ return NULL;
+ }
+ nvpws->next_handle = 0x77000000;
+
+ nvpws->base.buffer_create = nouveau_pipe_bo_create;
+ nvpws->base.buffer_destroy = nouveau_pipe_bo_del;
+ nvpws->base.user_buffer_create = nouveau_pipe_bo_user_create;
+ nvpws->base.buffer_map = nouveau_pipe_bo_map;
+ nvpws->base.buffer_unmap = nouveau_pipe_bo_unmap;
+
+ nvpws->base.fence_reference = nouveau_pipe_fence_reference;
+ nvpws->base.fence_signalled = nouveau_pipe_fence_signalled;
+ nvpws->base.fence_finish = nouveau_pipe_fence_finish;
+
+ nvpws->base.get_name = nouveau_get_name;
+ nvpws->base.destroy = nouveau_destroy;
+ return &nvpws->base;
+}
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
new file mode 100644
index 0000000000..10e1e269e8
--- /dev/null
+++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_winsys_pipe.h
@@ -0,0 +1,52 @@
+#ifndef NOUVEAU_PIPE_WINSYS_H
+#define NOUVEAU_PIPE_WINSYS_H
+
+#include "pipe/internal/p_winsys_screen.h"
+#include "pipe/p_context.h"
+
+#include "nouveau/nouveau_winsys.h"
+
+#include "nouveau_device.h"
+
+struct nouveau_pipe_buffer {
+ struct pipe_buffer base;
+ struct nouveau_bo *bo;
+};
+
+static INLINE struct nouveau_pipe_buffer *
+nouveau_pipe_buffer(struct pipe_buffer *buf)
+{
+ return (struct nouveau_pipe_buffer *)buf;
+}
+
+struct nouveau_pipe_winsys {
+ struct pipe_winsys base;
+
+ struct pipe_screen *pscreen;
+
+ struct nouveau_channel *channel;
+ uint32_t next_handle;
+
+ unsigned nr_pctx;
+ struct pipe_context **pctx;
+};
+
+static INLINE struct nouveau_pipe_winsys *
+nouveau_pipe_winsys(struct pipe_winsys *ws)
+{
+ return (struct nouveau_pipe_winsys *)ws;
+}
+
+static INLINE struct nouveau_pipe_winsys *
+nouveau_screen(struct pipe_screen *pscreen)
+{
+ return nouveau_pipe_winsys(pscreen->winsys);
+}
+
+struct pipe_winsys *
+nouveau_pipe_winsys_new(struct nouveau_device *);
+
+struct nouveau_winsys *
+nouveau_winsys_new(struct pipe_winsys *ws);
+
+#endif
diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile
index dca1e3233a..bacdf3de28 100644
--- a/src/gallium/winsys/drm/radeon/Makefile
+++ b/src/gallium/winsys/drm/radeon/Makefile
@@ -1,32 +1,12 @@
-
+# src/gallium/winsys/drm/radeon/Makefile
TOP = ../../../../..
include $(TOP)/configs/current
-LIBNAME = radeon_dri.so
-
-MINIGLX_SOURCES =
-
-PIPE_DRIVERS = \
- $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/drivers/r300/libr300.a
-
-DRIVER_SOURCES = \
- radeon_buffer.c \
- radeon_context.c \
- radeon_r300.c \
- radeon_screen.c \
- radeon_winsys_softpipe.c
-
-C_SOURCES = \
- $(COMMON_GALLIUM_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I../../../drivers/r300
-
-include ../Makefile.template
-
-DRI_LIB_DEPS += -ldrm_radeon
+SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-symlinks:
+default install clean:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir && $(MAKE) $@) || exit 1; \
+ fi \
+ done
diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/drm/radeon/core/Makefile
new file mode 100644
index 0000000000..42a6f4abc2
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/core/Makefile
@@ -0,0 +1,18 @@
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeonwinsys
+
+C_SOURCES = \
+ radeon_buffer.c \
+ radeon_drm.c \
+ radeon_r300.c \
+ radeon_winsys_softpipe.c
+
+LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/r300 \
+ $(shell pkg-config libdrm --cflags-only-I)
+
+include ../../../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
index 259a505c0a..9dca510c81 100644
--- a/src/gallium/winsys/drm/radeon/radeon_buffer.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2008 Jérôme Glisse
+ * 2009 Corbin Simpson
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -26,37 +27,31 @@
/*
* Authors:
* Jérôme Glisse <glisse@freedesktop.org>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
*/
-#include <stdio.h>
-#include "dri_util.h"
-#include "state_tracker/st_public.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+
#include "radeon_buffer.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
-#include "radeon_bo.h"
-#include "radeon_drm.h"
static const char *radeon_get_name(struct pipe_winsys *ws)
{
- return "RADEON/DRI2";
+ return "Radeon/GEM+KMS";
}
static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
+ unsigned alignment,
+ unsigned usage,
+ unsigned size)
{
- struct radeon_pipe_winsys *radeon_ws = (struct radeon_pipe_winsys *)ws;
+ struct radeon_winsys *radeon_ws = (struct radeon_winsys *)ws;
struct radeon_pipe_buffer *radeon_buffer;
uint32_t domain;
- radeon_buffer = calloc(1, sizeof(*radeon_buffer));
+ radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
if (radeon_buffer == NULL) {
return NULL;
}
- radeon_buffer->base.refcount = 1;
+
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
radeon_buffer->base.alignment = alignment;
radeon_buffer->base.usage = usage;
radeon_buffer->base.size = size;
@@ -69,21 +64,21 @@ static struct pipe_buffer *radeon_buffer_create(struct pipe_winsys *ws,
if (usage & PIPE_BUFFER_USAGE_VERTEX) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
-
if (usage & PIPE_BUFFER_USAGE_INDEX) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
- radeon_buffer->bo = radeon_bo_open(radeon_ws->radeon_screen->bom, 0,
- size, alignment, domain, 0);
+
+ radeon_buffer->bo = radeon_bo_open(radeon_ws->bom, 0, size, alignment,
+ domain, 0);
if (radeon_buffer->bo == NULL) {
- free(radeon_buffer);
+ FREE(radeon_buffer);
}
return &radeon_buffer->base;
}
static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
- void *ptr,
- unsigned bytes)
+ void *ptr,
+ unsigned bytes)
{
struct radeon_pipe_buffer *radeon_buffer;
@@ -97,7 +92,7 @@ static struct pipe_buffer *radeon_buffer_user_create(struct pipe_winsys *ws,
return &radeon_buffer->base;
}
-static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer)
+static void radeon_buffer_del(struct pipe_buffer *buffer)
{
struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer;
@@ -106,15 +101,20 @@ static void radeon_buffer_del(struct pipe_winsys *ws, struct pipe_buffer *buffer
}
static void *radeon_buffer_map(struct pipe_winsys *ws,
- struct pipe_buffer *buffer,
- unsigned flags)
+ struct pipe_buffer *buffer,
+ unsigned flags)
{
struct radeon_pipe_buffer *radeon_buffer = (struct radeon_pipe_buffer*)buffer;
int write = 0;
+ if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ /* XXX Remove this when radeon_bo_map supports DONTBLOCK */
+ return NULL;
+ }
if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
write = 1;
}
+
if (radeon_bo_map(radeon_buffer->bo, write))
return NULL;
return radeon_buffer->bo->ptr;
@@ -128,59 +128,62 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws, struct pipe_buffer *buff
}
static void radeon_fence_reference(struct pipe_winsys *ws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *pfence)
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *pfence)
{
}
static int radeon_fence_signalled(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence,
- unsigned flag)
+ struct pipe_fence_handle *pfence,
+ unsigned flag)
{
return 1;
}
static int radeon_fence_finish(struct pipe_winsys *ws,
- struct pipe_fence_handle *pfence,
- unsigned flag)
+ struct pipe_fence_handle *pfence,
+ unsigned flag)
{
return 0;
}
static void radeon_flush_frontbuffer(struct pipe_winsys *pipe_winsys,
- struct pipe_surface *pipe_surface,
- void *context_private)
+ struct pipe_surface *pipe_surface,
+ void *context_private)
{
/* TODO: call dri2CopyRegion */
}
-struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen)
+struct radeon_winsys* radeon_pipe_winsys(int fd)
{
- struct radeon_pipe_winsys *radeon_ws;
+ struct radeon_winsys* radeon_ws;
+ struct radeon_bo_manager* bom;
- radeon_ws = calloc(1, sizeof(struct radeon_pipe_winsys));
+ radeon_ws = CALLOC_STRUCT(radeon_winsys);
if (radeon_ws == NULL) {
return NULL;
}
- radeon_ws->radeon_screen = radeon_screen;
- radeon_ws->winsys.flush_frontbuffer = radeon_flush_frontbuffer;
+ bom = radeon_bo_manager_gem_ctor(fd);
+ radeon_ws->bom = bom;
- radeon_ws->winsys.buffer_create = radeon_buffer_create;
- radeon_ws->winsys.buffer_destroy = radeon_buffer_del;
- radeon_ws->winsys.user_buffer_create = radeon_buffer_user_create;
- radeon_ws->winsys.buffer_map = radeon_buffer_map;
- radeon_ws->winsys.buffer_unmap = radeon_buffer_unmap;
+ radeon_ws->base.flush_frontbuffer = radeon_flush_frontbuffer;
- radeon_ws->winsys.fence_reference = radeon_fence_reference;
- radeon_ws->winsys.fence_signalled = radeon_fence_signalled;
- radeon_ws->winsys.fence_finish = radeon_fence_finish;
+ radeon_ws->base.buffer_create = radeon_buffer_create;
+ radeon_ws->base.buffer_destroy = radeon_buffer_del;
+ radeon_ws->base.user_buffer_create = radeon_buffer_user_create;
+ radeon_ws->base.buffer_map = radeon_buffer_map;
+ radeon_ws->base.buffer_unmap = radeon_buffer_unmap;
- radeon_ws->winsys.get_name = radeon_get_name;
+ radeon_ws->base.fence_reference = radeon_fence_reference;
+ radeon_ws->base.fence_signalled = radeon_fence_signalled;
+ radeon_ws->base.fence_finish = radeon_fence_finish;
- return &radeon_ws->winsys;
-}
+ radeon_ws->base.get_name = radeon_get_name;
+ return radeon_ws;
+}
+#if 0
static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeon_screen,
uint32_t handle)
{
@@ -196,7 +199,7 @@ static struct pipe_buffer *radeon_buffer_from_handle(struct radeon_screen *radeo
radeon_bo_unref(bo);
return NULL;
}
- radeon_buffer->base.refcount = 1;
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
radeon_buffer->bo = bo;
return &radeon_buffer->base;
@@ -231,9 +234,10 @@ struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_co
pt = pipe_screen->texture_blanket(pipe_screen, &tmpl, &pitch, pb);
if (pt == NULL) {
- pipe_buffer_reference(pipe_screen, &pb, NULL);
+ pipe_buffer_reference(&pb, NULL);
}
ps = pipe_screen->get_tex_surface(pipe_screen, pt, 0, 0, 0,
PIPE_BUFFER_USAGE_GPU_WRITE);
return ps;
}
+#endif
diff --git a/src/gallium/winsys/drm/radeon/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
index c626c20229..40ad0fc8d1 100644
--- a/src/gallium/winsys/drm/radeon/radeon_buffer.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
@@ -30,22 +30,35 @@
#ifndef RADEON_BUFFER_H
#define RADEON_BUFFER_H
+#include <stdio.h>
+
#include "pipe/internal/p_winsys_screen.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_inlines.h"
+
+//#include "state_tracker/st_public.h"
+
+#include "util/u_memory.h"
+
#include "radeon_bo.h"
+#include "radeon_drm.h"
+
struct radeon_pipe_buffer {
struct pipe_buffer base;
struct radeon_bo *bo;
};
-struct radeon_pipe_winsys {
- struct pipe_winsys winsys;
- struct radeon_screen *radeon_screen;
+struct radeon_winsys {
+ /* Parent class. */
+ struct pipe_winsys base;
+
+ /* Radeon BO manager.
+ * This corresponds to void* radeon_winsys in r300_winsys. */
+ struct radeon_bo_manager* bom;
};
-struct pipe_winsys *radeon_pipe_winsys(struct radeon_screen *radeon_screen);
+struct radeon_winsys* radeon_pipe_winsys(int fb);
struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context,
uint32_t handle,
enum pipe_format format,
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
new file mode 100644
index 0000000000..3446654e28
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright © 2009 Corbin Simpson
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
+ * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ */
+/*
+ * Authors:
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
+ */
+
+#include "radeon_drm.h"
+
+/* Create a pipe_screen. */
+struct pipe_screen* radeon_create_screen(int drmFB, int pciID)
+{
+ struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB);
+
+ if (getenv("RADEON_SOFTPIPE")) {
+ return softpipe_create_screen((struct pipe_winsys*)winsys);
+ } else {
+ struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys);
+ FREE(winsys);
+ return r300_create_screen(r300);
+ }
+}
+
+/* Create a pipe_context. */
+struct pipe_context* radeon_create_context(struct pipe_screen* screen)
+{
+ if (getenv("RADEON_SOFTPIPE")) {
+ return radeon_create_softpipe(screen->winsys);
+ } else {
+ return r300_create_context(screen, screen->winsys);
+ }
+}
+
+boolean radeon_buffer_from_texture(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride)
+{
+ return FALSE;
+}
+
+/* Create a buffer from a handle. */
+/* XXX what's up with name? */
+struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen,
+ const char* name,
+ unsigned handle)
+{
+ struct radeon_bo_manager* bom =
+ ((struct radeon_winsys*)screen->winsys)->bom;
+ struct radeon_pipe_buffer* radeon_buffer;
+ struct radeon_bo* bo = NULL;
+
+ bo = radeon_bo_open(bom, handle, 0, 0, 0, 0);
+ if (bo == NULL) {
+ return NULL;
+ }
+
+ radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer);
+ if (radeon_buffer == NULL) {
+ radeon_bo_unref(bo);
+ return NULL;
+ }
+
+ pipe_reference_init(&radeon_buffer->base.reference, 1);
+ radeon_buffer->base.screen = screen;
+ radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL;
+ radeon_buffer->bo = bo;
+ return &radeon_buffer->base;
+}
+
+boolean radeon_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle)
+{
+ struct radeon_pipe_buffer* radeon_buffer =
+ (struct radeon_pipe_buffer*)buffer;
+ *handle = radeon_buffer->bo->handle;
+ return TRUE;
+}
+
+boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle)
+{
+ /* XXX WTF is the difference here? global? */
+ struct radeon_pipe_buffer* radeon_buffer =
+ (struct radeon_pipe_buffer*)buffer;
+ *handle = radeon_buffer->bo->handle;
+ return TRUE;
+}
+
+struct drm_api drm_api_hooks = {
+ .create_screen = radeon_create_screen,
+ .create_context = radeon_create_context,
+ /* XXX fix this */
+ .buffer_from_texture = r300_get_texture_buffer,
+ .buffer_from_handle = radeon_buffer_from_handle,
+ .handle_from_buffer = radeon_handle_from_buffer,
+ .global_handle_from_buffer = radeon_global_handle_from_buffer,
+};
diff --git a/src/gallium/winsys/drm/radeon/radeon_context.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
index d7222b4469..ca2d98ed1a 100644
--- a/src/gallium/winsys/drm/radeon/radeon_context.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Jérôme Glisse
+ * Copyright © 2009 Corbin Simpson
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
@@ -25,46 +25,39 @@
*/
/*
* Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
+ * Corbin Simpson <MostAwesomeDude@gmail.com>
*/
-#ifndef RADEON_CONTEXT_H
-#define RADEON_CONTEXT_H
+#ifndef RADEON_DRM_H
+#define RADEON_DRM_H
-#include "dri_util.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "radeon_screen.h"
+#include "pipe/p_screen.h"
+#include "util/u_memory.h"
+
+#include "state_tracker/drm_api.h"
+
+#include "radeon_buffer.h"
#include "radeon_r300.h"
+#include "radeon_winsys_softpipe.h"
+
+struct pipe_screen* radeon_create_screen(int drmFB, int pciID);
+
+struct pipe_context* radeon_create_context(struct pipe_screen* screen);
+
+boolean radeon_buffer_from_texture(struct pipe_texture* texture,
+ struct pipe_buffer** buffer,
+ unsigned* stride);
-struct radeon_framebuffer {
- struct st_framebuffer *st_framebuffer;
- unsigned attachments;
-};
+struct pipe_buffer* radeon_buffer_from_handle(struct pipe_screen* screen,
+ const char* name,
+ unsigned handle);
-struct radeon_context {
- /* st */
- struct st_context *st_context;
- /* pipe */
- struct pipe_screen *pipe_screen;
- struct pipe_winsys *pipe_winsys;
- /* DRI */
- __DRIscreenPrivate *dri_screen;
- __DRIdrawablePrivate *dri_drawable;
- __DRIdrawablePrivate *dri_readable;
- /* DRM */
- int drm_fd;
- /* RADEON */
- struct radeon_screen *radeon_screen;
-};
+boolean radeon_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle);
-GLboolean radeon_context_create(const __GLcontextModes*,
- __DRIcontextPrivate*,
- void*);
-void radeon_context_destroy(__DRIcontextPrivate*);
-GLboolean radeon_context_bind(__DRIcontextPrivate*,
- __DRIdrawablePrivate*,
- __DRIdrawablePrivate*);
-GLboolean radeon_context_unbind(__DRIcontextPrivate*);
+boolean radeon_global_handle_from_buffer(struct pipe_screen* screen,
+ struct pipe_buffer* buffer,
+ unsigned* handle);
#endif
diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
index 8fe2375e34..c7b6813014 100644
--- a/src/gallium/winsys/drm/radeon/radeon_r300.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
@@ -75,9 +75,10 @@ static void do_ioctls(struct r300_winsys* winsys, int fd)
}
-struct r300_winsys* radeon_create_r300_winsys(int fd)
+struct r300_winsys*
+radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys)
{
- struct r300_winsys* winsys = calloc(1, sizeof(struct r300_winsys));
+ struct r300_winsys* winsys = CALLOC_STRUCT(r300_winsys);
do_ioctls(winsys, fd);
@@ -92,5 +93,7 @@ struct r300_winsys* radeon_create_r300_winsys(int fd)
winsys->end_cs = radeon_cs_end;
winsys->flush_cs = radeon_r300_flush_cs;
+ memcpy(winsys, old_winsys, sizeof(struct radeon_winsys));
+
return winsys;
}
diff --git a/src/gallium/winsys/drm/radeon/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
index 8ed95a3a9b..5c373cd084 100644
--- a/src/gallium/winsys/drm/radeon/radeon_r300.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
@@ -31,4 +31,5 @@
#include "radeon_buffer.h"
-struct r300_winsys* radeon_create_r300_winsys(int fd);
+struct r300_winsys*
+radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys);
diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c
index 8402e1fa5a..226e16674c 100644
--- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.c
+++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.c
@@ -28,12 +28,7 @@
/*
* Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
-#include <stdio.h>
-#include "imports.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_format.h"
-#include "softpipe/sp_winsys.h"
-#include "radeon_context.h"
+
#include "radeon_winsys_softpipe.h"
struct radeon_softpipe_winsys {
@@ -57,21 +52,20 @@ static boolean radeon_is_format_supported(struct softpipe_winsys *sws, uint form
return FALSE;
}
-struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context)
+struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys)
{
- struct radeon_softpipe_winsys *radeon_sp_ws;
+ struct softpipe_winsys *sp_winsys;
struct pipe_screen *pipe_screen;
- pipe_screen = softpipe_create_screen(radeon_context->pipe_winsys);
+ pipe_screen = softpipe_create_screen(winsys);
- radeon_sp_ws = CALLOC_STRUCT(radeon_softpipe_winsys);
- if (radeon_sp_ws == NULL) {
+ sp_winsys = CALLOC_STRUCT(softpipe_winsys);
+ if (sp_winsys == NULL) {
return NULL;
}
- radeon_context->pipe_screen = pipe_screen;
- radeon_sp_ws->radeon_context = radeon_context;
- radeon_sp_ws->sp_winsys.is_format_supported = radeon_is_format_supported;
+
+ sp_winsys->is_format_supported = radeon_is_format_supported;
return softpipe_create(pipe_screen,
- radeon_context->pipe_winsys,
- &radeon_sp_ws->sp_winsys);
+ winsys,
+ sp_winsys);
}
diff --git a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h
index 519eab769c..04740e41a5 100644
--- a/src/gallium/winsys/drm/radeon/radeon_winsys_softpipe.h
+++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys_softpipe.h
@@ -30,8 +30,15 @@
#ifndef RADEON_WINSYS_SOFTPIPE_H
#define RADEON_WINSYS_SOFTPIPE_H
-#include "radeon_context.h"
+#include <stdio.h>
-struct pipe_context *radeon_create_softpipe(struct radeon_context *radeon_context);
+#include "pipe/p_defines.h"
+#include "pipe/p_format.h"
+
+#include "softpipe/sp_winsys.h"
+
+#include "util/u_memory.h"
+
+struct pipe_context *radeon_create_softpipe(struct pipe_winsys* winsys);
#endif
diff --git a/src/gallium/winsys/drm/radeon/dri2/Makefile b/src/gallium/winsys/drm/radeon/dri2/Makefile
new file mode 100644
index 0000000000..f471c44349
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/dri2/Makefile
@@ -0,0 +1,25 @@
+
+TOP = ../../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeon_dri.so
+
+MINIGLX_SOURCES =
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/dri2/libdri2drm.a \
+ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../../Makefile.template
+
+DRI_LIB_DEPS += -ldrm_radeon
+
+symlinks:
diff --git a/src/gallium/winsys/drm/radeon/egl/Makefile b/src/gallium/winsys/drm/radeon/egl/Makefile
new file mode 100644
index 0000000000..d989b3aa93
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/egl/Makefile
@@ -0,0 +1,25 @@
+TOP = ../../../../../..
+GALLIUMDIR = ../../../..
+include $(TOP)/configs/current
+
+LIBNAME = EGL_r300.so
+
+PIPE_DRIVERS = \
+ $(TOP)/src/gallium/state_trackers/egl/libegldrm.a \
+ $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a
+
+DRIVER_SOURCES =
+
+C_SOURCES = \
+ $(COMMON_GALLIUM_SOURCES) \
+ $(DRIVER_SOURCES)
+
+DRIVER_EXTRAS = -ldrm_radeon
+
+ASM_SOURCES =
+
+include ../../Makefile.template
+
+symlinks:
diff --git a/src/gallium/winsys/drm/radeon/radeon_context.c b/src/gallium/winsys/drm/radeon/radeon_context.c
deleted file mode 100644
index a9d1577634..0000000000
--- a/src/gallium/winsys/drm/radeon/radeon_context.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright © 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
- */
-#include <stdio.h>
-#include "dri_util.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
-#include "radeon_buffer.h"
-#include "radeon_winsys_softpipe.h"
-
-#define need_GL_ARB_fragment_program
-#define need_GL_ARB_multisample
-#define need_GL_ARB_point_parameters
-#define need_GL_ARB_shader_objects
-#define need_GL_ARB_texture_compression
-#define need_GL_ARB_vertex_buffer_object
-#define need_GL_ARB_vertex_program
-#define need_GL_ARB_vertex_shader
-#define need_GL_EXT_blend_color
-#define need_GL_EXT_blend_equation_separate
-#define need_GL_EXT_blend_func_separate
-#define need_GL_EXT_blend_minmax
-#define need_GL_EXT_cull_vertex
-#define need_GL_EXT_compiled_vertex_array
-#define need_GL_EXT_fog_coord
-#define need_GL_EXT_framebuffer_object
-#define need_GL_EXT_multi_draw_arrays
-#define need_GL_EXT_secondary_color
-#define need_GL_VERSION_2_0
-#define need_GL_VERSION_2_1
-#include "extension_helper.h"
-
-/**
- * Extension strings exported by the radeon driver.
- */
-const struct dri_extension radeon_card_extensions[] = {
- {"GL_ARB_multitexture", NULL},
- {"GL_ARB_texture_border_clamp", NULL},
- {"GL_ARB_texture_rectangle", NULL},
- {"GL_ARB_pixel_buffer_object", NULL},
- {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions},
- {"GL_ARB_shader_objects", GL_ARB_shader_objects_functions},
- {"GL_ARB_shading_language_100", GL_VERSION_2_0_functions},
- {"GL_ARB_shading_language_120", GL_VERSION_2_1_functions},
- {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
- {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
- {"GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions},
- {"GL_EXT_blend_color", GL_EXT_blend_color_functions},
- {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
- {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
- {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
- {"GL_EXT_blend_subtract", NULL},
- {"GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions},
- {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions},
- {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions},
- {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions},
- {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions},
- {"GL_EXT_packed_depth_stencil", NULL},
- {"GL_EXT_pixel_buffer_object", NULL},
- {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
- {"GL_EXT_stencil_wrap", NULL},
- {NULL, NULL}
-};
-
-static void radeon_update_renderbuffers(__DRIcontext *dri_context,
- __DRIdrawable *dri_drawable)
-{
- struct radeon_framebuffer *radeon_fb;
- struct radeon_context *radeon_context;
- unsigned attachments[10];
- __DRIbuffer *buffers;
- __DRIscreen *screen;
- int i, count;
-
- radeon_context = dri_context->driverPrivate;
- screen = dri_drawable->driScreenPriv;
- radeon_fb = dri_drawable->driverPrivate;
- for (count = 0, i = 0; count < 6; count++) {
- if (radeon_fb->attachments & (1 << count)) {
- attachments[i++] = count;
- }
- }
-
- buffers = (*screen->dri2.loader->getBuffers)(dri_drawable,
- &dri_drawable->w,
- &dri_drawable->h,
- attachments,
- i,
- &count,
- dri_drawable->loaderPrivate);
- if (buffers == NULL) {
- return;
- }
-
- /* set one cliprect to cover the whole dri_drawable */
- dri_drawable->x = 0;
- dri_drawable->y = 0;
- dri_drawable->backX = 0;
- dri_drawable->backY = 0;
- dri_drawable->numClipRects = 1;
- dri_drawable->pClipRects[0].x1 = 0;
- dri_drawable->pClipRects[0].y1 = 0;
- dri_drawable->pClipRects[0].x2 = dri_drawable->w;
- dri_drawable->pClipRects[0].y2 = dri_drawable->h;
- dri_drawable->numBackClipRects = 1;
- dri_drawable->pBackClipRects[0].x1 = 0;
- dri_drawable->pBackClipRects[0].y1 = 0;
- dri_drawable->pBackClipRects[0].x2 = dri_drawable->w;
- dri_drawable->pBackClipRects[0].y2 = dri_drawable->h;
-
- for (i = 0; i < count; i++) {
- struct pipe_surface *ps;
- enum pipe_format format = 0;
- int index = 0;
-
- switch (buffers[i].attachment) {
- case __DRI_BUFFER_FRONT_LEFT:
- index = ST_SURFACE_FRONT_LEFT;
- switch (buffers[i].cpp) {
- case 4:
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- case 2:
- format = PIPE_FORMAT_R5G6B5_UNORM;
- break;
- default:
- /* FIXME: error */
- return;
- }
- break;
- case __DRI_BUFFER_BACK_LEFT:
- index = ST_SURFACE_BACK_LEFT;
- switch (buffers[i].cpp) {
- case 4:
- format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- case 2:
- format = PIPE_FORMAT_R5G6B5_UNORM;
- break;
- default:
- /* FIXME: error */
- return;
- }
- break;
- case __DRI_BUFFER_STENCIL:
- case __DRI_BUFFER_DEPTH:
- index = ST_SURFACE_DEPTH;
- switch (buffers[i].cpp) {
- case 4:
- format = PIPE_FORMAT_Z24S8_UNORM;
- break;
- case 2:
- format = PIPE_FORMAT_Z16_UNORM;
- break;
- default:
- /* FIXME: error */
- return;
- }
- break;
- case __DRI_BUFFER_ACCUM:
- default:
- fprintf(stderr,
- "unhandled buffer attach event, attacment type %d\n",
- buffers[i].attachment);
- return;
- }
-
- ps = radeon_surface_from_handle(radeon_context,
- buffers[i].name,
- format,
- dri_drawable->w,
- dri_drawable->h,
- buffers[i].pitch);
- assert(ps);
- st_set_framebuffer_surface(radeon_fb->st_framebuffer, index, ps);
- }
- st_resize_framebuffer(radeon_fb->st_framebuffer,
- dri_drawable->w,
- dri_drawable->h);
-}
-
-GLboolean radeon_context_create(const __GLcontextModes *visual,
- __DRIcontextPrivate *dri_context,
- void *shared_context)
-{
- __DRIscreenPrivate *dri_screen;
- struct radeon_context *radeon_context;
- struct radeon_screen *radeon_screen;
- struct pipe_context *pipe;
- struct st_context *shared_st_context = NULL;
-
- dri_context->driverPrivate = NULL;
- radeon_context = calloc(1, sizeof(struct radeon_context));
- if (radeon_context == NULL) {
- return GL_FALSE;
- }
-
- if (shared_context) {
- shared_st_context = ((struct radeon_context*)shared_context)->st_context;
- }
-
- dri_screen = dri_context->driScreenPriv;
- radeon_screen = dri_screen->private;
- radeon_context->dri_screen = dri_screen;
- radeon_context->radeon_screen = radeon_screen;
- radeon_context->drm_fd = dri_screen->fd;
-
- radeon_context->pipe_winsys = radeon_pipe_winsys(radeon_screen);
- if (radeon_context->pipe_winsys == NULL) {
- free(radeon_context);
- return GL_FALSE;
- }
-
- if (!getenv("RADEON_SOFTPIPE")) {
- fprintf(stderr, "Creating r300 context...\n");
- pipe =
- r300_create_context(NULL,
- radeon_context->pipe_winsys,
- radeon_create_r300_winsys(radeon_context->drm_fd));
- radeon_context->pipe_screen = pipe->screen;
- } else {
- pipe = radeon_create_softpipe(radeon_context);
- }
- radeon_context->st_context = st_create_context(pipe, visual,
- shared_st_context);
- driInitExtensions(radeon_context->st_context->ctx,
- radeon_card_extensions, GL_TRUE);
- dri_context->driverPrivate = radeon_context;
- return GL_TRUE;
-}
-
-void radeon_context_destroy(__DRIcontextPrivate *dri_context)
-{
- struct radeon_context *radeon_context;
-
- radeon_context = dri_context->driverPrivate;
- st_finish(radeon_context->st_context);
- st_destroy_context(radeon_context->st_context);
- free(radeon_context);
-}
-
-GLboolean radeon_context_bind(__DRIcontextPrivate *dri_context,
- __DRIdrawablePrivate *dri_drawable,
- __DRIdrawablePrivate *dri_readable)
-{
- struct radeon_framebuffer *drawable;
- struct radeon_framebuffer *readable;
- struct radeon_context *radeon_context;
-
- if (dri_context == NULL) {
- st_make_current(NULL, NULL, NULL);
- return GL_TRUE;
- }
-
- radeon_context = dri_context->driverPrivate;
- drawable = dri_drawable->driverPrivate;
- readable = dri_readable->driverPrivate;
- st_make_current(radeon_context->st_context,
- drawable->st_framebuffer,
- readable->st_framebuffer);
-
- radeon_update_renderbuffers(dri_context, dri_drawable);
- if (dri_drawable != dri_readable) {
- radeon_update_renderbuffers(dri_context, dri_readable);
- }
- return GL_TRUE;
-}
-
-GLboolean radeon_context_unbind(__DRIcontextPrivate *dri_context)
-{
- struct radeon_context *radeon_context;
-
- radeon_context = dri_context->driverPrivate;
- st_flush(radeon_context->st_context, PIPE_FLUSH_RENDER_CACHE, NULL);
- return GL_TRUE;
-}
diff --git a/src/gallium/winsys/drm/radeon/radeon_screen.c b/src/gallium/winsys/drm/radeon/radeon_screen.c
deleted file mode 100644
index e31caff0bf..0000000000
--- a/src/gallium/winsys/drm/radeon/radeon_screen.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright © 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
- */
-#include <stdio.h>
-#include "pipe/p_screen.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "state_tracker/st_public.h"
-#include "state_tracker/st_context.h"
-#include "utils.h"
-#include "xf86drm.h"
-#include "drm.h"
-#include "dri_util.h"
-#include "radeon_screen.h"
-#include "radeon_context.h"
-#include "radeon_buffer.h"
-#include "radeon_bo.h"
-#include "radeon_bo_gem.h"
-#include "radeon_drm.h"
-
-extern const struct dri_extension radeon_card_extensions[];
-
-static const __DRIextension *radeon_screen_extensions[] = {
- &driReadDrawableExtension,
- &driCopySubBufferExtension.base,
- &driSwapControlExtension.base,
- &driFrameTrackingExtension.base,
- &driMediaStreamCounterExtension.base,
- NULL
-};
-
-static __DRIconfig **radeon_fill_in_modes(unsigned pixel_bits,
- unsigned depth_bits,
- GLboolean have_back_buffer)
-{
- __DRIconfig **configs;
- unsigned depth_buffer_factor;
- unsigned back_buffer_factor;
- unsigned num_modes;
- GLenum fb_format;
- GLenum fb_type;
- uint8_t depth_bits_array[3];
- uint8_t stencil_bits_array[3];
- uint8_t msaa_samples_array[1];
- /* TODO: pageflipping ? */
- static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
- };
-
- stencil_bits_array[0] = 0;
- stencil_bits_array[1] = 0;
- if (depth_bits == 24) {
- stencil_bits_array[2] = 8;
- num_modes = 3;
- }
-
- depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
- depth_buffer_factor = (depth_bits == 24) ? 3 : 2;
-
- back_buffer_factor = (have_back_buffer) ? 3 : 1;
-
- msaa_samples_array[0] = 0;
-
- if (pixel_bits == 16) {
- fb_format = GL_RGB;
- fb_type = GL_UNSIGNED_SHORT_5_6_5;
- } else {
- fb_format = GL_BGRA;
- fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
- }
-
- configs = (__DRIconfig **)driCreateConfigs(fb_format,
- fb_type,
- depth_bits_array,
- stencil_bits_array,
- depth_buffer_factor,
- back_buffer_modes,
- back_buffer_factor,
- msaa_samples_array,
- 1);
- if (configs == NULL) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n",
- __FILE__, __LINE__);
- return NULL;
- }
- return configs;
-}
-
-static void radeon_screen_destroy(__DRIscreenPrivate *dri_screen)
-{
- struct radeon_screen *radeon_screen = (struct radeon_screen*)dri_screen->private;
-
- radeon_bo_manager_gem_dtor(radeon_screen->bom);
- dri_screen = NULL;
- free(radeon_screen);
-}
-
-static const __DRIconfig **radeon_screen_init(__DRIscreenPrivate *dri_screen)
-{
- struct radeon_screen *radeon_screen;
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- driInitExtensions(NULL, radeon_card_extensions, GL_FALSE);
-
- radeon_screen = calloc(1, sizeof(struct radeon_screen));
- if (radeon_screen == NULL) {
- fprintf(stderr, "\nERROR! Allocating private area failed\n");
- return NULL;
- }
- dri_screen->private = (void*)radeon_screen;
- dri_screen->extensions = radeon_screen_extensions;
- radeon_screen->dri_screen = dri_screen;
-
- radeon_screen->bom = radeon_bo_manager_gem_ctor(dri_screen->fd);
- if (radeon_screen->bom == NULL) {
- radeon_screen_destroy(dri_screen);
- return NULL;
- }
-
- return driConcatConfigs(radeon_fill_in_modes(16, 16, 1),
- radeon_fill_in_modes(32, 24, 1));
-}
-
-static boolean radeon_buffer_create(__DRIscreenPrivate *dri_screen,
- __DRIdrawablePrivate *dri_drawable,
- const __GLcontextModes *visual,
- boolean is_pixmap)
-{
- if (is_pixmap) {
- /* TODO: implement ? */
- return GL_FALSE;
- } else {
- enum pipe_format color_format, depth_format, stencil_format;
- struct radeon_framebuffer *radeon_fb;
-
- radeon_fb = calloc(1, sizeof(struct radeon_framebuffer));
- if (radeon_fb == NULL) {
- return GL_FALSE;
- }
-
- switch (visual->redBits) {
- case 5:
- color_format = PIPE_FORMAT_R5G6B5_UNORM;
- break;
- default:
- color_format = PIPE_FORMAT_A8R8G8B8_UNORM;
- break;
- }
-
- switch (visual->depthBits) {
- case 24:
- depth_format = PIPE_FORMAT_S8Z24_UNORM;
- break;
- case 16:
- depth_format = PIPE_FORMAT_Z16_UNORM;
- break;
- default:
- depth_format = PIPE_FORMAT_NONE;
- break;
- }
-
- switch (visual->stencilBits) {
- case 8:
- /* force depth format */
- depth_format = PIPE_FORMAT_S8Z24_UNORM;
- stencil_format = PIPE_FORMAT_S8Z24_UNORM;
- break;
- default:
- stencil_format = PIPE_FORMAT_NONE;
- break;
- }
-
- radeon_fb->st_framebuffer = st_create_framebuffer(visual,
- color_format,
- depth_format,
- stencil_format,
- dri_drawable->w,
- dri_drawable->h,
- (void*)radeon_fb);
- if (radeon_fb->st_framebuffer == NULL) {
- free(radeon_fb);
- return GL_FALSE;
- }
- dri_drawable->driverPrivate = (void *) radeon_fb;
-
- radeon_fb->attachments = (1 << __DRI_BUFFER_FRONT_LEFT);
- if (visual->doubleBufferMode) {
- radeon_fb->attachments |= (1 << __DRI_BUFFER_BACK_LEFT);
- }
- if (visual->depthBits || visual->stencilBits) {
- radeon_fb->attachments |= (1 << __DRI_BUFFER_DEPTH);
- }
-
- return GL_TRUE;
- }
-}
-
-static void radeon_buffer_destroy(__DRIdrawablePrivate * dri_drawable)
-{
- struct radeon_framebuffer *radeon_fb;
-
- radeon_fb = dri_drawable->driverPrivate;
- assert(radeon_fb->st_framebuffer);
- st_unreference_framebuffer(radeon_fb->st_framebuffer);
- free(radeon_fb);
-}
-
-static void radeon_swap_buffers(__DRIdrawablePrivate *dri_drawable)
-{
- struct radeon_framebuffer *radeon_fb;
- struct pipe_surface *back_surf = NULL;
-
- radeon_fb = dri_drawable->driverPrivate;
- assert(radeon_fb);
- assert(radeon_fb->st_framebuffer);
-
- st_get_framebuffer_surface(radeon_fb->st_framebuffer,
- ST_SURFACE_BACK_LEFT,
- &back_surf);
- if (back_surf) {
- st_notify_swapbuffers(radeon_fb->st_framebuffer);
- /* TODO: do we want to do anythings ? */
- st_notify_swapbuffers_complete(radeon_fb->st_framebuffer);
- }
-}
-
-/**
- * Called via glXCopySubBufferMESA() to copy a subrect of the back
- * buffer to the front buffer/screen.
- */
-static void radeon_copy_sub_buffer(__DRIdrawablePrivate *dri_drawable,
- int x, int y, int w, int h)
-{
- /* TODO: ... */
-}
-
-const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = NULL,
- .DestroyScreen = radeon_screen_destroy,
- .CreateContext = radeon_context_create,
- .DestroyContext = radeon_context_destroy,
- .CreateBuffer = radeon_buffer_create,
- .DestroyBuffer = radeon_buffer_destroy,
- .SwapBuffers = radeon_swap_buffers,
- .MakeCurrent = radeon_context_bind,
- .UnbindContext = radeon_context_unbind,
- .CopySubBuffer = radeon_copy_sub_buffer,
- .InitScreen2 = radeon_screen_init,
-};
diff --git a/src/gallium/winsys/drm/radeon/radeon_screen.h b/src/gallium/winsys/drm/radeon/radeon_screen.h
deleted file mode 100644
index 01b7fa6531..0000000000
--- a/src/gallium/winsys/drm/radeon/radeon_screen.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright © 2008 Jérôme Glisse
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
- * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- */
-/*
- * Authors:
- * Jérôme Glisse <glisse@freedesktop.org>
- */
-#ifndef RADEON_SCREEN_H
-#define RADEON_SCREEN_H
-
-#include "dri_util.h"
-#include "radeon_bo.h"
-
-struct radeon_screen {
- __DRIscreenPrivate *dri_screen;
- struct radeon_bo_manager *bom;
-};
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile
new file mode 100644
index 0000000000..6ffd4a3a54
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/xorg/Makefile
@@ -0,0 +1,42 @@
+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 xproto) \
+ -I${GALLIUMDIR}/include \
+ -I${GALLIUMDIR}/drivers \
+ -I${GALLIUMDIR}/auxiliary \
+ -I${TOP}/src/mesa \
+ -I$(TOP)/include \
+ -I$(TOP)/src/egl/main
+
+LIBS = \
+ $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a \
+ $(GALLIUMDIR)/winsys/drm/radeon/core/libradeonwinsys.a \
+ $(TOP)/src/gallium/drivers/r300/libr300.a \
+ $(GALLIUM_AUXILIARIES)
+
+#############################################
+
+
+
+all default: $(TARGET)
+
+$(TARGET): $(OBJECTS) Makefile $(GALLIUMDIR)/state_trackers/xorg/libxorgtracker.a
+ $(TOP)/bin/mklib -noprefix -o $@ \
+ $(OBJECTS) $(LIBS) $(shell pkg-config --libs libdrm) -ldrm_radeon
+
+clean:
+ rm -rf $(OBJECTS) $(TARGET)
+
+install:
+ $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+ $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR)
+
+.PHONY = all clean install
diff --git a/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c
new file mode 100644
index 0000000000..6f77fbe5de
--- /dev/null
+++ b/src/gallium/winsys/drm/radeon/xorg/radeon_xorg.c
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ * Author: Alan Hourihane <alanh@tungstengraphics.com>
+ * Author: Jakob Bornecrantz <wallbraker@gmail.com>
+ * Author: Corbin Simpson <MostAwesomedude@gmail.com>
+ *
+ */
+
+#include "../../../../state_trackers/xorg/xorg_winsys.h"
+
+static void radeon_xorg_identify(int flags);
+static Bool radeon_xorg_pci_probe(DriverPtr driver,
+ int entity_num,
+ struct pci_device *device,
+ intptr_t match_data);
+
+static const struct pci_id_match radeon_xorg_device_match[] = {
+ {0x1002, 0x5E4D, 0xffff, 0xffff, 0, 0, 0},
+ {0x1002, 0x7249, 0xffff, 0xffff, 0, 0, 0},
+ {0, 0, 0},
+};
+
+static SymTabRec radeon_xorg_chipsets[] = {
+ {0x5E4D, "Radeon RV410 PCIE (X700)"},
+ {0x7249, "Radeon R580 PCIE (X1900 XT)"},
+ {-1, NULL}
+};
+
+static PciChipsets radeon_xorg_pci_devices[] = {
+ {0x5E4D, 0x5E4D, RES_SHARED_VGA},
+ {0x7249, 0x7249, RES_SHARED_VGA},
+ {-1, -1, RES_UNDEFINED}
+};
+
+static XF86ModuleVersionInfo radeon_xorg_version = {
+ "modesetting",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XORG_VERSION_CURRENT,
+ 0, 1, 0, /* major, minor, patch */
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+/*
+ * Xorg driver exported structures
+ */
+
+_X_EXPORT DriverRec modesetting = {
+ 1,
+ "modesetting",
+ radeon_xorg_identify,
+ NULL,
+ xorg_tracker_available_options,
+ NULL,
+ 0,
+ NULL,
+ radeon_xorg_device_match,
+ radeon_xorg_pci_probe
+};
+
+static MODULESETUPPROTO(radeon_xorg_setup);
+
+_X_EXPORT XF86ModuleData modesettingModuleData = {
+ &radeon_xorg_version,
+ radeon_xorg_setup,
+ NULL
+};
+
+/*
+ * Xorg driver functions
+ */
+
+static pointer
+radeon_xorg_setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = 0;
+
+ /* This module should be loaded only once, but check to be sure.
+ */
+ if (!setupDone) {
+ setupDone = 1;
+ xf86AddDriver(&modesetting, module, HaveDriverFuncs);
+
+ /*
+ * Tell the loader about symbols from other modules that this module
+ * might refer to.
+ */
+ xorg_tracker_loader_ref_sym_lists();
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+static void
+radeon_xorg_identify(int flags)
+{
+ xf86PrintChipsets("modesetting", "Driver for Modesetting Kernel Drivers",
+ radeon_xorg_chipsets);
+}
+
+static Bool
+radeon_xorg_pci_probe(DriverPtr driver,
+ int entity_num, struct pci_device *device, intptr_t match_data)
+{
+ ScrnInfoPtr scrn = NULL;
+ EntityInfoPtr entity;
+
+ scrn = xf86ConfigPciEntity(scrn, 0, entity_num, radeon_xorg_pci_devices,
+ NULL, NULL, NULL, NULL, NULL);
+ if (scrn != NULL) {
+ scrn->driverVersion = 1;
+ scrn->driverName = "modesetting";
+ scrn->name = "modesetting";
+ scrn->Probe = NULL;
+
+ entity = xf86GetEntityInfo(entity_num);
+
+ /* Use all the functions from the xorg tracker */
+ xorg_tracker_set_functions(scrn);
+ }
+ return scrn != NULL;
+}