c64-tools: new recipe for c64_tools
[openpandora.oe.git] / recipes / c64_tools / c64-tools / op_dsp_c64.sh
diff --git a/recipes/c64_tools/c64-tools/op_dsp_c64.sh b/recipes/c64_tools/c64-tools/op_dsp_c64.sh
new file mode 100755 (executable)
index 0000000..25a743c
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+# ----
+# ---- file   : go64.sh
+# ---- author : Bastian Spiegel <bs@tkscript.de>
+# ---- legal  : (c) 2013 by Bastian Spiegel. 
+# ----          Distributed under terms of the GNU GENERAL PUBLIC LICENSE (GPL). See 
+# ----          http://www.gnu.org/licenses/licenses.html#GPL or COPYING_GPL for further information.
+# ----
+# ---- info   : This is part of the "c64_tools" package.
+# ----
+# ---- changed: 06Sep2013, 08Sep2013, 14Sep2013, 16Sep2013, 18Sep2013, 01Oct2013
+# ----
+# ----
+#
+
+#
+#
+# You need to be root in order to run this:
+#
+#  $ sudo ./go64.sh [c64_load args] [c64_load dspimage pathname]
+#
+# Enable kernel module debug output by setting the C64_DEBUG variable
+#  before running this script:
+#
+#  $ export C64_DEBUG=1
+#
+# To disable debug output, unset the variable:
+#
+#  $ unset C64_DEBUG
+#
+# then re-run this script.
+#
+#
+
+#export C64_DEBUG=10
+
+#ARGS=-vv
+#ARGS=-vv
+#ARGS=-v
+ARGS=
+
+DSPIMAGE=/lib/dsp/core.out
+
+# LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:./"
+
+
+if [ $# -eq 2 ]; then
+   # args + DSP image pathname
+   ARGS="$1"
+   DSPIMAGE="$2"
+else
+   if [ $# -eq 1 ]; then
+      if [ "x`echo $1 | cut -c -1`" = "x-" ]; then
+         # args only
+         ARGS="$1"
+      else
+         # DSP image pathname only
+         DSPIMAGE="$1"
+      fi
+   else 
+      if [ $# -eq 0 ]; then
+        if [ "x" != "x`/sbin/lsmod | grep c64`" -a -c /dev/c64 ] ; then
+          # don't reload or reinit, somebody may be using it
+          echo "module already loaded"
+          exit 0
+        fi
+        # use default args
+        echo " "
+      else
+        echo "Usage: sudo go64.sh [c64_load args] [c64_load dspimage pathname]"
+        exit 10;
+      fi
+   fi
+fi
+
+
+
+# Unload kernel module if it's already loaded
+if [ "x" != "x`/sbin/lsmod | grep c64`" ] ; then
+  /sbin/rmmod c64
+  rm -f /dev/c64
+fi
+
+
+# Load kernel module
+KMODARGS=
+if [ "x" != "x$C64_DEBUG" ]; then
+  KMODARGS="debug=$C64_DEBUG"
+fi
+# /sbin/insmod ./
+modprobe c64 $KMODARGS
+
+
+sleep 0.25
+
+
+# Grant everyone access to the c64 driver 
+# (done by udev rule)
+#chmod 0666 /dev/c64
+
+
+# Load COFF2 DSP image and start the DSP
+echo "go64.sh: ARGS=\"${ARGS}\" DSPIMAGE=\"${DSPIMAGE}\""
+/usr/sbin/c64_load ${ARGS} ${DSPIMAGE}