Linux MIDI - Getting and Installing the Drivers

Getting the Drivers

The OSS/Free kernel driver is included with the regular Linux distributions. Note that the distribution kernels are usually a version or so behind the lastest release. If your soundcard isn't supported, you may want to get the lastest version from:

Patches you may require

OSS/Free patches

Depending on your solution, you may need some additional patches for the kernel and/or the OSS/Free driver.

These are recommended reading for all Linux MIDI enthusiests.

"Plug and Play" kernel patches

PnP kernel patch

If you have a "Plug-and-Play" soundcard (also denoted by "PnP"), you will need additional software to the driver and patches mentioned above

Plug-and-Play kernel patch

This patch also contains patches for the AWE-32 driver, and so should be applied after the AWE-32 patches are applied.

If installed as a module, the "pnp" module needs to be loaded before the "sound" module (almost obvious, really.


A tool for setting up PnP devices from the command-line

You should run "isapnp" to configure your PnP card before you load the "sound" module (the OSS/Free driver MUST be compiled as a module if you are using isapnp).

Installing the Driver

The Linux kernels of the 1.2.xx series are distributed with a fairly old version of the sound driver (2.x) and you will probably need to upgrade the driver. Most currently available applications require version 3.x of the sound driver.

The best solution is to get a Linux 2.x kernel.

  1. If you are not updating your OSS/Free sound driver, you can skip this step.

    If you are updating the OSS/Free driver, it is a good idea to start by removing the old sound driver:

    and then unpack the new driver.

  2. Apply any OSS/Free patches, such as the "awe32" patch and/or the "uart16550" patch

  3. Apply the PnP patches, if required.

    Note that Tom Lees' PnP patch, there are TWO patches to apply:

  4. Configure the kernel

    I strongly recommended that you compile the sound driver as a module.
    If you're never used kernel modules before, now is the time to start.
    There are two advantages to be realised:

    Don't forget:

    You will be taken through another menu asking you lots of questions about your soundcard, such as base-addresses, IRQ's and DMA channels. Have this information ready. It is possible to have multiple MIDI-devices, though this is not well-supported by applications (see below).

    Note that it is possible to selectively disable devices, so it's best to configure everything you have the hardware for.

  5. Routinely build and install the new kernel

    Install the new kernel (ie using lilo or whatever you usually use)

  6. Routinely build and install the module(s)

  7. Set up the sound module. This is a good time to set up your kerneld configuration. Edit /etc/conf.modules, adding a line of the form:
      options sound trace_init=1 
  8. Reboot with the new kernel

  9. If you have a PnP soundcard, configure the card before you load the sound module.

  10. After rebooting, you should load the module(s) (unless you've set up kerneld to do it for you)

    the /dev/sndstat file lists all configured devices. If a device appears in brackets, it is unused. That is: the software exists to handle the device type, but the hardware was not detected.

    Here is a sample output from the command:

    cat /dev/sndstat
    Sound Driver:3.5.4-960630 (Tue Mar 18 00:46:06 EST 1997 root,
    Linux crystal 2.0.22 #5 Sun Mar 16 20:42:46 EST 1997 i486)
    Kernel: Linux crystal 2.0.22 #7 Tue Mar 18 00:48:20 EST 1997 i486
    Config options: 1510002
    Installed drivers: 
    Type 1: OPL-2/OPL-3 FM
    Type 2: Sound Blaster
    Type 7: SB MPU-401
    Type 32: 16450/16550A Midi
    Card config: 
    Sound Blaster at 0x220 irq 7 drq 0,5
    (SB MPU-401 at 0x330 irq 7 drq 0)
    OPL-2/OPL-3 FM at 0x388 drq 0,0
    16450/16550A Midi at 0x2f8 irq 3 drq 3,0
    (16450/16550A Midi at 0x2e8 irq 7 drq 16)
    (16450/16550A Midi drq 0)
    (16450/16550A Midi drq 0)
    Audio devices:
    0: Sound Blaster 16 (4.16)
    Synth devices:
    0: Yamaha OPL-3
    1: AWE32 Driver v0.3.99b (DRAM 8192k)
    Midi devices:
    0: uart16450 MIDI
    0: System clock
    0: Sound Blaster
    1: AWE32 Equalizer

    The driver was confiured to support three types of devices:

    The audio device, OPL-3 synth device, and SB MPU-401 are included with the SoundBlaster configuration.

    The 2nd 16450/16550 Midi device was setup during configuration, but disabled using the module parameter sound=... (see below). The SB MPU-401 was similary disabled. The 3rd and 4th 16450/16550 Midi device are normally disabled (having an IOBASE of 0x0), but these can be activated by the sound=... parameter.

    The above configuration was performed by the kerneld using:

    in /etc/conf.modules ...
    options sound trace_init=1 sound=0x138800,0x50222070,0x202f833

Reconfiguring the driver

By default, the sound driver probes for all the hardware that was configured during the make config .

Those devices which are detected become active, otherwise they are disabled. Disabled devices appear in brackets in the /dev/sndstat listing (see above)

It is possible to re-configure the sound-driver, so as to:

This is done by using the parameter sound=...

iff the sound-driver was compiled into the kernel,
this is a boot-parameter (at the LILO prompt, or on the LOADLIN command line)

The parameter is specified at boot-time, and the system must be re-booted in order to change the sound-device configuration.

iff the sound-driver was compiled as a module,
this is a symbol-parameter (on the insmod command line or, if the kerneld is being used, in /etc/conf.modules)

The parameter is specified when the module is loaded, and the module need only be unloaded and re-loaded with new parameters in order to change the sound-device configuration.

The format of the sound-parameter is:


D ..... is the 16-bit DMA channel
nn .... is the device-number (or "Type") of the driver
bbb ... is the base address
i ..... is the IRQ
d ..... is the 8-bit DMA channel

All values are specified in hexadecimal. The device-number or "Type" appears in the /dev/sndstat listing (eg 7 for the SB MPU-401)

The parameter is in fact a comma-seperated list, so multiple devices may be specified. Only those devices which appear in the list are probed-for, so any devices ommitted will be effectively disabled.

There are two notable variations on the above format:

It is not possible to disable low-level drivers (such as the AWE-32) using this method.

Multiple (MIDI) Devices

It is possible to configure the driver for more than one MIDI device, but most applications are "unaware" of this, and will just default to using the 1st MIDI device.

One solution is to use the sound=... parameter to selectively disable MIDI devices, so that only one MIDI device is configured. If you compiled the driver as a module, you can choose between the possible MIDI devices by reloading the module with the appropriate parameters.

Some applications which do support multiple devices are:

playmidi -D 0 ... selects the 1st MIDI device
playmidi -D 1 ... selects the 2nd MIDI device
in the file: ~/.jazz,
device 0
selects device 0 as defined by the output of the showdev command (supplied with Jazz)

Next: sound_patches.html
Previous intro.html