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