es1688_lib.c 30 KB

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