[vlc-commits] mmal: device: move the VCSM init in the decoder device

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


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jan 24 12:28:49 2020 +0100| [fa45884478dc561faee96ad14f96f1bc2f000f77] | committer: Steve Lhomme

mmal: device: move the VCSM init in the decoder device

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

 modules/hw/mmal/Makefile.am      |  3 +-
 modules/hw/mmal/decoder_device.c | 69 +++++++++++++++++++++++++++++++++++++++-
 modules/hw/mmal/mmal_picture.c   | 63 ------------------------------------
 modules/hw/mmal/mmal_picture.h   |  4 ---
 4 files changed, 69 insertions(+), 70 deletions(-)

diff --git a/modules/hw/mmal/Makefile.am b/modules/hw/mmal/Makefile.am
index 7ed83e1bdc..44be760053 100644
--- a/modules/hw/mmal/Makefile.am
+++ b/modules/hw/mmal/Makefile.am
@@ -25,8 +25,7 @@ libmmal_deinterlace_plugin_la_LDFLAGS = $(AM_LDFLAGS)
 libmmal_deinterlace_plugin_la_LIBADD = $(LIBS_mmal)
 mmal_LTLIBRARIES += libmmal_deinterlace_plugin.la
 
-libmmal_device_plugin_la_SOURCES = decoder_device.c mmal_picture.c mmal_picture.h \
-  mmal_cma.c mmal_cma.h
+libmmal_device_plugin_la_SOURCES = decoder_device.c mmal_picture.h
 libmmal_device_plugin_la_CFLAGS = $(AM_CFLAGS)
 libmmal_device_plugin_la_LDFLAGS = $(AM_LDFLAGS)
 libmmal_device_plugin_la_LIBADD = $(LIBS_mmal)
diff --git a/modules/hw/mmal/decoder_device.c b/modules/hw/mmal/decoder_device.c
index 67e92d6fcd..8bc964b8d3 100644
--- a/modules/hw/mmal/decoder_device.c
+++ b/modules/hw/mmal/decoder_device.c
@@ -29,6 +29,9 @@
 #include <vlc_vout_window.h>
 #include <vlc_codec.h>
 
+#include <bcm_host.h>
+#include <interface/vcsm/user-vcsm.h>
+
 #include "mmal_picture.h"
 
 static int OpenDecoderDevice(vlc_decoder_device *, vout_window_t *);
@@ -39,6 +42,70 @@ vlc_module_begin()
     add_shortcut("mmal-device")
 vlc_module_end()
 
+
+// Preferred mode - none->cma on Pi4 otherwise legacy
+static volatile vcsm_init_type_t last_vcsm_type = VCSM_INIT_NONE;
+
+static vcsm_init_type_t cma_vcsm_init(void)
+{
+    vcsm_init_type_t rv = VCSM_INIT_NONE;
+    // We don't bother locking - taking a copy here should be good enough
+    vcsm_init_type_t try_type = last_vcsm_type;
+
+    if (try_type == VCSM_INIT_NONE) {
+        if (bcm_host_is_fkms_active())
+            try_type = VCSM_INIT_CMA;
+        else
+            try_type = VCSM_INIT_LEGACY;
+    }
+
+    if (try_type == VCSM_INIT_CMA) {
+        if (vcsm_init_ex(1, -1) == 0)
+            rv = VCSM_INIT_CMA;
+        else if (vcsm_init_ex(0, -1) == 0)
+            rv = VCSM_INIT_LEGACY;
+    }
+    else
+    {
+        if (vcsm_init_ex(0, -1) == 0)
+            rv = VCSM_INIT_LEGACY;
+        else if (vcsm_init_ex(1, -1) == 0)
+            rv = VCSM_INIT_CMA;
+    }
+
+    // Just in case this affects vcsm init do after that
+    if (rv != VCSM_INIT_NONE)
+        bcm_host_init();
+
+    last_vcsm_type = rv;
+    return rv;
+}
+
+static void cma_vcsm_exit(const vcsm_init_type_t init_mode)
+{
+    if (init_mode != VCSM_INIT_NONE)
+    {
+        vcsm_exit();
+        bcm_host_deinit();  // Does nothing but add in case it ever does
+    }
+}
+
+static const char * cma_vcsm_init_str(const vcsm_init_type_t init_mode)
+{
+    switch (init_mode)
+    {
+        case VCSM_INIT_CMA:
+            return "CMA";
+        case VCSM_INIT_LEGACY:
+            return "Legacy";
+        case VCSM_INIT_NONE:
+            return "none";
+        default:
+            break;
+    }
+    return "???";
+}
+
 static void CloseDecoderDevice(vlc_decoder_device *device)
 {
     mmal_decoder_device_t *sys = device->opaque;
@@ -63,7 +130,7 @@ static int OpenDecoderDevice(vlc_decoder_device *device, vout_window_t *window)
         return VLC_EGENERIC;
     }
 
