[Mesa-dev] [RFC 2/2] gallium: add tegra support

Alexandre Courbot gnurou at gmail.com
Mon Oct 12 20:44:42 PDT 2015


On Mon, Oct 12, 2015 at 12:09 AM, Christian Gmeiner
<christian.gmeiner at gmail.com> wrote:
> This commit adds tegra support, which uses the renderonly driver
> library.
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
>  configure.ac                                       | 19 +++++++-
>  src/gallium/Makefile.am                            |  6 +++
>  .../auxiliary/target-helpers/inline_drm_helper.h   | 29 ++++++++++++
>  src/gallium/drivers/tegra/Automake.inc             | 10 +++++
>  src/gallium/drivers/tegra/Makefile.am              |  9 ++++
>  src/gallium/targets/dri/Makefile.am                |  2 +
>  src/gallium/winsys/tegra/drm/Android.mk            | 34 +++++++++++++++
>  src/gallium/winsys/tegra/drm/Makefile.am           | 33 ++++++++++++++
>  src/gallium/winsys/tegra/drm/Makefile.sources      |  3 ++
>  src/gallium/winsys/tegra/drm/tegra_drm_public.h    | 31 +++++++++++++
>  src/gallium/winsys/tegra/drm/tegra_drm_winsys.c    | 51 ++++++++++++++++++++++
>  11 files changed, 226 insertions(+), 1 deletion(-)
>  create mode 100644 src/gallium/drivers/tegra/Automake.inc
>  create mode 100644 src/gallium/drivers/tegra/Makefile.am
>  create mode 100644 src/gallium/winsys/tegra/drm/Android.mk
>  create mode 100644 src/gallium/winsys/tegra/drm/Makefile.am
>  create mode 100644 src/gallium/winsys/tegra/drm/Makefile.sources
>  create mode 100644 src/gallium/winsys/tegra/drm/tegra_drm_public.h
>  create mode 100644 src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
>
> diff --git a/configure.ac b/configure.ac
> index ea485b1..9fb8244 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -75,6 +75,7 @@ LIBDRM_INTEL_REQUIRED=2.4.61
>  LIBDRM_NVVIEUX_REQUIRED=2.4.33
>  LIBDRM_NOUVEAU_REQUIRED=2.4.62
>  LIBDRM_FREEDRENO_REQUIRED=2.4.65
> +LIBDRM_TEGRA_REQUIRED=2.4.58
>  DRI2PROTO_REQUIRED=2.6
>  DRI3PROTO_REQUIRED=1.0
>  PRESENTPROTO_REQUIRED=1.0
> @@ -864,7 +865,7 @@ GALLIUM_DRIVERS_DEFAULT="r300,r600,svga,swrast"
>  AC_ARG_WITH([gallium-drivers],
>      [AS_HELP_STRING([--with-gallium-drivers@<:@=DIRS...@:>@],
>          [comma delimited Gallium drivers list, e.g.
> -        "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4"
> +        "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,tegra,vc4"
>          @<:@default=r300,r600,svga,swrast@:>@])],
>      [with_gallium_drivers="$withval"],
>      [with_gallium_drivers="$GALLIUM_DRIVERS_DEFAULT"])
> @@ -2166,6 +2167,12 @@ if test -n "$with_gallium_drivers"; then
>                  HAVE_GALLIUM_LLVMPIPE=yes
>              fi
>              ;;
> +        xtegra)
> +            HAVE_GALLIUM_TEGRA=yes
> +            PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED])
> +            gallium_require_drm "tegra"
> +            gallium_require_drm_loader
> +            ;;
>          xvc4)
>              HAVE_GALLIUM_VC4=yes
>              gallium_require_drm "vc4"
> @@ -2181,6 +2188,13 @@ if test -n "$with_gallium_drivers"; then
>      done
>  fi
>
> +dnl We need to validate some needed dependencies for renderonly drivers.
> +
> +if test "x$HAVE_GALLIUM_NOUVEAU" != xyes -a "x$HAVE_GALLIUM_TEGRA" == xyes  ; then
> +    AC_ERROR([Building with tegra requires that nouveau])
> +fi
> +
> +
>  dnl Set LLVM_LIBS - This is done after the driver configuration so
>  dnl that drivers can add additional components to LLVM_COMPONENTS.
>  dnl Previously, gallium drivers were updating LLVM_LIBS directly
> @@ -2245,6 +2259,7 @@ AM_CONDITIONAL(HAVE_GALLIUM_FREEDRENO, test "x$HAVE_GALLIUM_FREEDRENO" = xyes)
>  AM_CONDITIONAL(HAVE_GALLIUM_SOFTPIPE, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes)
>  AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test "x$HAVE_GALLIUM_LLVMPIPE" = xyes)
>  AM_CONDITIONAL(HAVE_GALLIUM_VC4, test "x$HAVE_GALLIUM_VC4" = xyes)
> +AM_CONDITIONAL(HAVE_GALLIUM_TEGRA, test "x$HAVE_GALLIUM_TEGRA" = xyes)
>
>  AM_CONDITIONAL(HAVE_GALLIUM_STATIC_TARGETS, test "x$enable_shared_pipe_drivers" = xno)
>
> @@ -2364,6 +2379,7 @@ AC_CONFIG_FILES([Makefile
>                 src/gallium/drivers/renderonly/Makefile
>                 src/gallium/drivers/softpipe/Makefile
>                 src/gallium/drivers/svga/Makefile
> +               src/gallium/drivers/tegra/Makefile
>                 src/gallium/drivers/trace/Makefile
>                 src/gallium/drivers/vc4/Makefile
>                 src/gallium/state_trackers/clover/Makefile
> @@ -2406,6 +2422,7 @@ AC_CONFIG_FILES([Makefile
>                 src/gallium/winsys/sw/wrapper/Makefile
>                 src/gallium/winsys/sw/xlib/Makefile
>                 src/gallium/winsys/vc4/drm/Makefile
> +               src/gallium/winsys/tegra/drm/Makefile
>                 src/gbm/Makefile
>                 src/gbm/main/gbm.pc
>                 src/glsl/Makefile
> diff --git a/src/gallium/Makefile.am b/src/gallium/Makefile.am
> index a7c3606..7278300 100644
> --- a/src/gallium/Makefile.am
> +++ b/src/gallium/Makefile.am
> @@ -82,6 +82,12 @@ if HAVE_GALLIUM_VC4
>  SUBDIRS += drivers/vc4 winsys/vc4/drm
>  endif
>
> +## tegra
> +if HAVE_GALLIUM_TEGRA
> +SUBDIRS += drivers/tegra winsys/tegra/drm
> +SUBDIRS += drivers/renderonly
> +endif
> +
>  ## the sw winsys'
>  SUBDIRS += winsys/sw/null
>
> diff --git a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
> index 08271a7..92fe66b 100644
> --- a/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
> +++ b/src/gallium/auxiliary/target-helpers/inline_drm_helper.h
> @@ -59,6 +59,10 @@
>  #include "vc4/drm/vc4_drm_public.h"
>  #endif
>
> +#if GALLIUM_TEGRA
> +#include "tegra/drm/tegra_drm_public.h"
> +#endif
> +
>  static char* driver_name = NULL;
>
>  /* XXX: We need to teardown the winsys if *screen_create() fails. */
> @@ -338,6 +342,26 @@ pipe_vc4_create_screen(int fd)
>  }
>  #endif
>
> +#if defined(GALLIUM_TEGRA)
> +#if defined(DRI_TARGET)
> +const __DRIextension **__driDriverGetExtensions_tegra(void);
> +
> +PUBLIC const __DRIextension **__driDriverGetExtensions_tegra(void)
> +{
> +   globalDriverAPI = &galliumdrm_driver_api;
> +   return galliumdrm_driver_extensions;
> +}
> +#endif
> +
> +static struct pipe_screen *pipe_tegra_create_screen(int fd)
> +{
> +   struct pipe_screen *screen;
> +
> +   screen = tegra_drm_screen_create(fd);
> +   return screen ? debug_screen_wrap(screen) : NULL;
> +}
> +#endif
> +
>  inline struct pipe_screen *
>  dd_create_screen(int fd)
>  {
> @@ -395,6 +419,11 @@ dd_create_screen(int fd)
>     else
>  #endif
>  #endif
> +#if defined(GALLIUM_TEGRA)
> +   if (strcmp(driver_name, "tegra") == 0)
> +      return pipe_tegra_create_screen(fd);
> +   else
> +#endif
>        return NULL;
>  }
>
> diff --git a/src/gallium/drivers/tegra/Automake.inc b/src/gallium/drivers/tegra/Automake.inc
> new file mode 100644
> index 0000000..3471445
> --- /dev/null
> +++ b/src/gallium/drivers/tegra/Automake.inc
> @@ -0,0 +1,10 @@
> +if HAVE_GALLIUM_TEGRA
> +
> +TARGET_DRIVERS += tegra
> +TARGET_CPPFLAGS += -DGALLIUM_TEGRA
> +TARGET_LIB_DEPS += \
> +       $(top_builddir)/src/gallium/drivers/renderonly/librenderonly.la \
> +       $(top_builddir)/src/gallium/winsys/tegra/drm/libtegradrm.la \
> +       $(LIBDRM_LIBS)
> +
> +endif
> diff --git a/src/gallium/drivers/tegra/Makefile.am b/src/gallium/drivers/tegra/Makefile.am
> new file mode 100644
> index 0000000..30f4689
> --- /dev/null
> +++ b/src/gallium/drivers/tegra/Makefile.am
> @@ -0,0 +1,9 @@
> +include $(top_srcdir)/src/gallium/Automake.inc
> +
> +AM_CPPFLAGS = \
> +       $(GALLIUM_CFLAGS) \
> +       $(TEGRA_CFLAGS)
> +
> +noinst_LTLIBRARIES = libtegra.la
> +
> +libtegra_la_SOURCES =
> diff --git a/src/gallium/targets/dri/Makefile.am b/src/gallium/targets/dri/Makefile.am
> index 7f945d1..5beca6c 100644
> --- a/src/gallium/targets/dri/Makefile.am
> +++ b/src/gallium/targets/dri/Makefile.am
> @@ -83,6 +83,8 @@ include $(top_srcdir)/src/gallium/drivers/freedreno/Automake.inc
>
>  include $(top_srcdir)/src/gallium/drivers/vc4/Automake.inc
>
> +include $(top_srcdir)/src/gallium/drivers/tegra/Automake.inc
> +
>  include $(top_srcdir)/src/gallium/drivers/softpipe/Automake.inc
>  include $(top_srcdir)/src/gallium/drivers/llvmpipe/Automake.inc
>
> diff --git a/src/gallium/winsys/tegra/drm/Android.mk b/src/gallium/winsys/tegra/drm/Android.mk
> new file mode 100644
> index 0000000..65add16
> --- /dev/null
> +++ b/src/gallium/winsys/tegra/drm/Android.mk
> @@ -0,0 +1,34 @@
> +# Copyright (C) 2014 Emil Velikov <emil.l.velikov at 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
> +# 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.
> +
> +LOCAL_PATH := $(call my-dir)
> +
> +# get C_SOURCES
> +include $(LOCAL_PATH)/Makefile.sources
> +
> +include $(CLEAR_VARS)
> +
> +LOCAL_SRC_FILES := $(C_SOURCES)
> +
> +LOCAL_SHARED_LIBRARIES := libdrm libdrm_tegra
> +LOCAL_MODULE := libmesa_winsys_tegra
> +
> +include $(GALLIUM_COMMON_MK)
> +include $(BUILD_STATIC_LIBRARY)
> diff --git a/src/gallium/winsys/tegra/drm/Makefile.am b/src/gallium/winsys/tegra/drm/Makefile.am
> new file mode 100644
> index 0000000..39068fe
> --- /dev/null
> +++ b/src/gallium/winsys/tegra/drm/Makefile.am
> @@ -0,0 +1,33 @@
> +# Copyright © 2012 Intel Corporation
> +#
> +# 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.
> +
> +include Makefile.sources
> +include $(top_srcdir)/src/gallium/Automake.inc
> +
> +AM_CFLAGS = \
> +       -I$(top_srcdir)/src/gallium/drivers \
> +       $(GALLIUM_WINSYS_CFLAGS) \
> +       $(TEGRA_CFLAGS)
> +
> +noinst_LTLIBRARIES = libtegradrm.la
> +
> +libtegradrm_la_SOURCES = $(C_SOURCES)
> diff --git a/src/gallium/winsys/tegra/drm/Makefile.sources b/src/gallium/winsys/tegra/drm/Makefile.sources
> new file mode 100644
> index 0000000..29a0edc
> --- /dev/null
> +++ b/src/gallium/winsys/tegra/drm/Makefile.sources
> @@ -0,0 +1,3 @@
> +C_SOURCES := \
> +       tegra_drm_public.h \
> +       tegra_drm_winsys.c
> diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_public.h b/src/gallium/winsys/tegra/drm/tegra_drm_public.h
> new file mode 100644
> index 0000000..b689b72
> --- /dev/null
> +++ b/src/gallium/winsys/tegra/drm/tegra_drm_public.h
> @@ -0,0 +1,31 @@
> +/*
> + * Copyright © 2014 NVIDIA Corporation
> + *
> + * 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.
> + */
> +
> +#ifndef __TEGRA_DRM_PUBLIC_H__
> +#define __TEGRA_DRM_PUBLIC_H__
> +
> +struct pipe_screen;
> +
> +struct pipe_screen *tegra_drm_screen_create(int fd);
> +
> +#endif /* __TEGRA_DRM_PUBLIC_H__ */
> \ No newline at end of file
> diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
> new file mode 100644
> index 0000000..e172407
> --- /dev/null
> +++ b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
> @@ -0,0 +1,51 @@
> +/*
> + * Copyright © 2014 NVIDIA Corporation
> + *
> + * 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.
> + */
> +
> +#include "renderonly/renderonly_screen.h"
> +#include "../winsys/tegra/drm/tegra_drm_public.h"
> +#include "../winsys/nouveau/drm/nouveau_drm_public.h"
> +
> +#include <drm/tegra_drm.h>

I had to change this line to

#include <libdrm/tegra_drm.h>

on my system for it to compile (drm's master installs tegra_drm.h in
$PREFIX/include/libdrm)

After this I could compile and run unmodified DRM applications
(kmscube, weston).

However, as with the first version sent by Thierry, EGL on Wayland is
broken with this. Try running weston and then weston-simple-egl: the
EGL client window looks weird and is not updated. I also tried
glmark2-es2-wayland and it segfaulted directly. Using the modified
weston client and unmodified Mesa these use-cases were working. It
seems like non-DRM cases need to yield to the Nouveau driver entirely
in order to work - I will try to see if I can understand what goes
wrong.


More information about the mesa-dev mailing list