opti92x-ad1848.c 29 KB

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