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