Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 1 | From a91c588b5a4122506e7fe949c37d530621bdd997 Mon Sep 17 00:00:00 2001 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 2 | From: =?UTF-8?q?Daniel=20D=C3=ADaz?= <daniel.diaz@linaro.org> |
| 3 | Date: Tue, 11 Jul 2017 14:50:37 -0500 |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 4 | Subject: [PATCH] Detect gst_bo_map/_unmap and use it (or avoid it) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | Those functions are not available on libMali, thus breaking |
| 10 | builds and creating havoc. |
| 11 | |
| 12 | Removing the specific parts of the code that deal with |
| 13 | gbm_bo_map() and gbm_bo_unmap() renders the kmscube utility |
| 14 | a little less useful, but still valuable. |
| 15 | |
| 16 | Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org> |
| 17 | Cc: Rob Clark <robdclark@gmail.com> |
| 18 | Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com> |
| 19 | |
| 20 | Upstream-Status: Submitted [https://lists.freedesktop.org/archives/mesa-dev/2017-July/163020.html] |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 21 | Signed-off-by: Zoltan Kuscsik <zoltan.kuscsik@solution57.com> |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | --- |
| 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 | |
| 29 | diff --git a/Makefile.am b/Makefile.am |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 30 | index ba064e4..3a0a50b 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 31 | --- 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 Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 41 | @@ -68,3 +67,7 @@ texturator_SOURCES = \ |
| 42 | drm-common.c \ |
| 43 | drm-legacy.c \ |
| 44 | texturator.c |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 45 | + |
| 46 | +if ENABLE_GBM_MAP |
| 47 | +kmscube_SOURCES += cube-tex.c |
| 48 | +endif |
| 49 | diff --git a/configure.ac b/configure.ac |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 50 | index 6be6541..3d20121 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 51 | --- a/configure.ac |
| 52 | +++ b/configure.ac |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 53 | @@ -49,5 +49,8 @@ if test "x$HAVE_GST" = "xyes"; then |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 54 | fi |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 55 | AM_CONDITIONAL(ENABLE_GST, [test "x$HAVE_GST" = "xyes"]) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 56 | |
| 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 |
| 62 | diff --git a/gst-decoder.c b/gst-decoder.c |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 63 | index 5431014..0aa7a55 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | --- 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"); |
| 99 | diff --git a/kmscube.c b/kmscube.c |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 100 | index 81803be..e93da67 100644 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 101 | --- a/kmscube.c |
| 102 | +++ b/kmscube.c |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 103 | @@ -166,7 +166,11 @@ int main(int argc, char *argv[]) |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 104 | else if (mode == VIDEO) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 105 | egl = init_cube_video(gbm, video, samples); |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 106 | else |
| 107 | +#if HAVE_GBM_BO_MAP |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 108 | egl = init_cube_tex(gbm, mode, samples); |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 109 | +#else |
| 110 | + printf("gbm_bo_map() support missing\n"); |
| 111 | +#endif |
| 112 | |
| 113 | if (!egl) { |
| 114 | printf("failed to initialize EGL\n"); |
| 115 | -- |
Brad Bishop | 08902b0 | 2019-08-20 09:16:51 -0400 | [diff] [blame] | 116 | 2.22.0 |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 117 | |