blob: a7a08f14e6a353cd67b1566b278444c9a283b4b4 [file] [log] [blame]
Brad Bishop08902b02019-08-20 09:16:51 -04001From a91c588b5a4122506e7fe949c37d530621bdd997 Mon Sep 17 00:00:00 2001
Brad Bishop316dfdd2018-06-25 12:45:53 -04002From: =?UTF-8?q?Daniel=20D=C3=ADaz?= <daniel.diaz@linaro.org>
3Date: Tue, 11 Jul 2017 14:50:37 -0500
Brad Bishop08902b02019-08-20 09:16:51 -04004Subject: [PATCH] Detect gst_bo_map/_unmap and use it (or avoid it)
Brad Bishop316dfdd2018-06-25 12:45:53 -04005MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Those functions are not available on libMali, thus breaking
10builds and creating havoc.
11
12Removing the specific parts of the code that deal with
13gbm_bo_map() and gbm_bo_unmap() renders the kmscube utility
14a little less useful, but still valuable.
15
16Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org>
17Cc: Rob Clark <robdclark@gmail.com>
18Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
19
20Upstream-Status: Submitted [https://lists.freedesktop.org/archives/mesa-dev/2017-July/163020.html]
Brad Bishop08902b02019-08-20 09:16:51 -040021Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@solution57.com>
Brad Bishop316dfdd2018-06-25 12:45:53 -040022---
23 Makefile.am | 5 ++++-
24 configure.ac | 3 +++
25 gst-decoder.c | 7 ++++++-
26 kmscube.c | 4 ++++
27 4 files changed, 17 insertions(+), 2 deletions(-)
28
29diff --git a/Makefile.am b/Makefile.am
Brad Bishop08902b02019-08-20 09:16:51 -040030index ba064e4..3a0a50b 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040031--- a/Makefile.am
32+++ b/Makefile.am
33@@ -43,7 +43,6 @@ kmscube_SOURCES = \
34 common.c \
35 common.h \
36 cube-smooth.c \
37- cube-tex.c \
38 drm-atomic.c \
39 drm-common.c \
40 drm-common.h \
Brad Bishop08902b02019-08-20 09:16:51 -040041@@ -68,3 +67,7 @@ texturator_SOURCES = \
42 drm-common.c \
43 drm-legacy.c \
44 texturator.c
Brad Bishop316dfdd2018-06-25 12:45:53 -040045+
46+if ENABLE_GBM_MAP
47+kmscube_SOURCES += cube-tex.c
48+endif
49diff --git a/configure.ac b/configure.ac
Brad Bishop08902b02019-08-20 09:16:51 -040050index 6be6541..3d20121 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040051--- a/configure.ac
52+++ b/configure.ac
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053@@ -49,5 +49,8 @@ if test "x$HAVE_GST" = "xyes"; then
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 fi
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080055 AM_CONDITIONAL(ENABLE_GST, [test "x$HAVE_GST" = "xyes"])
Brad Bishop316dfdd2018-06-25 12:45:53 -040056
57+AC_CHECK_LIB([gbm], [gbm_bo_map], [HAVE_GBM_BO_MAP=yes], [])
58+AM_CONDITIONAL(ENABLE_GBM_MAP, [test "x$HAVE_GBM_BO_MAP" = "xyes"])
59+
60 AC_CONFIG_FILES([Makefile])
61 AC_OUTPUT
62diff --git a/gst-decoder.c b/gst-decoder.c
Brad Bishop08902b02019-08-20 09:16:51 -040063index 5431014..0aa7a55 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040064--- a/gst-decoder.c
65+++ b/gst-decoder.c
66@@ -332,6 +332,7 @@ set_last_frame(struct decoder *dec, EGLImage frame, GstSample *samp)
67 dec->last_samp = samp;
68 }
69
70+#if HAVE_GBM_BO_MAP
71 // TODO this could probably be a helper re-used by cube-tex:
72 static int
73 buf_to_fd(const struct gbm *gbm, int size, void *ptr)
74@@ -357,6 +358,7 @@ buf_to_fd(const struct gbm *gbm, int size, void *ptr)
75
76 return fd;
77 }
78+#endif
79
80 static EGLImage
81 buffer_to_image(struct decoder *dec, GstBuffer *buf)
82@@ -410,12 +412,15 @@ buffer_to_image(struct decoder *dec, GstBuffer *buf)
83
84 if (is_dmabuf_mem) {
85 dmabuf_fd = dup(gst_dmabuf_memory_get_fd(mem));
86- } else {
87+ }
88+#if HAVE_GBM_BO_MAP
89+ else {
90 GstMapInfo map_info;
91 gst_buffer_map(buf, &map_info, GST_MAP_READ);
92 dmabuf_fd = buf_to_fd(dec->gbm, map_info.size, map_info.data);
93 gst_buffer_unmap(buf, &map_info);
94 }
95+#endif
96
97 if (dmabuf_fd < 0) {
98 GST_ERROR("could not obtain DMABUF FD");
99diff --git a/kmscube.c b/kmscube.c
Brad Bishop08902b02019-08-20 09:16:51 -0400100index 81803be..e93da67 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -0400101--- a/kmscube.c
102+++ b/kmscube.c
Brad Bishop08902b02019-08-20 09:16:51 -0400103@@ -166,7 +166,11 @@ int main(int argc, char *argv[])
Brad Bishop316dfdd2018-06-25 12:45:53 -0400104 else if (mode == VIDEO)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800105 egl = init_cube_video(gbm, video, samples);
Brad Bishop316dfdd2018-06-25 12:45:53 -0400106 else
107+#if HAVE_GBM_BO_MAP
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800108 egl = init_cube_tex(gbm, mode, samples);
Brad Bishop316dfdd2018-06-25 12:45:53 -0400109+#else
110+ printf("gbm_bo_map() support missing\n");
111+#endif
112
113 if (!egl) {
114 printf("failed to initialize EGL\n");
115--
Brad Bishop08902b02019-08-20 09:16:51 -04001162.22.0
Brad Bishop316dfdd2018-06-25 12:45:53 -0400117