ak4531_codec.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. /*
  2. * Copyright (c) by Jaroslav Kysela <perex@suse.cz>
  3. * Universal routines for AK4531 codec
  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 <sound/driver.h>
  22. #include <linux/delay.h>
  23. #include <linux/init.h>
  24. #include <linux/slab.h>
  25. #include <linux/mutex.h>
  26. #include <sound/core.h>
  27. #include <sound/ak4531_codec.h>
  28. MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>");
  29. MODULE_DESCRIPTION("Universal routines for AK4531 codec");
  30. MODULE_LICENSE("GPL");
  31. #ifdef CONFIG_PROC_FS
  32. static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531);
  33. #else
  34. #define snd_ak4531_proc_init(card,ak)
  35. #endif
  36. /*
  37. *
  38. */
  39. #if 0
  40. static void snd_ak4531_dump(struct snd_ak4531 *ak4531)
  41. {
  42. int idx;
  43. for (idx = 0; idx < 0x19; idx++)
  44. printk("ak4531 0x%x: 0x%x\n", idx, ak4531->regs[idx]);
  45. }
  46. #endif
  47. /*
  48. *
  49. */
  50. #define AK4531_SINGLE(xname, xindex, reg, shift, mask, invert) \
  51. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  52. .info = snd_ak4531_info_single, \
  53. .get = snd_ak4531_get_single, .put = snd_ak4531_put_single, \
  54. .private_value = reg | (shift << 16) | (mask << 24) | (invert << 22) }
  55. static int snd_ak4531_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  56. {
  57. int mask = (kcontrol->private_value >> 24) & 0xff;
  58. uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
  59. uinfo->count = 1;
  60. uinfo->value.integer.min = 0;
  61. uinfo->value.integer.max = mask;
  62. return 0;
  63. }
  64. static int snd_ak4531_get_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  65. {
  66. struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol);
  67. int reg = kcontrol->private_value & 0xff;
  68. int shift = (kcontrol->private_value >> 16) & 0x07;
  69. int mask = (kcontrol->private_value >> 24) & 0xff;
  70. int invert = (kcontrol->private_value >> 22) & 1;
  71. int val;
  72. mutex_lock(&ak4531->reg_mutex);
  73. val = (ak4531->regs[reg] >> shift) & mask;
  74. mutex_unlock(&ak4531->reg_mutex);
  75. if (invert) {
  76. val = mask - val;
  77. }
  78. ucontrol->value.integer.value[0] = val;
  79. return 0;
  80. }
  81. static int snd_ak4531_put_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  82. {
  83. struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol);
  84. int reg = kcontrol->private_value & 0xff;
  85. int shift = (kcontrol->private_value >> 16) & 0x07;
  86. int mask = (kcontrol->private_value >> 24) & 0xff;
  87. int invert = (kcontrol->private_value >> 22) & 1;
  88. int change;
  89. int val;
  90. val = ucontrol->value.integer.value[0] & mask;
  91. if (invert) {
  92. val = mask - val;
  93. }
  94. val <<= shift;
  95. mutex_lock(&ak4531->reg_mutex);
  96. val = (ak4531->regs[reg] & ~(mask << shift)) | val;
  97. change = val != ak4531->regs[reg];
  98. ak4531->write(ak4531, reg, ak4531->regs[reg] = val);
  99. mutex_unlock(&ak4531->reg_mutex);
  100. return change;
  101. }
  102. #define AK4531_DOUBLE(xname, xindex, left_reg, right_reg, left_shift, right_shift, mask, invert) \
  103. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  104. .info = snd_ak4531_info_double, \
  105. .get = snd_ak4531_get_double, .put = snd_ak4531_put_double, \
  106. .private_value = left_reg | (right_reg << 8) | (left_shift << 16) | (right_shift << 19) | (mask << 24) | (invert << 22) }
  107. static int snd_ak4531_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  108. {
  109. int mask = (kcontrol->private_value >> 24) & 0xff;
  110. uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
  111. uinfo->count = 2;
  112. uinfo->value.integer.min = 0;
  113. uinfo->value.integer.max = mask;
  114. return 0;
  115. }
  116. static int snd_ak4531_get_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  117. {
  118. struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol);
  119. int left_reg = kcontrol->private_value & 0xff;
  120. int right_reg = (kcontrol->private_value >> 8) & 0xff;
  121. int left_shift = (kcontrol->private_value >> 16) & 0x07;
  122. int right_shift = (kcontrol->private_value >> 19) & 0x07;
  123. int mask = (kcontrol->private_value >> 24) & 0xff;
  124. int invert = (kcontrol->private_value >> 22) & 1;
  125. int left, right;
  126. mutex_lock(&ak4531->reg_mutex);
  127. left = (ak4531->regs[left_reg] >> left_shift) & mask;
  128. right = (ak4531->regs[right_reg] >> right_shift) & mask;
  129. mutex_unlock(&ak4531->reg_mutex);
  130. if (invert) {
  131. left = mask - left;
  132. right = mask - right;
  133. }
  134. ucontrol->value.integer.value[0] = left;
  135. ucontrol->value.integer.value[1] = right;
  136. return 0;
  137. }
  138. static int snd_ak4531_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  139. {
  140. struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol);
  141. int left_reg = kcontrol->private_value & 0xff;
  142. int right_reg = (kcontrol->private_value >> 8) & 0xff;
  143. int left_shift = (kcontrol->private_value >> 16) & 0x07;
  144. int right_shift = (kcontrol->private_value >> 19) & 0x07;
  145. int mask = (kcontrol->private_value >> 24) & 0xff;
  146. int invert = (kcontrol->private_value >> 22) & 1;
  147. int change;
  148. int left, right;
  149. left = ucontrol->value.integer.value[0] & mask;
  150. right = ucontrol->value.integer.value[1] & mask;
  151. if (invert) {
  152. left = mask - left;
  153. right = mask - right;
  154. }
  155. left <<= left_shift;
  156. right <<= right_shift;
  157. mutex_lock(&ak4531->reg_mutex);
  158. if (left_reg == right_reg) {
  159. left = (ak4531->regs[left_reg] & ~((mask << left_shift) | (mask << right_shift))) | left | right;
  160. change = left != ak4531->regs[left_reg];
  161. ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left);
  162. } else {
  163. left = (ak4531->regs[left_reg] & ~(mask << left_shift)) | left;
  164. right = (ak4531->regs[right_reg] & ~(mask << right_shift)) | right;
  165. change = left != ak4531->regs[left_reg] || right != ak4531->regs[right_reg];
  166. ak4531->write(ak4531, left_reg, ak4531->regs[left_reg] = left);
  167. ak4531->write(ak4531, right_reg, ak4531->regs[right_reg] = right);
  168. }
  169. mutex_unlock(&ak4531->reg_mutex);
  170. return change;
  171. }
  172. #define AK4531_INPUT_SW(xname, xindex, reg1, reg2, left_shift, right_shift) \
  173. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
  174. .info = snd_ak4531_info_input_sw, \
  175. .get = snd_ak4531_get_input_sw, .put = snd_ak4531_put_input_sw, \
  176. .private_value = reg1 | (reg2 << 8) | (left_shift << 16) | (right_shift << 24) }
  177. static int snd_ak4531_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  178. {
  179. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  180. uinfo->count = 4;
  181. uinfo->value.integer.min = 0;
  182. uinfo->value.integer.max = 1;
  183. return 0;
  184. }
  185. static int snd_ak4531_get_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  186. {
  187. struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol);
  188. int reg1 = kcontrol->private_value & 0xff;
  189. int reg2 = (kcontrol->private_value >> 8) & 0xff;
  190. int left_shift = (kcontrol->private_value >> 16) & 0x0f;
  191. int right_shift = (kcontrol->private_value >> 24) & 0x0f;
  192. mutex_lock(&ak4531->reg_mutex);
  193. ucontrol->value.integer.value[0] = (ak4531->regs[reg1] >> left_shift) & 1;
  194. ucontrol->value.integer.value[1] = (ak4531->regs[reg2] >> left_shift) & 1;
  195. ucontrol->value.integer.value[2] = (ak4531->regs[reg1] >> right_shift) & 1;
  196. ucontrol->value.integer.value[3] = (ak4531->regs[reg2] >> right_shift) & 1;
  197. mutex_unlock(&ak4531->reg_mutex);
  198. return 0;
  199. }
  200. static int snd_ak4531_put_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  201. {
  202. struct snd_ak4531 *ak4531 = snd_kcontrol_chip(kcontrol);
  203. int reg1 = kcontrol->private_value & 0xff;
  204. int reg2 = (kcontrol->private_value >> 8) & 0xff;
  205. int left_shift = (kcontrol->private_value >> 16) & 0x0f;
  206. int right_shift = (kcontrol->private_value >> 24) & 0x0f;
  207. int change;
  208. int val1, val2;
  209. mutex_lock(&ak4531->reg_mutex);
  210. val1 = ak4531->regs[reg1] & ~((1 << left_shift) | (1 << right_shift));
  211. val2 = ak4531->regs[reg2] & ~((1 << left_shift) | (1 << right_shift));
  212. val1 |= (ucontrol->value.integer.value[0] & 1) << left_shift;
  213. val2 |= (ucontrol->value.integer.value[1] & 1) << left_shift;
  214. val1 |= (ucontrol->value.integer.value[2] & 1) << right_shift;
  215. val2 |= (ucontrol->value.integer.value[3] & 1) << right_shift;
  216. change = val1 != ak4531->regs[reg1] || val2 != ak4531->regs[reg2];
  217. ak4531->write(ak4531, reg1, ak4531->regs[reg1] = val1);
  218. ak4531->write(ak4531, reg2, ak4531->regs[reg2] = val2);
  219. mutex_unlock(&ak4531->reg_mutex);
  220. return change;
  221. }
  222. static struct snd_kcontrol_new snd_ak4531_controls[] = {
  223. AK4531_DOUBLE("Master Playback Switch", 0, AK4531_LMASTER, AK4531_RMASTER, 7, 7, 1, 1),
  224. AK4531_DOUBLE("Master Playback Volume", 0, AK4531_LMASTER, AK4531_RMASTER, 0, 0, 0x1f, 1),
  225. AK4531_SINGLE("Master Mono Playback Switch", 0, AK4531_MONO_OUT, 7, 1, 1),
  226. AK4531_SINGLE("Master Mono Playback Volume", 0, AK4531_MONO_OUT, 0, 0x07, 1),
  227. AK4531_DOUBLE("PCM Switch", 0, AK4531_LVOICE, AK4531_RVOICE, 7, 7, 1, 1),
  228. AK4531_DOUBLE("PCM Volume", 0, AK4531_LVOICE, AK4531_RVOICE, 0, 0, 0x1f, 1),
  229. AK4531_DOUBLE("PCM Playback Switch", 0, AK4531_OUT_SW2, AK4531_OUT_SW2, 3, 2, 1, 0),
  230. AK4531_DOUBLE("PCM Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 2, 2, 1, 0),
  231. AK4531_DOUBLE("PCM Switch", 1, AK4531_LFM, AK4531_RFM, 7, 7, 1, 1),
  232. AK4531_DOUBLE("PCM Volume", 1, AK4531_LFM, AK4531_RFM, 0, 0, 0x1f, 1),
  233. AK4531_DOUBLE("PCM Playback Switch", 1, AK4531_OUT_SW1, AK4531_OUT_SW1, 6, 5, 1, 0),
  234. AK4531_INPUT_SW("PCM Capture Route", 1, AK4531_LIN_SW1, AK4531_RIN_SW1, 6, 5),
  235. AK4531_DOUBLE("CD Switch", 0, AK4531_LCD, AK4531_RCD, 7, 7, 1, 1),
  236. AK4531_DOUBLE("CD Volume", 0, AK4531_LCD, AK4531_RCD, 0, 0, 0x1f, 1),
  237. AK4531_DOUBLE("CD Playback Switch", 0, AK4531_OUT_SW1, AK4531_OUT_SW1, 2, 1, 1, 0),
  238. AK4531_INPUT_SW("CD Capture Route", 0, AK4531_LIN_SW1, AK4531_RIN_SW1, 2, 1),
  239. AK4531_DOUBLE("Line Switch", 0, AK4531_LLINE, AK4531_RLINE, 7, 7, 1, 1),
  240. AK4531_DOUBLE("Line Volume", 0, AK4531_LLINE, AK4531_RLINE, 0, 0, 0x1f, 1),
  241. AK4531_DOUBLE("Line Playback Switch", 0, AK4531_OUT_SW1, AK4531_OUT_SW1, 4, 3, 1, 0),
  242. AK4531_INPUT_SW("Line Capture Route", 0, AK4531_LIN_SW1, AK4531_RIN_SW1, 4, 3),
  243. AK4531_DOUBLE("Aux Switch", 0, AK4531_LAUXA, AK4531_RAUXA, 7, 7, 1, 1),
  244. AK4531_DOUBLE("Aux Volume", 0, AK4531_LAUXA, AK4531_RAUXA, 0, 0, 0x1f, 1),
  245. AK4531_DOUBLE("Aux Playback Switch", 0, AK4531_OUT_SW2, AK4531_OUT_SW2, 5, 4, 1, 0),
  246. AK4531_INPUT_SW("Aux Capture Route", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 4, 3),
  247. AK4531_SINGLE("Mono Switch", 0, AK4531_MONO1, 7, 1, 1),
  248. AK4531_SINGLE("Mono Volume", 0, AK4531_MONO1, 0, 0x1f, 1),
  249. AK4531_SINGLE("Mono Playback Switch", 0, AK4531_OUT_SW2, 0, 1, 0),
  250. AK4531_DOUBLE("Mono Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 0, 0, 1, 0),
  251. AK4531_SINGLE("Mono Switch", 1, AK4531_MONO2, 7, 1, 1),
  252. AK4531_SINGLE("Mono Volume", 1, AK4531_MONO2, 0, 0x1f, 1),
  253. AK4531_SINGLE("Mono Playback Switch", 1, AK4531_OUT_SW2, 1, 1, 0),
  254. AK4531_DOUBLE("Mono Capture Switch", 1, AK4531_LIN_SW2, AK4531_RIN_SW2, 1, 1, 1, 0),
  255. AK4531_SINGLE("Mic Volume", 0, AK4531_MIC, 0, 0x1f, 1),
  256. AK4531_SINGLE("Mic Switch", 0, AK4531_MIC, 7, 1, 1),
  257. AK4531_SINGLE("Mic Playback Switch", 0, AK4531_OUT_SW1, 0, 1, 0),
  258. AK4531_DOUBLE("Mic Capture Switch", 0, AK4531_LIN_SW1, AK4531_RIN_SW1, 0, 0, 1, 0),
  259. AK4531_DOUBLE("Mic Bypass Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 7, 7, 1, 0),
  260. AK4531_DOUBLE("Mono1 Bypass Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 6, 6, 1, 0),
  261. AK4531_DOUBLE("Mono2 Bypass Capture Switch", 0, AK4531_LIN_SW2, AK4531_RIN_SW2, 5, 5, 1, 0),
  262. AK4531_SINGLE("AD Input Select", 0, AK4531_AD_IN, 0, 1, 0),
  263. AK4531_SINGLE("Mic Boost (+30dB)", 0, AK4531_MIC_GAIN, 0, 1, 0)
  264. };
  265. static int snd_ak4531_free(struct snd_ak4531 *ak4531)
  266. {
  267. if (ak4531) {
  268. if (ak4531->private_free)
  269. ak4531->private_free(ak4531);
  270. kfree(ak4531);
  271. }
  272. return 0;
  273. }
  274. static int snd_ak4531_dev_free(struct snd_device *device)
  275. {
  276. struct snd_ak4531 *ak4531 = device->device_data;
  277. return snd_ak4531_free(ak4531);
  278. }
  279. static u8 snd_ak4531_initial_map[0x19 + 1] = {
  280. 0x9f, /* 00: Master Volume Lch */
  281. 0x9f, /* 01: Master Volume Rch */
  282. 0x9f, /* 02: Voice Volume Lch */
  283. 0x9f, /* 03: Voice Volume Rch */
  284. 0x9f, /* 04: FM Volume Lch */
  285. 0x9f, /* 05: FM Volume Rch */
  286. 0x9f, /* 06: CD Audio Volume Lch */
  287. 0x9f, /* 07: CD Audio Volume Rch */
  288. 0x9f, /* 08: Line Volume Lch */
  289. 0x9f, /* 09: Line Volume Rch */
  290. 0x9f, /* 0a: Aux Volume Lch */
  291. 0x9f, /* 0b: Aux Volume Rch */
  292. 0x9f, /* 0c: Mono1 Volume */
  293. 0x9f, /* 0d: Mono2 Volume */
  294. 0x9f, /* 0e: Mic Volume */
  295. 0x87, /* 0f: Mono-out Volume */
  296. 0x00, /* 10: Output Mixer SW1 */
  297. 0x00, /* 11: Output Mixer SW2 */
  298. 0x00, /* 12: Lch Input Mixer SW1 */
  299. 0x00, /* 13: Rch Input Mixer SW1 */
  300. 0x00, /* 14: Lch Input Mixer SW2 */
  301. 0x00, /* 15: Rch Input Mixer SW2 */
  302. 0x00, /* 16: Reset & Power Down */
  303. 0x00, /* 17: Clock Select */
  304. 0x00, /* 18: AD Input Select */
  305. 0x01 /* 19: Mic Amp Setup */
  306. };
  307. int snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531,
  308. struct snd_ak4531 **rak4531)
  309. {
  310. unsigned int idx;
  311. int err;
  312. struct snd_ak4531 *ak4531;
  313. static struct snd_device_ops ops = {
  314. .dev_free = snd_ak4531_dev_free,
  315. };
  316. snd_assert(rak4531 != NULL, return -EINVAL);
  317. *rak4531 = NULL;
  318. snd_assert(card != NULL && _ak4531 != NULL, return -EINVAL);
  319. ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL);
  320. if (ak4531 == NULL)
  321. return -ENOMEM;
  322. *ak4531 = *_ak4531;
  323. mutex_init(&ak4531->reg_mutex);
  324. if ((err = snd_component_add(card, "AK4531")) < 0) {
  325. snd_ak4531_free(ak4531);
  326. return err;
  327. }
  328. strcpy(card->mixername, "Asahi Kasei AK4531");
  329. ak4531->write(ak4531, AK4531_RESET, 0x03); /* no RST, PD */
  330. udelay(100);
  331. ak4531->write(ak4531, AK4531_CLOCK, 0x00); /* CODEC ADC and CODEC DAC use {LR,B}CLK2 and run off LRCLK2 PLL */
  332. for (idx = 0; idx <= 0x19; idx++) {
  333. if (idx == AK4531_RESET || idx == AK4531_CLOCK)
  334. continue;
  335. ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]); /* recording source is mixer */
  336. }
  337. for (idx = 0; idx < ARRAY_SIZE(snd_ak4531_controls); idx++) {
  338. if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ak4531_controls[idx], ak4531))) < 0) {
  339. snd_ak4531_free(ak4531);
  340. return err;
  341. }
  342. }
  343. snd_ak4531_proc_init(card, ak4531);
  344. if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops)) < 0) {
  345. snd_ak4531_free(ak4531);
  346. return err;
  347. }
  348. #if 0
  349. snd_ak4531_dump(ak4531);
  350. #endif
  351. *rak4531 = ak4531;
  352. return 0;
  353. }
  354. /*
  355. * power management
  356. */
  357. #ifdef CONFIG_PM
  358. void snd_ak4531_suspend(struct snd_ak4531 *ak4531)
  359. {
  360. /* mute */
  361. ak4531->write(ak4531, AK4531_LMASTER, 0x9f);
  362. ak4531->write(ak4531, AK4531_RMASTER, 0x9f);
  363. /* powerdown */
  364. ak4531->write(ak4531, AK4531_RESET, 0x01);
  365. }
  366. void snd_ak4531_resume(struct snd_ak4531 *ak4531)
  367. {
  368. int idx;
  369. /* initialize */
  370. ak4531->write(ak4531, AK4531_RESET, 0x03);
  371. udelay(100);
  372. ak4531->write(ak4531, AK4531_CLOCK, 0x00);
  373. /* restore mixer registers */
  374. for (idx = 0; idx <= 0x19; idx++) {
  375. if (idx == AK4531_RESET || idx == AK4531_CLOCK)
  376. continue;
  377. ak4531->write(ak4531, idx, ak4531->regs[idx]);
  378. }
  379. }
  380. #endif
  381. #ifdef CONFIG_PROC_FS
  382. /*
  383. * /proc interface
  384. */
  385. static void snd_ak4531_proc_read(struct snd_info_entry *entry,
  386. struct snd_info_buffer *buffer)
  387. {
  388. struct snd_ak4531 *ak4531 = entry->private_data;
  389. snd_iprintf(buffer, "Asahi Kasei AK4531\n\n");
  390. snd_iprintf(buffer, "Recording source : %s\n"
  391. "MIC gain : %s\n",
  392. ak4531->regs[AK4531_AD_IN] & 1 ? "external" : "mixer",
  393. ak4531->regs[AK4531_MIC_GAIN] & 1 ? "+30dB" : "+0dB");
  394. }
  395. static void snd_ak4531_proc_init(struct snd_card *card, struct snd_ak4531 *ak4531)
  396. {
  397. struct snd_info_entry *entry;
  398. if (! snd_card_proc_new(card, "ak4531", &entry))
  399. snd_info_set_text_ops(entry, ak4531, snd_ak4531_proc_read);
  400. }
  401. #endif
  402. EXPORT_SYMBOL(snd_ak4531_mixer);
  403. #ifdef CONFIG_PM
  404. EXPORT_SYMBOL(snd_ak4531_suspend);
  405. EXPORT_SYMBOL(snd_ak4531_resume);
  406. #endif
  407. /*
  408. * INIT part
  409. */
  410. static int __init alsa_ak4531_init(void)
  411. {
  412. return 0;
  413. }
  414. static void __exit alsa_ak4531_exit(void)
  415. {
  416. }
  417. module_init(alsa_ak4531_init)
  418. module_exit(alsa_ak4531_exit)