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/SConscript69
-rw-r--r--src/gallium/winsys/drm/i965/Makefile12
-rw-r--r--src/gallium/winsys/drm/i965/SConscript3
-rw-r--r--src/gallium/winsys/drm/i965/gem/Makefile14
-rw-r--r--src/gallium/winsys/drm/i965/gem/SConscript15
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_api.c122
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c503
-rw-r--r--src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h64
-rw-r--r--src/gallium/winsys/drm/i965/xlib/Makefile97
-rw-r--r--src/gallium/winsys/drm/i965/xlib/xlib_i965.c503
-rw-r--r--src/gallium/winsys/drm/intel/Makefile12
-rw-r--r--src/gallium/winsys/drm/intel/SConscript3
-rw-r--r--src/gallium/winsys/drm/intel/gem/Makefile16
-rw-r--r--src/gallium/winsys/drm/intel/gem/SConscript17
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_api.c109
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c244
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c217
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_fence.c83
-rw-r--r--src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h77
-rw-r--r--src/gallium/winsys/drm/nouveau/Makefile12
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/Makefile11
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h28
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c157
-rw-r--r--src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h31
-rw-r--r--src/gallium/winsys/drm/radeon/Makefile12
-rw-r--r--src/gallium/winsys/drm/radeon/SConscript3
-rw-r--r--src/gallium/winsys/drm/radeon/core/Makefile17
-rw-r--r--src/gallium/winsys/drm/radeon/core/SConscript18
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_buffer.h86
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.c200
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm.h66
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c385
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.c348
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_r300.h30
-rw-r--r--src/gallium/winsys/drm/radeon/core/radeon_winsys.h86
-rw-r--r--src/gallium/winsys/drm/sw/Makefile14
-rw-r--r--src/gallium/winsys/drm/sw/sw_drm_api.c97
-rw-r--r--src/gallium/winsys/drm/sw/sw_drm_api.h34
-rw-r--r--src/gallium/winsys/drm/sw/wrapper_sw_winsys.c282
-rw-r--r--src/gallium/winsys/drm/sw/wrapper_sw_winsys.h35
-rw-r--r--src/gallium/winsys/drm/vmware/Makefile12
-rw-r--r--src/gallium/winsys/drm/vmware/SConscript3
-rw-r--r--src/gallium/winsys/drm/vmware/core/Makefile35
-rw-r--r--src/gallium/winsys/drm/vmware/core/SConscript39
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_buffer.c274
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_buffer.h65
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_context.c382
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_context.h56
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_fence.c108
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_fence.h59
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen.c77
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen.h140
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c373
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c529
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c97
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c295
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_surface.c61
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmw_surface.h79
-rw-r--r--src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h545
59 files changed, 0 insertions, 7361 deletions
diff --git a/src/gallium/winsys/drm/SConscript b/src/gallium/winsys/drm/SConscript
deleted file mode 100644
index 66b73a8bf9..0000000000
--- a/src/gallium/winsys/drm/SConscript
+++ /dev/null
@@ -1,69 +0,0 @@
-Import('*')
-
-if env['dri']:
-
- drienv = env.Clone()
-
- drienv.Replace(CPPPATH = [
- '#src/mesa/drivers/dri/common',
- '#include',
- '#include/GL/internal',
- '#src/gallium/include',
- '#src/gallium/auxiliary',
- '#src/gallium/drivers',
- '#src/mesa',
- '#src/mesa/main',
- '#src/mesa/glapi',
- '#src/mesa/math',
- '#src/mesa/transform',
- '#src/mesa/shader',
- '#src/mesa/swrast',
- '#src/mesa/swrast_setup',
- '#src/egl/main',
- '#src/egl/drivers/dri',
- ])
-
- drienv.ParseConfig('pkg-config --cflags --libs libdrm')
-
- COMMON_GALLIUM_SOURCES = [
- '#src/mesa/drivers/dri/common/utils.c',
- '#src/mesa/drivers/dri/common/vblank.c',
- '#src/mesa/drivers/dri/common/dri_util.c',
- '#src/mesa/drivers/dri/common/xmlconfig.c',
- ]
-
- COMMON_BM_SOURCES = [
- '#src/mesa/drivers/dri/common/dri_bufmgr.c',
- '#src/mesa/drivers/dri/common/dri_drmpool.c',
- ]
-
- Export([
- 'drienv',
- 'COMMON_GALLIUM_SOURCES',
- 'COMMON_BM_SOURCES',
- ])
-
- # TODO: Installation
- #install: $(LIBNAME)
- # $(INSTALL) -d $(DRI_DRIVER_INSTALL_DIR)
- # $(INSTALL) -m 755 $(LIBNAME) $(DRI_DRIVER_INSTALL_DIR)
-
- if 'vmware' in env['winsys']:
- SConscript([
- 'vmware/SConscript',
- ])
-
- if 'intel' in env['winsys']:
- SConscript([
- 'intel/SConscript',
- ])
-
- if 'i965' in env['winsys']:
- SConscript([
- 'i965/SConscript',
- ])
-
- if 'radeon' in env['winsys']:
- SConscript([
- 'radeon/SConscript',
- ])
diff --git a/src/gallium/winsys/drm/i965/Makefile b/src/gallium/winsys/drm/i965/Makefile
deleted file mode 100644
index d8feef6824..0000000000
--- a/src/gallium/winsys/drm/i965/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/intel/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
-
-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/i965/SConscript b/src/gallium/winsys/drm/i965/SConscript
deleted file mode 100644
index fdf57eedb9..0000000000
--- a/src/gallium/winsys/drm/i965/SConscript
+++ /dev/null
@@ -1,3 +0,0 @@
-Import('*')
-
-SConscript(['gem/SConscript',])
diff --git a/src/gallium/winsys/drm/i965/gem/Makefile b/src/gallium/winsys/drm/i965/gem/Makefile
deleted file mode 100644
index 6a7497b6be..0000000000
--- a/src/gallium/winsys/drm/i965/gem/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = i965drm
-
-C_SOURCES = \
- i965_drm_buffer.c \
- i965_drm_api.c
-
-LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
-
-LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/i965/gem/SConscript b/src/gallium/winsys/drm/i965/gem/SConscript
deleted file mode 100644
index 6256ec6eaf..0000000000
--- a/src/gallium/winsys/drm/i965/gem/SConscript
+++ /dev/null
@@ -1,15 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-i965drm_sources = [
- 'i965_drm_api.c',
- 'i965_drm_buffer.c',
-]
-
-i965drm = env.ConvenienceLibrary(
- target ='i965drm',
- source = i965drm_sources,
-)
-
-Export('i965drm')
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
deleted file mode 100644
index c644eedcb3..0000000000
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c
+++ /dev/null
@@ -1,122 +0,0 @@
-
-#include <stdio.h>
-#include "state_tracker/drm_api.h"
-
-#include "i965_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i965/brw_context.h" /* XXX: shouldn't be doing this */
-#include "i965/brw_screen.h" /* XXX: shouldn't be doing this */
-
-#include "trace/tr_drm.h"
-
-#include "../../sw/sw_drm_api.h"
-
-/*
- * Helper functions
- */
-
-
-static void
-i965_libdrm_get_device_id(unsigned int *device_id)
-{
- char path[512];
- FILE *file;
- void *shutup_gcc;
-
- /*
- * FIXME: Fix this up to use a drm ioctl or whatever.
- */
-
- snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
- file = fopen(path, "r");
- if (!file) {
- return;
- }
-
- shutup_gcc = fgets(path, sizeof(path), file);
- sscanf(path, "%x", device_id);
- fclose(file);
-}
-
-static void
-i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws)
-{
- struct i965_libdrm_winsys *idws = i965_libdrm_winsys(iws);
-
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
- drm_intel_bufmgr_destroy(idws->gem);
-
- FREE(idws);
-}
-
-static struct pipe_screen *
-i965_libdrm_create_screen(struct drm_api *api, int drmFD,
- struct drm_create_screen_arg *arg)
-{
- struct i965_libdrm_winsys *idws;
- unsigned int deviceID;
-
- debug_printf("%s\n", __FUNCTION__);
-
- if (arg != NULL) {
- switch(arg->mode) {
- case DRM_CREATE_NORMAL:
- break;
- default:
- return NULL;
- }
- }
-
- idws = CALLOC_STRUCT(i965_libdrm_winsys);
- if (!idws)
- return NULL;
-
- i965_libdrm_get_device_id(&deviceID);
-
- i965_libdrm_winsys_init_buffer_functions(idws);
-
- idws->fd = drmFD;
- idws->id = deviceID;
-
- idws->base.destroy = i965_libdrm_winsys_destroy;
-
- idws->gem = drm_intel_bufmgr_gem_init(idws->fd, BRW_BATCH_SIZE);
- drm_intel_bufmgr_gem_enable_reuse(idws->gem);
-
- idws->send_cmd = !debug_get_bool_option("BRW_NO_HW", FALSE);
-
- return brw_create_screen(&idws->base, deviceID);
-}
-
-
-static void
-destroy(struct drm_api *api)
-{
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
-}
-
-struct drm_api i965_libdrm_api =
-{
- .name = "i965",
- .create_screen = i965_libdrm_create_screen,
- .destroy = destroy,
-};
-
-struct drm_api *
-drm_api_create()
-{
- struct drm_api *api = NULL;
-
- if (api == NULL && debug_get_bool_option("BRW_SOFTPIPE", FALSE))
- api = sw_drm_api_create(&i965_libdrm_api);
-
- if (api == NULL)
- api = &i965_libdrm_api;
-
- return trace_drm_create(api);
-}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
deleted file mode 100644
index 33a17496b2..0000000000
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c
+++ /dev/null
@@ -1,503 +0,0 @@
-
-#include "state_tracker/drm_api.h"
-#include "i965_drm_winsys.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-
-#include "i915_drm.h"
-#include "intel_bufmgr.h"
-
-
-
-const char *names[BRW_BUFFER_TYPE_MAX] = {
- "TEXTURE",
- "SCANOUT",
- "VERTEX",
- "CURBE",
- "QUERY",
- "SHADER_CONSTANTS",
- "WM_SCRATCH",
- "BATCH",
- "GENERAL_STATE",
- "SURFACE_STATE",
- "PIXEL",
- "GENERIC",
-};
-
-const char *usages[BRW_USAGE_MAX] = {
- "STATE",
- "QUERY_RESULT",
- "RENDER_TARGET",
- "DEPTH_BUFFER",
- "BLIT_SOURCE",
- "BLIT_DEST",
- "SAMPLER",
- "VERTEX",
- "SCRATCH"
-};
-
-
-const char *data_types[BRW_DATA_MAX] =
-{
- "GS: CC_VP",
- "GS: CC_UNIT",
- "GS: WM_PROG",
- "GS: SAMPLER_DEFAULT_COLOR",
- "GS: SAMPLER",
- "GS: WM_UNIT",
- "GS: SF_PROG",
- "GS: SF_VP",
- "GS: SF_UNIT",
- "GS: VS_UNIT",
- "GS: VS_PROG",
- "GS: GS_UNIT",
- "GS: GS_PROG",
- "GS: CLIP_VP",
- "GS: CLIP_UNIT",
- "GS: CLIP_PROG",
- "SS: SURFACE",
- "SS: SURF_BIND",
- "CONSTANT DATA",
- "BATCH DATA",
- "(untyped)"
-};
-
-static enum pipe_error
-i965_libdrm_bo_alloc(struct brw_winsys_screen *sws,
- enum brw_buffer_type type,
- unsigned size,
- unsigned alignment,
- struct brw_winsys_buffer **bo_out)
-{
- struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
- struct i965_libdrm_buffer *buf;
-
- if (BRW_DUMP)
- debug_printf("%s type %s sz %d align %d\n",
- __FUNCTION__, names[type], size, alignment );
-
- buf = CALLOC_STRUCT(i965_libdrm_buffer);
- if (!buf)
- return PIPE_ERROR_OUT_OF_MEMORY;
-
- switch (type) {
- case BRW_BUFFER_TYPE_TEXTURE:
-/* case BRW_BUFFER_TYPE_SCANOUT:*/
- case BRW_BUFFER_TYPE_VERTEX:
- case BRW_BUFFER_TYPE_CURBE:
- case BRW_BUFFER_TYPE_QUERY:
- case BRW_BUFFER_TYPE_SHADER_CONSTANTS:
- case BRW_BUFFER_TYPE_SHADER_SCRATCH:
- case BRW_BUFFER_TYPE_BATCH:
- case BRW_BUFFER_TYPE_GENERAL_STATE:
- case BRW_BUFFER_TYPE_SURFACE_STATE:
- case BRW_BUFFER_TYPE_PIXEL:
- case BRW_BUFFER_TYPE_GENERIC:
- break;
- case BRW_BUFFER_TYPE_SCANOUT:
- buf->map_gtt = TRUE;
- break;
- default:
- assert(0);
- break;
- }
-
- buf->bo = drm_intel_bo_alloc(idws->gem,
- names[type],
- size,
- alignment);
-
- if (!buf->bo)
- goto err;
-
- pipe_reference_init(&buf->base.reference, 1);
- buf->base.size = size;
- buf->base.sws = sws;
-
- *bo_out = &buf->base;
- return PIPE_OK;
-
-err:
- assert(0);
- FREE(buf);
- return PIPE_ERROR_OUT_OF_MEMORY;
-}
-
-static enum pipe_error
-i965_libdrm_bo_from_handle(struct brw_winsys_screen *sws,
- struct winsys_handle *whandle,
- unsigned *stride,
- unsigned *tile,
- struct brw_winsys_buffer **bo_out)
-{
- struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws);
- struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer);
- uint32_t swizzle = 0;
-
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
- if (!buf)
- return PIPE_ERROR_OUT_OF_MEMORY;
-
- pipe_reference_init(&buf->base.reference, 1);
- buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, "FROM_HANDLE", whandle->handle);
- buf->base.size = buf->bo->size;
- buf->base.sws = &idws->base;
- buf->flinked = TRUE;
- buf->flink = whandle->handle;
-
-
- if (!buf->bo)
- goto err;
-
- drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle);
- if (buf->tiling != 0)
- buf->map_gtt = TRUE;
-
- *tile = buf->tiling;
- *stride = whandle->stride;
-
- *bo_out = &buf->base;
- return PIPE_OK;
-
-err:
- FREE(buf);
- return PIPE_ERROR_OUT_OF_MEMORY;
-}
-
-static enum pipe_error
-i965_libdrm_bo_get_handle(struct brw_winsys_buffer *buffer,
- struct winsys_handle *whandle,
- unsigned stride)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
- if (!buf->flinked) {
- if (drm_intel_bo_flink(buf->bo, &buf->flink))
- return PIPE_ERROR_BAD_INPUT;
- buf->flinked = TRUE;
- }
-
- whandle->handle = buf->flink;
- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
- whandle->handle = buf->bo->handle;
- } else {
- assert(!"unknown usage");
- return PIPE_ERROR_BAD_INPUT;
- }
-
- whandle->stride = stride;
- return PIPE_OK;
-}
-
-static void
-i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
- drm_intel_bo_unreference(buf->bo);
- FREE(buffer);
-}
-
-static enum pipe_error
-i965_libdrm_bo_emit_reloc(struct brw_winsys_buffer *buffer,
- enum brw_buffer_usage usage,
- unsigned delta,
- unsigned offset,
- struct brw_winsys_buffer *buffer2)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
- struct i965_libdrm_buffer *buf2 = i965_libdrm_buffer(buffer2);
- int read, write;
- int ret;
-
- if (BRW_DUMP)
- debug_printf("%s buf %p offset %x delta %x buf2 %p/%s/%s\n",
- __FUNCTION__, (void *)buffer,
- offset, delta,
- (void *)buffer2, names[buf2->data_type], usages[usage]);
-
- switch (usage) {
- case BRW_USAGE_STATE:
- read = I915_GEM_DOMAIN_INSTRUCTION;
- write = 0;
- break;
- case BRW_USAGE_QUERY_RESULT:
- read = I915_GEM_DOMAIN_INSTRUCTION;
- write = I915_GEM_DOMAIN_INSTRUCTION;
- break;
- case BRW_USAGE_RENDER_TARGET:
- read = I915_GEM_DOMAIN_RENDER;
- write = 0;
- break;
- case BRW_USAGE_DEPTH_BUFFER:
- read = I915_GEM_DOMAIN_RENDER;
- write = I915_GEM_DOMAIN_RENDER;
- break;
- case BRW_USAGE_BLIT_SOURCE:
- read = 0;
- write = I915_GEM_DOMAIN_RENDER;
- break;
- case BRW_USAGE_BLIT_DEST:
- read = I915_GEM_DOMAIN_RENDER;
- write = I915_GEM_DOMAIN_RENDER;
- break;
- case BRW_USAGE_SAMPLER:
- read = I915_GEM_DOMAIN_SAMPLER;
- write = 0;
- break;
- case BRW_USAGE_VERTEX:
- read = I915_GEM_DOMAIN_VERTEX;
- write = 0;
- break;
- case BRW_USAGE_SCRATCH:
- read = 0;
- write = 0;
- break;
- default:
- assert(0);
- return -1;
- }
-
- /* Needed??
- ((uint32_t *)buf->bo->virtual)[offset/4] = (delta +
- buf2->bo->offset);
- */
-
- ret = dri_bo_emit_reloc( buf->bo, read, write, delta, offset, buf2->bo );
- if (ret)
- return -1;
-
- return 0;
-}
-
-static enum pipe_error
-i965_libdrm_bo_exec(struct brw_winsys_buffer *buffer,
- unsigned bytes_used)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
- struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
- int ret;
-
- if (BRW_DUMP)
- debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
-
- if (idws->send_cmd) {
- ret = dri_bo_exec(buf->bo, bytes_used, NULL, 0, 0);
- if (ret)
- return PIPE_ERROR;
- }
-
- return PIPE_OK;
-}
-
-static enum pipe_error
-i965_libdrm_bo_subdata(struct brw_winsys_buffer *buffer,
- enum brw_buffer_data_type data_type,
- size_t offset,
- size_t size,
- const void *data,
- const struct brw_winsys_reloc *reloc,
- unsigned nr_reloc)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
- struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
- int ret, i;
-
- (void)data_type;
-
- if (BRW_DUMP)
- debug_printf("%s buf %p off %d sz %d %s relocs: %d\n",
- __FUNCTION__,
- (void *)buffer, offset, size,
- data_types[data_type],
- nr_reloc);
-
- if (BRW_DUMP)
- brw_dump_data( idws->id,
- data_type,
- buf->bo->offset + offset,
- data, size );
-
- /* XXX: use bo_map_gtt/memcpy/unmap_gtt under some circumstances???
- */
- ret = drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
- if (ret)
- return PIPE_ERROR;
-
- for (i = 0; i < nr_reloc; i++) {
- i965_libdrm_bo_emit_reloc(buffer, reloc[i].usage, reloc[i].delta,
- reloc[i].offset, reloc[i].bo);
- }
-
- return PIPE_OK;
-}
-
-static boolean
-i965_libdrm_bo_is_busy(struct brw_winsys_buffer *buffer)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
- boolean ret;
-
- if (BRW_DUMP)
- debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
-
- ret = drm_intel_bo_busy(buf->bo);
-
- if (BRW_DUMP)
- debug_printf(" --> %d\n", ret);
-
- return ret;
-}
-
-static boolean
-i965_libdrm_bo_references(struct brw_winsys_buffer *a,
- struct brw_winsys_buffer *b)
-{
- struct i965_libdrm_buffer *bufa = i965_libdrm_buffer(a);
- struct i965_libdrm_buffer *bufb = i965_libdrm_buffer(b);
- boolean ret;
-
- if (BRW_DUMP)
- debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
-
- ret = drm_intel_bo_references(bufa->bo, bufb->bo);
-
- if (BRW_DUMP)
- debug_printf(" --> %d\n", ret);
-
- return ret;
-}
-
-/* XXX: couldn't this be handled by returning true/false on
- * bo_emit_reloc?
- */
-static enum pipe_error
-i965_libdrm_check_aperture_space(struct brw_winsys_screen *iws,
- struct brw_winsys_buffer **buffers,
- unsigned count)
-{
- static drm_intel_bo *bos[128];
- int i;
- int ret;
-
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
- if (count > Elements(bos)) {
- assert(0);
- return FALSE;
- }
-
- for (i = 0; i < count; i++)
- bos[i] = i965_libdrm_buffer(buffers[i])->bo;
-
- /* XXX: converting from ??? to pipe_error:
- */
- ret = dri_bufmgr_check_aperture_space(bos, count);
-
- if (BRW_DUMP)
- debug_printf(" --> %d (ok == %d)\n", ret, PIPE_OK);
-
- return ret;
-}
-
-static void *
-i965_libdrm_bo_map(struct brw_winsys_buffer *buffer,
- enum brw_buffer_data_type data_type,
- unsigned offset,
- unsigned length,
- boolean write,
- boolean discard,
- boolean flush_explicit)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
- int ret;
-
-
- if (BRW_DUMP)
- debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer,
- write ? "read/write" : "read",
- write ? data_types[data_type] : "");
-
- if (!buf->map_count) {
- if (buf->map_gtt) {
- ret = drm_intel_gem_bo_map_gtt(buf->bo);
- if (ret)
- return NULL;
- }
- else {
- ret = drm_intel_bo_map(buf->bo, write);
- if (ret)
- return NULL;
- }
- }
-
- buf->data_type = data_type;
- buf->map_count++;
- return buf->bo->virtual;
-}
-
-static void
-i965_libdrm_bo_flush_range(struct brw_winsys_buffer *buffer,
- unsigned offset,
- unsigned length)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
- struct i965_libdrm_winsys *idws = i965_libdrm_winsys(buffer->sws);
-
- if (BRW_DUMP)
- debug_printf("%s %s offset %d len %d\n", __FUNCTION__,
- data_types[buf->data_type],
- offset, length);
-
- if (BRW_DUMP)
- brw_dump_data( idws->id,
- buf->data_type,
- buf->bo->offset + offset,
- buf->bo->virtual + offset,
- length );
-}
-
-static void
-i965_libdrm_bo_unmap(struct brw_winsys_buffer *buffer)
-{
- struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer);
-
- if (BRW_DUMP)
- debug_printf("%s\n", __FUNCTION__);
-
- if (--buf->map_count > 0)
- return;
-
- if (buf->map_gtt)
- drm_intel_gem_bo_unmap_gtt(buf->bo);
- else
- drm_intel_bo_unmap(buf->bo);
-}
-
-void
-i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws)
-{
- idws->base.bo_alloc = i965_libdrm_bo_alloc;
- idws->base.bo_from_handle = i965_libdrm_bo_from_handle;
- idws->base.bo_get_handle = i965_libdrm_bo_get_handle;
- idws->base.bo_destroy = i965_libdrm_bo_destroy;
- idws->base.bo_emit_reloc = i965_libdrm_bo_emit_reloc;
- idws->base.bo_exec = i965_libdrm_bo_exec;
- idws->base.bo_subdata = i965_libdrm_bo_subdata;
- idws->base.bo_is_busy = i965_libdrm_bo_is_busy;
- idws->base.bo_references = i965_libdrm_bo_references;
- idws->base.check_aperture_space = i965_libdrm_check_aperture_space;
- idws->base.bo_map = i965_libdrm_bo_map;
- idws->base.bo_flush_range = i965_libdrm_bo_flush_range;
- idws->base.bo_unmap = i965_libdrm_bo_unmap;
-}
diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h b/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
deleted file mode 100644
index c6a7d4a8c5..0000000000
--- a/src/gallium/winsys/drm/i965/gem/i965_drm_winsys.h
+++ /dev/null
@@ -1,64 +0,0 @@
-
-#ifndef INTEL_DRM_WINSYS_H
-#define INTEL_DRM_WINSYS_H
-
-#include "i965/brw_winsys.h"
-
-#include "drm.h"
-#include "intel_bufmgr.h"
-
-
-
-/*
- * Winsys
- */
-
-
-struct i965_libdrm_winsys
-{
- struct brw_winsys_screen base;
- drm_intel_bufmgr *gem;
-
- boolean send_cmd;
-
- int fd; /**< Drm file discriptor */
-
- unsigned id;
-};
-
-static INLINE struct i965_libdrm_winsys *
-i965_libdrm_winsys(struct brw_winsys_screen *iws)
-{
- return (struct i965_libdrm_winsys *)iws;
-}
-
-struct i965_libdrm_winsys *i965_libdrm_winsys_create(int fd, unsigned pci_id);
-
-void i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws);
-
-
-/* Buffer.
- */
-struct i965_libdrm_buffer {
- struct brw_winsys_buffer base;
-
- drm_intel_bo *bo;
-
- void *ptr;
- unsigned map_count;
- unsigned data_type; /* valid while mapped */
- unsigned tiling;
-
- boolean map_gtt;
- boolean flinked;
- unsigned flink;
-};
-
-static INLINE struct i965_libdrm_buffer *
-i965_libdrm_buffer(struct brw_winsys_buffer *buffer)
-{
- return (struct i965_libdrm_buffer *)buffer;
-}
-
-
-#endif
diff --git a/src/gallium/winsys/drm/i965/xlib/Makefile b/src/gallium/winsys/drm/i965/xlib/Makefile
deleted file mode 100644
index 0efa0ca6f9..0000000000
--- a/src/gallium/winsys/drm/i965/xlib/Makefile
+++ /dev/null
@@ -1,97 +0,0 @@
-# src/gallium/winsys/xlib/Makefile
-
-# This makefile produces a "stand-alone" libGL.so which is based on
-# Xlib (no DRI HW acceleration)
-
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-
-GL_MAJOR = 1
-GL_MINOR = 5
-GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
-
-
-INCLUDE_DIRS = \
- -I$(TOP)/include \
- -I$(TOP)/src/mesa \
- -I$(TOP)/src/mesa/main \
- -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/drivers/i965 \
- -I$(TOP)/src/gallium/drivers/i965/include \
- -I$(TOP)/src/gallium/state_trackers/glx/xlib \
- -I$(TOP)/src/gallium/auxiliary \
- -I/usr/include/drm
-
-XLIB_WINSYS_SOURCES = \
- xlib_i965.c \
-
-
-
-XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o)
-
-
-
-LIBS = \
- $(TOP)/src/gallium/drivers/i965/libi965.a \
- $(TOP)/src/gallium/drivers/trace/libtrace.a \
- $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \
- $(TOP)/src/mesa/libglapi.a \
- $(TOP)/src/mesa/libmesagallium.a \
- $(GALLIUM_AUXILIARIES)
-
-# $(TOP)/src/gallium/drivers/i965/lib/libi9xx.a \
-
-.SUFFIXES : .cpp
-
-.c.o:
- $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@
-
-.cpp.o:
- $(CXX) -c $(INCLUDE_DIRS) $(DEFINES) $(CXXFLAGS) $< -o $@
-
-
-
-default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME)
-
-$(TOP)/$(LIB_DIR)/gallium:
- @ mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-# Make the libGL.so library
-$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile
- $(TOP)/bin/mklib -o $(GL_LIB) \
- -linker "$(CC)" \
- -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
- -install $(TOP)/$(LIB_DIR)/gallium \
- $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \
- -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS)
-
-
-depend: $(XLIB_WINSYS_SOURCES)
- @ echo "running $(MKDEP)"
- @ rm -f depend # workaround oops on gutsy?!?
- @ touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \
- > /dev/null 2>/dev/null
-
-
-install: default
- $(INSTALL) -d $(INSTALL_DIR)/include/GL
- $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
- $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
- @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
- $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
- fi
-
-
-# Emacs tags
-tags:
- etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
-
-clean:
- -rm -f *.o
-
-
-include depend
diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
deleted file mode 100644
index 063e9f600b..0000000000
--- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c
+++ /dev/null
@@ -1,503 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 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
- * Brian Paul
- */
-
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "pipe/p_error.h"
-#include "pipe/p_context.h"
-
-#include "xm_public.h"
-
-#include "i965/brw_winsys.h"
-#include "i965/brw_screen.h"
-#include "i965/brw_reg.h"
-#include "i965/brw_structs_dump.h"
-
-#define MAX_VRAM (128*1024*1024)
-
-
-
-extern int brw_disasm (FILE *file,
- const struct brw_instruction *inst,
- unsigned count );
-
-extern int intel_decode(const uint32_t *data,
- int count,
- uint32_t hw_offset,
- uint32_t devid);
-
-struct xlib_brw_buffer
-{
- struct brw_winsys_buffer base;
- char *virtual;
- unsigned offset;
- unsigned type;
- int map_count;
- boolean modified;
-};
-
-
-/**
- * Subclass of brw_winsys_screen for Xlib winsys
- */
-struct xlib_brw_winsys
-{
- struct brw_winsys_screen base;
- struct brw_chipset chipset;
-
- unsigned size;
- unsigned used;
-};
-
-static struct xlib_brw_winsys *
-xlib_brw_winsys( struct brw_winsys_screen *screen )
-{
- return (struct xlib_brw_winsys *)screen;
-}
-
-
-static struct xlib_brw_buffer *
-xlib_brw_buffer( struct brw_winsys_buffer *buffer )
-{
- return (struct xlib_brw_buffer *)buffer;
-}
-
-
-
-const char *names[BRW_BUFFER_TYPE_MAX] = {
- "TEXTURE",
- "SCANOUT",
- "VERTEX",
- "CURBE",
- "QUERY",
- "SHADER_CONSTANTS",
- "WM_SCRATCH",
- "BATCH",
- "GENERAL_STATE",
- "SURFACE_STATE",
- "PIXEL",
- "GENERIC",
-};
-
-const char *usages[BRW_USAGE_MAX] = {
- "STATE",
- "QUERY_RESULT",
- "RENDER_TARGET",
- "DEPTH_BUFFER",
- "BLIT_SOURCE",
- "BLIT_DEST",
- "SAMPLER",
- "VERTEX",
- "SCRATCH"
-};
-
-
-const char *data_types[BRW_DATA_MAX] =
-{
- "GS: CC_VP",
- "GS: CC_UNIT",
- "GS: WM_PROG",
- "GS: SAMPLER_DEFAULT_COLOR",
- "GS: SAMPLER",
- "GS: WM_UNIT",
- "GS: SF_PROG",
- "GS: SF_VP",
- "GS: SF_UNIT",
- "GS: VS_UNIT",
- "GS: VS_PROG",
- "GS: GS_UNIT",
- "GS: GS_PROG",
- "GS: CLIP_VP",
- "GS: CLIP_UNIT",
- "GS: CLIP_PROG",
- "SS: SURFACE",
- "SS: SURF_BIND",
- "CONSTANT DATA",
- "BATCH DATA",
- "(untyped)"
-};
-
-
-static enum pipe_error
-xlib_brw_bo_alloc( struct brw_winsys_screen *sws,
- enum brw_buffer_type type,
- unsigned size,
- unsigned alignment,
- struct brw_winsys_buffer **bo_out )
-{
- struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
- struct xlib_brw_buffer *buf;
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s type %s sz %d align %d\n",
- __FUNCTION__, names[type], size, alignment );
-
- buf = CALLOC_STRUCT(xlib_brw_buffer);
- if (!buf)
- return PIPE_ERROR_OUT_OF_MEMORY;
-
- pipe_reference_init(&buf->base.reference, 1);
-
- buf->offset = align(xbw->used, alignment);
- buf->type = type;
- buf->virtual = MALLOC(size);
- buf->base.size = size;
- buf->base.sws = sws;
-
- xbw->used = align(xbw->used, alignment) + size;
- if (xbw->used > MAX_VRAM)
- goto err;
-
- /* XXX: possibly rentrant call to bo_destroy:
- */
- bo_reference(bo_out, &buf->base);
- return PIPE_OK;
-
-err:
- assert(0);
- FREE(buf->virtual);
- FREE(buf);
- return PIPE_ERROR_OUT_OF_MEMORY;
-}
-
-static void
-xlib_brw_bo_destroy( struct brw_winsys_buffer *buffer )
-{
- struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
- FREE(buf);
-}
-
-static int
-xlib_brw_bo_emit_reloc( struct brw_winsys_buffer *buffer,
- enum brw_buffer_usage usage,
- unsigned delta,
- unsigned offset,
- struct brw_winsys_buffer *buffer2)
-{
- struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
- struct xlib_brw_buffer *buf2 = xlib_brw_buffer(buffer2);
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s buf %p offset %x val %x + %x buf2 %p/%s/%s\n",
- __FUNCTION__, (void *)buffer, offset,
- buf2->offset, delta,
- (void *)buffer2, names[buf2->type], usages[usage]);
-
- *(uint32_t *)(buf->virtual + offset) = buf2->offset + delta;
-
- return 0;
-}
-
-static int
-xlib_brw_bo_exec( struct brw_winsys_buffer *buffer,
- unsigned bytes_used )
-{
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("execute buffer %p, bytes %d\n", (void *)buffer, bytes_used);
-
- return 0;
-}
-
-
-
-
-static int
-xlib_brw_bo_subdata(struct brw_winsys_buffer *buffer,
- enum brw_buffer_data_type data_type,
- size_t offset,
- size_t size,
- const void *data,
- const struct brw_winsys_reloc *reloc,
- unsigned nr_relocs)
-{
- struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
- struct xlib_brw_winsys *xbw = xlib_brw_winsys(buffer->sws);
- unsigned i;
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s buf %p off %d sz %d %s relocs: %d\n",
- __FUNCTION__,
- (void *)buffer, offset, size,
- data_types[data_type],
- nr_relocs);
-
- assert(buf->base.size >= offset + size);
- memcpy(buf->virtual + offset, data, size);
-
- /* Apply the relocations:
- */
- for (i = 0; i < nr_relocs; i++) {
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("\treloc[%d] usage %s off %d value %x+%x\n",
- i, usages[reloc[i].usage], reloc[i].offset,
- xlib_brw_buffer(reloc[i].bo)->offset, reloc[i].delta);
-
- *(unsigned *)(buf->virtual + offset + reloc[i].offset) =
- xlib_brw_buffer(reloc[i].bo)->offset + reloc[i].delta;
- }
-
- if (BRW_DUMP)
- brw_dump_data( xbw->chipset.pci_id,
- data_type,
- buf->offset + offset,
- buf->virtual + offset, size );
-
-
- return 0;
-}
-
-
-static boolean
-xlib_brw_bo_is_busy(struct brw_winsys_buffer *buffer)
-{
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
- return TRUE;
-}
-
-static boolean
-xlib_brw_bo_references(struct brw_winsys_buffer *a,
- struct brw_winsys_buffer *b)
-{
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s %p %p\n", __FUNCTION__, (void *)a, (void *)b);
- return TRUE;
-}
-
-static enum pipe_error
-xlib_brw_check_aperture_space( struct brw_winsys_screen *iws,
- struct brw_winsys_buffer **buffers,
- unsigned count )
-{
- unsigned tot_size = 0;
- unsigned i;
-
- for (i = 0; i < count; i++)
- tot_size += buffers[i]->size;
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s %d bufs, tot_size: %d kb\n",
- __FUNCTION__, count,
- (tot_size + 1023) / 1024);
-
- return PIPE_OK;
-}
-
-static void *
-xlib_brw_bo_map(struct brw_winsys_buffer *buffer,
- enum brw_buffer_data_type data_type,
- unsigned offset,
- unsigned length,
- boolean write,
- boolean discard,
- boolean explicit)
-{
- struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s %p %s %s\n", __FUNCTION__, (void *)buffer,
- write ? "read/write" : "read",
- write ? data_types[data_type] : "");
-
- if (write)
- buf->modified = 1;
-
- buf->map_count++;
- return buf->virtual;
-}
-
-
-static void
-xlib_brw_bo_flush_range( struct brw_winsys_buffer *buffer,
- unsigned offset,
- unsigned length )
-{
-}
-
-
-static void
-xlib_brw_bo_unmap(struct brw_winsys_buffer *buffer)
-{
- struct xlib_brw_buffer *buf = xlib_brw_buffer(buffer);
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s %p\n", __FUNCTION__, (void *)buffer);
-
- --buf->map_count;
- assert(buf->map_count >= 0);
-
- if (buf->map_count == 0 &&
- buf->modified) {
-
- buf->modified = 0;
-
- /* Consider dumping new buffer contents here, using the
- * flush-range info to minimize verbosity.
- */
- }
-}
-
-
-static void
-xlib_brw_bo_wait_idle( struct brw_winsys_buffer *buffer )
-{
-}
-
-
-static void
-xlib_brw_winsys_destroy( struct brw_winsys_screen *sws )
-{
- struct xlib_brw_winsys *xbw = xlib_brw_winsys(sws);
-
- FREE(xbw);
-}
-
-static struct brw_winsys_screen *
-xlib_create_brw_winsys_screen( void )
-{
- struct xlib_brw_winsys *ws;
-
- ws = CALLOC_STRUCT(xlib_brw_winsys);
- if (!ws)
- return NULL;
-
- ws->used = 0;
-
- ws->base.destroy = xlib_brw_winsys_destroy;
- ws->base.bo_alloc = xlib_brw_bo_alloc;
- ws->base.bo_destroy = xlib_brw_bo_destroy;
- ws->base.bo_emit_reloc = xlib_brw_bo_emit_reloc;
- ws->base.bo_exec = xlib_brw_bo_exec;
- ws->base.bo_subdata = xlib_brw_bo_subdata;
- ws->base.bo_is_busy = xlib_brw_bo_is_busy;
- ws->base.bo_references = xlib_brw_bo_references;
- ws->base.check_aperture_space = xlib_brw_check_aperture_space;
- ws->base.bo_map = xlib_brw_bo_map;
- ws->base.bo_flush_range = xlib_brw_bo_flush_range;
- ws->base.bo_unmap = xlib_brw_bo_unmap;
- ws->base.bo_wait_idle = xlib_brw_bo_wait_idle;
-
- return &ws->base;
-}
-
-
-/***********************************************************************
- * Implementation of Xlib co-state-tracker's winsys interface
- */
-
-static void
-xlib_i965_display_surface(struct xmesa_buffer *xm_buffer,
- struct pipe_surface *surf)
-{
- struct brw_surface *surface = brw_surface(surf);
- struct xlib_brw_buffer *bo = xlib_brw_buffer(surface->bo);
-
- if (BRW_DEBUG & DEBUG_WINSYS)
- debug_printf("%s offset %x+%x sz %dx%d\n", __FUNCTION__,
- bo->offset,
- surface->draw_offset,
- surf->width,
- surf->height);
-}
-
-static void
-xlib_i965_flush_frontbuffer(struct pipe_screen *screen,
- struct pipe_surface *surf,
- void *context_private)
-{
- xlib_i965_display_surface(NULL, surf);
-}
-
-
-static struct pipe_screen *
-xlib_create_i965_screen( void )
-{
- struct brw_winsys_screen *winsys;
- struct pipe_screen *screen;
-
- winsys = xlib_create_brw_winsys_screen();
- if (winsys == NULL)
- return NULL;
-
- screen = brw_create_screen(winsys, PCI_CHIP_GM45_GM);
- if (screen == NULL)
- goto fail;
-
- xlib_brw_winsys(winsys)->chipset = brw_screen(screen)->chipset;
-
- screen->flush_frontbuffer = xlib_i965_flush_frontbuffer;
- return screen;
-
-fail:
- if (winsys)
- winsys->destroy( winsys );
-
- return NULL;
-}
-
-
-
-
-
-struct xm_driver xlib_i965_driver =
-{
- .create_pipe_screen = xlib_create_i965_screen,
- .display_surface = xlib_i965_display_surface
-};
-
-
-/* Register this driver at library load:
- */
-static void _init( void ) __attribute__((constructor));
-static void _init( void )
-{
- xmesa_set_driver( &xlib_i965_driver );
-}
-
-
-
-/***********************************************************************
- *
- * Butt-ugly hack to convince the linker not to throw away public GL
- * symbols (they are all referenced from getprocaddress, I guess).
- */
-extern void (*linker_foo(const unsigned char *procName))();
-extern void (*glXGetProcAddress(const unsigned char *procName))();
-
-extern void (*linker_foo(const unsigned char *procName))()
-{
- return glXGetProcAddress(procName);
-}
diff --git a/src/gallium/winsys/drm/intel/Makefile b/src/gallium/winsys/drm/intel/Makefile
deleted file mode 100644
index d8feef6824..0000000000
--- a/src/gallium/winsys/drm/intel/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/intel/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = gem $(GALLIUM_STATE_TRACKERS_DIRS)
-
-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/intel/SConscript b/src/gallium/winsys/drm/intel/SConscript
deleted file mode 100644
index fdf57eedb9..0000000000
--- a/src/gallium/winsys/drm/intel/SConscript
+++ /dev/null
@@ -1,3 +0,0 @@
-Import('*')
-
-SConscript(['gem/SConscript',])
diff --git a/src/gallium/winsys/drm/intel/gem/Makefile b/src/gallium/winsys/drm/intel/gem/Makefile
deleted file mode 100644
index 0d6d4e37db..0000000000
--- a/src/gallium/winsys/drm/intel/gem/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = inteldrm
-
-C_SOURCES = \
- intel_drm_batchbuffer.c \
- intel_drm_buffer.c \
- intel_drm_fence.c \
- intel_drm_api.c
-
-LIBRARY_INCLUDES = $(shell pkg-config libdrm --cflags-only-I)
-
-LIBRARY_DEFINES = $(shell pkg-config libdrm --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/intel/gem/SConscript b/src/gallium/winsys/drm/intel/gem/SConscript
deleted file mode 100644
index 26717f391f..0000000000
--- a/src/gallium/winsys/drm/intel/gem/SConscript
+++ /dev/null
@@ -1,17 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-inteldrm_sources = [
- 'intel_drm_api.c',
- 'intel_drm_batchbuffer.c',
- 'intel_drm_buffer.c',
- 'intel_drm_fence.c',
-]
-
-inteldrm = env.ConvenienceLibrary(
- target ='inteldrm',
- source = inteldrm_sources,
-)
-
-Export('inteldrm')
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
deleted file mode 100644
index e3b980a832..0000000000
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <stdio.h>
-
-#include "state_tracker/drm_api.h"
-
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i915/i915_context.h"
-#include "i915/i915_screen.h"
-
-#include "trace/tr_drm.h"
-
-/*
- * Helper functions
- */
-
-
-static void
-intel_drm_get_device_id(unsigned int *device_id)
-{
- char path[512];
- FILE *file;
- void *shutup_gcc;
-
- /*
- * FIXME: Fix this up to use a drm ioctl or whatever.
- */
-
- snprintf(path, sizeof(path), "/sys/class/drm/card0/device/device");
- file = fopen(path, "r");
- if (!file) {
- return;
- }
-
- shutup_gcc = fgets(path, sizeof(path), file);
- (void) shutup_gcc;
- sscanf(path, "%x", device_id);
- fclose(file);
-}
-
-static void
-intel_drm_winsys_destroy(struct intel_winsys *iws)
-{
- struct intel_drm_winsys *idws = intel_drm_winsys(iws);
-
- drm_intel_bufmgr_destroy(idws->pools.gem);
-
- FREE(idws);
-}
-
-static struct pipe_screen *
-intel_drm_create_screen(struct drm_api *api, int drmFD,
- struct drm_create_screen_arg *arg)
-{
- struct intel_drm_winsys *idws;
- unsigned int deviceID;
-
- if (arg != NULL) {
- switch(arg->mode) {
- case DRM_CREATE_NORMAL:
- break;
- default:
- return NULL;
- }
- }
-
- idws = CALLOC_STRUCT(intel_drm_winsys);
- if (!idws)
- return NULL;
-
- intel_drm_get_device_id(&deviceID);
-
- intel_drm_winsys_init_batchbuffer_functions(idws);
- intel_drm_winsys_init_buffer_functions(idws);
- intel_drm_winsys_init_fence_functions(idws);
-
- idws->fd = drmFD;
- idws->id = deviceID;
- idws->max_batch_size = 16 * 4096;
-
- idws->base.destroy = intel_drm_winsys_destroy;
-
- idws->pools.gem = drm_intel_bufmgr_gem_init(idws->fd, idws->max_batch_size);
- drm_intel_bufmgr_gem_enable_reuse(idws->pools.gem);
-
- idws->dump_cmd = debug_get_bool_option("INTEL_DUMP_CMD", FALSE);
-
- return i915_create_screen(&idws->base, deviceID);
-}
-
-static void
-destroy(struct drm_api *api)
-{
-
-}
-
-struct drm_api intel_drm_api =
-{
- .name = "i915",
- .driver_name = "i915",
- .create_screen = intel_drm_create_screen,
- .destroy = destroy,
-};
-
-struct drm_api *
-drm_api_create()
-{
- return trace_drm_create(&intel_drm_api);
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c b/src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c
deleted file mode 100644
index 5b4dafc8e4..0000000000
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_batchbuffer.c
+++ /dev/null
@@ -1,244 +0,0 @@
-
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i915_drm.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
-
-#undef INTEL_RUN_SYNC
-#undef INTEL_MAP_BATCHBUFFER
-#undef INTEL_MAP_GTT
-#define INTEL_ALWAYS_FLUSH
-
-struct intel_drm_batchbuffer
-{
- struct intel_batchbuffer base;
-
- size_t actual_size;
-
- drm_intel_bo *bo;
-};
-
-static INLINE struct intel_drm_batchbuffer *
-intel_drm_batchbuffer(struct intel_batchbuffer *batch)
-{
- return (struct intel_drm_batchbuffer *)batch;
-}
-
-static void
-intel_drm_batchbuffer_reset(struct intel_drm_batchbuffer *batch)
-{
- struct intel_drm_winsys *idws = intel_drm_winsys(batch->base.iws);
- int ret;
-
- if (batch->bo)
- drm_intel_bo_unreference(batch->bo);
- batch->bo = drm_intel_bo_alloc(idws->pools.gem,
- "gallium3d_batchbuffer",
- batch->actual_size,
- 4096);
-
-#ifdef INTEL_MAP_BATCHBUFFER
-#ifdef INTEL_MAP_GTT
- ret = drm_intel_gem_bo_map_gtt(batch->bo);
-#else
- ret = drm_intel_bo_map(batch->bo, TRUE);
-#endif
- assert(ret == 0);
- batch->base.map = batch->bo->virtual;
-#else
- (void)ret;
-#endif
-
- memset(batch->base.map, 0, batch->actual_size);
- batch->base.ptr = batch->base.map;
- batch->base.size = batch->actual_size - BATCH_RESERVED;
- batch->base.relocs = 0;
-}
-
-static struct intel_batchbuffer *
-intel_drm_batchbuffer_create(struct intel_winsys *iws)
-{
- struct intel_drm_winsys *idws = intel_drm_winsys(iws);
- struct intel_drm_batchbuffer *batch = CALLOC_STRUCT(intel_drm_batchbuffer);
-
- batch->actual_size = idws->max_batch_size;
-
-#ifdef INTEL_MAP_BATCHBUFFER
- batch->base.map = NULL;
-#else
- batch->base.map = MALLOC(batch->actual_size);
-#endif
- batch->base.ptr = NULL;
- batch->base.size = 0;
-
- batch->base.relocs = 0;
- batch->base.max_relocs = 300;/*INTEL_DEFAULT_RELOCS;*/
-
- batch->base.iws = iws;
-
- intel_drm_batchbuffer_reset(batch);
-
- return &batch->base;
-}
-
-static int
-intel_drm_batchbuffer_reloc(struct intel_batchbuffer *ibatch,
- struct intel_buffer *buffer,
- enum intel_buffer_usage usage,
- unsigned pre_add)
-{
- struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch);
- unsigned write_domain = 0;
- unsigned read_domain = 0;
- unsigned offset;
- int ret = 0;
-
- assert(batch->base.relocs < batch->base.max_relocs);
-
- if (usage == INTEL_USAGE_SAMPLER) {
- write_domain = 0;
- read_domain = I915_GEM_DOMAIN_SAMPLER;
-
- } else if (usage == INTEL_USAGE_RENDER) {
- write_domain = I915_GEM_DOMAIN_RENDER;
- read_domain = I915_GEM_DOMAIN_RENDER;
-
- } else if (usage == INTEL_USAGE_2D_TARGET) {
- write_domain = I915_GEM_DOMAIN_RENDER;
- read_domain = I915_GEM_DOMAIN_RENDER;
-
- } else if (usage == INTEL_USAGE_2D_SOURCE) {
- write_domain = 0;
- read_domain = I915_GEM_DOMAIN_RENDER;
-
- } else if (usage == INTEL_USAGE_VERTEX) {
- write_domain = 0;
- read_domain = I915_GEM_DOMAIN_VERTEX;
-
- } else {
- assert(0);
- return -1;
- }
-
- offset = (unsigned)(batch->base.ptr - batch->base.map);
-
- ret = drm_intel_bo_emit_reloc(batch->bo, offset,
- intel_bo(buffer), pre_add,
- read_domain,
- write_domain);
-
- ((uint32_t*)batch->base.ptr)[0] = intel_bo(buffer)->offset + pre_add;
- batch->base.ptr += 4;
-
- if (!ret)
- batch->base.relocs++;
-
- return ret;
-}
-
-static void
-intel_drm_batchbuffer_flush(struct intel_batchbuffer *ibatch,
- struct pipe_fence_handle **fence)
-{
- struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch);
- unsigned used = 0;
- int ret = 0;
- int i;
-
- assert(intel_batchbuffer_space(ibatch) >= 0);
-
- used = batch->base.ptr - batch->base.map;
- assert((used & 3) == 0);
-
-
-#ifdef INTEL_ALWAYS_FLUSH
- /* MI_FLUSH | FLUSH_MAP_CACHE */
- intel_batchbuffer_dword(ibatch, (0x4<<23)|(1<<0));
- used += 4;
-#endif
-
- if ((used & 4) == 0) {
- /* MI_NOOP */
- intel_batchbuffer_dword(ibatch, 0);
- }
- /* MI_BATCH_BUFFER_END */
- intel_batchbuffer_dword(ibatch, (0xA<<23));
-
- used = batch->base.ptr - batch->base.map;
- assert((used & 4) == 0);
-
-#ifdef INTEL_MAP_BATCHBUFFER
-#ifdef INTEL_MAP_GTT
- drm_intel_gem_bo_unmap_gtt(batch->bo);
-#else
- drm_intel_bo_unmap(batch->bo);
-#endif
-#else
- drm_intel_bo_subdata(batch->bo, 0, used, batch->base.map);
-#endif
-
- /* Do the sending to HW */
- ret = drm_intel_bo_exec(batch->bo, used, NULL, 0, 0);
- assert(ret == 0);
-
- if (intel_drm_winsys(ibatch->iws)->dump_cmd) {
- unsigned *ptr;
- drm_intel_bo_map(batch->bo, FALSE);
- ptr = (unsigned*)batch->bo->virtual;
-
- debug_printf("%s:\n", __func__);
- for (i = 0; i < used / 4; i++, ptr++) {
- debug_printf("\t%08x: %08x\n", i*4, *ptr);
- }
-
- drm_intel_bo_unmap(batch->bo);
- } else {
-#ifdef INTEL_RUN_SYNC
- drm_intel_bo_map(batch->bo, FALSE);
- drm_intel_bo_unmap(batch->bo);
-#endif
- }
-
- if (fence) {
- ibatch->iws->fence_reference(ibatch->iws, fence, NULL);
-
-#ifdef INTEL_RUN_SYNC
- /* we run synced to GPU so just pass null */
- (*fence) = intel_drm_fence_create(NULL);
-#else
- (*fence) = intel_drm_fence_create(batch->bo);
-#endif
- }
-
- intel_drm_batchbuffer_reset(batch);
-}
-
-static void
-intel_drm_batchbuffer_destroy(struct intel_batchbuffer *ibatch)
-{
- struct intel_drm_batchbuffer *batch = intel_drm_batchbuffer(ibatch);
-
- if (batch->bo)
- drm_intel_bo_unreference(batch->bo);
-
-#ifndef INTEL_MAP_BATCHBUFFER
- FREE(batch->base.map);
-#endif
- FREE(batch);
-}
-
-void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws)
-{
- idws->base.batchbuffer_create = intel_drm_batchbuffer_create;
- idws->base.batchbuffer_reloc = intel_drm_batchbuffer_reloc;
- idws->base.batchbuffer_flush = intel_drm_batchbuffer_flush;
- idws->base.batchbuffer_destroy = intel_drm_batchbuffer_destroy;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c b/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c
deleted file mode 100644
index cb4f92a3b1..0000000000
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c
+++ /dev/null
@@ -1,217 +0,0 @@
-
-#include "state_tracker/drm_api.h"
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-
-#include "i915_drm.h"
-
-static struct intel_buffer *
-intel_drm_buffer_create(struct intel_winsys *iws,
- unsigned size, unsigned alignment,
- enum intel_buffer_type type)
-{
- struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer);
- struct intel_drm_winsys *idws = intel_drm_winsys(iws);
- drm_intel_bufmgr *pool;
- char *name;
-
- if (!buf)
- return NULL;
-
- buf->magic = 0xDEAD1337;
- buf->flinked = FALSE;
- buf->flink = 0;
- buf->map_gtt = FALSE;
-
- if (type == INTEL_NEW_TEXTURE) {
- name = "gallium3d_texture";
- pool = idws->pools.gem;
- } else if (type == INTEL_NEW_VERTEX) {
- name = "gallium3d_vertex";
- pool = idws->pools.gem;
- buf->map_gtt = TRUE;
- } else if (type == INTEL_NEW_SCANOUT) {
- name = "gallium3d_scanout";
- pool = idws->pools.gem;
- buf->map_gtt = TRUE;
- } else {
- assert(0);
- name = "gallium3d_unknown";
- pool = idws->pools.gem;
- }
-
- buf->bo = drm_intel_bo_alloc(pool, name, size, alignment);
-
- if (!buf->bo)
- goto err;
-
- return (struct intel_buffer *)buf;
-
-err:
- assert(0);
- FREE(buf);
- return NULL;
-}
-
-static struct intel_buffer *
-intel_drm_buffer_from_handle(struct intel_winsys *iws,
- struct winsys_handle *whandle,
- unsigned *stride)
-{
- struct intel_drm_winsys *idws = intel_drm_winsys(iws);
- struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer);
- uint32_t tile = 0, swizzle = 0;
-
- if (!buf)
- return NULL;
-
- buf->magic = 0xDEAD1337;
- buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, "gallium3d_from_handle", whandle->handle);
- buf->flinked = TRUE;
- buf->flink = whandle->handle;
-
- if (!buf->bo)
- goto err;
-
- drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle);
- if (tile != INTEL_TILE_NONE)
- buf->map_gtt = TRUE;
-
- *stride = whandle->stride;
-
- return (struct intel_buffer *)buf;
-
-err:
- FREE(buf);
- return NULL;
-}
-
-static boolean
-intel_drm_buffer_get_handle(struct intel_winsys *iws,
- struct intel_buffer *buffer,
- struct winsys_handle *whandle,
- unsigned stride)
-{
- struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-
- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
- if (!buf->flinked) {
- if (drm_intel_bo_flink(buf->bo, &buf->flink))
- return FALSE;
- buf->flinked = TRUE;
- }
-
- whandle->handle = buf->flink;
- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
- whandle->handle = buf->bo->handle;
- } else {
- assert(!"unknown usage");
- return FALSE;
- }
-
- whandle->stride = stride;
- return TRUE;
-}
-
-static int
-intel_drm_buffer_set_fence_reg(struct intel_winsys *iws,
- struct intel_buffer *buffer,
- unsigned stride,
- enum intel_buffer_tile tile)
-{
- struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
- assert(I915_TILING_NONE == INTEL_TILE_NONE);
- assert(I915_TILING_X == INTEL_TILE_X);
- assert(I915_TILING_Y == INTEL_TILE_Y);
-
- if (tile != INTEL_TILE_NONE) {
- assert(buf->map_count == 0);
- buf->map_gtt = TRUE;
- }
-
- return drm_intel_bo_set_tiling(buf->bo, &tile, stride);
-}
-
-static void *
-intel_drm_buffer_map(struct intel_winsys *iws,
- struct intel_buffer *buffer,
- boolean write)
-{
- struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
- drm_intel_bo *bo = intel_bo(buffer);
- int ret = 0;
-
- assert(bo);
-
- if (buf->map_count)
- goto out;
-
- if (buf->map_gtt)
- ret = drm_intel_gem_bo_map_gtt(bo);
- else
- ret = drm_intel_bo_map(bo, write);
-
- buf->ptr = bo->virtual;
-
- assert(ret == 0);
-out:
- if (ret)
- return NULL;
-
- buf->map_count++;
- return buf->ptr;
-}
-
-static void
-intel_drm_buffer_unmap(struct intel_winsys *iws,
- struct intel_buffer *buffer)
-{
- struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-
- if (--buf->map_count)
- return;
-
- if (buf->map_gtt)
- drm_intel_gem_bo_unmap_gtt(intel_bo(buffer));
- else
- drm_intel_bo_unmap(intel_bo(buffer));
-}
-
-static int
-intel_drm_buffer_write(struct intel_winsys *iws,
- struct intel_buffer *buffer,
- size_t offset,
- size_t size,
- const void *data)
-{
- struct intel_drm_buffer *buf = intel_drm_buffer(buffer);
-
- return drm_intel_bo_subdata(buf->bo, offset, size, (void*)data);
-}
-
-static void
-intel_drm_buffer_destroy(struct intel_winsys *iws,
- struct intel_buffer *buffer)
-{
- drm_intel_bo_unreference(intel_bo(buffer));
-
-#ifdef DEBUG
- intel_drm_buffer(buffer)->magic = 0;
- intel_drm_buffer(buffer)->bo = NULL;
-#endif
-
- FREE(buffer);
-}
-
-void
-intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws)
-{
- idws->base.buffer_create = intel_drm_buffer_create;
- idws->base.buffer_from_handle = intel_drm_buffer_from_handle;
- idws->base.buffer_get_handle = intel_drm_buffer_get_handle;
- idws->base.buffer_set_fence_reg = intel_drm_buffer_set_fence_reg;
- idws->base.buffer_map = intel_drm_buffer_map;
- idws->base.buffer_unmap = intel_drm_buffer_unmap;
- idws->base.buffer_write = intel_drm_buffer_write;
- idws->base.buffer_destroy = intel_drm_buffer_destroy;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c b/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
deleted file mode 100644
index 102faedfea..0000000000
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_fence.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-#include "intel_drm_winsys.h"
-#include "util/u_memory.h"
-#include "util/u_atomic.h"
-#include "util/u_inlines.h"
-
-/**
- * Because gem does not have fence's we have to create our own fences.
- *
- * They work by keeping the batchbuffer around and checking if that has
- * been idled. If bo is NULL fence has expired.
- */
-struct intel_drm_fence
-{
- struct pipe_reference reference;
- drm_intel_bo *bo;
-};
-
-
-struct pipe_fence_handle *
-intel_drm_fence_create(drm_intel_bo *bo)
-{
- struct intel_drm_fence *fence = CALLOC_STRUCT(intel_drm_fence);
-
- pipe_reference_init(&fence->reference, 1);
- /* bo is null if fence already expired */
- if (bo) {
- drm_intel_bo_reference(bo);
- fence->bo = bo;
- }
-
- return (struct pipe_fence_handle *)fence;
-}
-
-static void
-intel_drm_fence_reference(struct intel_winsys *iws,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- struct intel_drm_fence *old = (struct intel_drm_fence *)*ptr;
- struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
-
- if (pipe_reference(&((struct intel_drm_fence *)(*ptr))->reference, &f->reference)) {
- if (old->bo)
- drm_intel_bo_unreference(old->bo);
- FREE(old);
- }
- *ptr = fence;
-}
-
-static int
-intel_drm_fence_signalled(struct intel_winsys *iws,
- struct pipe_fence_handle *fence)
-{
- assert(0);
-
- return 0;
-}
-
-static int
-intel_drm_fence_finish(struct intel_winsys *iws,
- struct pipe_fence_handle *fence)
-{
- struct intel_drm_fence *f = (struct intel_drm_fence *)fence;
-
- /* fence already expired */
- if (!f->bo)
- return 0;
-
- drm_intel_bo_wait_rendering(f->bo);
- drm_intel_bo_unreference(f->bo);
- f->bo = NULL;
-
- return 0;
-}
-
-void
-intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws)
-{
- idws->base.fence_reference = intel_drm_fence_reference;
- idws->base.fence_signalled = intel_drm_fence_signalled;
- idws->base.fence_finish = intel_drm_fence_finish;
-}
diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h b/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h
deleted file mode 100644
index 9786ee9365..0000000000
--- a/src/gallium/winsys/drm/intel/gem/intel_drm_winsys.h
+++ /dev/null
@@ -1,77 +0,0 @@
-
-#ifndef INTEL_DRM_WINSYS_H
-#define INTEL_DRM_WINSYS_H
-
-#include "i915/intel_batchbuffer.h"
-
-#include "drm.h"
-#include "intel_bufmgr.h"
-
-
-/*
- * Winsys
- */
-
-
-struct intel_drm_winsys
-{
- struct intel_winsys base;
-
- boolean dump_cmd;
-
- int fd; /**< Drm file discriptor */
-
- unsigned id;
-
- size_t max_batch_size;
-
- struct {
- drm_intel_bufmgr *gem;
- } pools;
-};
-
-static INLINE struct intel_drm_winsys *
-intel_drm_winsys(struct intel_winsys *iws)
-{
- return (struct intel_drm_winsys *)iws;
-}
-
-struct intel_drm_winsys * intel_drm_winsys_create(int fd, unsigned pci_id);
-struct pipe_fence_handle * intel_drm_fence_create(drm_intel_bo *bo);
-
-void intel_drm_winsys_init_batchbuffer_functions(struct intel_drm_winsys *idws);
-void intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws);
-void intel_drm_winsys_init_fence_functions(struct intel_drm_winsys *idws);
-
-
-/*
- * Buffer
- */
-
-
-struct intel_drm_buffer {
- unsigned magic;
-
- drm_intel_bo *bo;
-
- void *ptr;
- unsigned map_count;
- boolean map_gtt;
-
- boolean flinked;
- unsigned flink;
-};
-
-static INLINE struct intel_drm_buffer *
-intel_drm_buffer(struct intel_buffer *buffer)
-{
- return (struct intel_drm_buffer *)buffer;
-}
-
-static INLINE drm_intel_bo *
-intel_bo(struct intel_buffer *buffer)
-{
- return intel_drm_buffer(buffer)->bo;
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/nouveau/Makefile b/src/gallium/winsys/drm/nouveau/Makefile
deleted file mode 100644
index 6c9cbef26d..0000000000
--- a/src/gallium/winsys/drm/nouveau/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/nouveau/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = drm $(GALLIUM_STATE_TRACKERS_DIRS)
-
-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/nouveau/drm/Makefile b/src/gallium/winsys/drm/nouveau/drm/Makefile
deleted file mode 100644
index 54c3b26c75..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = nouveaudrm
-
-C_SOURCES = nouveau_drm_api.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_dri.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h
deleted file mode 100644
index 1207c2d609..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_dri.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef _NOUVEAU_DRI_
-#define _NOUVEAU_DRI_
-
-#include "xf86drm.h"
-#include "drm.h"
-#include "nouveau_drm.h"
-
-struct nouveau_dri {
- uint32_t device_id; /**< \brief PCI device ID */
- uint32_t width; /**< \brief width in pixels of display */
- uint32_t height; /**< \brief height in scanlines of display */
- uint32_t depth; /**< \brief depth of display (8, 15, 16, 24) */
- uint32_t bpp; /**< \brief bit depth of display (8, 16, 24, 32) */
-
- uint32_t bus_type; /**< \brief ths bus type */
- uint32_t bus_mode; /**< \brief bus mode (used for AGP, maybe also for PCI-E ?) */
-
- uint32_t front_offset; /**< \brief front buffer offset */
- uint32_t front_pitch; /**< \brief front buffer pitch */
- uint32_t back_offset; /**< \brief private back buffer offset */
- uint32_t back_pitch; /**< \brief private back buffer pitch */
- uint32_t depth_offset; /**< \brief private depth buffer offset */
- uint32_t depth_pitch; /**< \brief private depth buffer pitch */
-
-};
-
-#endif
-
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
deleted file mode 100644
index 716d4bacd3..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
+++ /dev/null
@@ -1,157 +0,0 @@
-#include "pipe/p_context.h"
-#include "pipe/p_state.h"
-#include "util/u_format.h"
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-
-#include "nouveau_drm_api.h"
-
-#include "nouveau_drmif.h"
-#include "nouveau_channel.h"
-#include "nouveau_bo.h"
-
-#include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_screen.h"
-
-static struct pipe_surface *
-dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
- unsigned handle, enum pipe_format format,
- unsigned width, unsigned height, unsigned pitch)
-{
- struct pipe_surface *ps = NULL;
- struct pipe_texture *pt = NULL;
- struct pipe_texture tmpl;
- struct winsys_handle whandle;
-
- memset(&tmpl, 0, sizeof(tmpl));
- tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT;
- tmpl.target = PIPE_TEXTURE_2D;
- tmpl.last_level = 0;
- tmpl.depth0 = 1;
- tmpl.format = format;
- tmpl.width0 = width;
- tmpl.height0 = height;
-
- memset(&whandle, 0, sizeof(whandle));
- whandle.stride = pitch;
- whandle.handle = handle;
-
- pt = pscreen->texture_from_handle(pscreen, &tmpl, &whandle);
- if (!pt)
- return NULL;
-
- ps = pscreen->get_tex_surface(pscreen, pt, 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(&pt, NULL);
- return ps;
-}
-
-static struct pipe_surface *
-nouveau_dri1_front_surface(struct pipe_context *pipe)
-{
- return nouveau_winsys_screen(pipe->screen)->front;
-}
-
-static struct dri1_api nouveau_dri1_api = {
- nouveau_dri1_front_surface,
-};
-
-static void
-nouveau_drm_destroy_winsys(struct pipe_winsys *s)
-{
- struct nouveau_winsys *nv_winsys = nouveau_winsys(s);
- struct nouveau_screen *nv_screen= nouveau_screen(nv_winsys->pscreen);
- nouveau_device_close(&nv_screen->device);
- FREE(nv_winsys);
-}
-
-static struct pipe_screen *
-nouveau_drm_create_screen(struct drm_api *api, int fd,
- struct drm_create_screen_arg *arg)
-{
- struct dri1_create_screen_arg *dri1 = (void *)arg;
- struct nouveau_winsys *nvws;
- struct pipe_winsys *ws;
- struct nouveau_device *dev = NULL;
- struct pipe_screen *(*init)(struct pipe_winsys *,
- struct nouveau_device *);
- int ret;
-
- ret = nouveau_device_open_existing(&dev, 0, fd, 0);
- if (ret)
- return NULL;
-
- switch (dev->chipset & 0xf0) {
- case 0x30:
- case 0x40:
- case 0x60:
- init = nvfx_screen_create;
- break;
- case 0x50:
- 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;
- }
-
- nvws = CALLOC_STRUCT(nouveau_winsys);
- if (!nvws) {
- nouveau_device_close(&dev);
- return NULL;
- }
- ws = &nvws->base;
- ws->destroy = nouveau_drm_destroy_winsys;
-
- nvws->pscreen = init(ws, dev);
- if (!nvws->pscreen) {
- ws->destroy(ws);
- return NULL;
- }
-
- if (arg && arg->mode == DRM_CREATE_DRI1) {
- struct nouveau_dri *nvdri = dri1->ddx_info;
- enum pipe_format format;
-
- if (nvdri->bpp == 16)
- format = PIPE_FORMAT_B5G6R5_UNORM;
- else
- format = PIPE_FORMAT_B8G8R8A8_UNORM;
-
- nvws->front = dri_surface_from_handle(api, nvws->pscreen,
- nvdri->front_offset,
- format, nvdri->width,
- nvdri->height,
- nvdri->front_pitch *
- (nvdri->bpp / 8));
- if (!nvws->front) {
- debug_printf("%s: error referencing front buffer\n",
- __func__);
- ws->destroy(ws);
- return NULL;
- }
-
- dri1->api = &nouveau_dri1_api;
- }
-
- return nvws->pscreen;
-}
-
-struct drm_api drm_api_hooks = {
- .name = "nouveau",
- .driver_name = "nouveau",
- .create_screen = nouveau_drm_create_screen,
-};
-
-struct drm_api *
-drm_api_create() {
- return &drm_api_hooks;
-}
-
diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
deleted file mode 100644
index a91aad7df8..0000000000
--- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __NOUVEAU_DRM_API_H__
-#define __NOUVEAU_DRM_API_H__
-
-#include "state_tracker/drm_api.h"
-#include "state_tracker/dri1_api.h"
-
-#include "util/u_simple_screen.h"
-
-#include "nouveau_dri.h"
-
-struct nouveau_winsys {
- struct pipe_winsys base;
-
- struct pipe_screen *pscreen;
-
- struct pipe_surface *front;
-};
-
-static INLINE struct nouveau_winsys *
-nouveau_winsys(struct pipe_winsys *ws)
-{
- return (struct nouveau_winsys *)ws;
-}
-
-static INLINE struct nouveau_winsys *
-nouveau_winsys_screen(struct pipe_screen *pscreen)
-{
- return nouveau_winsys(pscreen->winsys);
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/Makefile b/src/gallium/winsys/drm/radeon/Makefile
deleted file mode 100644
index bacdf3de28..0000000000
--- a/src/gallium/winsys/drm/radeon/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/radeon/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-
-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/SConscript b/src/gallium/winsys/drm/radeon/SConscript
deleted file mode 100644
index eff87e7d01..0000000000
--- a/src/gallium/winsys/drm/radeon/SConscript
+++ /dev/null
@@ -1,3 +0,0 @@
-Import('*')
-
-SConscript(['core/SConscript',])
diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/drm/radeon/core/Makefile
deleted file mode 100644
index 13bbbf730d..0000000000
--- a/src/gallium/winsys/drm/radeon/core/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = radeonwinsys
-
-C_SOURCES = \
- radeon_drm_buffer.c \
- radeon_drm.c \
- radeon_r300.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/core/SConscript b/src/gallium/winsys/drm/radeon/core/SConscript
deleted file mode 100644
index f4e9c397bd..0000000000
--- a/src/gallium/winsys/drm/radeon/core/SConscript
+++ /dev/null
@@ -1,18 +0,0 @@
-Import('*')
-
-env = drienv.Clone()
-
-radeon_sources = [
- 'radeon_buffer.c',
- 'radeon_drm.c',
- 'radeon_r300.c',
-]
-
-env.Append(CPPPATH = '#/src/gallium/drivers/r300')
-
-radeonwinsys = env.ConvenienceLibrary(
- target ='radeonwinsys',
- source = radeon_sources,
-)
-
-Export('radeonwinsys')
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
deleted file mode 100644
index 218a376301..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
+++ /dev/null
@@ -1,86 +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_BUFFER_H
-#define RADEON_BUFFER_H
-
-#include <stdio.h>
-
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-#include "radeon_bo.h"
-#include "radeon_cs.h"
-
-#include "radeon_winsys.h"
-
-
-#define RADEON_MAX_BOS 24
-
-static INLINE struct pb_buffer *
-radeon_pb_buffer(struct r300_winsys_buffer *buffer)
-{
- return (struct pb_buffer *)buffer;
-}
-
-static INLINE struct r300_winsys_buffer *
-radeon_libdrm_winsys_buffer(struct pb_buffer *buffer)
-{
- return (struct r300_winsys_buffer *)buffer;
-}
-
-struct pb_manager *
-radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws);
-
-boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
- uint32_t rd, uint32_t wd);
-
-
-void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
- uint32_t rd, uint32_t wd,
- uint32_t flags);
-
-struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
- uint32_t handle);
-
-void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf,
- enum r300_buffer_tiling microtiled,
- enum r300_buffer_tiling macrotiled,
- uint32_t pitch);
-
-void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr);
-
-boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
- struct winsys_handle *whandle);
-
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf);
-#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
deleted file mode 100644
index 3dfcc5aef0..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * 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>
- * Joakim Sindholt <opensource@zhasha.com>
- */
-
-#include "radeon_drm.h"
-#include "radeon_r300.h"
-#include "radeon_buffer.h"
-
-#include "r300_winsys.h"
-#include "trace/tr_drm.h"
-
-#include "util/u_memory.h"
-
-#include "xf86drm.h"
-#include <sys/ioctl.h>
-
-static struct radeon_libdrm_winsys *
-radeon_winsys_create(int fd)
-{
- struct radeon_libdrm_winsys *rws;
-
- rws = CALLOC_STRUCT(radeon_libdrm_winsys);
- if (rws == NULL) {
- return NULL;
- }
-
- rws->fd = fd;
- return rws;
-}
-
-/* Helper function to do the ioctls needed for setup and init. */
-static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys)
-{
- struct drm_radeon_gem_info gem_info = {0};
- struct drm_radeon_info info = {0};
- int target = 0;
- int retval;
- drmVersionPtr version;
-
- info.value = (unsigned long)&target;
-
- /* We do things in a specific order here.
- *
- * DRM version first. We need to be sure we're running on a KMS chipset.
- * This is also for some features.
- *
- * Then, the PCI ID. This is essential and should return usable numbers
- * for all Radeons. If this fails, we probably got handed an FD for some
- * non-Radeon card.
- *
- * The GB and Z pipe requests should always succeed, but they might not
- * return sensical values for all chipsets, but that's alright because
- * the pipe drivers already know that.
- *
- * The GEM info is actually bogus on the kernel side, as well as our side
- * (see radeon_gem_info_ioctl in radeon_gem.c) but that's alright because
- * we don't actually use the info for anything yet. */
-
- version = drmGetVersion(fd);
- if (version->version_major != 2) {
- fprintf(stderr, "%s: DRM version is %d.%d.%d but this driver is "
- "only compatible with 2.x.x\n", __FUNCTION__,
- version->version_major, version->version_minor,
- version->version_patchlevel);
- drmFreeVersion(version);
- exit(1);
- }
-
-/* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */
-#ifdef RADEON_BO_FLAGS_MICRO_TILE_SQUARE
- // Supported since 2.1.0.
- winsys->squaretiling = version->version_major > 2 ||
- version->version_minor >= 1;
-#endif
-
- info.request = RADEON_INFO_DEVICE_ID;
- retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get PCI ID, "
- "error number %d\n", __FUNCTION__, retval);
- exit(1);
- }
- winsys->pci_id = target;
-
- info.request = RADEON_INFO_NUM_GB_PIPES;
- retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get GB pipe count, "
- "error number %d\n", __FUNCTION__, retval);
- exit(1);
- }
- winsys->gb_pipes = target;
-
- info.request = RADEON_INFO_NUM_Z_PIPES;
- retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get Z pipe count, "
- "error number %d\n", __FUNCTION__, retval);
- exit(1);
- }
- winsys->z_pipes = target;
-
- retval = drmCommandWriteRead(fd, DRM_RADEON_GEM_INFO,
- &gem_info, sizeof(gem_info));
- if (retval) {
- fprintf(stderr, "%s: Failed to get MM info, error number %d\n",
- __FUNCTION__, retval);
- exit(1);
- }
- winsys->gart_size = gem_info.gart_size;
- winsys->vram_size = gem_info.vram_size;
-
- debug_printf("radeon: Successfully grabbed chipset info from kernel!\n"
- "radeon: DRM version: %d.%d.%d ID: 0x%04x GB: %d Z: %d\n"
- "radeon: GART size: %d MB VRAM size: %d MB\n",
- version->version_major, version->version_minor,
- version->version_patchlevel, winsys->pci_id,
- winsys->gb_pipes, winsys->z_pipes,
- winsys->gart_size / 1024 / 1024,
- winsys->vram_size / 1024 / 1024);
-
- drmFreeVersion(version);
-}
-
-/* Create a pipe_screen. */
-struct pipe_screen* radeon_create_screen(struct drm_api* api,
- int drmFB,
- struct drm_create_screen_arg *arg)
-{
- struct radeon_libdrm_winsys* rws;
- boolean ret;
-
- rws = radeon_winsys_create(drmFB);
- if (!rws)
- return NULL;
-
- do_ioctls(drmFB, rws);
-
- /* The state tracker can organize a softpipe fallback if no hw
- * driver is found.
- */
- if (is_r3xx(rws->pci_id)) {
- ret = radeon_setup_winsys(drmFB, rws);
- if (ret == FALSE)
- goto fail;
- return r300_create_screen(&rws->base);
- }
-
-fail:
- FREE(rws);
- return NULL;
-}
-
-static void radeon_drm_api_destroy(struct drm_api *api)
-{
- return;
-}
-
-struct drm_api drm_api_hooks = {
- .name = "radeon",
- .driver_name = "radeon",
- .create_screen = radeon_create_screen,
- .destroy = radeon_drm_api_destroy,
-};
-
-struct drm_api* drm_api_create()
-{
-#ifdef DEBUG
- return trace_drm_create(&drm_api_hooks);
-#else
- return &drm_api_hooks;
-#endif
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
deleted file mode 100644
index 2dc077c052..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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>
- */
-#ifndef RADEON_DRM_H
-#define RADEON_DRM_H
-
-#include "state_tracker/drm_api.h"
-
-
-struct pipe_screen* radeon_create_screen(struct drm_api* api,
- int drmFB,
- struct drm_create_screen_arg *arg);
-
-boolean radeon_buffer_from_texture(struct drm_api* api,
- struct pipe_screen* screen,
- struct pipe_texture* texture,
- struct pipe_buffer** buffer,
- unsigned* stride);
-
-boolean radeon_handle_from_buffer(struct drm_api* api,
- struct pipe_screen* screen,
- struct pipe_buffer* buffer,
- unsigned* handle);
-
-boolean radeon_global_handle_from_buffer(struct drm_api* api,
- struct pipe_screen* screen,
- struct pipe_buffer* buffer,
- unsigned* handle);
-
-void radeon_destroy_drm_api(struct drm_api* api);
-
-/* Guess at whether this chipset should use r300g.
- *
- * I believe that this check is valid, but I haven't been exhaustive. */
-static INLINE boolean is_r3xx(int pciid)
-{
- return (pciid > 0x3150) && (pciid < 0x796f);
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
deleted file mode 100644
index 66f6132245..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
+++ /dev/null
@@ -1,385 +0,0 @@
-
-#include <sys/ioctl.h>
-#include "radeon_drm.h"
-#include "radeon_bo_gem.h"
-#include "radeon_cs_gem.h"
-#include "radeon_buffer.h"
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_simple_list.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-#include "radeon_winsys.h"
-struct radeon_drm_bufmgr;
-
-struct radeon_drm_buffer {
- struct pb_buffer base;
- struct radeon_drm_bufmgr *mgr;
-
- struct radeon_bo *bo;
-
- boolean flinked;
- uint32_t flink;
-
- struct radeon_drm_buffer *next, *prev;
-};
-
-extern const struct pb_vtbl radeon_drm_buffer_vtbl;
-
-
-static INLINE struct radeon_drm_buffer *
-radeon_drm_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- assert(buf->vtbl == &radeon_drm_buffer_vtbl);
- return (struct radeon_drm_buffer *)buf;
-}
-
-struct radeon_drm_bufmgr {
- struct pb_manager base;
- struct radeon_libdrm_winsys *rws;
- struct radeon_drm_buffer buffer_map_list;
-};
-
-static INLINE struct radeon_drm_bufmgr *
-radeon_drm_bufmgr(struct pb_manager *mgr)
-{
- assert(mgr);
- return (struct radeon_drm_bufmgr *)mgr;
-}
-
-static void
-radeon_drm_buffer_destroy(struct pb_buffer *_buf)
-{
- struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
-
- if (buf->bo->ptr != NULL) {
- remove_from_list(buf);
- radeon_bo_unmap(buf->bo);
- buf->bo->ptr = NULL;
- }
- radeon_bo_unref(buf->bo);
-
- FREE(buf);
-}
-
-static void *
-radeon_drm_buffer_map(struct pb_buffer *_buf,
- unsigned flags)
-{
- struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
- int write = 0;
-
- if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
- if ((_buf->base.usage & PIPE_BUFFER_USAGE_VERTEX) ||
- (_buf->base.usage & PIPE_BUFFER_USAGE_INDEX))
- if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs))
- return NULL;
- }
-
- if (buf->bo->ptr != NULL)
- return buf->bo->ptr;
-
- if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
- uint32_t domain;
- if (radeon_bo_is_busy(buf->bo, &domain))
- return NULL;
- }
-
- if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
- buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
- }
-
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
- write = 1;
- }
-
- if (radeon_bo_map(buf->bo, write)) {
- return NULL;
- }
- insert_at_tail(&buf->mgr->buffer_map_list, buf);
- return buf->bo->ptr;
-}
-
-static void
-radeon_drm_buffer_unmap(struct pb_buffer *_buf)
-{
- (void)_buf;
-}
-
-static void
-radeon_drm_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- *base_buf = buf;
- *offset = 0;
-}
-
-
-static enum pipe_error
-radeon_drm_buffer_validate(struct pb_buffer *_buf,
- struct pb_validate *vl,
- unsigned flags)
-{
- /* Always pinned */
- return PIPE_OK;
-}
-
-static void
-radeon_drm_buffer_fence(struct pb_buffer *buf,
- struct pipe_fence_handle *fence)
-{
-}
-
-const struct pb_vtbl radeon_drm_buffer_vtbl = {
- radeon_drm_buffer_destroy,
- radeon_drm_buffer_map,
- radeon_drm_buffer_unmap,
- radeon_drm_buffer_validate,
- radeon_drm_buffer_fence,
- radeon_drm_buffer_get_base_buffer,
-};
-
-
-static uint32_t radeon_domain_from_usage(unsigned usage)
-{
- uint32_t domain = 0;
-
- if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
- domain |= RADEON_GEM_DOMAIN_VRAM;
- }
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
- domain |= RADEON_GEM_DOMAIN_VRAM;
- }
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
- domain |= RADEON_GEM_DOMAIN_GTT;
- }
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
- domain |= RADEON_GEM_DOMAIN_GTT;
- }
-
- return domain;
-}
-
-struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
- uint32_t handle)
-{
- struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
- struct radeon_libdrm_winsys *rws = mgr->rws;
- struct radeon_drm_buffer *buf;
- struct radeon_bo *bo;
-
- bo = radeon_bo_open(rws->bom, handle, 0,
- 0, 0, 0);
- if (bo == NULL)
- return NULL;
-
- buf = CALLOC_STRUCT(radeon_drm_buffer);
- if (!buf) {
- radeon_bo_unref(bo);
- return NULL;
- }
-
- make_empty_list(buf);
-
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = 0;
- buf->base.base.usage = PIPE_BUFFER_USAGE_PIXEL;
- buf->base.base.size = 0;
- buf->base.vtbl = &radeon_drm_buffer_vtbl;
- buf->mgr = mgr;
-
- buf->bo = bo;
-
- return &buf->base;
-}
-
-static struct pb_buffer *
-radeon_drm_bufmgr_create_buffer(struct pb_manager *_mgr,
- pb_size size,
- const struct pb_desc *desc)
-{
- struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
- struct radeon_libdrm_winsys *rws = mgr->rws;
- struct radeon_drm_buffer *buf;
- uint32_t domain;
-
- buf = CALLOC_STRUCT(radeon_drm_buffer);
- if (!buf)
- goto error1;
-
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
- buf->base.vtbl = &radeon_drm_buffer_vtbl;
- buf->mgr = mgr;
-
- make_empty_list(buf);
- domain = radeon_domain_from_usage(desc->usage);
- buf->bo = radeon_bo_open(rws->bom, 0, size,
- desc->alignment, domain, 0);
- if (buf->bo == NULL)
- goto error2;
-
- return &buf->base;
-
- error2:
- FREE(buf);
- error1:
- return NULL;
-}
-
-static void
-radeon_drm_bufmgr_flush(struct pb_manager *mgr)
-{
- /* NOP */
-}
-
-static void
-radeon_drm_bufmgr_destroy(struct pb_manager *_mgr)
-{
- struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
- FREE(mgr);
-}
-
-struct pb_manager *
-radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws)
-{
- struct radeon_drm_bufmgr *mgr;
-
- mgr = CALLOC_STRUCT(radeon_drm_bufmgr);
- if (!mgr)
- return NULL;
-
- mgr->base.destroy = radeon_drm_bufmgr_destroy;
- mgr->base.create_buffer = radeon_drm_bufmgr_create_buffer;
- mgr->base.flush = radeon_drm_bufmgr_flush;
-
- mgr->rws = rws;
- make_empty_list(&mgr->buffer_map_list);
- return &mgr->base;
-}
-
-static struct radeon_drm_buffer *get_drm_buffer(struct pb_buffer *_buf)
-{
- struct radeon_drm_buffer *buf;
- if (_buf->vtbl == &radeon_drm_buffer_vtbl) {
- buf = radeon_drm_buffer(_buf);
- } else {
- struct pb_buffer *base_buf;
- pb_size offset;
- pb_get_base_buffer(_buf, &base_buf, &offset);
-
- buf = radeon_drm_buffer(base_buf);
- }
- return buf;
-}
-
-boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
- struct winsys_handle *whandle)
-{
- int retval, fd;
- struct drm_gem_flink flink;
- struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
- if (!buf->flinked) {
- fd = buf->mgr->rws->fd;
- flink.handle = buf->bo->handle;
-
- retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
- if (retval) {
- return FALSE;
- }
-
- buf->flinked = TRUE;
- buf->flink = flink.name;
- }
- whandle->handle = buf->flink;
- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
- whandle->handle = buf->bo->handle;
- }
- return TRUE;
-}
-
-
-void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf,
- enum r300_buffer_tiling microtiled,
- enum r300_buffer_tiling macrotiled,
- uint32_t pitch)
-{
- struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
- uint32_t flags = 0, old_flags, old_pitch;
- if (microtiled == R300_BUFFER_TILED)
- flags |= RADEON_BO_FLAGS_MICRO_TILE;
-/* XXX Remove this ifdef when libdrm version 2.4.19 becomes mandatory. */
-#ifdef RADEON_BO_FLAGS_MICRO_TILE_SQUARE
- else if (microtiled == R300_BUFFER_SQUARETILED)
- flags |= RADEON_BO_FLAGS_MICRO_TILE_SQUARE;
-#endif
- if (macrotiled == R300_BUFFER_TILED)
- flags |= RADEON_BO_FLAGS_MACRO_TILE;
-
- radeon_bo_get_tiling(buf->bo, &old_flags, &old_pitch);
-
- if (flags != old_flags || pitch != old_pitch) {
- /* Tiling determines how DRM treats the buffer data.
- * We must flush CS when changing it if the buffer is referenced. */
- if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
- buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
- }
- }
- radeon_bo_set_tiling(buf->bo, flags, pitch);
-
-}
-
-boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
- uint32_t rd, uint32_t wd)
-{
- struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
- radeon_cs_space_add_persistent_bo(buf->mgr->rws->cs, buf->bo,
- rd, wd);
- return TRUE;
-}
-
-void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
- uint32_t rd, uint32_t wd,
- uint32_t flags)
-{
- struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
- int retval;
-
- retval = radeon_cs_write_reloc(buf->mgr->rws->cs,
- buf->bo, rd, wd, flags);
- if (retval) {
- debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
- buf, rd, wd, flags);
- }
-}
-
-boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf)
-{
- struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
- uint32_t domain;
-
- return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) ||
- radeon_bo_is_busy(buf->bo, &domain));
-}
-
-
-void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr)
-{
- struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
- struct radeon_drm_buffer *rpb, *t_rpb;
-
- foreach_s(rpb, t_rpb, &mgr->buffer_map_list) {
- radeon_bo_unmap(rpb->bo);
- rpb->bo->ptr = NULL;
- remove_from_list(rpb);
- }
-
- make_empty_list(&mgr->buffer_map_list);
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
deleted file mode 100644
index 38fcf889c8..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c
+++ /dev/null
@@ -1,348 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *
- * 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
- * THE AUTHOR(S) 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. */
-
-#include "radeon_r300.h"
-#include "radeon_buffer.h"
-
-#include "radeon_bo_gem.h"
-#include "radeon_cs_gem.h"
-#include "state_tracker/drm_api.h"
-
-static struct r300_winsys_buffer *
-radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- struct pb_desc desc;
- struct pb_manager *provider;
- struct pb_buffer *buffer;
-
- memset(&desc, 0, sizeof(desc));
- desc.alignment = alignment;
- desc.usage = usage;
-
- if (usage & PIPE_BUFFER_USAGE_CONSTANT)
- provider = ws->mman;
- else if ((usage & PIPE_BUFFER_USAGE_VERTEX) ||
- (usage & PIPE_BUFFER_USAGE_INDEX))
- provider = ws->cman;
- else
- provider = ws->kman;
- buffer = provider->create_buffer(provider, size, &desc);
- if (!buffer)
- return NULL;
-
- return radeon_libdrm_winsys_buffer(buffer);
-}
-
-static void radeon_r300_winsys_buffer_destroy(struct r300_winsys_buffer *buf)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
- pb_destroy(_buf);
-}
-static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer *buf,
- uint32_t pitch,
- enum r300_buffer_tiling microtiled,
- enum r300_buffer_tiling macrotiled)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
- radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch);
-}
-
-static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws,
- struct r300_winsys_buffer *buf,
- unsigned usage)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
- return pb_map(_buf, usage);
-}
-
-static void radeon_r300_winsys_buffer_unmap(struct r300_winsys_screen *ws,
- struct r300_winsys_buffer *buf)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
- pb_unmap(_buf);
-}
-
-static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer **pdst,
- struct r300_winsys_buffer *src)
-{
- struct pb_buffer *_src = radeon_pb_buffer(src);
- struct pb_buffer *_dst = radeon_pb_buffer(*pdst);
-
- pb_reference(&_dst, _src);
-
- *pdst = radeon_libdrm_winsys_buffer(_dst);
-}
-
-static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer *buf)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
- return radeon_drm_bufmgr_is_buffer_referenced(_buf);
-}
-
-static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,
- struct pipe_screen *screen,
- struct winsys_handle *whandle,
- unsigned *stride)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- struct pb_buffer *_buf;
-
- _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, whandle->handle);
- *stride = whandle->stride;
- return radeon_libdrm_winsys_buffer(_buf);
-}
-
-static boolean radeon_r300_winsys_buffer_get_handle(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer *buffer,
- unsigned stride,
- struct winsys_handle *whandle)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buffer);
- boolean ret;
- ret = radeon_drm_bufmgr_get_handle(_buf, whandle);
- if (ret)
- whandle->stride = stride;
- return ret;
-}
-
-static void radeon_set_flush_cb(struct r300_winsys_screen *rws,
- void (*flush_cb)(void *),
- void *data)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- ws->flush_cb = flush_cb;
- ws->flush_data = data;
- radeon_cs_space_set_flush(ws->cs, flush_cb, data);
-}
-
-static boolean radeon_add_buffer(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer *buf,
- uint32_t rd,
- uint32_t wd)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
-
- return radeon_drm_bufmgr_add_buffer(_buf, rd, wd);
-}
-
-static boolean radeon_validate(struct r300_winsys_screen *rws)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- if (radeon_cs_space_check(ws->cs) < 0) {
- return FALSE;
- }
-
- /* Things are fine, we can proceed as normal. */
- return TRUE;
-}
-
-static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- struct radeon_cs *cs = ws->cs;
-
- return radeon_validate(rws) && cs->cdw + size <= cs->ndw;
-}
-
-static void radeon_begin_cs(struct r300_winsys_screen *rws,
- int size,
- const char* file,
- const char* function,
- int line)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- radeon_cs_begin(ws->cs, size, file, function, line);
-}
-
-static void radeon_write_cs_dword(struct r300_winsys_screen *rws,
- uint32_t dword)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- radeon_cs_write_dword(ws->cs, dword);
-}
-
-static void radeon_write_cs_reloc(struct r300_winsys_screen *rws,
- struct r300_winsys_buffer *buf,
- uint32_t rd,
- uint32_t wd,
- uint32_t flags)
-{
- struct pb_buffer *_buf = radeon_pb_buffer(buf);
- radeon_drm_bufmgr_write_reloc(_buf, rd, wd, flags);
-}
-
-static void radeon_reset_bos(struct r300_winsys_screen *rws)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- radeon_cs_space_reset_bos(ws->cs);
-}
-
-static void radeon_end_cs(struct r300_winsys_screen *rws,
- const char* file,
- const char* function,
- int line)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- radeon_cs_end(ws->cs, file, function, line);
-}
-
-static void radeon_flush_cs(struct r300_winsys_screen *rws)
-{
- struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
- int retval;
-
- /* Don't flush a zero-sized CS. */
- if (!ws->cs->cdw) {
- return;
- }
-
- radeon_drm_bufmgr_flush_maps(ws->kman);
- /* Emit the CS. */
- retval = radeon_cs_emit(ws->cs);
- if (retval) {
- debug_printf("radeon: Bad CS, dumping...\n");
- radeon_cs_print(ws->cs, stderr);
- }
-
- /* Reset CS.
- * Someday, when we care about performance, we should really find a way
- * to rotate between two or three CS objects so that the GPU can be
- * spinning through one CS while another one is being filled. */
- radeon_cs_erase(ws->cs);
-}
-
-static uint32_t radeon_get_value(struct r300_winsys_screen *rws,
- enum r300_value_id id)
-{
- struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
-
- switch(id) {
- case R300_VID_PCI_ID:
- return ws->pci_id;
- case R300_VID_GB_PIPES:
- return ws->gb_pipes;
- case R300_VID_Z_PIPES:
- return ws->z_pipes;
- case R300_VID_SQUARE_TILING_SUPPORT:
- return ws->squaretiling;
- }
- return 0;
-}
-
-static void
-radeon_winsys_destroy(struct r300_winsys_screen *rws)
-{
- struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
- radeon_cs_destroy(ws->cs);
-
- ws->cman->destroy(ws->cman);
- ws->kman->destroy(ws->kman);
- ws->mman->destroy(ws->mman);
-
- radeon_bo_manager_gem_dtor(ws->bom);
- radeon_cs_manager_gem_dtor(ws->csm);
-}
-
-boolean
-radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
-{
-
- ws->csm = radeon_cs_manager_gem_ctor(fd);
- if (!ws->csm)
- goto fail;
- ws->bom = radeon_bo_manager_gem_ctor(fd);
- if (!ws->bom)
- goto fail;
- ws->kman = radeon_drm_bufmgr_create(ws);
- if (!ws->kman)
- goto fail;
-
- ws->cman = pb_cache_manager_create(ws->kman, 100000);
- if (!ws->cman)
- goto fail;
-
- ws->mman = pb_malloc_bufmgr_create();
- if (!ws->mman)
- goto fail;
-
- /* Size limit on IBs is 64 kibibytes. */
- ws->cs = radeon_cs_create(ws->csm, 1024 * 64 / 4);
- if (!ws->cs)
- goto fail;
- radeon_cs_set_limit(ws->cs,
- RADEON_GEM_DOMAIN_GTT, ws->gart_size);
- radeon_cs_set_limit(ws->cs,
- RADEON_GEM_DOMAIN_VRAM, ws->vram_size);
-
- ws->base.add_buffer = radeon_add_buffer;
- ws->base.validate = radeon_validate;
- ws->base.destroy = radeon_winsys_destroy;
- ws->base.check_cs = radeon_check_cs;
- ws->base.begin_cs = radeon_begin_cs;
- ws->base.write_cs_dword = radeon_write_cs_dword;
- ws->base.write_cs_reloc = radeon_write_cs_reloc;
- ws->base.end_cs = radeon_end_cs;
- ws->base.flush_cs = radeon_flush_cs;
- ws->base.reset_bos = radeon_reset_bos;
- ws->base.set_flush_cb = radeon_set_flush_cb;
- ws->base.get_value = radeon_get_value;
-
- ws->base.buffer_create = radeon_r300_winsys_buffer_create;
- ws->base.buffer_destroy = radeon_r300_winsys_buffer_destroy;
- ws->base.buffer_set_tiling = radeon_r300_winsys_buffer_set_tiling;
- ws->base.buffer_map = radeon_r300_winsys_buffer_map;
- ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap;
- ws->base.buffer_reference = radeon_r300_winsys_buffer_reference;
- ws->base.buffer_from_handle = radeon_r300_winsys_buffer_from_handle;
- ws->base.buffer_get_handle = radeon_r300_winsys_buffer_get_handle;
- ws->base.is_buffer_referenced = radeon_r300_winsys_is_buffer_referenced;
- return TRUE;
-
-fail:
- if (ws->csm)
- radeon_cs_manager_gem_dtor(ws->csm);
-
- if (ws->bom)
- radeon_bo_manager_gem_dtor(ws->bom);
-
- if (ws->cman)
- ws->cman->destroy(ws->cman);
- if (ws->kman)
- ws->kman->destroy(ws->kman);
- if (ws->mman)
- ws->mman->destroy(ws->mman);
-
- if (ws->cs)
- radeon_cs_destroy(ws->cs);
- return FALSE;
-}
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
deleted file mode 100644
index 2703464ad8..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
- *
- * 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
- * THE AUTHOR(S) 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 RADEON_R300_H
-#define RADEON_R300_H
-
-#include "radeon_winsys.h"
-
-boolean radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* winsys);
-
-#endif /* RADEON_R300_H */
diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
deleted file mode 100644
index 4260dbaad7..0000000000
--- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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>
- */
-#ifndef RADEON_WINSYS_H
-#define RADEON_WINSYS_H
-
-#include "r300_winsys.h"
-
-struct radeon_libdrm_winsys {
- /* Parent class. */
- struct r300_winsys_screen base;
-
- struct pb_manager *kman;
-
- struct pb_manager *cman;
-
- struct pb_manager *mman;
-
- /* PCI ID */
- uint32_t pci_id;
-
- /* GB pipe count */
- uint32_t gb_pipes;
-
- /* Z pipe count (rv530 only) */
- uint32_t z_pipes;
-
- /* GART size. */
- uint32_t gart_size;
-
- /* VRAM size. */
- uint32_t vram_size;
-
- /* Square tiling support. */
- boolean squaretiling;
-
- /* DRM FD */
- int fd;
-
- /* Radeon BO manager. */
- struct radeon_bo_manager *bom;
-
- /* Radeon CS manager. */
- struct radeon_cs_manager *csm;
-
- /* Current CS. */
- struct radeon_cs *cs;
-
- /* Flush CB */
- void (*flush_cb)(void *);
- void *flush_data;
-};
-
-static INLINE struct radeon_libdrm_winsys *
-radeon_winsys_screen(struct r300_winsys_screen *base)
-{
- return (struct radeon_libdrm_winsys *)base;
-}
-
-#endif
diff --git a/src/gallium/winsys/drm/sw/Makefile b/src/gallium/winsys/drm/sw/Makefile
deleted file mode 100644
index 5f3c3ec325..0000000000
--- a/src/gallium/winsys/drm/sw/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = swdrm
-
-C_SOURCES = \
- wrapper_sw_winsys.c \
- sw_drm_api.c
-
-LIBRARY_INCLUDES =
-
-LIBRARY_DEFINES =
-
-include ../../../Makefile.template
diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.c b/src/gallium/winsys/drm/sw/sw_drm_api.c
deleted file mode 100644
index 0fd2163913..0000000000
--- a/src/gallium/winsys/drm/sw/sw_drm_api.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/**********************************************************
- * Copyright 2010 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "util/u_memory.h"
-#include "softpipe/sp_public.h"
-#include "state_tracker/drm_api.h"
-#include "wrapper_sw_winsys.h"
-#include "sw_drm_api.h"
-
-
-/*
- * Defines
- */
-
-
-struct sw_drm_api
-{
- struct drm_api base;
- struct drm_api *api;
- struct sw_winsys *sw;
-};
-
-static INLINE struct sw_drm_api *
-sw_drm_api(struct drm_api *api)
-{
- return (struct sw_drm_api *)api;
-}
-
-
-/*
- * Exported functions
- */
-
-
-static struct pipe_screen *
-sw_drm_create_screen(struct drm_api *_api, int drmFD,
- struct drm_create_screen_arg *arg)
-{
- struct sw_drm_api *swapi = sw_drm_api(_api);
- struct drm_api *api = swapi->api;
- struct sw_winsys *sww;
- struct pipe_screen *screen;
-
- screen = api->create_screen(api, drmFD, arg);
-
- sww = wrapper_sw_winsys_warp_pipe_screen(screen);
-
- return softpipe_create_screen(sww);
-}
-
-static void
-sw_drm_destroy(struct drm_api *api)
-{
- struct sw_drm_api *swapi = sw_drm_api(api);
- if (swapi->api->destroy)
- swapi->api->destroy(swapi->api);
-
- FREE(swapi);
-}
-
-struct drm_api *
-sw_drm_api_create(struct drm_api *api)
-{
- struct sw_drm_api *swapi = CALLOC_STRUCT(sw_drm_api);
-
- swapi->base.name = "sw";
- swapi->base.driver_name = api->driver_name;
- swapi->base.create_screen = sw_drm_create_screen;
- swapi->base.destroy = sw_drm_destroy;
-
- swapi->api = api;
-
- return &swapi->base;
-}
diff --git a/src/gallium/winsys/drm/sw/sw_drm_api.h b/src/gallium/winsys/drm/sw/sw_drm_api.h
deleted file mode 100644
index ce90a04ae0..0000000000
--- a/src/gallium/winsys/drm/sw/sw_drm_api.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/**********************************************************
- * Copyright 2010 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 SW_DRM_API_H
-#define SW_DRM_API_H
-
-struct drm_api;
-
-struct drm_api * sw_drm_api_create(struct drm_api *api);
-
-#endif
diff --git a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c b/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c
deleted file mode 100644
index 459b1c1e2a..0000000000
--- a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/**********************************************************
- * Copyright 2010 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "wrapper_sw_winsys.h"
-
-#include "pipe/p_format.h"
-#include "pipe/p_state.h"
-
-#include "state_tracker/sw_winsys.h"
-
-#include "util/u_memory.h"
-#include "util/u_inlines.h"
-
-/*
- * This code wraps a pipe_screen and exposes a sw_winsys interface for use
- * with software resterizers. This code is used by the DRM based winsys to
- * allow access to the drm driver.
- *
- * We must borrow the whole stack because only the pipe screen knows how
- * to decode the content of a buffer. Or how to create a buffer that
- * can still be used by drivers using real hardware (as the case is
- * with software st/xorg but hw st/dri).
- *
- * We also need a pipe context for the transfers.
- */
-
-struct wrapper_sw_winsys
-{
- struct sw_winsys base;
- struct pipe_screen *screen;
- struct pipe_context *pipe;
-};
-
-struct wrapper_sw_displaytarget
-{
- struct wrapper_sw_winsys *winsys;
- struct pipe_texture *tex;
- struct pipe_transfer *transfer;
-
- unsigned width;
- unsigned height;
- unsigned map_count;
- unsigned stride; /**< because we give stride at create */
- void *ptr;
-};
-
-static INLINE struct wrapper_sw_winsys *
-wrapper_sw_winsys(struct sw_winsys *ws)
-{
- return (struct wrapper_sw_winsys *)ws;
-}
-
-static INLINE struct wrapper_sw_displaytarget *
-wrapper_sw_displaytarget(struct sw_displaytarget *dt)
-{
- return (struct wrapper_sw_displaytarget *)dt;
-}
-
-
-/*
- * Functions
- */
-
-
-static boolean
-wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride)
-{
- struct pipe_context *pipe = wdt->winsys->pipe;
- struct pipe_texture *tex = wdt->tex;
- struct pipe_transfer *tr;
-
- tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, wdt->width, wdt->height);
- if (!tr)
- return FALSE;
-
- *stride = tr->stride;
- wdt->stride = tr->stride;
-
- pipe->tex_transfer_destroy(pipe, tr);
-
- return TRUE;
-}
-
-static struct sw_displaytarget *
-wsw_dt_wrap_texture(struct wrapper_sw_winsys *wsw,
- struct pipe_texture *tex, unsigned *stride)
-{
- struct wrapper_sw_displaytarget *wdt = CALLOC_STRUCT(wrapper_sw_displaytarget);
- if (!wdt)
- goto err_unref;
-
- wdt->tex = tex;
- wdt->winsys = wsw;
-
- if (!wsw_dt_get_stride(wdt, stride))
- goto err_free;
-
- return (struct sw_displaytarget *)wdt;
-
-err_free:
- FREE(wdt);
-err_unref:
- pipe_texture_reference(&tex, NULL);
- return NULL;
-}
-
-static struct sw_displaytarget *
-wsw_dt_create(struct sw_winsys *ws,
- unsigned tex_usage,
- enum pipe_format format,
- unsigned width, unsigned height,
- unsigned alignment,
- unsigned *stride)
-{
- struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
- struct pipe_texture templ;
- struct pipe_texture *tex;
-
- /*
- * XXX Why don't we just get the template.
- */
- memset(&templ, 0, sizeof(templ));
- templ.width0 = width;
- templ.height0 = height;
- templ.format = format;
- templ.tex_usage = tex_usage;
-
- /* XXX alignment: we can't do anything about this */
-
- tex = wsw->screen->texture_create(wsw->screen, &templ);
- if (!tex)
- return NULL;
-
- return wsw_dt_wrap_texture(wsw, tex, stride);
-}
-
-static struct sw_displaytarget *
-wsw_dt_from_handle(struct sw_winsys *ws,
- const struct pipe_texture *templ,
- struct winsys_handle *whandle,
- unsigned *stride)
-{
- struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
- struct pipe_texture *tex;
-
- tex = wsw->screen->texture_from_handle(wsw->screen, templ, whandle);
- if (!tex)
- return NULL;
-
- return wsw_dt_wrap_texture(wsw, tex, stride);
-}
-
-static void *
-wsw_dt_map(struct sw_winsys *ws,
- struct sw_displaytarget *dt,
- unsigned flags)
-{
- struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
- struct pipe_context *pipe = wdt->winsys->pipe;
- struct pipe_texture *tex = wdt->tex;
- struct pipe_transfer *tr;
- void *ptr;
-
- if (!wdt->map_count) {
-
- assert(!wdt->transfer);
-
- tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, wdt->width, wdt->height);
- if (!tr)
- return NULL;
-
- ptr = pipe->transfer_map(pipe, tr);
- if (!ptr)
- goto err;
-
- wdt->transfer = tr;
- wdt->ptr = ptr;
-
- /* XXX Handle this case */
- assert(tr->stride == wdt->stride);
- }
-
- wdt->map_count++;
-
- return wdt->ptr;
-
-err:
- pipe->tex_transfer_destroy(pipe, tr);
- return NULL;
-}
-
-static void
-wsw_dt_unmap(struct sw_winsys *ws,
- struct sw_displaytarget *dt)
-{
- struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
- struct pipe_context *pipe = wdt->winsys->pipe;
-
- assert(wdt->transfer);
-
- wdt->map_count--;
-
- if (wdt->map_count)
- return;
-
- pipe->transfer_unmap(pipe, wdt->transfer);
- pipe->tex_transfer_destroy(pipe, wdt->transfer);
- wdt->transfer = NULL;
-}
-
-static void
-wsw_dt_destroy(struct sw_winsys *ws,
- struct sw_displaytarget *dt)
-{
- struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
-
- pipe_texture_reference(&wdt->tex, NULL);
-
- FREE(wdt);
-}
-
-static void
-wsw_destroy(struct sw_winsys *ws)
-{
- struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
-
- wsw->pipe->destroy(wsw->pipe);
- wsw->screen->destroy(wsw->screen);
-
- FREE(wsw);
-}
-
-struct sw_winsys *
-wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen)
-{
- struct wrapper_sw_winsys *wsw = CALLOC_STRUCT(wrapper_sw_winsys);
-
- wsw->base.displaytarget_create = wsw_dt_create;
- wsw->base.displaytarget_from_handle = wsw_dt_from_handle;
- wsw->base.displaytarget_map = wsw_dt_map;
- wsw->base.displaytarget_unmap = wsw_dt_unmap;
- wsw->base.displaytarget_destroy = wsw_dt_destroy;
- wsw->base.destroy = wsw_destroy;
-
- wsw->screen = screen;
- wsw->pipe = screen->context_create(screen, NULL);
- if (!wsw->pipe)
- goto err;
-
- return &wsw->base;
-
-err:
- FREE(wsw);
- return NULL;
-}
diff --git a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h b/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h
deleted file mode 100644
index b5c25a3c50..0000000000
--- a/src/gallium/winsys/drm/sw/wrapper_sw_winsys.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/**********************************************************
- * Copyright 2010 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 WRAPPER_SW_WINSYS
-#define WRAPPER_SW_WINSYS
-
-struct sw_winsys;
-struct pipe_screen;
-
-struct sw_winsys *wrapper_sw_winsys_warp_pipe_screen(struct pipe_screen *screen);
-
-#endif
diff --git a/src/gallium/winsys/drm/vmware/Makefile b/src/gallium/winsys/drm/vmware/Makefile
deleted file mode 100644
index 2ae6dead5c..0000000000
--- a/src/gallium/winsys/drm/vmware/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# src/gallium/winsys/drm/vmware/Makefile
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = core $(GALLIUM_STATE_TRACKERS_DIRS)
-
-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/vmware/SConscript b/src/gallium/winsys/drm/vmware/SConscript
deleted file mode 100644
index eff87e7d01..0000000000
--- a/src/gallium/winsys/drm/vmware/SConscript
+++ /dev/null
@@ -1,3 +0,0 @@
-Import('*')
-
-SConscript(['core/SConscript',])
diff --git a/src/gallium/winsys/drm/vmware/core/Makefile b/src/gallium/winsys/drm/vmware/core/Makefile
deleted file mode 100644
index a52957c1a5..0000000000
--- a/src/gallium/winsys/drm/vmware/core/Makefile
+++ /dev/null
@@ -1,35 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = svgadrm
-
-C_SOURCES = \
- vmw_buffer.c \
- vmw_context.c \
- vmw_fence.c \
- vmw_screen.c \
- vmw_screen_dri.c \
- vmw_screen_ioctl.c \
- vmw_screen_pools.c \
- vmw_screen_svga.c \
- vmw_surface.c
-
-LIBRARY_INCLUDES = \
- -I$(TOP)/src/gallium/drivers/svga \
- -I$(TOP)/src/gallium/drivers/svga/include \
- -I$(GALLIUM)/src/mesa/drivers/dri/common \
- -I$(GALLIUM)/include \
- -I$(GALLIUM)/include/GL/internal \
- -I$(GALLIUM)/src/mesa \
- -I$(GALLIUM)/src/mesa/main \
- -I$(GALLIUM)/src/mesa/glapi \
- -I$(GALLIUM)/src/egl/main \
- -I$(GALLIUM)/src/egl/drivers/dri \
- $(shell pkg-config libdrm --cflags-only-I)
-
-LIBRARY_DEFINES = \
- -std=gnu99 -fvisibility=hidden \
- -DHAVE_STDINT_H -D_FILE_OFFSET_BITS=64 \
- $(shell pkg-config libdrm --cflags-only-other)
-
-include ../../../../Makefile.template
diff --git a/src/gallium/winsys/drm/vmware/core/SConscript b/src/gallium/winsys/drm/vmware/core/SConscript
deleted file mode 100644
index edaf9458be..0000000000
--- a/src/gallium/winsys/drm/vmware/core/SConscript
+++ /dev/null
@@ -1,39 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-if env['gcc']:
- env.Append(CCFLAGS = ['-fvisibility=hidden'])
- env.Append(CPPDEFINES = [
- 'HAVE_STDINT_H',
- 'HAVE_SYS_TYPES_H',
- '-D_FILE_OFFSET_BITS=64',
- ])
-
-env.Prepend(CPPPATH = [
- 'include',
- '#/src/gallium/drivers/svga',
- '#/src/gallium/drivers/svga/include',
-])
-
-env.Append(CPPDEFINES = [
-])
-
-sources = [
- 'vmw_buffer.c',
- 'vmw_context.c',
- 'vmw_fence.c',
- 'vmw_screen.c',
- 'vmw_screen_dri.c',
- 'vmw_screen_ioctl.c',
- 'vmw_screen_pools.c',
- 'vmw_screen_svga.c',
- 'vmw_surface.c',
-]
-
-svgadrm = env.ConvenienceLibrary(
- target = 'svgadrm',
- source = sources,
-)
-
-Export('svgadrm')
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c b/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
deleted file mode 100644
index eca174a6c5..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_buffer.c
+++ /dev/null
@@ -1,274 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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.
- *
- **********************************************************/
-
-/**
- * @file
- * SVGA buffer manager for Guest Memory Regions (GMRs).
- *
- * GMRs are used for pixel and vertex data upload/download to/from the virtual
- * SVGA hardware. There is a limited number of GMRs available, and
- * creating/destroying them is also a slow operation so we must suballocate
- * them.
- *
- * This file implements a pipebuffer library's buffer manager, so that we can
- * use pipepbuffer's suballocation, fencing, and debugging facilities with GMRs.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#include "svga_cmd.h"
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-#include "svga_winsys.h"
-
-#include "vmw_screen.h"
-#include "vmw_buffer.h"
-
-
-struct vmw_gmr_bufmgr;
-
-
-struct vmw_gmr_buffer
-{
- struct pb_buffer base;
-
- struct vmw_gmr_bufmgr *mgr;
-
- struct vmw_region *region;
- void *map;
-
-#ifdef DEBUG
- struct pipe_fence_handle *last_fence;
-#endif
-};
-
-
-extern const struct pb_vtbl vmw_gmr_buffer_vtbl;
-
-
-static INLINE struct vmw_gmr_buffer *
-vmw_gmr_buffer(struct pb_buffer *buf)
-{
- assert(buf);
- assert(buf->vtbl == &vmw_gmr_buffer_vtbl);
- return (struct vmw_gmr_buffer *)buf;
-}
-
-
-struct vmw_gmr_bufmgr
-{
- struct pb_manager base;
-
- struct vmw_winsys_screen *vws;
-};
-
-
-static INLINE struct vmw_gmr_bufmgr *
-vmw_gmr_bufmgr(struct pb_manager *mgr)
-{
- assert(mgr);
- return (struct vmw_gmr_bufmgr *)mgr;
-}
-
-
-static void
-vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
-{
- struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
-
-#ifdef DEBUG
- if(buf->last_fence) {
- struct svga_winsys_screen *sws = &buf->mgr->vws->base;
- assert(sws->fence_signalled(sws, buf->last_fence, 0) == 0);
- }
-#endif
-
- vmw_ioctl_region_unmap(buf->region);
-
- vmw_ioctl_region_destroy(buf->region);
-
- FREE(buf);
-}
-
-
-static void *
-vmw_gmr_buffer_map(struct pb_buffer *_buf,
- unsigned flags)
-{
- struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
- return buf->map;
-}
-
-
-static void
-vmw_gmr_buffer_unmap(struct pb_buffer *_buf)
-{
- /* Do nothing */
- (void)_buf;
-}
-
-
-static void
-vmw_gmr_buffer_get_base_buffer(struct pb_buffer *buf,
- struct pb_buffer **base_buf,
- unsigned *offset)
-{
- *base_buf = buf;
- *offset = 0;
-}
-
-
-static enum pipe_error
-vmw_gmr_buffer_validate( struct pb_buffer *_buf,
- struct pb_validate *vl,
- unsigned flags )
-{
- /* Always pinned */
- return PIPE_OK;
-}
-
-
-static void
-vmw_gmr_buffer_fence( struct pb_buffer *_buf,
- struct pipe_fence_handle *fence )
-{
- /* We don't need to do anything, as the pipebuffer library
- * will take care of delaying the destruction of fenced buffers */
-#ifdef DEBUG
- struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
- if(fence)
- buf->last_fence = fence;
-#endif
-}
-
-
-const struct pb_vtbl vmw_gmr_buffer_vtbl = {
- vmw_gmr_buffer_destroy,
- vmw_gmr_buffer_map,
- vmw_gmr_buffer_unmap,
- vmw_gmr_buffer_validate,
- vmw_gmr_buffer_fence,
- vmw_gmr_buffer_get_base_buffer
-};
-
-
-static struct pb_buffer *
-vmw_gmr_bufmgr_create_buffer(struct pb_manager *_mgr,
- pb_size size,
- const struct pb_desc *desc)
-{
- struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
- struct vmw_winsys_screen *vws = mgr->vws;
- struct vmw_gmr_buffer *buf;
-
- buf = CALLOC_STRUCT(vmw_gmr_buffer);
- if(!buf)
- goto error1;
-
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
- buf->base.vtbl = &vmw_gmr_buffer_vtbl;
- buf->mgr = mgr;
-
- buf->region = vmw_ioctl_region_create(vws, size);
- if(!buf->region)
- goto error2;
-
- buf->map = vmw_ioctl_region_map(buf->region);
- if(!buf->map)
- goto error3;
-
- return &buf->base;
-
-error3:
- vmw_ioctl_region_destroy(buf->region);
-error2:
- FREE(buf);
-error1:
- return NULL;
-}
-
-
-static void
-vmw_gmr_bufmgr_flush(struct pb_manager *mgr)
-{
- /* No-op */
-}
-
-
-static void
-vmw_gmr_bufmgr_destroy(struct pb_manager *_mgr)
-{
- struct vmw_gmr_bufmgr *mgr = vmw_gmr_bufmgr(_mgr);
- FREE(mgr);
-}
-
-
-struct pb_manager *
-vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws)
-{
- struct vmw_gmr_bufmgr *mgr;
-
- mgr = CALLOC_STRUCT(vmw_gmr_bufmgr);
- if(!mgr)
- return NULL;
-
- mgr->base.destroy = vmw_gmr_bufmgr_destroy;
- mgr->base.create_buffer = vmw_gmr_bufmgr_create_buffer;
- mgr->base.flush = vmw_gmr_bufmgr_flush;
-
- mgr->vws = vws;
-
- return &mgr->base;
-}
-
-
-boolean
-vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf,
- struct SVGAGuestPtr *ptr)
-{
- struct pb_buffer *base_buf;
- unsigned offset = 0;
- struct vmw_gmr_buffer *gmr_buf;
-
- pb_get_base_buffer( buf, &base_buf, &offset );
-
- gmr_buf = vmw_gmr_buffer(base_buf);
- if(!gmr_buf)
- return FALSE;
-
- *ptr = vmw_ioctl_region_ptr(gmr_buf->region);
-
- ptr->offset += offset;
-
- return TRUE;
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h b/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
deleted file mode 100644
index 41fb4476da..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_buffer.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 VMW_BUFFER_H_
-#define VMW_BUFFER_H_
-
-#include <assert.h>
-#include "pipe/p_compiler.h"
-
-struct SVGAGuestPtr;
-struct pb_buffer;
-struct pb_manager;
-struct svga_winsys_buffer;
-struct svga_winsys_surface;
-struct vmw_winsys_screen;
-
-
-static INLINE struct pb_buffer *
-vmw_pb_buffer(struct svga_winsys_buffer *buffer)
-{
- assert(buffer);
- return (struct pb_buffer *)buffer;
-}
-
-
-static INLINE struct svga_winsys_buffer *
-vmw_svga_winsys_buffer(struct pb_buffer *buffer)
-{
- assert(buffer);
- return (struct svga_winsys_buffer *)buffer;
-}
-
-
-struct pb_manager *
-vmw_gmr_bufmgr_create(struct vmw_winsys_screen *vws);
-
-boolean
-vmw_gmr_bufmgr_region_ptr(struct pb_buffer *buf,
- struct SVGAGuestPtr *ptr);
-
-
-#endif /* VMW_BUFFER_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.c b/src/gallium/winsys/drm/vmware/core/vmw_context.c
deleted file mode 100644
index 90ffc4868f..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_context.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "svga_cmd.h"
-
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-#include "util/u_debug_stack.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_validate.h"
-
-#include "svga_winsys.h"
-#include "vmw_context.h"
-#include "vmw_screen.h"
-#include "vmw_buffer.h"
-#include "vmw_surface.h"
-#include "vmw_fence.h"
-
-#define VMW_COMMAND_SIZE (64*1024)
-#define VMW_SURFACE_RELOCS (1024)
-#define VMW_REGION_RELOCS (512)
-
-#define VMW_MUST_FLUSH_STACK 8
-
-struct vmw_region_relocation
-{
- struct SVGAGuestPtr *where;
- struct pb_buffer *buffer;
- /* TODO: put offset info inside where */
- uint32 offset;
-};
-
-struct vmw_svga_winsys_context
-{
- struct svga_winsys_context base;
-
- struct vmw_winsys_screen *vws;
-
-#ifdef DEBUG
- boolean must_flush;
- struct debug_stack_frame must_flush_stack[VMW_MUST_FLUSH_STACK];
-#endif
-
- struct {
- uint8_t buffer[VMW_COMMAND_SIZE];
- uint32_t size;
- uint32_t used;
- uint32_t reserved;
- } command;
-
- struct {
- struct vmw_svga_winsys_surface *handles[VMW_SURFACE_RELOCS];
- uint32_t size;
- uint32_t used;
- uint32_t staged;
- uint32_t reserved;
- } surface;
-
- struct {
- struct vmw_region_relocation relocs[VMW_REGION_RELOCS];
- uint32_t size;
- uint32_t used;
- uint32_t staged;
- uint32_t reserved;
- } region;
-
- struct pb_validate *validate;
-
- uint32_t last_fence;
-
- /**
- * The amount of GMR that is referred by the commands currently batched
- * in the context.
- */
- uint32_t seen_regions;
-
- /**
- * Whether this context should fail to reserve more commands, not because it
- * ran out of command space, but because a substantial ammount of GMR was
- * referred.
- */
- boolean preemptive_flush;
-};
-
-
-static INLINE struct vmw_svga_winsys_context *
-vmw_svga_winsys_context(struct svga_winsys_context *swc)
-{
- assert(swc);
- return (struct vmw_svga_winsys_context *)swc;
-}
-
-
-static enum pipe_error
-vmw_swc_flush(struct svga_winsys_context *swc,
- struct pipe_fence_handle **pfence)
-{
- struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
- struct pipe_fence_handle *fence = NULL;
- unsigned i;
- enum pipe_error ret;
-
- ret = pb_validate_validate(vswc->validate);
- assert(ret == PIPE_OK);
- if(ret == PIPE_OK) {
-
- /* Apply relocations */
- for(i = 0; i < vswc->region.used; ++i) {
- struct vmw_region_relocation *reloc = &vswc->region.relocs[i];
- struct SVGAGuestPtr ptr;
-
- if(!vmw_gmr_bufmgr_region_ptr(reloc->buffer, &ptr))
- assert(0);
-
- ptr.offset += reloc->offset;
-
- *reloc->where = ptr;
- }
-
- if (vswc->command.used)
- vmw_ioctl_command(vswc->vws,
- vswc->command.buffer,
- vswc->command.used,
- &vswc->last_fence);
-
- fence = vmw_pipe_fence(vswc->last_fence);
-
- pb_validate_fence(vswc->validate, fence);
- }
-
- vswc->command.used = 0;
- vswc->command.reserved = 0;
-
- for(i = 0; i < vswc->surface.used + vswc->surface.staged; ++i) {
- struct vmw_svga_winsys_surface *vsurf =
- vswc->surface.handles[i];
- p_atomic_dec(&vsurf->validated);
- vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
- }
-
- vswc->surface.used = 0;
- vswc->surface.reserved = 0;
-
- for(i = 0; i < vswc->region.used + vswc->region.staged; ++i) {
- pb_reference(&vswc->region.relocs[i].buffer, NULL);
- }
-
- vswc->region.used = 0;
- vswc->region.reserved = 0;
-
-#ifdef DEBUG
- vswc->must_flush = FALSE;
-#endif
- vswc->preemptive_flush = FALSE;
- vswc->seen_regions = 0;
-
- if(pfence)
- *pfence = fence;
-
- return ret;
-}
-
-
-static void *
-vmw_swc_reserve(struct svga_winsys_context *swc,
- uint32_t nr_bytes, uint32_t nr_relocs )
-{
- struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-
-#ifdef DEBUG
- /* Check if somebody forgot to check the previous failure */
- if(vswc->must_flush) {
- debug_printf("Forgot to flush:\n");
- debug_backtrace_dump(vswc->must_flush_stack, VMW_MUST_FLUSH_STACK);
- assert(!vswc->must_flush);
- }
-#endif
-
- assert(nr_bytes <= vswc->command.size);
- if(nr_bytes > vswc->command.size)
- return NULL;
-
- if(vswc->preemptive_flush ||
- vswc->command.used + nr_bytes > vswc->command.size ||
- vswc->surface.used + nr_relocs > vswc->surface.size ||
- vswc->region.used + nr_relocs > vswc->region.size) {
-#ifdef DEBUG
- vswc->must_flush = TRUE;
- debug_backtrace_capture(vswc->must_flush_stack, 1,
- VMW_MUST_FLUSH_STACK);
-#endif
- return NULL;
- }
-
- assert(vswc->command.used + nr_bytes <= vswc->command.size);
- assert(vswc->surface.used + nr_relocs <= vswc->surface.size);
- assert(vswc->region.used + nr_relocs <= vswc->region.size);
-
- vswc->command.reserved = nr_bytes;
- vswc->surface.reserved = nr_relocs;
- vswc->surface.staged = 0;
- vswc->region.reserved = nr_relocs;
- vswc->region.staged = 0;
-
- return vswc->command.buffer + vswc->command.used;
-}
-
-
-static void
-vmw_swc_surface_relocation(struct svga_winsys_context *swc,
- uint32 *where,
- struct svga_winsys_surface *surface,
- unsigned flags)
-{
- struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
- struct vmw_svga_winsys_surface *vsurf;
-
- if(!surface) {
- *where = SVGA3D_INVALID_ID;
- return;
- }
-
- assert(vswc->surface.staged < vswc->surface.reserved);
-
- vsurf = vmw_svga_winsys_surface(surface);
-
- *where = vsurf->sid;
-
- vmw_svga_winsys_surface_reference(&vswc->surface.handles[vswc->surface.used + vswc->surface.staged], vsurf);
- p_atomic_inc(&vsurf->validated);
- ++vswc->surface.staged;
-}
-
-
-static void
-vmw_swc_region_relocation(struct svga_winsys_context *swc,
- struct SVGAGuestPtr *where,
- struct svga_winsys_buffer *buffer,
- uint32 offset,
- unsigned flags)
-{
- struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
- struct vmw_region_relocation *reloc;
- enum pipe_error ret;
-
- assert(vswc->region.staged < vswc->region.reserved);
-
- reloc = &vswc->region.relocs[vswc->region.used + vswc->region.staged];
- reloc->where = where;
- pb_reference(&reloc->buffer, vmw_pb_buffer(buffer));
- reloc->offset = offset;
-
- ++vswc->region.staged;
-
- ret = pb_validate_add_buffer(vswc->validate, reloc->buffer, flags);
- /* TODO: Update pipebuffer to reserve buffers and not fail here */
- assert(ret == PIPE_OK);
-
- /*
- * Flush preemptively the FIFO commands to keep the GMR working set within
- * the GMR pool size.
- *
- * This is necessary for applications like SPECviewperf that generate huge
- * amounts of immediate vertex data, so that we don't pile up too much of
- * that vertex data neither in the guest nor in the host.
- *
- * Note that in the current implementation if a region is referred twice in
- * a command stream, it will be accounted twice. We could detect repeated
- * regions and count only once, but there is no incentive to do that, since
- * regions are typically short-lived; always referred in a single command;
- * and at the worst we just flush the commands a bit sooner, which for the
- * SVGA virtual device it's not a performance issue since flushing commands
- * to the FIFO won't cause flushing in the host.
- */
- vswc->seen_regions += reloc->buffer->base.size;
- if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/2)
- vswc->preemptive_flush = TRUE;
-}
-
-
-static void
-vmw_swc_commit(struct svga_winsys_context *swc)
-{
- struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
-
- assert(vswc->command.reserved);
- assert(vswc->command.used + vswc->command.reserved <= vswc->command.size);
- vswc->command.used += vswc->command.reserved;
- vswc->command.reserved = 0;
-
- assert(vswc->surface.staged <= vswc->surface.reserved);
- assert(vswc->surface.used + vswc->surface.staged <= vswc->surface.size);
- vswc->surface.used += vswc->surface.staged;
- vswc->surface.staged = 0;
- vswc->surface.reserved = 0;
-
- assert(vswc->region.staged <= vswc->region.reserved);
- assert(vswc->region.used + vswc->region.staged <= vswc->region.size);
- vswc->region.used += vswc->region.staged;
- vswc->region.staged = 0;
- vswc->region.reserved = 0;
-}
-
-
-static void
-vmw_swc_destroy(struct svga_winsys_context *swc)
-{
- struct vmw_svga_winsys_context *vswc = vmw_svga_winsys_context(swc);
- unsigned i;
-
- for(i = 0; i < vswc->region.used; ++i) {
- pb_reference(&vswc->region.relocs[i].buffer, NULL);
- }
-
- for(i = 0; i < vswc->surface.used; ++i) {
- p_atomic_dec(&vswc->surface.handles[i]->validated);
- vmw_svga_winsys_surface_reference(&vswc->surface.handles[i], NULL);
- }
- pb_validate_destroy(vswc->validate);
- vmw_ioctl_context_destroy(vswc->vws, swc->cid);
- FREE(vswc);
-}
-
-
-struct svga_winsys_context *
-vmw_svga_winsys_context_create(struct svga_winsys_screen *sws)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- struct vmw_svga_winsys_context *vswc;
-
- vswc = CALLOC_STRUCT(vmw_svga_winsys_context);
- if(!vswc)
- return NULL;
-
- vswc->base.destroy = vmw_swc_destroy;
- vswc->base.reserve = vmw_swc_reserve;
- vswc->base.surface_relocation = vmw_swc_surface_relocation;
- vswc->base.region_relocation = vmw_swc_region_relocation;
- vswc->base.commit = vmw_swc_commit;
- vswc->base.flush = vmw_swc_flush;
-
- vswc->base.cid = vmw_ioctl_context_create(vws);
-
- vswc->vws = vws;
-
- vswc->command.size = VMW_COMMAND_SIZE;
- vswc->surface.size = VMW_SURFACE_RELOCS;
- vswc->region.size = VMW_REGION_RELOCS;
-
- vswc->validate = pb_validate_create();
- if(!vswc->validate) {
- FREE(vswc);
- return NULL;
- }
-
- return &vswc->base;
-}
-
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_context.h b/src/gallium/winsys/drm/vmware/core/vmw_context.h
deleted file mode 100644
index d4884d24e9..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_context.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#ifndef VMW_CONTEXT_H_
-#define VMW_CONTEXT_H_
-
-#include "pipe/p_compiler.h"
-
-struct svga_winsys_screen;
-struct svga_winsys_context;
-struct pipe_context;
-struct pipe_screen;
-
-#define VMW_DEBUG 0
-
-#if VMW_DEBUG
-#define vmw_printf debug_printf
-#define VMW_FUNC debug_printf("%s\n", __FUNCTION__)
-#else
-#define VMW_FUNC
-#define vmw_printf(...)
-#endif
-
-
-struct svga_winsys_context *
-vmw_svga_winsys_context_create(struct svga_winsys_screen *sws);
-
-
-#endif /* VMW_CONTEXT_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.c b/src/gallium/winsys/drm/vmware/core/vmw_fence.c
deleted file mode 100644
index 873dd51166..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_fence.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "util/u_memory.h"
-#include "pipebuffer/pb_buffer_fenced.h"
-
-#include "vmw_screen.h"
-#include "vmw_fence.h"
-
-
-
-struct vmw_fence_ops
-{
- struct pb_fence_ops base;
-
- struct vmw_winsys_screen *vws;
-};
-
-
-static INLINE struct vmw_fence_ops *
-vmw_fence_ops(struct pb_fence_ops *ops)
-{
- assert(ops);
- return (struct vmw_fence_ops *)ops;
-}
-
-
-static void
-vmw_fence_ops_fence_reference(struct pb_fence_ops *ops,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- *ptr = fence;
-}
-
-
-static int
-vmw_fence_ops_fence_signalled(struct pb_fence_ops *ops,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
- (void)flag;
- return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
-}
-
-
-static int
-vmw_fence_ops_fence_finish(struct pb_fence_ops *ops,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
- (void)flag;
- return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
-}
-
-
-static void
-vmw_fence_ops_destroy(struct pb_fence_ops *ops)
-{
- FREE(ops);
-}
-
-
-struct pb_fence_ops *
-vmw_fence_ops_create(struct vmw_winsys_screen *vws)
-{
- struct vmw_fence_ops *ops;
-
- ops = CALLOC_STRUCT(vmw_fence_ops);
- if(!ops)
- return NULL;
-
- ops->base.destroy = &vmw_fence_ops_destroy;
- ops->base.fence_reference = &vmw_fence_ops_fence_reference;
- ops->base.fence_signalled = &vmw_fence_ops_fence_signalled;
- ops->base.fence_finish = &vmw_fence_ops_fence_finish;
-
- ops->vws = vws;
-
- return &ops->base;
-}
-
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_fence.h b/src/gallium/winsys/drm/vmware/core/vmw_fence.h
deleted file mode 100644
index 5357b4f61d..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_fence.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 VMW_FENCE_H_
-#define VMW_FENCE_H_
-
-
-#include "pipe/p_compiler.h"
-
-
-struct pipe_fence_handle;
-struct pb_fence_ops;
-struct vmw_winsys_screen;
-
-
-/** Cast from a pipe_fence_handle pointer into a SVGA fence */
-static INLINE uint32_t
-vmw_fence( struct pipe_fence_handle *fence )
-{
- return (uint32_t)(uintptr_t)fence;
-}
-
-
-/** Cast from a SVGA fence number to pipe_fence_handle pointer */
-static INLINE struct pipe_fence_handle *
-vmw_pipe_fence( uint32_t fence )
-{
- return (struct pipe_fence_handle *)(uintptr_t)fence;
-}
-
-
-struct pb_fence_ops *
-vmw_fence_ops_create(struct vmw_winsys_screen *vws);
-
-
-#endif /* VMW_FENCE_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.c b/src/gallium/winsys/drm/vmware/core/vmw_screen.c
deleted file mode 100644
index 6cc9b38293..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "vmw_screen.h"
-
-#include "vmw_context.h"
-
-#include "util/u_memory.h"
-#include "pipe/p_compiler.h"
-
-
-/* Called from vmw_drm_create_screen(), creates and initializes the
- * vmw_winsys_screen structure, which is the main entity in this
- * module.
- */
-struct vmw_winsys_screen *
-vmw_winsys_create( int fd, boolean use_old_scanout_flag )
-{
- struct vmw_winsys_screen *vws = CALLOC_STRUCT(vmw_winsys_screen);
- if (!vws)
- goto out_no_vws;
-
- vws->ioctl.drm_fd = fd;
- vws->use_old_scanout_flag = use_old_scanout_flag;
- debug_printf("%s: use_old_scanout_flag == %s\n", __FUNCTION__,
- use_old_scanout_flag ? "true" : "false");
-
- if (!vmw_ioctl_init(vws))
- goto out_no_ioctl;
-
- if(!vmw_pools_init(vws))
- goto out_no_pools;
-
- if (!vmw_winsys_screen_init_svga(vws))
- goto out_no_svga;
-
- return vws;
-out_no_svga:
- vmw_pools_cleanup(vws);
-out_no_pools:
- vmw_ioctl_cleanup(vws);
-out_no_ioctl:
- FREE(vws);
-out_no_vws:
- return NULL;
-}
-
-void
-vmw_winsys_destroy(struct vmw_winsys_screen *vws)
-{
- vmw_pools_cleanup(vws);
- vmw_ioctl_cleanup(vws);
- FREE(vws);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen.h b/src/gallium/winsys/drm/vmware/core/vmw_screen.h
deleted file mode 100644
index d3f2c2c7f5..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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.
- *
- **********************************************************/
-
-/**
- * @file
- * Common definitions for the VMware SVGA winsys.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#ifndef VMW_SCREEN_H_
-#define VMW_SCREEN_H_
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-#include "svga_winsys.h"
-
-
-#define VMW_GMR_POOL_SIZE (16*1024*1024)
-
-
-struct pb_manager;
-struct vmw_region;
-
-
-struct vmw_winsys_screen
-{
- struct svga_winsys_screen base;
-
- boolean use_old_scanout_flag;
-
- struct {
- volatile uint32_t *fifo_map;
- uint64_t last_fence;
- int drm_fd;
- } ioctl;
-
- struct {
- struct pb_manager *gmr;
- struct pb_manager *gmr_mm;
- struct pb_manager *gmr_fenced;
- } pools;
-};
-
-
-static INLINE struct vmw_winsys_screen *
-vmw_winsys_screen(struct svga_winsys_screen *base)
-{
- return (struct vmw_winsys_screen *)base;
-}
-
-/* */
-uint32
-vmw_ioctl_context_create(struct vmw_winsys_screen *vws);
-
-void
-vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws,
- uint32 cid);
-
-uint32
-vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
- SVGA3dSurfaceFlags flags,
- SVGA3dSurfaceFormat format,
- SVGA3dSize size,
- uint32 numFaces,
- uint32 numMipLevels);
-
-void
-vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws,
- uint32 sid);
-
-void
-vmw_ioctl_command(struct vmw_winsys_screen *vws,
- void *commands,
- uint32_t size,
- uint32_t *fence);
-
-struct vmw_region *
-vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size);
-
-void
-vmw_ioctl_region_destroy(struct vmw_region *region);
-
-struct SVGAGuestPtr
-vmw_ioctl_region_ptr(struct vmw_region *region);
-
-void *
-vmw_ioctl_region_map(struct vmw_region *region);
-void
-vmw_ioctl_region_unmap(struct vmw_region *region);
-
-
-int
-vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
- uint32_t fence);
-
-int
-vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
- uint32_t fence);
-
-
-/* Initialize parts of vmw_winsys_screen at startup:
- */
-boolean vmw_ioctl_init(struct vmw_winsys_screen *vws);
-boolean vmw_pools_init(struct vmw_winsys_screen *vws);
-boolean vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws);
-
-void vmw_ioctl_cleanup(struct vmw_winsys_screen *vws);
-void vmw_pools_cleanup(struct vmw_winsys_screen *vws);
-
-struct vmw_winsys_screen *vmw_winsys_create(int fd, boolean use_old_scanout_flag);
-void vmw_winsys_destroy(struct vmw_winsys_screen *sws);
-
-
-#endif /* VMW_SCREEN_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
deleted file mode 100644
index 657544dcb2..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "pipe/p_compiler.h"
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_format.h"
-#include "vmw_screen.h"
-
-#include "trace/tr_drm.h"
-
-#include "vmw_screen.h"
-#include "vmw_surface.h"
-#include "vmw_fence.h"
-#include "vmw_context.h"
-
-#include <state_tracker/dri1_api.h>
-#include <state_tracker/drm_api.h>
-#include <vmwgfx_drm.h>
-#include <xf86drm.h>
-
-#include <stdio.h>
-
-static struct svga_winsys_surface *
-vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
- struct winsys_handle *whandle,
- SVGA3dSurfaceFormat *format);
-static boolean
-vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
- struct svga_winsys_surface *surface,
- unsigned stride,
- struct winsys_handle *whandle);
-
-static struct dri1_api dri1_api_hooks;
-static struct dri1_api_version ddx_required = { 0, 1, 0 };
-static struct dri1_api_version ddx_compat = { 0, 0, 0 };
-static struct dri1_api_version dri_required = { 4, 0, 0 };
-static struct dri1_api_version dri_compat = { 4, 0, 0 };
-static struct dri1_api_version drm_required = { 1, 0, 0 };
-static struct dri1_api_version drm_compat = { 1, 0, 0 };
-static struct dri1_api_version drm_scanout = { 0, 9, 0 };
-
-static boolean
-vmw_dri1_check_version(const struct dri1_api_version *cur,
- const struct dri1_api_version *required,
- const struct dri1_api_version *compat,
- const char component[])
-{
- if (cur->major > required->major && cur->major <= compat->major)
- return TRUE;
- if (cur->major == required->major && cur->minor >= required->minor)
- return TRUE;
-
- fprintf(stderr, "%s version failure.\n", component);
- fprintf(stderr, "%s version is %d.%d.%d and this driver can only work\n"
- "with versions %d.%d.x through %d.x.x.\n",
- component,
- cur->major,
- cur->minor,
- cur->patch_level, required->major, required->minor, compat->major);
- return FALSE;
-}
-
-/* This is actually the entrypoint to the entire driver, called by the
- * libGL (or EGL, or ...) code via the drm_api_hooks table at the
- * bottom of the file.
- */
-static struct pipe_screen *
-vmw_drm_create_screen(struct drm_api *drm_api,
- int fd,
- struct drm_create_screen_arg *arg)
-{
- struct vmw_winsys_screen *vws;
- struct pipe_screen *screen;
- struct dri1_create_screen_arg *dri1;
- boolean use_old_scanout_flag = FALSE;
-
- if (!arg || arg->mode == DRM_CREATE_NORMAL) {
- struct dri1_api_version drm_ver;
- drmVersionPtr ver;
-
- ver = drmGetVersion(fd);
- if (ver == NULL)
- return NULL;
-
- drm_ver.major = ver->version_major;
- drm_ver.minor = ver->version_minor;
- drm_ver.patch_level = 0; /* ??? */
-
- drmFreeVersion(ver);
- if (!vmw_dri1_check_version(&drm_ver, &drm_required,
- &drm_compat, "vmwgfx drm driver"))
- return NULL;
-
- if (!vmw_dri1_check_version(&drm_ver, &drm_scanout,
- &drm_compat, "use old scanout field (not a error)"))
- use_old_scanout_flag = TRUE;
- }
-
- if (arg != NULL) {
- switch (arg->mode) {
- case DRM_CREATE_NORMAL:
- break;
- case DRM_CREATE_DRI1:
- dri1 = (struct dri1_create_screen_arg *)arg;
- if (!vmw_dri1_check_version(&dri1->ddx_version, &ddx_required,
- &ddx_compat, "ddx - driver api"))
- return NULL;
- if (!vmw_dri1_check_version(&dri1->dri_version, &dri_required,
- &dri_compat, "dri info"))
- return NULL;
- if (!vmw_dri1_check_version(&dri1->drm_version, &drm_required,
- &drm_compat, "vmwgfx drm driver"))
- return NULL;
- if (!vmw_dri1_check_version(&dri1->drm_version, &drm_scanout,
- &drm_compat, "use old scanout field (not a error)"))
- use_old_scanout_flag = TRUE;
- dri1->api = &dri1_api_hooks;
-#if 0
- break;
-#else
- assert(!"No dri 1 support for now\n");
- return NULL;
-#endif
- default:
- return NULL;
- }
- }
-
- vws = vmw_winsys_create( fd, use_old_scanout_flag );
- if (!vws)
- goto out_no_vws;
-
- /* XXX do this properly */
- vws->base.surface_from_handle = vmw_drm_surface_from_handle;
- vws->base.surface_get_handle = vmw_drm_surface_get_handle;
-
- screen = svga_screen_create( &vws->base );
- if (!screen)
- goto out_no_screen;
-
- return screen;
-
- /* Failure cases:
- */
-out_no_screen:
- vmw_winsys_destroy( vws );
-
-out_no_vws:
- return NULL;
-}
-
-static INLINE boolean
-vmw_dri1_intersect_src_bbox(struct drm_clip_rect *dst,
- int dst_x,
- int dst_y,
- const struct drm_clip_rect *src,
- const struct drm_clip_rect *bbox)
-{
- int xy1;
- int xy2;
-
- xy1 = ((int)src->x1 > (int)bbox->x1 + dst_x) ? src->x1 :
- (int)bbox->x1 + dst_x;
- xy2 = ((int)src->x2 < (int)bbox->x2 + dst_x) ? src->x2 :
- (int)bbox->x2 + dst_x;
- if (xy1 >= xy2 || xy1 < 0)
- return FALSE;
-
- dst->x1 = xy1;
- dst->x2 = xy2;
-
- xy1 = ((int)src->y1 > (int)bbox->y1 + dst_y) ? src->y1 :
- (int)bbox->y1 + dst_y;
- xy2 = ((int)src->y2 < (int)bbox->y2 + dst_y) ? src->y2 :
- (int)bbox->y2 + dst_y;
- if (xy1 >= xy2 || xy1 < 0)
- return FALSE;
-
- dst->y1 = xy1;
- dst->y2 = xy2;
- return TRUE;
-}
-
-/**
- * No fancy get-surface-from-sarea stuff here.
- * Just use the present blit.
- */
-
-static void
-vmw_dri1_present_locked(struct pipe_context *locked_pipe,
- struct pipe_surface *surf,
- const struct drm_clip_rect *rect,
- unsigned int num_clip,
- int x_draw, int y_draw,
- const struct drm_clip_rect *bbox,
- struct pipe_fence_handle **p_fence)
-{
-#if 0
- struct svga_winsys_surface *srf =
- svga_screen_texture_get_winsys_surface(surf->texture);
- struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf);
- struct vmw_winsys_screen *vws =
- vmw_winsys_screen(svga_winsys_screen(locked_pipe->screen));
- struct drm_clip_rect clip;
- int i;
- struct
- {
- SVGA3dCmdHeader header;
- SVGA3dCmdPresent body;
- SVGA3dCopyRect rect;
- } cmd;
- boolean visible = FALSE;
- uint32_t fence_seq = 0;
-
- VMW_FUNC;
- cmd.header.id = SVGA_3D_CMD_PRESENT;
- cmd.header.size = sizeof cmd.body + sizeof cmd.rect;
- cmd.body.sid = vsrf->sid;
-
- for (i = 0; i < num_clip; ++i) {
- if (!vmw_dri1_intersect_src_bbox(&clip, x_draw, y_draw, rect++, bbox))
- continue;
-
- cmd.rect.x = clip.x1;
- cmd.rect.y = clip.y1;
- cmd.rect.w = clip.x2 - clip.x1;
- cmd.rect.h = clip.y2 - clip.y1;
- cmd.rect.srcx = (int)clip.x1 - x_draw;
- cmd.rect.srcy = (int)clip.y1 - y_draw;
-
- vmw_printf("%s: Clip %d x %d y %d w %d h %d srcx %d srcy %d\n",
- __FUNCTION__,
- i,
- cmd.rect.x,
- cmd.rect.y,
- cmd.rect.w, cmd.rect.h, cmd.rect.srcx, cmd.rect.srcy);
-
- vmw_ioctl_command(vws, &cmd, sizeof cmd.header + cmd.header.size,
- &fence_seq);
- visible = TRUE;
- }
-
- *p_fence = (visible) ? vmw_pipe_fence(fence_seq) : NULL;
- vmw_svga_winsys_surface_reference(&vsrf, NULL);
-#else
- assert(!"No dri 1 support for now\n");
-#endif
-}
-
-static struct svga_winsys_surface *
-vmw_drm_surface_from_handle(struct svga_winsys_screen *sws,
- struct winsys_handle *whandle,
- SVGA3dSurfaceFormat *format)
-{
- struct vmw_svga_winsys_surface *vsrf;
- struct svga_winsys_surface *ssrf;
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- union drm_vmw_surface_reference_arg arg;
- struct drm_vmw_surface_arg *req = &arg.req;
- struct drm_vmw_surface_create_req *rep = &arg.rep;
- int ret;
- int i;
-
- /**
- * The vmware device specific handle is the hardware SID.
- * FIXME: We probably want to move this to the ioctl implementations.
- */
-
- memset(&arg, 0, sizeof(arg));
- req->sid = whandle->handle;
-
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE,
- &arg, sizeof(arg));
-
- if (ret) {
- fprintf(stderr, "Failed referencing shared surface. SID %d.\n"
- "Error %d (%s).\n",
- whandle->handle, ret, strerror(-ret));
- return NULL;
- }
-
- if (rep->mip_levels[0] != 1) {
- fprintf(stderr, "Incorrect number of mipmap levels on shared surface."
- " SID %d, levels %d\n",
- whandle->handle, rep->mip_levels[0]);
- goto out_mip;
- }
-
- for (i=1; i < DRM_VMW_MAX_SURFACE_FACES; ++i) {
- if (rep->mip_levels[i] != 0) {
- fprintf(stderr, "Incorrect number of faces levels on shared surface."
- " SID %d, face %d present.\n",
- whandle->handle, i);
- goto out_mip;
- }
- }
-
- vsrf = CALLOC_STRUCT(vmw_svga_winsys_surface);
- if (!vsrf)
- goto out_mip;
-
- pipe_reference_init(&vsrf->refcnt, 1);
- p_atomic_set(&vsrf->validated, 0);
- vsrf->screen = vws;
- vsrf->sid = whandle->handle;
- ssrf = svga_winsys_surface(vsrf);
- *format = rep->format;
-
- return ssrf;
-
-out_mip:
- vmw_ioctl_surface_destroy(vws, whandle->handle);
- return NULL;
-}
-
-static boolean
-vmw_drm_surface_get_handle(struct svga_winsys_screen *sws,
- struct svga_winsys_surface *surface,
- unsigned stride,
- struct winsys_handle *whandle)
-{
- struct vmw_svga_winsys_surface *vsrf;
-
- if (!surface)
- return FALSE;
-
- vsrf = vmw_svga_winsys_surface(surface);
- whandle->handle = vsrf->sid;
- whandle->stride = stride;
-
- return TRUE;
-}
-
-
-static struct dri1_api dri1_api_hooks = {
- .front_srf_locked = NULL,
- .present_locked = vmw_dri1_present_locked
-};
-
-static struct drm_api vmw_drm_api_hooks = {
- .name = "vmwgfx",
- .driver_name = "vmwgfx",
- .create_screen = vmw_drm_create_screen,
-};
-
-struct drm_api* drm_api_create()
-{
- return trace_drm_create(&vmw_drm_api_hooks);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
deleted file mode 100644
index 5d81fa8c4a..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_ioctl.c
+++ /dev/null
@@ -1,529 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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.
- *
- **********************************************************/
-
-/**
- * @file
- *
- * Wrappers for DRM ioctl functionlaity used by the rest of the vmw
- * drm winsys.
- *
- * Based on svgaicd_escape.c
- */
-
-
-#include "svga_cmd.h"
-#include "util/u_memory.h"
-#include "util/u_math.h"
-#include "svgadump/svga_dump.h"
-#include "vmw_screen.h"
-#include "vmw_context.h"
-#include "xf86drm.h"
-#include "vmwgfx_drm.h"
-
-#include <sys/mman.h>
-#include <errno.h>
-#include <unistd.h>
-
-struct vmw_region
-{
- SVGAGuestPtr ptr;
- uint32_t handle;
- uint64_t map_handle;
- void *data;
- uint32_t map_count;
- int drm_fd;
- uint32_t size;
-};
-
-/* XXX: This isn't a real hardware flag, but just a hack for kernel to
- * know about primary surfaces. In newer versions of the kernel
- * interface the driver uses a special field.
- */
-#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
-
-static void
-vmw_check_last_cmd(struct vmw_winsys_screen *vws)
-{
- static uint32_t buffer[16384];
- struct drm_vmw_fifo_debug_arg arg;
- int ret;
-
- return;
- memset(&arg, 0, sizeof(arg));
- arg.debug_buffer = (unsigned long)buffer;
- arg.debug_buffer_size = 65536;
-
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FIFO_DEBUG,
- &arg, sizeof(arg));
-
- if (ret) {
- debug_printf("%s Ioctl error: \"%s\".\n", __FUNCTION__, strerror(-ret));
- return;
- }
-
- if (arg.did_not_fit) {
- debug_printf("%s Command did not fit completely.\n", __FUNCTION__);
- }
-
- svga_dump_commands(buffer, arg.used_size);
-}
-
-static void
-vmw_ioctl_fifo_unmap(struct vmw_winsys_screen *vws, void *mapping)
-{
- VMW_FUNC;
- (void)munmap(mapping, getpagesize());
-}
-
-
-static void *
-vmw_ioctl_fifo_map(struct vmw_winsys_screen *vws,
- uint32_t fifo_offset )
-{
- void *map;
-
- VMW_FUNC;
-
- map = mmap(NULL, getpagesize(), PROT_READ, MAP_SHARED,
- vws->ioctl.drm_fd, fifo_offset);
-
- if (map == MAP_FAILED) {
- debug_printf("Map failed %s\n", strerror(errno));
- return NULL;
- }
-
- vmw_printf("Fifo (min) is 0x%08x\n", ((uint32_t *) map)[SVGA_FIFO_MIN]);
-
- return map;
-}
-
-uint32
-vmw_ioctl_context_create(struct vmw_winsys_screen *vws)
-{
- struct drm_vmw_context_arg c_arg;
- int ret;
-
- VMW_FUNC;
-
- ret = drmCommandRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_CONTEXT,
- &c_arg, sizeof(c_arg));
-
- if (ret)
- return -1;
-
- vmw_check_last_cmd(vws);
- vmw_printf("Context id is %d\n", c_arg.cid);
-
- return c_arg.cid;
-}
-
-void
-vmw_ioctl_context_destroy(struct vmw_winsys_screen *vws, uint32 cid)
-{
- struct drm_vmw_context_arg c_arg;
-
- VMW_FUNC;
-
- memset(&c_arg, 0, sizeof(c_arg));
- c_arg.cid = cid;
-
- (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_CONTEXT,
- &c_arg, sizeof(c_arg));
-
- vmw_check_last_cmd(vws);
-}
-
-uint32
-vmw_ioctl_surface_create(struct vmw_winsys_screen *vws,
- SVGA3dSurfaceFlags flags,
- SVGA3dSurfaceFormat format,
- SVGA3dSize size,
- uint32_t numFaces, uint32_t numMipLevels)
-{
- union drm_vmw_surface_create_arg s_arg;
- struct drm_vmw_surface_create_req *req = &s_arg.req;
- struct drm_vmw_surface_arg *rep = &s_arg.rep;
- struct drm_vmw_size sizes[DRM_VMW_MAX_SURFACE_FACES*
- DRM_VMW_MAX_MIP_LEVELS];
- struct drm_vmw_size *cur_size;
- uint32_t iFace;
- uint32_t iMipLevel;
- int ret;
-
- vmw_printf("%s flags %d format %d\n", __FUNCTION__, flags, format);
-
- memset(&s_arg, 0, sizeof(s_arg));
- if (vws->use_old_scanout_flag &&
- (flags & SVGA3D_SURFACE_HINT_SCANOUT)) {
- req->flags = (uint32_t) flags;
- req->scanout = false;
- } else if (flags & SVGA3D_SURFACE_HINT_SCANOUT) {
- req->flags = (uint32_t) (flags & ~SVGA3D_SURFACE_HINT_SCANOUT);
- req->scanout = true;
- } else {
- req->flags = (uint32_t) flags;
- req->scanout = false;
- }
- req->format = (uint32_t) format;
- req->shareable = 1;
-
- assert(numFaces * numMipLevels < DRM_VMW_MAX_SURFACE_FACES*
- DRM_VMW_MAX_MIP_LEVELS);
- cur_size = sizes;
- for (iFace = 0; iFace < numFaces; ++iFace) {
- SVGA3dSize mipSize = size;
-
- req->mip_levels[iFace] = numMipLevels;
- for (iMipLevel = 0; iMipLevel < numMipLevels; ++iMipLevel) {
- cur_size->width = mipSize.width;
- cur_size->height = mipSize.height;
- cur_size->depth = mipSize.depth;
- mipSize.width = MAX2(mipSize.width >> 1, 1);
- mipSize.height = MAX2(mipSize.height >> 1, 1);
- mipSize.depth = MAX2(mipSize.depth >> 1, 1);
- cur_size++;
- }
- }
- for (iFace = numFaces; iFace < SVGA3D_MAX_SURFACE_FACES; ++iFace) {
- req->mip_levels[iFace] = 0;
- }
-
- req->size_addr = (unsigned long)&sizes;
-
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_CREATE_SURFACE,
- &s_arg, sizeof(s_arg));
-
- if (ret)
- return -1;
-
- vmw_printf("Surface id is %d\n", rep->sid);
- vmw_check_last_cmd(vws);
-
- return rep->sid;
-}
-
-void
-vmw_ioctl_surface_destroy(struct vmw_winsys_screen *vws, uint32 sid)
-{
- struct drm_vmw_surface_arg s_arg;
-
- VMW_FUNC;
-
- memset(&s_arg, 0, sizeof(s_arg));
- s_arg.sid = sid;
-
- (void)drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_UNREF_SURFACE,
- &s_arg, sizeof(s_arg));
- vmw_check_last_cmd(vws);
-
-}
-
-void
-vmw_ioctl_command(struct vmw_winsys_screen *vws, void *commands, uint32_t size,
- uint32_t * pfence)
-{
- struct drm_vmw_execbuf_arg arg;
- struct drm_vmw_fence_rep rep;
- int ret;
-
-#ifdef DEBUG
- {
- static boolean firsttime = TRUE;
- static boolean debug = FALSE;
- static boolean skip = FALSE;
- if (firsttime) {
- debug = debug_get_bool_option("SVGA_DUMP_CMD", FALSE);
- skip = debug_get_bool_option("SVGA_SKIP_CMD", FALSE);
- }
- if (debug) {
- VMW_FUNC;
- svga_dump_commands(commands, size);
- }
- firsttime = FALSE;
- if (skip) {
- size = 0;
- }
- }
-#endif
-
- memset(&arg, 0, sizeof(arg));
- memset(&rep, 0, sizeof(rep));
-
- rep.error = -EFAULT;
- arg.fence_rep = (unsigned long)&rep;
- arg.commands = (unsigned long)commands;
- arg.command_size = size;
-
- do {
- ret = drmCommandWrite(vws->ioctl.drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
- } while(ret == -ERESTART);
- if (ret) {
- debug_printf("%s error %s.\n", __FUNCTION__, strerror(-ret));
- }
- if (rep.error) {
-
- /*
- * Kernel has synced and put the last fence sequence in the FIFO
- * register.
- */
-
- if (rep.error == -EFAULT)
- rep.fence_seq = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
-
- debug_printf("%s Fence error %s.\n", __FUNCTION__,
- strerror(-rep.error));
- }
-
- vws->ioctl.last_fence = rep.fence_seq;
-
- if (pfence)
- *pfence = rep.fence_seq;
- vmw_check_last_cmd(vws);
-
-}
-
-
-struct vmw_region *
-vmw_ioctl_region_create(struct vmw_winsys_screen *vws, uint32_t size)
-{
- struct vmw_region *region;
- union drm_vmw_alloc_dmabuf_arg arg;
- struct drm_vmw_alloc_dmabuf_req *req = &arg.req;
- struct drm_vmw_dmabuf_rep *rep = &arg.rep;
- int ret;
-
- vmw_printf("%s: size = %u\n", __FUNCTION__, size);
-
- region = CALLOC_STRUCT(vmw_region);
- if (!region)
- goto out_err1;
-
- memset(&arg, 0, sizeof(arg));
- req->size = size;
- do {
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_ALLOC_DMABUF, &arg,
- sizeof(arg));
- } while (ret == -ERESTART);
-
- if (ret) {
- debug_printf("IOCTL failed %d: %s\n", ret, strerror(-ret));
- goto out_err1;
- }
-
- region->ptr.gmrId = rep->cur_gmr_id;
- region->ptr.offset = rep->cur_gmr_offset;
- region->data = NULL;
- region->handle = rep->handle;
- region->map_handle = rep->map_handle;
- region->map_count = 0;
- region->size = size;
- region->drm_fd = vws->ioctl.drm_fd;
-
- vmw_printf(" gmrId = %u, offset = %u\n",
- region->ptr.gmrId, region->ptr.offset);
-
- return region;
-
- out_err1:
- FREE(region);
- return NULL;
-}
-
-void
-vmw_ioctl_region_destroy(struct vmw_region *region)
-{
- struct drm_vmw_unref_dmabuf_arg arg;
-
- vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
- region->ptr.gmrId, region->ptr.offset);
-
- if (region->data) {
- munmap(region->data, region->size);
- region->data = NULL;
- }
-
- memset(&arg, 0, sizeof(arg));
- arg.handle = region->handle;
- drmCommandWrite(region->drm_fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
-
- FREE(region);
-}
-
-SVGAGuestPtr
-vmw_ioctl_region_ptr(struct vmw_region *region)
-{
- return region->ptr;
-}
-
-void *
-vmw_ioctl_region_map(struct vmw_region *region)
-{
- void *map;
-
- vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
- region->ptr.gmrId, region->ptr.offset);
-
- if (region->data == NULL) {
- map = mmap(NULL, region->size, PROT_READ | PROT_WRITE, MAP_SHARED,
- region->drm_fd, region->map_handle);
- if (map == MAP_FAILED) {
- debug_printf("%s: Map failed.\n", __FUNCTION__);
- return NULL;
- }
-
- region->data = map;
- }
-
- ++region->map_count;
-
- return region->data;
-}
-
-void
-vmw_ioctl_region_unmap(struct vmw_region *region)
-{
- vmw_printf("%s: gmrId = %u, offset = %u\n", __FUNCTION__,
- region->ptr.gmrId, region->ptr.offset);
- --region->map_count;
-}
-
-
-int
-vmw_ioctl_fence_signalled(struct vmw_winsys_screen *vws,
- uint32_t fence)
-{
- uint32_t expected;
- uint32_t current;
-
- assert(fence);
- if(!fence)
- return 0;
-
- expected = fence;
- current = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
-
- if ((int32)(current - expected) >= 0)
- return 0; /* fence passed */
- else
- return -1;
-}
-
-
-static void
-vmw_ioctl_sync(struct vmw_winsys_screen *vws,
- uint32_t fence)
-{
- uint32_t cur_fence;
- struct drm_vmw_fence_wait_arg arg;
- int ret;
-
- vmw_printf("%s: fence = %lu\n", __FUNCTION__,
- (unsigned long)fence);
-
- cur_fence = vws->ioctl.fifo_map[SVGA_FIFO_FENCE];
- vmw_printf("%s: Fence id read is 0x%08x\n", __FUNCTION__,
- (unsigned int)cur_fence);
-
- if ((cur_fence - fence) < (1 << 24))
- return;
-
- memset(&arg, 0, sizeof(arg));
- arg.sequence = fence;
-
- do {
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_FENCE_WAIT, &arg,
- sizeof(arg));
- } while (ret == -ERESTART);
-}
-
-
-int
-vmw_ioctl_fence_finish(struct vmw_winsys_screen *vws,
- uint32_t fence)
-{
- assert(fence);
-
- if(fence) {
- if(vmw_ioctl_fence_signalled(vws, fence) != 0) {
- vmw_ioctl_sync(vws, fence);
- }
- }
-
- return 0;
-}
-
-
-boolean
-vmw_ioctl_init(struct vmw_winsys_screen *vws)
-{
- struct drm_vmw_getparam_arg gp_arg;
- int ret;
-
- VMW_FUNC;
-
- memset(&gp_arg, 0, sizeof(gp_arg));
- gp_arg.param = DRM_VMW_PARAM_3D;
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
- &gp_arg, sizeof(gp_arg));
- if (ret || gp_arg.value == 0) {
- debug_printf("No 3D enabled (%i, %s)\n", ret, strerror(-ret));
- goto out_err1;
- }
-
- memset(&gp_arg, 0, sizeof(gp_arg));
- gp_arg.param = DRM_VMW_PARAM_FIFO_OFFSET;
- ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_GET_PARAM,
- &gp_arg, sizeof(gp_arg));
-
- if (ret) {
- debug_printf("GET_PARAM on %d returned %d: %s\n",
- vws->ioctl.drm_fd, ret, strerror(-ret));
- goto out_err1;
- }
-
- vmw_printf("Offset to map is 0x%08llx\n",
- (unsigned long long)gp_arg.value);
-
- vws->ioctl.fifo_map = vmw_ioctl_fifo_map(vws, gp_arg.value);
- if (vws->ioctl.fifo_map == NULL)
- goto out_err1;
-
- vmw_printf("%s OK\n", __FUNCTION__);
- return TRUE;
-
- out_err1:
- debug_printf("%s Failed\n", __FUNCTION__);
- return FALSE;
-}
-
-
-
-void
-vmw_ioctl_cleanup(struct vmw_winsys_screen *vws)
-{
- VMW_FUNC;
-
- vmw_ioctl_fifo_unmap(vws, (void *)vws->ioctl.fifo_map);
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
deleted file mode 100644
index b9823d7857..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_pools.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "vmw_screen.h"
-
-#include "vmw_buffer.h"
-#include "vmw_fence.h"
-
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-
-void
-vmw_pools_cleanup(struct vmw_winsys_screen *vws)
-{
- if(vws->pools.gmr_fenced)
- vws->pools.gmr_fenced->destroy(vws->pools.gmr_fenced);
-
- /* gmr_mm pool is already destroyed above */
-
- if(vws->pools.gmr)
- vws->pools.gmr->destroy(vws->pools.gmr);
-}
-
-
-boolean
-vmw_pools_init(struct vmw_winsys_screen *vws)
-{
- vws->pools.gmr = vmw_gmr_bufmgr_create(vws);
- if(!vws->pools.gmr)
- goto error;
-
- vws->pools.gmr_mm = mm_bufmgr_create(vws->pools.gmr,
- VMW_GMR_POOL_SIZE,
- 12 /* 4096 alignment */);
- if(!vws->pools.gmr_mm)
- goto error;
-
- /*
- * GMR buffers are typically shortlived, but it's possible that at a given
- * instance a buffer is mapped. So to avoid stalling we tell pipebuffer to
- * forbid creation of buffers beyond half the GMR pool size,
- *
- * XXX: It is unclear weather we want to limit the total amount of temporary
- * malloc memory used to backup unvalidated GMR buffers. On one hand it is
- * preferrable to fail an allocation than exhausting the guest memory with
- * temporary data, but on the other hand it is possible that a stupid
- * application creates large vertex buffers and does not use them for a long
- * time -- since the svga pipe driver only emits the DMA uploads when a
- * buffer is used for drawing this would effectively disabling swapping GMR
- * buffers to memory. So far, the preemptively flush already seems to keep
- * total allocated memory within relatively small numbers, so we don't
- * limit.
- */
- vws->pools.gmr_fenced = fenced_bufmgr_create(
- vws->pools.gmr_mm,
- vmw_fence_ops_create(vws),
- VMW_GMR_POOL_SIZE/2,
- ~0);
-
-#ifdef DEBUG
- vws->pools.gmr_fenced = pb_debug_manager_create(vws->pools.gmr_fenced,
- 4096,
- 4096);
-#endif
- if(!vws->pools.gmr_fenced)
- goto error;
-
- return TRUE;
-
-error:
- vmw_pools_cleanup(vws);
- return FALSE;
-}
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
deleted file mode 100644
index 2b4e80f003..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_screen_svga.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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.
- *
- **********************************************************/
-
-/**
- * @file
- * This file implements the SVGA interface into this winsys, defined
- * in drivers/svga/svga_winsys.h.
- *
- * @author Keith Whitwell
- * @author Jose Fonseca
- */
-
-
-#include "svga_cmd.h"
-#include "svga3d_caps.h"
-
-#include "util/u_inlines.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-#include "pipebuffer/pb_buffer.h"
-#include "pipebuffer/pb_bufmgr.h"
-#include "svga_winsys.h"
-#include "vmw_context.h"
-#include "vmw_screen.h"
-#include "vmw_surface.h"
-#include "vmw_buffer.h"
-#include "vmw_fence.h"
-
-
-static struct svga_winsys_buffer *
-vmw_svga_winsys_buffer_create(struct svga_winsys_screen *sws,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- struct pb_desc desc;
- struct pb_manager *provider;
- struct pb_buffer *buffer;
-
- memset(&desc, 0, sizeof desc);
- desc.alignment = alignment;
- desc.usage = usage;
-
- provider = vws->pools.gmr_fenced;
-
- assert(provider);
- buffer = provider->create_buffer(provider, size, &desc);
- if(!buffer)
- return NULL;
-
- return vmw_svga_winsys_buffer(buffer);
-}
-
-
-static void *
-vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
- struct svga_winsys_buffer *buf,
- unsigned flags)
-{
- (void)sws;
- return pb_map(vmw_pb_buffer(buf), flags);
-}
-
-
-static void
-vmw_svga_winsys_buffer_unmap(struct svga_winsys_screen *sws,
- struct svga_winsys_buffer *buf)
-{
- (void)sws;
- pb_unmap(vmw_pb_buffer(buf));
-}
-
-
-static void
-vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws,
- struct svga_winsys_buffer *buf)
-{
- struct pb_buffer *pbuf = vmw_pb_buffer(buf);
- (void)sws;
- pb_reference(&pbuf, NULL);
-}
-
-
-static void
-vmw_svga_winsys_fence_reference(struct svga_winsys_screen *sws,
- struct pipe_fence_handle **pdst,
- struct pipe_fence_handle *src)
-{
- (void)sws;
- *pdst = src;
-}
-
-
-static int
-vmw_svga_winsys_fence_signalled(struct svga_winsys_screen *sws,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- (void)flag;
- return vmw_ioctl_fence_signalled(vws, vmw_fence(fence));
-}
-
-
-static int
-vmw_svga_winsys_fence_finish(struct svga_winsys_screen *sws,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- (void)flag;
- return vmw_ioctl_fence_finish(vws, vmw_fence(fence));
-}
-
-
-
-static struct svga_winsys_surface *
-vmw_svga_winsys_surface_create(struct svga_winsys_screen *sws,
- SVGA3dSurfaceFlags flags,
- SVGA3dSurfaceFormat format,
- SVGA3dSize size,
- uint32 numFaces,
- uint32 numMipLevels)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- struct vmw_svga_winsys_surface *surface;
-
- surface = CALLOC_STRUCT(vmw_svga_winsys_surface);
- if(!surface)
- goto no_surface;
-
- pipe_reference_init(&surface->refcnt, 1);
- p_atomic_set(&surface->validated, 0);
- surface->screen = vws;
- surface->sid = vmw_ioctl_surface_create(vws,
- flags, format, size,
- numFaces, numMipLevels);
- if(surface->sid == SVGA3D_INVALID_ID)
- goto no_sid;
-
- return svga_winsys_surface(surface);
-
-no_sid:
- FREE(surface);
-no_surface:
- return NULL;
-}
-
-
-static boolean
-vmw_svga_winsys_surface_is_flushed(struct svga_winsys_screen *sws,
- struct svga_winsys_surface *surface)
-{
- struct vmw_svga_winsys_surface *vsurf = vmw_svga_winsys_surface(surface);
- return (p_atomic_read(&vsurf->validated) == 0);
-}
-
-
-static void
-vmw_svga_winsys_surface_ref(struct svga_winsys_screen *sws,
- struct svga_winsys_surface **pDst,
- struct svga_winsys_surface *src)
-{
- struct vmw_svga_winsys_surface *d_vsurf = vmw_svga_winsys_surface(*pDst);
- struct vmw_svga_winsys_surface *s_vsurf = vmw_svga_winsys_surface(src);
-
- vmw_svga_winsys_surface_reference(&d_vsurf, s_vsurf);
- *pDst = svga_winsys_surface(d_vsurf);
-}
-
-
-static void
-vmw_svga_winsys_destroy(struct svga_winsys_screen *sws)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
-
- vmw_winsys_destroy(vws);
-}
-
-
-static boolean
-vmw_svga_winsys_get_cap(struct svga_winsys_screen *sws,
- SVGA3dDevCapIndex index,
- SVGA3dDevCapResult *result)
-{
- struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
- const uint32 *capsBlock;
- const SVGA3dCapsRecord *capsRecord = NULL;
- uint32 offset;
- const SVGA3dCapPair *capArray;
- int numCaps, first, last;
-
- if(!vws->ioctl.fifo_map)
- return FALSE;
-
- if(vws->ioctl.fifo_map[SVGA_FIFO_3D_HWVERSION] < SVGA3D_HWVERSION_WS6_B1)
- return FALSE;
-
- /*
- * Search linearly through the caps block records for the specified type.
- */
- capsBlock = (const uint32 *)&vws->ioctl.fifo_map[SVGA_FIFO_3D_CAPS];
- for (offset = 0; capsBlock[offset] != 0; offset += capsBlock[offset]) {
- const SVGA3dCapsRecord *record;
- assert(offset < SVGA_FIFO_3D_CAPS_SIZE);
- record = (const SVGA3dCapsRecord *) (capsBlock + offset);
- if ((record->header.type >= SVGA3DCAPS_RECORD_DEVCAPS_MIN) &&
- (record->header.type <= SVGA3DCAPS_RECORD_DEVCAPS_MAX) &&
- (!capsRecord || (record->header.type > capsRecord->header.type))) {
- capsRecord = record;
- }
- }
-
- if(!capsRecord)
- return FALSE;
-
- /*
- * Calculate the number of caps from the size of the record.
- */
- capArray = (const SVGA3dCapPair *) capsRecord->data;
- numCaps = (int) ((capsRecord->header.length * sizeof(uint32) -
- sizeof capsRecord->header) / (2 * sizeof(uint32)));
-
- /*
- * Binary-search for the cap with the specified index.
- */
- for (first = 0, last = numCaps - 1; first <= last; ) {
- int mid = (first + last) / 2;
-
- if ((SVGA3dDevCapIndex) capArray[mid][0] == index) {
- /*
- * Found it.
- */
- result->u = capArray[mid][1];
- return TRUE;
- }
-
- /*
- * Divide and conquer.
- */
- if ((SVGA3dDevCapIndex) capArray[mid][0] > index) {
- last = mid - 1;
- } else {
- first = mid + 1;
- }
- }
-
- return FALSE;
-}
-
-
-boolean
-vmw_winsys_screen_init_svga(struct vmw_winsys_screen *vws)
-{
- vws->base.destroy = vmw_svga_winsys_destroy;
- vws->base.get_cap = vmw_svga_winsys_get_cap;
- vws->base.context_create = vmw_svga_winsys_context_create;
- vws->base.surface_create = vmw_svga_winsys_surface_create;
- vws->base.surface_is_flushed = vmw_svga_winsys_surface_is_flushed;
- vws->base.surface_reference = vmw_svga_winsys_surface_ref;
- vws->base.buffer_create = vmw_svga_winsys_buffer_create;
- vws->base.buffer_map = vmw_svga_winsys_buffer_map;
- vws->base.buffer_unmap = vmw_svga_winsys_buffer_unmap;
- vws->base.buffer_destroy = vmw_svga_winsys_buffer_destroy;
- vws->base.fence_reference = vmw_svga_winsys_fence_reference;
- vws->base.fence_signalled = vmw_svga_winsys_fence_signalled;
- vws->base.fence_finish = vmw_svga_winsys_fence_finish;
-
- return TRUE;
-}
-
-
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.c b/src/gallium/winsys/drm/vmware/core/vmw_surface.c
deleted file mode 100644
index 5f1b9ad577..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_surface.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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 "svga_cmd.h"
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-
-#include "vmw_surface.h"
-#include "vmw_screen.h"
-
-void
-vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
- struct vmw_svga_winsys_surface *src)
-{
- struct pipe_reference *src_ref;
- struct pipe_reference *dst_ref;
- struct vmw_svga_winsys_surface *dst;
-
- if(pdst == NULL || *pdst == src)
- return;
-
- dst = *pdst;
-
- src_ref = src ? &src->refcnt : NULL;
- dst_ref = dst ? &dst->refcnt : NULL;
-
- if (pipe_reference(dst_ref, src_ref)) {
- vmw_ioctl_surface_destroy(dst->screen, dst->sid);
-#ifdef DEBUG
- /* to detect dangling pointers */
- assert(p_atomic_read(&dst->validated) == 0);
- dst->sid = SVGA3D_INVALID_ID;
-#endif
- FREE(dst);
- }
-
- *pdst = src;
-}
diff --git a/src/gallium/winsys/drm/vmware/core/vmw_surface.h b/src/gallium/winsys/drm/vmware/core/vmw_surface.h
deleted file mode 100644
index 3d61595c28..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmw_surface.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/**********************************************************
- * Copyright 2009 VMware, Inc. 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, sublicense, 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 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
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * 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.
- *
- **********************************************************/
-
-/**
- * @file
- * Surfaces for VMware SVGA winsys.
- *
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-
-#ifndef VMW_SURFACE_H_
-#define VMW_SURFACE_H_
-
-
-#include "pipe/p_compiler.h"
-#include "util/u_atomic.h"
-#include "util/u_inlines.h"
-
-#define VMW_MAX_PRESENTS 3
-
-
-
-struct vmw_svga_winsys_surface
-{
- int32_t validated; /* atomic */
- struct pipe_reference refcnt;
-
- struct vmw_winsys_screen *screen;
- uint32_t sid;
-
- /* FIXME: make this thread safe */
- unsigned next_present_no;
- uint32_t present_fences[VMW_MAX_PRESENTS];
-};
-
-
-static INLINE struct svga_winsys_surface *
-svga_winsys_surface(struct vmw_svga_winsys_surface *surf)
-{
- assert(!surf || surf->sid != SVGA3D_INVALID_ID);
- return (struct svga_winsys_surface *)surf;
-}
-
-
-static INLINE struct vmw_svga_winsys_surface *
-vmw_svga_winsys_surface(struct svga_winsys_surface *surf)
-{
- return (struct vmw_svga_winsys_surface *)surf;
-}
-
-
-void
-vmw_svga_winsys_surface_reference(struct vmw_svga_winsys_surface **pdst,
- struct vmw_svga_winsys_surface *src);
-
-#endif /* VMW_SURFACE_H_ */
diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
deleted file mode 100644
index 47914bdb71..0000000000
--- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h
+++ /dev/null
@@ -1,545 +0,0 @@
-/**************************************************************************
- *
- * Copyright © 2009 VMware, Inc., Palo Alto, CA., 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 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
- * 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.
- *
- **************************************************************************/
-
-#ifndef __VMWGFX_DRM_H__
-#define __VMWGFX_DRM_H__
-
-#define DRM_VMW_MAX_SURFACE_FACES 6
-#define DRM_VMW_MAX_MIP_LEVELS 24
-
-#define DRM_VMW_EXT_NAME_LEN 128
-
-#define DRM_VMW_GET_PARAM 0
-#define DRM_VMW_ALLOC_DMABUF 1
-#define DRM_VMW_UNREF_DMABUF 2
-#define DRM_VMW_CURSOR_BYPASS 3
-/* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
-#define DRM_VMW_CONTROL_STREAM 4
-#define DRM_VMW_CLAIM_STREAM 5
-#define DRM_VMW_UNREF_STREAM 6
-/* guarded by DRM_VMW_PARAM_3D == 1 */
-#define DRM_VMW_CREATE_CONTEXT 7
-#define DRM_VMW_UNREF_CONTEXT 8
-#define DRM_VMW_CREATE_SURFACE 9
-#define DRM_VMW_UNREF_SURFACE 10
-#define DRM_VMW_REF_SURFACE 11
-#define DRM_VMW_EXECBUF 12
-#define DRM_VMW_FIFO_DEBUG 13
-#define DRM_VMW_FENCE_WAIT 14
-
-
-/*************************************************************************/
-/**
- * DRM_VMW_GET_PARAM - get device information.
- *
- * DRM_VMW_PARAM_FIFO_OFFSET:
- * Offset to use to map the first page of the FIFO read-only.
- * The fifo is mapped using the mmap() system call on the drm device.
- *
- * DRM_VMW_PARAM_OVERLAY_IOCTL:
- * Does the driver support the overlay ioctl.
- */
-
-#define DRM_VMW_PARAM_NUM_STREAMS 0
-#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
-#define DRM_VMW_PARAM_3D 2
-#define DRM_VMW_PARAM_FIFO_OFFSET 3
-#define DRM_VMW_PARAM_HW_CAPS 4
-#define DRM_VMW_PARAM_FIFO_CAPS 5
-
-/**
- * struct drm_vmw_getparam_arg
- *
- * @value: Returned value. //Out
- * @param: Parameter to query. //In.
- *
- * Argument to the DRM_VMW_GET_PARAM Ioctl.
- */
-
-struct drm_vmw_getparam_arg {
- uint64_t value;
- uint32_t param;
- uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CREATE_CONTEXT - Create a host context.
- *
- * Allocates a device unique context id, and queues a create context command
- * for the host. Does not wait for host completion.
- */
-
-/**
- * struct drm_vmw_context_arg
- *
- * @cid: Device unique context ID.
- *
- * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
- * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
- */
-
-struct drm_vmw_context_arg {
- int32_t cid;
- uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_CONTEXT - Create a host context.
- *
- * Frees a global context id, and queues a destroy host command for the host.
- * Does not wait for host completion. The context ID can be used directly
- * in the command stream and shows up as the same context ID on the host.
- */
-
-/*************************************************************************/
-/**
- * DRM_VMW_CREATE_SURFACE - Create a host suface.
- *
- * Allocates a device unique surface id, and queues a create surface command
- * for the host. Does not wait for host completion. The surface ID can be
- * used directly in the command stream and shows up as the same surface
- * ID on the host.
- */
-
-/**
- * struct drm_wmv_surface_create_req
- *
- * @flags: Surface flags as understood by the host.
- * @format: Surface format as understood by the host.
- * @mip_levels: Number of mip levels for each face.
- * An unused face should have 0 encoded.
- * @size_addr: Address of a user-space array of sruct drm_vmw_size
- * cast to an uint64_t for 32-64 bit compatibility.
- * The size of the array should equal the total number of mipmap levels.
- * @shareable: Boolean whether other clients (as identified by file descriptors)
- * may reference this surface.
- * @scanout: Boolean whether the surface is intended to be used as a
- * scanout.
- *
- * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
- * Output data from the DRM_VMW_REF_SURFACE Ioctl.
- */
-
-struct drm_vmw_surface_create_req {
- uint32_t flags;
- uint32_t format;
- uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
- uint64_t size_addr;
- int32_t shareable;
- int32_t scanout;
-};
-
-/**
- * struct drm_wmv_surface_arg
- *
- * @sid: Surface id of created surface or surface to destroy or reference.
- *
- * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
- * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
- * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
- */
-
-struct drm_vmw_surface_arg {
- int32_t sid;
- uint32_t pad64;
-};
-
-/**
- * struct drm_vmw_size ioctl.
- *
- * @width - mip level width
- * @height - mip level height
- * @depth - mip level depth
- *
- * Description of a mip level.
- * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
- */
-
-struct drm_vmw_size {
- uint32_t width;
- uint32_t height;
- uint32_t depth;
- uint32_t pad64;
-};
-
-/**
- * union drm_vmw_surface_create_arg
- *
- * @rep: Output data as described above.
- * @req: Input data as described above.
- *
- * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
- */
-
-union drm_vmw_surface_create_arg {
- struct drm_vmw_surface_arg rep;
- struct drm_vmw_surface_create_req req;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_REF_SURFACE - Reference a host surface.
- *
- * Puts a reference on a host surface with a give sid, as previously
- * returned by the DRM_VMW_CREATE_SURFACE ioctl.
- * A reference will make sure the surface isn't destroyed while we hold
- * it and will allow the calling client to use the surface ID in the command
- * stream.
- *
- * On successful return, the Ioctl returns the surface information given
- * in the DRM_VMW_CREATE_SURFACE ioctl.
- */
-
-/**
- * union drm_vmw_surface_reference_arg
- *
- * @rep: Output data as described above.
- * @req: Input data as described above.
- *
- * Argument to the DRM_VMW_REF_SURFACE Ioctl.
- */
-
-union drm_vmw_surface_reference_arg {
- struct drm_vmw_surface_create_req rep;
- struct drm_vmw_surface_arg req;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
- *
- * Clear a reference previously put on a host surface.
- * When all references are gone, including the one implicitly placed
- * on creation,
- * a destroy surface command will be queued for the host.
- * Does not wait for completion.
- */
-
-/*************************************************************************/
-/**
- * DRM_VMW_EXECBUF
- *
- * Submit a command buffer for execution on the host, and return a
- * fence sequence that when signaled, indicates that the command buffer has
- * executed.
- */
-
-/**
- * struct drm_vmw_execbuf_arg
- *
- * @commands: User-space address of a command buffer cast to an uint64_t.
- * @command-size: Size in bytes of the command buffer.
- * @throttle-us: Sleep until software is less than @throttle_us
- * microseconds ahead of hardware. The driver may round this value
- * to the nearest kernel tick.
- * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
- * uint64_t.
- * @version: Allows expanding the execbuf ioctl parameters without breaking
- * backwards compatibility, since user-space will always tell the kernel
- * which version it uses.
- * @flags: Execbuf flags. None currently.
- *
- * Argument to the DRM_VMW_EXECBUF Ioctl.
- */
-
-#define DRM_VMW_EXECBUF_VERSION 0
-
-struct drm_vmw_execbuf_arg {
- uint64_t commands;
- uint32_t command_size;
- uint32_t throttle_us;
- uint64_t fence_rep;
- uint32_t version;
- uint32_t flags;
-};
-
-/**
- * struct drm_vmw_fence_rep
- *
- * @fence_seq: Fence sequence associated with a command submission.
- * @error: This member should've been set to -EFAULT on submission.
- * The following actions should be take on completion:
- * error == -EFAULT: Fence communication failed. The host is synchronized.
- * Use the last fence id read from the FIFO fence register.
- * error != 0 && error != -EFAULT:
- * Fence submission failed. The host is synchronized. Use the fence_seq member.
- * error == 0: All is OK, The host may not be synchronized.
- * Use the fence_seq member.
- *
- * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
- */
-
-struct drm_vmw_fence_rep {
- uint64_t fence_seq;
- int32_t error;
- uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_ALLOC_DMABUF
- *
- * Allocate a DMA buffer that is visible also to the host.
- * NOTE: The buffer is
- * identified by a handle and an offset, which are private to the guest, but
- * useable in the command stream. The guest kernel may translate these
- * and patch up the command stream accordingly. In the future, the offset may
- * be zero at all times, or it may disappear from the interface before it is
- * fixed.
- *
- * The DMA buffer may stay user-space mapped in the guest at all times,
- * and is thus suitable for sub-allocation.
- *
- * DMA buffers are mapped using the mmap() syscall on the drm device.
- */
-
-/**
- * struct drm_vmw_alloc_dmabuf_req
- *
- * @size: Required minimum size of the buffer.
- *
- * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
- */
-
-struct drm_vmw_alloc_dmabuf_req {
- uint32_t size;
- uint32_t pad64;
-};
-
-/**
- * struct drm_vmw_dmabuf_rep
- *
- * @map_handle: Offset to use in the mmap() call used to map the buffer.
- * @handle: Handle unique to this buffer. Used for unreferencing.
- * @cur_gmr_id: GMR id to use in the command stream when this buffer is
- * referenced. See not above.
- * @cur_gmr_offset: Offset to use in the command stream when this buffer is
- * referenced. See note above.
- *
- * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
- */
-
-struct drm_vmw_dmabuf_rep {
- uint64_t map_handle;
- uint32_t handle;
- uint32_t cur_gmr_id;
- uint32_t cur_gmr_offset;
- uint32_t pad64;
-};
-
-/**
- * union drm_vmw_dmabuf_arg
- *
- * @req: Input data as described above.
- * @rep: Output data as described above.
- *
- * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
- */
-
-union drm_vmw_alloc_dmabuf_arg {
- struct drm_vmw_alloc_dmabuf_req req;
- struct drm_vmw_dmabuf_rep rep;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
- *
- */
-
-/**
- * struct drm_vmw_unref_dmabuf_arg
- *
- * @handle: Handle indicating what buffer to free. Obtained from the
- * DRM_VMW_ALLOC_DMABUF Ioctl.
- *
- * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
- */
-
-struct drm_vmw_unref_dmabuf_arg {
- uint32_t handle;
- uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
- *
- * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
- */
-
-/**
- * struct drm_vmw_fifo_debug_arg
- *
- * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
- * @debug_buffer_size: Size in bytes of debug buffer //In
- * @used_size: Number of bytes copied to the buffer // Out
- * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
- *
- * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
- */
-
-struct drm_vmw_fifo_debug_arg {
- uint64_t debug_buffer;
- uint32_t debug_buffer_size;
- uint32_t used_size;
- int32_t did_not_fit;
- uint32_t pad64;
-};
-
-struct drm_vmw_fence_wait_arg {
- uint64_t sequence;
- uint64_t kernel_cookie;
- int32_t cookie_valid;
- int32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
- *
- * This IOCTL controls the overlay units of the svga device.
- * The SVGA overlay units does not work like regular hardware units in
- * that they do not automaticaly read back the contents of the given dma
- * buffer. But instead only read back for each call to this ioctl, and
- * at any point between this call being made and a following call that
- * either changes the buffer or disables the stream.
- */
-
-/**
- * struct drm_vmw_rect
- *
- * Defines a rectangle. Used in the overlay ioctl to define
- * source and destination rectangle.
- */
-
-struct drm_vmw_rect {
- int32_t x;
- int32_t y;
- uint32_t w;
- uint32_t h;
-};
-
-/**
- * struct drm_vmw_control_stream_arg
- *
- * @stream_id: Stearm to control
- * @enabled: If false all following arguments are ignored.
- * @handle: Handle to buffer for getting data from.
- * @format: Format of the overlay as understood by the host.
- * @width: Width of the overlay.
- * @height: Height of the overlay.
- * @size: Size of the overlay in bytes.
- * @pitch: Array of pitches, the two last are only used for YUV12 formats.
- * @offset: Offset from start of dma buffer to overlay.
- * @src: Source rect, must be within the defined area above.
- * @dst: Destination rect, x and y may be negative.
- *
- * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
- */
-
-struct drm_vmw_control_stream_arg {
- uint32_t stream_id;
- uint32_t enabled;
-
- uint32_t flags;
- uint32_t color_key;
-
- uint32_t handle;
- uint32_t offset;
- int32_t format;
- uint32_t size;
- uint32_t width;
- uint32_t height;
- uint32_t pitch[3];
-
- uint32_t pad64;
- struct drm_vmw_rect src;
- struct drm_vmw_rect dst;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
- *
- */
-
-#define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
-#define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
-
-/**
- * struct drm_vmw_cursor_bypass_arg
- *
- * @flags: Flags.
- * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
- * @xpos: X position of cursor.
- * @ypos: Y position of cursor.
- * @xhot: X hotspot.
- * @yhot: Y hotspot.
- *
- * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
- */
-
-struct drm_vmw_cursor_bypass_arg {
- uint32_t flags;
- uint32_t crtc_id;
- int32_t xpos;
- int32_t ypos;
- int32_t xhot;
- int32_t yhot;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_CLAIM_STREAM - Claim a single stream.
- */
-
-/**
- * struct drm_vmw_context_arg
- *
- * @stream_id: Device unique context ID.
- *
- * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
- * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
- */
-
-struct drm_vmw_stream_arg {
- uint32_t stream_id;
- uint32_t pad64;
-};
-
-/*************************************************************************/
-/**
- * DRM_VMW_UNREF_STREAM - Unclaim a stream.
- *
- * Return a single stream that was claimed by this process. Also makes
- * sure that the stream has been stopped.
- */
-
-#endif