Linux-libre 3.4.9-gnu1
[librecmc/linux-libre.git] / Documentation / sound / oss / MultiSound
1 #! /bin/sh
2 #
3 #  Turtle Beach MultiSound Driver Notes
4 #  -- Andrew Veliath <andrewtv@usa.net>
5 #
6 #  Last update:                      September 10, 1998
7 #  Corresponding msnd driver:        0.8.3
8 #
9 # ** This file is a README (top part) and shell archive (bottom part).
10 #    The corresponding archived utility sources can be unpacked by
11 #    running `sh MultiSound' (the utilities are only needed for the
12 #    Pinnacle and Fiji cards). **
13 #
14 #
15 #  -=-=- Getting Firmware -=-=-
16 #  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17 #  
18 #  See the section `Obtaining and Creating Firmware Files' in this
19 #  document for instructions on obtaining the necessary firmware
20 #  files.
21 #  
22 #  
23 #  Supported Features
24 #  ~~~~~~~~~~~~~~~~~~
25 #  
26 #  Currently, full-duplex digital audio (/dev/dsp only, /dev/audio is
27 #  not currently available) and mixer functionality (/dev/mixer) are
28 #  supported (memory mapped digital audio is not yet supported).
29 #  Digital transfers and monitoring can be done as well if you have
30 #  the digital daughterboard (see the section on using the S/PDIF port
31 #  for more information).
32 #
33 #  Support for the Turtle Beach MultiSound Hurricane architecture is
34 #  composed of the following modules (these can also operate compiled
35 #  into the kernel):
36 #  
37 #  msnd               - MultiSound base (requires soundcore)
38 #
39 #  msnd_classic       - Base audio/mixer support for Classic, Monetery and
40 #                       Tahiti cards
41 #
42 #  msnd_pinnacle      - Base audio/mixer support for Pinnacle and Fiji cards
43 #  
44 #  
45 #  /*(DEBLOBBED)*/
46 #  
47 #  
48 #  Configuring Card Resources
49 #  ~~~~~~~~~~~~~~~~~~~~~~~~~~
50 #
51 #  ** This section is very important, as your card may not work at all
52 #     or your machine may crash if you do not do this correctly. **
53 #
54 #  * Classic/Monterey/Tahiti
55 #  
56 #  These cards are configured through the driver msnd_classic.  You must
57 #  know the io port, then the driver will select the irq and memory resources
58 #  on the card.  It is up to you to know if these are free locations or now,
59 #  a conflict can lock the machine up.
60 #
61 #  * Pinnacle/Fiji
62 #
63 #  The Pinnacle and Fiji cards have an extra config port, either
64 #  0x250, 0x260 or 0x270.  This port can be disabled to have the card
65 #  configured strictly through PnP, however you lose the ability to
66 #  access the IDE controller and joystick devices on this card when
67 #  using PnP.  The included pinnaclecfg program in this shell archive
68 #  can be used to configure the card in non-PnP mode, and in PnP mode
69 #  you can use isapnptools.  These are described briefly here.
70 #
71 #  pinnaclecfg is not required; you can use the msnd_pinnacle module
72 #  to fully configure the card as well.  However, pinnaclecfg can be
73 #  used to change the resource values of a particular device after the
74 #  msnd_pinnacle module has been loaded.  If you are compiling the
75 #  driver into the kernel, you must set these values during compile
76 #  time, however other peripheral resource values can be changed with
77 #  the pinnaclecfg program after the kernel is loaded.
78 #
79 #
80 #  *** PnP mode
81 #  
82 #  Use pnpdump to obtain a sample configuration if you can; I was able
83 #  to obtain one with the command `pnpdump 1 0x203' -- this may vary
84 #  for you (running pnpdump by itself did not work for me).  Then,
85 #  edit this file and use isapnp to uncomment and set the card values.
86 #  Use these values when inserting the msnd_pinnacle module.  Using
87 #  this method, you can set the resources for the DSP and the Kurzweil
88 #  synth (Pinnacle).  Since Linux does not directly support PnP
89 #  devices, you may have difficulty when using the card in PnP mode
90 #  when it the driver is compiled into the kernel.  Using non-PnP mode
91 #  is preferable in this case.
92 #
93 #  Here is an example mypinnacle.conf for isapnp that sets the card to
94 #  io base 0x210, irq 5 and mem 0xd8000, and also sets the Kurzweil
95 #  synth to 0x330 and irq 9 (may need editing for your system):
96 #
97 #  (READPORT 0x0203)
98 #  (CSN 2)
99 #  (IDENTIFY *)
100 #  
101 #  # DSP
102 #  (CONFIGURE BVJ0440/-1 (LD 0
103 #          (INT 0 (IRQ 5 (MODE +E))) (IO 0 (BASE 0x0210)) (MEM 0 (BASE 0x0d8000))
104 #          (ACT Y)))
105 #  
106 #  # Kurzweil Synth (Pinnacle Only)
107 #  (CONFIGURE BVJ0440/-1 (LD 1
108 #          (IO 0 (BASE 0x0330)) (INT 0 (IRQ 9 (MODE +E)))
109 #          (ACT Y)))
110 #  
111 #  (WAITFORKEY)
112 #
113 #
114 #  *** Non-PnP mode
115 #  
116 #  The second way is by running the card in non-PnP mode.  This
117 #  actually has some advantages in that you can access some other
118 #  devices on the card, such as the joystick and IDE controller.  To
119 #  configure the card, unpack this shell archive and build the
120 #  pinnaclecfg program.  Using this program, you can assign the
121 #  resource values to the card's devices, or disable the devices.  As
122 #  an alternative to using pinnaclecfg, you can specify many of the
123 #  configuration values when loading the msnd_pinnacle module (or
124 #  during kernel configuration when compiling the driver into the
125 #  kernel).
126 #
127 #  If you specify cfg=0x250 for the msnd_pinnacle module, it
128 #  automatically configure the card to the given io, irq and memory
129 #  values using that config port (the config port is jumper selectable
130 #  on the card to 0x250, 0x260 or 0x270).
131 #
132 #  See the `msnd_pinnacle Additional Options' section below for more
133 #  information on these parameters (also, if you compile the driver
134 #  directly into the kernel, these extra parameters can be useful
135 #  here).
136 #
137 #
138 # ** It is very easy to cause problems in your machine if you choose a
139 #    resource value which is incorrect. **
140 #  
141 #
142 #  Examples
143 #  ~~~~~~~~
144 #  
145 #  * MultiSound Classic/Monterey/Tahiti:
146 #  
147 #  modprobe soundcore
148 #  insmod msnd
149 #  insmod msnd_classic io=0x290 irq=7 mem=0xd0000
150 #  
151 #  * MultiSound Pinnacle in PnP mode:
152 #  
153 #  modprobe soundcore
154 #  insmod msnd
155 #  isapnp mypinnacle.conf
156 #  insmod msnd_pinnacle io=0x210 irq=5 mem=0xd8000 <-- match mypinnacle.conf values
157 #  
158 #  * MultiSound Pinnacle in non-PnP mode (replace 0x250 with your configuration port,
159 #    one of 0x250, 0x260 or 0x270):
160 #  
161 #  insmod soundcore
162 #  insmod msnd
163 #  insmod msnd_pinnacle cfg=0x250 io=0x290 irq=5 mem=0xd0000
164 #  
165 # * To use the MPU-compatible Kurzweil synth on the Pinnacle in PnP
166 #   mode, add the following (assumes you did `isapnp mypinnacle.conf'):
167 #  
168 #  insmod sound
169 #  insmod mpu401 io=0x330 irq=9                    <-- match mypinnacle.conf values
170 #  
171 # * To use the MPU-compatible Kurzweil synth on the Pinnacle in non-PnP
172 #   mode, add the following.  Note how we first configure the peripheral's
173 #   resources, _then_ install a Linux driver for it:
174 #  
175 #  insmod sound
176 #  pinnaclecfg 0x250 mpu 0x330 9
177 #  insmod mpu401 io=0x330 irq=9
178 #
179 #  -- OR you can use the following sequence without pinnaclecfg in non-PnP mode:
180 #
181 #  insmod soundcore
182 #  insmod msnd
183 #  insmod msnd_pinnacle cfg=0x250 io=0x290 irq=5 mem=0xd0000 mpu_io=0x330 mpu_irq=9
184 #  insmod sound
185 #  insmod mpu401 io=0x330 irq=9
186 #
187 # * To setup the joystick port on the Pinnacle in non-PnP mode (though
188 #   you have to find the actual Linux joystick driver elsewhere), you
189 #   can use pinnaclecfg:
190 #
191 #   pinnaclecfg 0x250 joystick 0x200
192 #
193 #  -- OR you can configure this using msnd_pinnacle with the following:
194 #
195 #  insmod soundcore
196 #  insmod msnd
197 #  insmod msnd_pinnacle cfg=0x250 io=0x290 irq=5 mem=0xd0000 joystick_io=0x200
198 #
199 #  
200 #  msnd_classic, msnd_pinnacle Required Options
201 #  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
202 #  
203 #  If the following options are not given, the module will not load.
204 #  Examine the kernel message log for informative error messages.
205 #  WARNING--probing isn't supported so try to make sure you have the
206 #  correct shared memory area, otherwise you may experience problems.
207 #  
208 #  io                   I/O base of DSP, e.g. io=0x210
209 #  irq                  IRQ number, e.g. irq=5
210 #  mem                  Shared memory area, e.g. mem=0xd8000
211 #  
212 #  
213 #  msnd_classic, msnd_pinnacle Additional Options
214 #  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215 #  
216 #  fifosize             The digital audio FIFOs, in kilobytes.  If not
217 #                       specified, the default will be used.  Increasing
218 #                       this value will reduce the chance of a FIFO
219 #                       underflow at the expense of increasing overall
220 #                       latency.  For example, fifosize=512 will
221 #                       allocate 512kB read and write FIFOs (1MB total).
222 #                       While this may reduce dropouts, a heavy machine
223 #                       load will undoubtedly starve the FIFO of data
224 #                       and you will eventually get dropouts.  One
225 #                       option is to alter the scheduling priority of
226 #                       the playback process, using `nice' or some form
227 #                       of POSIX soft real-time scheduling.
228 #
229 #  calibrate_signal     Setting this to one calibrates the ADCs to the
230 #                       signal, zero calibrates to the card (defaults
231 #                       to zero).
232 #  
233 #  
234 #  msnd_pinnacle Additional Options
235 #  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
236 #
237 #  digital              Specify digital=1 to enable the S/PDIF input
238 #                       if you have the digital daughterboard
239 #                       adapter. This will enable access to the
240 #                       DIGITAL1 input for the soundcard in the mixer.
241 #                       Some mixer programs might have trouble setting
242 #                       the DIGITAL1 source as an input.  If you have
243 #                       trouble, you can try the setdigital.c program
244 #                       at the bottom of this document.
245 #
246 #  cfg                  Non-PnP configuration port for the Pinnacle
247 #                       and Fiji (typically 0x250, 0x260 or 0x270,
248 #                       depending on the jumper configuration).  If
249 #                       this option is omitted, then it is assumed
250 #                       that the card is in PnP mode, and that the
251 #                       specified DSP resource values are already
252 #                       configured with PnP (i.e. it won't attempt to
253 #                       do any sort of configuration).
254 #
255 #  When the Pinnacle is in non-PnP mode, you can use the following
256 #  options to configure particular devices.  If a full specification
257 #  for a device is not given, then the device is not configured.  Note
258 #  that you still must use a Linux driver for any of these devices
259 #  once their resources are setup (such as the Linux joystick driver,
260 #  or the MPU401 driver from OSS for the Kurzweil synth).
261 #
262 #  mpu_io               I/O port of MPU (on-board Kurzweil synth)
263 #  mpu_irq              IRQ of MPU (on-board Kurzweil synth)
264 #  ide_io0              First I/O port of IDE controller
265 #  ide_io1              Second I/O port of IDE controller
266 #  ide_irq              IRQ IDE controller
267 #  joystick_io          I/O port of joystick
268 #  
269 #  
270 #  /*(DEBLOBBED)*/
271 #
272 #  
273 #  Using Digital I/O with the S/PDIF Port
274 #  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
275 #
276 #  If you have a Pinnacle or Fiji with the digital daughterboard and
277 #  want to set it as the input source, you can use this program if you
278 #  have trouble trying to do it with a mixer program (be sure to
279 #  insert the module with the digital=1 option, or say Y to the option
280 #  during compiled-in kernel operation).  Upon selection of the S/PDIF
281 #  port, you should be able monitor and record from it.
282 #
283 #  There is something to note about using the S/PDIF port.  Digital
284 #  timing is taken from the digital signal, so if a signal is not
285 #  connected to the port and it is selected as recording input, you
286 #  will find PCM playback to be distorted in playback rate.  Also,
287 #  attempting to record at a sampling rate other than the DAT rate may
288 #  be problematic (i.e. trying to record at 8000Hz when the DAT signal
289 #  is 44100Hz).  If you have a problem with this, set the recording
290 #  input to analog if you need to record at a rate other than that of
291 #  the DAT rate.
292 #
293 #
294 #  -- Shell archive attached below, just run `sh MultiSound' to extract.
295 #     Contains Pinnacle/Fiji utilities to convert firmware, configure
296 #     in non-PnP mode, and select the DIGITAL1 input for the mixer.
297 #
298 #
299 #!/bin/sh
300 # This is a shell archive (produced by GNU sharutils 4.2).
301 # To extract the files from this archive, save it to some FILE, remove
302 # everything before the `!/bin/sh' line above, then type `sh FILE'.
303 #
304 # Made on 1998-12-04 10:07 EST by <andrewtv@ztransform.velsoft.com>.
305 # Source directory was `/home/andrewtv/programming/pinnacle/pinnacle'.
306 #
307 # Existing files will *not* be overwritten unless `-c' is specified.
308 #
309 # This shar contains:
310 # length mode       name
311 # ------ ---------- ------------------------------------------
312 #   2046 -rw-rw-r-- MultiSound.d/setdigital.c
313 #  10235 -rw-rw-r-- MultiSound.d/pinnaclecfg.c
314 #    106 -rw-rw-r-- MultiSound.d/Makefile
315 #    141 -rw-rw-r-- MultiSound.d/conv.l
316 #   1472 -rw-rw-r-- MultiSound.d/msndreset.c
317 #
318 save_IFS="${IFS}"
319 IFS="${IFS}:"
320 gettext_dir=FAILED
321 locale_dir=FAILED
322 first_param="$1"
323 for dir in $PATH
324 do
325   if test "$gettext_dir" = FAILED && test -f $dir/gettext \
326      && ($dir/gettext --version >/dev/null 2>&1)
327   then
328     set `$dir/gettext --version 2>&1`
329     if test "$3" = GNU
330     then
331       gettext_dir=$dir
332     fi
333   fi
334   if test "$locale_dir" = FAILED && test -f $dir/shar \
335      && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
336   then
337     locale_dir=`$dir/shar --print-text-domain-dir`
338   fi
339 done
340 IFS="$save_IFS"
341 if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
342 then
343   echo=echo
344 else
345   TEXTDOMAINDIR=$locale_dir
346   export TEXTDOMAINDIR
347   TEXTDOMAIN=sharutils
348   export TEXTDOMAIN
349   echo="$gettext_dir/gettext -s"
350 fi
351 touch -am 1231235999 $$.touch >/dev/null 2>&1
352 if test ! -f 1231235999 && test -f $$.touch; then
353   shar_touch=touch
354 else
355   shar_touch=:
356   echo
357   $echo 'WARNING: not restoring timestamps.  Consider getting and'
358   $echo "installing GNU \`touch', distributed in GNU File Utilities..."
359   echo
360 fi
361 rm -f 1231235999 $$.touch
362 #
363 if mkdir _sh01426; then
364   $echo 'x -' 'creating lock directory'
365 else
366   $echo 'failed to create lock directory'
367   exit 1
368 fi
369 # ============= MultiSound.d/setdigital.c ==============
370 if test ! -d 'MultiSound.d'; then
371   $echo 'x -' 'creating directory' 'MultiSound.d'
372   mkdir 'MultiSound.d'
373 fi
374 if test -f 'MultiSound.d/setdigital.c' && test "$first_param" != -c; then
375   $echo 'x -' SKIPPING 'MultiSound.d/setdigital.c' '(file already exists)'
376 else
377   $echo 'x -' extracting 'MultiSound.d/setdigital.c' '(text)'
378   sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/setdigital.c' &&
379 /*********************************************************************
380 X *
381 X * setdigital.c - sets the DIGITAL1 input for a mixer
382 X *
383 X * Copyright (C) 1998 Andrew Veliath
384 X *
385 X * This program is free software; you can redistribute it and/or modify
386 X * it under the terms of the GNU General Public License as published by
387 X * the Free Software Foundation; either version 2 of the License, or
388 X * (at your option) any later version.
389 X *
390 X * This program is distributed in the hope that it will be useful,
391 X * but WITHOUT ANY WARRANTY; without even the implied warranty of
392 X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
393 X * GNU General Public License for more details.
394 X *
395 X * You should have received a copy of the GNU General Public License
396 X * along with this program; if not, write to the Free Software
397 X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
398 X *
399 X ********************************************************************/
400 X
401 #include <stdio.h>
402 #include <unistd.h>
403 #include <fcntl.h>
404 #include <sys/types.h>
405 #include <sys/stat.h>
406 #include <sys/ioctl.h>
407 #include <sys/soundcard.h>
408 X
409 int main(int argc, char *argv[])
410 {
411 X       int fd;
412 X       unsigned long recmask, recsrc;
413 X
414 X       if (argc != 2) {
415 X               fprintf(stderr, "usage: setdigital <mixer device>\n");
416 X               exit(1);
417 X       }
418 X
419 X       if ((fd = open(argv[1], O_RDWR)) < 0) {
420 X               perror(argv[1]);
421 X               exit(1);
422 X       }
423 X
424 X       if (ioctl(fd, SOUND_MIXER_READ_RECMASK, &recmask) < 0) {
425 X               fprintf(stderr, "error: ioctl read recording mask failed\n");
426 X               perror("ioctl");
427 X               close(fd);
428 X               exit(1);
429 X       }
430 X
431 X       if (!(recmask & SOUND_MASK_DIGITAL1)) {
432 X               fprintf(stderr, "error: cannot find DIGITAL1 device in mixer\n");
433 X               close(fd);
434 X               exit(1);
435 X       }
436 X
437 X       if (ioctl(fd, SOUND_MIXER_READ_RECSRC, &recsrc) < 0) {
438 X               fprintf(stderr, "error: ioctl read recording source failed\n");
439 X               perror("ioctl");
440 X               close(fd);
441 X               exit(1);
442 X       }
443 X
444 X       recsrc |= SOUND_MASK_DIGITAL1;
445 X       
446 X       if (ioctl(fd, SOUND_MIXER_WRITE_RECSRC, &recsrc) < 0) {
447 X               fprintf(stderr, "error: ioctl write recording source failed\n");
448 X               perror("ioctl");
449 X               close(fd);
450 X               exit(1);
451 X       }
452 X
453 X       close(fd);
454 X       
455 X       return 0;
456 }
457 SHAR_EOF
458   $shar_touch -am 1204092598 'MultiSound.d/setdigital.c' &&
459   chmod 0664 'MultiSound.d/setdigital.c' ||
460   $echo 'restore of' 'MultiSound.d/setdigital.c' 'failed'
461   if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
462   && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
463     md5sum -c << SHAR_EOF >/dev/null 2>&1 \
464     || $echo 'MultiSound.d/setdigital.c:' 'MD5 check failed'
465 e87217fc3e71288102ba41fd81f71ec4  MultiSound.d/setdigital.c
466 SHAR_EOF
467   else
468     shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/setdigital.c'`"
469     test 2046 -eq "$shar_count" ||
470     $echo 'MultiSound.d/setdigital.c:' 'original size' '2046,' 'current size' "$shar_count!"
471   fi
472 fi
473 # ============= MultiSound.d/pinnaclecfg.c ==============
474 if test -f 'MultiSound.d/pinnaclecfg.c' && test "$first_param" != -c; then
475   $echo 'x -' SKIPPING 'MultiSound.d/pinnaclecfg.c' '(file already exists)'
476 else
477   $echo 'x -' extracting 'MultiSound.d/pinnaclecfg.c' '(text)'
478   sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/pinnaclecfg.c' &&
479 /*********************************************************************
480 X *
481 X * pinnaclecfg.c - Pinnacle/Fiji Device Configuration Program
482 X *
483 X * This is for NON-PnP mode only.  For PnP mode, use isapnptools.
484 X *
485 X * This is Linux-specific, and must be run with root permissions.
486 X *
487 X * Part of the Turtle Beach MultiSound Sound Card Driver for Linux
488 X *
489 X * Copyright (C) 1998 Andrew Veliath
490 X *
491 X * This program is free software; you can redistribute it and/or modify
492 X * it under the terms of the GNU General Public License as published by
493 X * the Free Software Foundation; either version 2 of the License, or
494 X * (at your option) any later version.
495 X *
496 X * This program is distributed in the hope that it will be useful,
497 X * but WITHOUT ANY WARRANTY; without even the implied warranty of
498 X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
499 X * GNU General Public License for more details.
500 X *
501 X * You should have received a copy of the GNU General Public License
502 X * along with this program; if not, write to the Free Software
503 X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
504 X *
505 X ********************************************************************/
506 X
507 #include <stdio.h>
508 #include <stdlib.h>
509 #include <string.h>
510 #include <errno.h>
511 #include <unistd.h>
512 #include <asm/io.h>
513 #include <asm/types.h>
514 X
515 #define IREG_LOGDEVICE          0x07
516 #define IREG_ACTIVATE           0x30
517 #define LD_ACTIVATE             0x01
518 #define LD_DISACTIVATE          0x00
519 #define IREG_EECONTROL          0x3F
520 #define IREG_MEMBASEHI          0x40
521 #define IREG_MEMBASELO          0x41
522 #define IREG_MEMCONTROL         0x42
523 #define IREG_MEMRANGEHI         0x43
524 #define IREG_MEMRANGELO         0x44
525 #define MEMTYPE_8BIT            0x00
526 #define MEMTYPE_16BIT           0x02
527 #define MEMTYPE_RANGE           0x00
528 #define MEMTYPE_HIADDR          0x01
529 #define IREG_IO0_BASEHI         0x60
530 #define IREG_IO0_BASELO         0x61
531 #define IREG_IO1_BASEHI         0x62
532 #define IREG_IO1_BASELO         0x63
533 #define IREG_IRQ_NUMBER         0x70
534 #define IREG_IRQ_TYPE           0x71
535 #define IRQTYPE_HIGH            0x02
536 #define IRQTYPE_LOW             0x00
537 #define IRQTYPE_LEVEL           0x01
538 #define IRQTYPE_EDGE            0x00
539 X
540 #define HIBYTE(w)               ((BYTE)(((WORD)(w) >> 8) & 0xFF))
541 #define LOBYTE(w)               ((BYTE)(w))
542 #define MAKEWORD(low,hi)        ((WORD)(((BYTE)(low))|(((WORD)((BYTE)(hi)))<<8)))
543 X
544 typedef __u8                    BYTE;
545 typedef __u16                   USHORT;
546 typedef __u16                   WORD;
547 X
548 static int config_port = -1;
549 X
550 static int msnd_write_cfg(int cfg, int reg, int value)
551 {
552 X       outb(reg, cfg);
553 X       outb(value, cfg + 1);
554 X       if (value != inb(cfg + 1)) {
555 X               fprintf(stderr, "error: msnd_write_cfg: I/O error\n");
556 X               return -EIO;
557 X       }
558 X       return 0;
559 }
560 X
561 static int msnd_read_cfg(int cfg, int reg)
562 {
563 X       outb(reg, cfg);
564 X       return inb(cfg + 1);
565 }
566 X
567 static int msnd_write_cfg_io0(int cfg, int num, WORD io)
568 {
569 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
570 X               return -EIO;
571 X       if (msnd_write_cfg(cfg, IREG_IO0_BASEHI, HIBYTE(io)))
572 X               return -EIO;
573 X       if (msnd_write_cfg(cfg, IREG_IO0_BASELO, LOBYTE(io)))
574 X               return -EIO;
575 X       return 0;
576 }
577 X
578 static int msnd_read_cfg_io0(int cfg, int num, WORD *io)
579 {
580 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
581 X               return -EIO;
582 X       
583 X       *io = MAKEWORD(msnd_read_cfg(cfg, IREG_IO0_BASELO),
584 X                      msnd_read_cfg(cfg, IREG_IO0_BASEHI));
585 X
586 X       return 0;
587 }
588 X
589 static int msnd_write_cfg_io1(int cfg, int num, WORD io)
590 {
591 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
592 X               return -EIO;
593 X       if (msnd_write_cfg(cfg, IREG_IO1_BASEHI, HIBYTE(io)))
594 X               return -EIO;
595 X       if (msnd_write_cfg(cfg, IREG_IO1_BASELO, LOBYTE(io)))
596 X               return -EIO;
597 X       return 0;
598 }
599 X
600 static int msnd_read_cfg_io1(int cfg, int num, WORD *io)
601 {
602 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
603 X               return -EIO;
604 X       
605 X       *io = MAKEWORD(msnd_read_cfg(cfg, IREG_IO1_BASELO),
606 X                      msnd_read_cfg(cfg, IREG_IO1_BASEHI));
607 X
608 X       return 0;
609 }
610 X
611 static int msnd_write_cfg_irq(int cfg, int num, WORD irq)
612 {
613 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
614 X               return -EIO;
615 X       if (msnd_write_cfg(cfg, IREG_IRQ_NUMBER, LOBYTE(irq)))
616 X               return -EIO;
617 X       if (msnd_write_cfg(cfg, IREG_IRQ_TYPE, IRQTYPE_EDGE))
618 X               return -EIO;
619 X       return 0;
620 }
621 X
622 static int msnd_read_cfg_irq(int cfg, int num, WORD *irq)
623 {
624 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
625 X               return -EIO;
626 X       
627 X       *irq = msnd_read_cfg(cfg, IREG_IRQ_NUMBER);
628 X
629 X       return 0;
630 }
631 X
632 static int msnd_write_cfg_mem(int cfg, int num, int mem)
633 {
634 X       WORD wmem;
635 X
636 X       mem >>= 8;
637 X       mem &= 0xfff;
638 X       wmem = (WORD)mem;
639 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
640 X               return -EIO;
641 X       if (msnd_write_cfg(cfg, IREG_MEMBASEHI, HIBYTE(wmem)))
642 X               return -EIO;
643 X       if (msnd_write_cfg(cfg, IREG_MEMBASELO, LOBYTE(wmem)))
644 X               return -EIO;
645 X       if (wmem && msnd_write_cfg(cfg, IREG_MEMCONTROL, (MEMTYPE_HIADDR | MEMTYPE_16BIT)))
646 X               return -EIO;
647 X       return 0;
648 }
649 X
650 static int msnd_read_cfg_mem(int cfg, int num, int *mem)
651 {
652 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
653 X               return -EIO;
654 X       
655 X       *mem = MAKEWORD(msnd_read_cfg(cfg, IREG_MEMBASELO),
656 X                       msnd_read_cfg(cfg, IREG_MEMBASEHI));
657 X       *mem <<= 8;
658 X
659 X       return 0;
660 }
661 X
662 static int msnd_activate_logical(int cfg, int num)
663 {
664 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
665 X               return -EIO;
666 X       if (msnd_write_cfg(cfg, IREG_ACTIVATE, LD_ACTIVATE))
667 X               return -EIO;
668 X       return 0;
669 }
670 X
671 static int msnd_write_cfg_logical(int cfg, int num, WORD io0, WORD io1, WORD irq, int mem)
672 {
673 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
674 X               return -EIO;
675 X       if (msnd_write_cfg_io0(cfg, num, io0))
676 X               return -EIO;
677 X       if (msnd_write_cfg_io1(cfg, num, io1))
678 X               return -EIO;
679 X       if (msnd_write_cfg_irq(cfg, num, irq))
680 X               return -EIO;
681 X       if (msnd_write_cfg_mem(cfg, num, mem))
682 X               return -EIO;
683 X       if (msnd_activate_logical(cfg, num))
684 X               return -EIO;
685 X       return 0;
686 }
687 X
688 static int msnd_read_cfg_logical(int cfg, int num, WORD *io0, WORD *io1, WORD *irq, int *mem)
689 {
690 X       if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
691 X               return -EIO;
692 X       if (msnd_read_cfg_io0(cfg, num, io0))
693 X               return -EIO;
694 X       if (msnd_read_cfg_io1(cfg, num, io1))
695 X               return -EIO;
696 X       if (msnd_read_cfg_irq(cfg, num, irq))
697 X               return -EIO;
698 X       if (msnd_read_cfg_mem(cfg, num, mem))
699 X               return -EIO;
700 X       return 0;
701 }
702 X
703 static void usage(void)
704 {
705 X       fprintf(stderr,
706 X               "\n"
707 X               "pinnaclecfg 1.0\n"
708 X               "\n"
709 X               "usage: pinnaclecfg <config port> [device config]\n"
710 X               "\n"
711 X               "This is for use with the card in NON-PnP mode only.\n"
712 X               "\n"
713 X               "Available devices (not all available for Fiji):\n"
714 X               "\n"
715 X               "        Device                       Description\n"
716 X               "        -------------------------------------------------------------------\n"
717 X               "        reset                        Reset all devices (i.e. disable)\n"
718 X               "        show                         Display current device configurations\n"
719 X               "\n"
720 X               "        dsp <io> <irq> <mem>         Audio device\n"
721 X               "        mpu <io> <irq>               Internal Kurzweil synth\n"
722 X               "        ide <io0> <io1> <irq>        On-board IDE controller\n"
723 X               "        joystick <io>                Joystick port\n"
724 X               "\n");
725 X       exit(1);
726 }
727 X
728 static int cfg_reset(void)
729 {
730 X       int i;
731 X
732 X       for (i = 0; i < 4; ++i)
733 X               msnd_write_cfg_logical(config_port, i, 0, 0, 0, 0);
734 X       
735 X       return 0;
736 }
737 X
738 static int cfg_show(void)
739 {
740 X       int i;
741 X       int count = 0;
742 X
743 X       for (i = 0; i < 4; ++i) {
744 X               WORD io0, io1, irq;
745 X               int mem;
746 X               msnd_read_cfg_logical(config_port, i, &io0, &io1, &irq, &mem);
747 X               switch (i) {
748 X               case 0:
749 X                       if (io0 || irq || mem) {
750 X                               printf("dsp 0x%x %d 0x%x\n", io0, irq, mem);
751 X                               ++count;
752 X                       }
753 X                       break;
754 X               case 1:
755 X                       if (io0 || irq) {
756 X                               printf("mpu 0x%x %d\n", io0, irq);
757 X                               ++count;
758 X                       }
759 X                       break;
760 X               case 2:
761 X                       if (io0 || io1 || irq) {
762 X                               printf("ide 0x%x 0x%x %d\n", io0, io1, irq);
763 X                               ++count;
764 X                       }
765 X                       break;
766 X               case 3:
767 X                       if (io0) {
768 X                               printf("joystick 0x%x\n", io0);
769 X                               ++count;
770 X                       }
771 X                       break;
772 X               }
773 X       }
774 X
775 X       if (count == 0)
776 X               fprintf(stderr, "no devices configured\n");
777 X       
778 X       return 0;
779 }
780 X
781 static int cfg_dsp(int argc, char *argv[])
782 {
783 X       int io, irq, mem;
784 X
785 X       if (argc < 3 ||
786 X           sscanf(argv[0], "0x%x", &io) != 1 ||
787 X           sscanf(argv[1], "%d", &irq) != 1 ||
788 X           sscanf(argv[2], "0x%x", &mem) != 1)
789 X               usage();
790 X
791 X       if (!(io == 0x290 ||
792 X             io == 0x260 ||
793 X             io == 0x250 ||
794 X             io == 0x240 ||
795 X             io == 0x230 ||
796 X             io == 0x220 ||
797 X             io == 0x210 ||
798 X             io == 0x3e0)) {
799 X               fprintf(stderr, "error: io must be one of "
800 X                       "210, 220, 230, 240, 250, 260, 290, or 3E0\n");
801 X               usage();
802 X       }
803 X       
804 X       if (!(irq == 5 ||
805 X             irq == 7 ||
806 X             irq == 9 ||
807 X             irq == 10 ||
808 X             irq == 11 ||
809 X             irq == 12)) {
810 X               fprintf(stderr, "error: irq must be one of "
811 X                       "5, 7, 9, 10, 11 or 12\n");
812 X               usage();
813 X       }
814 X
815 X       if (!(mem == 0xb0000 ||
816 X             mem == 0xc8000 ||
817 X             mem == 0xd0000 ||
818 X             mem == 0xd8000 ||
819 X             mem == 0xe0000 ||
820 X             mem == 0xe8000)) {
821 X               fprintf(stderr, "error: mem must be one of "
822 X                       "0xb0000, 0xc8000, 0xd0000, 0xd8000, 0xe0000 or 0xe8000\n");
823 X               usage();
824 X       }
825 X
826 X       return msnd_write_cfg_logical(config_port, 0, io, 0, irq, mem);
827 }
828 X
829 static int cfg_mpu(int argc, char *argv[])
830 {
831 X       int io, irq;
832 X
833 X       if (argc < 2 ||
834 X           sscanf(argv[0], "0x%x", &io) != 1 ||
835 X           sscanf(argv[1], "%d", &irq) != 1)
836 X               usage();
837 X       
838 X       return msnd_write_cfg_logical(config_port, 1, io, 0, irq, 0);
839 }
840 X
841 static int cfg_ide(int argc, char *argv[])
842 {
843 X       int io0, io1, irq;
844 X
845 X       if (argc < 3 ||
846 X           sscanf(argv[0], "0x%x", &io0) != 1 ||
847 X           sscanf(argv[0], "0x%x", &io1) != 1 ||
848 X           sscanf(argv[1], "%d", &irq) != 1)
849 X               usage();
850 X       
851 X       return msnd_write_cfg_logical(config_port, 2, io0, io1, irq, 0);
852 }
853 X
854 static int cfg_joystick(int argc, char *argv[])
855 {
856 X       int io;
857 X
858 X       if (argc < 1 ||
859 X           sscanf(argv[0], "0x%x", &io) != 1)
860 X               usage();
861 X       
862 X       return msnd_write_cfg_logical(config_port, 3, io, 0, 0, 0);
863 }
864 X
865 int main(int argc, char *argv[])
866 {
867 X       char *device;
868 X       int rv = 0;
869 X
870 X       --argc; ++argv;
871 X
872 X       if (argc < 2)
873 X               usage();
874 X
875 X       sscanf(argv[0], "0x%x", &config_port);
876 X       if (config_port != 0x250 && config_port != 0x260 && config_port != 0x270) {
877 X               fprintf(stderr, "error: <config port> must be 0x250, 0x260 or 0x270\n");
878 X               exit(1);
879 X       }
880 X       if (ioperm(config_port, 2, 1)) {
881 X               perror("ioperm");
882 X               fprintf(stderr, "note: pinnaclecfg must be run as root\n");
883 X               exit(1);
884 X       }
885 X       device = argv[1];
886 X
887 X       argc -= 2; argv += 2;
888 X
889 X       if (strcmp(device, "reset") == 0)
890 X               rv = cfg_reset();
891 X       else if (strcmp(device, "show") == 0)
892 X               rv = cfg_show();
893 X       else if (strcmp(device, "dsp") == 0)
894 X               rv = cfg_dsp(argc, argv);
895 X       else if (strcmp(device, "mpu") == 0)
896 X               rv = cfg_mpu(argc, argv);
897 X       else if (strcmp(device, "ide") == 0)
898 X               rv = cfg_ide(argc, argv);
899 X       else if (strcmp(device, "joystick") == 0)
900 X               rv = cfg_joystick(argc, argv);
901 X       else {
902 X               fprintf(stderr, "error: unknown device %s\n", device);
903 X               usage();
904 X       }
905 X
906 X       if (rv)
907 X               fprintf(stderr, "error: device configuration failed\n");
908 X       
909 X       return 0;
910 }
911 SHAR_EOF
912   $shar_touch -am 1204092598 'MultiSound.d/pinnaclecfg.c' &&
913   chmod 0664 'MultiSound.d/pinnaclecfg.c' ||
914   $echo 'restore of' 'MultiSound.d/pinnaclecfg.c' 'failed'
915   if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
916   && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
917     md5sum -c << SHAR_EOF >/dev/null 2>&1 \
918     || $echo 'MultiSound.d/pinnaclecfg.c:' 'MD5 check failed'
919 366bdf27f0db767a3c7921d0a6db20fe  MultiSound.d/pinnaclecfg.c
920 SHAR_EOF
921   else
922     shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/pinnaclecfg.c'`"
923     test 10235 -eq "$shar_count" ||
924     $echo 'MultiSound.d/pinnaclecfg.c:' 'original size' '10235,' 'current size' "$shar_count!"
925   fi
926 fi
927 # ============= MultiSound.d/Makefile ==============
928 if test -f 'MultiSound.d/Makefile' && test "$first_param" != -c; then
929   $echo 'x -' SKIPPING 'MultiSound.d/Makefile' '(file already exists)'
930 else
931   $echo 'x -' extracting 'MultiSound.d/Makefile' '(text)'
932   sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/Makefile' &&
933 CC      = gcc
934 CFLAGS  = -O
935 PROGS   = setdigital msndreset pinnaclecfg conv
936 X
937 all: $(PROGS)
938 X
939 clean:
940 X       rm -f $(PROGS)
941 SHAR_EOF
942   $shar_touch -am 1204092398 'MultiSound.d/Makefile' &&
943   chmod 0664 'MultiSound.d/Makefile' ||
944   $echo 'restore of' 'MultiSound.d/Makefile' 'failed'
945   if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
946   && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
947     md5sum -c << SHAR_EOF >/dev/null 2>&1 \
948     || $echo 'MultiSound.d/Makefile:' 'MD5 check failed'
949 76ca8bb44e3882edcf79c97df6c81845  MultiSound.d/Makefile
950 SHAR_EOF
951   else
952     shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/Makefile'`"
953     test 106 -eq "$shar_count" ||
954     $echo 'MultiSound.d/Makefile:' 'original size' '106,' 'current size' "$shar_count!"
955   fi
956 fi
957 # ============= MultiSound.d/conv.l ==============
958 if test -f 'MultiSound.d/conv.l' && test "$first_param" != -c; then
959   $echo 'x -' SKIPPING 'MultiSound.d/conv.l' '(file already exists)'
960 else
961   $echo 'x -' extracting 'MultiSound.d/conv.l' '(text)'
962   sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/conv.l' &&
963 %%
964 [ \n\t,\r]
965 \;.*
966 DB
967 [0-9A-Fa-f]+H   { int n; sscanf(yytext, "%xH", &n); printf("%c", n); }
968 %%
969 int yywrap() { return 1; }
970 main() { yylex(); }
971 SHAR_EOF
972   $shar_touch -am 0828231798 'MultiSound.d/conv.l' &&
973   chmod 0664 'MultiSound.d/conv.l' ||
974   $echo 'restore of' 'MultiSound.d/conv.l' 'failed'
975   if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
976   && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
977     md5sum -c << SHAR_EOF >/dev/null 2>&1 \
978     || $echo 'MultiSound.d/conv.l:' 'MD5 check failed'
979 d2411fc32cd71a00dcdc1f009e858dd2  MultiSound.d/conv.l
980 SHAR_EOF
981   else
982     shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/conv.l'`"
983     test 141 -eq "$shar_count" ||
984     $echo 'MultiSound.d/conv.l:' 'original size' '141,' 'current size' "$shar_count!"
985   fi
986 fi
987 # ============= MultiSound.d/msndreset.c ==============
988 if test -f 'MultiSound.d/msndreset.c' && test "$first_param" != -c; then
989   $echo 'x -' SKIPPING 'MultiSound.d/msndreset.c' '(file already exists)'
990 else
991   $echo 'x -' extracting 'MultiSound.d/msndreset.c' '(text)'
992   sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/msndreset.c' &&
993 /*********************************************************************
994 X *
995 X * msndreset.c - resets the MultiSound card
996 X *
997 X * Copyright (C) 1998 Andrew Veliath
998 X *
999 X * This program is free software; you can redistribute it and/or modify
1000 X * it under the terms of the GNU General Public License as published by
1001 X * the Free Software Foundation; either version 2 of the License, or
1002 X * (at your option) any later version.
1003 X *
1004 X * This program is distributed in the hope that it will be useful,
1005 X * but WITHOUT ANY WARRANTY; without even the implied warranty of
1006 X * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1007 X * GNU General Public License for more details.
1008 X *
1009 X * You should have received a copy of the GNU General Public License
1010 X * along with this program; if not, write to the Free Software
1011 X * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1012 X *
1013 X ********************************************************************/
1014 X
1015 #include <stdio.h>
1016 #include <unistd.h>
1017 #include <fcntl.h>
1018 #include <sys/types.h>
1019 #include <sys/stat.h>
1020 #include <sys/ioctl.h>
1021 #include <sys/soundcard.h>
1022 X
1023 int main(int argc, char *argv[])
1024 {
1025 X       int fd;
1026 X
1027 X       if (argc != 2) {
1028 X               fprintf(stderr, "usage: msndreset <mixer device>\n");
1029 X               exit(1);
1030 X       }
1031 X
1032 X       if ((fd = open(argv[1], O_RDWR)) < 0) {
1033 X               perror(argv[1]);
1034 X               exit(1);
1035 X       }
1036 X
1037 X       if (ioctl(fd, SOUND_MIXER_PRIVATE1, 0) < 0) {
1038 X               fprintf(stderr, "error: msnd ioctl reset failed\n");
1039 X               perror("ioctl");
1040 X               close(fd);
1041 X               exit(1);
1042 X       }
1043 X
1044 X       close(fd);
1045 X       
1046 X       return 0;
1047 }
1048 SHAR_EOF
1049   $shar_touch -am 1204100698 'MultiSound.d/msndreset.c' &&
1050   chmod 0664 'MultiSound.d/msndreset.c' ||
1051   $echo 'restore of' 'MultiSound.d/msndreset.c' 'failed'
1052   if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
1053   && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
1054     md5sum -c << SHAR_EOF >/dev/null 2>&1 \
1055     || $echo 'MultiSound.d/msndreset.c:' 'MD5 check failed'
1056 c52f876521084e8eb25e12e01dcccb8a  MultiSound.d/msndreset.c
1057 SHAR_EOF
1058   else
1059     shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/msndreset.c'`"
1060     test 1472 -eq "$shar_count" ||
1061     $echo 'MultiSound.d/msndreset.c:' 'original size' '1472,' 'current size' "$shar_count!"
1062   fi
1063 fi
1064 rm -fr _sh01426
1065 exit 0