summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCooper Yuan <cooperyuan@gmail.com>2009-09-21 14:46:21 +0800
committerCooper Yuan <cooperyuan@gmail.com>2009-09-21 14:46:21 +0800
commitc77966af19fcf5c7887a2cde0420dd5af86733d3 (patch)
treebd44b22617fca90b5cf15da014808a2f8cf5e141
parent0178f5c950a9d501fbd74f722f86cb0ed0a2e62c (diff)
xvmc: add hardware context and screen management, not finished
-rw-r--r--src/gallium/winsys/g3dvl/radeon/Makefile45
-rw-r--r--src/gallium/winsys/g3dvl/radeon/radeon_vl.c239
-rw-r--r--src/gallium/winsys/g3dvl/radeon/radeon_vl.h51
-rw-r--r--src/xvmc/Makefile14
4 files changed, 342 insertions, 7 deletions
diff --git a/src/gallium/winsys/g3dvl/radeon/Makefile b/src/gallium/winsys/g3dvl/radeon/Makefile
new file mode 100644
index 000000000..464a751b5
--- /dev/null
+++ b/src/gallium/winsys/g3dvl/radeon/Makefile
@@ -0,0 +1,45 @@
+TARGET = libradeon_dri.so
+GALLIUMDIR = ../../..
+DRMDIR ?= /usr
+DRIDIR = ../../../../driclient
+
+OBJECTS = radeon_vl.o
+
+CFLAGS += -g -Wall -Werror=implicit-function-declaration -fPIC \
+ -I${GALLIUMDIR}/include \
+ -I${GALLIUMDIR}/winsys/g3dvl \
+ -I${GALLIUMDIR}/winsys/drm/nouveau \
+ -I${DRMDIR}/include \
+ -I${DRMDIR}/include/drm \
+ -I${DRMDIR}/include/nouveau \
+ -I${GALLIUMDIR}/drivers \
+ -I${GALLIUMDIR}/auxiliary \
+ -I${DRIDIR}/include
+
+LDFLAGS += -L${DRMDIR}/lib \
+ -L${DRIDIR}/lib \
+ -L${GALLIUMDIR}/winsys/drm/nouveau/common \
+ -L${GALLIUMDIR}/auxiliary/draw \
+ -L${GALLIUMDIR}/auxiliary/tgsi \
+ -L${GALLIUMDIR}/auxiliary/translate \
+ -L${GALLIUMDIR}/auxiliary/rtasm \
+ -L${GALLIUMDIR}/auxiliary/cso_cache \
+ -L${GALLIUMDIR}/drivers/r300
+
+LIBS += -lradeondrm -ldriclient -ldrm_nouveau -ldrm -lradeon -ldraw -ltgsi -ltranslate -lrtasm -lcso_cache -lm
+
+#############################################
+
+.PHONY = all clean libdriclient
+
+all: ${TARGET}
+
+${TARGET}: ${OBJECTS} libdriclient
+ $(CC) ${LDFLAGS} -shared -o $@ ${OBJECTS} ${LIBS}
+
+libdriclient:
+ cd ${DRIDIR}/src; ${MAKE}
+
+clean:
+ cd ${DRIDIR}/src; ${MAKE} clean
+ rm -rf ${OBJECTS} ${TARGET}
diff --git a/src/gallium/winsys/g3dvl/radeon/radeon_vl.c b/src/gallium/winsys/g3dvl/radeon/radeon_vl.c
new file mode 100644
index 000000000..acca20c8b
--- /dev/null
+++ b/src/gallium/winsys/g3dvl/radeon/radeon_vl.c
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2008 Advanced Micro Devices, Inc.
+ *
+ * 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 (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 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: Cooper Yuan <cooper.yuan@amd.com>
+ *
+ */
+
+#include <pipe/p_defines.h>
+#include <pipe/p_context.h>
+#include <pipe/p_screen.h>
+#include <util/u_memory.h>
+#include <common/nouveau_dri.h>
+#include <common/nouveau_local.h>
+#include <common/nouveau_winsys_pipe.h>
+
+#include "radeon_vl.h"
+
+static int radeon_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_version_t *ddx)
+{
+ static const dri_version_t ddx_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
+ static const dri_version_t dri_expected = {4, 0, 0};
+ static const dri_version_t drm_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
+
+ assert(dri);
+ assert(drm);
+ assert(ddx);
+
+ if (dri->major != dri_expected.major || dri->minor < dri_expected.minor)
+ {
+ NOUVEAU_ERR("Unexpected DRI version.\n");
+ return 1;
+ }
+ if (drm->major != drm_expected.major || drm->minor < drm_expected.minor)
+ {
+ NOUVEAU_ERR("Unexpected DRM version.\n");
+ return 1;
+ }
+ if (ddx->major != ddx_expected.major || ddx->minor < ddx_expected.minor)
+ {
+ NOUVEAU_ERR("Unexpected DDX version.\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static int radeon_vl_context_create(dri_context_t *dri_context)
+{
+ dri_screen_t *dri_screen;
+ struct radeon_vl_screen *rvl_screen;
+ struct radeon_vl_context *rvl_ctx;
+
+ assert (dri_context);
+
+ dri_screen = dri_context->dri_screen;
+ rvl_screen = dri_screen->private;
+ rvl_ctx = CALLOC_STRUCT(nouveau_context_vl);
+
+ if (!rvl_ctx)
+ return 1;
+
+ if (nouveau_context_init(&nv_screen->base, dri_context->drm_context,
+ (drmLock*)&dri_screen->sarea->lock, NULL, &rvl_ctx->base))
+ {
+ FREE(rvl_ctx);
+ return 1;
+ }
+
+ dri_context->private = (void*)rvl_ctx
+ rvl_ctx->dri_context = dri_context;
+ rvl_ctx->nv_screen = rvl_screen;
+
+ rvl_ctx->base.nvc->pctx[rvl_ctx->base.pctx_id]->priv = rvl_ctx;
+
+ return 0;
+}
+
+static void radeon_vl_context_destroy(dri_context_t *dri_context)
+{
+ struct radeon_vl_context *rvl_ctx = dri_context->private;
+
+ assert(dri_context);
+
+ nouveau_context_cleanup(&nv->base);
+
+ FREE(nv);
+}
+
+static int radeon_vl_context_bind(struct radeon_vl_context *rvl_ctx, dri_drawable_t *dri_drawable)
+{
+ assert(rvl_ctx);
+ assert(dri_drawable);
+
+ if (rvl_ctx->dri_drawable != dri_drawable)
+ {
+ rvl_ctx->dri_drawable = dri_drawable;
+ dri_drawable->private = rvl_ctx;
+ }
+
+ return 0;
+}
+
+static int radeon_vl_context_unbind(struct radeon_vl_context *rvl_ctx)
+{
+ assert(rvl_ctx);
+
+ rvl_ctx->dri_drawable = NULL;
+
+ return 0;
+}
+
+static int radeon_vl_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf)
+{
+ struct nouveau_dri *nv_dri = dri_framebuf->private;
+ struct nouveau_screen_vl *nv_screen;
+
+ assert(dri_screen);
+ assert(dri_framebuf);
+
+ if (nouveau_check_dri_drm_ddx(&dri_screen->dri, &dri_screen->drm, &dri_screen->ddx))
+ return 1;
+
+ nv_screen = CALLOC_STRUCT(nouveau_screen_vl);
+
+ if (!nv_screen)
+ return 1;
+
+ if (nouveau_screen_init(nv_dri, dri_screen->fd, &nv_screen->base))
+ {
+ FREE(nv_screen);
+ return 1;
+ }
+
+ nv_screen->dri_screen = dri_screen;
+ dri_screen->private = (void*)nv_screen;
+
+ return 0;
+}
+
+static void radeon_vl_screen_destroy(dri_screen_t *dri_screen)
+{
+ struct nouveau_screen_vl *nv_screen = dri_screen->private;
+
+ radeon_screen_cleanup(&nv_screen->base);
+ FREE(nv_screen);
+}
+
+/*
+ * The following 4 functions are exported to xvmc.
+ */
+int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
+{
+ struct radeon_vl_context *rvl_ctx;
+ dri_drawable_t *dri_drawable;
+
+ assert(pipe);
+
+ rvl_ctx = pipe->priv;
+ driCreateDrawable(rvl_ctx->nv_screen->dri_screen, drawable, &dri_drawable);
+ radeon_vl_context_bind(rvl_ctx, dri_drawable);
+
+ return 0;
+}
+
+int unbind_pipe_drawable(struct pipe_context *pipe)
+{
+ assert (pipe);
+
+ radeon_vl_context_unbind(pipe->priv);
+
+ return 0;
+}
+
+struct pipe_context* create_pipe_context(Display *display, int screen)
+{
+ dri_screen_t *dri_screen;
+ dri_framebuffer_t dri_framebuf;
+ dri_context_t *dri_context;
+ struct radeon_vl_context *rvl_ctx;
+
+ assert(display);
+
+ driCreateScreen(display, screen, &dri_screen, &dri_framebuf);
+ driCreateContext(dri_screen, XDefaultVisual(display, screen), &dri_context);
+
+ radeon_vl_screen_create(dri_screen, &dri_framebuf);
+ radeon_vl_context_create(dri_context);
+
+ rvl_ctx = dri_context->private;
+
+ return rvl_ctx->base.nvc->pctx[rvl_ctx->base.pctx_id];
+}
+
+int destroy_pipe_context(struct pipe_context *pipe)
+{
+ struct pipe_screen *screen;
+ struct pipe_winsys *winsys;
+ struct nouveau_context_vl *rvl_ctx;
+ dri_screen_t *dri_screen;
+ dri_context_t *dri_context;
+
+ assert(pipe);
+
+ screen = pipe->screen;
+ winsys = pipe->winsys;
+ rvl_ctx = pipe->priv;
+ dri_context = rvl_ctx->dri_context;
+ dri_screen = dri_context->dri_screen;
+
+ pipe->destroy(pipe);
+ screen->destroy(screen);
+ FREE(winsys);
+
+ radeon_vl_context_destroy(dri_context);
+ radeon_vl_screen_destroy(dri_screen);
+ driDestroyContext(dri_context);
+ driDestroyScreen(dri_screen);
+
+ return 0;
+}
diff --git a/src/gallium/winsys/g3dvl/radeon/radeon_vl.h b/src/gallium/winsys/g3dvl/radeon/radeon_vl.h
new file mode 100644
index 000000000..69f148f66
--- /dev/null
+++ b/src/gallium/winsys/g3dvl/radeon/radeon_vl.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2008 Advanced Micro Devices, Inc.
+ *
+ * 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 (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 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: Cooper Yuan <cooper.yuan@amd.com>
+ *
+ */
+
+#ifndef __RADEON_VL_H__
+#define __RADEON_VL_H__
+
+#include <driclient.h>
+#include <nouveau/radeon_winsys.h>
+#include <common/radeon_context.h>
+
+struct radeon_vl_context
+{
+ struct radeon_context base;
+ struct radeon_vl_screen *rvl_screen;
+ dri_context_t *dri_context;
+ dri_drawable_t *dri_drawable;
+ unsigned int last_stamp;
+ drm_context_t drm_context;
+ drmLock drm_lock;
+};
+
+struct radeon_vl_screen
+{
+ struct radeon_screen base;
+ dri_screen_t *dri_screen;
+};
+
+#endif //__RADEON_CONTEXT_VL_H__ \ No newline at end of file
diff --git a/src/xvmc/Makefile b/src/xvmc/Makefile
index 7badcfd26..87a78e355 100644
--- a/src/xvmc/Makefile
+++ b/src/xvmc/Makefile
@@ -26,14 +26,14 @@ LDFLAGS += -L${GALLIUMDIR}/state_trackers/g3dvl \
-L${GALLIUMDIR}/auxiliary/rtasm
else
LDFLAGS += -L${GALLIUMDIR}/state_trackers/g3dvl \
- -L${GALLIUMDIR}/winsys/g3dvl/nouveau \
+ -L${GALLIUMDIR}/winsys/g3dvl/radeon \
-L${GALLIUMDIR}/auxiliary/util
endif
ifeq (${DRIVER}, softpipe)
LIBS += -lg3dvl -lsoftpipe -ldraw -ltgsi -ltranslate -lrtasm -lcso_cache -lutil -lm
else
-LIBS += -lg3dvl -lnouveau_dri -lutil
+LIBS += -lg3dvl -lradeon_dri -lutil
endif
#############################################
@@ -41,7 +41,7 @@ endif
ifeq (${DRIVER}, softpipe)
.PHONY = all clean g3dvl
else
-.PHONY = all clean g3dvl nouveau_winsys
+.PHONY = all clean g3dvl radeon_winsys
endif
all: ${TARGET}
@@ -57,17 +57,17 @@ clean:
cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE} clean
rm -rf ${OBJECTS} ${TARGET}
else
-${TARGET}: ${OBJECTS} g3dvl nouveau_winsys
+${TARGET}: ${OBJECTS} g3dvl radeon_winsys
$(CC) ${LDFLAGS} -shared -Wl,-soname,${SONAME} -o $@ ${OBJECTS} ${LIBS}
g3dvl:
cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE}
-nouveau_winsys:
- cd ${GALLIUMDIR}/winsys/g3dvl/nouveau; ${MAKE}
+radeon_winsys:
+ cd ${GALLIUMDIR}/winsys/g3dvl/radeon; ${MAKE}
clean:
cd ${GALLIUMDIR}/state_trackers/g3dvl; ${MAKE} clean
- cd ${GALLIUMDIR}/winsys/g3dvl/nouveau; ${MAKE} clean
+ cd ${GALLIUMDIR}/winsys/g3dvl/radeon; ${MAKE} clean
rm -rf ${OBJECTS} ${TARGET}
endif