How I got sound working under Linux

by Simon Rumble

Wednesday 19th April, 2000

Wot I've got

I have a Dell Dimension XPS D266 computer running Linux. This machine has a Yamaha OPL3-SA3 audio chipset soldered onto the motherboard with three audio plugs connecting at the back. Getting audio going was an absolute bastard so I'm writing this page, with lots of hints for the search engines, so that perhaps others will have less trouble.

For the record I'm running Linux 2.2.14 under the Debian unstable distribution, but that shouldn't make much difference. The relevant kernel drivers have been available for ages.

These chips, as documented in /usr/src/linux/Documentation/sound/OPL3-SA2 give you:

  • OPL3 FM synthesizer
  • Soundblaster Pro
  • Microsoft/Windows Sound System
  • MPU401 MIDI interface

As Plug and Pray devices (PnP) I needed to use isapnptools, a package that lets you play with the PnP settings. You do something like:
pnpdump >/etc/isapnp.conf
Which probes all the PnP devices and outputs a big file with all the options. You need to go through the options and uncomment one of the options for each function.

As you see above with this chipset supporting four actual devices, it gets quite complicated. The only ISA PnP device in my machine is this chipset and it's still complicated. The raw output of pnpdump is attached below.

Getting it going

So I started mucking around with it, getting nowhere. My first approach was to try and get ALSA going and get it sort it out. No joy. At this stage I could probably get ALSA working--the reason I had problems before was that I didn't have the memory io ports, irqs and DMA set correctly. The alsa config stuff is like the kernel modules and requires all that info up front.

Next was to remove all the ALSA crap, recompile the kernel with the opl3 and associated drivers and try again. No joy. It was getting drastic, I was getting frustrated and I couldn't listen to any mp3s, let alone take advantage of my shiny new cable modem to stream audio and video. It was time to call in The Guru.

Craig walked me through all the settings, eventually getting it going with this isapnp.conf file. On the first attempt I used IRQ 7, seemingly unused according to /proc/interrupts but got staccato sound coming out with everything else working. Couldn't work it out and eventually changes to IRQ 5 and it worked fine.

Boodiful!

Making it permanent

To make the settings re-occur with reboots I had to add the following to /etc/modules:

mpu401
ad1848
sound
opl3sa2 io=0x370 mss_io=0x530 mpu_io=0x330 irq=5 dma=0 dma2=3

Make sure you add it with the first three before the opl3sa2 line. If you're running a roll-your-own distribution you'll need to get isapnp to run before this script. With Debian that all happens automagically.

Let me know if you find this useful.

My working /etc/isapnp.conf file

# (DEBUG)
(READPORT 0x0273)
(ISOLATE PRESERVE)
(IDENTIFY *)
(VERBOSITY 2)
(CONFLICT (IO FATAL)(IRQ FATAL)(DMA FATAL)(MEM FATAL)) # or WARNING

(CONFIGURE YMH0800/-1 (LD 0

# Instead of (IO 0 (BASE 0x0220)), disable SB:
(IO 0 (BASE 0x0220))
(IO 1 (BASE 0x0530))
(IO 2 (BASE 0x0388))
(IO 3 (BASE 0x0330))
(IO 4 (BASE 0x0370))
(INT 0 (IRQ 4 (MODE +E)))
(DMA 0 (CHANNEL 0))
(DMA 1 (CHANNEL 3))

(NAME "YMH0030/2156265473[1]{OPL3-SA3 Snd System }")
(ACT Y)
))

# Returns all cards to the "Wait for Key" state
(WAITFORKEY)

Output of pnpdump on my machine

# $Id: pnpdump.c,v 1.21 1999/12/09 22:28:33 fox Exp $
# Release isapnptools-1.21 (library isapnptools-1.21)
# 
# This is free software, see the sources for details.
# This software has NO WARRANTY, use at your OWN RISK
# 
# For details of the output file format, see isapnp.conf(5)
# 
# For latest information and FAQ on isapnp and pnpdump see:
# http://www.roestock.demon.co.uk/isapnptools/
# 
# Compiler flags:  -DREALTIME -DNEEDSETSCHEDULER -DABORT_ONRESERR
# (for   library:  -DREALTIME -DNEEDSETSCHEDULER -DABORT_ONRESERR)
# 
# Trying port address 0273
# Board 1 has serial identifier cb 80 86 00 01 30 00 a8 65

# (DEBUG)
(READPORT 0x0273)
(ISOLATE PRESERVE)
(IDENTIFY *)
(VERBOSITY 2)
(CONFLICT (IO FATAL)(IRQ FATAL)(DMA FATAL)(MEM FATAL)) # or WARNING

# Card 1: (serial identifier cb 80 86 00 01 30 00 a8 65)
# Vendor Id YMH0030, Serial Number 2156265473, checksum 0xCB.
# Version 1.0, Vendor version 0.0
# ANSI string -->OPL3-SA3 Snd System<--
#
# Logical device id YMH0021
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy

