| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | Support for the OPTi 82C931 chip | 
|  | 2 | -------------------------------- | 
|  | 3 | Note: parts of this README file apply also to other | 
|  | 4 | cards that use the mad16 driver. | 
|  | 5 |  | 
|  | 6 | Some items in this README file are based on features | 
|  | 7 | added to the sound driver after Linux-2.1.91 was out. | 
|  | 8 | By the time of writing this I do not know which official | 
|  | 9 | kernel release will include these features. | 
|  | 10 | Please do not report inconsistencies on older Linux | 
|  | 11 | kernels. | 
|  | 12 |  | 
|  | 13 | The OPTi 82C931 is supported in its non-PnP mode. | 
|  | 14 | Usually you do not need to set jumpers, etc. The sound driver | 
|  | 15 | will check the card status and if it is required it will | 
|  | 16 | force the card into a mode in which it can be programmed. | 
|  | 17 |  | 
|  | 18 | If you have another OS installed on your computer it is recommended | 
|  | 19 | that Linux and the other OS use the same resources. | 
|  | 20 |  | 
| Lucas De Marchi | 970e248 | 2012-03-30 13:37:16 -0700 | [diff] [blame] | 21 | Also, it is recommended that resources specified in /etc/modprobe.d/*.conf | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | and resources specified in /etc/isapnp.conf agree. | 
|  | 23 |  | 
|  | 24 | Compiling the sound driver | 
|  | 25 | -------------------------- | 
|  | 26 | I highly recommend that you build a modularized sound driver. | 
|  | 27 | This document does not cover a sound-driver which is built in | 
|  | 28 | the kernel. | 
|  | 29 |  | 
|  | 30 | Sound card support should be enabled as a module (chose m). | 
|  | 31 | Answer 'm' for  these items: | 
|  | 32 | Generic OPL2/OPL3 FM synthesizer support		(CONFIG_SOUND_ADLIB) | 
|  | 33 | Microsoft Sound System support			(CONFIG_SOUND_MSS) | 
|  | 34 | Support for OPTi MAD16 and/or Mozart based cards	(CONFIG_SOUND_MAD16) | 
|  | 35 | FM synthesizer (YM3812/OPL-3) support			(CONFIG_SOUND_YM3812) | 
|  | 36 |  | 
|  | 37 | The configuration menu may ask for addresses, IRQ lines or DMA | 
|  | 38 | channels. If the card is used as a module the module loading | 
|  | 39 | options will override these values. | 
|  | 40 |  | 
|  | 41 | For the OPTi 931 you can answer 'n' to: | 
|  | 42 | Support MIDI in older MAD16 based cards (requires SB)	(CONFIG_SOUND_MAD16_OLDCARD) | 
|  | 43 | If you do need MIDI support in a Mozart or C928 based card you | 
|  | 44 | need to answer 'm' to the above question. In that case you will | 
|  | 45 | also need to answer 'm' to: | 
|  | 46 | '100% Sound Blaster compatibles (SB16/32/64, ESS, Jazz16) support' (CONFIG_SOUND_SB) | 
|  | 47 |  | 
|  | 48 | Go on and compile your kernel and modules. Install the modules. Run depmod -a. | 
|  | 49 |  | 
|  | 50 | Using isapnptools | 
|  | 51 | ----------------- | 
|  | 52 | In most systems with a PnP BIOS you do not need to use isapnp. The | 
|  | 53 | initialization provided by the BIOS is sufficient for the driver | 
|  | 54 | to pick up the card and continue initialization. | 
|  | 55 |  | 
|  | 56 | If that fails, or if you have other PnP cards, you need to use isapnp | 
|  | 57 | to initialize the card. | 
|  | 58 | This was tested with isapnptools-1.11 but I recommend that you use | 
|  | 59 | isapnptools-1.13 (or newer). Run pnpdump to dump the information | 
|  | 60 | about your PnP cards. Then edit the resulting file and select | 
|  | 61 | the options of your choice. This file is normally installed as | 
|  | 62 | /etc/isapnp.conf. | 
|  | 63 |  | 
|  | 64 | The driver has one limitation with respect to I/O port resources: | 
|  | 65 | IO3 base must be 0x0E0C.  Although isapnp allows other ports, this | 
|  | 66 | address is hard-coded into the driver. | 
|  | 67 |  | 
|  | 68 | Using kmod and autoloading the sound driver | 
|  | 69 | ------------------------------------------- | 
| Lucas De Marchi | 970e248 | 2012-03-30 13:37:16 -0700 | [diff] [blame] | 70 | Config files in '/etc/modprobe.d/' are used as below: | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 |  | 
|  | 72 | alias mixer0 mad16 | 
|  | 73 | alias audio0 mad16 | 
|  | 74 | alias midi0  mad16 | 
|  | 75 | alias synth0 opl3 | 
|  | 76 | options sb mad16=1 | 
|  | 77 | options mad16 irq=10 dma=0 dma16=1 io=0x530 joystick=1 cdtype=0 | 
|  | 78 | options opl3 io=0x388 | 
|  | 79 | install mad16 /sbin/modprobe -i mad16 && /sbin/ad1848_mixer_reroute 14 8 15 3 16 6 | 
|  | 80 |  | 
|  | 81 | If you have an MPU daughtercard or onboard MPU you will want to add to the | 
|  | 82 | "options mad16" line - eg | 
|  | 83 |  | 
|  | 84 | options mad16 irq=5 dma=0 dma16=3 io=0x530 mpu_io=0x330 mpu_irq=9 | 
|  | 85 |  | 
|  | 86 | To set the I/O and IRQ of the MPU. | 
|  | 87 |  | 
|  | 88 |  | 
|  | 89 | Explain: | 
|  | 90 |  | 
|  | 91 | alias mixer0 mad16 | 
|  | 92 | alias audio0 mad16 | 
|  | 93 | alias midi0  mad16 | 
|  | 94 | alias synth0 opl3 | 
|  | 95 |  | 
|  | 96 | When any sound device is opened the kernel requests auto-loading | 
|  | 97 | of char-major-14. There is a built-in alias that translates this | 
|  | 98 | request to loading the main sound module. | 
|  | 99 |  | 
|  | 100 | The sound module in its turn will request loading of a sub-driver | 
|  | 101 | for mixer, audio, midi or synthesizer device. The first 3 are | 
|  | 102 | supported by the mad16 driver. The synth device is supported | 
|  | 103 | by the opl3 driver. | 
|  | 104 |  | 
|  | 105 | There is currently no way to autoload the sound device driver | 
|  | 106 | if more than one card is installed. | 
|  | 107 |  | 
|  | 108 | options sb mad16=1 | 
|  | 109 |  | 
|  | 110 | This is left for historical reasons. If you enable the | 
|  | 111 | config option 'Support MIDI in older MAD16 based cards (requires SB)' | 
|  | 112 | or if you use an older mad16 driver it will force loading of the | 
|  | 113 | SoundBlaster driver. This option tells the SB driver not to look | 
|  | 114 | for a SB card but to wait for the mad16 driver. | 
|  | 115 |  | 
|  | 116 | options mad16 irq=10 dma=0 dma16=1 io=0x530 joystick=1 cdtype=0 | 
|  | 117 | options opl3 io=0x388 | 
|  | 118 |  | 
|  | 119 | post-install mad16 /sbin/ad1848_mixer_reroute 14 8 15 3 16 6 | 
|  | 120 |  | 
|  | 121 | This sets resources and options for the mad16 and opl3 drivers. | 
|  | 122 | I use two DMA channels (only one is required) to enable full duplex. | 
|  | 123 | joystick=1 enables the joystick port. cdtype=0 disables the cd port. | 
|  | 124 | You can also set mpu_io and mpu_irq in the mad16 options for the | 
|  | 125 | uart401 driver. | 
|  | 126 |  | 
|  | 127 | This tells modprobe to run /sbin/ad1848_mixer_reroute after | 
|  | 128 | mad16 is successfully loaded and initialized. The source | 
|  | 129 | for ad1848_mixer_reroute is appended to the end of this readme | 
|  | 130 | file. It is impossible for the sound driver to know the actual | 
|  | 131 | connections to the mixer. The 3 inputs intended for cd, synth | 
|  | 132 | and line-in are mapped to the generic inputs line1, line2 and | 
|  | 133 | line3. This program reroutes these mixer channels to their | 
|  | 134 | right names (note the right mapping depends on the actual sound | 
|  | 135 | card that you use). | 
|  | 136 | The numeric parameters mean: | 
|  | 137 | 14=line1 8=cd    - reroute line1 to the CD input. | 
|  | 138 | 15=line2 3=synth - reroute line2 to the synthesizer input. | 
|  | 139 | 16=line3 6=line  - reroute line3 to the line input. | 
|  | 140 | For reference on other input names look at the file | 
|  | 141 | /usr/include/linux/soundcard.h. | 
|  | 142 |  | 
|  | 143 | Using a joystick | 
|  | 144 | ----------------- | 
|  | 145 | You must enable a joystick in the mad16 options. (also | 
|  | 146 | in /etc/isapnp.conf if you use it). | 
|  | 147 | Tested with regular analog joysticks. | 
|  | 148 |  | 
|  | 149 | A CDROM drive connected to the sound card | 
|  | 150 | ----------------------------------------- | 
|  | 151 | The 82C931 chip has support only for secondary ATAPI cdrom. | 
|  | 152 | (cdtype=8). Loading the mad16 driver resets the C931 chip | 
|  | 153 | and if a cdrom was already mounted it may cause a complete | 
|  | 154 | system hang. Do not use the sound card if you have an alternative. | 
|  | 155 | If you do use the sound card it is important that you load | 
|  | 156 | the mad16 driver (use "modprobe mad16" to prevent auto-unloading) | 
|  | 157 | before the cdrom is accessed the first time. | 
|  | 158 |  | 
|  | 159 | Using the sound driver built-in to the kernel may help here, but... | 
|  | 160 | Most new systems have a PnP BIOS and also two IDE controllers. | 
|  | 161 | The IDE controller on the sound card may be needed only on older | 
|  | 162 | systems (which have only one IDE controller) but these systems | 
|  | 163 | also do not have a PnP BIOS - requiring isapnptools and a modularized | 
|  | 164 | driver. | 
|  | 165 |  | 
|  | 166 | Known problems | 
|  | 167 | -------------- | 
|  | 168 | 1. See the section on "A CDROM drive connected to the sound card". | 
|  | 169 |  | 
|  | 170 | 2. On my system the codec cannot capture companded sound samples. | 
|  | 171 | (eg., recording from /dev/audio). When any companded capture is | 
|  | 172 | requested I get stereo-16 bit samples instead. Playback of | 
|  | 173 | companded samples works well. Apparently this problem is not common | 
|  | 174 | to all C931 based cards. I do not know how to identify cards that | 
|  | 175 | have this problem. | 
|  | 176 |  | 
|  | 177 | Source for ad1848_mixer_reroute.c | 
|  | 178 | --------------------------------- | 
|  | 179 | #include <stdio.h> | 
|  | 180 | #include <fcntl.h> | 
|  | 181 | #include <linux/soundcard.h> | 
|  | 182 |  | 
|  | 183 | static char *mixer_names[SOUND_MIXER_NRDEVICES] = | 
|  | 184 | SOUND_DEVICE_LABELS; | 
|  | 185 |  | 
|  | 186 | int | 
|  | 187 | main(int argc, char **argv) { | 
|  | 188 | int val, from, to; | 
|  | 189 | int i, fd; | 
|  | 190 |  | 
|  | 191 | fd = open("/dev/mixer", O_RDWR); | 
|  | 192 | if(fd < 0) { | 
|  | 193 | perror("/dev/mixer"); | 
|  | 194 | return 1; | 
|  | 195 | } | 
|  | 196 |  | 
|  | 197 | for(i = 2; i < argc; i += 2) { | 
|  | 198 | from = atoi(argv[i-1]); | 
|  | 199 | to = atoi(argv[i]); | 
|  | 200 |  | 
|  | 201 | if(to == SOUND_MIXER_NONE) | 
|  | 202 | fprintf(stderr, "%s: turning off mixer %s\n", | 
|  | 203 | argv[0], mixer_names[to]); | 
|  | 204 | else | 
|  | 205 | fprintf(stderr, "%s: rerouting mixer %s to %s\n", | 
|  | 206 | argv[0], mixer_names[from], mixer_names[to]); | 
|  | 207 |  | 
|  | 208 | val = from << 8 | to; | 
|  | 209 |  | 
|  | 210 | if(ioctl(fd, SOUND_MIXER_PRIVATE2, &val)) { | 
|  | 211 | perror("AD1848 mixer reroute"); | 
|  | 212 | return 1; | 
|  | 213 | } | 
|  | 214 | } | 
|  | 215 |  | 
|  | 216 | return 0; | 
|  | 217 | } | 
|  | 218 |  |