ak4xxx-adda.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. /*
  2. * ALSA driver for AK4524 / AK4528 / AK4529 / AK4355 / AK4358 / AK4381
  3. * AD and DA converters
  4. *
  5. * Copyright (c) 2000-2004 Jaroslav Kysela <perex@suse.cz>,
  6. * Takashi Iwai <tiwai@suse.de>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <sound/driver.h>
  24. #include <asm/io.h>
  25. #include <linux/delay.h>
  26. #include <linux/interrupt.h>
  27. #include <linux/init.h>
  28. #include <sound/core.h>
  29. #include <sound/control.h>
  30. #include <sound/ak4xxx-adda.h>
  31. MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Takashi Iwai <tiwai@suse.de>");
  32. MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters");
  33. MODULE_LICENSE("GPL");
  34. void snd_akm4xxx_write(akm4xxx_t *ak, int chip, unsigned char reg, unsigned char val)
  35. {
  36. ak->ops.lock(ak, chip);
  37. ak->ops.write(ak, chip, reg, val);
  38. /* save the data */
  39. if (ak->type == SND_AK4524 || ak->type == SND_AK4528) {
  40. if ((reg != 0x04 && reg != 0x05) || (val & 0x80) == 0)
  41. snd_akm4xxx_set(ak, chip, reg, val);
  42. else
  43. snd_akm4xxx_set_ipga(ak, chip, reg, val);
  44. } else {
  45. /* AK4529, or else */
  46. snd_akm4xxx_set(ak, chip, reg, val);
  47. }
  48. ak->ops.unlock(ak, chip);
  49. }
  50. /*
  51. * reset the AKM codecs
  52. * @state: 1 = reset codec, 0 = restore the registers
  53. *
  54. * assert the reset operation and restores the register values to the chips.
  55. */
  56. void snd_akm4xxx_reset(akm4xxx_t *ak, int state)
  57. {
  58. unsigned int chip;
  59. unsigned char reg;
  60. switch (ak->type) {
  61. case SND_AK4524:
  62. case SND_AK4528:
  63. for (chip = 0; chip < ak->num_dacs/2; chip++) {
  64. snd_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03);
  65. if (state)
  66. continue;
  67. /* DAC volumes */
  68. for (reg = 0x04; reg < (ak->type == SND_AK4528 ? 0x06 : 0x08); reg++)
  69. snd_akm4xxx_write(ak, chip, reg, snd_akm4xxx_get(ak, chip, reg));
  70. if (ak->type == SND_AK4528)
  71. continue;
  72. /* IPGA */
  73. for (reg = 0x04; reg < 0x06; reg++)
  74. snd_akm4xxx_write(ak, chip, reg, snd_akm4xxx_get_ipga(ak, chip, reg));
  75. }
  76. break;
  77. case SND_AK4529:
  78. /* FIXME: needed for ak4529? */
  79. break;
  80. case SND_AK4355:
  81. case SND_AK4358:
  82. if (state) {
  83. snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */
  84. return;
  85. }
  86. for (reg = 0x00; reg < 0x0b; reg++)
  87. if (reg != 0x01)
  88. snd_akm4xxx_write(ak, 0, reg, snd_akm4xxx_get(ak, 0, reg));
  89. snd_akm4xxx_write(ak, 0, 0x01, 0x01); /* un-reset, unmute */
  90. break;
  91. case SND_AK4381:
  92. for (chip = 0; chip < ak->num_dacs/2; chip++) {
  93. snd_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f);
  94. if (state)
  95. continue;
  96. for (reg = 0x01; reg < 0x05; reg++)
  97. snd_akm4xxx_write(ak, chip, reg, snd_akm4xxx_get(ak, chip, reg));
  98. }
  99. break;
  100. }
  101. }
  102. /*
  103. * initialize all the ak4xxx chips
  104. */
  105. void snd_akm4xxx_init(akm4xxx_t *ak)
  106. {
  107. static unsigned char inits_ak4524[] = {
  108. 0x00, 0x07, /* 0: all power up */
  109. 0x01, 0x00, /* 1: ADC/DAC reset */
  110. 0x02, 0x60, /* 2: 24bit I2S */
  111. 0x03, 0x19, /* 3: deemphasis off */
  112. 0x01, 0x03, /* 1: ADC/DAC enable */
  113. 0x04, 0x00, /* 4: ADC left muted */
  114. 0x05, 0x00, /* 5: ADC right muted */
  115. 0x04, 0x80, /* 4: ADC IPGA gain 0dB */
  116. 0x05, 0x80, /* 5: ADC IPGA gain 0dB */
  117. 0x06, 0x00, /* 6: DAC left muted */
  118. 0x07, 0x00, /* 7: DAC right muted */
  119. 0xff, 0xff
  120. };
  121. static unsigned char inits_ak4528[] = {
  122. 0x00, 0x07, /* 0: all power up */
  123. 0x01, 0x00, /* 1: ADC/DAC reset */
  124. 0x02, 0x60, /* 2: 24bit I2S */
  125. 0x03, 0x0d, /* 3: deemphasis off, turn LR highpass filters on */
  126. 0x01, 0x03, /* 1: ADC/DAC enable */
  127. 0x04, 0x00, /* 4: ADC left muted */
  128. 0x05, 0x00, /* 5: ADC right muted */
  129. 0xff, 0xff
  130. };
  131. static unsigned char inits_ak4529[] = {
  132. 0x09, 0x01, /* 9: ATS=0, RSTN=1 */
  133. 0x0a, 0x3f, /* A: all power up, no zero/overflow detection */
  134. 0x00, 0x0c, /* 0: TDM=0, 24bit I2S, SMUTE=0 */
  135. 0x01, 0x00, /* 1: ACKS=0, ADC, loop off */
  136. 0x02, 0xff, /* 2: LOUT1 muted */
  137. 0x03, 0xff, /* 3: ROUT1 muted */
  138. 0x04, 0xff, /* 4: LOUT2 muted */
  139. 0x05, 0xff, /* 5: ROUT2 muted */
  140. 0x06, 0xff, /* 6: LOUT3 muted */
  141. 0x07, 0xff, /* 7: ROUT3 muted */
  142. 0x0b, 0xff, /* B: LOUT4 muted */
  143. 0x0c, 0xff, /* C: ROUT4 muted */
  144. 0x08, 0x55, /* 8: deemphasis all off */
  145. 0xff, 0xff
  146. };
  147. static unsigned char inits_ak4355[] = {
  148. 0x01, 0x02, /* 1: reset and soft-mute */
  149. 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect, disable DZF, sharp roll-off, RSTN#=0 */
  150. 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */
  151. // 0x02, 0x2e, /* quad speed */
  152. 0x03, 0x01, /* 3: de-emphasis off */
  153. 0x04, 0x00, /* 4: LOUT1 volume muted */
  154. 0x05, 0x00, /* 5: ROUT1 volume muted */
  155. 0x06, 0x00, /* 6: LOUT2 volume muted */
  156. 0x07, 0x00, /* 7: ROUT2 volume muted */
  157. 0x08, 0x00, /* 8: LOUT3 volume muted */
  158. 0x09, 0x00, /* 9: ROUT3 volume muted */
  159. 0x0a, 0x00, /* a: DATT speed=0, ignore DZF */
  160. 0x01, 0x01, /* 1: un-reset, unmute */
  161. 0xff, 0xff
  162. };
  163. static unsigned char inits_ak4358[] = {
  164. 0x01, 0x02, /* 1: reset and soft-mute */
  165. 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect, disable DZF, sharp roll-off, RSTN#=0 */
  166. 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */
  167. // 0x02, 0x2e, /* quad speed */
  168. 0x03, 0x01, /* 3: de-emphasis off */
  169. 0x04, 0x00, /* 4: LOUT1 volume muted */
  170. 0x05, 0x00, /* 5: ROUT1 volume muted */
  171. 0x06, 0x00, /* 6: LOUT2 volume muted */
  172. 0x07, 0x00, /* 7: ROUT2 volume muted */
  173. 0x08, 0x00, /* 8: LOUT3 volume muted */
  174. 0x09, 0x00, /* 9: ROUT3 volume muted */
  175. 0x0b, 0x00, /* b: LOUT4 volume muted */
  176. 0x0c, 0x00, /* c: ROUT4 volume muted */
  177. 0x0a, 0x00, /* a: DATT speed=0, ignore DZF */
  178. 0x01, 0x01, /* 1: un-reset, unmute */
  179. 0xff, 0xff
  180. };
  181. static unsigned char inits_ak4381[] = {
  182. 0x00, 0x0c, /* 0: mode3(i2s), disable auto-clock detect */
  183. 0x01, 0x02, /* 1: de-emphasis off, normal speed, sharp roll-off, DZF off */
  184. // 0x01, 0x12, /* quad speed */
  185. 0x02, 0x00, /* 2: DZF disabled */
  186. 0x03, 0x00, /* 3: LATT 0 */
  187. 0x04, 0x00, /* 4: RATT 0 */
  188. 0x00, 0x0f, /* 0: power-up, un-reset */
  189. 0xff, 0xff
  190. };
  191. int chip, num_chips;
  192. unsigned char *ptr, reg, data, *inits;
  193. switch (ak->type) {
  194. case SND_AK4524:
  195. inits = inits_ak4524;
  196. num_chips = ak->num_dacs / 2;
  197. break;
  198. case SND_AK4528:
  199. inits = inits_ak4528;
  200. num_chips = ak->num_dacs / 2;
  201. break;
  202. case SND_AK4529:
  203. inits = inits_ak4529;
  204. num_chips = 1;
  205. break;
  206. case SND_AK4355:
  207. inits = inits_ak4355;
  208. num_chips = 1;
  209. break;
  210. case SND_AK4358:
  211. inits = inits_ak4358;
  212. num_chips = 1;
  213. break;
  214. case SND_AK4381:
  215. inits = inits_ak4381;
  216. num_chips = ak->num_dacs / 2;
  217. break;
  218. default:
  219. snd_BUG();
  220. return;
  221. }
  222. for (chip = 0; chip < num_chips; chip++) {
  223. ptr = inits;
  224. while (*ptr != 0xff) {
  225. reg = *ptr++;
  226. data = *ptr++;
  227. snd_akm4xxx_write(ak, chip, reg, data);
  228. }
  229. }
  230. }
  231. #define AK_GET_CHIP(val) (((val) >> 8) & 0xff)
  232. #define AK_GET_ADDR(val) ((val) & 0xff)
  233. #define AK_GET_SHIFT(val) (((val) >> 16) & 0x7f)
  234. #define AK_GET_INVERT(val) (((val) >> 23) & 1)
  235. #define AK_GET_MASK(val) (((val) >> 24) & 0xff)
  236. #define AK_COMPOSE(chip,addr,shift,mask) (((chip) << 8) | (addr) | ((shift) << 16) | ((mask) << 24))
  237. #define AK_INVERT (1<<23)
  238. static int snd_akm4xxx_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
  239. {
  240. unsigned int mask = AK_GET_MASK(kcontrol->private_value);
  241. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  242. uinfo->count = 1;
  243. uinfo->value.integer.min = 0;
  244. uinfo->value.integer.max = mask;
  245. return 0;
  246. }
  247. static int snd_akm4xxx_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  248. {
  249. akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);
  250. int chip = AK_GET_CHIP(kcontrol->private_value);
  251. int addr = AK_GET_ADDR(kcontrol->private_value);
  252. int invert = AK_GET_INVERT(kcontrol->private_value);
  253. unsigned int mask = AK_GET_MASK(kcontrol->private_value);
  254. unsigned char val = snd_akm4xxx_get(ak, chip, addr);
  255. ucontrol->value.integer.value[0] = invert ? mask - val : val;
  256. return 0;
  257. }
  258. static int snd_akm4xxx_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  259. {
  260. akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);
  261. int chip = AK_GET_CHIP(kcontrol->private_value);
  262. int addr = AK_GET_ADDR(kcontrol->private_value);
  263. int invert = AK_GET_INVERT(kcontrol->private_value);
  264. unsigned int mask = AK_GET_MASK(kcontrol->private_value);
  265. unsigned char nval = ucontrol->value.integer.value[0] % (mask+1);
  266. int change;
  267. if (invert)
  268. nval = mask - nval;
  269. change = snd_akm4xxx_get(ak, chip, addr) != nval;
  270. if (change)
  271. snd_akm4xxx_write(ak, chip, addr, nval);
  272. return change;
  273. }
  274. static int snd_akm4xxx_ipga_gain_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo)
  275. {
  276. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  277. uinfo->count = 1;
  278. uinfo->value.integer.min = 0;
  279. uinfo->value.integer.max = 36;
  280. return 0;
  281. }
  282. static int snd_akm4xxx_ipga_gain_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  283. {
  284. akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);
  285. int chip = AK_GET_CHIP(kcontrol->private_value);
  286. int addr = AK_GET_ADDR(kcontrol->private_value);
  287. ucontrol->value.integer.value[0] = snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f;
  288. return 0;
  289. }
  290. static int snd_akm4xxx_ipga_gain_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  291. {
  292. akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);
  293. int chip = AK_GET_CHIP(kcontrol->private_value);
  294. int addr = AK_GET_ADDR(kcontrol->private_value);
  295. unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80;
  296. int change = snd_akm4xxx_get_ipga(ak, chip, addr) != nval;
  297. if (change)
  298. snd_akm4xxx_write(ak, chip, addr, nval);
  299. return change;
  300. }
  301. static int snd_akm4xxx_deemphasis_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *uinfo)
  302. {
  303. static char *texts[4] = {
  304. "44.1kHz", "Off", "48kHz", "32kHz",
  305. };
  306. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  307. uinfo->count = 1;
  308. uinfo->value.enumerated.items = 4;
  309. if (uinfo->value.enumerated.item >= 4)
  310. uinfo->value.enumerated.item = 3;
  311. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  312. return 0;
  313. }
  314. static int snd_akm4xxx_deemphasis_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t *ucontrol)
  315. {
  316. akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);
  317. int chip = AK_GET_CHIP(kcontrol->private_value);
  318. int addr = AK_GET_ADDR(kcontrol->private_value);
  319. int shift = AK_GET_SHIFT(kcontrol->private_value);
  320. ucontrol->value.enumerated.item[0] = (snd_akm4xxx_get(ak, chip, addr) >> shift) & 3;
  321. return 0;
  322. }
  323. static int snd_akm4xxx_deemphasis_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *ucontrol)
  324. {
  325. akm4xxx_t *ak = snd_kcontrol_chip(kcontrol);
  326. int chip = AK_GET_CHIP(kcontrol->private_value);
  327. int addr = AK_GET_ADDR(kcontrol->private_value);
  328. int shift = AK_GET_SHIFT(kcontrol->private_value);
  329. unsigned char nval = ucontrol->value.enumerated.item[0] & 3;
  330. int change;
  331. nval = (nval << shift) | (snd_akm4xxx_get(ak, chip, addr) & ~(3 << shift));
  332. change = snd_akm4xxx_get(ak, chip, addr) != nval;
  333. if (change)
  334. snd_akm4xxx_write(ak, chip, addr, nval);
  335. return change;
  336. }
  337. /*
  338. * build AK4xxx controls
  339. */
  340. int snd_akm4xxx_build_controls(akm4xxx_t *ak)
  341. {
  342. unsigned int idx, num_emphs;
  343. snd_kcontrol_t *ctl;
  344. int err;
  345. ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);
  346. if (! ctl)
  347. return -ENOMEM;
  348. for (idx = 0; idx < ak->num_dacs; ++idx) {
  349. memset(ctl, 0, sizeof(*ctl));
  350. strcpy(ctl->id.name, "DAC Volume");
  351. ctl->id.index = idx + ak->idx_offset * 2;
  352. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  353. ctl->count = 1;
  354. ctl->info = snd_akm4xxx_volume_info;
  355. ctl->get = snd_akm4xxx_volume_get;
  356. ctl->put = snd_akm4xxx_volume_put;
  357. switch (ak->type) {
  358. case SND_AK4524:
  359. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127); /* register 6 & 7 */
  360. break;
  361. case SND_AK4528:
  362. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */
  363. break;
  364. case SND_AK4529: {
  365. int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb; /* registers 2-7 and b,c */
  366. ctl->private_value = AK_COMPOSE(0, val, 0, 255) | AK_INVERT;
  367. break;
  368. }
  369. case SND_AK4355:
  370. ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */
  371. break;
  372. case SND_AK4358:
  373. if (idx >= 6)
  374. ctl->private_value = AK_COMPOSE(0, idx + 5, 0, 255); /* register 4-9, chip #0 only */
  375. else
  376. ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */
  377. break;
  378. case SND_AK4381:
  379. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); /* register 3 & 4 */
  380. break;
  381. default:
  382. err = -EINVAL;
  383. goto __error;
  384. }
  385. ctl->private_data = ak;
  386. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  387. goto __error;
  388. }
  389. for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) {
  390. memset(ctl, 0, sizeof(*ctl));
  391. strcpy(ctl->id.name, "ADC Volume");
  392. ctl->id.index = idx + ak->idx_offset * 2;
  393. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  394. ctl->count = 1;
  395. ctl->info = snd_akm4xxx_volume_info;
  396. ctl->get = snd_akm4xxx_volume_get;
  397. ctl->put = snd_akm4xxx_volume_put;
  398. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */
  399. ctl->private_data = ak;
  400. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  401. goto __error;
  402. memset(ctl, 0, sizeof(*ctl));
  403. strcpy(ctl->id.name, "IPGA Analog Capture Volume");
  404. ctl->id.index = idx + ak->idx_offset * 2;
  405. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  406. ctl->count = 1;
  407. ctl->info = snd_akm4xxx_ipga_gain_info;
  408. ctl->get = snd_akm4xxx_ipga_gain_get;
  409. ctl->put = snd_akm4xxx_ipga_gain_put;
  410. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0); /* register 4 & 5 */
  411. ctl->private_data = ak;
  412. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  413. goto __error;
  414. }
  415. if (ak->type == SND_AK4355 || ak->type == SND_AK4358)
  416. num_emphs = 1;
  417. else
  418. num_emphs = ak->num_dacs / 2;
  419. for (idx = 0; idx < num_emphs; idx++) {
  420. memset(ctl, 0, sizeof(*ctl));
  421. strcpy(ctl->id.name, "Deemphasis");
  422. ctl->id.index = idx + ak->idx_offset;
  423. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  424. ctl->count = 1;
  425. ctl->info = snd_akm4xxx_deemphasis_info;
  426. ctl->get = snd_akm4xxx_deemphasis_get;
  427. ctl->put = snd_akm4xxx_deemphasis_put;
  428. switch (ak->type) {
  429. case SND_AK4524:
  430. case SND_AK4528:
  431. ctl->private_value = AK_COMPOSE(idx, 3, 0, 0); /* register 3 */
  432. break;
  433. case SND_AK4529: {
  434. int shift = idx == 3 ? 6 : (2 - idx) * 2;
  435. ctl->private_value = AK_COMPOSE(0, 8, shift, 0); /* register 8 with shift */
  436. break;
  437. }
  438. case SND_AK4355:
  439. case SND_AK4358:
  440. ctl->private_value = AK_COMPOSE(idx, 3, 0, 0);
  441. break;
  442. case SND_AK4381:
  443. ctl->private_value = AK_COMPOSE(idx, 1, 1, 0);
  444. break;
  445. }
  446. ctl->private_data = ak;
  447. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  448. goto __error;
  449. }
  450. err = 0;
  451. __error:
  452. kfree(ctl);
  453. return err;
  454. }
  455. static int __init alsa_akm4xxx_module_init(void)
  456. {
  457. return 0;
  458. }
  459. static void __exit alsa_akm4xxx_module_exit(void)
  460. {
  461. }
  462. module_init(alsa_akm4xxx_module_init)
  463. module_exit(alsa_akm4xxx_module_exit)
  464. EXPORT_SYMBOL(snd_akm4xxx_write);
  465. EXPORT_SYMBOL(snd_akm4xxx_reset);
  466. EXPORT_SYMBOL(snd_akm4xxx_init);
  467. EXPORT_SYMBOL(snd_akm4xxx_build_controls);