ak4xxx-adda.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  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(struct snd_akm4xxx *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(struct snd_akm4xxx *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(struct snd_akm4xxx *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(struct snd_kcontrol *kcontrol,
  239. struct snd_ctl_elem_info *uinfo)
  240. {
  241. unsigned int mask = AK_GET_MASK(kcontrol->private_value);
  242. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  243. uinfo->count = 1;
  244. uinfo->value.integer.min = 0;
  245. uinfo->value.integer.max = mask;
  246. return 0;
  247. }
  248. static int snd_akm4xxx_volume_get(struct snd_kcontrol *kcontrol,
  249. struct snd_ctl_elem_value *ucontrol)
  250. {
  251. struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
  252. int chip = AK_GET_CHIP(kcontrol->private_value);
  253. int addr = AK_GET_ADDR(kcontrol->private_value);
  254. int invert = AK_GET_INVERT(kcontrol->private_value);
  255. unsigned int mask = AK_GET_MASK(kcontrol->private_value);
  256. unsigned char val = snd_akm4xxx_get(ak, chip, addr);
  257. ucontrol->value.integer.value[0] = invert ? mask - val : val;
  258. return 0;
  259. }
  260. static int snd_akm4xxx_volume_put(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_value *ucontrol)
  262. {
  263. struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
  264. int chip = AK_GET_CHIP(kcontrol->private_value);
  265. int addr = AK_GET_ADDR(kcontrol->private_value);
  266. int invert = AK_GET_INVERT(kcontrol->private_value);
  267. unsigned int mask = AK_GET_MASK(kcontrol->private_value);
  268. unsigned char nval = ucontrol->value.integer.value[0] % (mask+1);
  269. int change;
  270. if (invert)
  271. nval = mask - nval;
  272. change = snd_akm4xxx_get(ak, chip, addr) != nval;
  273. if (change)
  274. snd_akm4xxx_write(ak, chip, addr, nval);
  275. return change;
  276. }
  277. static int snd_akm4xxx_ipga_gain_info(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_info *uinfo)
  279. {
  280. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  281. uinfo->count = 1;
  282. uinfo->value.integer.min = 0;
  283. uinfo->value.integer.max = 36;
  284. return 0;
  285. }
  286. static int snd_akm4xxx_ipga_gain_get(struct snd_kcontrol *kcontrol,
  287. struct snd_ctl_elem_value *ucontrol)
  288. {
  289. struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
  290. int chip = AK_GET_CHIP(kcontrol->private_value);
  291. int addr = AK_GET_ADDR(kcontrol->private_value);
  292. ucontrol->value.integer.value[0] = snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f;
  293. return 0;
  294. }
  295. static int snd_akm4xxx_ipga_gain_put(struct snd_kcontrol *kcontrol,
  296. struct snd_ctl_elem_value *ucontrol)
  297. {
  298. struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
  299. int chip = AK_GET_CHIP(kcontrol->private_value);
  300. int addr = AK_GET_ADDR(kcontrol->private_value);
  301. unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80;
  302. int change = snd_akm4xxx_get_ipga(ak, chip, addr) != nval;
  303. if (change)
  304. snd_akm4xxx_write(ak, chip, addr, nval);
  305. return change;
  306. }
  307. static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol,
  308. struct snd_ctl_elem_info *uinfo)
  309. {
  310. static char *texts[4] = {
  311. "44.1kHz", "Off", "48kHz", "32kHz",
  312. };
  313. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  314. uinfo->count = 1;
  315. uinfo->value.enumerated.items = 4;
  316. if (uinfo->value.enumerated.item >= 4)
  317. uinfo->value.enumerated.item = 3;
  318. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  319. return 0;
  320. }
  321. static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol,
  322. struct snd_ctl_elem_value *ucontrol)
  323. {
  324. struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
  325. int chip = AK_GET_CHIP(kcontrol->private_value);
  326. int addr = AK_GET_ADDR(kcontrol->private_value);
  327. int shift = AK_GET_SHIFT(kcontrol->private_value);
  328. ucontrol->value.enumerated.item[0] = (snd_akm4xxx_get(ak, chip, addr) >> shift) & 3;
  329. return 0;
  330. }
  331. static int snd_akm4xxx_deemphasis_put(struct snd_kcontrol *kcontrol,
  332. struct snd_ctl_elem_value *ucontrol)
  333. {
  334. struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
  335. int chip = AK_GET_CHIP(kcontrol->private_value);
  336. int addr = AK_GET_ADDR(kcontrol->private_value);
  337. int shift = AK_GET_SHIFT(kcontrol->private_value);
  338. unsigned char nval = ucontrol->value.enumerated.item[0] & 3;
  339. int change;
  340. nval = (nval << shift) | (snd_akm4xxx_get(ak, chip, addr) & ~(3 << shift));
  341. change = snd_akm4xxx_get(ak, chip, addr) != nval;
  342. if (change)
  343. snd_akm4xxx_write(ak, chip, addr, nval);
  344. return change;
  345. }
  346. /*
  347. * build AK4xxx controls
  348. */
  349. int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
  350. {
  351. unsigned int idx, num_emphs;
  352. struct snd_kcontrol *ctl;
  353. int err;
  354. ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);
  355. if (! ctl)
  356. return -ENOMEM;
  357. for (idx = 0; idx < ak->num_dacs; ++idx) {
  358. memset(ctl, 0, sizeof(*ctl));
  359. strcpy(ctl->id.name, "DAC Volume");
  360. ctl->id.index = idx + ak->idx_offset * 2;
  361. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  362. ctl->count = 1;
  363. ctl->info = snd_akm4xxx_volume_info;
  364. ctl->get = snd_akm4xxx_volume_get;
  365. ctl->put = snd_akm4xxx_volume_put;
  366. switch (ak->type) {
  367. case SND_AK4524:
  368. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127); /* register 6 & 7 */
  369. break;
  370. case SND_AK4528:
  371. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */
  372. break;
  373. case SND_AK4529: {
  374. int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb; /* registers 2-7 and b,c */
  375. ctl->private_value = AK_COMPOSE(0, val, 0, 255) | AK_INVERT;
  376. break;
  377. }
  378. case SND_AK4355:
  379. ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */
  380. break;
  381. case SND_AK4358:
  382. if (idx >= 6)
  383. ctl->private_value = AK_COMPOSE(0, idx + 5, 0, 255); /* register 4-9, chip #0 only */
  384. else
  385. ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255); /* register 4-9, chip #0 only */
  386. break;
  387. case SND_AK4381:
  388. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255); /* register 3 & 4 */
  389. break;
  390. default:
  391. err = -EINVAL;
  392. goto __error;
  393. }
  394. ctl->private_data = ak;
  395. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  396. goto __error;
  397. }
  398. for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) {
  399. memset(ctl, 0, sizeof(*ctl));
  400. strcpy(ctl->id.name, "ADC Volume");
  401. ctl->id.index = idx + ak->idx_offset * 2;
  402. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  403. ctl->count = 1;
  404. ctl->info = snd_akm4xxx_volume_info;
  405. ctl->get = snd_akm4xxx_volume_get;
  406. ctl->put = snd_akm4xxx_volume_put;
  407. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127); /* register 4 & 5 */
  408. ctl->private_data = ak;
  409. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  410. goto __error;
  411. memset(ctl, 0, sizeof(*ctl));
  412. strcpy(ctl->id.name, "IPGA Analog Capture Volume");
  413. ctl->id.index = idx + ak->idx_offset * 2;
  414. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  415. ctl->count = 1;
  416. ctl->info = snd_akm4xxx_ipga_gain_info;
  417. ctl->get = snd_akm4xxx_ipga_gain_get;
  418. ctl->put = snd_akm4xxx_ipga_gain_put;
  419. ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0); /* register 4 & 5 */
  420. ctl->private_data = ak;
  421. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  422. goto __error;
  423. }
  424. if (ak->type == SND_AK4355 || ak->type == SND_AK4358)
  425. num_emphs = 1;
  426. else
  427. num_emphs = ak->num_dacs / 2;
  428. for (idx = 0; idx < num_emphs; idx++) {
  429. memset(ctl, 0, sizeof(*ctl));
  430. strcpy(ctl->id.name, "Deemphasis");
  431. ctl->id.index = idx + ak->idx_offset;
  432. ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
  433. ctl->count = 1;
  434. ctl->info = snd_akm4xxx_deemphasis_info;
  435. ctl->get = snd_akm4xxx_deemphasis_get;
  436. ctl->put = snd_akm4xxx_deemphasis_put;
  437. switch (ak->type) {
  438. case SND_AK4524:
  439. case SND_AK4528:
  440. ctl->private_value = AK_COMPOSE(idx, 3, 0, 0); /* register 3 */
  441. break;
  442. case SND_AK4529: {
  443. int shift = idx == 3 ? 6 : (2 - idx) * 2;
  444. ctl->private_value = AK_COMPOSE(0, 8, shift, 0); /* register 8 with shift */
  445. break;
  446. }
  447. case SND_AK4355:
  448. case SND_AK4358:
  449. ctl->private_value = AK_COMPOSE(idx, 3, 0, 0);
  450. break;
  451. case SND_AK4381:
  452. ctl->private_value = AK_COMPOSE(idx, 1, 1, 0);
  453. break;
  454. }
  455. ctl->private_data = ak;
  456. if ((err = snd_ctl_add(ak->card, snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|SNDRV_CTL_ELEM_ACCESS_WRITE))) < 0)
  457. goto __error;
  458. }
  459. err = 0;
  460. __error:
  461. kfree(ctl);
  462. return err;
  463. }
  464. static int __init alsa_akm4xxx_module_init(void)
  465. {
  466. return 0;
  467. }
  468. static void __exit alsa_akm4xxx_module_exit(void)
  469. {
  470. }
  471. module_init(alsa_akm4xxx_module_init)
  472. module_exit(alsa_akm4xxx_module_exit)
  473. EXPORT_SYMBOL(snd_akm4xxx_write);
  474. EXPORT_SYMBOL(snd_akm4xxx_reset);
  475. EXPORT_SYMBOL(snd_akm4xxx_init);
  476. EXPORT_SYMBOL(snd_akm4xxx_build_controls);