]> code.ossystems Code Review - meta-freescale.git/blob
44bb7b0e1e29918d2c6d06b214f8f11ff4f2712a
[meta-freescale.git] /
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.
5
6 1.Add directviv and g2d check in configure.ac
7 2.Add compile marcos in glupload and gldownload
8
9 Upstream-Status: Inappropriate [i.MX specific]
10
11 Signed-off-by: Haihua Hu <jared.hu@nxp.com>
12 ---
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(-)
19
20 diff --git a/configure.ac b/configure.ac
21 index 9d007f1..655e019 100644
22 --- a/configure.ac
23 +++ b/configure.ac
24 @@ -682,7 +682,9 @@ save_LIBS="$LIBS"
25  HAVE_GL=no
26  HAVE_GLES2=no
27  HAVE_WAYLAND_EGL=no
28 -HAV_FB_EGL=no
29 +HAVE_FB_EGL=no
30 +HAVE_DIRECTVIV=no
31 +HAVE_G2D=no
32  
33  HAVE_EGL_RPI=no
34  
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)
38  
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)
42 +
43      dnl FIXME: Mali EGL depends on GLESv1 or GLESv2
44      AC_CHECK_HEADER([EGL/fbdev_window.h],
45        [
46 @@ -820,6 +826,18 @@ if test "x$HAVE_GLES2" = "xno"; then
47    fi
48  fi
49  
50 +dnl specific for imx soc
51 +GST_GL_HAVE_DIRECTVIV=0
52 +GST_GL_HAVE_PHYMEM=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
57 +  else
58 +    AC_MSG_WARN([Physical memory do not support])
59 +  fi
60 +fi
61 +
62  dnl X, GLX and OpenGL
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
66  
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
71  "
72  
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
75    HAVE_WINDOW_COCOA=no
76    HAVE_WINDOW_EAGL=no
77    HAVE_WINDOW_FB=no
78 +
79 +  HAVE_DIRECTVIV=no
80 +  HAVE_G2D=no
81  fi
82  
83  AC_SUBST(GL_LIBS)
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")
90  
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
97 @@ -23,9 +23,12 @@
98  #endif
99  
100  #include <gst/gl/gl.h>
101 -#include <gst/gl/gstglphymemory.h>
102  #include "gstgldownloadelement.h"
103  
104 +#if GST_GL_HAVE_PHYMEM
105 +#include <gst/gl/gstglphymemory.h>
106 +#endif
107 +
108  GST_DEBUG_CATEGORY_STATIC (gst_gl_download_element_debug);
109  #define GST_CAT_DEFAULT gst_gl_download_element_debug
110  
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");
117 +    );
118  
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,
122    gint i, n;
123    GstGLMemory *glmem;
124  
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,
130  
131      return GST_FLOW_OK;
132    }
133 +#endif /* GST_GL_HAVE_PHYMEM */
134  
135    *outbuf = inbuf;
136  
137 @@ -235,19 +241,23 @@ gst_gl_download_element_propose_allocation (GstBaseTransform * bt,
138      return FALSE;
139    }
140  
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)));
144  
145    gst_allocation_params_init (&params);
146 +
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);
151    }
152 +#endif /* GST_GL_HAVE_PHYMEM */
153  
154    if (!allocator)
155      allocator = gst_allocator_find (GST_GL_MEMORY_ALLOCATOR_NAME);
156  
157    if (!allocator) {
158 -    GST_ERROR_OBJECT (bt, "Can't obtain physical memory allocator.");
159 +    GST_ERROR_OBJECT (bt, "Can't obtain gl memory allocator.");
160      return FALSE;
161    }
162  
163 @@ -268,7 +278,8 @@ gst_gl_download_element_propose_allocation (GstBaseTransform * bt,
164    /* the normal size of a frame */
165    size = info.size;
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);
170  
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 = \
178         gstglviewconvert.c \
179         gstgloverlaycompositor.c \
180         gstglquery.c \
181 -       gstglvivdirecttexture.c \
182 -       gstglphymemory.c \
183         gstglcontrolbindingproxy.c
184  
185 +if HAVE_DIRECTVIV
186 +libgstgl_@GST_API_VERSION@_la_SOURCES += gstglvivdirecttexture.c
187 +endif
188 +
189 +if HAVE_PHYMEM
190 +libgstgl_@GST_API_VERSION@_la_SOURCES += gstglphymemory.c
191 +endif
192 +
193  libgstgl_@GST_API_VERSION@includedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/gl
194  libgstgl_@GST_API_VERSION@include_HEADERS = \
195         gstglwindow.h \
196 @@ -68,10 +74,16 @@ libgstgl_@GST_API_VERSION@include_HEADERS = \
197         gstglcontrolbindingproxy.h \
198         gstgl_fwd.h \
199         gstgl_enums.h \
200 -       gstglvivdirecttexture.h \
201 -       gstglphymemory.h \
202         gl.h
203  
204 +if HAVE_DIRECTVIV
205 +libgstgl_@GST_API_VERSION@include_HEADERS += gstglvivdirecttexture.h
206 +endif
207 +
208 +if HAVE_PHYMEM
209 +libgstgl_@GST_API_VERSION@include_HEADERS += gstglphymemory.h
210 +endif
211 +
212  noinst_HEADERS = \
213         gstglsl_private.h \
214         utils/opengl_versions.h \
215 @@ -86,7 +98,9 @@ libgstgl_@GST_API_VERSION@_la_LIBADD = \
216         $(GST_LIBS) \
217         $(GL_LIBS)
218  
219 +if HAVE_PHYMEM
220  libgstgl_@GST_API_VERSION@_la_LIBADD += -lg2d
221 +endif
222  
223  if HAVE_WINDOW_WIN32
224  SUBDIRS += win32
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,
230    }
231  #endif
232  
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,
241      *buffer = buf;
242      return GST_FLOW_OK;
243    }
244 +#endif
245  
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
252 @@ -23,7 +23,6 @@
253  #endif
254  
255  #include <stdio.h>
256 -#include <gst/gl/gstglvivdirecttexture.h>
257  
258  #include "gl.h"
259  #include "gstglupload.h"
260 @@ -36,6 +35,9 @@
261  #include <gst/allocators/gstdmabuf.h>
262  #endif
263  
264 +#if GST_GL_HAVE_DIRECTVIV
265 +#include <gst/gl/gstglvivdirecttexture.h>
266 +#endif
267  /**
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 (&params);
272  
273      allocator =
274 -        GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->
275 -            upload->context));
276 +        GST_ALLOCATOR (gst_gl_memory_allocator_get_default (upload->upload->
277 +            context));
278      gst_query_add_allocation_param (query, allocator, &params);
279      gst_object_unref (allocator);
280    }
281 @@ -603,8 +605,8 @@ _egl_image_upload_perform_gl_thread (GstGLContext * context,
282    }
283  
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);
289  }
290  
291  static GstGLUploadReturn
292 @@ -1045,11 +1047,11 @@ _upload_meta_upload_propose_allocation (gpointer impl, GstQuery * decide_query,
293    gpointer handle;
294  
295    gl_apis =
296 -      gst_gl_api_to_string (gst_gl_context_get_gl_api (upload->upload->
297 -          context));
298 -  platform =
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->
301            upload->context));
302 +  platform =
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);
306  
307    gl_context =
308 @@ -1170,6 +1172,7 @@ static const UploadMethod _upload_meta_upload = {
309    &_upload_meta_upload_free
310  };
311  
312 +#if GST_GL_HAVE_DIRECTVIV
313  struct PhyBufferUpload
314  {
315    GstGLUpload *upload;
316 @@ -1177,7 +1180,7 @@ struct PhyBufferUpload
317  };
318  
319  static gpointer
320 -_physical_buffer_upload_new(GstGLUpload *upload)
321 +_physical_buffer_upload_new (GstGLUpload * upload)
322  {
323    struct PhyBufferUpload *phybuffer = g_new0 (struct PhyBufferUpload, 1);
324  
325 @@ -1187,8 +1190,8 @@ _physical_buffer_upload_new(GstGLUpload *upload)
326  }
327  
328  static GstCaps *
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)
333  {
334    GstCapsFeatures *passthrough =
335        gst_caps_features_from_string
336 @@ -1208,7 +1211,7 @@ _physical_buffer_upload_transform_caps(GstGLContext *context,
337      ret = tmp;
338    } else {
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));
342    }
343  
344    gst_caps_features_free (passthrough);
345 @@ -1216,16 +1219,16 @@ _physical_buffer_upload_transform_caps(GstGLContext *context,
346  }
347  
348  static gboolean
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)
353  {
354 -  struct PhyBufferUpload *upload = impl;  
355 +  struct PhyBufferUpload *upload = impl;
356    GstCapsFeatures *features;
357  
358    features = gst_caps_get_features (out_caps, 0);
359    if (!gst_caps_features_contains (features, GST_CAPS_FEATURE_MEMORY_GL_MEMORY))
360      return FALSE;
361 -  
362 +
363    if (upload->params)
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)))
368      return FALSE;
369  
370 -  return gst_is_physical_buffer(buffer);
371 +  return gst_is_physical_buffer (buffer);
372  }
373  
374  static void
375 -_physical_buffer_upload_propose_allocation(gpointer impl, GstQuery *decide_query,
376 -    GstQuery *query)
377 +_physical_buffer_upload_propose_allocation (gpointer impl,
378 +    GstQuery * decide_query, GstQuery * query)
379  {
380    gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, 0);
381  }
382  
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)
387  {
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");
394 -  
395 +
396    allocator =
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);
402  
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);
406  
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);
411  
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
415  }
416  
417  static void
418 -_physical_buffer_upload_free(gpointer impl)
419 +_physical_buffer_upload_free (gpointer impl)
420  {
421    struct PhyBufferUpload *phyBuffer = impl;
422  
423    if (phyBuffer->params)
424      gst_gl_allocation_params_free ((GstGLAllocationParams *) phyBuffer->params);
425  
426 -  g_free(phyBuffer);
427 +  g_free (phyBuffer);
428  }
429  
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
434  };
435 +#endif /* GST_GL_HAVE_DIRECTVIV */
436  
437  struct RawUploadFrame
438  {
439 @@ -1526,7 +1530,11 @@ static const UploadMethod *upload_methods[] = { &_gl_memory_upload,
440  #if GST_GL_HAVE_DMABUF
441    &_dma_buf_upload,
442  #endif
443 -  &_upload_meta_upload, &_physical_buffer_upload, &_raw_data_upload
444 +  &_upload_meta_upload,
445 +#if GST_GL_HAVE_DIRECTVIV
446 +  &_physical_buffer_upload,
447 +#endif
448 +  &_raw_data_upload
449  };
450  
451  static GMutex upload_global_lock;
452 -- 
453 1.9.1
454