(CONFIGURE YMH0030/2156265473 (LD 0

# Multiple choice time, choose one only !

#     Start dependent functions: priority preferred
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0220
#             Maximum IO base address 0x0220
#             IO base alignment 16 bytes
#             Number of IO addresses required: 16
# (IO 0 (SIZE 16) (BASE 0x0220))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0530
#             Maximum IO base address 0x0530
#             IO base alignment 8 bytes
#             Number of IO addresses required: 8
# (IO 1 (SIZE 8) (BASE 0x0530))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0388
#             Maximum IO base address 0x0388
#             IO base alignment 8 bytes
#             Number of IO addresses required: 8
# (IO 2 (SIZE 8) (BASE 0x0388))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0330
#             Maximum IO base address 0x0330
#             IO base alignment 2 bytes
#             Number of IO addresses required: 2
# (IO 3 (SIZE 2) (BASE 0x0330))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0370
#             Maximum IO base address 0x0370
#             IO base alignment 2 bytes
#             Number of IO addresses required: 2
# (IO 4 (SIZE 2) (BASE 0x0370))
#       IRQ 5.
#             High true, edge sensitive interrupt
# (INT 0 (IRQ 5 (MODE +E)))
#       First DMA channel 0.
#             8 bit DMA only
#             Logical device is a bus master
#             DMA may execute in count by byte mode
#             DMA may not execute in count by word mode
#             DMA channel speed type F
# (DMA 0 (CHANNEL 0))
#       Next DMA channel 1.
#             8 bit DMA only
#             Logical device is not a bus master
#             DMA may execute in count by byte mode
#             DMA may not execute in count by word mode
#             DMA channel speed type F
# (DMA 1 (CHANNEL 1))

#       Start dependent functions: priority acceptable
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0240
#             Maximum IO base address 0x0240
#             IO base alignment 16 bytes
#             Number of IO addresses required: 16
# (IO 0 (SIZE 16) (BASE 0x0240))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0e80
#             Maximum IO base address 0x0e80
#             IO base alignment 8 bytes
#             Number of IO addresses required: 8
# (IO 1 (SIZE 8) (BASE 0x0e80))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0388
#             Maximum IO base address 0x0388
#             IO base alignment 8 bytes
#             Number of IO addresses required: 8
# (IO 2 (SIZE 8) (BASE 0x0388))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0300
#             Maximum IO base address 0x0300
#             IO base alignment 2 bytes
#             Number of IO addresses required: 2
# (IO 3 (SIZE 2) (BASE 0x0300))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0100
#             Maximum IO base address 0x0ffe
#             IO base alignment 2 bytes
#             Number of IO addresses required: 2
# (IO 4 (SIZE 2) (BASE 0x0100))
#       IRQ 5, 7, 9, 10 or 11.
#             High true, edge sensitive interrupt
# (INT 0 (IRQ 5 (MODE +E)))
#       First DMA channel 0, 1 or 3.
#             8 bit DMA only
#             Logical device is a bus master
#             DMA may execute in count by byte mode
#             DMA may not execute in count by word mode
#             DMA channel speed type F
# (DMA 0 (CHANNEL 0))
#       Next DMA channel 0, 1 or 3.
#             8 bit DMA only
#             Logical device is a bus master
#             DMA may execute in count by byte mode
#             DMA may not execute in count by word mode
#             DMA channel speed type F
# (DMA 1 (CHANNEL 0))

#       Start dependent functions: priority functional
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0220
#             Maximum IO base address 0x0280
#             IO base alignment 16 bytes
#             Number of IO addresses required: 16
# (IO 0 (SIZE 16) (BASE 0x0220))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0530
#             Maximum IO base address 0x0f48
#             IO base alignment 8 bytes
#             Number of IO addresses required: 8
# (IO 1 (SIZE 8) (BASE 0x0530))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0388
#             Maximum IO base address 0x03f8
#             IO base alignment 8 bytes
#             Number of IO addresses required: 8
# (IO 2 (SIZE 8) (BASE 0x0388))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0300
#             Maximum IO base address 0x0334
#             IO base alignment 2 bytes
#             Number of IO addresses required: 2
# (IO 3 (SIZE 2) (BASE 0x0300))
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0100
#             Maximum IO base address 0x0ffe
#             IO base alignment 2 bytes
#             Number of IO addresses required: 2
# (IO 4 (SIZE 2) (BASE 0x0100))
#       IRQ 5, 7, 9, 10 or 11.
#             High true, edge sensitive interrupt
# (INT 0 (IRQ 5 (MODE +E)))
#       First DMA channel 0, 1 or 3.
#             8 bit DMA only
#             Logical device is a bus master
#             DMA may execute in count by byte mode
#             DMA may not execute in count by word mode
#             DMA channel speed type F
# (DMA 0 (CHANNEL 0))
#       Next DMA channel 0, 1 or 3.
#             8 bit DMA only
#             Logical device is a bus master
#             DMA may execute in count by byte mode
#             DMA may not execute in count by word mode
#             DMA channel speed type F
# (DMA 1 (CHANNEL 0))

#     End dependent functions
 (NAME "YMH0030/2156265473[0]{OPL3-SA3 Snd System }")
# (ACT Y)
))
#
# Logical device id YMH0022
#
# Edit the entries below to uncomment out the configuration required.
# Note that only the first value of any range is given, this may be changed if required
# Don't forget to uncomment the activate (ACT Y) when happy

(CONFIGURE YMH0030/2156265473 (LD 1
#     Compatible device id PNPb02f

# Multiple choice time, choose one only !

#     Start dependent functions: priority preferred
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0201
#             Maximum IO base address 0x0201
#             IO base alignment 1 bytes
#             Number of IO addresses required: 1
# (IO 0 (SIZE 1) (BASE 0x0201))

#       Start dependent functions: priority acceptable
#       Logical device decodes 16 bit IO address lines
#             Minimum IO base address 0x0201
#             Maximum IO base address 0x0211
#             IO base alignment 16 bytes
#             Number of IO addresses required: 1
# (IO 0 (SIZE 1) (BASE 0x0201))

#     End dependent functions
 (NAME "YMH0030/2156265473[1]{OPL3-SA3 Snd System }")
# (ACT Y)
))
# End tag... Checksum 0x00 (OK)

# Returns all cards to the "Wait for Key" state
(WAITFORKEY)