c64-tools: update to latest
[openpandora.oe.git] / recipes / c64_tools / c64-tools / op_dsp_c64.sh
1 #!/bin/sh
2
3 # ----
4 # ---- file   : go64.sh
5 # ---- author : Bastian Spiegel <bs@tkscript.de>
6 # ---- legal  : (c) 2013 by Bastian Spiegel. 
7 # ----          Distributed under terms of the GNU GENERAL PUBLIC LICENSE (GPL). See 
8 # ----          http://www.gnu.org/licenses/licenses.html#GPL or COPYING_GPL for further information.
9 # ----
10 # ---- info   : This is part of the "c64_tools" package.
11 # ----
12 # ---- changed: 06Sep2013, 08Sep2013, 14Sep2013, 16Sep2013, 18Sep2013, 01Oct2013
13 # ----
14 # ----
15 #
16
17 #
18 #
19 # You need to be root in order to run this:
20 #
21 #  $ sudo ./go64.sh [c64_load args] [c64_load dspimage pathname]
22 #
23 # Enable kernel module debug output by setting the C64_DEBUG variable
24 #  before running this script:
25 #
26 #  $ export C64_DEBUG=1
27 #
28 # To disable debug output, unset the variable:
29 #
30 #  $ unset C64_DEBUG
31 #
32 # then re-run this script.
33 #
34 #
35
36 #export C64_DEBUG=10
37
38 #ARGS=-vv
39 #ARGS=-vv
40 #ARGS=-v
41 ARGS=
42
43 DSPIMAGE=/lib/dsp/core.out
44
45 # LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:./"
46
47
48 if [ $# -eq 2 ]; then
49    # args + DSP image pathname
50    ARGS="$1"
51    DSPIMAGE="$2"
52 else
53    if [ $# -eq 1 ]; then
54       if [ "x`echo $1 | cut -c -1`" = "x-" ]; then
55          # args only
56          ARGS="$1"
57       else
58          # DSP image pathname only
59          DSPIMAGE="$1"
60       fi
61    else 
62       if [ $# -eq 0 ]; then
63         if [ "x" != "x`/sbin/lsmod | grep c64`" -a -c /dev/c64 ] ; then
64           # don't reload or reinit, somebody may be using it
65           echo "module already loaded"
66           exit 0
67         fi
68         # use default args
69         echo " "
70       else
71         echo "Usage: sudo go64.sh [c64_load args] [c64_load dspimage pathname]"
72         exit 10;
73       fi
74    fi
75 fi
76
77
78
79 # Unload kernel module if it's already loaded
80 if [ "x" != "x`/sbin/lsmod | grep c64`" ] ; then
81   /sbin/rmmod c64
82   rm -f /dev/c64
83 fi
84
85
86 # Load kernel module
87 KMODARGS=
88 if [ "x" != "x$C64_DEBUG" ]; then
89   KMODARGS="debug=$C64_DEBUG"
90 fi
91 # /sbin/insmod ./
92 /sbin/modprobe c64 $KMODARGS
93
94
95 sleep 0.25
96
97
98 # Grant everyone access to the c64 driver 
99 # (done by udev rule)
100 #chmod 0666 /dev/c64
101
102
103 # Load COFF2 DSP image and start the DSP
104 echo "go64.sh: ARGS=\"${ARGS}\" DSPIMAGE=\"${DSPIMAGE}\""
105 /usr/sbin/c64_load ${ARGS} ${DSPIMAGE}