opti92x-ad1848.c 29 KB

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