opti92x-ad1848.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. /*
  2. card-opti92x-ad1848.c - driver for OPTi 82c92x based soundcards.
  3. Copyright (C) 1998-2000 by Massimo Piccioni <dafastidio@libero.it>
  4. Part of this code was developed at the Italian Ministry of Air Defence,
  5. Sixth Division (oh, che pace ...), Rome.
  6. Thanks to Maria Grazia Pollarini, Salvatore Vassallo.
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #include <linux/init.h>
  20. #include <linux/err.h>
  21. #include <linux/isa.h>
  22. #include <linux/delay.h>
  23. #include <linux/pnp.h>
  24. #include <linux/moduleparam.h>
  25. #include <asm/io.h>
  26. #include <asm/dma.h>
  27. #include <sound/core.h>
  28. #include <sound/tlv.h>
  29. #include <sound/wss.h>
  30. #include <sound/mpu401.h>
  31. #include <sound/opl3.h>
  32. #ifndef OPTi93X
  33. #include <sound/opl4.h>
  34. #endif
  35. #define SNDRV_LEGACY_FIND_FREE_IRQ
  36. #define SNDRV_LEGACY_FIND_FREE_DMA
  37. #include <sound/initval.h>
  38. MODULE_AUTHOR("Massimo Piccioni <dafastidio@libero.it>");
  39. MODULE_LICENSE("GPL");
  40. #ifdef OPTi93X
  41. MODULE_DESCRIPTION("OPTi93X");
  42. MODULE_SUPPORTED_DEVICE("{{OPTi,82C931/3}}");
  43. #else /* OPTi93X */
  44. #ifdef CS4231
  45. MODULE_DESCRIPTION("OPTi92X - CS4231");
  46. MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (CS4231)},"
  47. "{OPTi,82C925 (CS4231)}}");
  48. #else /* CS4231 */
  49. MODULE_DESCRIPTION("OPTi92X - AD1848");
  50. MODULE_SUPPORTED_DEVICE("{{OPTi,82C924 (AD1848)},"
  51. "{OPTi,82C925 (AD1848)},"
  52. "{OAK,Mozart}}");
  53. #endif /* CS4231 */
  54. #endif /* OPTi93X */
  55. static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
  56. static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
  57. //static int enable = SNDRV_DEFAULT_ENABLE1; /* Enable this card */
  58. #ifdef CONFIG_PNP
  59. static int isapnp = 1; /* Enable ISA PnP detection */
  60. #endif
  61. static long port = SNDRV_DEFAULT_PORT1; /* 0x530,0xe80,0xf40,0x604 */
  62. static long mpu_port = SNDRV_DEFAULT_PORT1; /* 0x300,0x310,0x320,0x330 */
  63. static long fm_port = SNDRV_DEFAULT_PORT1; /* 0x388 */
  64. static int irq = SNDRV_DEFAULT_IRQ1; /* 5,7,9,10,11 */
  65. static int mpu_irq = SNDRV_DEFAULT_IRQ1; /* 5,7,9,10 */
  66. static int dma1 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */
  67. #if defined(CS4231) || defined(OPTi93X)
  68. static int dma2 = SNDRV_DEFAULT_DMA1; /* 0,1,3 */
  69. #endif /* CS4231 || OPTi93X */
  70. module_param(index, int, 0444);
  71. MODULE_PARM_DESC(index, "Index value for opti9xx based soundcard.");
  72. module_param(id, charp, 0444);
  73. MODULE_PARM_DESC(id, "ID string for opti9xx based soundcard.");
  74. //module_param(enable, bool, 0444);
  75. //MODULE_PARM_DESC(enable, "Enable opti9xx soundcard.");
  76. #ifdef CONFIG_PNP
  77. module_param(isapnp, bool, 0444);
  78. MODULE_PARM_DESC(isapnp, "Enable ISA PnP detection for specified soundcard.");
  79. #endif
  80. module_param(port, long, 0444);
  81. MODULE_PARM_DESC(port, "WSS port # for opti9xx driver.");
  82. module_param(mpu_port, long, 0444);
  83. MODULE_PARM_DESC(mpu_port, "MPU-401 port # for opti9xx driver.");
  84. module_param(fm_port, long, 0444);
  85. MODULE_PARM_DESC(fm_port, "FM port # for opti9xx driver.");
  86. module_param(irq, int, 0444);
  87. MODULE_PARM_DESC(irq, "WSS irq # for opti9xx driver.");
  88. module_param(mpu_irq, int, 0444);
  89. MODULE_PARM_DESC(mpu_irq, "MPU-401 irq # for opti9xx driver.");
  90. module_param(dma1, int, 0444);
  91. MODULE_PARM_DESC(dma1, "1st dma # for opti9xx driver.");
  92. #if defined(CS4231) || defined(OPTi93X)
  93. module_param(dma2, int, 0444);
  94. MODULE_PARM_DESC(dma2, "2nd dma # for opti9xx driver.");
  95. #endif /* CS4231 || OPTi93X */
  96. #define OPTi9XX_HW_82C928 1
  97. #define OPTi9XX_HW_82C929 2
  98. #define OPTi9XX_HW_82C924 3
  99. #define OPTi9XX_HW_82C925 4
  100. #define OPTi9XX_HW_82C930 5
  101. #define OPTi9XX_HW_82C931 6
  102. #define OPTi9XX_HW_82C933 7
  103. #define OPTi9XX_HW_LAST OPTi9XX_HW_82C933
  104. #define OPTi9XX_MC_REG(n) n
  105. #ifdef OPTi93X
  106. #define OPTi93X_STATUS 0x02
  107. #define OPTi93X_PORT(chip, r) ((chip)->port + OPTi93X_##r)
  108. #define OPTi93X_IRQ_PLAYBACK 0x04
  109. #define OPTi93X_IRQ_CAPTURE 0x08
  110. #endif /* OPTi93X */
  111. struct snd_opti9xx {
  112. unsigned short hardware;
  113. unsigned char password;
  114. char name[7];
  115. unsigned long mc_base;
  116. struct resource *res_mc_base;
  117. unsigned long mc_base_size;
  118. #ifdef OPTi93X
  119. unsigned long mc_indir_index;
  120. unsigned long mc_indir_size;
  121. struct resource *res_mc_indir;
  122. struct snd_wss *codec;
  123. #endif /* OPTi93X */
  124. unsigned long pwd_reg;
  125. spinlock_t lock;
  126. long wss_base;
  127. int irq;
  128. };
  129. static int snd_opti9xx_pnp_is_probed;
  130. #ifdef CONFIG_PNP
  131. static struct pnp_card_device_id snd_opti9xx_pnpids[] = {
  132. #ifndef OPTi93X
  133. /* OPTi 82C924 */
  134. { .id = "OPT0924",
  135. .devs = { { "OPT0000" }, { "OPT0002" }, { "OPT0005" } },
  136. .driver_data = 0x0924 },
  137. /* OPTi 82C925 */
  138. { .id = "OPT0925",
  139. .devs = { { "OPT9250" }, { "OPT0002" }, { "OPT0005" } },
  140. .driver_data = 0x0925 },
  141. #else
  142. /* OPTi 82C931/3 */
  143. { .id = "OPT0931", .devs = { { "OPT9310" }, { "OPT0002" } },
  144. .driver_data = 0x0931 },
  145. #endif /* OPTi93X */
  146. { .id = "" }
  147. };
  148. MODULE_DEVICE_TABLE(pnp_card, snd_opti9xx_pnpids);
  149. #endif /* CONFIG_PNP */
  150. #ifdef OPTi93X
  151. #define DEV_NAME "opti93x"
  152. #else
  153. #define DEV_NAME "opti92x"
  154. #endif
  155. static char * snd_opti9xx_names[] = {
  156. "unknown",
  157. "82C928", "82C929",
  158. "82C924", "82C925",
  159. "82C930", "82C931", "82C933"
  160. };
  161. static long __devinit snd_legacy_find_free_ioport(long *port_table, long size)
  162. {
  163. while (*port_table != -1) {
  164. if (request_region(*port_table, size, "ALSA test")) {
  165. release_region(*port_table, size);
  166. return *port_table;
  167. }
  168. port_table++;
  169. }
  170. return -1;
  171. }
  172. static int __devinit snd_opti9xx_init(struct snd_opti9xx *chip,
  173. unsigned short hardware)
  174. {
  175. static int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
  176. chip->hardware = hardware;
  177. strcpy(chip->name, snd_opti9xx_names[hardware]);
  178. spin_lock_init(&chip->lock);
  179. chip->irq = -1;
  180. #ifndef OPTi93X
  181. #ifdef CONFIG_PNP
  182. if (isapnp && chip->mc_base)
  183. /* PnP resource gives the least 10 bits */
  184. chip->mc_base |= 0xc00;
  185. else
  186. #endif /* CONFIG_PNP */
  187. {
  188. chip->mc_base = 0xf8c;
  189. chip->mc_base_size = opti9xx_mc_size[hardware];
  190. }
  191. #else
  192. chip->mc_base_size = opti9xx_mc_size[hardware];
  193. #endif
  194. switch (hardware) {
  195. #ifndef OPTi93X
  196. case OPTi9XX_HW_82C928:
  197. case OPTi9XX_HW_82C929:
  198. chip->password = (hardware == OPTi9XX_HW_82C928) ? 0xe2 : 0xe3;
  199. chip->pwd_reg = 3;
  200. break;
  201. case OPTi9XX_HW_82C924:
  202. case OPTi9XX_HW_82C925:
  203. chip->password = 0xe5;
  204. chip->pwd_reg = 3;
  205. break;
  206. #else /* OPTi93X */
  207. case OPTi9XX_HW_82C930:
  208. case OPTi9XX_HW_82C931:
  209. case OPTi9XX_HW_82C933:
  210. chip->mc_base = (hardware == OPTi9XX_HW_82C930) ? 0xf8f : 0xf8d;
  211. if (!chip->mc_indir_index) {
  212. chip->mc_indir_index = 0xe0e;
  213. chip->mc_indir_size = 2;
  214. }
  215. chip->password = 0xe4;
  216. chip->pwd_reg = 0;
  217. break;
  218. #endif /* OPTi93X */
  219. default:
  220. snd_printk(KERN_ERR "chip %d not supported\n", hardware);
  221. return -ENODEV;
  222. }
  223. return 0;
  224. }
  225. static unsigned char snd_opti9xx_read(struct snd_opti9xx *chip,
  226. unsigned char reg)
  227. {
  228. unsigned long flags;
  229. unsigned char retval = 0xff;
  230. spin_lock_irqsave(&chip->lock, flags);
  231. outb(chip->password, chip->mc_base + chip->pwd_reg);
  232. switch (chip->hardware) {
  233. #ifndef OPTi93X
  234. case OPTi9XX_HW_82C924:
  235. case OPTi9XX_HW_82C925:
  236. if (reg > 7) {
  237. outb(reg, chip->mc_base + 8);
  238. outb(chip->password, chip->mc_base + chip->pwd_reg);
  239. retval = inb(chip->mc_base + 9);
  240. break;
  241. }
  242. case OPTi9XX_HW_82C928:
  243. case OPTi9XX_HW_82C929:
  244. retval = inb(chip->mc_base + reg);
  245. break;
  246. #else /* OPTi93X */
  247. case OPTi9XX_HW_82C930:
  248. case OPTi9XX_HW_82C931:
  249. case OPTi9XX_HW_82C933:
  250. outb(reg, chip->mc_indir_index);
  251. outb(chip->password, chip->mc_base + chip->pwd_reg);
  252. retval = inb(chip->mc_indir_index + 1);
  253. break;
  254. #endif /* OPTi93X */
  255. default:
  256. snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
  257. }
  258. spin_unlock_irqrestore(&chip->lock, flags);
  259. return retval;
  260. }
  261. static void snd_opti9xx_write(struct snd_opti9xx *chip, unsigned char reg,
  262. unsigned char value)
  263. {
  264. unsigned long flags;
  265. spin_lock_irqsave(&chip->lock, flags);
  266. outb(chip->password, chip->mc_base + chip->pwd_reg);
  267. switch (chip->hardware) {
  268. #ifndef OPTi93X
  269. case OPTi9XX_HW_82C924:
  270. case OPTi9XX_HW_82C925:
  271. if (reg > 7) {
  272. outb(reg, chip->mc_base + 8);
  273. outb(chip->password, chip->mc_base + chip->pwd_reg);
  274. outb(value, chip->mc_base + 9);
  275. break;
  276. }
  277. case OPTi9XX_HW_82C928:
  278. case OPTi9XX_HW_82C929:
  279. outb(value, chip->mc_base + reg);
  280. break;
  281. #else /* OPTi93X */
  282. case OPTi9XX_HW_82C930:
  283. case OPTi9XX_HW_82C931:
  284. case OPTi9XX_HW_82C933:
  285. outb(reg, chip->mc_indir_index);
  286. outb(chip->password, chip->mc_base + chip->pwd_reg);
  287. outb(value, chip->mc_indir_index + 1);
  288. break;
  289. #endif /* OPTi93X */
  290. default:
  291. snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
  292. }
  293. spin_unlock_irqrestore(&chip->lock, flags);
  294. }
  295. #define snd_opti9xx_write_mask(chip, reg, value, mask) \
  296. snd_opti9xx_write(chip, reg, \
  297. (snd_opti9xx_read(chip, reg) & ~(mask)) | ((value) & (mask)))
  298. static int __devinit snd_opti9xx_configure(struct snd_opti9xx *chip,
  299. long port,
  300. int irq, int dma1, int dma2,
  301. long mpu_port, int mpu_irq)
  302. {
  303. unsigned char wss_base_bits;
  304. unsigned char irq_bits;
  305. unsigned char dma_bits;
  306. unsigned char mpu_port_bits = 0;
  307. unsigned char mpu_irq_bits;
  308. switch (chip->hardware) {
  309. #ifndef OPTi93X
  310. case OPTi9XX_HW_82C924:
  311. /* opti 929 mode (?), OPL3 clock output, audio enable */
  312. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0xf0, 0xfc);
  313. /* enable wave audio */
  314. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x02);
  315. case OPTi9XX_HW_82C925:
  316. /* enable WSS mode */
  317. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80);
  318. /* OPL3 FM synthesis */
  319. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20);
  320. /* disable Sound Blaster IRQ and DMA */
  321. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xf0, 0xff);
  322. #ifdef CS4231
  323. /* cs4231/4248 fix enabled */
  324. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02);
  325. #else
  326. /* cs4231/4248 fix disabled */
  327. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02);
  328. #endif /* CS4231 */
  329. break;
  330. case OPTi9XX_HW_82C928:
  331. case OPTi9XX_HW_82C929:
  332. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), 0x80, 0x80);
  333. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2), 0x00, 0x20);
  334. /*
  335. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0xa2, 0xae);
  336. */
  337. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0x00, 0x0c);
  338. #ifdef CS4231
  339. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x02, 0x02);
  340. #else
  341. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x00, 0x02);
  342. #endif /* CS4231 */
  343. break;
  344. #else /* OPTi93X */
  345. case OPTi9XX_HW_82C931:
  346. case OPTi9XX_HW_82C933:
  347. /*
  348. * The BTC 1817DW has QS1000 wavetable which is connected
  349. * to the serial digital input of the OPTI931.
  350. */
  351. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(21), 0x82, 0xff);
  352. /*
  353. * This bit sets OPTI931 to automaticaly select FM
  354. * or digital input signal.
  355. */
  356. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(26), 0x01, 0x01);
  357. case OPTi9XX_HW_82C930: /* FALL THROUGH */
  358. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6), 0x02, 0x03);
  359. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(3), 0x00, 0xff);
  360. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(4), 0x10 |
  361. (chip->hardware == OPTi9XX_HW_82C930 ? 0x00 : 0x04),
  362. 0x34);
  363. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(5), 0x20, 0xbf);
  364. break;
  365. #endif /* OPTi93X */
  366. default:
  367. snd_printk(KERN_ERR "chip %d not supported\n", chip->hardware);
  368. return -EINVAL;
  369. }
  370. /* PnP resource says it decodes only 10 bits of address */
  371. switch (port & 0x3ff) {
  372. case 0x130:
  373. chip->wss_base = 0x530;
  374. wss_base_bits = 0x00;
  375. break;
  376. case 0x204:
  377. chip->wss_base = 0x604;
  378. wss_base_bits = 0x03;
  379. break;
  380. case 0x280:
  381. chip->wss_base = 0xe80;
  382. wss_base_bits = 0x01;
  383. break;
  384. case 0x340:
  385. chip->wss_base = 0xf40;
  386. wss_base_bits = 0x02;
  387. break;
  388. default:
  389. snd_printk(KERN_WARNING "WSS port 0x%lx not valid\n", port);
  390. goto __skip_base;
  391. }
  392. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(1), wss_base_bits << 4, 0x30);
  393. __skip_base:
  394. switch (irq) {
  395. //#ifdef OPTi93X
  396. case 5:
  397. irq_bits = 0x05;
  398. break;
  399. //#endif /* OPTi93X */
  400. case 7:
  401. irq_bits = 0x01;
  402. break;
  403. case 9:
  404. irq_bits = 0x02;
  405. break;
  406. case 10:
  407. irq_bits = 0x03;
  408. break;
  409. case 11:
  410. irq_bits = 0x04;
  411. break;
  412. default:
  413. snd_printk(KERN_WARNING "WSS irq # %d not valid\n", irq);
  414. goto __skip_resources;
  415. }
  416. switch (dma1) {
  417. case 0:
  418. dma_bits = 0x01;
  419. break;
  420. case 1:
  421. dma_bits = 0x02;
  422. break;
  423. case 3:
  424. dma_bits = 0x03;
  425. break;
  426. default:
  427. snd_printk(KERN_WARNING "WSS dma1 # %d not valid\n", dma1);
  428. goto __skip_resources;
  429. }
  430. #if defined(CS4231) || defined(OPTi93X)
  431. if (dma1 == dma2) {
  432. snd_printk(KERN_ERR "don't want to share dmas\n");
  433. return -EBUSY;
  434. }
  435. switch (dma2) {
  436. case 0:
  437. case 1:
  438. break;
  439. default:
  440. snd_printk(KERN_WARNING "WSS dma2 # %d not valid\n", dma2);
  441. goto __skip_resources;
  442. }
  443. dma_bits |= 0x04;
  444. #endif /* CS4231 || OPTi93X */
  445. #ifndef OPTi93X
  446. outb(irq_bits << 3 | dma_bits, chip->wss_base);
  447. #else /* OPTi93X */
  448. snd_opti9xx_write(chip, OPTi9XX_MC_REG(3), (irq_bits << 3 | dma_bits));
  449. #endif /* OPTi93X */
  450. __skip_resources:
  451. if (chip->hardware > OPTi9XX_HW_82C928) {
  452. switch (mpu_port) {
  453. case 0:
  454. case -1:
  455. break;
  456. case 0x300:
  457. mpu_port_bits = 0x03;
  458. break;
  459. case 0x310:
  460. mpu_port_bits = 0x02;
  461. break;
  462. case 0x320:
  463. mpu_port_bits = 0x01;
  464. break;
  465. case 0x330:
  466. mpu_port_bits = 0x00;
  467. break;
  468. default:
  469. snd_printk(KERN_WARNING
  470. "MPU-401 port 0x%lx not valid\n", mpu_port);
  471. goto __skip_mpu;
  472. }
  473. switch (mpu_irq) {
  474. case 5:
  475. mpu_irq_bits = 0x02;
  476. break;
  477. case 7:
  478. mpu_irq_bits = 0x03;
  479. break;
  480. case 9:
  481. mpu_irq_bits = 0x00;
  482. break;
  483. case 10:
  484. mpu_irq_bits = 0x01;
  485. break;
  486. default:
  487. snd_printk(KERN_WARNING "MPU-401 irq # %d not valid\n",
  488. mpu_irq);
  489. goto __skip_mpu;
  490. }
  491. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(6),
  492. (mpu_port <= 0) ? 0x00 :
  493. 0x80 | mpu_port_bits << 5 | mpu_irq_bits << 3,
  494. 0xf8);
  495. }
  496. __skip_mpu:
  497. return 0;
  498. }
  499. #ifdef OPTi93X
  500. static const DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_step, -9300, 300, 0);
  501. static const DECLARE_TLV_DB_SCALE(db_scale_5bit, -4650, 150, 0);
  502. static const DECLARE_TLV_DB_SCALE(db_scale_4bit_12db_max, -3300, 300, 0);
  503. static struct snd_kcontrol_new snd_opti93x_controls[] = {
  504. WSS_DOUBLE("Master Playback Switch", 0,
  505. OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 7, 7, 1, 1),
  506. WSS_DOUBLE_TLV("Master Playback Volume", 0,
  507. OPTi93X_OUT_LEFT, OPTi93X_OUT_RIGHT, 1, 1, 31, 1,
  508. db_scale_5bit_3db_step),
  509. WSS_DOUBLE_TLV("PCM Playback Volume", 0,
  510. CS4231_LEFT_OUTPUT, CS4231_RIGHT_OUTPUT, 0, 0, 31, 1,
  511. db_scale_5bit),
  512. WSS_DOUBLE_TLV("FM Playback Volume", 0,
  513. CS4231_AUX2_LEFT_INPUT, CS4231_AUX2_RIGHT_INPUT, 1, 1, 15, 1,
  514. db_scale_4bit_12db_max),
  515. WSS_DOUBLE("Line Playback Switch", 0,
  516. CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 7, 7, 1, 1),
  517. WSS_DOUBLE_TLV("Line Playback Volume", 0,
  518. CS4231_LEFT_LINE_IN, CS4231_RIGHT_LINE_IN, 0, 0, 15, 1,
  519. db_scale_4bit_12db_max),
  520. WSS_DOUBLE("Mic Playback Switch", 0,
  521. OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 7, 7, 1, 1),
  522. WSS_DOUBLE_TLV("Mic Playback Volume", 0,
  523. OPTi93X_MIC_LEFT_INPUT, OPTi93X_MIC_RIGHT_INPUT, 1, 1, 15, 1,
  524. db_scale_4bit_12db_max),
  525. WSS_DOUBLE_TLV("CD Playback Volume", 0,
  526. CS4231_AUX1_LEFT_INPUT, CS4231_AUX1_RIGHT_INPUT, 1, 1, 15, 1,
  527. db_scale_4bit_12db_max),
  528. WSS_DOUBLE("Aux Playback Switch", 0,
  529. OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 7, 7, 1, 1),
  530. WSS_DOUBLE_TLV("Aux Playback Volume", 0,
  531. OPTi931_AUX_LEFT_INPUT, OPTi931_AUX_RIGHT_INPUT, 1, 1, 15, 1,
  532. db_scale_4bit_12db_max),
  533. };
  534. static int __devinit snd_opti93x_mixer(struct snd_wss *chip)
  535. {
  536. struct snd_card *card;
  537. unsigned int idx;
  538. struct snd_ctl_elem_id id1, id2;
  539. int err;
  540. if (snd_BUG_ON(!chip || !chip->pcm))
  541. return -EINVAL;
  542. card = chip->card;
  543. strcpy(card->mixername, chip->pcm->name);
  544. memset(&id1, 0, sizeof(id1));
  545. memset(&id2, 0, sizeof(id2));
  546. id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  547. /* reassign AUX0 switch to CD */
  548. strcpy(id1.name, "Aux Playback Switch");
  549. strcpy(id2.name, "CD Playback Switch");
  550. err = snd_ctl_rename_id(card, &id1, &id2);
  551. if (err < 0) {
  552. snd_printk(KERN_ERR "Cannot rename opti93x control\n");
  553. return err;
  554. }
  555. /* reassign AUX1 switch to FM */
  556. strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
  557. strcpy(id2.name, "FM Playback Switch");
  558. err = snd_ctl_rename_id(card, &id1, &id2);
  559. if (err < 0) {
  560. snd_printk(KERN_ERR "Cannot rename opti93x control\n");
  561. return err;
  562. }
  563. /* remove AUX1 volume */
  564. strcpy(id1.name, "Aux Playback Volume"); id1.index = 1;
  565. snd_ctl_remove_id(card, &id1);
  566. /* Replace WSS volume controls with OPTi93x volume controls */
  567. id1.index = 0;
  568. for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) {
  569. strcpy(id1.name, snd_opti93x_controls[idx].name);
  570. snd_ctl_remove_id(card, &id1);
  571. err = snd_ctl_add(card,
  572. snd_ctl_new1(&snd_opti93x_controls[idx], chip));
  573. if (err < 0)
  574. return err;
  575. }
  576. return 0;
  577. }
  578. static irqreturn_t snd_opti93x_interrupt(int irq, void *dev_id)
  579. {
  580. struct snd_opti9xx *chip = dev_id;
  581. struct snd_wss *codec = chip->codec;
  582. unsigned char status;
  583. if (!codec)
  584. return IRQ_HANDLED;
  585. status = snd_opti9xx_read(chip, OPTi9XX_MC_REG(11));
  586. if ((status & OPTi93X_IRQ_PLAYBACK) && codec->playback_substream)
  587. snd_pcm_period_elapsed(codec->playback_substream);
  588. if ((status & OPTi93X_IRQ_CAPTURE) && codec->capture_substream) {
  589. snd_wss_overrange(codec);
  590. snd_pcm_period_elapsed(codec->capture_substream);
  591. }
  592. outb(0x00, OPTi93X_PORT(codec, STATUS));
  593. return IRQ_HANDLED;
  594. }
  595. #endif /* OPTi93X */
  596. static int __devinit snd_opti9xx_read_check(struct snd_opti9xx *chip)
  597. {
  598. unsigned char value;
  599. #ifdef OPTi93X
  600. unsigned long flags;
  601. #endif
  602. chip->res_mc_base = request_region(chip->mc_base, chip->mc_base_size,
  603. "OPTi9xx MC");
  604. if (chip->res_mc_base == NULL)
  605. return -EBUSY;
  606. #ifndef OPTi93X
  607. value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(1));
  608. if (value != 0xff && value != inb(chip->mc_base + OPTi9XX_MC_REG(1)))
  609. if (value == snd_opti9xx_read(chip, OPTi9XX_MC_REG(1)))
  610. return 0;
  611. #else /* OPTi93X */
  612. chip->res_mc_indir = request_region(chip->mc_indir_index,
  613. chip->mc_indir_size,
  614. "OPTi93x MC");
  615. if (chip->res_mc_indir == NULL)
  616. return -EBUSY;
  617. spin_lock_irqsave(&chip->lock, flags);
  618. outb(chip->password, chip->mc_base + chip->pwd_reg);
  619. outb(((chip->mc_indir_index & 0x1f0) >> 4), chip->mc_base);
  620. spin_unlock_irqrestore(&chip->lock, flags);
  621. value = snd_opti9xx_read(chip, OPTi9XX_MC_REG(7));
  622. snd_opti9xx_write(chip, OPTi9XX_MC_REG(7), 0xff - value);
  623. if (snd_opti9xx_read(chip, OPTi9XX_MC_REG(7)) == 0xff - value)
  624. return 0;
  625. release_and_free_resource(chip->res_mc_indir);
  626. chip->res_mc_indir = NULL;
  627. #endif /* OPTi93X */
  628. release_and_free_resource(chip->res_mc_base);
  629. chip->res_mc_base = NULL;
  630. return -ENODEV;
  631. }
  632. static int __devinit snd_card_opti9xx_detect(struct snd_card *card,
  633. struct snd_opti9xx *chip)
  634. {
  635. int i, err;
  636. #ifndef OPTi93X
  637. for (i = OPTi9XX_HW_82C928; i < OPTi9XX_HW_82C930; i++) {
  638. #else
  639. for (i = OPTi9XX_HW_82C931; i >= OPTi9XX_HW_82C930; i--) {
  640. #endif
  641. err = snd_opti9xx_init(chip, i);
  642. if (err < 0)
  643. return err;
  644. err = snd_opti9xx_read_check(chip);
  645. if (err == 0)
  646. return 1;
  647. #ifdef OPTi93X
  648. chip->mc_indir_index = 0;
  649. #endif
  650. }
  651. return -ENODEV;
  652. }
  653. #ifdef CONFIG_PNP
  654. static int __devinit snd_card_opti9xx_pnp(struct snd_opti9xx *chip,
  655. struct pnp_card_link *card,
  656. const struct pnp_card_device_id *pid)
  657. {
  658. struct pnp_dev *pdev;
  659. int err;
  660. struct pnp_dev *devmpu;
  661. #ifndef OPTi93X
  662. struct pnp_dev *devmc;
  663. #endif
  664. pdev = pnp_request_card_device(card, pid->devs[0].id, NULL);
  665. if (pdev == NULL)
  666. return -EBUSY;
  667. err = pnp_activate_dev(pdev);
  668. if (err < 0) {
  669. snd_printk(KERN_ERR "AUDIO pnp configure failure: %d\n", err);
  670. return err;
  671. }
  672. #ifdef OPTi93X
  673. port = pnp_port_start(pdev, 0) - 4;
  674. fm_port = pnp_port_start(pdev, 1) + 8;
  675. chip->mc_indir_index = pnp_port_start(pdev, 3) + 2;
  676. chip->mc_indir_size = pnp_port_len(pdev, 3) - 2;
  677. #else
  678. devmc = pnp_request_card_device(card, pid->devs[2].id, NULL);
  679. if (devmc == NULL)
  680. return -EBUSY;
  681. err = pnp_activate_dev(devmc);
  682. if (err < 0) {
  683. snd_printk(KERN_ERR "MC pnp configure failure: %d\n", err);
  684. return err;
  685. }
  686. port = pnp_port_start(pdev, 1);
  687. fm_port = pnp_port_start(pdev, 2) + 8;
  688. /*
  689. * The MC(0) is never accessed and card does not
  690. * include it in the PnP resource range. OPTI93x include it.
  691. */
  692. chip->mc_base = pnp_port_start(devmc, 0) - 1;
  693. chip->mc_base_size = pnp_port_len(devmc, 0) + 1;
  694. #endif /* OPTi93X */
  695. irq = pnp_irq(pdev, 0);
  696. dma1 = pnp_dma(pdev, 0);
  697. #if defined(CS4231) || defined(OPTi93X)
  698. dma2 = pnp_dma(pdev, 1);
  699. #endif /* CS4231 || OPTi93X */
  700. devmpu = pnp_request_card_device(card, pid->devs[1].id, NULL);
  701. if (devmpu && mpu_port > 0) {
  702. err = pnp_activate_dev(devmpu);
  703. if (err < 0) {
  704. snd_printk(KERN_ERR "MPU401 pnp configure failure\n");
  705. mpu_port = -1;
  706. } else {
  707. mpu_port = pnp_port_start(devmpu, 0);
  708. mpu_irq = pnp_irq(devmpu, 0);
  709. }
  710. }
  711. return pid->driver_data;
  712. }
  713. #endif /* CONFIG_PNP */
  714. static void snd_card_opti9xx_free(struct snd_card *card)
  715. {
  716. struct snd_opti9xx *chip = card->private_data;
  717. if (chip) {
  718. #ifdef OPTi93X
  719. if (chip->irq > 0) {
  720. disable_irq(chip->irq);
  721. free_irq(chip->irq, chip);
  722. }
  723. release_and_free_resource(chip->res_mc_indir);
  724. #endif
  725. release_and_free_resource(chip->res_mc_base);
  726. }
  727. }
  728. static int __devinit snd_opti9xx_probe(struct snd_card *card)
  729. {
  730. static long possible_ports[] = {0x530, 0xe80, 0xf40, 0x604, -1};
  731. int error;
  732. int xdma2;
  733. struct snd_opti9xx *chip = card->private_data;
  734. struct snd_wss *codec;
  735. #ifdef CS4231
  736. struct snd_timer *timer;
  737. #endif
  738. struct snd_pcm *pcm;
  739. struct snd_rawmidi *rmidi;
  740. struct snd_hwdep *synth;
  741. #if defined(CS4231) || defined(OPTi93X)
  742. xdma2 = dma2;
  743. #else
  744. xdma2 = -1;
  745. #endif
  746. if (port == SNDRV_AUTO_PORT) {
  747. port = snd_legacy_find_free_ioport(possible_ports, 4);
  748. if (port < 0) {
  749. snd_printk(KERN_ERR "unable to find a free WSS port\n");
  750. return -EBUSY;
  751. }
  752. }
  753. error = snd_opti9xx_configure(chip, port, irq, dma1, xdma2,
  754. mpu_port, mpu_irq);
  755. if (error)
  756. return error;
  757. error = snd_wss_create(card, chip->wss_base + 4, -1, irq, dma1, xdma2,
  758. #ifdef OPTi93X
  759. WSS_HW_OPTI93X, WSS_HWSHARE_IRQ,
  760. #else
  761. WSS_HW_DETECT, 0,
  762. #endif
  763. &codec);
  764. if (error < 0)
  765. return error;
  766. #ifdef OPTi93X
  767. chip->codec = codec;
  768. #endif
  769. error = snd_wss_pcm(codec, 0, &pcm);
  770. if (error < 0)
  771. return error;
  772. error = snd_wss_mixer(codec);
  773. if (error < 0)
  774. return error;
  775. #ifdef OPTi93X
  776. error = snd_opti93x_mixer(codec);
  777. if (error < 0)
  778. return error;
  779. #endif
  780. #ifdef CS4231
  781. error = snd_wss_timer(codec, 0, &timer);
  782. if (error < 0)
  783. return error;
  784. #endif
  785. #ifdef OPTi93X
  786. error = request_irq(irq, snd_opti93x_interrupt,
  787. IRQF_DISABLED, DEV_NAME" - WSS", chip);
  788. if (error < 0) {
  789. snd_printk(KERN_ERR "opti9xx: can't grab IRQ %d\n", irq);
  790. return error;
  791. }
  792. #endif
  793. chip->irq = irq;
  794. strcpy(card->driver, chip->name);
  795. sprintf(card->shortname, "OPTi %s", card->driver);
  796. #if defined(CS4231) || defined(OPTi93X)
  797. sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d&%d",
  798. card->shortname, pcm->name,
  799. chip->wss_base + 4, irq, dma1, xdma2);
  800. #else
  801. sprintf(card->longname, "%s, %s at 0x%lx, irq %d, dma %d",
  802. card->shortname, pcm->name, chip->wss_base + 4, irq, dma1);
  803. #endif /* CS4231 || OPTi93X */
  804. if (mpu_port <= 0 || mpu_port == SNDRV_AUTO_PORT)
  805. rmidi = NULL;
  806. else {
  807. error = snd_mpu401_uart_new(card, 0, MPU401_HW_MPU401,
  808. mpu_port, 0, mpu_irq, IRQF_DISABLED, &rmidi);
  809. if (error)
  810. snd_printk(KERN_WARNING "no MPU-401 device at 0x%lx?\n",
  811. mpu_port);
  812. }
  813. if (fm_port > 0 && fm_port != SNDRV_AUTO_PORT) {
  814. struct snd_opl3 *opl3 = NULL;
  815. #ifndef OPTi93X
  816. if (chip->hardware == OPTi9XX_HW_82C928 ||
  817. chip->hardware == OPTi9XX_HW_82C929 ||
  818. chip->hardware == OPTi9XX_HW_82C924) {
  819. struct snd_opl4 *opl4;
  820. /* assume we have an OPL4 */
  821. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
  822. 0x20, 0x20);
  823. if (snd_opl4_create(card, fm_port, fm_port - 8,
  824. 2, &opl3, &opl4) < 0) {
  825. /* no luck, use OPL3 instead */
  826. snd_opti9xx_write_mask(chip, OPTi9XX_MC_REG(2),
  827. 0x00, 0x20);
  828. }
  829. }
  830. #endif /* !OPTi93X */
  831. if (!opl3 && snd_opl3_create(card, fm_port, fm_port + 2,
  832. OPL3_HW_AUTO, 0, &opl3) < 0) {
  833. snd_printk(KERN_WARNING "no OPL device at 0x%lx-0x%lx\n",
  834. fm_port, fm_port + 4 - 1);
  835. }
  836. if (opl3) {
  837. error = snd_opl3_hwdep_new(opl3, 0, 1, &synth);
  838. if (error < 0)
  839. return error;
  840. }
  841. }
  842. return snd_card_register(card);
  843. }
  844. static int snd_opti9xx_card_new(struct snd_card **cardp)
  845. {
  846. struct snd_card *card;
  847. int err;
  848. err = snd_card_create(index, id, THIS_MODULE,
  849. sizeof(struct snd_opti9xx), &card);
  850. if (err < 0)
  851. return err;
  852. card->private_free = snd_card_opti9xx_free;
  853. *cardp = card;
  854. return 0;
  855. }
  856. static int __devinit snd_opti9xx_isa_match(struct device *devptr,
  857. unsigned int dev)
  858. {
  859. #ifdef CONFIG_PNP
  860. if (snd_opti9xx_pnp_is_probed)
  861. return 0;
  862. if (isapnp)
  863. return 0;
  864. #endif
  865. return 1;
  866. }
  867. static int __devinit snd_opti9xx_isa_probe(struct device *devptr,
  868. unsigned int dev)
  869. {
  870. struct snd_card *card;
  871. int error;
  872. static long possible_mpu_ports[] = {0x300, 0x310, 0x320, 0x330, -1};
  873. #ifdef OPTi93X
  874. static int possible_irqs[] = {5, 9, 10, 11, 7, -1};
  875. #else
  876. static int possible_irqs[] = {9, 10, 11, 7, -1};
  877. #endif /* OPTi93X */
  878. static int possible_mpu_irqs[] = {5, 9, 10, 7, -1};
  879. static int possible_dma1s[] = {3, 1, 0, -1};
  880. #if defined(CS4231) || defined(OPTi93X)
  881. static int possible_dma2s[][2] = {{1,-1}, {0,-1}, {-1,-1}, {0,-1}};
  882. #endif /* CS4231 || OPTi93X */
  883. if (mpu_port == SNDRV_AUTO_PORT) {
  884. if ((mpu_port = snd_legacy_find_free_ioport(possible_mpu_ports, 2)) < 0) {
  885. snd_printk(KERN_ERR "unable to find a free MPU401 port\n");
  886. return -EBUSY;
  887. }
  888. }
  889. if (irq == SNDRV_AUTO_IRQ) {
  890. if ((irq = snd_legacy_find_free_irq(possible_irqs)) < 0) {
  891. snd_printk(KERN_ERR "unable to find a free IRQ\n");
  892. return -EBUSY;
  893. }
  894. }
  895. if (mpu_irq == SNDRV_AUTO_IRQ) {
  896. if ((mpu_irq = snd_legacy_find_free_irq(possible_mpu_irqs)) < 0) {
  897. snd_printk(KERN_ERR "unable to find a free MPU401 IRQ\n");
  898. return -EBUSY;
  899. }
  900. }
  901. if (dma1 == SNDRV_AUTO_DMA) {
  902. if ((dma1 = snd_legacy_find_free_dma(possible_dma1s)) < 0) {
  903. snd_printk(KERN_ERR "unable to find a free DMA1\n");
  904. return -EBUSY;
  905. }
  906. }
  907. #if defined(CS4231) || defined(OPTi93X)
  908. if (dma2 == SNDRV_AUTO_DMA) {
  909. if ((dma2 = snd_legacy_find_free_dma(possible_dma2s[dma1 % 4])) < 0) {
  910. snd_printk(KERN_ERR "unable to find a free DMA2\n");
  911. return -EBUSY;
  912. }
  913. }
  914. #endif
  915. error = snd_opti9xx_card_new(&card);
  916. if (error < 0)
  917. return error;
  918. if ((error = snd_card_opti9xx_detect(card, card->private_data)) < 0) {
  919. snd_card_free(card);
  920. return error;
  921. }
  922. snd_card_set_dev(card, devptr);
  923. if ((error = snd_opti9xx_probe(card)) < 0) {
  924. snd_card_free(card);
  925. return error;
  926. }
  927. dev_set_drvdata(devptr, card);
  928. return 0;
  929. }
  930. static int __devexit snd_opti9xx_isa_remove(struct device *devptr,
  931. unsigned int dev)
  932. {
  933. snd_card_free(dev_get_drvdata(devptr));
  934. dev_set_drvdata(devptr, NULL);
  935. return 0;
  936. }
  937. static struct isa_driver snd_opti9xx_driver = {
  938. .match = snd_opti9xx_isa_match,
  939. .probe = snd_opti9xx_isa_probe,
  940. .remove = __devexit_p(snd_opti9xx_isa_remove),
  941. /* FIXME: suspend/resume */
  942. .driver = {
  943. .name = DEV_NAME
  944. },
  945. };
  946. #ifdef CONFIG_PNP
  947. static int __devinit snd_opti9xx_pnp_probe(struct pnp_card_link *pcard,
  948. const struct pnp_card_device_id *pid)
  949. {
  950. struct snd_card *card;
  951. int error, hw;
  952. struct snd_opti9xx *chip;
  953. if (snd_opti9xx_pnp_is_probed)
  954. return -EBUSY;
  955. if (! isapnp)
  956. return -ENODEV;
  957. error = snd_opti9xx_card_new(&card);
  958. if (error < 0)
  959. return error;
  960. chip = card->private_data;
  961. hw = snd_card_opti9xx_pnp(chip, pcard, pid);
  962. switch (hw) {
  963. case 0x0924:
  964. hw = OPTi9XX_HW_82C924;
  965. break;
  966. case 0x0925:
  967. hw = OPTi9XX_HW_82C925;
  968. break;
  969. case 0x0931:
  970. hw = OPTi9XX_HW_82C931;
  971. break;
  972. default:
  973. snd_card_free(card);
  974. return -ENODEV;
  975. }
  976. if ((error = snd_opti9xx_init(chip, hw))) {
  977. snd_card_free(card);
  978. return error;
  979. }
  980. error = snd_opti9xx_read_check(chip);
  981. if (error) {
  982. snd_printk(KERN_ERR "OPTI chip not found\n");
  983. snd_card_free(card);
  984. return error;
  985. }
  986. snd_card_set_dev(card, &pcard->card->dev);
  987. if ((error = snd_opti9xx_probe(card)) < 0) {
  988. snd_card_free(card);
  989. return error;
  990. }
  991. pnp_set_card_drvdata(pcard, card);
  992. snd_opti9xx_pnp_is_probed = 1;
  993. return 0;
  994. }
  995. static void __devexit snd_opti9xx_pnp_remove(struct pnp_card_link * pcard)
  996. {
  997. snd_card_free(pnp_get_card_drvdata(pcard));
  998. pnp_set_card_drvdata(pcard, NULL);
  999. snd_opti9xx_pnp_is_probed = 0;
  1000. }
  1001. static struct pnp_card_driver opti9xx_pnpc_driver = {
  1002. .flags = PNP_DRIVER_RES_DISABLE,
  1003. .name = "opti9xx",
  1004. .id_table = snd_opti9xx_pnpids,
  1005. .probe = snd_opti9xx_pnp_probe,
  1006. .remove = __devexit_p(snd_opti9xx_pnp_remove),
  1007. };
  1008. #endif
  1009. #ifdef OPTi93X
  1010. #define CHIP_NAME "82C93x"
  1011. #else
  1012. #define CHIP_NAME "82C92x"
  1013. #endif
  1014. static int __init alsa_card_opti9xx_init(void)
  1015. {
  1016. #ifdef CONFIG_PNP
  1017. pnp_register_card_driver(&opti9xx_pnpc_driver);
  1018. if (snd_opti9xx_pnp_is_probed)
  1019. return 0;
  1020. pnp_unregister_card_driver(&opti9xx_pnpc_driver);
  1021. #endif
  1022. return isa_register_driver(&snd_opti9xx_driver, 1);
  1023. }
  1024. static void __exit alsa_card_opti9xx_exit(void)
  1025. {
  1026. if (!snd_opti9xx_pnp_is_probed) {
  1027. isa_unregister_driver(&snd_opti9xx_driver);
  1028. return;
  1029. }
  1030. #ifdef CONFIG_PNP
  1031. pnp_unregister_card_driver(&opti9xx_pnpc_driver);
  1032. #endif
  1033. }
  1034. module_init(alsa_card_opti9xx_init)
  1035. module_exit(alsa_card_opti9xx_exit)