opl3sa2.c 30 KB

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