1 From 506dd50401d4f702d92540db9cb90a752e6817aa Mon Sep 17 00:00:00 2001
2 From: Haihua Hu <jared.hu@nxp.com>
3 Date: Mon, 31 Oct 2016 15:22:01 +0800
4 Subject: [PATCH] [MMFMWK-7308] Fix build issue on non-GPU soc.
6 1.Add directviv and g2d check in configure.ac
7 2.Add compile marcos in glupload and gldownload
9 Upstream-Status: Inappropriate [i.MX specific]
11 Signed-off-by: Haihua Hu <jared.hu@nxp.com>
13 configure.ac | 27 +++++++++++++++-
14 ext/gl/gstgldownloadelement.c | 21 ++++++++++---
15 gst-libs/gst/gl/Makefile.am | 22 ++++++++++---
16 gst-libs/gst/gl/gstglbufferpool.c | 4 ++-
17 gst-libs/gst/gl/gstglupload.c | 66 ++++++++++++++++++++++-----------------
18 5 files changed, 100 insertions(+), 40 deletions(-)
20 diff --git a/configure.ac b/configure.ac
21 index 9d007f1..655e019 100644
24 @@ -682,7 +682,9 @@ save_LIBS="$LIBS"
35 @@ -722,6 +724,10 @@ case $host in
36 dnl check for imx fbbackend support
37 AC_CHECK_LIB(EGL, fbGetDisplay, HAVE_FB_EGL=yes, HAVE_FB_EGL=no)
39 + dnl specific check for imx soc
40 + AC_CHECK_LIB(GLESv2, glTexDirectVIV, HAVE_DIRECTVIV=yes, HAVE_DIRECTVIV=no)
41 + AC_CHECK_HEADER(g2d.h, HAVE_G2D=yes, HAVE_G2D=no)
43 dnl FIXME: Mali EGL depends on GLESv1 or GLESv2
44 AC_CHECK_HEADER([EGL/fbdev_window.h],
46 @@ -820,6 +826,18 @@ if test "x$HAVE_GLES2" = "xno"; then
50 +dnl specific for imx soc
51 +GST_GL_HAVE_DIRECTVIV=0
53 +if test "x$HAVE_DIRECTVIV" = "xyes"; then
54 + GST_GL_HAVE_DIRECTVIV=1
55 + if test "x$HAVE_G2D" = "xyes"; then
56 + GST_GL_HAVE_PHYMEM=1
58 + AC_MSG_WARN([Physical memory do not support])
63 if test "x$HAVE_X" = "xno"; then
64 if test "x$NEED_GLX" = "xyes"; then
65 @@ -1265,6 +1283,8 @@ GL_CONFIG_DEFINES="$GL_CONFIG_DEFINES
67 GL_CONFIG_DEFINES="$GL_CONFIG_DEFINES
68 #define GST_GL_HAVE_DMABUF $GST_GL_HAVE_DMABUF
69 +#define GST_GL_HAVE_DIRECTVIV $GST_GL_HAVE_DIRECTVIV
70 +#define GST_GL_HAVE_PHYMEM $GST_GL_HAVE_PHYMEM
73 dnl Check for no platforms/window systems
74 @@ -1300,6 +1320,9 @@ if test "x$GL_APIS" = "x" -o "x$GL_PLATFORMS" = "x" -o "x$GL_WINDOWS" = "x"; the
84 @@ -1316,6 +1339,8 @@ AM_CONDITIONAL(HAVE_WINDOW_WAYLAND, test "x$HAVE_WINDOW_WAYLAND" = "xyes")
85 AM_CONDITIONAL(HAVE_WINDOW_ANDROID, test "x$HAVE_WINDOW_ANDROID" = "xyes")
86 AM_CONDITIONAL(HAVE_WINDOW_EAGL, test "x$HAVE_WINDOW_EAGL" = "xyes")
87 AM_CONDITIONAL(HAVE_WINDOW_FB, test "x$HAVE_WINDOW_FB" = "xyes")
88 +AM_CONDITIONAL(HAVE_DIRECTVIV, test "x$HAVE_DIRECTVIV" = "xyes")
89 +AM_CONDITIONAL(HAVE_PHYMEM, test "x$HAVE_DIRECTVIV" = "xyes" -a "x$HAVE_G2D" = "xyes")
91 AM_CONDITIONAL(USE_OPENGL, test "x$USE_OPENGL" = "xyes")
92 AM_CONDITIONAL(USE_GLES2, test "x$USE_GLES2" = "xyes")
93 diff --git a/ext/gl/gstgldownloadelement.c b/ext/gl/gstgldownloadelement.c
94 index 9ea0146..e89c36e 100644
95 --- a/ext/gl/gstgldownloadelement.c
96 +++ b/ext/gl/gstgldownloadelement.c
100 #include <gst/gl/gl.h>
101 -#include <gst/gl/gstglphymemory.h>
102 #include "gstgldownloadelement.h"
104 +#if GST_GL_HAVE_PHYMEM
105 +#include <gst/gl/gstglphymemory.h>
108 GST_DEBUG_CATEGORY_STATIC (gst_gl_download_element_debug);
109 #define GST_CAT_DEFAULT gst_gl_download_element_debug
111 @@ -33,7 +36,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_download_element_debug);
112 G_DEFINE_TYPE_WITH_CODE (GstGLDownloadElement, gst_gl_download_element,
113 GST_TYPE_GL_BASE_FILTER,
114 GST_DEBUG_CATEGORY_INIT (gst_gl_download_element_debug, "gldownloadelement",
115 - 0, "download element"););
116 + 0, "download element");
119 static gboolean gst_gl_download_element_get_unit_size (GstBaseTransform * trans,
120 GstCaps * caps, gsize * size);
121 @@ -170,6 +174,7 @@ gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
125 +#if GST_GL_HAVE_PHYMEM
126 glmem = gst_buffer_peek_memory (inbuf, 0);
127 if (gst_is_gl_physical_memory (glmem)) {
128 GstGLContext *context = GST_GL_BASE_FILTER (bt)->context;
129 @@ -182,6 +187,7 @@ gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
133 +#endif /* GST_GL_HAVE_PHYMEM */
137 @@ -235,19 +241,23 @@ gst_gl_download_element_propose_allocation (GstBaseTransform * bt,
141 - GST_DEBUG_OBJECT (bt, "video format is %s", gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&info)));
142 + GST_DEBUG_OBJECT (bt, "video format is %s",
143 + gst_video_format_to_string (GST_VIDEO_INFO_FORMAT (&info)));
145 gst_allocation_params_init (¶ms);
147 +#if GST_GL_HAVE_PHYMEM
148 if (gst_is_gl_physical_memory_supported_fmt (&info)) {
149 allocator = gst_phy_mem_allocator_obtain ();
150 GST_DEBUG_OBJECT (bt, "obtain physical memory allocator %p.", allocator);
152 +#endif /* GST_GL_HAVE_PHYMEM */
155 allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
158 - GST_ERROR_OBJECT (bt, "Can't obtain physical memory allocator.");
159 + GST_ERROR_OBJECT (bt, "Can't obtain gl memory allocator.");
163 @@ -268,7 +278,8 @@ gst_gl_download_element_propose_allocation (GstBaseTransform * bt,
164 /* the normal size of a frame */
166 gst_buffer_pool_config_set_params (config, caps, size, 0, 0);
167 - gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_GL_SYNC_META);
168 + gst_buffer_pool_config_add_option (config,
169 + GST_BUFFER_POOL_OPTION_GL_SYNC_META);
171 if (!gst_buffer_pool_set_config (pool, config)) {
172 gst_object_unref (pool);
173 diff --git a/gst-libs/gst/gl/Makefile.am b/gst-libs/gst/gl/Makefile.am
174 index 55f8a20..c52bba5 100644
175 --- a/gst-libs/gst/gl/Makefile.am
176 +++ b/gst-libs/gst/gl/Makefile.am
177 @@ -33,10 +33,16 @@ libgstgl_@GST_API_VERSION@_la_SOURCES = \
179 gstgloverlaycompositor.c \
181 - gstglvivdirecttexture.c \
183 gstglcontrolbindingproxy.c
186 +libgstgl_@GST_API_VERSION@_la_SOURCES += gstglvivdirecttexture.c
190 +libgstgl_@GST_API_VERSION@_la_SOURCES += gstglphymemory.c
193 libgstgl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl
194 libgstgl_@GST_API_VERSION@include_HEADERS = \
196 @@ -68,10 +74,16 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
197 gstglcontrolbindingproxy.h \
200 - gstglvivdirecttexture.h \
205 +libgstgl_@GST_API_VERSION@include_HEADERS += gstglvivdirecttexture.h
209 +libgstgl_@GST_API_VERSION@include_HEADERS += gstglphymemory.h
214 utils/opengl_versions.h \
215 @@ -86,7 +98,9 @@ libgstgl_@GST_API_VERSION@_la_LIBADD = \
220 libgstgl_@GST_API_VERSION@_la_LIBADD += -lg2d
225 diff --git a/gst-libs/gst/gl/gstglbufferpool.c b/gst-libs/gst/gl/gstglbufferpool.c
226 index 71c726a..77452be 100644
227 --- a/gst-libs/gst/gl/gstglbufferpool.c
228 +++ b/gst-libs/gst/gl/gstglbufferpool.c
229 @@ -292,8 +292,9 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
233 +#if GST_GL_HAVE_PHYMEM
234 if ((g_strcmp0 (priv->allocator->mem_type, GST_GL_PHY_MEM_ALLOCATOR) == 0)) {
235 - GstAllocator* allocator = (GstAllocator*) gst_phy_mem_allocator_obtain ();
236 + GstAllocator *allocator = (GstAllocator *) gst_phy_mem_allocator_obtain ();
237 if (!gst_gl_physical_memory_setup_buffer (allocator, buf, priv->gl_params)) {
238 GST_ERROR_OBJECT (pool, "Can't create physcial buffer.");
239 return GST_FLOW_ERROR;
240 @@ -301,6 +302,7 @@ gst_gl_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
246 alloc = GST_GL_MEMORY_ALLOCATOR (priv->allocator);
247 if (!gst_gl_memory_setup_buffer (alloc, buf, priv->gl_params))
248 diff --git a/gst-libs/gst/gl/gstglupload.c b/gst-libs/gst/gl/gstglupload.c
249 index 99cc68a..d17fab3 100644
250 --- a/gst-libs/gst/gl/gstglupload.c
251 +++ b/gst-libs/gst/gl/gstglupload.c
256 -#include <gst/gl/gstglvivdirecttexture.h>
259 #include "gstglupload.h"
261 #include <gst/allocators/gstdmabuf.h>
264 +#if GST_GL_HAVE_DIRECTVIV
265 +#include <gst/gl/gstglvivdirecttexture.h>
268 * SECTION:gstglupload
269 * @short_description: an object that uploads to GL textures
270 @@ -316,8 +318,8 @@ _gl_memory_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
271 gst_allocation_params_init (¶ms);
274 - GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
276 + GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload->
278 gst_query_add_allocation_param (query, allocator, ¶ms);
279 gst_object_unref (allocator);
281 @@ -603,8 +605,8 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
284 if (GST_IS_GL_BUFFER_POOL (image->buffer->pool))
285 - gst_gl_buffer_pool_replace_last_buffer (GST_GL_BUFFER_POOL (image->
286 - buffer->pool), image->buffer);
287 + gst_gl_buffer_pool_replace_last_buffer (GST_GL_BUFFER_POOL (image->buffer->
288 + pool), image->buffer);
291 static GstGLUploadReturn
292 @@ -1045,11 +1047,11 @@ _upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
296 - gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
299 - gst_gl_platform_to_string (gst_gl_context_get_gl_platform (upload->
300 + gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->
303 + gst_gl_platform_to_string (gst_gl_context_get_gl_platform
304 + (upload->upload->context));
305 handle = (gpointer) gst_gl_context_get_gl_context (upload->upload->context);
308 @@ -1170,6 +1172,7 @@ static const UploadMethod _upload_meta_upload = {
309 &_upload_meta_upload_free
312 +#if GST_GL_HAVE_DIRECTVIV
313 struct PhyBufferUpload
316 @@ -1177,7 +1180,7 @@ struct PhyBufferUpload
320 -_physical_buffer_upload_new(GstGLUpload *upload)
321 +_physical_buffer_upload_new (GstGLUpload * upload)
323 struct PhyBufferUpload *phybuffer = g_new0 (struct PhyBufferUpload, 1);
325 @@ -1187,8 +1190,8 @@ _physical_buffer_upload_new(GstGLUpload *upload)
329 -_physical_buffer_upload_transform_caps(GstGLContext *context,
330 - GstPadDirection direction, GstCaps *caps)
331 +_physical_buffer_upload_transform_caps (GstGLContext * context,
332 + GstPadDirection direction, GstCaps * caps)
334 GstCapsFeatures *passthrough =
335 gst_caps_features_from_string
336 @@ -1208,7 +1211,7 @@ _physical_buffer_upload_transform_caps(GstGLContext *context,
339 ret = gst_caps_from_string (GST_VIDEO_CAPS_MAKE_WITH_FEATURES
340 - (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY,GST_GL_DIRECTVIV_FORMAT));
341 + (GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, GST_GL_DIRECTVIV_FORMAT));
344 gst_caps_features_free (passthrough);
345 @@ -1216,16 +1219,16 @@ _physical_buffer_upload_transform_caps(GstGLContext *context,
349 -_physical_buffer_upload_accept(gpointer impl, GstBuffer *buffer,
350 - GstCaps *in_caps, GstCaps *out_caps)
351 +_physical_buffer_upload_accept (gpointer impl, GstBuffer * buffer,
352 + GstCaps * in_caps, GstCaps * out_caps)
354 - struct PhyBufferUpload *upload = impl;
355 + struct PhyBufferUpload *upload = impl;
356 GstCapsFeatures *features;
358 features = gst_caps_get_features (out_caps, 0);
359 if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
364 gst_gl_allocation_params_free ((GstGLAllocationParams *) upload->params);
365 if (!(upload->params =
366 @@ -1234,18 +1237,19 @@ _physical_buffer_upload_accept(gpointer impl, GstBuffer *buffer,
367 GST_GL_TEXTURE_TARGET_2D)))
370 - return gst_is_physical_buffer(buffer);
371 + return gst_is_physical_buffer (buffer);
375 -_physical_buffer_upload_propose_allocation(gpointer impl, GstQuery *decide_query,
377 +_physical_buffer_upload_propose_allocation (gpointer impl,
378 + GstQuery * decide_query, GstQuery * query)
380 gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
383 static GstGLUploadReturn
384 -_physical_buffer_upload_perform(gpointer impl, GstBuffer *buffer, GstBuffer **outbuf)
385 +_physical_buffer_upload_perform (gpointer impl, GstBuffer * buffer,
386 + GstBuffer ** outbuf)
388 struct PhyBufferUpload *phyBuffer = impl;
389 GstGLMemoryAllocator *allocator;
390 @@ -1255,7 +1259,7 @@ _physical_buffer_upload_perform(gpointer impl, GstBuffer *buffer, GstBuffer **ou
391 info = &phyBuffer->upload->priv->out_info;
392 n_mem = GST_VIDEO_INFO_N_PLANES (info);
393 GST_LOG_OBJECT (phyBuffer->upload, "Attempting viv direct upload");
397 GST_GL_MEMORY_ALLOCATOR (gst_allocator_find
398 (GST_GL_MEMORY_PBO_ALLOCATOR_NAME));
399 @@ -1265,11 +1269,10 @@ _physical_buffer_upload_perform(gpointer impl, GstBuffer *buffer, GstBuffer **ou
400 gst_gl_memory_setup_buffer (allocator, *outbuf, phyBuffer->params);
401 gst_object_unref (allocator);
403 - GstGLMemory *out_gl_mem =
404 - (GstGLMemory *) gst_buffer_peek_memory (*outbuf, 0);
405 + GstGLMemory *out_gl_mem = (GstGLMemory *) gst_buffer_peek_memory (*outbuf, 0);
407 - gst_gl_viv_direct_bind_gstbuffer(phyBuffer->upload->context, out_gl_mem->tex_id,
408 - &phyBuffer->upload->priv->in_info, buffer);
409 + gst_gl_viv_direct_bind_gstbuffer (phyBuffer->upload->context,
410 + out_gl_mem->tex_id, &phyBuffer->upload->priv->in_info, buffer);
412 gst_buffer_add_video_meta_full (*outbuf, 0,
413 GST_VIDEO_INFO_FORMAT (info), GST_VIDEO_INFO_WIDTH (info),
414 @@ -1279,14 +1282,14 @@ _physical_buffer_upload_perform(gpointer impl, GstBuffer *buffer, GstBuffer **ou
418 -_physical_buffer_upload_free(gpointer impl)
419 +_physical_buffer_upload_free (gpointer impl)
421 struct PhyBufferUpload *phyBuffer = impl;
423 if (phyBuffer->params)
424 gst_gl_allocation_params_free ((GstGLAllocationParams *) phyBuffer->params);
427 + g_free (phyBuffer);
430 static GstStaticCaps _physical_buffer_upload_caps =
431 @@ -1303,6 +1306,7 @@ static const UploadMethod _physical_buffer_upload = {
432 &_physical_buffer_upload_perform,
433 &_physical_buffer_upload_free
435 +#endif /* GST_GL_HAVE_DIRECTVIV */
437 struct RawUploadFrame
439 @@ -1526,7 +1530,11 @@ static const UploadMethod *upload_methods[] = { &_gl_memory_upload,
440 #if GST_GL_HAVE_DMABUF
443 - &_upload_meta_upload, &_physical_buffer_upload, &_raw_data_upload
444 + &_upload_meta_upload,
445 +#if GST_GL_HAVE_DIRECTVIV
446 + &_physical_buffer_upload,
451 static GMutex upload_global_lock;