Permalink
Browse files

tegra: Gallium driver for NVIDIA Tegra

Add a stub Gallium driver for NVIDIA Tegra SoCs to serve as a basis for
future development. The driver contains enough stubs to allow Wayland's
reference compositor Weston to run, though without any actual output.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
  • Loading branch information...
Thierry Reding
Thierry Reding committed Mar 26, 2013
1 parent 43a8a6d commit b33282cb998321786217c0026f9a17a0ba48abb5
View
@@ -36,6 +36,7 @@ LIBDRM_INTEL_REQUIRED=2.4.38
LIBDRM_NVVIEUX_REQUIRED=2.4.33
LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
LIBDRM_FREEDRENO_REQUIRED=2.4.39
+LIBDRM_TEGRA_REQUIRED=2.4.42
DRI2PROTO_REQUIRED=2.6
GLPROTO_REQUIRED=1.4.14
LIBDRM_XORG_REQUIRED=2.4.24
@@ -1848,6 +1849,13 @@ if test "x$with_gallium_drivers" != x; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS freedreno"
gallium_check_st "freedreno/drm" "dri-freedreno" "" "" "" ""
;;
+ xtegra)
+ HAVE_GALLIUM_TEGRA=yes
+ PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED])
+ gallium_require_drm_loader
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS tegra"
+ gallium_check_st "tegra/drm" "dri-tegra" "" "" "" ""
+ ;;
xswrast)
HAVE_GALLIUM_SOFTPIPE=yes
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
@@ -1929,6 +1937,7 @@ AM_CONDITIONAL(HAVE_GALLIUM_R600, test "x$HAVE_GALLIUM_R600" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_RADEONSI, test "x$HAVE_GALLIUM_RADEONSI" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_NOUVEAU, test "x$HAVE_GALLIUM_NOUVEAU" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_FREEDRENO, test "x$HAVE_GALLIUM_FREEDRENO" = xyes)
+AM_CONDITIONAL(HAVE_GALLIUM_TEGRA, test "x$HAVE_GALLIUM_TEGRA" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_SOFTPIPE, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test "x$HAVE_GALLIUM_LLVMPIPE" = xyes)
@@ -2061,6 +2070,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/drivers/rbug/Makefile
src/gallium/drivers/softpipe/Makefile
src/gallium/drivers/svga/Makefile
+ src/gallium/drivers/tegra/Makefile
src/gallium/drivers/trace/Makefile
src/gallium/state_trackers/Makefile
src/gallium/state_trackers/clover/Makefile
@@ -2084,6 +2094,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/targets/dri-r600/Makefile
src/gallium/targets/dri-radeonsi/Makefile
src/gallium/targets/dri-swrast/Makefile
+ src/gallium/targets/dri-tegra/Makefile
src/gallium/targets/dri-vmwgfx/Makefile
src/gallium/targets/egl-static/Makefile
src/gallium/targets/gbm/Makefile
@@ -2122,6 +2133,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/winsys/sw/wayland/Makefile
src/gallium/winsys/sw/wrapper/Makefile
src/gallium/winsys/sw/xlib/Makefile
+ src/gallium/winsys/tegra/drm/Makefile
src/gbm/Makefile
src/gbm/main/gbm.pc
src/glsl/Makefile
@@ -0,0 +1,24 @@
+include $(top_srcdir)/src/gallium/Automake.inc
+
+noinst_LTLIBRARIES = libtegra.la
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src/gallium/drivers/tegra/include \
+ -I$(top_srcdir)/src/gallium/drivers \
+ -I$(top_srcdir)/include
+
+AM_CFLAGS = \
+ $(GALLIUM_CFLAGS) \
+ $(LIBDRM_CFLAGS)
+
+libtegra_la_SOURCES = \
+ tegra_context.c \
+ tegra_context.h \
+ tegra_resource.c \
+ tegra_resource.h \
+ tegra_screen.c \
+ tegra_screen.h \
+ tegra_state.c \
+ tegra_state.h \
+ tegra_surface.c \
+ tegra_surface.h
@@ -0,0 +1,57 @@
+#include <stdio.h>
+
+#include "tegra_context.h"
+#include "tegra_state.h"
+#include "tegra_surface.h"
+
+static void tegra_context_destroy(struct pipe_context *pcontext)
+{
+ struct tegra_context *context = tegra_context(pcontext);
+
+ fprintf(stdout, "> %s(pcontext=%p)\n", __func__, pcontext);
+
+ free(context);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_context_flush(struct pipe_context *pcontext,
+ struct pipe_fence_handle **fence,
+ enum pipe_flush_flags flags)
+{
+ fprintf(stdout, "> %s(pcontext=%p, fence=%p, flags=%x)\n", __func__,
+ pcontext, fence, flags);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+struct pipe_context *tegra_screen_context_create(struct pipe_screen *pscreen,
+ void *priv)
+{
+ struct tegra_context *context;
+
+ fprintf(stdout, "> %s(pscreen=%p, priv=%p)\n", __func__, pscreen, priv);
+
+ context = calloc(1, sizeof(*context));
+ if (!context) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ context->base.screen = pscreen;
+ context->base.priv = priv;
+
+ context->base.destroy = tegra_context_destroy;
+ context->base.flush = tegra_context_flush;
+
+ tegra_context_surface_init(&context->base);
+ tegra_context_state_init(&context->base);
+ tegra_context_blend_init(&context->base);
+ tegra_context_rasterizer_init(&context->base);
+ tegra_context_zsa_init(&context->base);
+ tegra_context_vs_init(&context->base);
+ tegra_context_fs_init(&context->base);
+ tegra_context_vbo_init(&context->base);
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &context->base);
+ return &context->base;
+}
@@ -0,0 +1,18 @@
+#ifndef TEGRA_CONTEXT_H
+#define TEGRA_CONTEXT_H
+
+#include "pipe/p_context.h"
+
+struct tegra_context {
+ struct pipe_context base;
+};
+
+static INLINE struct tegra_context *tegra_context(struct pipe_context *context)
+{
+ return (struct tegra_context *)context;
+}
+
+struct pipe_context *tegra_screen_context_create(struct pipe_screen *pscreen,
+ void *priv);
+
+#endif
@@ -0,0 +1,94 @@
+#include <stdio.h>
+
+#include "util/u_inlines.h"
+
+#include "tegra_resource.h"
+
+static boolean
+tegra_screen_can_create_resource(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ bool ret = TRUE;
+ fprintf(stdout, "> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
+ template);
+ fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ struct tegra_resource *resource;
+
+ fprintf(stdout, "> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
+ template);
+
+ resource = calloc(1, sizeof(*resource));
+ if (!resource) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ resource->base = *template;
+
+ pipe_reference_init(&resource->base.reference, 1);
+ resource->base.screen = pscreen;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &resource->base);
+ return &resource->base;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *handle)
+{
+ struct tegra_resource *resource;
+
+ fprintf(stdout, "> %s(pscreen=%p, template=%p, handle=%p)\n",
+ __func__, pscreen, template, handle);
+
+ resource = calloc(1, sizeof(*resource));
+ if (!resource) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ resource->base = *template;
+
+ pipe_reference_init(&resource->base.reference, 1);
+ resource->base.screen = pscreen;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &resource->base);
+ return &resource->base;
+}
+
+static boolean
+tegra_screen_resource_get_handle(struct pipe_screen *pscreen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ boolean ret = TRUE;
+ fprintf(stdout, "> %s(pscreen=%p, resource=%p, handle=%p)\n",
+ __func__, pscreen, resource, handle);
+ fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static void tegra_screen_resource_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *resource)
+{
+ fprintf(stdout, "> %s(pscreen=%p, resource=%p)\n", __func__, pscreen,
+ resource);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_screen_resource_init(struct pipe_screen *pscreen)
+{
+ pscreen->can_create_resource = tegra_screen_can_create_resource;
+ pscreen->resource_create = tegra_screen_resource_create;
+ pscreen->resource_from_handle = tegra_screen_resource_from_handle;
+ pscreen->resource_get_handle = tegra_screen_resource_get_handle;
+ pscreen->resource_destroy = tegra_screen_resource_destroy;
+}
@@ -0,0 +1,13 @@
+#ifndef TEGRA_RESOURCE_H
+#define TEGRA_RESOURCE_H
+
+#include "pipe/p_screen.h"
+#include "pipe/p_state.h"
+
+struct tegra_resource {
+ struct pipe_resource base;
+};
+
+void tegra_screen_resource_init(struct pipe_screen *pscreen);
+
+#endif
Oops, something went wrong.

0 comments on commit b33282c

Please sign in to comment.