* Use update-alternatives for the firmware
* Add reload-dsp-fw.sh to enable run-time firmware switch between opencl and 
tiovx

Signed-off-by: Djordje Senicic <[email protected]>
Signed-off-by: Jacob Stiffler <[email protected]>
Signed-off-by: Hongmei Gou <[email protected]>
---
 .../recipes-ti/tiovx/files/reload-dsp-fw.sh   | 66 +++++++++++++++++++
 .../recipes-ti/tiovx/tiovx-sys-iface.bb       | 49 ++++++++++++++
 .../recipes-ti/tiovx/tiovx-sys.inc            |  5 ++
 3 files changed, 120 insertions(+)
 create mode 100755 meta-arago-extras/recipes-ti/tiovx/files/reload-dsp-fw.sh
 create mode 100644 meta-arago-extras/recipes-ti/tiovx/tiovx-sys-iface.bb
 create mode 100644 meta-arago-extras/recipes-ti/tiovx/tiovx-sys.inc

diff --git a/meta-arago-extras/recipes-ti/tiovx/files/reload-dsp-fw.sh 
b/meta-arago-extras/recipes-ti/tiovx/files/reload-dsp-fw.sh
new file mode 100755
index 00000000..198fd60f
--- /dev/null
+++ b/meta-arago-extras/recipes-ti/tiovx/files/reload-dsp-fw.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+usage() {
+    cat << EOF
+
+  Usage:
+         $0 <fw-type: opencl, tiovx>
+
+EOF
+}
+
+if [ "$1" ]; then
+case "$1" in
+    opencl) echo "Reload opencl firmware to DSP"
+        ;;
+    tiovx) echo "Reload tiovx firmware to DSP"
+        ;;
+    *) echo "Wrong argument $1"
+       usage
+       exit
+        ;;
+esac
+else
+       usage
+       exit
+fi
+
+fw="${1}"
+
+if [[ ${fw} == opencl ]]; then
+    #Start OpenCL CMEM memory allocation daemon
+    if pgrep -x "ti-mctd" > /dev/null
+    then
+        echo "ti-mctd is running"
+    else
+        echo "Starting ti-mctd..."
+        ti-mctd
+    fi
+    # Link opencl monitor firmware for DSPs
+    ln -s -f /lib/firmware/dra7-dsp1-fw.xe66.opencl-monitor 
/lib/firmware/dra7-dsp1-fw.xe66
+    ln -s -f /lib/firmware/dra7-dsp2-fw.xe66.opencl-monitor 
/lib/firmware/dra7-dsp2-fw.xe66
+fi
+
+if [[ ${fw} == tiovx ]]; then
+    # Kill CMEM multi-process daemon. This releases all CMEM memory used by 
OpenCL memory allocation
+    pkill ti-mctd
+
+    # Link tiovx firmware for DSPs
+    ln -s -f /lib/firmware/dra7-dsp1-fw.xe66.openvx 
/lib/firmware/dra7-dsp1-fw.xe66
+    ln -s -f /lib/firmware/dra7-dsp2-fw.xe66.openvx 
/lib/firmware/dra7-dsp2-fw.xe66
+fi
+
+cd /sys/bus/platform/drivers/omap-rproc/
+
+# release DSPs
+echo "Releasing DSPs..."
+echo 40800000.dsp > unbind
+
+echo 41000000.dsp > unbind
+
+# reload firmware for DSPs
+echo "Reloading firmware for DSPs..."
+echo 40800000.dsp > bind
+
+echo 41000000.dsp > bind
+
+cd ~-
diff --git a/meta-arago-extras/recipes-ti/tiovx/tiovx-sys-iface.bb 
b/meta-arago-extras/recipes-ti/tiovx/tiovx-sys-iface.bb
new file mode 100644
index 00000000..84d2934b
--- /dev/null
+++ b/meta-arago-extras/recipes-ti/tiovx/tiovx-sys-iface.bb
@@ -0,0 +1,49 @@
+SUMMARY = "TI OpenVX interface header files between TIOVX library and HOST, 
DSP IPC side implementation "
+DESCRIPTION = "Collection of header files needed to defined interface between 
TIOVX library and HOST and DSP IPC side implementation. In order to maintain 
source compatibility, directory structure follows VSDK source tree layout."
+
+LICENSE = "TI-TSPA"
+LIC_FILES_CHKSUM = 
"file://iface/VSDK/docs/TIOVX-SYS-IFACE_1.0.0.0_manifest.html;md5=10904cbdb4f065c025a63ca71ae7de2d"
+
+require recipes-ti/includes/tisdk-paths.inc
+require tiovx-sys.inc
+
+PR = "r1"
+
+COMPATIBLE_MACHINE = "dra7xx"
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit update-alternatives
+
+SRC_URI_append += "\
+     file://reload-dsp-fw.sh \
+"
+
+S = "${WORKDIR}/git"
+
+do_install () {
+#   Install the header files
+    CP_ARGS="-Prf --preserve=mode,timestamps --no-preserve=ownership"
+    install -d ${D}${TIOVX_INSTALL_DIR_RECIPE}/sys-iface
+    cp ${CP_ARGS} ${S}/iface/VSDK/* ${D}${TIOVX_INSTALL_DIR_RECIPE}/sys-iface
+#   Install the firmware
+    install -d ${D}/${base_libdir}/firmware
+    install -m 0644 ${S}/firmware/tiovx_dsp1.xe66 
${D}/${base_libdir}/firmware/dra7-dsp1-fw.xe66.openvx
+    install -m 0644 ${S}/firmware/tiovx_dsp2.xe66 
${D}/${base_libdir}/firmware/dra7-dsp2-fw.xe66.openvx
+#   Install the scripts for loading dsp firmware
+    install -d ${D}${bindir}/
+    install -m 0755 ${WORKDIR}/reload-dsp-fw.sh ${D}${bindir}
+}
+
+ALTERNATIVE_${PN} = "dra7-dsp1-fw.xe66 dra7-dsp2-fw.xe66"
+ALTERNATIVE_LINK_NAME[dra7-dsp1-fw.xe66] = 
"${base_libdir}/firmware/dra7-dsp1-fw.xe66"
+ALTERNATIVE_TARGET[dra7-dsp1-fw.xe66] = 
"${base_libdir}/firmware/dra7-dsp1-fw.xe66.openvx"
+ALTERNATIVE_LINK_NAME[dra7-dsp2-fw.xe66] = 
"${base_libdir}/firmware/dra7-dsp2-fw.xe66"
+ALTERNATIVE_TARGET[dra7-dsp2-fw.xe66] = 
"${base_libdir}/firmware/dra7-dsp2-fw.xe66.openvx"
+ALTERNATIVE_PRIORITY = "20"
+
+FILES_${PN} += "${TIOVX_INSTALL_DIR_RECIPE}/sys-iface/* "
+PACKAGES =+ "${PN}-firmware"
+FILES_${PN}-firmware = "${base_libdir}/firmware/*"
+
+INSANE_SKIP_${PN}-firmware = "arch"
+
diff --git a/meta-arago-extras/recipes-ti/tiovx/tiovx-sys.inc 
b/meta-arago-extras/recipes-ti/tiovx/tiovx-sys.inc
new file mode 100644
index 00000000..becf0cc1
--- /dev/null
+++ b/meta-arago-extras/recipes-ti/tiovx/tiovx-sys.inc
@@ -0,0 +1,5 @@
+PV = "01.00.01.00"
+
+BRANCH="master"
+SRCREV = "5be60aee8d013907a4d8a6cc8af35a517a33b49e"
+SRC_URI = 
"git://git.ti.com/processor-sdk/tiovx-app.git;protocol=git;branch=${BRANCH}"
-- 
2.17.1

_______________________________________________
meta-arago mailing list
[email protected]
http://arago-project.org/cgi-bin/mailman/listinfo/meta-arago

Reply via email to