162306a36Sopenharmony_ci#! /bin/sh
262306a36Sopenharmony_ci#
362306a36Sopenharmony_ci#  Turtle Beach MultiSound Driver Notes
462306a36Sopenharmony_ci#  -- Andrew Veliath <andrewtv@usa.net>
562306a36Sopenharmony_ci#
662306a36Sopenharmony_ci#  Last update:                      September 10, 1998
762306a36Sopenharmony_ci#  Corresponding msnd driver:        0.8.3
862306a36Sopenharmony_ci#
962306a36Sopenharmony_ci# ** This file is a README (top part) and shell archive (bottom part).
1062306a36Sopenharmony_ci#    The corresponding archived utility sources can be unpacked by
1162306a36Sopenharmony_ci#    running `sh MultiSound' (the utilities are only needed for the
1262306a36Sopenharmony_ci#    Pinnacle and Fiji cards). **
1362306a36Sopenharmony_ci#
1462306a36Sopenharmony_ci#
1562306a36Sopenharmony_ci#  -=-=- Getting Firmware -=-=-
1662306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1762306a36Sopenharmony_ci#
1862306a36Sopenharmony_ci#  See the section `Obtaining and Creating Firmware Files' in this
1962306a36Sopenharmony_ci#  document for instructions on obtaining the necessary firmware
2062306a36Sopenharmony_ci#  files.
2162306a36Sopenharmony_ci#
2262306a36Sopenharmony_ci#
2362306a36Sopenharmony_ci#  Supported Features
2462306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~
2562306a36Sopenharmony_ci#
2662306a36Sopenharmony_ci#  Currently, full-duplex digital audio (/dev/dsp only, /dev/audio is
2762306a36Sopenharmony_ci#  not currently available) and mixer functionality (/dev/mixer) are
2862306a36Sopenharmony_ci#  supported (memory mapped digital audio is not yet supported).
2962306a36Sopenharmony_ci#  Digital transfers and monitoring can be done as well if you have
3062306a36Sopenharmony_ci#  the digital daughterboard (see the section on using the S/PDIF port
3162306a36Sopenharmony_ci#  for more information).
3262306a36Sopenharmony_ci#
3362306a36Sopenharmony_ci#  Support for the Turtle Beach MultiSound Hurricane architecture is
3462306a36Sopenharmony_ci#  composed of the following modules (these can also operate compiled
3562306a36Sopenharmony_ci#  into the kernel):
3662306a36Sopenharmony_ci#
3762306a36Sopenharmony_ci#  snd-msnd-lib           - MultiSound base (requires snd)
3862306a36Sopenharmony_ci#
3962306a36Sopenharmony_ci#  snd-msnd-classic       - Base audio/mixer support for Classic, Monetery and
4062306a36Sopenharmony_ci#                           Tahiti cards
4162306a36Sopenharmony_ci#
4262306a36Sopenharmony_ci#  snd-msnd-pinnacle      - Base audio/mixer support for Pinnacle and Fiji cards
4362306a36Sopenharmony_ci#
4462306a36Sopenharmony_ci#
4562306a36Sopenharmony_ci#  Important Notes - Read Before Using
4662306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4762306a36Sopenharmony_ci#
4862306a36Sopenharmony_ci#  The firmware files are not included (may change in future).  You
4962306a36Sopenharmony_ci#  must obtain these images from Turtle Beach (they are included in
5062306a36Sopenharmony_ci#  the MultiSound Development Kits), and place them in /etc/sound for
5162306a36Sopenharmony_ci#  example, and give the full paths in the Linux configuration.  If
5262306a36Sopenharmony_ci#  you are compiling in support for the MultiSound driver rather than
5362306a36Sopenharmony_ci#  using it as a module, these firmware files must be accessible
5462306a36Sopenharmony_ci#  during kernel compilation.
5562306a36Sopenharmony_ci#
5662306a36Sopenharmony_ci#  Please note these files must be binary files, not assembler.  See
5762306a36Sopenharmony_ci#  the section later in this document for instructions to obtain these
5862306a36Sopenharmony_ci#  files.
5962306a36Sopenharmony_ci#
6062306a36Sopenharmony_ci#
6162306a36Sopenharmony_ci#  Configuring Card Resources
6262306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~
6362306a36Sopenharmony_ci#
6462306a36Sopenharmony_ci#  ** This section is very important, as your card may not work at all
6562306a36Sopenharmony_ci#     or your machine may crash if you do not do this correctly. **
6662306a36Sopenharmony_ci#
6762306a36Sopenharmony_ci#  * Classic/Monterey/Tahiti
6862306a36Sopenharmony_ci#
6962306a36Sopenharmony_ci#  These cards are configured through the driver snd-msnd-classic.  You must
7062306a36Sopenharmony_ci#  know the io port, then the driver will select the irq and memory resources
7162306a36Sopenharmony_ci#  on the card.  It is up to you to know if these are free locations or now,
7262306a36Sopenharmony_ci#  a conflict can lock the machine up.
7362306a36Sopenharmony_ci#
7462306a36Sopenharmony_ci#  * Pinnacle/Fiji
7562306a36Sopenharmony_ci#
7662306a36Sopenharmony_ci#  The Pinnacle and Fiji cards have an extra config port, either
7762306a36Sopenharmony_ci#  0x250, 0x260 or 0x270.  This port can be disabled to have the card
7862306a36Sopenharmony_ci#  configured strictly through PnP, however you lose the ability to
7962306a36Sopenharmony_ci#  access the IDE controller and joystick devices on this card when
8062306a36Sopenharmony_ci#  using PnP.  The included pinnaclecfg program in this shell archive
8162306a36Sopenharmony_ci#  can be used to configure the card in non-PnP mode, and in PnP mode
8262306a36Sopenharmony_ci#  you can use isapnptools.  These are described briefly here.
8362306a36Sopenharmony_ci#
8462306a36Sopenharmony_ci#  pinnaclecfg is not required; you can use the snd-msnd-pinnacle module
8562306a36Sopenharmony_ci#  to fully configure the card as well.  However, pinnaclecfg can be
8662306a36Sopenharmony_ci#  used to change the resource values of a particular device after the
8762306a36Sopenharmony_ci#  snd-msnd-pinnacle module has been loaded.  If you are compiling the
8862306a36Sopenharmony_ci#  driver into the kernel, you must set these values during compile
8962306a36Sopenharmony_ci#  time, however other peripheral resource values can be changed with
9062306a36Sopenharmony_ci#  the pinnaclecfg program after the kernel is loaded.
9162306a36Sopenharmony_ci#
9262306a36Sopenharmony_ci#
9362306a36Sopenharmony_ci#  *** PnP mode
9462306a36Sopenharmony_ci#
9562306a36Sopenharmony_ci#  Use pnpdump to obtain a sample configuration if you can; I was able
9662306a36Sopenharmony_ci#  to obtain one with the command `pnpdump 1 0x203' -- this may vary
9762306a36Sopenharmony_ci#  for you (running pnpdump by itself did not work for me).  Then,
9862306a36Sopenharmony_ci#  edit this file and use isapnp to uncomment and set the card values.
9962306a36Sopenharmony_ci#  Use these values when inserting the snd-msnd-pinnacle module.  Using
10062306a36Sopenharmony_ci#  this method, you can set the resources for the DSP and the Kurzweil
10162306a36Sopenharmony_ci#  synth (Pinnacle).  Since Linux does not directly support PnP
10262306a36Sopenharmony_ci#  devices, you may have difficulty when using the card in PnP mode
10362306a36Sopenharmony_ci#  when it the driver is compiled into the kernel.  Using non-PnP mode
10462306a36Sopenharmony_ci#  is preferable in this case.
10562306a36Sopenharmony_ci#
10662306a36Sopenharmony_ci#  Here is an example mypinnacle.conf for isapnp that sets the card to
10762306a36Sopenharmony_ci#  io base 0x210, irq 5 and mem 0xd8000, and also sets the Kurzweil
10862306a36Sopenharmony_ci#  synth to 0x330 and irq 9 (may need editing for your system):
10962306a36Sopenharmony_ci#
11062306a36Sopenharmony_ci#  (READPORT 0x0203)
11162306a36Sopenharmony_ci#  (CSN 2)
11262306a36Sopenharmony_ci#  (IDENTIFY *)
11362306a36Sopenharmony_ci#
11462306a36Sopenharmony_ci#  # DSP
11562306a36Sopenharmony_ci#  (CONFIGURE BVJ0440/-1 (LD 0
11662306a36Sopenharmony_ci#          (INT 0 (IRQ 5 (MODE +E))) (IO 0 (BASE 0x0210)) (MEM 0 (BASE 0x0d8000))
11762306a36Sopenharmony_ci#          (ACT Y)))
11862306a36Sopenharmony_ci#
11962306a36Sopenharmony_ci#  # Kurzweil Synth (Pinnacle Only)
12062306a36Sopenharmony_ci#  (CONFIGURE BVJ0440/-1 (LD 1
12162306a36Sopenharmony_ci#          (IO 0 (BASE 0x0330)) (INT 0 (IRQ 9 (MODE +E)))
12262306a36Sopenharmony_ci#          (ACT Y)))
12362306a36Sopenharmony_ci#
12462306a36Sopenharmony_ci#  (WAITFORKEY)
12562306a36Sopenharmony_ci#
12662306a36Sopenharmony_ci#
12762306a36Sopenharmony_ci#  *** Non-PnP mode
12862306a36Sopenharmony_ci#
12962306a36Sopenharmony_ci#  The second way is by running the card in non-PnP mode.  This
13062306a36Sopenharmony_ci#  actually has some advantages in that you can access some other
13162306a36Sopenharmony_ci#  devices on the card, such as the joystick and IDE controller.  To
13262306a36Sopenharmony_ci#  configure the card, unpack this shell archive and build the
13362306a36Sopenharmony_ci#  pinnaclecfg program.  Using this program, you can assign the
13462306a36Sopenharmony_ci#  resource values to the card's devices, or disable the devices.  As
13562306a36Sopenharmony_ci#  an alternative to using pinnaclecfg, you can specify many of the
13662306a36Sopenharmony_ci#  configuration values when loading the snd-msnd-pinnacle module (or
13762306a36Sopenharmony_ci#  during kernel configuration when compiling the driver into the
13862306a36Sopenharmony_ci#  kernel).
13962306a36Sopenharmony_ci#
14062306a36Sopenharmony_ci#  If you specify cfg=0x250 for the snd-msnd-pinnacle module, it
14162306a36Sopenharmony_ci#  automatically configure the card to the given io, irq and memory
14262306a36Sopenharmony_ci#  values using that config port (the config port is jumper selectable
14362306a36Sopenharmony_ci#  on the card to 0x250, 0x260 or 0x270).
14462306a36Sopenharmony_ci#
14562306a36Sopenharmony_ci#  See the `snd-msnd-pinnacle Additional Options' section below for more
14662306a36Sopenharmony_ci#  information on these parameters (also, if you compile the driver
14762306a36Sopenharmony_ci#  directly into the kernel, these extra parameters can be useful
14862306a36Sopenharmony_ci#  here).
14962306a36Sopenharmony_ci#
15062306a36Sopenharmony_ci#
15162306a36Sopenharmony_ci# ** It is very easy to cause problems in your machine if you choose a
15262306a36Sopenharmony_ci#    resource value which is incorrect. **
15362306a36Sopenharmony_ci#
15462306a36Sopenharmony_ci#
15562306a36Sopenharmony_ci#  Examples
15662306a36Sopenharmony_ci#  ~~~~~~~~
15762306a36Sopenharmony_ci#
15862306a36Sopenharmony_ci#  * MultiSound Classic/Monterey/Tahiti:
15962306a36Sopenharmony_ci#
16062306a36Sopenharmony_ci#  modprobe snd
16162306a36Sopenharmony_ci#  insmod snd-msnd-lib
16262306a36Sopenharmony_ci#  insmod snd-msnd-classic io=0x290 irq=7 mem=0xd0000
16362306a36Sopenharmony_ci#
16462306a36Sopenharmony_ci#  * MultiSound Pinnacle in PnP mode:
16562306a36Sopenharmony_ci#
16662306a36Sopenharmony_ci#  modprobe snd
16762306a36Sopenharmony_ci#  insmod snd-msnd-lib
16862306a36Sopenharmony_ci#  isapnp mypinnacle.conf
16962306a36Sopenharmony_ci#  insmod snd-msnd-pinnacle io=0x210 irq=5 mem=0xd8000 <-- match mypinnacle.conf values
17062306a36Sopenharmony_ci#
17162306a36Sopenharmony_ci#  * MultiSound Pinnacle in non-PnP mode (replace 0x250 with your configuration port,
17262306a36Sopenharmony_ci#    one of 0x250, 0x260 or 0x270):
17362306a36Sopenharmony_ci#
17462306a36Sopenharmony_ci#  modprobe snd
17562306a36Sopenharmony_ci#  insmod snd-msnd-lib
17662306a36Sopenharmony_ci#  insmod snd-msnd-pinnacle cfg=0x250 io=0x290 irq=5 mem=0xd0000
17762306a36Sopenharmony_ci#
17862306a36Sopenharmony_ci# * To use the MPU-compatible Kurzweil synth on the Pinnacle in PnP
17962306a36Sopenharmony_ci#   mode, add the following (assumes you did `isapnp mypinnacle.conf'):
18062306a36Sopenharmony_ci#
18162306a36Sopenharmony_ci#  insmod snd
18262306a36Sopenharmony_ci#  insmod mpu401 io=0x330 irq=9                    <-- match mypinnacle.conf values
18362306a36Sopenharmony_ci#
18462306a36Sopenharmony_ci# * To use the MPU-compatible Kurzweil synth on the Pinnacle in non-PnP
18562306a36Sopenharmony_ci#   mode, add the following.  Note how we first configure the peripheral's
18662306a36Sopenharmony_ci#   resources, _then_ install a Linux driver for it:
18762306a36Sopenharmony_ci#
18862306a36Sopenharmony_ci#  insmod snd
18962306a36Sopenharmony_ci#  pinnaclecfg 0x250 mpu 0x330 9
19062306a36Sopenharmony_ci#  insmod mpu401 io=0x330 irq=9
19162306a36Sopenharmony_ci#
19262306a36Sopenharmony_ci#  -- OR you can use the following sequence without pinnaclecfg in non-PnP mode:
19362306a36Sopenharmony_ci#
19462306a36Sopenharmony_ci#  modprobe snd
19562306a36Sopenharmony_ci#  insmod snd-msnd-lib
19662306a36Sopenharmony_ci#  insmod snd-msnd-pinnacle cfg=0x250 io=0x290 irq=5 mem=0xd0000 mpu_io=0x330 mpu_irq=9
19762306a36Sopenharmony_ci#  insmod snd
19862306a36Sopenharmony_ci#  insmod mpu401 io=0x330 irq=9
19962306a36Sopenharmony_ci#
20062306a36Sopenharmony_ci# * To setup the joystick port on the Pinnacle in non-PnP mode (though
20162306a36Sopenharmony_ci#   you have to find the actual Linux joystick driver elsewhere), you
20262306a36Sopenharmony_ci#   can use pinnaclecfg:
20362306a36Sopenharmony_ci#
20462306a36Sopenharmony_ci#   pinnaclecfg 0x250 joystick 0x200
20562306a36Sopenharmony_ci#
20662306a36Sopenharmony_ci#  -- OR you can configure this using snd-msnd-pinnacle with the following:
20762306a36Sopenharmony_ci#
20862306a36Sopenharmony_ci#  modprobe snd
20962306a36Sopenharmony_ci#  insmod snd-msnd-lib
21062306a36Sopenharmony_ci#  insmod snd-msnd-pinnacle cfg=0x250 io=0x290 irq=5 mem=0xd0000 joystick_io=0x200
21162306a36Sopenharmony_ci#
21262306a36Sopenharmony_ci#
21362306a36Sopenharmony_ci#  snd-msnd-classic, snd-msnd-pinnacle Required Options
21462306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21562306a36Sopenharmony_ci#
21662306a36Sopenharmony_ci#  If the following options are not given, the module will not load.
21762306a36Sopenharmony_ci#  Examine the kernel message log for informative error messages.
21862306a36Sopenharmony_ci#  WARNING--probing isn't supported so try to make sure you have the
21962306a36Sopenharmony_ci#  correct shared memory area, otherwise you may experience problems.
22062306a36Sopenharmony_ci#
22162306a36Sopenharmony_ci#  io                   I/O base of DSP, e.g. io=0x210
22262306a36Sopenharmony_ci#  irq                  IRQ number, e.g. irq=5
22362306a36Sopenharmony_ci#  mem                  Shared memory area, e.g. mem=0xd8000
22462306a36Sopenharmony_ci#
22562306a36Sopenharmony_ci#
22662306a36Sopenharmony_ci#  snd-msnd-classic, snd-msnd-pinnacle Additional Options
22762306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22862306a36Sopenharmony_ci#
22962306a36Sopenharmony_ci#  fifosize             The digital audio FIFOs, in kilobytes.  If not
23062306a36Sopenharmony_ci#                       specified, the default will be used.  Increasing
23162306a36Sopenharmony_ci#                       this value will reduce the chance of a FIFO
23262306a36Sopenharmony_ci#                       underflow at the expense of increasing overall
23362306a36Sopenharmony_ci#                       latency.  For example, fifosize=512 will
23462306a36Sopenharmony_ci#                       allocate 512kB read and write FIFOs (1MB total).
23562306a36Sopenharmony_ci#                       While this may reduce dropouts, a heavy machine
23662306a36Sopenharmony_ci#                       load will undoubtedly starve the FIFO of data
23762306a36Sopenharmony_ci#                       and you will eventually get dropouts.  One
23862306a36Sopenharmony_ci#                       option is to alter the scheduling priority of
23962306a36Sopenharmony_ci#                       the playback process, using `nice' or some form
24062306a36Sopenharmony_ci#                       of POSIX soft real-time scheduling.
24162306a36Sopenharmony_ci#
24262306a36Sopenharmony_ci#  calibrate_signal     Setting this to one calibrates the ADCs to the
24362306a36Sopenharmony_ci#                       signal, zero calibrates to the card (defaults
24462306a36Sopenharmony_ci#                       to zero).
24562306a36Sopenharmony_ci#
24662306a36Sopenharmony_ci#
24762306a36Sopenharmony_ci#  snd-msnd-pinnacle Additional Options
24862306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24962306a36Sopenharmony_ci#
25062306a36Sopenharmony_ci#  digital              Specify digital=1 to enable the S/PDIF input
25162306a36Sopenharmony_ci#                       if you have the digital daughterboard
25262306a36Sopenharmony_ci#                       adapter. This will enable access to the
25362306a36Sopenharmony_ci#                       DIGITAL1 input for the soundcard in the mixer.
25462306a36Sopenharmony_ci#                       Some mixer programs might have trouble setting
25562306a36Sopenharmony_ci#                       the DIGITAL1 source as an input.  If you have
25662306a36Sopenharmony_ci#                       trouble, you can try the setdigital.c program
25762306a36Sopenharmony_ci#                       at the bottom of this document.
25862306a36Sopenharmony_ci#
25962306a36Sopenharmony_ci#  cfg                  Non-PnP configuration port for the Pinnacle
26062306a36Sopenharmony_ci#                       and Fiji (typically 0x250, 0x260 or 0x270,
26162306a36Sopenharmony_ci#                       depending on the jumper configuration).  If
26262306a36Sopenharmony_ci#                       this option is omitted, then it is assumed
26362306a36Sopenharmony_ci#                       that the card is in PnP mode, and that the
26462306a36Sopenharmony_ci#                       specified DSP resource values are already
26562306a36Sopenharmony_ci#                       configured with PnP (i.e. it won't attempt to
26662306a36Sopenharmony_ci#                       do any sort of configuration).
26762306a36Sopenharmony_ci#
26862306a36Sopenharmony_ci#  When the Pinnacle is in non-PnP mode, you can use the following
26962306a36Sopenharmony_ci#  options to configure particular devices.  If a full specification
27062306a36Sopenharmony_ci#  for a device is not given, then the device is not configured.  Note
27162306a36Sopenharmony_ci#  that you still must use a Linux driver for any of these devices
27262306a36Sopenharmony_ci#  once their resources are setup (such as the Linux joystick driver,
27362306a36Sopenharmony_ci#  or the MPU401 driver from OSS for the Kurzweil synth).
27462306a36Sopenharmony_ci#
27562306a36Sopenharmony_ci#  mpu_io               I/O port of MPU (on-board Kurzweil synth)
27662306a36Sopenharmony_ci#  mpu_irq              IRQ of MPU (on-board Kurzweil synth)
27762306a36Sopenharmony_ci#  ide_io0		First I/O port of IDE controller
27862306a36Sopenharmony_ci#  ide_io1		Second I/O port of IDE controller
27962306a36Sopenharmony_ci#  ide_irq		IRQ IDE controller
28062306a36Sopenharmony_ci#  joystick_io          I/O port of joystick
28162306a36Sopenharmony_ci#
28262306a36Sopenharmony_ci#
28362306a36Sopenharmony_ci#  Obtaining and Creating Firmware Files
28462306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28562306a36Sopenharmony_ci#
28662306a36Sopenharmony_ci#       For the Classic/Tahiti/Monterey
28762306a36Sopenharmony_ci#       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28862306a36Sopenharmony_ci#
28962306a36Sopenharmony_ci#  Download to /tmp and unzip the following file from Turtle Beach:
29062306a36Sopenharmony_ci#
29162306a36Sopenharmony_ci#       ftp://ftp.voyetra.com/pub/tbs/msndcl/msndvkit.zip
29262306a36Sopenharmony_ci#
29362306a36Sopenharmony_ci#  When unzipped, unzip the file named MsndFiles.zip.  Then copy the
29462306a36Sopenharmony_ci#  following firmware files to /etc/sound (note the file renaming):
29562306a36Sopenharmony_ci#
29662306a36Sopenharmony_ci#    cp DSPCODE/MSNDINIT.BIN /etc/sound/msndinit.bin
29762306a36Sopenharmony_ci#    cp DSPCODE/MSNDPERM.REB /etc/sound/msndperm.bin
29862306a36Sopenharmony_ci#
29962306a36Sopenharmony_ci#  When configuring the Linux kernel, specify /etc/sound/msndinit.bin and
30062306a36Sopenharmony_ci#  /etc/sound/msndperm.bin for the two firmware files (Linux kernel
30162306a36Sopenharmony_ci#  versions older than 2.2 do not ask for firmware paths, and are
30262306a36Sopenharmony_ci#  hardcoded to /etc/sound).
30362306a36Sopenharmony_ci#
30462306a36Sopenharmony_ci#  If you are compiling the driver into the kernel, these files must
30562306a36Sopenharmony_ci#  be accessible during compilation, but will not be needed later.
30662306a36Sopenharmony_ci#  The files must remain, however, if the driver is used as a module.
30762306a36Sopenharmony_ci#
30862306a36Sopenharmony_ci#
30962306a36Sopenharmony_ci#       For the Pinnacle/Fiji
31062306a36Sopenharmony_ci#       ~~~~~~~~~~~~~~~~~~~~~
31162306a36Sopenharmony_ci#
31262306a36Sopenharmony_ci#  Download to /tmp and unzip the following file from Turtle Beach (be
31362306a36Sopenharmony_ci#  sure to use the entire URL; some have had trouble navigating to the
31462306a36Sopenharmony_ci#  URL):
31562306a36Sopenharmony_ci#
31662306a36Sopenharmony_ci#       ftp://ftp.voyetra.com/pub/tbs/pinn/pnddk100.zip
31762306a36Sopenharmony_ci#
31862306a36Sopenharmony_ci#  Unpack this shell archive, and run make in the created directory
31962306a36Sopenharmony_ci#  (you need a C compiler and flex to build the utilities).  This
32062306a36Sopenharmony_ci#  should give you the executables conv, pinnaclecfg and setdigital.
32162306a36Sopenharmony_ci#  conv is only used temporarily here to create the firmware files,
32262306a36Sopenharmony_ci#  while pinnaclecfg is used to configure the Pinnacle or Fiji card in
32362306a36Sopenharmony_ci#  non-PnP mode, and setdigital can be used to set the S/PDIF input on
32462306a36Sopenharmony_ci#  the mixer (pinnaclecfg and setdigital should be copied to a
32562306a36Sopenharmony_ci#  convenient place, possibly run during system initialization).
32662306a36Sopenharmony_ci#
32762306a36Sopenharmony_ci#  To generating the firmware files with the `conv' program, we create
32862306a36Sopenharmony_ci#  the binary firmware files by doing the following conversion
32962306a36Sopenharmony_ci#  (assuming the archive unpacked into a directory named PINNDDK):
33062306a36Sopenharmony_ci#
33162306a36Sopenharmony_ci#    ./conv < PINNDDK/dspcode/pndspini.asm > /etc/sound/pndspini.bin
33262306a36Sopenharmony_ci#    ./conv < PINNDDK/dspcode/pndsperm.asm > /etc/sound/pndsperm.bin
33362306a36Sopenharmony_ci#
33462306a36Sopenharmony_ci#  The conv (and conv.l) program is not needed after conversion and can
33562306a36Sopenharmony_ci#  be safely deleted.  Then, when configuring the Linux kernel, specify
33662306a36Sopenharmony_ci#  /etc/sound/pndspini.bin and /etc/sound/pndsperm.bin for the two
33762306a36Sopenharmony_ci#  firmware files (Linux kernel versions older than 2.2 do not ask for
33862306a36Sopenharmony_ci#  firmware paths, and are hardcoded to /etc/sound).
33962306a36Sopenharmony_ci#
34062306a36Sopenharmony_ci#  If you are compiling the driver into the kernel, these files must
34162306a36Sopenharmony_ci#  be accessible during compilation, but will not be needed later.
34262306a36Sopenharmony_ci#  The files must remain, however, if the driver is used as a module.
34362306a36Sopenharmony_ci#
34462306a36Sopenharmony_ci#
34562306a36Sopenharmony_ci#  Using Digital I/O with the S/PDIF Port
34662306a36Sopenharmony_ci#  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34762306a36Sopenharmony_ci#
34862306a36Sopenharmony_ci#  If you have a Pinnacle or Fiji with the digital daughterboard and
34962306a36Sopenharmony_ci#  want to set it as the input source, you can use this program if you
35062306a36Sopenharmony_ci#  have trouble trying to do it with a mixer program (be sure to
35162306a36Sopenharmony_ci#  insert the module with the digital=1 option, or say Y to the option
35262306a36Sopenharmony_ci#  during compiled-in kernel operation).  Upon selection of the S/PDIF
35362306a36Sopenharmony_ci#  port, you should be able monitor and record from it.
35462306a36Sopenharmony_ci#
35562306a36Sopenharmony_ci#  There is something to note about using the S/PDIF port.  Digital
35662306a36Sopenharmony_ci#  timing is taken from the digital signal, so if a signal is not
35762306a36Sopenharmony_ci#  connected to the port and it is selected as recording input, you
35862306a36Sopenharmony_ci#  will find PCM playback to be distorted in playback rate.  Also,
35962306a36Sopenharmony_ci#  attempting to record at a sampling rate other than the DAT rate may
36062306a36Sopenharmony_ci#  be problematic (i.e. trying to record at 8000Hz when the DAT signal
36162306a36Sopenharmony_ci#  is 44100Hz).  If you have a problem with this, set the recording
36262306a36Sopenharmony_ci#  input to analog if you need to record at a rate other than that of
36362306a36Sopenharmony_ci#  the DAT rate.
36462306a36Sopenharmony_ci#
36562306a36Sopenharmony_ci#
36662306a36Sopenharmony_ci#  -- Shell archive attached below, just run `sh MultiSound' to extract.
36762306a36Sopenharmony_ci#     Contains Pinnacle/Fiji utilities to convert firmware, configure
36862306a36Sopenharmony_ci#     in non-PnP mode, and select the DIGITAL1 input for the mixer.
36962306a36Sopenharmony_ci#
37062306a36Sopenharmony_ci#
37162306a36Sopenharmony_ci#!/bin/sh
37262306a36Sopenharmony_ci# This is a shell archive (produced by GNU sharutils 4.2).
37362306a36Sopenharmony_ci# To extract the files from this archive, save it to some FILE, remove
37462306a36Sopenharmony_ci# everything before the `!/bin/sh' line above, then type `sh FILE'.
37562306a36Sopenharmony_ci#
37662306a36Sopenharmony_ci# Made on 1998-12-04 10:07 EST by <andrewtv@ztransform.velsoft.com>.
37762306a36Sopenharmony_ci# Source directory was `/home/andrewtv/programming/pinnacle/pinnacle'.
37862306a36Sopenharmony_ci#
37962306a36Sopenharmony_ci# Existing files will *not* be overwritten unless `-c' is specified.
38062306a36Sopenharmony_ci#
38162306a36Sopenharmony_ci# This shar contains:
38262306a36Sopenharmony_ci# length mode       name
38362306a36Sopenharmony_ci# ------ ---------- ------------------------------------------
38462306a36Sopenharmony_ci#   2064 -rw-rw-r-- MultiSound.d/setdigital.c
38562306a36Sopenharmony_ci#  10224 -rw-rw-r-- MultiSound.d/pinnaclecfg.c
38662306a36Sopenharmony_ci#    106 -rw-rw-r-- MultiSound.d/Makefile
38762306a36Sopenharmony_ci#    146 -rw-rw-r-- MultiSound.d/conv.l
38862306a36Sopenharmony_ci#   1491 -rw-rw-r-- MultiSound.d/msndreset.c
38962306a36Sopenharmony_ci#
39062306a36Sopenharmony_cisave_IFS="${IFS}"
39162306a36Sopenharmony_ciIFS="${IFS}:"
39262306a36Sopenharmony_cigettext_dir=FAILED
39362306a36Sopenharmony_cilocale_dir=FAILED
39462306a36Sopenharmony_cifirst_param="$1"
39562306a36Sopenharmony_cifor dir in $PATH
39662306a36Sopenharmony_cido
39762306a36Sopenharmony_ci  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
39862306a36Sopenharmony_ci     && ($dir/gettext --version >/dev/null 2>&1)
39962306a36Sopenharmony_ci  then
40062306a36Sopenharmony_ci    set `$dir/gettext --version 2>&1`
40162306a36Sopenharmony_ci    if test "$3" = GNU
40262306a36Sopenharmony_ci    then
40362306a36Sopenharmony_ci      gettext_dir=$dir
40462306a36Sopenharmony_ci    fi
40562306a36Sopenharmony_ci  fi
40662306a36Sopenharmony_ci  if test "$locale_dir" = FAILED && test -f $dir/shar \
40762306a36Sopenharmony_ci     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
40862306a36Sopenharmony_ci  then
40962306a36Sopenharmony_ci    locale_dir=`$dir/shar --print-text-domain-dir`
41062306a36Sopenharmony_ci  fi
41162306a36Sopenharmony_cidone
41262306a36Sopenharmony_ciIFS="$save_IFS"
41362306a36Sopenharmony_ciif test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
41462306a36Sopenharmony_cithen
41562306a36Sopenharmony_ci  echo=echo
41662306a36Sopenharmony_cielse
41762306a36Sopenharmony_ci  TEXTDOMAINDIR=$locale_dir
41862306a36Sopenharmony_ci  export TEXTDOMAINDIR
41962306a36Sopenharmony_ci  TEXTDOMAIN=sharutils
42062306a36Sopenharmony_ci  export TEXTDOMAIN
42162306a36Sopenharmony_ci  echo="$gettext_dir/gettext -s"
42262306a36Sopenharmony_cifi
42362306a36Sopenharmony_citouch -am 1231235999 $$.touch >/dev/null 2>&1
42462306a36Sopenharmony_ciif test ! -f 1231235999 && test -f $$.touch; then
42562306a36Sopenharmony_ci  shar_touch=touch
42662306a36Sopenharmony_cielse
42762306a36Sopenharmony_ci  shar_touch=:
42862306a36Sopenharmony_ci  echo
42962306a36Sopenharmony_ci  $echo 'WARNING: not restoring timestamps.  Consider getting and'
43062306a36Sopenharmony_ci  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
43162306a36Sopenharmony_ci  echo
43262306a36Sopenharmony_cifi
43362306a36Sopenharmony_cirm -f 1231235999 $$.touch
43462306a36Sopenharmony_ci#
43562306a36Sopenharmony_ciif mkdir _sh01426; then
43662306a36Sopenharmony_ci  $echo 'x -' 'creating lock directory'
43762306a36Sopenharmony_cielse
43862306a36Sopenharmony_ci  $echo 'failed to create lock directory'
43962306a36Sopenharmony_ci  exit 1
44062306a36Sopenharmony_cifi
44162306a36Sopenharmony_ci# ============= MultiSound.d/setdigital.c ==============
44262306a36Sopenharmony_ciif test ! -d 'MultiSound.d'; then
44362306a36Sopenharmony_ci  $echo 'x -' 'creating directory' 'MultiSound.d'
44462306a36Sopenharmony_ci  mkdir 'MultiSound.d'
44562306a36Sopenharmony_cifi
44662306a36Sopenharmony_ciif test -f 'MultiSound.d/setdigital.c' && test "$first_param" != -c; then
44762306a36Sopenharmony_ci  $echo 'x -' SKIPPING 'MultiSound.d/setdigital.c' '(file already exists)'
44862306a36Sopenharmony_cielse
44962306a36Sopenharmony_ci  $echo 'x -' extracting 'MultiSound.d/setdigital.c' '(text)'
45062306a36Sopenharmony_ci  sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/setdigital.c' &&
45162306a36Sopenharmony_ci/*********************************************************************
45262306a36Sopenharmony_ciX *
45362306a36Sopenharmony_ciX * setdigital.c - sets the DIGITAL1 input for a mixer
45462306a36Sopenharmony_ciX *
45562306a36Sopenharmony_ciX * Copyright (C) 1998 Andrew Veliath
45662306a36Sopenharmony_ciX *
45762306a36Sopenharmony_ciX * This program is free software; you can redistribute it and/or modify
45862306a36Sopenharmony_ciX * it under the terms of the GNU General Public License as published by
45962306a36Sopenharmony_ciX * the Free Software Foundation; either version 2 of the License, or
46062306a36Sopenharmony_ciX * (at your option) any later version.
46162306a36Sopenharmony_ciX *
46262306a36Sopenharmony_ciX * This program is distributed in the hope that it will be useful,
46362306a36Sopenharmony_ciX * but WITHOUT ANY WARRANTY; without even the implied warranty of
46462306a36Sopenharmony_ciX * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
46562306a36Sopenharmony_ciX * GNU General Public License for more details.
46662306a36Sopenharmony_ciX *
46762306a36Sopenharmony_ciX * You should have received a copy of the GNU General Public License
46862306a36Sopenharmony_ciX * along with this program; if not, write to the Free Software
46962306a36Sopenharmony_ciX * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
47062306a36Sopenharmony_ciX *
47162306a36Sopenharmony_ciX ********************************************************************/
47262306a36Sopenharmony_ciX
47362306a36Sopenharmony_ci#include <stdio.h>
47462306a36Sopenharmony_ci#include <stdlib.h>
47562306a36Sopenharmony_ci#include <unistd.h>
47662306a36Sopenharmony_ci#include <fcntl.h>
47762306a36Sopenharmony_ci#include <sys/types.h>
47862306a36Sopenharmony_ci#include <sys/stat.h>
47962306a36Sopenharmony_ci#include <sys/ioctl.h>
48062306a36Sopenharmony_ci#include <sys/soundcard.h>
48162306a36Sopenharmony_ciX
48262306a36Sopenharmony_ciint main(int argc, char *argv[])
48362306a36Sopenharmony_ci{
48462306a36Sopenharmony_ciX	int fd;
48562306a36Sopenharmony_ciX	unsigned long recmask, recsrc;
48662306a36Sopenharmony_ciX
48762306a36Sopenharmony_ciX	if (argc != 2) {
48862306a36Sopenharmony_ciX		fprintf(stderr, "usage: setdigital <mixer device>\n");
48962306a36Sopenharmony_ciX		exit(1);
49062306a36Sopenharmony_ciX	}
49162306a36Sopenharmony_ciX
49262306a36Sopenharmony_ciX	if ((fd = open(argv[1], O_RDWR)) < 0) {
49362306a36Sopenharmony_ciX		perror(argv[1]);
49462306a36Sopenharmony_ciX		exit(1);
49562306a36Sopenharmony_ciX	}
49662306a36Sopenharmony_ciX
49762306a36Sopenharmony_ciX	if (ioctl(fd, SOUND_MIXER_READ_RECMASK, &recmask) < 0) {
49862306a36Sopenharmony_ciX		fprintf(stderr, "error: ioctl read recording mask failed\n");
49962306a36Sopenharmony_ciX		perror("ioctl");
50062306a36Sopenharmony_ciX		close(fd);
50162306a36Sopenharmony_ciX		exit(1);
50262306a36Sopenharmony_ciX	}
50362306a36Sopenharmony_ciX
50462306a36Sopenharmony_ciX	if (!(recmask & SOUND_MASK_DIGITAL1)) {
50562306a36Sopenharmony_ciX		fprintf(stderr, "error: cannot find DIGITAL1 device in mixer\n");
50662306a36Sopenharmony_ciX		close(fd);
50762306a36Sopenharmony_ciX		exit(1);
50862306a36Sopenharmony_ciX	}
50962306a36Sopenharmony_ciX
51062306a36Sopenharmony_ciX	if (ioctl(fd, SOUND_MIXER_READ_RECSRC, &recsrc) < 0) {
51162306a36Sopenharmony_ciX		fprintf(stderr, "error: ioctl read recording source failed\n");
51262306a36Sopenharmony_ciX		perror("ioctl");
51362306a36Sopenharmony_ciX		close(fd);
51462306a36Sopenharmony_ciX		exit(1);
51562306a36Sopenharmony_ciX	}
51662306a36Sopenharmony_ciX
51762306a36Sopenharmony_ciX	recsrc |= SOUND_MASK_DIGITAL1;
51862306a36Sopenharmony_ciX
51962306a36Sopenharmony_ciX	if (ioctl(fd, SOUND_MIXER_WRITE_RECSRC, &recsrc) < 0) {
52062306a36Sopenharmony_ciX		fprintf(stderr, "error: ioctl write recording source failed\n");
52162306a36Sopenharmony_ciX		perror("ioctl");
52262306a36Sopenharmony_ciX		close(fd);
52362306a36Sopenharmony_ciX		exit(1);
52462306a36Sopenharmony_ciX	}
52562306a36Sopenharmony_ciX
52662306a36Sopenharmony_ciX	close(fd);
52762306a36Sopenharmony_ciX
52862306a36Sopenharmony_ciX	return 0;
52962306a36Sopenharmony_ci}
53062306a36Sopenharmony_ciSHAR_EOF
53162306a36Sopenharmony_ci  $shar_touch -am 1204092598 'MultiSound.d/setdigital.c' &&
53262306a36Sopenharmony_ci  chmod 0664 'MultiSound.d/setdigital.c' ||
53362306a36Sopenharmony_ci  $echo 'restore of' 'MultiSound.d/setdigital.c' 'failed'
53462306a36Sopenharmony_ci  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
53562306a36Sopenharmony_ci  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
53662306a36Sopenharmony_ci    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
53762306a36Sopenharmony_ci    || $echo 'MultiSound.d/setdigital.c:' 'MD5 check failed'
53862306a36Sopenharmony_cie87217fc3e71288102ba41fd81f71ec4  MultiSound.d/setdigital.c
53962306a36Sopenharmony_ciSHAR_EOF
54062306a36Sopenharmony_ci  else
54162306a36Sopenharmony_ci    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/setdigital.c'`"
54262306a36Sopenharmony_ci    test 2064 -eq "$shar_count" ||
54362306a36Sopenharmony_ci    $echo 'MultiSound.d/setdigital.c:' 'original size' '2064,' 'current size' "$shar_count!"
54462306a36Sopenharmony_ci  fi
54562306a36Sopenharmony_cifi
54662306a36Sopenharmony_ci# ============= MultiSound.d/pinnaclecfg.c ==============
54762306a36Sopenharmony_ciif test -f 'MultiSound.d/pinnaclecfg.c' && test "$first_param" != -c; then
54862306a36Sopenharmony_ci  $echo 'x -' SKIPPING 'MultiSound.d/pinnaclecfg.c' '(file already exists)'
54962306a36Sopenharmony_cielse
55062306a36Sopenharmony_ci  $echo 'x -' extracting 'MultiSound.d/pinnaclecfg.c' '(text)'
55162306a36Sopenharmony_ci  sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/pinnaclecfg.c' &&
55262306a36Sopenharmony_ci/*********************************************************************
55362306a36Sopenharmony_ciX *
55462306a36Sopenharmony_ciX * pinnaclecfg.c - Pinnacle/Fiji Device Configuration Program
55562306a36Sopenharmony_ciX *
55662306a36Sopenharmony_ciX * This is for NON-PnP mode only.  For PnP mode, use isapnptools.
55762306a36Sopenharmony_ciX *
55862306a36Sopenharmony_ciX * This is Linux-specific, and must be run with root permissions.
55962306a36Sopenharmony_ciX *
56062306a36Sopenharmony_ciX * Part of the Turtle Beach MultiSound Sound Card Driver for Linux
56162306a36Sopenharmony_ciX *
56262306a36Sopenharmony_ciX * Copyright (C) 1998 Andrew Veliath
56362306a36Sopenharmony_ciX *
56462306a36Sopenharmony_ciX * This program is free software; you can redistribute it and/or modify
56562306a36Sopenharmony_ciX * it under the terms of the GNU General Public License as published by
56662306a36Sopenharmony_ciX * the Free Software Foundation; either version 2 of the License, or
56762306a36Sopenharmony_ciX * (at your option) any later version.
56862306a36Sopenharmony_ciX *
56962306a36Sopenharmony_ciX * This program is distributed in the hope that it will be useful,
57062306a36Sopenharmony_ciX * but WITHOUT ANY WARRANTY; without even the implied warranty of
57162306a36Sopenharmony_ciX * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
57262306a36Sopenharmony_ciX * GNU General Public License for more details.
57362306a36Sopenharmony_ciX *
57462306a36Sopenharmony_ciX * You should have received a copy of the GNU General Public License
57562306a36Sopenharmony_ciX * along with this program; if not, write to the Free Software
57662306a36Sopenharmony_ciX * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
57762306a36Sopenharmony_ciX *
57862306a36Sopenharmony_ciX ********************************************************************/
57962306a36Sopenharmony_ciX
58062306a36Sopenharmony_ci#include <stdio.h>
58162306a36Sopenharmony_ci#include <stdlib.h>
58262306a36Sopenharmony_ci#include <string.h>
58362306a36Sopenharmony_ci#include <errno.h>
58462306a36Sopenharmony_ci#include <unistd.h>
58562306a36Sopenharmony_ci#include <asm/types.h>
58662306a36Sopenharmony_ci#include <sys/io.h>
58762306a36Sopenharmony_ciX
58862306a36Sopenharmony_ci#define IREG_LOGDEVICE		0x07
58962306a36Sopenharmony_ci#define IREG_ACTIVATE		0x30
59062306a36Sopenharmony_ci#define LD_ACTIVATE		0x01
59162306a36Sopenharmony_ci#define LD_DISACTIVATE		0x00
59262306a36Sopenharmony_ci#define IREG_EECONTROL		0x3F
59362306a36Sopenharmony_ci#define IREG_MEMBASEHI		0x40
59462306a36Sopenharmony_ci#define IREG_MEMBASELO		0x41
59562306a36Sopenharmony_ci#define IREG_MEMCONTROL		0x42
59662306a36Sopenharmony_ci#define IREG_MEMRANGEHI		0x43
59762306a36Sopenharmony_ci#define IREG_MEMRANGELO		0x44
59862306a36Sopenharmony_ci#define MEMTYPE_8BIT		0x00
59962306a36Sopenharmony_ci#define MEMTYPE_16BIT		0x02
60062306a36Sopenharmony_ci#define MEMTYPE_RANGE		0x00
60162306a36Sopenharmony_ci#define MEMTYPE_HIADDR		0x01
60262306a36Sopenharmony_ci#define IREG_IO0_BASEHI		0x60
60362306a36Sopenharmony_ci#define IREG_IO0_BASELO		0x61
60462306a36Sopenharmony_ci#define IREG_IO1_BASEHI		0x62
60562306a36Sopenharmony_ci#define IREG_IO1_BASELO		0x63
60662306a36Sopenharmony_ci#define IREG_IRQ_NUMBER		0x70
60762306a36Sopenharmony_ci#define IREG_IRQ_TYPE		0x71
60862306a36Sopenharmony_ci#define IRQTYPE_HIGH		0x02
60962306a36Sopenharmony_ci#define IRQTYPE_LOW		0x00
61062306a36Sopenharmony_ci#define IRQTYPE_LEVEL		0x01
61162306a36Sopenharmony_ci#define IRQTYPE_EDGE		0x00
61262306a36Sopenharmony_ciX
61362306a36Sopenharmony_ci#define HIBYTE(w)		((BYTE)(((WORD)(w) >> 8) & 0xFF))
61462306a36Sopenharmony_ci#define LOBYTE(w)		((BYTE)(w))
61562306a36Sopenharmony_ci#define MAKEWORD(low,hi)	((WORD)(((BYTE)(low))|(((WORD)((BYTE)(hi)))<<8)))
61662306a36Sopenharmony_ciX
61762306a36Sopenharmony_citypedef __u8			BYTE;
61862306a36Sopenharmony_citypedef __u16			USHORT;
61962306a36Sopenharmony_citypedef __u16			WORD;
62062306a36Sopenharmony_ciX
62162306a36Sopenharmony_cistatic int config_port = -1;
62262306a36Sopenharmony_ciX
62362306a36Sopenharmony_cistatic int msnd_write_cfg(int cfg, int reg, int value)
62462306a36Sopenharmony_ci{
62562306a36Sopenharmony_ciX	outb(reg, cfg);
62662306a36Sopenharmony_ciX	outb(value, cfg + 1);
62762306a36Sopenharmony_ciX	if (value != inb(cfg + 1)) {
62862306a36Sopenharmony_ciX		fprintf(stderr, "error: msnd_write_cfg: I/O error\n");
62962306a36Sopenharmony_ciX		return -EIO;
63062306a36Sopenharmony_ciX	}
63162306a36Sopenharmony_ciX	return 0;
63262306a36Sopenharmony_ci}
63362306a36Sopenharmony_ciX
63462306a36Sopenharmony_cistatic int msnd_read_cfg(int cfg, int reg)
63562306a36Sopenharmony_ci{
63662306a36Sopenharmony_ciX	outb(reg, cfg);
63762306a36Sopenharmony_ciX	return inb(cfg + 1);
63862306a36Sopenharmony_ci}
63962306a36Sopenharmony_ciX
64062306a36Sopenharmony_cistatic int msnd_write_cfg_io0(int cfg, int num, WORD io)
64162306a36Sopenharmony_ci{
64262306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
64362306a36Sopenharmony_ciX		return -EIO;
64462306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_IO0_BASEHI, HIBYTE(io)))
64562306a36Sopenharmony_ciX		return -EIO;
64662306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_IO0_BASELO, LOBYTE(io)))
64762306a36Sopenharmony_ciX		return -EIO;
64862306a36Sopenharmony_ciX	return 0;
64962306a36Sopenharmony_ci}
65062306a36Sopenharmony_ciX
65162306a36Sopenharmony_cistatic int msnd_read_cfg_io0(int cfg, int num, WORD *io)
65262306a36Sopenharmony_ci{
65362306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
65462306a36Sopenharmony_ciX		return -EIO;
65562306a36Sopenharmony_ciX
65662306a36Sopenharmony_ciX	*io = MAKEWORD(msnd_read_cfg(cfg, IREG_IO0_BASELO),
65762306a36Sopenharmony_ciX		       msnd_read_cfg(cfg, IREG_IO0_BASEHI));
65862306a36Sopenharmony_ciX
65962306a36Sopenharmony_ciX	return 0;
66062306a36Sopenharmony_ci}
66162306a36Sopenharmony_ciX
66262306a36Sopenharmony_cistatic int msnd_write_cfg_io1(int cfg, int num, WORD io)
66362306a36Sopenharmony_ci{
66462306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
66562306a36Sopenharmony_ciX		return -EIO;
66662306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_IO1_BASEHI, HIBYTE(io)))
66762306a36Sopenharmony_ciX		return -EIO;
66862306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_IO1_BASELO, LOBYTE(io)))
66962306a36Sopenharmony_ciX		return -EIO;
67062306a36Sopenharmony_ciX	return 0;
67162306a36Sopenharmony_ci}
67262306a36Sopenharmony_ciX
67362306a36Sopenharmony_cistatic int msnd_read_cfg_io1(int cfg, int num, WORD *io)
67462306a36Sopenharmony_ci{
67562306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
67662306a36Sopenharmony_ciX		return -EIO;
67762306a36Sopenharmony_ciX
67862306a36Sopenharmony_ciX	*io = MAKEWORD(msnd_read_cfg(cfg, IREG_IO1_BASELO),
67962306a36Sopenharmony_ciX		       msnd_read_cfg(cfg, IREG_IO1_BASEHI));
68062306a36Sopenharmony_ciX
68162306a36Sopenharmony_ciX	return 0;
68262306a36Sopenharmony_ci}
68362306a36Sopenharmony_ciX
68462306a36Sopenharmony_cistatic int msnd_write_cfg_irq(int cfg, int num, WORD irq)
68562306a36Sopenharmony_ci{
68662306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
68762306a36Sopenharmony_ciX		return -EIO;
68862306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_IRQ_NUMBER, LOBYTE(irq)))
68962306a36Sopenharmony_ciX		return -EIO;
69062306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_IRQ_TYPE, IRQTYPE_EDGE))
69162306a36Sopenharmony_ciX		return -EIO;
69262306a36Sopenharmony_ciX	return 0;
69362306a36Sopenharmony_ci}
69462306a36Sopenharmony_ciX
69562306a36Sopenharmony_cistatic int msnd_read_cfg_irq(int cfg, int num, WORD *irq)
69662306a36Sopenharmony_ci{
69762306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
69862306a36Sopenharmony_ciX		return -EIO;
69962306a36Sopenharmony_ciX
70062306a36Sopenharmony_ciX	*irq = msnd_read_cfg(cfg, IREG_IRQ_NUMBER);
70162306a36Sopenharmony_ciX
70262306a36Sopenharmony_ciX	return 0;
70362306a36Sopenharmony_ci}
70462306a36Sopenharmony_ciX
70562306a36Sopenharmony_cistatic int msnd_write_cfg_mem(int cfg, int num, int mem)
70662306a36Sopenharmony_ci{
70762306a36Sopenharmony_ciX	WORD wmem;
70862306a36Sopenharmony_ciX
70962306a36Sopenharmony_ciX	mem >>= 8;
71062306a36Sopenharmony_ciX	mem &= 0xfff;
71162306a36Sopenharmony_ciX	wmem = (WORD)mem;
71262306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
71362306a36Sopenharmony_ciX		return -EIO;
71462306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_MEMBASEHI, HIBYTE(wmem)))
71562306a36Sopenharmony_ciX		return -EIO;
71662306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_MEMBASELO, LOBYTE(wmem)))
71762306a36Sopenharmony_ciX		return -EIO;
71862306a36Sopenharmony_ciX	if (wmem && msnd_write_cfg(cfg, IREG_MEMCONTROL, (MEMTYPE_HIADDR | MEMTYPE_16BIT)))
71962306a36Sopenharmony_ciX		return -EIO;
72062306a36Sopenharmony_ciX	return 0;
72162306a36Sopenharmony_ci}
72262306a36Sopenharmony_ciX
72362306a36Sopenharmony_cistatic int msnd_read_cfg_mem(int cfg, int num, int *mem)
72462306a36Sopenharmony_ci{
72562306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
72662306a36Sopenharmony_ciX		return -EIO;
72762306a36Sopenharmony_ciX
72862306a36Sopenharmony_ciX	*mem = MAKEWORD(msnd_read_cfg(cfg, IREG_MEMBASELO),
72962306a36Sopenharmony_ciX			msnd_read_cfg(cfg, IREG_MEMBASEHI));
73062306a36Sopenharmony_ciX	*mem <<= 8;
73162306a36Sopenharmony_ciX
73262306a36Sopenharmony_ciX	return 0;
73362306a36Sopenharmony_ci}
73462306a36Sopenharmony_ciX
73562306a36Sopenharmony_cistatic int msnd_activate_logical(int cfg, int num)
73662306a36Sopenharmony_ci{
73762306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
73862306a36Sopenharmony_ciX		return -EIO;
73962306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_ACTIVATE, LD_ACTIVATE))
74062306a36Sopenharmony_ciX		return -EIO;
74162306a36Sopenharmony_ciX	return 0;
74262306a36Sopenharmony_ci}
74362306a36Sopenharmony_ciX
74462306a36Sopenharmony_cistatic int msnd_write_cfg_logical(int cfg, int num, WORD io0, WORD io1, WORD irq, int mem)
74562306a36Sopenharmony_ci{
74662306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
74762306a36Sopenharmony_ciX		return -EIO;
74862306a36Sopenharmony_ciX	if (msnd_write_cfg_io0(cfg, num, io0))
74962306a36Sopenharmony_ciX		return -EIO;
75062306a36Sopenharmony_ciX	if (msnd_write_cfg_io1(cfg, num, io1))
75162306a36Sopenharmony_ciX		return -EIO;
75262306a36Sopenharmony_ciX	if (msnd_write_cfg_irq(cfg, num, irq))
75362306a36Sopenharmony_ciX		return -EIO;
75462306a36Sopenharmony_ciX	if (msnd_write_cfg_mem(cfg, num, mem))
75562306a36Sopenharmony_ciX		return -EIO;
75662306a36Sopenharmony_ciX	if (msnd_activate_logical(cfg, num))
75762306a36Sopenharmony_ciX		return -EIO;
75862306a36Sopenharmony_ciX	return 0;
75962306a36Sopenharmony_ci}
76062306a36Sopenharmony_ciX
76162306a36Sopenharmony_cistatic int msnd_read_cfg_logical(int cfg, int num, WORD *io0, WORD *io1, WORD *irq, int *mem)
76262306a36Sopenharmony_ci{
76362306a36Sopenharmony_ciX	if (msnd_write_cfg(cfg, IREG_LOGDEVICE, num))
76462306a36Sopenharmony_ciX		return -EIO;
76562306a36Sopenharmony_ciX	if (msnd_read_cfg_io0(cfg, num, io0))
76662306a36Sopenharmony_ciX		return -EIO;
76762306a36Sopenharmony_ciX	if (msnd_read_cfg_io1(cfg, num, io1))
76862306a36Sopenharmony_ciX		return -EIO;
76962306a36Sopenharmony_ciX	if (msnd_read_cfg_irq(cfg, num, irq))
77062306a36Sopenharmony_ciX		return -EIO;
77162306a36Sopenharmony_ciX	if (msnd_read_cfg_mem(cfg, num, mem))
77262306a36Sopenharmony_ciX		return -EIO;
77362306a36Sopenharmony_ciX	return 0;
77462306a36Sopenharmony_ci}
77562306a36Sopenharmony_ciX
77662306a36Sopenharmony_cistatic void usage(void)
77762306a36Sopenharmony_ci{
77862306a36Sopenharmony_ciX	fprintf(stderr,
77962306a36Sopenharmony_ciX		"\n"
78062306a36Sopenharmony_ciX		"pinnaclecfg 1.0\n"
78162306a36Sopenharmony_ciX		"\n"
78262306a36Sopenharmony_ciX		"usage: pinnaclecfg <config port> [device config]\n"
78362306a36Sopenharmony_ciX		"\n"
78462306a36Sopenharmony_ciX		"This is for use with the card in NON-PnP mode only.\n"
78562306a36Sopenharmony_ciX		"\n"
78662306a36Sopenharmony_ciX		"Available devices (not all available for Fiji):\n"
78762306a36Sopenharmony_ciX		"\n"
78862306a36Sopenharmony_ciX		"        Device                       Description\n"
78962306a36Sopenharmony_ciX		"        -------------------------------------------------------------------\n"
79062306a36Sopenharmony_ciX		"        reset                        Reset all devices (i.e. disable)\n"
79162306a36Sopenharmony_ciX		"        show                         Display current device configurations\n"
79262306a36Sopenharmony_ciX		"\n"
79362306a36Sopenharmony_ciX		"        dsp <io> <irq> <mem>         Audio device\n"
79462306a36Sopenharmony_ciX		"        mpu <io> <irq>               Internal Kurzweil synth\n"
79562306a36Sopenharmony_ciX		"        ide <io0> <io1> <irq>        On-board IDE controller\n"
79662306a36Sopenharmony_ciX		"        joystick <io>                Joystick port\n"
79762306a36Sopenharmony_ciX		"\n");
79862306a36Sopenharmony_ciX	exit(1);
79962306a36Sopenharmony_ci}
80062306a36Sopenharmony_ciX
80162306a36Sopenharmony_cistatic int cfg_reset(void)
80262306a36Sopenharmony_ci{
80362306a36Sopenharmony_ciX	int i;
80462306a36Sopenharmony_ciX
80562306a36Sopenharmony_ciX	for (i = 0; i < 4; ++i)
80662306a36Sopenharmony_ciX		msnd_write_cfg_logical(config_port, i, 0, 0, 0, 0);
80762306a36Sopenharmony_ciX
80862306a36Sopenharmony_ciX	return 0;
80962306a36Sopenharmony_ci}
81062306a36Sopenharmony_ciX
81162306a36Sopenharmony_cistatic int cfg_show(void)
81262306a36Sopenharmony_ci{
81362306a36Sopenharmony_ciX	int i;
81462306a36Sopenharmony_ciX	int count = 0;
81562306a36Sopenharmony_ciX
81662306a36Sopenharmony_ciX	for (i = 0; i < 4; ++i) {
81762306a36Sopenharmony_ciX		WORD io0, io1, irq;
81862306a36Sopenharmony_ciX		int mem;
81962306a36Sopenharmony_ciX		msnd_read_cfg_logical(config_port, i, &io0, &io1, &irq, &mem);
82062306a36Sopenharmony_ciX		switch (i) {
82162306a36Sopenharmony_ciX		case 0:
82262306a36Sopenharmony_ciX			if (io0 || irq || mem) {
82362306a36Sopenharmony_ciX				printf("dsp 0x%x %d 0x%x\n", io0, irq, mem);
82462306a36Sopenharmony_ciX				++count;
82562306a36Sopenharmony_ciX			}
82662306a36Sopenharmony_ciX			break;
82762306a36Sopenharmony_ciX		case 1:
82862306a36Sopenharmony_ciX			if (io0 || irq) {
82962306a36Sopenharmony_ciX				printf("mpu 0x%x %d\n", io0, irq);
83062306a36Sopenharmony_ciX				++count;
83162306a36Sopenharmony_ciX			}
83262306a36Sopenharmony_ciX			break;
83362306a36Sopenharmony_ciX		case 2:
83462306a36Sopenharmony_ciX			if (io0 || io1 || irq) {
83562306a36Sopenharmony_ciX				printf("ide 0x%x 0x%x %d\n", io0, io1, irq);
83662306a36Sopenharmony_ciX				++count;
83762306a36Sopenharmony_ciX			}
83862306a36Sopenharmony_ciX			break;
83962306a36Sopenharmony_ciX		case 3:
84062306a36Sopenharmony_ciX			if (io0) {
84162306a36Sopenharmony_ciX				printf("joystick 0x%x\n", io0);
84262306a36Sopenharmony_ciX				++count;
84362306a36Sopenharmony_ciX			}
84462306a36Sopenharmony_ciX			break;
84562306a36Sopenharmony_ciX		}
84662306a36Sopenharmony_ciX	}
84762306a36Sopenharmony_ciX
84862306a36Sopenharmony_ciX	if (count == 0)
84962306a36Sopenharmony_ciX		fprintf(stderr, "no devices configured\n");
85062306a36Sopenharmony_ciX
85162306a36Sopenharmony_ciX	return 0;
85262306a36Sopenharmony_ci}
85362306a36Sopenharmony_ciX
85462306a36Sopenharmony_cistatic int cfg_dsp(int argc, char *argv[])
85562306a36Sopenharmony_ci{
85662306a36Sopenharmony_ciX	int io, irq, mem;
85762306a36Sopenharmony_ciX
85862306a36Sopenharmony_ciX	if (argc < 3 ||
85962306a36Sopenharmony_ciX	    sscanf(argv[0], "0x%x", &io) != 1 ||
86062306a36Sopenharmony_ciX	    sscanf(argv[1], "%d", &irq) != 1 ||
86162306a36Sopenharmony_ciX	    sscanf(argv[2], "0x%x", &mem) != 1)
86262306a36Sopenharmony_ciX		usage();
86362306a36Sopenharmony_ciX
86462306a36Sopenharmony_ciX	if (!(io == 0x290 ||
86562306a36Sopenharmony_ciX	      io == 0x260 ||
86662306a36Sopenharmony_ciX	      io == 0x250 ||
86762306a36Sopenharmony_ciX	      io == 0x240 ||
86862306a36Sopenharmony_ciX	      io == 0x230 ||
86962306a36Sopenharmony_ciX	      io == 0x220 ||
87062306a36Sopenharmony_ciX	      io == 0x210 ||
87162306a36Sopenharmony_ciX	      io == 0x3e0)) {
87262306a36Sopenharmony_ciX		fprintf(stderr, "error: io must be one of "
87362306a36Sopenharmony_ciX			"210, 220, 230, 240, 250, 260, 290, or 3E0\n");
87462306a36Sopenharmony_ciX		usage();
87562306a36Sopenharmony_ciX	}
87662306a36Sopenharmony_ciX
87762306a36Sopenharmony_ciX	if (!(irq == 5 ||
87862306a36Sopenharmony_ciX	      irq == 7 ||
87962306a36Sopenharmony_ciX	      irq == 9 ||
88062306a36Sopenharmony_ciX	      irq == 10 ||
88162306a36Sopenharmony_ciX	      irq == 11 ||
88262306a36Sopenharmony_ciX	      irq == 12)) {
88362306a36Sopenharmony_ciX		fprintf(stderr, "error: irq must be one of "
88462306a36Sopenharmony_ciX			"5, 7, 9, 10, 11 or 12\n");
88562306a36Sopenharmony_ciX		usage();
88662306a36Sopenharmony_ciX	}
88762306a36Sopenharmony_ciX
88862306a36Sopenharmony_ciX	if (!(mem == 0xb0000 ||
88962306a36Sopenharmony_ciX	      mem == 0xc8000 ||
89062306a36Sopenharmony_ciX	      mem == 0xd0000 ||
89162306a36Sopenharmony_ciX	      mem == 0xd8000 ||
89262306a36Sopenharmony_ciX	      mem == 0xe0000 ||
89362306a36Sopenharmony_ciX	      mem == 0xe8000)) {
89462306a36Sopenharmony_ciX		fprintf(stderr, "error: mem must be one of "
89562306a36Sopenharmony_ciX			"0xb0000, 0xc8000, 0xd0000, 0xd8000, 0xe0000 or 0xe8000\n");
89662306a36Sopenharmony_ciX		usage();
89762306a36Sopenharmony_ciX	}
89862306a36Sopenharmony_ciX
89962306a36Sopenharmony_ciX	return msnd_write_cfg_logical(config_port, 0, io, 0, irq, mem);
90062306a36Sopenharmony_ci}
90162306a36Sopenharmony_ciX
90262306a36Sopenharmony_cistatic int cfg_mpu(int argc, char *argv[])
90362306a36Sopenharmony_ci{
90462306a36Sopenharmony_ciX	int io, irq;
90562306a36Sopenharmony_ciX
90662306a36Sopenharmony_ciX	if (argc < 2 ||
90762306a36Sopenharmony_ciX	    sscanf(argv[0], "0x%x", &io) != 1 ||
90862306a36Sopenharmony_ciX	    sscanf(argv[1], "%d", &irq) != 1)
90962306a36Sopenharmony_ciX		usage();
91062306a36Sopenharmony_ciX
91162306a36Sopenharmony_ciX	return msnd_write_cfg_logical(config_port, 1, io, 0, irq, 0);
91262306a36Sopenharmony_ci}
91362306a36Sopenharmony_ciX
91462306a36Sopenharmony_cistatic int cfg_ide(int argc, char *argv[])
91562306a36Sopenharmony_ci{
91662306a36Sopenharmony_ciX	int io0, io1, irq;
91762306a36Sopenharmony_ciX
91862306a36Sopenharmony_ciX	if (argc < 3 ||
91962306a36Sopenharmony_ciX	    sscanf(argv[0], "0x%x", &io0) != 1 ||
92062306a36Sopenharmony_ciX	    sscanf(argv[0], "0x%x", &io1) != 1 ||
92162306a36Sopenharmony_ciX	    sscanf(argv[1], "%d", &irq) != 1)
92262306a36Sopenharmony_ciX		usage();
92362306a36Sopenharmony_ciX
92462306a36Sopenharmony_ciX	return msnd_write_cfg_logical(config_port, 2, io0, io1, irq, 0);
92562306a36Sopenharmony_ci}
92662306a36Sopenharmony_ciX
92762306a36Sopenharmony_cistatic int cfg_joystick(int argc, char *argv[])
92862306a36Sopenharmony_ci{
92962306a36Sopenharmony_ciX	int io;
93062306a36Sopenharmony_ciX
93162306a36Sopenharmony_ciX	if (argc < 1 ||
93262306a36Sopenharmony_ciX	    sscanf(argv[0], "0x%x", &io) != 1)
93362306a36Sopenharmony_ciX		usage();
93462306a36Sopenharmony_ciX
93562306a36Sopenharmony_ciX	return msnd_write_cfg_logical(config_port, 3, io, 0, 0, 0);
93662306a36Sopenharmony_ci}
93762306a36Sopenharmony_ciX
93862306a36Sopenharmony_ciint main(int argc, char *argv[])
93962306a36Sopenharmony_ci{
94062306a36Sopenharmony_ciX	char *device;
94162306a36Sopenharmony_ciX	int rv = 0;
94262306a36Sopenharmony_ciX
94362306a36Sopenharmony_ciX	--argc; ++argv;
94462306a36Sopenharmony_ciX
94562306a36Sopenharmony_ciX	if (argc < 2)
94662306a36Sopenharmony_ciX		usage();
94762306a36Sopenharmony_ciX
94862306a36Sopenharmony_ciX	sscanf(argv[0], "0x%x", &config_port);
94962306a36Sopenharmony_ciX	if (config_port != 0x250 && config_port != 0x260 && config_port != 0x270) {
95062306a36Sopenharmony_ciX		fprintf(stderr, "error: <config port> must be 0x250, 0x260 or 0x270\n");
95162306a36Sopenharmony_ciX		exit(1);
95262306a36Sopenharmony_ciX	}
95362306a36Sopenharmony_ciX	if (ioperm(config_port, 2, 1)) {
95462306a36Sopenharmony_ciX		perror("ioperm");
95562306a36Sopenharmony_ciX		fprintf(stderr, "note: pinnaclecfg must be run as root\n");
95662306a36Sopenharmony_ciX		exit(1);
95762306a36Sopenharmony_ciX	}
95862306a36Sopenharmony_ciX	device = argv[1];
95962306a36Sopenharmony_ciX
96062306a36Sopenharmony_ciX	argc -= 2; argv += 2;
96162306a36Sopenharmony_ciX
96262306a36Sopenharmony_ciX	if (strcmp(device, "reset") == 0)
96362306a36Sopenharmony_ciX		rv = cfg_reset();
96462306a36Sopenharmony_ciX	else if (strcmp(device, "show") == 0)
96562306a36Sopenharmony_ciX		rv = cfg_show();
96662306a36Sopenharmony_ciX	else if (strcmp(device, "dsp") == 0)
96762306a36Sopenharmony_ciX		rv = cfg_dsp(argc, argv);
96862306a36Sopenharmony_ciX	else if (strcmp(device, "mpu") == 0)
96962306a36Sopenharmony_ciX		rv = cfg_mpu(argc, argv);
97062306a36Sopenharmony_ciX	else if (strcmp(device, "ide") == 0)
97162306a36Sopenharmony_ciX		rv = cfg_ide(argc, argv);
97262306a36Sopenharmony_ciX	else if (strcmp(device, "joystick") == 0)
97362306a36Sopenharmony_ciX		rv = cfg_joystick(argc, argv);
97462306a36Sopenharmony_ciX	else {
97562306a36Sopenharmony_ciX		fprintf(stderr, "error: unknown device %s\n", device);
97662306a36Sopenharmony_ciX		usage();
97762306a36Sopenharmony_ciX	}
97862306a36Sopenharmony_ciX
97962306a36Sopenharmony_ciX	if (rv)
98062306a36Sopenharmony_ciX		fprintf(stderr, "error: device configuration failed\n");
98162306a36Sopenharmony_ciX
98262306a36Sopenharmony_ciX	return 0;
98362306a36Sopenharmony_ci}
98462306a36Sopenharmony_ciSHAR_EOF
98562306a36Sopenharmony_ci  $shar_touch -am 1204092598 'MultiSound.d/pinnaclecfg.c' &&
98662306a36Sopenharmony_ci  chmod 0664 'MultiSound.d/pinnaclecfg.c' ||
98762306a36Sopenharmony_ci  $echo 'restore of' 'MultiSound.d/pinnaclecfg.c' 'failed'
98862306a36Sopenharmony_ci  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
98962306a36Sopenharmony_ci  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
99062306a36Sopenharmony_ci    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
99162306a36Sopenharmony_ci    || $echo 'MultiSound.d/pinnaclecfg.c:' 'MD5 check failed'
99262306a36Sopenharmony_ci366bdf27f0db767a3c7921d0a6db20fe  MultiSound.d/pinnaclecfg.c
99362306a36Sopenharmony_ciSHAR_EOF
99462306a36Sopenharmony_ci  else
99562306a36Sopenharmony_ci    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/pinnaclecfg.c'`"
99662306a36Sopenharmony_ci    test 10224 -eq "$shar_count" ||
99762306a36Sopenharmony_ci    $echo 'MultiSound.d/pinnaclecfg.c:' 'original size' '10224,' 'current size' "$shar_count!"
99862306a36Sopenharmony_ci  fi
99962306a36Sopenharmony_cifi
100062306a36Sopenharmony_ci# ============= MultiSound.d/Makefile ==============
100162306a36Sopenharmony_ciif test -f 'MultiSound.d/Makefile' && test "$first_param" != -c; then
100262306a36Sopenharmony_ci  $echo 'x -' SKIPPING 'MultiSound.d/Makefile' '(file already exists)'
100362306a36Sopenharmony_cielse
100462306a36Sopenharmony_ci  $echo 'x -' extracting 'MultiSound.d/Makefile' '(text)'
100562306a36Sopenharmony_ci  sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/Makefile' &&
100662306a36Sopenharmony_ciCC	= gcc
100762306a36Sopenharmony_ciCFLAGS	= -O
100862306a36Sopenharmony_ciPROGS	= setdigital msndreset pinnaclecfg conv
100962306a36Sopenharmony_ciX
101062306a36Sopenharmony_ciall: $(PROGS)
101162306a36Sopenharmony_ciX
101262306a36Sopenharmony_ciclean:
101362306a36Sopenharmony_ciX	rm -f $(PROGS)
101462306a36Sopenharmony_ciSHAR_EOF
101562306a36Sopenharmony_ci  $shar_touch -am 1204092398 'MultiSound.d/Makefile' &&
101662306a36Sopenharmony_ci  chmod 0664 'MultiSound.d/Makefile' ||
101762306a36Sopenharmony_ci  $echo 'restore of' 'MultiSound.d/Makefile' 'failed'
101862306a36Sopenharmony_ci  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
101962306a36Sopenharmony_ci  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
102062306a36Sopenharmony_ci    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
102162306a36Sopenharmony_ci    || $echo 'MultiSound.d/Makefile:' 'MD5 check failed'
102262306a36Sopenharmony_ci76ca8bb44e3882edcf79c97df6c81845  MultiSound.d/Makefile
102362306a36Sopenharmony_ciSHAR_EOF
102462306a36Sopenharmony_ci  else
102562306a36Sopenharmony_ci    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/Makefile'`"
102662306a36Sopenharmony_ci    test 106 -eq "$shar_count" ||
102762306a36Sopenharmony_ci    $echo 'MultiSound.d/Makefile:' 'original size' '106,' 'current size' "$shar_count!"
102862306a36Sopenharmony_ci  fi
102962306a36Sopenharmony_cifi
103062306a36Sopenharmony_ci# ============= MultiSound.d/conv.l ==============
103162306a36Sopenharmony_ciif test -f 'MultiSound.d/conv.l' && test "$first_param" != -c; then
103262306a36Sopenharmony_ci  $echo 'x -' SKIPPING 'MultiSound.d/conv.l' '(file already exists)'
103362306a36Sopenharmony_cielse
103462306a36Sopenharmony_ci  $echo 'x -' extracting 'MultiSound.d/conv.l' '(text)'
103562306a36Sopenharmony_ci  sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/conv.l' &&
103662306a36Sopenharmony_ci%%
103762306a36Sopenharmony_ci[ \n\t,\r]
103862306a36Sopenharmony_ci\;.*
103962306a36Sopenharmony_ciDB
104062306a36Sopenharmony_ci[0-9A-Fa-f]+H	{ int n; sscanf(yytext, "%xH", &n); printf("%c", n); }
104162306a36Sopenharmony_ci%%
104262306a36Sopenharmony_ciint yywrap() { return 1; }
104362306a36Sopenharmony_civoid main() { yylex(); }
104462306a36Sopenharmony_ciSHAR_EOF
104562306a36Sopenharmony_ci  $shar_touch -am 0828231798 'MultiSound.d/conv.l' &&
104662306a36Sopenharmony_ci  chmod 0664 'MultiSound.d/conv.l' ||
104762306a36Sopenharmony_ci  $echo 'restore of' 'MultiSound.d/conv.l' 'failed'
104862306a36Sopenharmony_ci  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
104962306a36Sopenharmony_ci  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
105062306a36Sopenharmony_ci    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
105162306a36Sopenharmony_ci    || $echo 'MultiSound.d/conv.l:' 'MD5 check failed'
105262306a36Sopenharmony_cid2411fc32cd71a00dcdc1f009e858dd2  MultiSound.d/conv.l
105362306a36Sopenharmony_ciSHAR_EOF
105462306a36Sopenharmony_ci  else
105562306a36Sopenharmony_ci    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/conv.l'`"
105662306a36Sopenharmony_ci    test 146 -eq "$shar_count" ||
105762306a36Sopenharmony_ci    $echo 'MultiSound.d/conv.l:' 'original size' '146,' 'current size' "$shar_count!"
105862306a36Sopenharmony_ci  fi
105962306a36Sopenharmony_cifi
106062306a36Sopenharmony_ci# ============= MultiSound.d/msndreset.c ==============
106162306a36Sopenharmony_ciif test -f 'MultiSound.d/msndreset.c' && test "$first_param" != -c; then
106262306a36Sopenharmony_ci  $echo 'x -' SKIPPING 'MultiSound.d/msndreset.c' '(file already exists)'
106362306a36Sopenharmony_cielse
106462306a36Sopenharmony_ci  $echo 'x -' extracting 'MultiSound.d/msndreset.c' '(text)'
106562306a36Sopenharmony_ci  sed 's/^X//' << 'SHAR_EOF' > 'MultiSound.d/msndreset.c' &&
106662306a36Sopenharmony_ci/*********************************************************************
106762306a36Sopenharmony_ciX *
106862306a36Sopenharmony_ciX * msndreset.c - resets the MultiSound card
106962306a36Sopenharmony_ciX *
107062306a36Sopenharmony_ciX * Copyright (C) 1998 Andrew Veliath
107162306a36Sopenharmony_ciX *
107262306a36Sopenharmony_ciX * This program is free software; you can redistribute it and/or modify
107362306a36Sopenharmony_ciX * it under the terms of the GNU General Public License as published by
107462306a36Sopenharmony_ciX * the Free Software Foundation; either version 2 of the License, or
107562306a36Sopenharmony_ciX * (at your option) any later version.
107662306a36Sopenharmony_ciX *
107762306a36Sopenharmony_ciX * This program is distributed in the hope that it will be useful,
107862306a36Sopenharmony_ciX * but WITHOUT ANY WARRANTY; without even the implied warranty of
107962306a36Sopenharmony_ciX * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
108062306a36Sopenharmony_ciX * GNU General Public License for more details.
108162306a36Sopenharmony_ciX *
108262306a36Sopenharmony_ciX * You should have received a copy of the GNU General Public License
108362306a36Sopenharmony_ciX * along with this program; if not, write to the Free Software
108462306a36Sopenharmony_ciX * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
108562306a36Sopenharmony_ciX *
108662306a36Sopenharmony_ciX ********************************************************************/
108762306a36Sopenharmony_ciX
108862306a36Sopenharmony_ci#include <stdio.h>
108962306a36Sopenharmony_ci#include <stdlib.h>
109062306a36Sopenharmony_ci#include <unistd.h>
109162306a36Sopenharmony_ci#include <fcntl.h>
109262306a36Sopenharmony_ci#include <sys/types.h>
109362306a36Sopenharmony_ci#include <sys/stat.h>
109462306a36Sopenharmony_ci#include <sys/ioctl.h>
109562306a36Sopenharmony_ci#include <sys/soundcard.h>
109662306a36Sopenharmony_ciX
109762306a36Sopenharmony_ciint main(int argc, char *argv[])
109862306a36Sopenharmony_ci{
109962306a36Sopenharmony_ciX	int fd;
110062306a36Sopenharmony_ciX
110162306a36Sopenharmony_ciX	if (argc != 2) {
110262306a36Sopenharmony_ciX		fprintf(stderr, "usage: msndreset <mixer device>\n");
110362306a36Sopenharmony_ciX		exit(1);
110462306a36Sopenharmony_ciX	}
110562306a36Sopenharmony_ciX
110662306a36Sopenharmony_ciX	if ((fd = open(argv[1], O_RDWR)) < 0) {
110762306a36Sopenharmony_ciX		perror(argv[1]);
110862306a36Sopenharmony_ciX		exit(1);
110962306a36Sopenharmony_ciX	}
111062306a36Sopenharmony_ciX
111162306a36Sopenharmony_ciX	if (ioctl(fd, SOUND_MIXER_PRIVATE1, 0) < 0) {
111262306a36Sopenharmony_ciX		fprintf(stderr, "error: msnd ioctl reset failed\n");
111362306a36Sopenharmony_ciX		perror("ioctl");
111462306a36Sopenharmony_ciX		close(fd);
111562306a36Sopenharmony_ciX		exit(1);
111662306a36Sopenharmony_ciX	}
111762306a36Sopenharmony_ciX
111862306a36Sopenharmony_ciX	close(fd);
111962306a36Sopenharmony_ciX
112062306a36Sopenharmony_ciX	return 0;
112162306a36Sopenharmony_ci}
112262306a36Sopenharmony_ciSHAR_EOF
112362306a36Sopenharmony_ci  $shar_touch -am 1204100698 'MultiSound.d/msndreset.c' &&
112462306a36Sopenharmony_ci  chmod 0664 'MultiSound.d/msndreset.c' ||
112562306a36Sopenharmony_ci  $echo 'restore of' 'MultiSound.d/msndreset.c' 'failed'
112662306a36Sopenharmony_ci  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
112762306a36Sopenharmony_ci  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
112862306a36Sopenharmony_ci    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
112962306a36Sopenharmony_ci    || $echo 'MultiSound.d/msndreset.c:' 'MD5 check failed'
113062306a36Sopenharmony_cic52f876521084e8eb25e12e01dcccb8a  MultiSound.d/msndreset.c
113162306a36Sopenharmony_ciSHAR_EOF
113262306a36Sopenharmony_ci  else
113362306a36Sopenharmony_ci    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'MultiSound.d/msndreset.c'`"
113462306a36Sopenharmony_ci    test 1491 -eq "$shar_count" ||
113562306a36Sopenharmony_ci    $echo 'MultiSound.d/msndreset.c:' 'original size' '1491,' 'current size' "$shar_count!"
113662306a36Sopenharmony_ci  fi
113762306a36Sopenharmony_cifi
113862306a36Sopenharmony_cirm -fr _sh01426
113962306a36Sopenharmony_ciexit 0
1140