[Mesa-dev] [PATCH] fixup! tegra: Initial support
Thierry Reding
thierry.reding at gmail.com
Thu Feb 22 18:09:40 UTC 2018
From: Thierry Reding <treding at nvidia.com>
---
configure.ac | 5 +++--
src/gallium/drivers/tegra/Makefile.am | 9 +-------
src/gallium/drivers/tegra/Makefile.sources | 5 ++++-
src/gallium/drivers/tegra/tegra_context.c | 8 +++----
src/gallium/drivers/tegra/tegra_context.h | 2 +-
src/gallium/drivers/tegra/tegra_resource.h | 2 +-
src/gallium/drivers/tegra/tegra_screen.c | 30 ++++++++++++++++++++-----
src/gallium/drivers/tegra/tegra_screen.h | 2 +-
src/gallium/winsys/tegra/drm/Makefile.am | 3 +--
src/gallium/winsys/tegra/drm/tegra_drm_public.h | 2 +-
src/gallium/winsys/tegra/drm/tegra_drm_winsys.c | 20 +++++++++++++++--
11 files changed, 59 insertions(+), 29 deletions(-)
diff --git a/configure.ac b/configure.ac
index 7f83fb9ee17e..60a671046016 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,7 +80,6 @@ LIBDRM_NVVIEUX_REQUIRED=2.4.66
LIBDRM_NOUVEAU_REQUIRED=2.4.66
LIBDRM_FREEDRENO_REQUIRED=2.4.89
LIBDRM_ETNAVIV_REQUIRED=2.4.82
-LIBDRM_TEGRA_REQUIRED=2.4.58
dnl Versions for external dependencies
DRI2PROTO_REQUIRED=2.8
@@ -2598,7 +2597,6 @@ if test -n "$with_gallium_drivers"; then
;;
xtegra)
HAVE_GALLIUM_TEGRA=yes
- PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED])
require_libdrm "tegra"
;;
xswrast)
@@ -2725,6 +2723,9 @@ if test "x$HAVE_GALLIUM_VC4" != xyes -a "x$HAVE_GALLIUM_PL111" = xyes ; then
AC_MSG_ERROR([Building with pl111 requires vc4])
fi
+if test "x$HAVE_GALLIUM_NOUVEAU" != xyes -a "x$HAVE_GALLIUM_TEGRA" = xyes; then
+ AC_MSG_ERROR([Building with tegra requires nouveau])
+fi
detect_old_buggy_llvm() {
dnl llvm-config may not give the right answer when llvm is a built as a
diff --git a/src/gallium/drivers/tegra/Makefile.am b/src/gallium/drivers/tegra/Makefile.am
index 1375ee97814f..7e87ea048733 100644
--- a/src/gallium/drivers/tegra/Makefile.am
+++ b/src/gallium/drivers/tegra/Makefile.am
@@ -1,18 +1,11 @@
-AUTOMAKE_OPTIONS = subdir-objects
-
include Makefile.sources
include $(top_srcdir)/src/gallium/Automake.inc
AM_CFLAGS = \
-I$(top_srcdir)/include/drm-uapi \
- $(GALLIUM_DRIVER_CFLAGS) \
- $(LIBUDEV_CFLAGS) \
- $(TEGRA_CFLAGS)
+ $(GALLIUM_DRIVER_CFLAGS)
noinst_LTLIBRARIES = libtegra.la
libtegra_la_SOURCES = \
$(C_SOURCES)
-
-libtegra_la_LIBADD = \
- $(LIBUDEV_LIBS)
diff --git a/src/gallium/drivers/tegra/Makefile.sources b/src/gallium/drivers/tegra/Makefile.sources
index 655c60ab6853..af4ff838c7ca 100644
--- a/src/gallium/drivers/tegra/Makefile.sources
+++ b/src/gallium/drivers/tegra/Makefile.sources
@@ -1,3 +1,6 @@
C_SOURCES := \
tegra_context.c \
- tegra_screen.c
+ tegra_context.h \
+ tegra_resource.h \
+ tegra_screen.c \
+ tegra_screen.h
diff --git a/src/gallium/drivers/tegra/tegra_context.c b/src/gallium/drivers/tegra/tegra_context.c
index feaa5138c95d..38e6e59b31ff 100644
--- a/src/gallium/drivers/tegra/tegra_context.c
+++ b/src/gallium/drivers/tegra/tegra_context.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -27,9 +27,9 @@
#include "util/u_debug.h"
#include "util/u_inlines.h"
-#include "tegra/tegra_context.h"
-#include "tegra/tegra_resource.h"
-#include "tegra/tegra_screen.h"
+#include "tegra_context.h"
+#include "tegra_resource.h"
+#include "tegra_screen.h"
static void
tegra_destroy(struct pipe_context *pcontext)
diff --git a/src/gallium/drivers/tegra/tegra_context.h b/src/gallium/drivers/tegra/tegra_context.h
index 669ae1c0c4ab..4869b0913a6f 100644
--- a/src/gallium/drivers/tegra/tegra_context.h
+++ b/src/gallium/drivers/tegra/tegra_context.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/src/gallium/drivers/tegra/tegra_resource.h b/src/gallium/drivers/tegra/tegra_resource.h
index 43265211be1e..67507d64590d 100644
--- a/src/gallium/drivers/tegra/tegra_resource.h
+++ b/src/gallium/drivers/tegra/tegra_resource.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c
index 2bb6014238af..5ff79a5a7d66 100644
--- a/src/gallium/drivers/tegra/tegra_screen.c
+++ b/src/gallium/drivers/tegra/tegra_screen.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -40,9 +40,9 @@
#include "nouveau/drm/nouveau_drm_public.h"
-#include "tegra/tegra_context.h"
-#include "tegra/tegra_resource.h"
-#include "tegra/tegra_screen.h"
+#include "tegra_context.h"
+#include "tegra_resource.h"
+#include "tegra_screen.h"
static void tegra_screen_destroy(struct pipe_screen *pscreen)
{
@@ -164,8 +164,8 @@ tegra_screen_can_create_resource(struct pipe_screen *pscreen,
static int tegra_open_render_node(void)
{
drmDevicePtr *devices, device;
- int err, fd = -ENODEV;
unsigned int num, i;
+ int err, fd;
err = drmGetDevices2(0, NULL, 0);
if (err < 0)
@@ -185,10 +185,28 @@ static int tegra_open_render_node(void)
for (i = 0; i < num; i++) {
device = devices[i];
+ fd = -ENODEV;
if ((device->available_nodes & (1 << DRM_NODE_RENDER)) &&
(device->bustype == DRM_BUS_PLATFORM)) {
- fd = open(device->nodes[DRM_NODE_RENDER], O_RDWR);
+ drmVersionPtr version;
+
+ fd = open(device->nodes[DRM_NODE_RENDER], O_RDWR | O_CLOEXEC);
+ if (fd < 0)
+ continue;
+
+ version = drmGetVersion(fd);
+ if (!version) {
+ close(fd);
+ continue;
+ }
+
+ if (strcmp(version->name, "nouveau") != 0) {
+ close(fd);
+ continue;
+ }
+
+ drmFreeVersion(version);
break;
}
}
diff --git a/src/gallium/drivers/tegra/tegra_screen.h b/src/gallium/drivers/tegra/tegra_screen.h
index fe249aca4215..558d22f2f993 100644
--- a/src/gallium/drivers/tegra/tegra_screen.h
+++ b/src/gallium/drivers/tegra/tegra_screen.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/src/gallium/winsys/tegra/drm/Makefile.am b/src/gallium/winsys/tegra/drm/Makefile.am
index 8af32530479a..8518dedf3fb1 100644
--- a/src/gallium/winsys/tegra/drm/Makefile.am
+++ b/src/gallium/winsys/tegra/drm/Makefile.am
@@ -3,8 +3,7 @@ include $(top_srcdir)/src/gallium/Automake.inc
AM_CFLAGS = \
-I$(top_srcdir)/src/gallium/drivers \
- $(GALLIUM_WINSYS_CFLAGS) \
- $(TEGRA_CFLAGS)
+ $(GALLIUM_WINSYS_CFLAGS)
noinst_LTLIBRARIES = libtegradrm.la
diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_public.h b/src/gallium/winsys/tegra/drm/tegra_drm_public.h
index 44e7eaaab931..8105180003f0 100644
--- a/src/gallium/winsys/tegra/drm/tegra_drm_public.h
+++ b/src/gallium/winsys/tegra/drm/tegra_drm_public.h
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
diff --git a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
index c320f008b82e..e2a8efb0f63f 100644
--- a/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
+++ b/src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2014-2016 NVIDIA Corporation
+ * Copyright © 2014-2018 NVIDIA Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -21,6 +21,8 @@
* IN THE SOFTWARE.
*/
+#include <fcntl.h>
+
#include "util/u_debug.h"
#include "tegra/tegra_screen.h"
@@ -29,5 +31,19 @@ struct pipe_screen *tegra_drm_screen_create(int fd);
struct pipe_screen *tegra_drm_screen_create(int fd)
{
- return tegra_screen_create(fd);
+ struct pipe_screen *screen;
+
+ /*
+ * NOTE: There are reportedly issues with reusing the file descriptor
+ * as-is related to Xinerama. Duplicate it to side-step any issues.
+ */
+ fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
+ if (fd < 0)
+ return NULL;
+
+ screen = tegra_screen_create(fd);
+ if (!screen)
+ close(fd);
+
+ return screen;
}
--
2.16.2
More information about the mesa-dev
mailing list