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