[vlc-commits] mmal: converter: pass the VCSM init type to cma_buf_pool_new()

Steve Lhomme git at videolan.org
Fri Jan 24 14:15:46 CET 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jan 24 11:48:55 2020 +0100| [d14846b7f9ba94d18564b4e4977bc07329829921] | committer: Steve Lhomme

mmal: converter: pass the VCSM init type to cma_buf_pool_new()

The pool exists as long as the decoder device is in use.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d14846b7f9ba94d18564b4e4977bc07329829921
---

 modules/hw/mmal/converter.c |  5 ++++-
 modules/hw/mmal/mmal_cma.c  | 16 ++++++----------
 modules/hw/mmal/mmal_cma.h  |  5 +++--
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/modules/hw/mmal/converter.c b/modules/hw/mmal/converter.c
index feae4a6744..6d4200641e 100644
--- a/modules/hw/mmal/converter.c
+++ b/modules/hw/mmal/converter.c
@@ -863,8 +863,11 @@ retry:
         goto fail;
     }
 
+    mmal_decoder_device_t *devsys = GetMMALDeviceOpaque(sys->dec_dev);
+    assert(devsys != NULL);
+
     if (sys->needs_copy_in &&
-        (sys->cma_in_pool = cma_buf_pool_new(2, 2, true, "conv-copy-in")) == NULL)
+        (sys->cma_in_pool = cma_buf_pool_new(2, 2, true, devsys->vcsm_init_type == VCSM_INIT_CMA, "conv-copy-in")) == NULL)
     {
         msg_Err(p_filter, "Failed to allocate input CMA pool");
         goto fail;
diff --git a/modules/hw/mmal/mmal_cma.c b/modules/hw/mmal/mmal_cma.c
index 9b9eb48bbd..5622590946 100644
--- a/modules/hw/mmal/mmal_cma.c
+++ b/modules/hw/mmal/mmal_cma.c
@@ -350,7 +350,7 @@ cma_pool_fixed_new(const unsigned int pool_size,
 
 struct cma_buf_pool_s {
     cma_pool_fixed_t * pool;
-    vcsm_init_type_t init_type;
+    bool is_cma;
 
     bool all_in_flight;
 };
@@ -377,7 +377,7 @@ static void cma_pool_delete(cma_buf_t * const cb)
 
     if (cb->mmap != MAP_FAILED)
     {
-        if (cb->cbp->init_type == VCSM_INIT_CMA)
+        if (cb->cbp->is_cma)
             munmap(cb->mmap, cb->size);
         else
             vcsm_unlock_hdl(cb->vcsm_h);
@@ -421,7 +421,7 @@ static cma_buf_t * cma_pool_alloc_cb(cma_buf_pool_t * const v, size_t size)
         goto fail;
     }
 
-    if (cbp->init_type == VCSM_INIT_CMA)
+    if (cbp->is_cma)
     {
         if ((cb->fd = vcsm_export_dmabuf(cb->vcsm_h)) == -1)
         {
@@ -453,7 +453,6 @@ fail:
 // Pool has died - safe now to exit vcsm
 static void cma_buf_pool_on_delete_cb(cma_buf_pool_t * const cbp)
 {
-    cma_vcsm_exit(cbp->init_type);
     free(cbp);
 }
 
@@ -503,17 +502,14 @@ int cma_buf_pool_resize(cma_buf_pool_t * const cbp,
     return cma_pool_fixed_resize(cbp->pool, new_pool_size, new_flight_size);
 }
 
-cma_buf_pool_t * cma_buf_pool_new(const unsigned int pool_size, const unsigned int flight_size, const bool all_in_flight, const char * const name)
+cma_buf_pool_t * cma_buf_pool_new(const unsigned int pool_size, const unsigned int flight_size, const bool all_in_flight,
+                                  bool is_cma, const char * const name)
 {
-    vcsm_init_type_t const init_type = cma_vcsm_init();
-    if (init_type == VCSM_INIT_NONE)
-        return NULL;
-
     cma_buf_pool_t * const cbp = calloc(1, sizeof(cma_buf_pool_t));
     if (cbp == NULL)
         return NULL;
 
-    cbp->init_type = init_type;
+    cbp->is_cma = is_cma;
     cbp->all_in_flight = all_in_flight;
 
     if ((cbp->pool = cma_pool_fixed_new(pool_size, flight_size, cbp, name)) == NULL)
diff --git a/modules/hw/mmal/mmal_cma.h b/modules/hw/mmal/mmal_cma.h
index 9001070a20..9a229de789 100644
--- a/modules/hw/mmal/mmal_cma.h
+++ b/modules/hw/mmal/mmal_cma.h
@@ -54,8 +54,9 @@ void cma_buf_pool_delete(cma_buf_pool_t * const p);
 int cma_buf_pool_fill(cma_buf_pool_t * const cbp, const size_t el_size);
 int cma_buf_pool_resize(cma_buf_pool_t * const cbp,
                           const unsigned int new_pool_size, const int new_flight_size);
-cma_buf_pool_t * cma_buf_pool_new(const unsigned int pool_size, const unsigned int flight_size,
-                                  const bool all_in_flight, const char * const name);
+cma_buf_pool_t * cma_buf_pool_new(const unsigned int pool_size,
+                                  const unsigned int flight_size,
+                                  const bool all_in_flight, bool is_cma, const char * const name);
 
 static inline void cma_buf_pool_deletez(cma_buf_pool_t ** const pp)
 {



More information about the vlc-commits mailing list