-    sys->vcsm_init_type = vcsm_init_type;
+    sys->is_cma = vcsm_init_type == VCSM_INIT_CMA;
 
     device->ops = &mmal_device_ops;
     device->opaque = sys;
diff --git a/modules/hw/mmal/mmal_picture.c b/modules/hw/mmal/mmal_picture.c
index ab289246f2..0fe7f4ee18 100644
--- a/modules/hw/mmal/mmal_picture.c
+++ b/modules/hw/mmal/mmal_picture.c
@@ -1207,69 +1207,6 @@ bool rpi_is_model_pi4(void) {
     return bcm_host_is_model_pi4();
 }
 
-// Preferred mode - none->cma on Pi4 otherwise legacy
-static volatile vcsm_init_type_t last_vcsm_type = VCSM_INIT_NONE;
-
-vcsm_init_type_t cma_vcsm_init(void)
-{
-    vcsm_init_type_t rv = VCSM_INIT_NONE;
-    // We don't bother locking - taking a copy here should be good enough
-    vcsm_init_type_t try_type = last_vcsm_type;
-
-    if (try_type == VCSM_INIT_NONE) {
-        if (bcm_host_is_fkms_active())
-            try_type = VCSM_INIT_CMA;
-        else
-            try_type = VCSM_INIT_LEGACY;
-    }
-
-    if (try_type == VCSM_INIT_CMA) {
-        if (vcsm_init_ex(1, -1) == 0)
-            rv = VCSM_INIT_CMA;
-        else if (vcsm_init_ex(0, -1) == 0)
-            rv = VCSM_INIT_LEGACY;
-    }
-    else
-    {
-        if (vcsm_init_ex(0, -1) == 0)
-            rv = VCSM_INIT_LEGACY;
-        else if (vcsm_init_ex(1, -1) == 0)
-            rv = VCSM_INIT_CMA;
-    }
-
-    // Just in case this affects vcsm init do after that
-    if (rv != VCSM_INIT_NONE)
-        bcm_host_init();
-
-    last_vcsm_type = rv;
-    return rv;
-}
-
-void cma_vcsm_exit(const vcsm_init_type_t init_mode)
-{
-    if (init_mode != VCSM_INIT_NONE)
-    {
-        vcsm_exit();
-        bcm_host_deinit();  // Does nothing but add in case it ever does
-    }
-}
-
-const char * cma_vcsm_init_str(const vcsm_init_type_t init_mode)
-{
-    switch (init_mode)
-    {
-        case VCSM_INIT_CMA:
-            return "CMA";
-        case VCSM_INIT_LEGACY:
-            return "Legacy";
-        case VCSM_INIT_NONE:
-            return "none";
-        default:
-            break;
-    }
-    return "???";
-}
-
 MMAL_FOURCC_T pic_to_slice_mmal_fourcc(MMAL_FOURCC_T fcc)
 {
     switch (fcc){
diff --git a/modules/hw/mmal/mmal_picture.h b/modules/hw/mmal/mmal_picture.h
index 7e9f9ca3b3..ab4c3a8c56 100644
--- a/modules/hw/mmal/mmal_picture.h
+++ b/modules/hw/mmal/mmal_picture.h
@@ -166,10 +166,6 @@ typedef enum vcsm_init_type_e {
     VCSM_INIT_CMA
 } vcsm_init_type_t;
 
-vcsm_init_type_t cma_vcsm_init(void);
-void cma_vcsm_exit(const vcsm_init_type_t init_mode);
-const char * cma_vcsm_init_str(const vcsm_init_type_t init_mode);
-
 #define MMAL_RESIZE_NAME "mmal-resize"
 #define MMAL_ISP_NAME    "mmal-isp"
 



More information about the vlc-commits mailing list