es1688_lib.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060
  1. /*
  2. * Copyright (c) by Jaroslav Kysela <perex@perex.cz>
  3. * Routines for control of ESS ES1688/688/488 chip
  4. *
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #include <linux/init.h>
  22. #include <linux/interrupt.h>
  23. #include <linux/delay.h>
  24. #include <linux/slab.h>
  25. #include <linux/ioport.h>
  26. #include <sound/core.h>
  27. #include <sound/es1688.h>
  28. #include <sound/initval.h>
  29. #include <asm/io.h>
  30. #include <asm/dma.h>
  31. MODULE_AUTHOR("Jaroslav Kysela <perex@perex.cz>");
  32. MODULE_DESCRIPTION("ESS ESx688 lowlevel module");
  33. MODULE_LICENSE("GPL");
  34. static int snd_es1688_dsp_command(struct snd_es1688 *chip, unsigned char val)
  35. {
  36. int i;
  37. for (i = 10000; i; i--)
  38. if ((inb(ES1688P(chip, STATUS)) & 0x80) == 0) {
  39. outb(val, ES1688P(chip, COMMAND));
  40. return 1;
  41. }
  42. #ifdef CONFIG_SND_DEBUG
  43. printk(KERN_DEBUG "snd_es1688_dsp_command: timeout (0x%x)\n", val);
  44. #endif
  45. return 0;
  46. }
  47. static int snd_es1688_dsp_get_byte(struct snd_es1688 *chip)
  48. {
  49. int i;
  50. for (i = 1000; i; i--)
  51. if (inb(ES1688P(chip, DATA_AVAIL)) & 0x80)
  52. return inb(ES1688P(chip, READ));
  53. snd_printd("es1688 get byte failed: 0x%lx = 0x%x!!!\n", ES1688P(chip, DATA_AVAIL), inb(ES1688P(chip, DATA_AVAIL)));
  54. return -ENODEV;
  55. }
  56. static int snd_es1688_write(struct snd_es1688 *chip,
  57. unsigned char reg, unsigned char data)
  58. {
  59. if (!snd_es1688_dsp_command(chip, reg))
  60. return 0;
  61. return snd_es1688_dsp_command(chip, data);
  62. }
  63. static int snd_es1688_read(struct snd_es1688 *chip, unsigned char reg)
  64. {
  65. /* Read a byte from an extended mode register of ES1688 */
  66. if (!snd_es1688_dsp_command(chip, 0xc0))
  67. return -1;
  68. if (!snd_es1688_dsp_command(chip, reg))
  69. return -1;
  70. return snd_es1688_dsp_get_byte(chip);
  71. }
  72. void snd_es1688_mixer_write(struct snd_es1688 *chip,
  73. unsigned char reg, unsigned char data)
  74. {
  75. outb(reg, ES1688P(chip, MIXER_ADDR));
  76. udelay(10);
  77. outb(data, ES1688P(chip, MIXER_DATA));
  78. udelay(10);
  79. }
  80. static unsigned char snd_es1688_mixer_read(struct snd_es1688 *chip, unsigned char reg)
  81. {
  82. unsigned char result;
  83. outb(reg, ES1688P(chip, MIXER_ADDR));
  84. udelay(10);
  85. result = inb(ES1688P(chip, MIXER_DATA));
  86. udelay(10);
  87. return result;
  88. }
  89. static int snd_es1688_reset(struct snd_es1688 *chip)
  90. {
  91. int i;
  92. outb(3, ES1688P(chip, RESET)); /* valid only for ESS chips, SB -> 1 */
  93. udelay(10);
  94. outb(0, ES1688P(chip, RESET));
  95. udelay(30);
  96. for (i = 0; i < 1000 && !(inb(ES1688P(chip, DATA_AVAIL)) & 0x80); i++);
  97. if (inb(ES1688P(chip, READ)) != 0xaa) {
  98. snd_printd("ess_reset at 0x%lx: failed!!!\n", chip->port);
  99. return -ENODEV;
  100. }
  101. snd_es1688_dsp_command(chip, 0xc6); /* enable extended mode */
  102. return 0;
  103. }
  104. static int snd_es1688_probe(struct snd_es1688 *chip)
  105. {
  106. unsigned long flags;
  107. unsigned short major, minor, hw;
  108. int i;
  109. /*
  110. * initialization sequence
  111. */
  112. spin_lock_irqsave(&chip->reg_lock, flags); /* Some ESS1688 cards need this */
  113. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  114. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  115. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  116. inb(ES1688P(chip, ENABLE2)); /* ENABLE2 */
  117. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  118. inb(ES1688P(chip, ENABLE2)); /* ENABLE2 */
  119. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  120. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  121. inb(ES1688P(chip, ENABLE2)); /* ENABLE2 */
  122. inb(ES1688P(chip, ENABLE1)); /* ENABLE1 */
  123. inb(ES1688P(chip, ENABLE0)); /* ENABLE0 */
  124. if (snd_es1688_reset(chip) < 0) {
  125. snd_printdd("ESS: [0x%lx] reset failed... 0x%x\n", chip->port, inb(ES1688P(chip, READ)));
  126. spin_unlock_irqrestore(&chip->reg_lock, flags);
  127. return -ENODEV;
  128. }
  129. snd_es1688_dsp_command(chip, 0xe7); /* return identification */
  130. for (i = 1000, major = minor = 0; i; i--) {
  131. if (inb(ES1688P(chip, DATA_AVAIL)) & 0x80) {
  132. if (major == 0) {
  133. major = inb(ES1688P(chip, READ));
  134. } else {
  135. minor = inb(ES1688P(chip, READ));
  136. }
  137. }
  138. }
  139. spin_unlock_irqrestore(&chip->reg_lock, flags);
  140. snd_printdd("ESS: [0x%lx] found.. major = 0x%x, minor = 0x%x\n", chip->port, major, minor);
  141. chip->version = (major << 8) | minor;
  142. if (!chip->version)
  143. return -ENODEV; /* probably SB */
  144. hw = ES1688_HW_AUTO;
  145. switch (chip->version & 0xfff0) {
  146. case 0x4880:
  147. snd_printk(KERN_ERR "[0x%lx] ESS: AudioDrive ES488 detected, "
  148. "but driver is in another place\n", chip->port);
  149. return -ENODEV;
  150. case 0x6880:
  151. hw = (chip->version & 0x0f) >= 8 ? ES1688_HW_1688 : ES1688_HW_688;
  152. break;
  153. default:
  154. snd_printk(KERN_ERR "[0x%lx] ESS: unknown AudioDrive chip "
  155. "with version 0x%x (Jazz16 soundcard?)\n",
  156. chip->port, chip->version);
  157. return -ENODEV;
  158. }
  159. spin_lock_irqsave(&chip->reg_lock, flags);
  160. snd_es1688_write(chip, 0xb1, 0x10); /* disable IRQ */
  161. snd_es1688_write(chip, 0xb2, 0x00); /* disable DMA */
  162. spin_unlock_irqrestore(&chip->reg_lock, flags);
  163. /* enable joystick, but disable OPL3 */
  164. spin_lock_irqsave(&chip->mixer_lock, flags);
  165. snd_es1688_mixer_write(chip, 0x40, 0x01);
  166. spin_unlock_irqrestore(&chip->mixer_lock, flags);
  167. return 0;
  168. }
  169. static int snd_es1688_init(struct snd_es1688 * chip, int enable)
  170. {
  171. static int irqs[16] = {-1, -1, 0, -1, -1, 1, -1, 2, -1, 0, 3, -1, -1, -1, -1, -1};
  172. unsigned long flags;
  173. int cfg, irq_bits, dma, dma_bits, tmp, tmp1;
  174. /* ok.. setup MPU-401 port and joystick and OPL3 */
  175. cfg = 0x01; /* enable joystick, but disable OPL3 */
  176. if (enable && chip->mpu_port >= 0x300 && chip->mpu_irq > 0 && chip->hardware != ES1688_HW_688) {
  177. tmp = (chip->mpu_port & 0x0f0) >> 4;
  178. if (tmp <= 3) {
  179. switch (chip->mpu_irq) {
  180. case 9:
  181. tmp1 = 4;
  182. break;
  183. case 5:
  184. tmp1 = 5;
  185. break;
  186. case 7:
  187. tmp1 = 6;
  188. break;
  189. case 10:
  190. tmp1 = 7;
  191. break;
  192. default:
  193. tmp1 = 0;
  194. }
  195. if (tmp1) {
  196. cfg |= (tmp << 3) | (tmp1 << 5);
  197. }
  198. }
  199. }
  200. #if 0
  201. snd_printk(KERN_DEBUG "mpu cfg = 0x%x\n", cfg);
  202. #endif
  203. spin_lock_irqsave(&chip->reg_lock, flags);
  204. snd_es1688_mixer_write(chip, 0x40, cfg);
  205. spin_unlock_irqrestore(&chip->reg_lock, flags);
  206. /* --- */
  207. spin_lock_irqsave(&chip->reg_lock, flags);
  208. snd_es1688_read(chip, 0xb1);
  209. snd_es1688_read(chip, 0xb2);
  210. spin_unlock_irqrestore(&chip->reg_lock, flags);
  211. if (enable) {
  212. cfg = 0xf0; /* enable only DMA counter interrupt */
  213. irq_bits = irqs[chip->irq & 0x0f];
  214. if (irq_bits < 0) {
  215. snd_printk(KERN_ERR "[0x%lx] ESS: bad IRQ %d "
  216. "for ES1688 chip!!\n",
  217. chip->port, chip->irq);
  218. #if 0
  219. irq_bits = 0;
  220. cfg = 0x10;
  221. #endif
  222. return -EINVAL;
  223. }
  224. spin_lock_irqsave(&chip->reg_lock, flags);
  225. snd_es1688_write(chip, 0xb1, cfg | (irq_bits << 2));
  226. spin_unlock_irqrestore(&chip->reg_lock, flags);
  227. cfg = 0xf0; /* extended mode DMA enable */
  228. dma = chip->dma8;
  229. if (dma > 3 || dma == 2) {
  230. snd_printk(KERN_ERR "[0x%lx] ESS: bad DMA channel %d "
  231. "for ES1688 chip!!\n", chip->port, dma);
  232. #if 0
  233. dma_bits = 0;
  234. cfg = 0x00; /* disable all DMA */
  235. #endif
  236. return -EINVAL;
  237. } else {
  238. dma_bits = dma;
  239. if (dma != 3)
  240. dma_bits++;
  241. }
  242. spin_lock_irqsave(&chip->reg_lock, flags);
  243. snd_es1688_write(chip, 0xb2, cfg | (dma_bits << 2));
  244. spin_unlock_irqrestore(&chip->reg_lock, flags);
  245. } else {
  246. spin_lock_irqsave(&chip->reg_lock, flags);
  247. snd_es1688_write(chip, 0xb1, 0x10); /* disable IRQ */
  248. snd_es1688_write(chip, 0xb2, 0x00); /* disable DMA */
  249. spin_unlock_irqrestore(&chip->reg_lock, flags);
  250. }
  251. spin_lock_irqsave(&chip->reg_lock, flags);
  252. snd_es1688_read(chip, 0xb1);
  253. snd_es1688_read(chip, 0xb2);
  254. snd_es1688_reset(chip);
  255. spin_unlock_irqrestore(&chip->reg_lock, flags);
  256. return 0;
  257. }
  258. /*
  259. */
  260. static struct snd_ratnum clocks[2] = {
  261. {
  262. .num = 795444,
  263. .den_min = 1,
  264. .den_max = 128,
  265. .den_step = 1,
  266. },
  267. {
  268. .num = 397722,
  269. .den_min = 1,
  270. .den_max = 128,
  271. .den_step = 1,
  272. }
  273. };
  274. static struct snd_pcm_hw_constraint_ratnums hw_constraints_clocks = {
  275. .nrats = 2,
  276. .rats = clocks,
  277. };
  278. static void snd_es1688_set_rate(struct snd_es1688 *chip, struct snd_pcm_substream *substream)
  279. {
  280. struct snd_pcm_runtime *runtime = substream->runtime;
  281. unsigned int bits, divider;
  282. if (runtime->rate_num == clocks[0].num)
  283. bits = 256 - runtime->rate_den;
  284. else
  285. bits = 128 - runtime->rate_den;
  286. /* set filter register */
  287. divider = 256 - 7160000*20/(8*82*runtime->rate);
  288. /* write result to hardware */
  289. snd_es1688_write(chip, 0xa1, bits);
  290. snd_es1688_write(chip, 0xa2, divider);
  291. }
  292. static int snd_es1688_ioctl(struct snd_pcm_substream *substream,
  293. unsigned int cmd, void *arg)
  294. {
  295. return snd_pcm_lib_ioctl(substream, cmd, arg);
  296. }
  297. static int snd_es1688_trigger(struct snd_es1688 *chip, int cmd, unsigned char value)
  298. {
  299. int val;
  300. if (cmd == SNDRV_PCM_TRIGGER_STOP) {
  301. value = 0x00;
  302. } else if (cmd != SNDRV_PCM_TRIGGER_START) {
  303. return -EINVAL;
  304. }
  305. spin_lock(&chip->reg_lock);
  306. chip->trigger_value = value;
  307. val = snd_es1688_read(chip, 0xb8);
  308. if ((val < 0) || (val & 0x0f) == value) {
  309. spin_unlock(&chip->reg_lock);
  310. return -EINVAL; /* something is wrong */
  311. }
  312. #if 0
  313. printk(KERN_DEBUG "trigger: val = 0x%x, value = 0x%x\n", val, value);
  314. printk(KERN_DEBUG "trigger: pointer = 0x%x\n",
  315. snd_dma_pointer(chip->dma8, chip->dma_size));
  316. #endif
  317. snd_es1688_write(chip, 0xb8, (val & 0xf0) | value);
  318. spin_unlock(&chip->reg_lock);
  319. return 0;
  320. }
  321. static int snd_es1688_hw_params(struct snd_pcm_substream *substream,
  322. struct snd_pcm_hw_params *hw_params)
  323. {
  324. return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
  325. }
  326. static int snd_es1688_hw_free(struct snd_pcm_substream *substream)
  327. {
  328. return snd_pcm_lib_free_pages(substream);
  329. }
  330. static int snd_es1688_playback_prepare(struct snd_pcm_substream *substream)
  331. {
  332. unsigned long flags;
  333. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  334. struct snd_pcm_runtime *runtime = substream->runtime;
  335. unsigned int size = snd_pcm_lib_buffer_bytes(substream);
  336. unsigned int count = snd_pcm_lib_period_bytes(substream);
  337. chip->dma_size = size;
  338. spin_lock_irqsave(&chip->reg_lock, flags);
  339. snd_es1688_reset(chip);
  340. snd_es1688_set_rate(chip, substream);
  341. snd_es1688_write(chip, 0xb8, 4); /* auto init DMA mode */
  342. snd_es1688_write(chip, 0xa8, (snd_es1688_read(chip, 0xa8) & ~0x03) | (3 - runtime->channels));
  343. snd_es1688_write(chip, 0xb9, 2); /* demand mode (4 bytes/request) */
  344. if (runtime->channels == 1) {
  345. if (snd_pcm_format_width(runtime->format) == 8) {
  346. /* 8. bit mono */
  347. snd_es1688_write(chip, 0xb6, 0x80);
  348. snd_es1688_write(chip, 0xb7, 0x51);
  349. snd_es1688_write(chip, 0xb7, 0xd0);
  350. } else {
  351. /* 16. bit mono */
  352. snd_es1688_write(chip, 0xb6, 0x00);
  353. snd_es1688_write(chip, 0xb7, 0x71);
  354. snd_es1688_write(chip, 0xb7, 0xf4);
  355. }
  356. } else {
  357. if (snd_pcm_format_width(runtime->format) == 8) {
  358. /* 8. bit stereo */
  359. snd_es1688_write(chip, 0xb6, 0x80);
  360. snd_es1688_write(chip, 0xb7, 0x51);
  361. snd_es1688_write(chip, 0xb7, 0x98);
  362. } else {
  363. /* 16. bit stereo */
  364. snd_es1688_write(chip, 0xb6, 0x00);
  365. snd_es1688_write(chip, 0xb7, 0x71);
  366. snd_es1688_write(chip, 0xb7, 0xbc);
  367. }
  368. }
  369. snd_es1688_write(chip, 0xb1, (snd_es1688_read(chip, 0xb1) & 0x0f) | 0x50);
  370. snd_es1688_write(chip, 0xb2, (snd_es1688_read(chip, 0xb2) & 0x0f) | 0x50);
  371. snd_es1688_dsp_command(chip, ES1688_DSP_CMD_SPKON);
  372. spin_unlock_irqrestore(&chip->reg_lock, flags);
  373. /* --- */
  374. count = -count;
  375. snd_dma_program(chip->dma8, runtime->dma_addr, size, DMA_MODE_WRITE | DMA_AUTOINIT);
  376. spin_lock_irqsave(&chip->reg_lock, flags);
  377. snd_es1688_write(chip, 0xa4, (unsigned char) count);
  378. snd_es1688_write(chip, 0xa5, (unsigned char) (count >> 8));
  379. spin_unlock_irqrestore(&chip->reg_lock, flags);
  380. return 0;
  381. }
  382. static int snd_es1688_playback_trigger(struct snd_pcm_substream *substream,
  383. int cmd)
  384. {
  385. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  386. return snd_es1688_trigger(chip, cmd, 0x05);
  387. }
  388. static int snd_es1688_capture_prepare(struct snd_pcm_substream *substream)
  389. {
  390. unsigned long flags;
  391. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  392. struct snd_pcm_runtime *runtime = substream->runtime;
  393. unsigned int size = snd_pcm_lib_buffer_bytes(substream);
  394. unsigned int count = snd_pcm_lib_period_bytes(substream);
  395. chip->dma_size = size;
  396. spin_lock_irqsave(&chip->reg_lock, flags);
  397. snd_es1688_reset(chip);
  398. snd_es1688_set_rate(chip, substream);
  399. snd_es1688_dsp_command(chip, ES1688_DSP_CMD_SPKOFF);
  400. snd_es1688_write(chip, 0xb8, 0x0e); /* auto init DMA mode */
  401. snd_es1688_write(chip, 0xa8, (snd_es1688_read(chip, 0xa8) & ~0x03) | (3 - runtime->channels));
  402. snd_es1688_write(chip, 0xb9, 2); /* demand mode (4 bytes/request) */
  403. if (runtime->channels == 1) {
  404. if (snd_pcm_format_width(runtime->format) == 8) {
  405. /* 8. bit mono */
  406. snd_es1688_write(chip, 0xb7, 0x51);
  407. snd_es1688_write(chip, 0xb7, 0xd0);
  408. } else {
  409. /* 16. bit mono */
  410. snd_es1688_write(chip, 0xb7, 0x71);
  411. snd_es1688_write(chip, 0xb7, 0xf4);
  412. }
  413. } else {
  414. if (snd_pcm_format_width(runtime->format) == 8) {
  415. /* 8. bit stereo */
  416. snd_es1688_write(chip, 0xb7, 0x51);
  417. snd_es1688_write(chip, 0xb7, 0x98);
  418. } else {
  419. /* 16. bit stereo */
  420. snd_es1688_write(chip, 0xb7, 0x71);
  421. snd_es1688_write(chip, 0xb7, 0xbc);
  422. }
  423. }
  424. snd_es1688_write(chip, 0xb1, (snd_es1688_read(chip, 0xb1) & 0x0f) | 0x50);
  425. snd_es1688_write(chip, 0xb2, (snd_es1688_read(chip, 0xb2) & 0x0f) | 0x50);
  426. spin_unlock_irqrestore(&chip->reg_lock, flags);
  427. /* --- */
  428. count = -count;
  429. snd_dma_program(chip->dma8, runtime->dma_addr, size, DMA_MODE_READ | DMA_AUTOINIT);
  430. spin_lock_irqsave(&chip->reg_lock, flags);
  431. snd_es1688_write(chip, 0xa4, (unsigned char) count);
  432. snd_es1688_write(chip, 0xa5, (unsigned char) (count >> 8));
  433. spin_unlock_irqrestore(&chip->reg_lock, flags);
  434. return 0;
  435. }
  436. static int snd_es1688_capture_trigger(struct snd_pcm_substream *substream,
  437. int cmd)
  438. {
  439. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  440. return snd_es1688_trigger(chip, cmd, 0x0f);
  441. }
  442. static irqreturn_t snd_es1688_interrupt(int irq, void *dev_id)
  443. {
  444. struct snd_es1688 *chip = dev_id;
  445. if (chip->trigger_value == 0x05) /* ok.. playback is active */
  446. snd_pcm_period_elapsed(chip->playback_substream);
  447. if (chip->trigger_value == 0x0f) /* ok.. capture is active */
  448. snd_pcm_period_elapsed(chip->capture_substream);
  449. inb(ES1688P(chip, DATA_AVAIL)); /* ack interrupt */
  450. return IRQ_HANDLED;
  451. }
  452. static snd_pcm_uframes_t snd_es1688_playback_pointer(struct snd_pcm_substream *substream)
  453. {
  454. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  455. size_t ptr;
  456. if (chip->trigger_value != 0x05)
  457. return 0;
  458. ptr = snd_dma_pointer(chip->dma8, chip->dma_size);
  459. return bytes_to_frames(substream->runtime, ptr);
  460. }
  461. static snd_pcm_uframes_t snd_es1688_capture_pointer(struct snd_pcm_substream *substream)
  462. {
  463. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  464. size_t ptr;
  465. if (chip->trigger_value != 0x0f)
  466. return 0;
  467. ptr = snd_dma_pointer(chip->dma8, chip->dma_size);
  468. return bytes_to_frames(substream->runtime, ptr);
  469. }
  470. /*
  471. */
  472. static struct snd_pcm_hardware snd_es1688_playback =
  473. {
  474. .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
  475. SNDRV_PCM_INFO_MMAP_VALID),
  476. .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
  477. .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
  478. .rate_min = 4000,
  479. .rate_max = 48000,
  480. .channels_min = 1,
  481. .channels_max = 2,
  482. .buffer_bytes_max = 65536,
  483. .period_bytes_min = 64,
  484. .period_bytes_max = 65536,
  485. .periods_min = 1,
  486. .periods_max = 1024,
  487. .fifo_size = 0,
  488. };
  489. static struct snd_pcm_hardware snd_es1688_capture =
  490. {
  491. .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
  492. SNDRV_PCM_INFO_MMAP_VALID),
  493. .formats = SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE,
  494. .rates = SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000,
  495. .rate_min = 4000,
  496. .rate_max = 48000,
  497. .channels_min = 1,
  498. .channels_max = 2,
  499. .buffer_bytes_max = 65536,
  500. .period_bytes_min = 64,
  501. .period_bytes_max = 65536,
  502. .periods_min = 1,
  503. .periods_max = 1024,
  504. .fifo_size = 0,
  505. };
  506. /*
  507. */
  508. static int snd_es1688_playback_open(struct snd_pcm_substream *substream)
  509. {
  510. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  511. struct snd_pcm_runtime *runtime = substream->runtime;
  512. if (chip->capture_substream != NULL)
  513. return -EAGAIN;
  514. chip->playback_substream = substream;
  515. runtime->hw = snd_es1688_playback;
  516. snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
  517. &hw_constraints_clocks);
  518. return 0;
  519. }
  520. static int snd_es1688_capture_open(struct snd_pcm_substream *substream)
  521. {
  522. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  523. struct snd_pcm_runtime *runtime = substream->runtime;
  524. if (chip->playback_substream != NULL)
  525. return -EAGAIN;
  526. chip->capture_substream = substream;
  527. runtime->hw = snd_es1688_capture;
  528. snd_pcm_hw_constraint_ratnums(runtime, 0, SNDRV_PCM_HW_PARAM_RATE,
  529. &hw_constraints_clocks);
  530. return 0;
  531. }
  532. static int snd_es1688_playback_close(struct snd_pcm_substream *substream)
  533. {
  534. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  535. chip->playback_substream = NULL;
  536. return 0;
  537. }
  538. static int snd_es1688_capture_close(struct snd_pcm_substream *substream)
  539. {
  540. struct snd_es1688 *chip = snd_pcm_substream_chip(substream);
  541. chip->capture_substream = NULL;
  542. return 0;
  543. }
  544. static int snd_es1688_free(struct snd_es1688 *chip)
  545. {
  546. if (chip->res_port) {
  547. snd_es1688_init(chip, 0);
  548. release_and_free_resource(chip->res_port);
  549. }
  550. if (chip->irq >= 0)
  551. free_irq(chip->irq, (void *) chip);
  552. if (chip->dma8 >= 0) {
  553. disable_dma(chip->dma8);
  554. free_dma(chip->dma8);
  555. }
  556. kfree(chip);
  557. return 0;
  558. }
  559. static int snd_es1688_dev_free(struct snd_device *device)
  560. {
  561. struct snd_es1688 *chip = device->device_data;
  562. return snd_es1688_free(chip);
  563. }
  564. static const char *snd_es1688_chip_id(struct snd_es1688 *chip)
  565. {
  566. static char tmp[16];
  567. sprintf(tmp, "ES%s688 rev %i", chip->hardware == ES1688_HW_688 ? "" : "1", chip->version & 0x0f);
  568. return tmp;
  569. }
  570. int snd_es1688_create(struct snd_card *card,
  571. unsigned long port,
  572. unsigned long mpu_port,
  573. int irq,
  574. int mpu_irq,
  575. int dma8,
  576. unsigned short hardware,
  577. struct snd_es1688 **rchip)
  578. {
  579. static struct snd_device_ops ops = {
  580. .dev_free = snd_es1688_dev_free,
  581. };
  582. struct snd_es1688 *chip;
  583. int err;
  584. *rchip = NULL;
  585. chip = kzalloc(sizeof(*chip), GFP_KERNEL);
  586. if (chip == NULL)
  587. return -ENOMEM;
  588. chip->irq = -1;
  589. chip->dma8 = -1;
  590. if ((chip->res_port = request_region(port + 4, 12, "ES1688")) == NULL) {
  591. snd_printk(KERN_ERR "es1688: can't grab port 0x%lx\n", port + 4);
  592. snd_es1688_free(chip);
  593. return -EBUSY;
  594. }
  595. if (request_irq(irq, snd_es1688_interrupt, IRQF_DISABLED, "ES1688", (void *) chip)) {
  596. snd_printk(KERN_ERR "es1688: can't grab IRQ %d\n", irq);
  597. snd_es1688_free(chip);
  598. return -EBUSY;
  599. }
  600. chip->irq = irq;
  601. if (request_dma(dma8, "ES1688")) {
  602. snd_printk(KERN_ERR "es1688: can't grab DMA8 %d\n", dma8);
  603. snd_es1688_free(chip);
  604. return -EBUSY;
  605. }
  606. chip->dma8 = dma8;
  607. spin_lock_init(&chip->reg_lock);
  608. spin_lock_init(&chip->mixer_lock);
  609. chip->card = card;
  610. chip->port = port;
  611. mpu_port &= ~0x000f;
  612. if (mpu_port < 0x300 || mpu_port > 0x330)
  613. mpu_port = 0;
  614. chip->mpu_port = mpu_port;
  615. chip->mpu_irq = mpu_irq;
  616. chip->hardware = hardware;
  617. if ((err = snd_es1688_probe(chip)) < 0) {
  618. snd_es1688_free(chip);
  619. return err;
  620. }
  621. if ((err = snd_es1688_init(chip, 1)) < 0) {
  622. snd_es1688_free(chip);
  623. return err;
  624. }
  625. /* Register device */
  626. if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
  627. snd_es1688_free(chip);
  628. return err;
  629. }
  630. *rchip = chip;
  631. return 0;
  632. }
  633. static struct snd_pcm_ops snd_es1688_playback_ops = {
  634. .open = snd_es1688_playback_open,
  635. .close = snd_es1688_playback_close,
  636. .ioctl = snd_es1688_ioctl,
  637. .hw_params = snd_es1688_hw_params,
  638. .hw_free = snd_es1688_hw_free,
  639. .prepare = snd_es1688_playback_prepare,
  640. .trigger = snd_es1688_playback_trigger,
  641. .pointer = snd_es1688_playback_pointer,
  642. };
  643. static struct snd_pcm_ops snd_es1688_capture_ops = {
  644. .open = snd_es1688_capture_open,
  645. .close = snd_es1688_capture_close,
  646. .ioctl = snd_es1688_ioctl,
  647. .hw_params = snd_es1688_hw_params,
  648. .hw_free = snd_es1688_hw_free,
  649. .prepare = snd_es1688_capture_prepare,
  650. .trigger = snd_es1688_capture_trigger,
  651. .pointer = snd_es1688_capture_pointer,
  652. };
  653. int snd_es1688_pcm(struct snd_es1688 * chip, int device, struct snd_pcm ** rpcm)
  654. {
  655. struct snd_pcm *pcm;
  656. int err;
  657. if ((err = snd_pcm_new(chip->card, "ESx688", device, 1, 1, &pcm)) < 0)
  658. return err;
  659. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_es1688_playback_ops);
  660. snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_es1688_capture_ops);
  661. pcm->private_data = chip;
  662. pcm->info_flags = SNDRV_PCM_INFO_HALF_DUPLEX;
  663. sprintf(pcm->name, snd_es1688_chip_id(chip));
  664. chip->pcm = pcm;
  665. snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
  666. snd_dma_isa_data(),
  667. 64*1024, 64*1024);
  668. if (rpcm)
  669. *rpcm = pcm;
  670. return 0;
  671. }
  672. /*
  673. * MIXER part
  674. */
  675. static int snd_es1688_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  676. {
  677. static char *texts[9] = {
  678. "Mic", "Mic Master", "CD", "AOUT",
  679. "Mic1", "Mix", "Line", "Master"
  680. };
  681. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  682. uinfo->count = 1;
  683. uinfo->value.enumerated.items = 8;
  684. if (uinfo->value.enumerated.item > 7)
  685. uinfo->value.enumerated.item = 7;
  686. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  687. return 0;
  688. }
  689. static int snd_es1688_get_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  690. {
  691. struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
  692. ucontrol->value.enumerated.item[0] = snd_es1688_mixer_read(chip, ES1688_REC_DEV) & 7;
  693. return 0;
  694. }
  695. static int snd_es1688_put_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  696. {
  697. struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
  698. unsigned long flags;
  699. unsigned char oval, nval;
  700. int change;
  701. if (ucontrol->value.enumerated.item[0] > 8)
  702. return -EINVAL;
  703. spin_lock_irqsave(&chip->reg_lock, flags);
  704. oval = snd_es1688_mixer_read(chip, ES1688_REC_DEV);
  705. nval = (ucontrol->value.enumerated.item[0] & 7) | (oval & ~15);
  706. change = nval != oval;
  707. if (change)
  708. snd_es1688_mixer_write(chip, ES1688_REC_DEV, nval);
  709. spin_unlock_irqrestore(&chip->reg_lock, flags);
  710. return change;
  711. }
  712. #define ES1688_SINGLE(xname, xindex, reg, shift, mask, invert) \
  713. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  714. .info = snd_es1688_info_single, \
  715. .get = snd_es1688_get_single, .put = snd_es1688_put_single, \
  716. .private_value = reg | (shift << 8) | (mask << 16) | (invert << 24) }
  717. static int snd_es1688_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  718. {
  719. int mask = (kcontrol->private_value >> 16) & 0xff;
  720. uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
  721. uinfo->count = 1;
  722. uinfo->value.integer.min = 0;
  723. uinfo->value.integer.max = mask;
  724. return 0;
  725. }
  726. static int snd_es1688_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  727. {
  728. struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
  729. unsigned long flags;
  730. int reg = kcontrol->private_value & 0xff;
  731. int shift = (kcontrol->private_value >> 8) & 0xff;
  732. int mask = (kcontrol->private_value >> 16) & 0xff;
  733. int invert = (kcontrol->private_value >> 24) & 0xff;
  734. spin_lock_irqsave(&chip->reg_lock, flags);
  735. ucontrol->value.integer.value[0] = (snd_es1688_mixer_read(chip, reg) >> shift) & mask;
  736. spin_unlock_irqrestore(&chip->reg_lock, flags);
  737. if (invert)
  738. ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
  739. return 0;
  740. }
  741. static int snd_es1688_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  742. {
  743. struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
  744. unsigned long flags;
  745. int reg = kcontrol->private_value & 0xff;
  746. int shift = (kcontrol->private_value >> 8) & 0xff;
  747. int mask = (kcontrol->private_value >> 16) & 0xff;
  748. int invert = (kcontrol->private_value >> 24) & 0xff;
  749. int change;
  750. unsigned char oval, nval;
  751. nval = (ucontrol->value.integer.value[0] & mask);
  752. if (invert)
  753. nval = mask - nval;
  754. nval <<= shift;
  755. spin_lock_irqsave(&chip->reg_lock, flags);
  756. oval = snd_es1688_mixer_read(chip, reg);
  757. nval = (oval & ~(mask << shift)) | nval;
  758. change = nval != oval;
  759. if (change)
  760. snd_es1688_mixer_write(chip, reg, nval);
  761. spin_unlock_irqrestore(&chip->reg_lock, flags);
  762. return change;
  763. }
  764. #define ES1688_DOUBLE(xname, xindex, left_reg, right_reg, shift_left, shift_right, mask, invert) \
  765. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  766. .info = snd_es1688_info_double, \
  767. .get = snd_es1688_get_double, .put = snd_es1688_put_double, \
  768. .private_value = left_reg | (right_reg << 8) | (shift_left << 16) | (shift_right << 19) | (mask << 24) | (invert << 22) }
  769. static int snd_es1688_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  770. {
  771. int mask = (kcontrol->private_value >> 24) & 0xff;
  772. uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
  773. uinfo->count = 2;
  774. uinfo->value.integer.min = 0;
  775. uinfo->value.integer.max = mask;
  776. return 0;
  777. }
  778. static int snd_es1688_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  779. {
  780. struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
  781. unsigned long flags;
  782. int left_reg = kcontrol->private_value & 0xff;
  783. int right_reg = (kcontrol->private_value >> 8) & 0xff;
  784. int shift_left = (kcontrol->private_value >> 16) & 0x07;
  785. int shift_right = (kcontrol->private_value >> 19) & 0x07;
  786. int mask = (kcontrol->private_value >> 24) & 0xff;
  787. int invert = (kcontrol->private_value >> 22) & 1;
  788. unsigned char left, right;
  789. spin_lock_irqsave(&chip->reg_lock, flags);
  790. if (left_reg < 0xa0)
  791. left = snd_es1688_mixer_read(chip, left_reg);
  792. else
  793. left = snd_es1688_read(chip, left_reg);
  794. if (left_reg != right_reg) {
  795. if (right_reg < 0xa0)
  796. right = snd_es1688_mixer_read(chip, right_reg);
  797. else
  798. right = snd_es1688_read(chip, right_reg);
  799. } else
  800. right = left;
  801. spin_unlock_irqrestore(&chip->reg_lock, flags);
  802. ucontrol->value.integer.value[0] = (left >> shift_left) & mask;
  803. ucontrol->value.integer.value[1] = (right >> shift_right) & mask;
  804. if (invert) {
  805. ucontrol->value.integer.value[0] = mask - ucontrol->value.integer.value[0];
  806. ucontrol->value.integer.value[1] = mask - ucontrol->value.integer.value[1];
  807. }
  808. return 0;
  809. }
  810. static int snd_es1688_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  811. {
  812. struct snd_es1688 *chip = snd_kcontrol_chip(kcontrol);
  813. unsigned long flags;
  814. int left_reg = kcontrol->private_value & 0xff;
  815. int right_reg = (kcontrol->private_value >> 8) & 0xff;
  816. int shift_left = (kcontrol->private_value >> 16) & 0x07;
  817. int shift_right = (kcontrol->private_value >> 19) & 0x07;
  818. int mask = (kcontrol->private_value >> 24) & 0xff;
  819. int invert = (kcontrol->private_value >> 22) & 1;
  820. int change;
  821. unsigned char val1, val2, oval1, oval2;
  822. val1 = ucontrol->value.integer.value[0] & mask;
  823. val2 = ucontrol->value.integer.value[1] & mask;
  824. if (invert) {
  825. val1 = mask - val1;
  826. val2 = mask - val2;
  827. }
  828. val1 <<= shift_left;
  829. val2 <<= shift_right;
  830. spin_lock_irqsave(&chip->reg_lock, flags);
  831. if (left_reg != right_reg) {
  832. if (left_reg < 0xa0)
  833. oval1 = snd_es1688_mixer_read(chip, left_reg);
  834. else
  835. oval1 = snd_es1688_read(chip, left_reg);
  836. if (right_reg < 0xa0)
  837. oval2 = snd_es1688_mixer_read(chip, right_reg);
  838. else
  839. oval2 = snd_es1688_read(chip, right_reg);
  840. val1 = (oval1 & ~(mask << shift_left)) | val1;
  841. val2 = (oval2 & ~(mask << shift_right)) | val2;
  842. change = val1 != oval1 || val2 != oval2;
  843. if (change) {
  844. if (left_reg < 0xa0)
  845. snd_es1688_mixer_write(chip, left_reg, val1);
  846. else
  847. snd_es1688_write(chip, left_reg, val1);
  848. if (right_reg < 0xa0)
  849. snd_es1688_mixer_write(chip, right_reg, val1);
  850. else
  851. snd_es1688_write(chip, right_reg, val1);
  852. }
  853. } else {
  854. if (left_reg < 0xa0)
  855. oval1 = snd_es1688_mixer_read(chip, left_reg);
  856. else
  857. oval1 = snd_es1688_read(chip, left_reg);
  858. val1 = (oval1 & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2;
  859. change = val1 != oval1;
  860. if (change) {
  861. if (left_reg < 0xa0)
  862. snd_es1688_mixer_write(chip, left_reg, val1);
  863. else
  864. snd_es1688_write(chip, left_reg, val1);
  865. }
  866. }
  867. spin_unlock_irqrestore(&chip->reg_lock, flags);
  868. return change;
  869. }
  870. static struct snd_kcontrol_new snd_es1688_controls[] = {
  871. ES1688_DOUBLE("Master Playback Volume", 0, ES1688_MASTER_DEV, ES1688_MASTER_DEV, 4, 0, 15, 0),
  872. ES1688_DOUBLE("PCM Playback Volume", 0, ES1688_PCM_DEV, ES1688_PCM_DEV, 4, 0, 15, 0),
  873. ES1688_DOUBLE("Line Playback Volume", 0, ES1688_LINE_DEV, ES1688_LINE_DEV, 4, 0, 15, 0),
  874. ES1688_DOUBLE("CD Playback Volume", 0, ES1688_CD_DEV, ES1688_CD_DEV, 4, 0, 15, 0),
  875. ES1688_DOUBLE("FM Playback Volume", 0, ES1688_FM_DEV, ES1688_FM_DEV, 4, 0, 15, 0),
  876. ES1688_DOUBLE("Mic Playback Volume", 0, ES1688_MIC_DEV, ES1688_MIC_DEV, 4, 0, 15, 0),
  877. ES1688_DOUBLE("Aux Playback Volume", 0, ES1688_AUX_DEV, ES1688_AUX_DEV, 4, 0, 15, 0),
  878. ES1688_SINGLE("Beep Playback Volume", 0, ES1688_SPEAKER_DEV, 0, 7, 0),
  879. ES1688_DOUBLE("Capture Volume", 0, ES1688_RECLEV_DEV, ES1688_RECLEV_DEV, 4, 0, 15, 0),
  880. ES1688_SINGLE("Capture Switch", 0, ES1688_REC_DEV, 4, 1, 1),
  881. {
  882. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  883. .name = "Capture Source",
  884. .info = snd_es1688_info_mux,
  885. .get = snd_es1688_get_mux,
  886. .put = snd_es1688_put_mux,
  887. },
  888. };
  889. #define ES1688_INIT_TABLE_SIZE (sizeof(snd_es1688_init_table)/2)
  890. static unsigned char snd_es1688_init_table[][2] = {
  891. { ES1688_MASTER_DEV, 0 },
  892. { ES1688_PCM_DEV, 0 },
  893. { ES1688_LINE_DEV, 0 },
  894. { ES1688_CD_DEV, 0 },
  895. { ES1688_FM_DEV, 0 },
  896. { ES1688_MIC_DEV, 0 },
  897. { ES1688_AUX_DEV, 0 },
  898. { ES1688_SPEAKER_DEV, 0 },
  899. { ES1688_RECLEV_DEV, 0 },
  900. { ES1688_REC_DEV, 0x17 }
  901. };
  902. int snd_es1688_mixer(struct snd_es1688 *chip)
  903. {
  904. struct snd_card *card;
  905. unsigned int idx;
  906. int err;
  907. unsigned char reg, val;
  908. if (snd_BUG_ON(!chip || !chip->card))
  909. return -EINVAL;
  910. card = chip->card;
  911. strcpy(card->mixername, snd_es1688_chip_id(chip));
  912. for (idx = 0; idx < ARRAY_SIZE(snd_es1688_controls); idx++) {
  913. if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_es1688_controls[idx], chip))) < 0)
  914. return err;
  915. }
  916. for (idx = 0; idx < ES1688_INIT_TABLE_SIZE; idx++) {
  917. reg = snd_es1688_init_table[idx][0];
  918. val = snd_es1688_init_table[idx][1];
  919. if (reg < 0xa0)
  920. snd_es1688_mixer_write(chip, reg, val);
  921. else
  922. snd_es1688_write(chip, reg, val);
  923. }
  924. return 0;
  925. }
  926. EXPORT_SYMBOL(snd_es1688_mixer_write);
  927. EXPORT_SYMBOL(snd_es1688_create);
  928. EXPORT_SYMBOL(snd_es1688_pcm);
  929. EXPORT_SYMBOL(snd_es1688_mixer);
  930. /*
  931. * INIT part
  932. */
  933. static int __init alsa_es1688_init(void)
  934. {
  935. return 0;
  936. }
  937. static void __exit alsa_es1688_exit(void)
  938. {
  939. }
  940. module_init(alsa_es1688_init)
  941. module_exit(alsa_es1688_exit)