1 // SPDX-License-Identifier: GPL-2.0-or-later 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 2 /* 3 * Driver for Yamaha OPL3-SA[2,3] soundcards 3 * Driver for Yamaha OPL3-SA[2,3] soundcards 4 * Copyright (c) by Jaroslav Kysela <perex@pe 4 * Copyright (c) by Jaroslav Kysela <perex@perex.cz> 5 */ 5 */ 6 6 7 #include <linux/init.h> 7 #include <linux/init.h> 8 #include <linux/err.h> 8 #include <linux/err.h> 9 #include <linux/isa.h> 9 #include <linux/isa.h> 10 #include <linux/interrupt.h> 10 #include <linux/interrupt.h> 11 #include <linux/pm.h> 11 #include <linux/pm.h> 12 #include <linux/pnp.h> 12 #include <linux/pnp.h> 13 #include <linux/module.h> 13 #include <linux/module.h> 14 #include <linux/io.h> 14 #include <linux/io.h> 15 #include <sound/core.h> 15 #include <sound/core.h> 16 #include <sound/wss.h> 16 #include <sound/wss.h> 17 #include <sound/mpu401.h> 17 #include <sound/mpu401.h> 18 #include <sound/opl3.h> 18 #include <sound/opl3.h> 19 #include <sound/initval.h> 19 #include <sound/initval.h> 20 #include <sound/tlv.h> 20 #include <sound/tlv.h> 21 21 22 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz 22 MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>"); 23 MODULE_DESCRIPTION("Yamaha OPL3SA2+"); 23 MODULE_DESCRIPTION("Yamaha OPL3SA2+"); 24 MODULE_LICENSE("GPL"); 24 MODULE_LICENSE("GPL"); 25 25 26 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_ 26 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ 27 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_S 27 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ 28 static bool enable[SNDRV_CARDS] = SNDRV_DEFAUL 28 static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_ISAPNP; /* Enable this card */ 29 #ifdef CONFIG_PNP 29 #ifdef CONFIG_PNP 30 static bool isapnp[SNDRV_CARDS] = {[0 ... (SND 30 static bool isapnp[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1}; 31 #endif 31 #endif 32 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_ 32 static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0xf86,0x370,0x100 */ 33 static long sb_port[SNDRV_CARDS] = SNDRV_DEFAU 33 static long sb_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x220,0x240,0x260 */ 34 static long wss_port[SNDRV_CARDS] = SNDRV_DEFA 34 static long wss_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* 0x530,0xe80,0xf40,0x604 */ 35 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAU 35 static long fm_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; /* 0x388 */ 36 static long midi_port[SNDRV_CARDS] = SNDRV_DEF 36 static long midi_port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT;/* 0x330,0x300 */ 37 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IR 37 static int irq[SNDRV_CARDS] = SNDRV_DEFAULT_IRQ; /* 0,1,3,5,9,11,12,15 */ 38 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_D 38 static int dma1[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */ 39 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_D 39 static int dma2[SNDRV_CARDS] = SNDRV_DEFAULT_DMA; /* 1,3,5,6,7 */ 40 static int opl3sa3_ymode[SNDRV_CARDS]; /* 0, 40 static int opl3sa3_ymode[SNDRV_CARDS]; /* 0,1,2,3 */ /*SL Added*/ 41 41 42 module_param_array(index, int, NULL, 0444); 42 module_param_array(index, int, NULL, 0444); 43 MODULE_PARM_DESC(index, "Index value for OPL3- 43 MODULE_PARM_DESC(index, "Index value for OPL3-SA soundcard."); 44 module_param_array(id, charp, NULL, 0444); 44 module_param_array(id, charp, NULL, 0444); 45 MODULE_PARM_DESC(id, "ID string for OPL3-SA so 45 MODULE_PARM_DESC(id, "ID string for OPL3-SA soundcard."); 46 module_param_array(enable, bool, NULL, 0444); 46 module_param_array(enable, bool, NULL, 0444); 47 MODULE_PARM_DESC(enable, "Enable OPL3-SA sound 47 MODULE_PARM_DESC(enable, "Enable OPL3-SA soundcard."); 48 #ifdef CONFIG_PNP 48 #ifdef CONFIG_PNP 49 module_param_array(isapnp, bool, NULL, 0444); 49 module_param_array(isapnp, bool, NULL, 0444); 50 MODULE_PARM_DESC(isapnp, "PnP detection for sp 50 MODULE_PARM_DESC(isapnp, "PnP detection for specified soundcard."); 51 #endif 51 #endif 52 module_param_hw_array(port, long, ioport, NULL 52 module_param_hw_array(port, long, ioport, NULL, 0444); 53 MODULE_PARM_DESC(port, "Port # for OPL3-SA dri 53 MODULE_PARM_DESC(port, "Port # for OPL3-SA driver."); 54 module_param_hw_array(sb_port, long, ioport, N 54 module_param_hw_array(sb_port, long, ioport, NULL, 0444); 55 MODULE_PARM_DESC(sb_port, "SB port # for OPL3- 55 MODULE_PARM_DESC(sb_port, "SB port # for OPL3-SA driver."); 56 module_param_hw_array(wss_port, long, ioport, 56 module_param_hw_array(wss_port, long, ioport, NULL, 0444); 57 MODULE_PARM_DESC(wss_port, "WSS port # for OPL 57 MODULE_PARM_DESC(wss_port, "WSS port # for OPL3-SA driver."); 58 module_param_hw_array(fm_port, long, ioport, N 58 module_param_hw_array(fm_port, long, ioport, NULL, 0444); 59 MODULE_PARM_DESC(fm_port, "FM port # for OPL3- 59 MODULE_PARM_DESC(fm_port, "FM port # for OPL3-SA driver."); 60 module_param_hw_array(midi_port, long, ioport, 60 module_param_hw_array(midi_port, long, ioport, NULL, 0444); 61 MODULE_PARM_DESC(midi_port, "MIDI port # for O 61 MODULE_PARM_DESC(midi_port, "MIDI port # for OPL3-SA driver."); 62 module_param_hw_array(irq, int, irq, NULL, 044 62 module_param_hw_array(irq, int, irq, NULL, 0444); 63 MODULE_PARM_DESC(irq, "IRQ # for OPL3-SA drive 63 MODULE_PARM_DESC(irq, "IRQ # for OPL3-SA driver."); 64 module_param_hw_array(dma1, int, dma, NULL, 04 64 module_param_hw_array(dma1, int, dma, NULL, 0444); 65 MODULE_PARM_DESC(dma1, "DMA1 # for OPL3-SA dri 65 MODULE_PARM_DESC(dma1, "DMA1 # for OPL3-SA driver."); 66 module_param_hw_array(dma2, int, dma, NULL, 04 66 module_param_hw_array(dma2, int, dma, NULL, 0444); 67 MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA dri 67 MODULE_PARM_DESC(dma2, "DMA2 # for OPL3-SA driver."); 68 module_param_array(opl3sa3_ymode, int, NULL, 0 68 module_param_array(opl3sa3_ymode, int, NULL, 0444); 69 MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size 69 MODULE_PARM_DESC(opl3sa3_ymode, "Speaker size selection for 3D Enhancement mode: Desktop/Large Notebook/Small Notebook/HiFi."); 70 70 71 #ifdef CONFIG_PNP 71 #ifdef CONFIG_PNP 72 static int isa_registered; 72 static int isa_registered; 73 static int pnp_registered; 73 static int pnp_registered; 74 static int pnpc_registered; 74 static int pnpc_registered; 75 #endif 75 #endif 76 76 77 /* control ports */ 77 /* control ports */ 78 #define OPL3SA2_PM_CTRL 0x01 78 #define OPL3SA2_PM_CTRL 0x01 79 #define OPL3SA2_SYS_CTRL 0x02 79 #define OPL3SA2_SYS_CTRL 0x02 80 #define OPL3SA2_IRQ_CONFIG 0x03 80 #define OPL3SA2_IRQ_CONFIG 0x03 81 #define OPL3SA2_IRQ_STATUS 0x04 81 #define OPL3SA2_IRQ_STATUS 0x04 82 #define OPL3SA2_DMA_CONFIG 0x06 82 #define OPL3SA2_DMA_CONFIG 0x06 83 #define OPL3SA2_MASTER_LEFT 0x07 83 #define OPL3SA2_MASTER_LEFT 0x07 84 #define OPL3SA2_MASTER_RIGHT 0x08 84 #define OPL3SA2_MASTER_RIGHT 0x08 85 #define OPL3SA2_MIC 0x09 85 #define OPL3SA2_MIC 0x09 86 #define OPL3SA2_MISC 0x0A 86 #define OPL3SA2_MISC 0x0A 87 87 88 /* opl3sa3 only */ 88 /* opl3sa3 only */ 89 #define OPL3SA3_DGTL_DOWN 0x12 89 #define OPL3SA3_DGTL_DOWN 0x12 90 #define OPL3SA3_ANLG_DOWN 0x13 90 #define OPL3SA3_ANLG_DOWN 0x13 91 #define OPL3SA3_WIDE 0x14 91 #define OPL3SA3_WIDE 0x14 92 #define OPL3SA3_BASS 0x15 92 #define OPL3SA3_BASS 0x15 93 #define OPL3SA3_TREBLE 0x16 93 #define OPL3SA3_TREBLE 0x16 94 94 95 /* power management bits */ 95 /* power management bits */ 96 #define OPL3SA2_PM_ADOWN 0x20 96 #define OPL3SA2_PM_ADOWN 0x20 97 #define OPL3SA2_PM_PSV 0x04 97 #define OPL3SA2_PM_PSV 0x04 98 #define OPL3SA2_PM_PDN 0x02 98 #define OPL3SA2_PM_PDN 0x02 99 #define OPL3SA2_PM_PDX 0x01 99 #define OPL3SA2_PM_PDX 0x01 100 100 101 #define OPL3SA2_PM_D0 0x00 101 #define OPL3SA2_PM_D0 0x00 102 #define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3 102 #define OPL3SA2_PM_D3 (OPL3SA2_PM_ADOWN|OPL3SA2_PM_PSV|OPL3SA2_PM_PDN|OPL3SA2_PM_PDX) 103 103 104 struct snd_opl3sa2 { 104 struct snd_opl3sa2 { 105 int version; /* 2 or 3 */ 105 int version; /* 2 or 3 */ 106 unsigned long port; /* control por 106 unsigned long port; /* control port */ 107 struct resource *res_port; /* control 107 struct resource *res_port; /* control port resource */ 108 int irq; 108 int irq; 109 int single_dma; 109 int single_dma; 110 spinlock_t reg_lock; 110 spinlock_t reg_lock; 111 struct snd_card *card; << 112 struct snd_hwdep *synth; 111 struct snd_hwdep *synth; 113 struct snd_rawmidi *rmidi; 112 struct snd_rawmidi *rmidi; 114 struct snd_wss *wss; 113 struct snd_wss *wss; 115 unsigned char ctlregs[0x20]; 114 unsigned char ctlregs[0x20]; 116 int ymode; /* SL added */ 115 int ymode; /* SL added */ 117 struct snd_kcontrol *master_switch; 116 struct snd_kcontrol *master_switch; 118 struct snd_kcontrol *master_volume; 117 struct snd_kcontrol *master_volume; 119 }; 118 }; 120 119 121 #define PFX "opl3sa2: " 120 #define PFX "opl3sa2: " 122 121 123 #ifdef CONFIG_PNP 122 #ifdef CONFIG_PNP 124 123 125 static const struct pnp_device_id snd_opl3sa2_ 124 static const struct pnp_device_id snd_opl3sa2_pnpbiosids[] = { 126 { .id = "YMH0021" }, 125 { .id = "YMH0021" }, 127 { .id = "NMX2210" }, /* Gateway Sol 126 { .id = "NMX2210" }, /* Gateway Solo 2500 */ 128 { .id = "" } /* end */ 127 { .id = "" } /* end */ 129 }; 128 }; 130 129 131 MODULE_DEVICE_TABLE(pnp, snd_opl3sa2_pnpbiosid 130 MODULE_DEVICE_TABLE(pnp, snd_opl3sa2_pnpbiosids); 132 131 133 static const struct pnp_card_device_id snd_opl 132 static const struct pnp_card_device_id snd_opl3sa2_pnpids[] = { 134 /* Yamaha YMF719E-S (Genius Sound Make 133 /* Yamaha YMF719E-S (Genius Sound Maker 3DX) */ 135 { .id = "YMH0020", .devs = { { "YMH002 134 { .id = "YMH0020", .devs = { { "YMH0021" } } }, 136 /* Yamaha OPL3-SA3 (integrated on Inte 135 /* Yamaha OPL3-SA3 (integrated on Intel's Pentium II AL440LX motherboard) */ 137 { .id = "YMH0030", .devs = { { "YMH002 136 { .id = "YMH0030", .devs = { { "YMH0021" } } }, 138 /* Yamaha OPL3-SA2 */ 137 /* Yamaha OPL3-SA2 */ 139 { .id = "YMH0800", .devs = { { "YMH002 138 { .id = "YMH0800", .devs = { { "YMH0021" } } }, 140 /* Yamaha OPL3-SA2 */ 139 /* Yamaha OPL3-SA2 */ 141 { .id = "YMH0801", .devs = { { "YMH002 140 { .id = "YMH0801", .devs = { { "YMH0021" } } }, 142 /* NeoMagic MagicWave 3DX */ 141 /* NeoMagic MagicWave 3DX */ 143 { .id = "NMX2200", .devs = { { "YMH221 142 { .id = "NMX2200", .devs = { { "YMH2210" } } }, 144 /* NeoMagic MagicWave 3D */ 143 /* NeoMagic MagicWave 3D */ 145 { .id = "NMX2200", .devs = { { "NMX221 144 { .id = "NMX2200", .devs = { { "NMX2210" } } }, 146 /* --- */ 145 /* --- */ 147 { .id = "" } /* end */ 146 { .id = "" } /* end */ 148 }; 147 }; 149 148 150 MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpi 149 MODULE_DEVICE_TABLE(pnp_card, snd_opl3sa2_pnpids); 151 150 152 #endif /* CONFIG_PNP */ 151 #endif /* CONFIG_PNP */ 153 152 154 153 155 /* read control port (w/o spinlock) */ 154 /* read control port (w/o spinlock) */ 156 static unsigned char __snd_opl3sa2_read(struct 155 static unsigned char __snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg) 157 { 156 { 158 unsigned char result; 157 unsigned char result; 159 #if 0 158 #if 0 160 outb(0x1d, port); /* password */ 159 outb(0x1d, port); /* password */ 161 dev_dbg(chip->card->dev, "read [0x%lx] !! 160 printk(KERN_DEBUG "read [0x%lx] = 0x%x\n", port, inb(port)); 162 #endif 161 #endif 163 outb(reg, chip->port); /* register */ 162 outb(reg, chip->port); /* register */ 164 result = inb(chip->port + 1); 163 result = inb(chip->port + 1); 165 #if 0 164 #if 0 166 dev_dbg(chip->card->dev, "read [0x%lx] !! 165 printk(KERN_DEBUG "read [0x%lx] = 0x%x [0x%x]\n", 167 port, result, inb(port)); 166 port, result, inb(port)); 168 #endif 167 #endif 169 return result; 168 return result; 170 } 169 } 171 170 172 /* read control port (with spinlock) */ 171 /* read control port (with spinlock) */ 173 static unsigned char snd_opl3sa2_read(struct s 172 static unsigned char snd_opl3sa2_read(struct snd_opl3sa2 *chip, unsigned char reg) 174 { 173 { 175 unsigned long flags; 174 unsigned long flags; 176 unsigned char result; 175 unsigned char result; 177 176 178 spin_lock_irqsave(&chip->reg_lock, fla 177 spin_lock_irqsave(&chip->reg_lock, flags); 179 result = __snd_opl3sa2_read(chip, reg) 178 result = __snd_opl3sa2_read(chip, reg); 180 spin_unlock_irqrestore(&chip->reg_lock 179 spin_unlock_irqrestore(&chip->reg_lock, flags); 181 return result; 180 return result; 182 } 181 } 183 182 184 /* write control port (w/o spinlock) */ 183 /* write control port (w/o spinlock) */ 185 static void __snd_opl3sa2_write(struct snd_opl 184 static void __snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value) 186 { 185 { 187 #if 0 186 #if 0 188 outb(0x1d, port); /* password */ 187 outb(0x1d, port); /* password */ 189 #endif 188 #endif 190 outb(reg, chip->port); /* register */ 189 outb(reg, chip->port); /* register */ 191 outb(value, chip->port + 1); 190 outb(value, chip->port + 1); 192 chip->ctlregs[reg] = value; 191 chip->ctlregs[reg] = value; 193 } 192 } 194 193 195 /* write control port (with spinlock) */ 194 /* write control port (with spinlock) */ 196 static void snd_opl3sa2_write(struct snd_opl3s 195 static void snd_opl3sa2_write(struct snd_opl3sa2 *chip, unsigned char reg, unsigned char value) 197 { 196 { 198 unsigned long flags; 197 unsigned long flags; 199 spin_lock_irqsave(&chip->reg_lock, fla 198 spin_lock_irqsave(&chip->reg_lock, flags); 200 __snd_opl3sa2_write(chip, reg, value); 199 __snd_opl3sa2_write(chip, reg, value); 201 spin_unlock_irqrestore(&chip->reg_lock 200 spin_unlock_irqrestore(&chip->reg_lock, flags); 202 } 201 } 203 202 204 static int snd_opl3sa2_detect(struct snd_card 203 static int snd_opl3sa2_detect(struct snd_card *card) 205 { 204 { 206 struct snd_opl3sa2 *chip = card->priva 205 struct snd_opl3sa2 *chip = card->private_data; 207 unsigned long port; 206 unsigned long port; 208 unsigned char tmp, tmp1; 207 unsigned char tmp, tmp1; 209 char str[2]; 208 char str[2]; 210 209 211 port = chip->port; 210 port = chip->port; 212 chip->res_port = devm_request_region(c 211 chip->res_port = devm_request_region(card->dev, port, 2, 213 " 212 "OPL3-SA control"); 214 if (!chip->res_port) { 213 if (!chip->res_port) { 215 dev_err(card->dev, "can't grab !! 214 snd_printk(KERN_ERR PFX "can't grab port 0x%lx\n", port); 216 return -EBUSY; 215 return -EBUSY; 217 } 216 } >> 217 /* >> 218 snd_printk(KERN_DEBUG "REG 0A = 0x%x\n", >> 219 snd_opl3sa2_read(chip, 0x0a)); >> 220 */ 218 chip->version = 0; 221 chip->version = 0; 219 tmp = snd_opl3sa2_read(chip, OPL3SA2_M 222 tmp = snd_opl3sa2_read(chip, OPL3SA2_MISC); 220 if (tmp == 0xff) { 223 if (tmp == 0xff) { 221 dev_dbg(card->dev, "OPL3-SA [0 !! 224 snd_printd("OPL3-SA [0x%lx] detect = 0x%x\n", port, tmp); 222 return -ENODEV; 225 return -ENODEV; 223 } 226 } 224 switch (tmp & 0x07) { 227 switch (tmp & 0x07) { 225 case 0x01: 228 case 0x01: 226 chip->version = 2; /* YMF711 * 229 chip->version = 2; /* YMF711 */ 227 break; 230 break; 228 default: 231 default: 229 chip->version = 3; 232 chip->version = 3; 230 /* 0x02 - standard */ 233 /* 0x02 - standard */ 231 /* 0x03 - YM715B */ 234 /* 0x03 - YM715B */ 232 /* 0x04 - YM719 - OPL-SA4? */ 235 /* 0x04 - YM719 - OPL-SA4? */ 233 /* 0x05 - OPL3-SA3 - Libretto 236 /* 0x05 - OPL3-SA3 - Libretto 100 */ 234 /* 0x07 - unknown - Neomagic M 237 /* 0x07 - unknown - Neomagic MagicWave 3D */ 235 break; 238 break; 236 } 239 } 237 str[0] = chip->version + ''; 240 str[0] = chip->version + ''; 238 str[1] = 0; 241 str[1] = 0; 239 strcat(card->shortname, str); 242 strcat(card->shortname, str); 240 snd_opl3sa2_write(chip, OPL3SA2_MISC, 243 snd_opl3sa2_write(chip, OPL3SA2_MISC, tmp ^ 7); 241 tmp1 = snd_opl3sa2_read(chip, OPL3SA2_ 244 tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MISC); 242 if (tmp1 != tmp) { 245 if (tmp1 != tmp) { 243 dev_dbg(card->dev, "OPL3-SA [0 !! 246 snd_printd("OPL3-SA [0x%lx] detect (1) = 0x%x (0x%x)\n", port, tmp, tmp1); 244 return -ENODEV; 247 return -ENODEV; 245 } 248 } 246 /* try if the MIC register is accessib 249 /* try if the MIC register is accessible */ 247 tmp = snd_opl3sa2_read(chip, OPL3SA2_M 250 tmp = snd_opl3sa2_read(chip, OPL3SA2_MIC); 248 snd_opl3sa2_write(chip, OPL3SA2_MIC, 0 251 snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x8a); 249 tmp1 = snd_opl3sa2_read(chip, OPL3SA2_ 252 tmp1 = snd_opl3sa2_read(chip, OPL3SA2_MIC); 250 if ((tmp1 & 0x9f) != 0x8a) { 253 if ((tmp1 & 0x9f) != 0x8a) { 251 dev_dbg(card->dev, "OPL3-SA [0 !! 254 snd_printd("OPL3-SA [0x%lx] detect (2) = 0x%x (0x%x)\n", port, tmp, tmp1); 252 return -ENODEV; 255 return -ENODEV; 253 } 256 } 254 snd_opl3sa2_write(chip, OPL3SA2_MIC, 0 257 snd_opl3sa2_write(chip, OPL3SA2_MIC, 0x9f); 255 /* initialization */ 258 /* initialization */ 256 /* Power Management - full on */ 259 /* Power Management - full on */ 257 snd_opl3sa2_write(chip, OPL3SA2_PM_CTR 260 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0); 258 if (chip->version > 2) { 261 if (chip->version > 2) { 259 /* ymode is bits 4&5 (of 0 to 262 /* ymode is bits 4&5 (of 0 to 7) on all but opl3sa2 versions */ 260 snd_opl3sa2_write(chip, OPL3SA 263 snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, (chip->ymode << 4)); 261 } else { 264 } else { 262 /* default for opl3sa2 version 265 /* default for opl3sa2 versions */ 263 snd_opl3sa2_write(chip, OPL3SA 266 snd_opl3sa2_write(chip, OPL3SA2_SYS_CTRL, 0x00); 264 } 267 } 265 snd_opl3sa2_write(chip, OPL3SA2_IRQ_CO 268 snd_opl3sa2_write(chip, OPL3SA2_IRQ_CONFIG, 0x0d); /* Interrupt Channel Configuration - IRQ A = OPL3 + MPU + WSS */ 266 if (chip->single_dma) { 269 if (chip->single_dma) { 267 snd_opl3sa2_write(chip, OPL3SA 270 snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x03); /* DMA Configuration - DMA A = WSS-R + WSS-P */ 268 } else { 271 } else { 269 snd_opl3sa2_write(chip, OPL3SA 272 snd_opl3sa2_write(chip, OPL3SA2_DMA_CONFIG, 0x21); /* DMA Configuration - DMA B = WSS-R, DMA A = WSS-P */ 270 } 273 } 271 snd_opl3sa2_write(chip, OPL3SA2_MISC, 274 snd_opl3sa2_write(chip, OPL3SA2_MISC, 0x80 | (tmp & 7)); /* Miscellaneous - default */ 272 if (chip->version > 2) { 275 if (chip->version > 2) { 273 snd_opl3sa2_write(chip, OPL3SA 276 snd_opl3sa2_write(chip, OPL3SA3_DGTL_DOWN, 0x00); /* Digital Block Partial Power Down - default */ 274 snd_opl3sa2_write(chip, OPL3SA 277 snd_opl3sa2_write(chip, OPL3SA3_ANLG_DOWN, 0x00); /* Analog Block Partial Power Down - default */ 275 } 278 } 276 return 0; 279 return 0; 277 } 280 } 278 281 279 static irqreturn_t snd_opl3sa2_interrupt(int i 282 static irqreturn_t snd_opl3sa2_interrupt(int irq, void *dev_id) 280 { 283 { 281 unsigned short status; 284 unsigned short status; 282 struct snd_card *card = dev_id; 285 struct snd_card *card = dev_id; 283 struct snd_opl3sa2 *chip; 286 struct snd_opl3sa2 *chip; 284 int handled = 0; 287 int handled = 0; 285 288 286 if (card == NULL) 289 if (card == NULL) 287 return IRQ_NONE; 290 return IRQ_NONE; 288 291 289 chip = card->private_data; 292 chip = card->private_data; 290 status = snd_opl3sa2_read(chip, OPL3SA 293 status = snd_opl3sa2_read(chip, OPL3SA2_IRQ_STATUS); 291 294 292 if (status & 0x20) { 295 if (status & 0x20) { 293 handled = 1; 296 handled = 1; 294 snd_opl3_interrupt(chip->synth 297 snd_opl3_interrupt(chip->synth); 295 } 298 } 296 299 297 if ((status & 0x10) && chip->rmidi != 300 if ((status & 0x10) && chip->rmidi != NULL) { 298 handled = 1; 301 handled = 1; 299 snd_mpu401_uart_interrupt(irq, 302 snd_mpu401_uart_interrupt(irq, chip->rmidi->private_data); 300 } 303 } 301 304 302 if (status & 0x07) { /* TI,CI,PI */ 305 if (status & 0x07) { /* TI,CI,PI */ 303 handled = 1; 306 handled = 1; 304 snd_wss_interrupt(irq, chip->w 307 snd_wss_interrupt(irq, chip->wss); 305 } 308 } 306 309 307 if (status & 0x40) { /* hardware volum 310 if (status & 0x40) { /* hardware volume change */ 308 handled = 1; 311 handled = 1; 309 /* reading from Master Lch reg 312 /* reading from Master Lch register at 0x07 clears this bit */ 310 snd_opl3sa2_read(chip, OPL3SA2 313 snd_opl3sa2_read(chip, OPL3SA2_MASTER_RIGHT); 311 snd_opl3sa2_read(chip, OPL3SA2 314 snd_opl3sa2_read(chip, OPL3SA2_MASTER_LEFT); 312 if (chip->master_switch && chi 315 if (chip->master_switch && chip->master_volume) { 313 snd_ctl_notify(card, S 316 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, 314 &chip- 317 &chip->master_switch->id); 315 snd_ctl_notify(card, S 318 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, 316 &chip- 319 &chip->master_volume->id); 317 } 320 } 318 } 321 } 319 return IRQ_RETVAL(handled); 322 return IRQ_RETVAL(handled); 320 } 323 } 321 324 322 #define OPL3SA2_SINGLE(xname, xindex, reg, shi 325 #define OPL3SA2_SINGLE(xname, xindex, reg, shift, mask, invert) \ 323 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 326 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 324 .info = snd_wss_info_single, \ 327 .info = snd_wss_info_single, \ 325 .get = snd_opl3sa2_get_single, .put = snd_op 328 .get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \ 326 .private_value = reg | (shift << 8) | (mask 329 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) } 327 #define OPL3SA2_SINGLE_TLV(xname, xindex, reg, 330 #define OPL3SA2_SINGLE_TLV(xname, xindex, reg, shift, mask, invert, xtlv) \ 328 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 331 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 329 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 332 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 330 .name = xname, .index = xindex, \ 333 .name = xname, .index = xindex, \ 331 .info = snd_wss_info_single, \ 334 .info = snd_wss_info_single, \ 332 .get = snd_opl3sa2_get_single, .put = snd_op 335 .get = snd_opl3sa2_get_single, .put = snd_opl3sa2_put_single, \ 333 .private_value = reg | (shift << 8) | (mask 336 .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24), \ 334 .tlv = { .p = (xtlv) } } 337 .tlv = { .p = (xtlv) } } 335 338 336 static int snd_opl3sa2_get_single(struct snd_k 339 static int snd_opl3sa2_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 337 { 340 { 338 struct snd_opl3sa2 *chip = snd_kcontro 341 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); 339 unsigned long flags; 342 unsigned long flags; 340 int reg = kcontrol->private_value & 0x 343 int reg = kcontrol->private_value & 0xff; 341 int shift = (kcontrol->private_value > 344 int shift = (kcontrol->private_value >> 8) & 0xff; 342 int mask = (kcontrol->private_value >> 345 int mask = (kcontrol->private_value >> 16) & 0xff; 343 int invert = (kcontrol->private_value 346 int invert = (kcontrol->private_value >> 24) & 0xff; 344 347 345 spin_lock_irqsave(&chip->reg_lock, fla 348 spin_lock_irqsave(&chip->reg_lock, flags); 346 ucontrol->value.integer.value[0] = (ch 349 ucontrol->value.integer.value[0] = (chip->ctlregs[reg] >> shift) & mask; 347 spin_unlock_irqrestore(&chip->reg_lock 350 spin_unlock_irqrestore(&chip->reg_lock, flags); 348 if (invert) 351 if (invert) 349 ucontrol->value.integer.value[ 352 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; 350 return 0; 353 return 0; 351 } 354 } 352 355 353 static int snd_opl3sa2_put_single(struct snd_k 356 static int snd_opl3sa2_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 354 { 357 { 355 struct snd_opl3sa2 *chip = snd_kcontro 358 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); 356 unsigned long flags; 359 unsigned long flags; 357 int reg = kcontrol->private_value & 0x 360 int reg = kcontrol->private_value & 0xff; 358 int shift = (kcontrol->private_value > 361 int shift = (kcontrol->private_value >> 8) & 0xff; 359 int mask = (kcontrol->private_value >> 362 int mask = (kcontrol->private_value >> 16) & 0xff; 360 int invert = (kcontrol->private_value 363 int invert = (kcontrol->private_value >> 24) & 0xff; 361 int change; 364 int change; 362 unsigned short val, oval; 365 unsigned short val, oval; 363 366 364 val = (ucontrol->value.integer.value[0 367 val = (ucontrol->value.integer.value[0] & mask); 365 if (invert) 368 if (invert) 366 val = mask - val; 369 val = mask - val; 367 val <<= shift; 370 val <<= shift; 368 spin_lock_irqsave(&chip->reg_lock, fla 371 spin_lock_irqsave(&chip->reg_lock, flags); 369 oval = chip->ctlregs[reg]; 372 oval = chip->ctlregs[reg]; 370 val = (oval & ~(mask << shift)) | val; 373 val = (oval & ~(mask << shift)) | val; 371 change = val != oval; 374 change = val != oval; 372 __snd_opl3sa2_write(chip, reg, val); 375 __snd_opl3sa2_write(chip, reg, val); 373 spin_unlock_irqrestore(&chip->reg_lock 376 spin_unlock_irqrestore(&chip->reg_lock, flags); 374 return change; 377 return change; 375 } 378 } 376 379 377 #define OPL3SA2_DOUBLE(xname, xindex, left_reg 380 #define OPL3SA2_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \ 378 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = 381 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ 379 .info = snd_wss_info_double, \ 382 .info = snd_wss_info_double, \ 380 .get = snd_opl3sa2_get_double, .put = snd_op 383 .get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \ 381 .private_value = left_reg | (right_reg << 8) 384 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) } 382 #define OPL3SA2_DOUBLE_TLV(xname, xindex, left 385 #define OPL3SA2_DOUBLE_TLV(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert, xtlv) \ 383 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 386 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ 384 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | 387 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ 385 .name = xname, .index = xindex, \ 388 .name = xname, .index = xindex, \ 386 .info = snd_wss_info_double, \ 389 .info = snd_wss_info_double, \ 387 .get = snd_opl3sa2_get_double, .put = snd_op 390 .get = snd_opl3sa2_get_double, .put = snd_opl3sa2_put_double, \ 388 .private_value = left_reg | (right_reg << 8) 391 .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22), \ 389 .tlv = { .p = (xtlv) } } 392 .tlv = { .p = (xtlv) } } 390 393 391 static int snd_opl3sa2_get_double(struct snd_k 394 static int snd_opl3sa2_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 392 { 395 { 393 struct snd_opl3sa2 *chip = snd_kcontro 396 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); 394 unsigned long flags; 397 unsigned long flags; 395 int left_reg = kcontrol->private_value 398 int left_reg = kcontrol->private_value & 0xff; 396 int right_reg = (kcontrol->private_val 399 int right_reg = (kcontrol->private_value >> 8) & 0xff; 397 int shift_left = (kcontrol->private_va 400 int shift_left = (kcontrol->private_value >> 16) & 0x07; 398 int shift_right = (kcontrol->private_v 401 int shift_right = (kcontrol->private_value >> 19) & 0x07; 399 int mask = (kcontrol->private_value >> 402 int mask = (kcontrol->private_value >> 24) & 0xff; 400 int invert = (kcontrol->private_value 403 int invert = (kcontrol->private_value >> 22) & 1; 401 404 402 spin_lock_irqsave(&chip->reg_lock, fla 405 spin_lock_irqsave(&chip->reg_lock, flags); 403 ucontrol->value.integer.value[0] = (ch 406 ucontrol->value.integer.value[0] = (chip->ctlregs[left_reg] >> shift_left) & mask; 404 ucontrol->value.integer.value[1] = (ch 407 ucontrol->value.integer.value[1] = (chip->ctlregs[right_reg] >> shift_right) & mask; 405 spin_unlock_irqrestore(&chip->reg_lock 408 spin_unlock_irqrestore(&chip->reg_lock, flags); 406 if (invert) { 409 if (invert) { 407 ucontrol->value.integer.value[ 410 ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0]; 408 ucontrol->value.integer.value[ 411 ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1]; 409 } 412 } 410 return 0; 413 return 0; 411 } 414 } 412 415 413 static int snd_opl3sa2_put_double(struct snd_k 416 static int snd_opl3sa2_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) 414 { 417 { 415 struct snd_opl3sa2 *chip = snd_kcontro 418 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); 416 unsigned long flags; 419 unsigned long flags; 417 int left_reg = kcontrol->private_value 420 int left_reg = kcontrol->private_value & 0xff; 418 int right_reg = (kcontrol->private_val 421 int right_reg = (kcontrol->private_value >> 8) & 0xff; 419 int shift_left = (kcontrol->private_va 422 int shift_left = (kcontrol->private_value >> 16) & 0x07; 420 int shift_right = (kcontrol->private_v 423 int shift_right = (kcontrol->private_value >> 19) & 0x07; 421 int mask = (kcontrol->private_value >> 424 int mask = (kcontrol->private_value >> 24) & 0xff; 422 int invert = (kcontrol->private_value 425 int invert = (kcontrol->private_value >> 22) & 1; 423 int change; 426 int change; 424 unsigned short val1, val2, oval1, oval 427 unsigned short val1, val2, oval1, oval2; 425 428 426 val1 = ucontrol->value.integer.value[0 429 val1 = ucontrol->value.integer.value[0] & mask; 427 val2 = ucontrol->value.integer.value[1 430 val2 = ucontrol->value.integer.value[1] & mask; 428 if (invert) { 431 if (invert) { 429 val1 = mask - val1; 432 val1 = mask - val1; 430 val2 = mask - val2; 433 val2 = mask - val2; 431 } 434 } 432 val1 <<= shift_left; 435 val1 <<= shift_left; 433 val2 <<= shift_right; 436 val2 <<= shift_right; 434 spin_lock_irqsave(&chip->reg_lock, fla 437 spin_lock_irqsave(&chip->reg_lock, flags); 435 if (left_reg != right_reg) { 438 if (left_reg != right_reg) { 436 oval1 = chip->ctlregs[left_reg 439 oval1 = chip->ctlregs[left_reg]; 437 oval2 = chip->ctlregs[right_re 440 oval2 = chip->ctlregs[right_reg]; 438 val1 = (oval1 & ~(mask << shif 441 val1 = (oval1 & ~(mask << shift_left)) | val1; 439 val2 = (oval2 & ~(mask << shif 442 val2 = (oval2 & ~(mask << shift_right)) | val2; 440 change = val1 != oval1 || val2 443 change = val1 != oval1 || val2 != oval2; 441 __snd_opl3sa2_write(chip, left 444 __snd_opl3sa2_write(chip, left_reg, val1); 442 __snd_opl3sa2_write(chip, righ 445 __snd_opl3sa2_write(chip, right_reg, val2); 443 } else { 446 } else { 444 oval1 = chip->ctlregs[left_reg 447 oval1 = chip->ctlregs[left_reg]; 445 val1 = (oval1 & ~((mask << shi 448 val1 = (oval1 & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2; 446 change = val1 != oval1; 449 change = val1 != oval1; 447 __snd_opl3sa2_write(chip, left 450 __snd_opl3sa2_write(chip, left_reg, val1); 448 } 451 } 449 spin_unlock_irqrestore(&chip->reg_lock 452 spin_unlock_irqrestore(&chip->reg_lock, flags); 450 return change; 453 return change; 451 } 454 } 452 455 453 static const DECLARE_TLV_DB_SCALE(db_scale_mas 456 static const DECLARE_TLV_DB_SCALE(db_scale_master, -3000, 200, 0); 454 static const DECLARE_TLV_DB_SCALE(db_scale_5bi 457 static const DECLARE_TLV_DB_SCALE(db_scale_5bit_12db_max, -3450, 150, 0); 455 458 456 static const struct snd_kcontrol_new snd_opl3s 459 static const struct snd_kcontrol_new snd_opl3sa2_controls[] = { 457 OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x 460 OPL3SA2_DOUBLE("Master Playback Switch", 0, 0x07, 0x08, 7, 7, 1, 1), 458 OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0 461 OPL3SA2_DOUBLE_TLV("Master Playback Volume", 0, 0x07, 0x08, 0, 0, 15, 1, 459 db_scale_master), 462 db_scale_master), 460 OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 463 OPL3SA2_SINGLE("Mic Playback Switch", 0, 0x09, 7, 1, 1), 461 OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0 464 OPL3SA2_SINGLE_TLV("Mic Playback Volume", 0, 0x09, 0, 31, 1, 462 db_scale_5bit_12db_max), 465 db_scale_5bit_12db_max), 463 OPL3SA2_SINGLE("ZV Port Switch", 0, 0x02, 0, 1 466 OPL3SA2_SINGLE("ZV Port Switch", 0, 0x02, 0, 1, 0), 464 }; 467 }; 465 468 466 static const struct snd_kcontrol_new snd_opl3s 469 static const struct snd_kcontrol_new snd_opl3sa2_tone_controls[] = { 467 OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0 470 OPL3SA2_DOUBLE("3D Control - Wide", 0, 0x14, 0x14, 4, 0, 7, 0), 468 OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 471 OPL3SA2_DOUBLE("Tone Control - Bass", 0, 0x15, 0x15, 4, 0, 7, 0), 469 OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x1 472 OPL3SA2_DOUBLE("Tone Control - Treble", 0, 0x16, 0x16, 4, 0, 7, 0) 470 }; 473 }; 471 474 472 static void snd_opl3sa2_master_free(struct snd 475 static void snd_opl3sa2_master_free(struct snd_kcontrol *kcontrol) 473 { 476 { 474 struct snd_opl3sa2 *chip = snd_kcontro 477 struct snd_opl3sa2 *chip = snd_kcontrol_chip(kcontrol); 475 chip->master_switch = NULL; 478 chip->master_switch = NULL; 476 chip->master_volume = NULL; 479 chip->master_volume = NULL; 477 } 480 } 478 481 479 static int snd_opl3sa2_mixer(struct snd_card * 482 static int snd_opl3sa2_mixer(struct snd_card *card) 480 { 483 { 481 struct snd_opl3sa2 *chip = card->priva 484 struct snd_opl3sa2 *chip = card->private_data; 482 struct snd_ctl_elem_id id1, id2; 485 struct snd_ctl_elem_id id1, id2; 483 struct snd_kcontrol *kctl; 486 struct snd_kcontrol *kctl; 484 unsigned int idx; 487 unsigned int idx; 485 int err; 488 int err; 486 489 487 memset(&id1, 0, sizeof(id1)); 490 memset(&id1, 0, sizeof(id1)); 488 memset(&id2, 0, sizeof(id2)); 491 memset(&id2, 0, sizeof(id2)); 489 id1.iface = id2.iface = SNDRV_CTL_ELEM 492 id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER; 490 /* reassign AUX0 to CD */ 493 /* reassign AUX0 to CD */ 491 strcpy(id1.name, "Aux Playback Switch" 494 strcpy(id1.name, "Aux Playback Switch"); 492 strcpy(id2.name, "CD Playback Switch") 495 strcpy(id2.name, "CD Playback Switch"); 493 err = snd_ctl_rename_id(card, &id1, &i 496 err = snd_ctl_rename_id(card, &id1, &id2); 494 if (err < 0) { 497 if (err < 0) { 495 dev_err(card->dev, "Cannot ren !! 498 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); 496 return err; 499 return err; 497 } 500 } 498 strcpy(id1.name, "Aux Playback Volume" 501 strcpy(id1.name, "Aux Playback Volume"); 499 strcpy(id2.name, "CD Playback Volume") 502 strcpy(id2.name, "CD Playback Volume"); 500 err = snd_ctl_rename_id(card, &id1, &i 503 err = snd_ctl_rename_id(card, &id1, &id2); 501 if (err < 0) { 504 if (err < 0) { 502 dev_err(card->dev, "Cannot ren !! 505 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); 503 return err; 506 return err; 504 } 507 } 505 /* reassign AUX1 to FM */ 508 /* reassign AUX1 to FM */ 506 strcpy(id1.name, "Aux Playback Switch" 509 strcpy(id1.name, "Aux Playback Switch"); id1.index = 1; 507 strcpy(id2.name, "FM Playback Switch") 510 strcpy(id2.name, "FM Playback Switch"); 508 err = snd_ctl_rename_id(card, &id1, &i 511 err = snd_ctl_rename_id(card, &id1, &id2); 509 if (err < 0) { 512 if (err < 0) { 510 dev_err(card->dev, "Cannot ren !! 513 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); 511 return err; 514 return err; 512 } 515 } 513 strcpy(id1.name, "Aux Playback Volume" 516 strcpy(id1.name, "Aux Playback Volume"); 514 strcpy(id2.name, "FM Playback Volume") 517 strcpy(id2.name, "FM Playback Volume"); 515 err = snd_ctl_rename_id(card, &id1, &i 518 err = snd_ctl_rename_id(card, &id1, &id2); 516 if (err < 0) { 519 if (err < 0) { 517 dev_err(card->dev, "Cannot ren !! 520 snd_printk(KERN_ERR "Cannot rename opl3sa2 control\n"); 518 return err; 521 return err; 519 } 522 } 520 /* add OPL3SA2 controls */ 523 /* add OPL3SA2 controls */ 521 for (idx = 0; idx < ARRAY_SIZE(snd_opl 524 for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_controls); idx++) { 522 kctl = snd_ctl_new1(&snd_opl3s 525 kctl = snd_ctl_new1(&snd_opl3sa2_controls[idx], chip); 523 err = snd_ctl_add(card, kctl); 526 err = snd_ctl_add(card, kctl); 524 if (err < 0) 527 if (err < 0) 525 return err; 528 return err; 526 switch (idx) { 529 switch (idx) { 527 case 0: chip->master_switch = 530 case 0: chip->master_switch = kctl; kctl->private_free = snd_opl3sa2_master_free; break; 528 case 1: chip->master_volume = 531 case 1: chip->master_volume = kctl; kctl->private_free = snd_opl3sa2_master_free; break; 529 } 532 } 530 } 533 } 531 if (chip->version > 2) { 534 if (chip->version > 2) { 532 for (idx = 0; idx < ARRAY_SIZE 535 for (idx = 0; idx < ARRAY_SIZE(snd_opl3sa2_tone_controls); idx++) { 533 err = snd_ctl_add(card 536 err = snd_ctl_add(card, snd_ctl_new1(&snd_opl3sa2_tone_controls[idx], chip)); 534 if (err < 0) 537 if (err < 0) 535 return err; 538 return err; 536 } 539 } 537 } 540 } 538 return 0; 541 return 0; 539 } 542 } 540 543 541 /* Power Management support functions */ 544 /* Power Management support functions */ 542 #ifdef CONFIG_PM 545 #ifdef CONFIG_PM 543 static int snd_opl3sa2_suspend(struct snd_card 546 static int snd_opl3sa2_suspend(struct snd_card *card, pm_message_t state) 544 { 547 { 545 if (card) { 548 if (card) { 546 struct snd_opl3sa2 *chip = car 549 struct snd_opl3sa2 *chip = card->private_data; 547 550 548 snd_power_change_state(card, S 551 snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); 549 chip->wss->suspend(chip->wss); 552 chip->wss->suspend(chip->wss); 550 /* power down */ 553 /* power down */ 551 snd_opl3sa2_write(chip, OPL3SA 554 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D3); 552 } 555 } 553 556 554 return 0; 557 return 0; 555 } 558 } 556 559 557 static int snd_opl3sa2_resume(struct snd_card 560 static int snd_opl3sa2_resume(struct snd_card *card) 558 { 561 { 559 struct snd_opl3sa2 *chip; 562 struct snd_opl3sa2 *chip; 560 int i; 563 int i; 561 564 562 if (!card) 565 if (!card) 563 return 0; 566 return 0; 564 567 565 chip = card->private_data; 568 chip = card->private_data; 566 /* power up */ 569 /* power up */ 567 snd_opl3sa2_write(chip, OPL3SA2_PM_CTR 570 snd_opl3sa2_write(chip, OPL3SA2_PM_CTRL, OPL3SA2_PM_D0); 568 571 569 /* restore registers */ 572 /* restore registers */ 570 for (i = 2; i <= 0x0a; i++) { 573 for (i = 2; i <= 0x0a; i++) { 571 if (i != OPL3SA2_IRQ_STATUS) 574 if (i != OPL3SA2_IRQ_STATUS) 572 snd_opl3sa2_write(chip 575 snd_opl3sa2_write(chip, i, chip->ctlregs[i]); 573 } 576 } 574 if (chip->version > 2) { 577 if (chip->version > 2) { 575 for (i = 0x12; i <= 0x16; i++) 578 for (i = 0x12; i <= 0x16; i++) 576 snd_opl3sa2_write(chip 579 snd_opl3sa2_write(chip, i, chip->ctlregs[i]); 577 } 580 } 578 /* restore wss */ 581 /* restore wss */ 579 chip->wss->resume(chip->wss); 582 chip->wss->resume(chip->wss); 580 583 581 snd_power_change_state(card, SNDRV_CTL 584 snd_power_change_state(card, SNDRV_CTL_POWER_D0); 582 return 0; 585 return 0; 583 } 586 } 584 #endif /* CONFIG_PM */ 587 #endif /* CONFIG_PM */ 585 588 586 #ifdef CONFIG_PNP 589 #ifdef CONFIG_PNP 587 static int snd_opl3sa2_pnp(int dev, struct snd 590 static int snd_opl3sa2_pnp(int dev, struct snd_opl3sa2 *chip, 588 struct pnp_dev *pde 591 struct pnp_dev *pdev) 589 { 592 { 590 if (pnp_activate_dev(pdev) < 0) { 593 if (pnp_activate_dev(pdev) < 0) { 591 dev_err(chip->card->dev, "PnP !! 594 snd_printk(KERN_ERR "PnP configure failure (out of resources?)\n"); 592 return -EBUSY; 595 return -EBUSY; 593 } 596 } 594 sb_port[dev] = pnp_port_start(pdev, 0) 597 sb_port[dev] = pnp_port_start(pdev, 0); 595 wss_port[dev] = pnp_port_start(pdev, 1 598 wss_port[dev] = pnp_port_start(pdev, 1); 596 fm_port[dev] = pnp_port_start(pdev, 2) 599 fm_port[dev] = pnp_port_start(pdev, 2); 597 midi_port[dev] = pnp_port_start(pdev, 600 midi_port[dev] = pnp_port_start(pdev, 3); 598 port[dev] = pnp_port_start(pdev, 4); 601 port[dev] = pnp_port_start(pdev, 4); 599 dma1[dev] = pnp_dma(pdev, 0); 602 dma1[dev] = pnp_dma(pdev, 0); 600 dma2[dev] = pnp_dma(pdev, 1); 603 dma2[dev] = pnp_dma(pdev, 1); 601 irq[dev] = pnp_irq(pdev, 0); 604 irq[dev] = pnp_irq(pdev, 0); 602 dev_dbg(chip->card->dev, "%sPnP OPL3-S !! 605 snd_printdd("%sPnP OPL3-SA: sb port=0x%lx, wss port=0x%lx, fm port=0x%lx, midi port=0x%lx\n", 603 pnp_device_is_pnpbios(pdev) ? 606 pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", sb_port[dev], wss_port[dev], fm_port[dev], midi_port[dev]); 604 dev_dbg(chip->card->dev, "%sPnP OPL3-S !! 607 snd_printdd("%sPnP OPL3-SA: control port=0x%lx, dma1=%i, dma2=%i, irq=%i\n", 605 pnp_device_is_pnpbios(pdev) ? 608 pnp_device_is_pnpbios(pdev) ? "BIOS" : "ISA", port[dev], dma1[dev], dma2[dev], irq[dev]); 606 return 0; 609 return 0; 607 } 610 } 608 #endif /* CONFIG_PNP */ 611 #endif /* CONFIG_PNP */ 609 612 610 static int snd_opl3sa2_card_new(struct device 613 static int snd_opl3sa2_card_new(struct device *pdev, int dev, 611 struct snd_car 614 struct snd_card **cardp) 612 { 615 { 613 struct snd_card *card; 616 struct snd_card *card; 614 struct snd_opl3sa2 *chip; 617 struct snd_opl3sa2 *chip; 615 int err; 618 int err; 616 619 617 err = snd_devm_card_new(pdev, index[de 620 err = snd_devm_card_new(pdev, index[dev], id[dev], THIS_MODULE, 618 sizeof(struct 621 sizeof(struct snd_opl3sa2), &card); 619 if (err < 0) 622 if (err < 0) 620 return err; 623 return err; 621 strcpy(card->driver, "OPL3SA2"); 624 strcpy(card->driver, "OPL3SA2"); 622 strcpy(card->shortname, "Yamaha OPL3-S 625 strcpy(card->shortname, "Yamaha OPL3-SA"); 623 chip = card->private_data; 626 chip = card->private_data; 624 spin_lock_init(&chip->reg_lock); 627 spin_lock_init(&chip->reg_lock); 625 chip->irq = -1; 628 chip->irq = -1; 626 *cardp = card; 629 *cardp = card; 627 return 0; 630 return 0; 628 } 631 } 629 632 630 static int snd_opl3sa2_probe(struct snd_card * 633 static int snd_opl3sa2_probe(struct snd_card *card, int dev) 631 { 634 { 632 int xirq, xdma1, xdma2; 635 int xirq, xdma1, xdma2; 633 struct snd_opl3sa2 *chip; 636 struct snd_opl3sa2 *chip; 634 struct snd_wss *wss; 637 struct snd_wss *wss; 635 struct snd_opl3 *opl3; 638 struct snd_opl3 *opl3; 636 int err; 639 int err; 637 640 638 /* initialise this card from supplied 641 /* initialise this card from supplied (or default) parameter*/ 639 chip = card->private_data; 642 chip = card->private_data; 640 chip->card = card; << 641 chip->ymode = opl3sa3_ymode[dev] & 0x0 643 chip->ymode = opl3sa3_ymode[dev] & 0x03 ; 642 chip->port = port[dev]; 644 chip->port = port[dev]; 643 xirq = irq[dev]; 645 xirq = irq[dev]; 644 xdma1 = dma1[dev]; 646 xdma1 = dma1[dev]; 645 xdma2 = dma2[dev]; 647 xdma2 = dma2[dev]; 646 if (xdma2 < 0) 648 if (xdma2 < 0) 647 chip->single_dma = 1; 649 chip->single_dma = 1; 648 err = snd_opl3sa2_detect(card); 650 err = snd_opl3sa2_detect(card); 649 if (err < 0) 651 if (err < 0) 650 return err; 652 return err; 651 err = devm_request_irq(card->dev, xirq 653 err = devm_request_irq(card->dev, xirq, snd_opl3sa2_interrupt, 0, 652 "OPL3-SA2", car 654 "OPL3-SA2", card); 653 if (err) { 655 if (err) { 654 dev_err(card->dev, "can't grab !! 656 snd_printk(KERN_ERR PFX "can't grab IRQ %d\n", xirq); 655 return -ENODEV; 657 return -ENODEV; 656 } 658 } 657 chip->irq = xirq; 659 chip->irq = xirq; 658 card->sync_irq = chip->irq; 660 card->sync_irq = chip->irq; 659 err = snd_wss_create(card, 661 err = snd_wss_create(card, 660 wss_port[dev] + 4 662 wss_port[dev] + 4, -1, 661 xirq, xdma1, xdma 663 xirq, xdma1, xdma2, 662 WSS_HW_OPL3SA2, W 664 WSS_HW_OPL3SA2, WSS_HWSHARE_IRQ, &wss); 663 if (err < 0) { 665 if (err < 0) { 664 dev_dbg(card->dev, "Oops, WSS !! 666 snd_printd("Oops, WSS not detected at 0x%lx\n", wss_port[dev] + 4); 665 return err; 667 return err; 666 } 668 } 667 chip->wss = wss; 669 chip->wss = wss; 668 err = snd_wss_pcm(wss, 0); 670 err = snd_wss_pcm(wss, 0); 669 if (err < 0) 671 if (err < 0) 670 return err; 672 return err; 671 err = snd_wss_mixer(wss); 673 err = snd_wss_mixer(wss); 672 if (err < 0) 674 if (err < 0) 673 return err; 675 return err; 674 err = snd_opl3sa2_mixer(card); 676 err = snd_opl3sa2_mixer(card); 675 if (err < 0) 677 if (err < 0) 676 return err; 678 return err; 677 err = snd_wss_timer(wss, 0); 679 err = snd_wss_timer(wss, 0); 678 if (err < 0) 680 if (err < 0) 679 return err; 681 return err; 680 if (fm_port[dev] >= 0x340 && fm_port[d 682 if (fm_port[dev] >= 0x340 && fm_port[dev] < 0x400) { 681 err = snd_opl3_create(card, fm 683 err = snd_opl3_create(card, fm_port[dev], 682 fm_port[ 684 fm_port[dev] + 2, 683 OPL3_HW_ 685 OPL3_HW_OPL3, 0, &opl3); 684 if (err < 0) 686 if (err < 0) 685 return err; 687 return err; 686 err = snd_opl3_timer_new(opl3, 688 err = snd_opl3_timer_new(opl3, 1, 2); 687 if (err < 0) 689 if (err < 0) 688 return err; 690 return err; 689 err = snd_opl3_hwdep_new(opl3, 691 err = snd_opl3_hwdep_new(opl3, 0, 1, &chip->synth); 690 if (err < 0) 692 if (err < 0) 691 return err; 693 return err; 692 } 694 } 693 if (midi_port[dev] >= 0x300 && midi_po 695 if (midi_port[dev] >= 0x300 && midi_port[dev] < 0x340) { 694 err = snd_mpu401_uart_new(card 696 err = snd_mpu401_uart_new(card, 0, MPU401_HW_OPL3SA2, 695 midi 697 midi_port[dev], 696 MPU4 698 MPU401_INFO_IRQ_HOOK, -1, 697 &chi 699 &chip->rmidi); 698 if (err < 0) 700 if (err < 0) 699 return err; 701 return err; 700 } 702 } 701 sprintf(card->longname, "%s at 0x%lx, 703 sprintf(card->longname, "%s at 0x%lx, irq %d, dma %d", 702 card->shortname, chip->port, x 704 card->shortname, chip->port, xirq, xdma1); 703 if (xdma2 >= 0) 705 if (xdma2 >= 0) 704 sprintf(card->longname + strle 706 sprintf(card->longname + strlen(card->longname), "&%d", xdma2); 705 707 706 return snd_card_register(card); 708 return snd_card_register(card); 707 } 709 } 708 710 709 #ifdef CONFIG_PNP 711 #ifdef CONFIG_PNP 710 static int snd_opl3sa2_pnp_detect(struct pnp_d 712 static int snd_opl3sa2_pnp_detect(struct pnp_dev *pdev, 711 const struct 713 const struct pnp_device_id *id) 712 { 714 { 713 static int dev; 715 static int dev; 714 int err; 716 int err; 715 struct snd_card *card; 717 struct snd_card *card; 716 718 717 if (pnp_device_is_isapnp(pdev)) 719 if (pnp_device_is_isapnp(pdev)) 718 return -ENOENT; /* we have ano 720 return -ENOENT; /* we have another procedure - card */ 719 for (; dev < SNDRV_CARDS; dev++) { 721 for (; dev < SNDRV_CARDS; dev++) { 720 if (enable[dev] && isapnp[dev] 722 if (enable[dev] && isapnp[dev]) 721 break; 723 break; 722 } 724 } 723 if (dev >= SNDRV_CARDS) 725 if (dev >= SNDRV_CARDS) 724 return -ENODEV; 726 return -ENODEV; 725 727 726 err = snd_opl3sa2_card_new(&pdev->dev, 728 err = snd_opl3sa2_card_new(&pdev->dev, dev, &card); 727 if (err < 0) 729 if (err < 0) 728 return err; 730 return err; 729 err = snd_opl3sa2_pnp(dev, card->priva 731 err = snd_opl3sa2_pnp(dev, card->private_data, pdev); 730 if (err < 0) 732 if (err < 0) 731 return err; 733 return err; 732 err = snd_opl3sa2_probe(card, dev); 734 err = snd_opl3sa2_probe(card, dev); 733 if (err < 0) 735 if (err < 0) 734 return err; 736 return err; 735 pnp_set_drvdata(pdev, card); 737 pnp_set_drvdata(pdev, card); 736 dev++; 738 dev++; 737 return 0; 739 return 0; 738 } 740 } 739 741 740 #ifdef CONFIG_PM 742 #ifdef CONFIG_PM 741 static int snd_opl3sa2_pnp_suspend(struct pnp_ 743 static int snd_opl3sa2_pnp_suspend(struct pnp_dev *pdev, pm_message_t state) 742 { 744 { 743 return snd_opl3sa2_suspend(pnp_get_drv 745 return snd_opl3sa2_suspend(pnp_get_drvdata(pdev), state); 744 } 746 } 745 static int snd_opl3sa2_pnp_resume(struct pnp_d 747 static int snd_opl3sa2_pnp_resume(struct pnp_dev *pdev) 746 { 748 { 747 return snd_opl3sa2_resume(pnp_get_drvd 749 return snd_opl3sa2_resume(pnp_get_drvdata(pdev)); 748 } 750 } 749 #endif 751 #endif 750 752 751 static struct pnp_driver opl3sa2_pnp_driver = 753 static struct pnp_driver opl3sa2_pnp_driver = { 752 .name = "snd-opl3sa2-pnpbios", 754 .name = "snd-opl3sa2-pnpbios", 753 .id_table = snd_opl3sa2_pnpbiosids, 755 .id_table = snd_opl3sa2_pnpbiosids, 754 .probe = snd_opl3sa2_pnp_detect, 756 .probe = snd_opl3sa2_pnp_detect, 755 #ifdef CONFIG_PM 757 #ifdef CONFIG_PM 756 .suspend = snd_opl3sa2_pnp_suspend, 758 .suspend = snd_opl3sa2_pnp_suspend, 757 .resume = snd_opl3sa2_pnp_resume, 759 .resume = snd_opl3sa2_pnp_resume, 758 #endif 760 #endif 759 }; 761 }; 760 762 761 static int snd_opl3sa2_pnp_cdetect(struct pnp_ 763 static int snd_opl3sa2_pnp_cdetect(struct pnp_card_link *pcard, 762 const struc 764 const struct pnp_card_device_id *id) 763 { 765 { 764 static int dev; 766 static int dev; 765 struct pnp_dev *pdev; 767 struct pnp_dev *pdev; 766 int err; 768 int err; 767 struct snd_card *card; 769 struct snd_card *card; 768 770 769 pdev = pnp_request_card_device(pcard, 771 pdev = pnp_request_card_device(pcard, id->devs[0].id, NULL); 770 if (pdev == NULL) { 772 if (pdev == NULL) { 771 dev_err(&pcard->card->dev, "ca !! 773 snd_printk(KERN_ERR PFX "can't get pnp device from id '%s'\n", 772 id->devs[0].id); 774 id->devs[0].id); 773 return -EBUSY; 775 return -EBUSY; 774 } 776 } 775 for (; dev < SNDRV_CARDS; dev++) { 777 for (; dev < SNDRV_CARDS; dev++) { 776 if (enable[dev] && isapnp[dev] 778 if (enable[dev] && isapnp[dev]) 777 break; 779 break; 778 } 780 } 779 if (dev >= SNDRV_CARDS) 781 if (dev >= SNDRV_CARDS) 780 return -ENODEV; 782 return -ENODEV; 781 783 782 err = snd_opl3sa2_card_new(&pdev->dev, 784 err = snd_opl3sa2_card_new(&pdev->dev, dev, &card); 783 if (err < 0) 785 if (err < 0) 784 return err; 786 return err; 785 err = snd_opl3sa2_pnp(dev, card->priva 787 err = snd_opl3sa2_pnp(dev, card->private_data, pdev); 786 if (err < 0) 788 if (err < 0) 787 return err; 789 return err; 788 err = snd_opl3sa2_probe(card, dev); 790 err = snd_opl3sa2_probe(card, dev); 789 if (err < 0) 791 if (err < 0) 790 return err; 792 return err; 791 pnp_set_card_drvdata(pcard, card); 793 pnp_set_card_drvdata(pcard, card); 792 dev++; 794 dev++; 793 return 0; 795 return 0; 794 } 796 } 795 797 796 #ifdef CONFIG_PM 798 #ifdef CONFIG_PM 797 static int snd_opl3sa2_pnp_csuspend(struct pnp 799 static int snd_opl3sa2_pnp_csuspend(struct pnp_card_link *pcard, pm_message_t state) 798 { 800 { 799 return snd_opl3sa2_suspend(pnp_get_car 801 return snd_opl3sa2_suspend(pnp_get_card_drvdata(pcard), state); 800 } 802 } 801 static int snd_opl3sa2_pnp_cresume(struct pnp_ 803 static int snd_opl3sa2_pnp_cresume(struct pnp_card_link *pcard) 802 { 804 { 803 return snd_opl3sa2_resume(pnp_get_card 805 return snd_opl3sa2_resume(pnp_get_card_drvdata(pcard)); 804 } 806 } 805 #endif 807 #endif 806 808 807 static struct pnp_card_driver opl3sa2_pnpc_dri 809 static struct pnp_card_driver opl3sa2_pnpc_driver = { 808 .flags = PNP_DRIVER_RES_DISABLE, 810 .flags = PNP_DRIVER_RES_DISABLE, 809 .name = "snd-opl3sa2-cpnp", 811 .name = "snd-opl3sa2-cpnp", 810 .id_table = snd_opl3sa2_pnpids, 812 .id_table = snd_opl3sa2_pnpids, 811 .probe = snd_opl3sa2_pnp_cdetect, 813 .probe = snd_opl3sa2_pnp_cdetect, 812 #ifdef CONFIG_PM 814 #ifdef CONFIG_PM 813 .suspend = snd_opl3sa2_pnp_csuspend, 815 .suspend = snd_opl3sa2_pnp_csuspend, 814 .resume = snd_opl3sa2_pnp_cresume, 816 .resume = snd_opl3sa2_pnp_cresume, 815 #endif 817 #endif 816 }; 818 }; 817 #endif /* CONFIG_PNP */ 819 #endif /* CONFIG_PNP */ 818 820 819 static int snd_opl3sa2_isa_match(struct device 821 static int snd_opl3sa2_isa_match(struct device *pdev, 820 unsigned int 822 unsigned int dev) 821 { 823 { 822 if (!enable[dev]) 824 if (!enable[dev]) 823 return 0; 825 return 0; 824 #ifdef CONFIG_PNP 826 #ifdef CONFIG_PNP 825 if (isapnp[dev]) 827 if (isapnp[dev]) 826 return 0; 828 return 0; 827 #endif 829 #endif 828 if (port[dev] == SNDRV_AUTO_PORT) { 830 if (port[dev] == SNDRV_AUTO_PORT) { 829 dev_err(pdev, "specify port\n" !! 831 snd_printk(KERN_ERR PFX "specify port\n"); 830 return 0; 832 return 0; 831 } 833 } 832 if (wss_port[dev] == SNDRV_AUTO_PORT) 834 if (wss_port[dev] == SNDRV_AUTO_PORT) { 833 dev_err(pdev, "specify wss_por !! 835 snd_printk(KERN_ERR PFX "specify wss_port\n"); 834 return 0; 836 return 0; 835 } 837 } 836 if (fm_port[dev] == SNDRV_AUTO_PORT) { 838 if (fm_port[dev] == SNDRV_AUTO_PORT) { 837 dev_err(pdev, "specify fm_port !! 839 snd_printk(KERN_ERR PFX "specify fm_port\n"); 838 return 0; 840 return 0; 839 } 841 } 840 if (midi_port[dev] == SNDRV_AUTO_PORT) 842 if (midi_port[dev] == SNDRV_AUTO_PORT) { 841 dev_err(pdev, "specify midi_po !! 843 snd_printk(KERN_ERR PFX "specify midi_port\n"); 842 return 0; 844 return 0; 843 } 845 } 844 return 1; 846 return 1; 845 } 847 } 846 848 847 static int snd_opl3sa2_isa_probe(struct device 849 static int snd_opl3sa2_isa_probe(struct device *pdev, 848 unsigned int 850 unsigned int dev) 849 { 851 { 850 struct snd_card *card; 852 struct snd_card *card; 851 int err; 853 int err; 852 854 853 err = snd_opl3sa2_card_new(pdev, dev, 855 err = snd_opl3sa2_card_new(pdev, dev, &card); 854 if (err < 0) 856 if (err < 0) 855 return err; 857 return err; 856 err = snd_opl3sa2_probe(card, dev); 858 err = snd_opl3sa2_probe(card, dev); 857 if (err < 0) 859 if (err < 0) 858 return err; 860 return err; 859 dev_set_drvdata(pdev, card); 861 dev_set_drvdata(pdev, card); 860 return 0; 862 return 0; 861 } 863 } 862 864 863 #ifdef CONFIG_PM 865 #ifdef CONFIG_PM 864 static int snd_opl3sa2_isa_suspend(struct devi 866 static int snd_opl3sa2_isa_suspend(struct device *dev, unsigned int n, 865 pm_message_ 867 pm_message_t state) 866 { 868 { 867 return snd_opl3sa2_suspend(dev_get_drv 869 return snd_opl3sa2_suspend(dev_get_drvdata(dev), state); 868 } 870 } 869 871 870 static int snd_opl3sa2_isa_resume(struct devic 872 static int snd_opl3sa2_isa_resume(struct device *dev, unsigned int n) 871 { 873 { 872 return snd_opl3sa2_resume(dev_get_drvd 874 return snd_opl3sa2_resume(dev_get_drvdata(dev)); 873 } 875 } 874 #endif 876 #endif 875 877 876 #define DEV_NAME "opl3sa2" 878 #define DEV_NAME "opl3sa2" 877 879 878 static struct isa_driver snd_opl3sa2_isa_drive 880 static struct isa_driver snd_opl3sa2_isa_driver = { 879 .match = snd_opl3sa2_isa_matc 881 .match = snd_opl3sa2_isa_match, 880 .probe = snd_opl3sa2_isa_prob 882 .probe = snd_opl3sa2_isa_probe, 881 #ifdef CONFIG_PM 883 #ifdef CONFIG_PM 882 .suspend = snd_opl3sa2_isa_susp 884 .suspend = snd_opl3sa2_isa_suspend, 883 .resume = snd_opl3sa2_isa_resu 885 .resume = snd_opl3sa2_isa_resume, 884 #endif 886 #endif 885 .driver = { 887 .driver = { 886 .name = DEV_NAME 888 .name = DEV_NAME 887 }, 889 }, 888 }; 890 }; 889 891 890 static int __init alsa_card_opl3sa2_init(void) 892 static int __init alsa_card_opl3sa2_init(void) 891 { 893 { 892 int err; 894 int err; 893 895 894 err = isa_register_driver(&snd_opl3sa2 896 err = isa_register_driver(&snd_opl3sa2_isa_driver, SNDRV_CARDS); 895 #ifdef CONFIG_PNP 897 #ifdef CONFIG_PNP 896 if (!err) 898 if (!err) 897 isa_registered = 1; 899 isa_registered = 1; 898 900 899 err = pnp_register_driver(&opl3sa2_pnp 901 err = pnp_register_driver(&opl3sa2_pnp_driver); 900 if (!err) 902 if (!err) 901 pnp_registered = 1; 903 pnp_registered = 1; 902 904 903 err = pnp_register_card_driver(&opl3sa 905 err = pnp_register_card_driver(&opl3sa2_pnpc_driver); 904 if (!err) 906 if (!err) 905 pnpc_registered = 1; 907 pnpc_registered = 1; 906 908 907 if (isa_registered || pnp_registered) 909 if (isa_registered || pnp_registered) 908 err = 0; 910 err = 0; 909 #endif 911 #endif 910 return err; 912 return err; 911 } 913 } 912 914 913 static void __exit alsa_card_opl3sa2_exit(void 915 static void __exit alsa_card_opl3sa2_exit(void) 914 { 916 { 915 #ifdef CONFIG_PNP 917 #ifdef CONFIG_PNP 916 if (pnpc_registered) 918 if (pnpc_registered) 917 pnp_unregister_card_driver(&op 919 pnp_unregister_card_driver(&opl3sa2_pnpc_driver); 918 if (pnp_registered) 920 if (pnp_registered) 919 pnp_unregister_driver(&opl3sa2 921 pnp_unregister_driver(&opl3sa2_pnp_driver); 920 if (isa_registered) 922 if (isa_registered) 921 #endif 923 #endif 922 isa_unregister_driver(&snd_opl 924 isa_unregister_driver(&snd_opl3sa2_isa_driver); 923 } 925 } 924 926 925 module_init(alsa_card_opl3sa2_init) 927 module_init(alsa_card_opl3sa2_init) 926 module_exit(alsa_card_opl3sa2_exit) 928 module_exit(alsa_card_opl3sa2_exit) 927 929
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.