2 * ALSA driver for AK4524 / AK4528 / AK4529 / AK4355 / AK4358 / AK4381
5 * Copyright (c) 2000-2004 Jaroslav Kysela <perex@suse.cz>,
6 * Takashi Iwai <tiwai@suse.de>
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.
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.
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
24 #include <sound/driver.h>
26 #include <linux/delay.h>
27 #include <linux/interrupt.h>
28 #include <linux/init.h>
29 #include <sound/core.h>
30 #include <sound/control.h>
31 #include <sound/ak4xxx-adda.h>
33 MODULE_AUTHOR("Jaroslav Kysela <perex@suse.cz>, Takashi Iwai <tiwai@suse.de>");
34 MODULE_DESCRIPTION("Routines for control of AK452x / AK43xx AD/DA converters");
35 MODULE_LICENSE("GPL");
37 void snd_akm4xxx_write(struct snd_akm4xxx *ak, int chip, unsigned char reg,
40 ak->ops.lock(ak, chip);
41 ak->ops.write(ak, chip, reg, val);
44 if (ak->type == SND_AK4524 || ak->type == SND_AK4528) {
45 if ((reg != 0x04 && reg != 0x05) || (val & 0x80) == 0)
46 snd_akm4xxx_set(ak, chip, reg, val);
48 snd_akm4xxx_set_ipga(ak, chip, reg, val);
51 snd_akm4xxx_set(ak, chip, reg, val);
53 ak->ops.unlock(ak, chip);
56 EXPORT_SYMBOL(snd_akm4xxx_write);
58 /* reset procedure for AK4524 and AK4528 */
59 static void ak4524_reset(struct snd_akm4xxx *ak, int state)
62 unsigned char reg, maxreg;
64 if (ak->type == SND_AK4528)
68 for (chip = 0; chip < ak->num_dacs/2; chip++) {
69 snd_akm4xxx_write(ak, chip, 0x01, state ? 0x00 : 0x03);
73 for (reg = 0x04; reg < maxreg; reg++)
74 snd_akm4xxx_write(ak, chip, reg,
75 snd_akm4xxx_get(ak, chip, reg));
76 if (ak->type == SND_AK4528)
79 for (reg = 0x04; reg < 0x06; reg++)
80 snd_akm4xxx_write(ak, chip, reg,
81 snd_akm4xxx_get_ipga(ak, chip, reg));
85 /* reset procedure for AK4355 and AK4358 */
86 static void ak4355_reset(struct snd_akm4xxx *ak, int state)
91 snd_akm4xxx_write(ak, 0, 0x01, 0x02); /* reset and soft-mute */
94 for (reg = 0x00; reg < 0x0b; reg++)
96 snd_akm4xxx_write(ak, 0, reg,
97 snd_akm4xxx_get(ak, 0, reg));
98 snd_akm4xxx_write(ak, 0, 0x01, 0x01); /* un-reset, unmute */
101 /* reset procedure for AK4381 */
102 static void ak4381_reset(struct snd_akm4xxx *ak, int state)
107 for (chip = 0; chip < ak->num_dacs/2; chip++) {
108 snd_akm4xxx_write(ak, chip, 0x00, state ? 0x0c : 0x0f);
111 for (reg = 0x01; reg < 0x05; reg++)
112 snd_akm4xxx_write(ak, chip, reg,
113 snd_akm4xxx_get(ak, chip, reg));
118 * reset the AKM codecs
119 * @state: 1 = reset codec, 0 = restore the registers
121 * assert the reset operation and restores the register values to the chips.
123 void snd_akm4xxx_reset(struct snd_akm4xxx *ak, int state)
128 ak4524_reset(ak, state);
131 /* FIXME: needed for ak4529? */
135 ak4355_reset(ak, state);
138 ak4381_reset(ak, state);
145 EXPORT_SYMBOL(snd_akm4xxx_reset);
148 * initialize all the ak4xxx chips
150 void snd_akm4xxx_init(struct snd_akm4xxx *ak)
152 static unsigned char inits_ak4524[] = {
153 0x00, 0x07, /* 0: all power up */
154 0x01, 0x00, /* 1: ADC/DAC reset */
155 0x02, 0x60, /* 2: 24bit I2S */
156 0x03, 0x19, /* 3: deemphasis off */
157 0x01, 0x03, /* 1: ADC/DAC enable */
158 0x04, 0x00, /* 4: ADC left muted */
159 0x05, 0x00, /* 5: ADC right muted */
160 0x04, 0x80, /* 4: ADC IPGA gain 0dB */
161 0x05, 0x80, /* 5: ADC IPGA gain 0dB */
162 0x06, 0x00, /* 6: DAC left muted */
163 0x07, 0x00, /* 7: DAC right muted */
166 static unsigned char inits_ak4528[] = {
167 0x00, 0x07, /* 0: all power up */
168 0x01, 0x00, /* 1: ADC/DAC reset */
169 0x02, 0x60, /* 2: 24bit I2S */
170 0x03, 0x0d, /* 3: deemphasis off, turn LR highpass filters on */
171 0x01, 0x03, /* 1: ADC/DAC enable */
172 0x04, 0x00, /* 4: ADC left muted */
173 0x05, 0x00, /* 5: ADC right muted */
176 static unsigned char inits_ak4529[] = {
177 0x09, 0x01, /* 9: ATS=0, RSTN=1 */
178 0x0a, 0x3f, /* A: all power up, no zero/overflow detection */
179 0x00, 0x0c, /* 0: TDM=0, 24bit I2S, SMUTE=0 */
180 0x01, 0x00, /* 1: ACKS=0, ADC, loop off */
181 0x02, 0xff, /* 2: LOUT1 muted */
182 0x03, 0xff, /* 3: ROUT1 muted */
183 0x04, 0xff, /* 4: LOUT2 muted */
184 0x05, 0xff, /* 5: ROUT2 muted */
185 0x06, 0xff, /* 6: LOUT3 muted */
186 0x07, 0xff, /* 7: ROUT3 muted */
187 0x0b, 0xff, /* B: LOUT4 muted */
188 0x0c, 0xff, /* C: ROUT4 muted */
189 0x08, 0x55, /* 8: deemphasis all off */
192 static unsigned char inits_ak4355[] = {
193 0x01, 0x02, /* 1: reset and soft-mute */
194 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect,
195 * disable DZF, sharp roll-off, RSTN#=0 */
196 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */
197 // 0x02, 0x2e, /* quad speed */
198 0x03, 0x01, /* 3: de-emphasis off */
199 0x04, 0x00, /* 4: LOUT1 volume muted */
200 0x05, 0x00, /* 5: ROUT1 volume muted */
201 0x06, 0x00, /* 6: LOUT2 volume muted */
202 0x07, 0x00, /* 7: ROUT2 volume muted */
203 0x08, 0x00, /* 8: LOUT3 volume muted */
204 0x09, 0x00, /* 9: ROUT3 volume muted */
205 0x0a, 0x00, /* a: DATT speed=0, ignore DZF */
206 0x01, 0x01, /* 1: un-reset, unmute */
209 static unsigned char inits_ak4358[] = {
210 0x01, 0x02, /* 1: reset and soft-mute */
211 0x00, 0x06, /* 0: mode3(i2s), disable auto-clock detect,
212 * disable DZF, sharp roll-off, RSTN#=0 */
213 0x02, 0x0e, /* 2: DA's power up, normal speed, RSTN#=0 */
214 // 0x02, 0x2e, /* quad speed */
215 0x03, 0x01, /* 3: de-emphasis off */
216 0x04, 0x00, /* 4: LOUT1 volume muted */
217 0x05, 0x00, /* 5: ROUT1 volume muted */
218 0x06, 0x00, /* 6: LOUT2 volume muted */
219 0x07, 0x00, /* 7: ROUT2 volume muted */
220 0x08, 0x00, /* 8: LOUT3 volume muted */
221 0x09, 0x00, /* 9: ROUT3 volume muted */
222 0x0b, 0x00, /* b: LOUT4 volume muted */
223 0x0c, 0x00, /* c: ROUT4 volume muted */
224 0x0a, 0x00, /* a: DATT speed=0, ignore DZF */
225 0x01, 0x01, /* 1: un-reset, unmute */
228 static unsigned char inits_ak4381[] = {
229 0x00, 0x0c, /* 0: mode3(i2s), disable auto-clock detect */
230 0x01, 0x02, /* 1: de-emphasis off, normal speed,
231 * sharp roll-off, DZF off */
232 // 0x01, 0x12, /* quad speed */
233 0x02, 0x00, /* 2: DZF disabled */
234 0x03, 0x00, /* 3: LATT 0 */
235 0x04, 0x00, /* 4: RATT 0 */
236 0x00, 0x0f, /* 0: power-up, un-reset */
241 unsigned char *ptr, reg, data, *inits;
245 inits = inits_ak4524;
246 num_chips = ak->num_dacs / 2;
249 inits = inits_ak4528;
250 num_chips = ak->num_dacs / 2;
253 inits = inits_ak4529;
257 inits = inits_ak4355;
261 inits = inits_ak4358;
265 inits = inits_ak4381;
266 num_chips = ak->num_dacs / 2;
273 for (chip = 0; chip < num_chips; chip++) {
275 while (*ptr != 0xff) {
278 snd_akm4xxx_write(ak, chip, reg, data);
283 EXPORT_SYMBOL(snd_akm4xxx_init);
285 #define AK_GET_CHIP(val) (((val) >> 8) & 0xff)
286 #define AK_GET_ADDR(val) ((val) & 0xff)
287 #define AK_GET_SHIFT(val) (((val) >> 16) & 0x7f)
288 #define AK_GET_INVERT(val) (((val) >> 23) & 1)
289 #define AK_GET_MASK(val) (((val) >> 24) & 0xff)
290 #define AK_COMPOSE(chip,addr,shift,mask) \
291 (((chip) << 8) | (addr) | ((shift) << 16) | ((mask) << 24))
292 #define AK_INVERT (1<<23)
294 static int snd_akm4xxx_volume_info(struct snd_kcontrol *kcontrol,
295 struct snd_ctl_elem_info *uinfo)
297 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
299 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
301 uinfo->value.integer.min = 0;
302 uinfo->value.integer.max = mask;
306 static int snd_akm4xxx_volume_get(struct snd_kcontrol *kcontrol,
307 struct snd_ctl_elem_value *ucontrol)
309 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
310 int chip = AK_GET_CHIP(kcontrol->private_value);
311 int addr = AK_GET_ADDR(kcontrol->private_value);
312 int invert = AK_GET_INVERT(kcontrol->private_value);
313 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
314 unsigned char val = snd_akm4xxx_get(ak, chip, addr);
316 ucontrol->value.integer.value[0] = invert ? mask - val : val;
320 static int snd_akm4xxx_volume_put(struct snd_kcontrol *kcontrol,
321 struct snd_ctl_elem_value *ucontrol)
323 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
324 int chip = AK_GET_CHIP(kcontrol->private_value);
325 int addr = AK_GET_ADDR(kcontrol->private_value);
326 int invert = AK_GET_INVERT(kcontrol->private_value);
327 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
328 unsigned char nval = ucontrol->value.integer.value[0] % (mask+1);
333 change = snd_akm4xxx_get(ak, chip, addr) != nval;
335 snd_akm4xxx_write(ak, chip, addr, nval);
339 static int snd_akm4xxx_stereo_volume_info(struct snd_kcontrol *kcontrol,
340 struct snd_ctl_elem_info *uinfo)
342 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
344 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
346 uinfo->value.integer.min = 0;
347 uinfo->value.integer.max = mask;
351 static int snd_akm4xxx_stereo_volume_get(struct snd_kcontrol *kcontrol,
352 struct snd_ctl_elem_value *ucontrol)
354 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
355 int chip = AK_GET_CHIP(kcontrol->private_value);
356 int addr = AK_GET_ADDR(kcontrol->private_value);
357 int invert = AK_GET_INVERT(kcontrol->private_value);
358 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
359 unsigned char val = snd_akm4xxx_get(ak, chip, addr);
361 ucontrol->value.integer.value[0] = invert ? mask - val : val;
363 val = snd_akm4xxx_get(ak, chip, addr+1);
364 ucontrol->value.integer.value[1] = invert ? mask - val : val;
369 static int snd_akm4xxx_stereo_volume_put(struct snd_kcontrol *kcontrol,
370 struct snd_ctl_elem_value *ucontrol)
372 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
373 int chip = AK_GET_CHIP(kcontrol->private_value);
374 int addr = AK_GET_ADDR(kcontrol->private_value);
375 int invert = AK_GET_INVERT(kcontrol->private_value);
376 unsigned int mask = AK_GET_MASK(kcontrol->private_value);
377 unsigned char nval = ucontrol->value.integer.value[0] % (mask+1);
378 int change0, change1;
382 change0 = snd_akm4xxx_get(ak, chip, addr) != nval;
384 snd_akm4xxx_write(ak, chip, addr, nval);
386 nval = ucontrol->value.integer.value[1] % (mask+1);
389 change1 = snd_akm4xxx_get(ak, chip, addr+1) != nval;
391 snd_akm4xxx_write(ak, chip, addr+1, nval);
394 return change0 || change1;
397 static int snd_akm4xxx_ipga_gain_info(struct snd_kcontrol *kcontrol,
398 struct snd_ctl_elem_info *uinfo)
400 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
402 uinfo->value.integer.min = 0;
403 uinfo->value.integer.max = 36;
407 static int snd_akm4xxx_ipga_gain_get(struct snd_kcontrol *kcontrol,
408 struct snd_ctl_elem_value *ucontrol)
410 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
411 int chip = AK_GET_CHIP(kcontrol->private_value);
412 int addr = AK_GET_ADDR(kcontrol->private_value);
413 ucontrol->value.integer.value[0] =
414 snd_akm4xxx_get_ipga(ak, chip, addr) & 0x7f;
418 static int snd_akm4xxx_ipga_gain_put(struct snd_kcontrol *kcontrol,
419 struct snd_ctl_elem_value *ucontrol)
421 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
422 int chip = AK_GET_CHIP(kcontrol->private_value);
423 int addr = AK_GET_ADDR(kcontrol->private_value);
424 unsigned char nval = (ucontrol->value.integer.value[0] % 37) | 0x80;
425 int change = snd_akm4xxx_get_ipga(ak, chip, addr) != nval;
427 snd_akm4xxx_write(ak, chip, addr, nval);
431 static int snd_akm4xxx_deemphasis_info(struct snd_kcontrol *kcontrol,
432 struct snd_ctl_elem_info *uinfo)
434 static char *texts[4] = {
435 "44.1kHz", "Off", "48kHz", "32kHz",
437 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
439 uinfo->value.enumerated.items = 4;
440 if (uinfo->value.enumerated.item >= 4)
441 uinfo->value.enumerated.item = 3;
442 strcpy(uinfo->value.enumerated.name,
443 texts[uinfo->value.enumerated.item]);
447 static int snd_akm4xxx_deemphasis_get(struct snd_kcontrol *kcontrol,
448 struct snd_ctl_elem_value *ucontrol)
450 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
451 int chip = AK_GET_CHIP(kcontrol->private_value);
452 int addr = AK_GET_ADDR(kcontrol->private_value);
453 int shift = AK_GET_SHIFT(kcontrol->private_value);
454 ucontrol->value.enumerated.item[0] =
455 (snd_akm4xxx_get(ak, chip, addr) >> shift) & 3;
459 static int snd_akm4xxx_deemphasis_put(struct snd_kcontrol *kcontrol,
460 struct snd_ctl_elem_value *ucontrol)
462 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
463 int chip = AK_GET_CHIP(kcontrol->private_value);
464 int addr = AK_GET_ADDR(kcontrol->private_value);
465 int shift = AK_GET_SHIFT(kcontrol->private_value);
466 unsigned char nval = ucontrol->value.enumerated.item[0] & 3;
469 nval = (nval << shift) |
470 (snd_akm4xxx_get(ak, chip, addr) & ~(3 << shift));
471 change = snd_akm4xxx_get(ak, chip, addr) != nval;
473 snd_akm4xxx_write(ak, chip, addr, nval);
477 static int ak4xxx_switch_info(struct snd_kcontrol *kcontrol,
478 struct snd_ctl_elem_info *uinfo)
480 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
482 uinfo->value.integer.min = 0;
483 uinfo->value.integer.max = 1;
487 static int ak4xxx_switch_get(struct snd_kcontrol *kcontrol,
488 struct snd_ctl_elem_value *ucontrol)
490 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
491 int chip = AK_GET_CHIP(kcontrol->private_value);
492 int addr = AK_GET_ADDR(kcontrol->private_value);
493 int shift = AK_GET_SHIFT(kcontrol->private_value);
494 int invert = AK_GET_INVERT(kcontrol->private_value);
495 unsigned char val = snd_akm4xxx_get(ak, chip, addr);
499 ucontrol->value.integer.value[0] = (val & (1<<shift)) != 0;
503 static int ak4xxx_switch_put(struct snd_kcontrol *kcontrol,
504 struct snd_ctl_elem_value *ucontrol)
506 struct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);
507 int chip = AK_GET_CHIP(kcontrol->private_value);
508 int addr = AK_GET_ADDR(kcontrol->private_value);
509 int shift = AK_GET_SHIFT(kcontrol->private_value);
510 int invert = AK_GET_INVERT(kcontrol->private_value);
511 long flag = ucontrol->value.integer.value[0];
512 unsigned char val, oval;
517 oval = snd_akm4xxx_get(ak, chip, addr);
519 val = oval | (1<<shift);
521 val = oval & ~(1<<shift);
522 change = (oval != val);
524 snd_akm4xxx_write(ak, chip, addr, val);
529 * build AK4xxx controls
532 int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak)
534 unsigned int idx, num_emphs;
535 struct snd_kcontrol *ctl;
540 ctl = kmalloc(sizeof(*ctl), GFP_KERNEL);
544 for (idx = 0; idx < ak->num_dacs; ) {
545 memset(ctl, 0, sizeof(*ctl));
546 if (ak->channel_names == NULL) {
547 strcpy(ctl->id.name, "DAC Volume");
549 ctl->id.index = mixer_ch + ak->idx_offset * 2;
551 strcpy(ctl->id.name, ak->channel_names[mixer_ch]);
552 num_stereo = ak->num_stereo[mixer_ch];
555 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
557 if (num_stereo == 2) {
558 ctl->info = snd_akm4xxx_stereo_volume_info;
559 ctl->get = snd_akm4xxx_stereo_volume_get;
560 ctl->put = snd_akm4xxx_stereo_volume_put;
562 ctl->info = snd_akm4xxx_volume_info;
563 ctl->get = snd_akm4xxx_volume_get;
564 ctl->put = snd_akm4xxx_volume_put;
570 AK_COMPOSE(idx/2, (idx%2) + 6, 0, 127);
575 AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127);
578 /* registers 2-7 and b,c */
579 int val = idx < 6 ? idx + 2 : (idx - 6) + 0xb;
581 AK_COMPOSE(0, val, 0, 255) | AK_INVERT;
585 /* register 4-9, chip #0 only */
586 ctl->private_value = AK_COMPOSE(0, idx + 4, 0, 255);
590 /* register 4-9, chip #0 only */
592 AK_COMPOSE(0, idx + 5, 0, 255);
594 /* register 4-9, chip #0 only */
596 AK_COMPOSE(0, idx + 4, 0, 255);
601 AK_COMPOSE(idx/2, (idx%2) + 3, 0, 255);
608 ctl->private_data = ak;
609 err = snd_ctl_add(ak->card,
610 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
611 SNDRV_CTL_ELEM_ACCESS_WRITE));
618 for (idx = 0; idx < ak->num_adcs && ak->type == SND_AK4524; ++idx) {
619 memset(ctl, 0, sizeof(*ctl));
620 strcpy(ctl->id.name, "ADC Volume");
621 ctl->id.index = idx + ak->idx_offset * 2;
622 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
624 ctl->info = snd_akm4xxx_volume_info;
625 ctl->get = snd_akm4xxx_volume_get;
626 ctl->put = snd_akm4xxx_volume_put;
629 AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127);
630 ctl->private_data = ak;
631 err = snd_ctl_add(ak->card,
632 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
633 SNDRV_CTL_ELEM_ACCESS_WRITE));
637 memset(ctl, 0, sizeof(*ctl));
638 strcpy(ctl->id.name, "IPGA Analog Capture Volume");
639 ctl->id.index = idx + ak->idx_offset * 2;
640 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
642 ctl->info = snd_akm4xxx_ipga_gain_info;
643 ctl->get = snd_akm4xxx_ipga_gain_get;
644 ctl->put = snd_akm4xxx_ipga_gain_put;
646 ctl->private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 0);
647 ctl->private_data = ak;
648 err = snd_ctl_add(ak->card,
649 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
650 SNDRV_CTL_ELEM_ACCESS_WRITE));
655 if (ak->type == SND_AK5365) {
656 memset(ctl, 0, sizeof(*ctl));
657 if (ak->channel_names == NULL)
658 strcpy(ctl->id.name, "Capture Volume");
660 strcpy(ctl->id.name, ak->channel_names[0]);
661 ctl->id.index = ak->idx_offset * 2;
662 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
664 ctl->info = snd_akm4xxx_stereo_volume_info;
665 ctl->get = snd_akm4xxx_stereo_volume_get;
666 ctl->put = snd_akm4xxx_stereo_volume_put;
667 /* Registers 4 & 5 (see AK5365 data sheet, pages 34 and 35):
668 * valid values are from 0x00 (mute) to 0x98 (+12dB). */
670 AK_COMPOSE(0, 4, 0, 0x98);
671 ctl->private_data = ak;
672 err = snd_ctl_add(ak->card,
673 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
674 SNDRV_CTL_ELEM_ACCESS_WRITE));
678 memset(ctl, 0, sizeof(*ctl));
679 if (ak->channel_names == NULL)
680 strcpy(ctl->id.name, "Capture Switch");
682 strcpy(ctl->id.name, ak->channel_names[1]);
683 ctl->id.index = ak->idx_offset * 2;
684 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
686 ctl->info = ak4xxx_switch_info;
687 ctl->get = ak4xxx_switch_get;
688 ctl->put = ak4xxx_switch_put;
689 /* register 2, bit 0 (SMUTE): 0 = normal operation, 1 = mute */
691 AK_COMPOSE(0, 2, 0, 0) | AK_INVERT;
692 ctl->private_data = ak;
693 err = snd_ctl_add(ak->card,
694 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
695 SNDRV_CTL_ELEM_ACCESS_WRITE));
700 if (ak->type == SND_AK4355 || ak->type == SND_AK4358)
703 num_emphs = ak->num_dacs / 2;
704 for (idx = 0; idx < num_emphs; idx++) {
705 memset(ctl, 0, sizeof(*ctl));
706 strcpy(ctl->id.name, "Deemphasis");
707 ctl->id.index = idx + ak->idx_offset;
708 ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
710 ctl->info = snd_akm4xxx_deemphasis_info;
711 ctl->get = snd_akm4xxx_deemphasis_get;
712 ctl->put = snd_akm4xxx_deemphasis_put;
717 ctl->private_value = AK_COMPOSE(idx, 3, 0, 0);
720 int shift = idx == 3 ? 6 : (2 - idx) * 2;
721 /* register 8 with shift */
722 ctl->private_value = AK_COMPOSE(0, 8, shift, 0);
727 ctl->private_value = AK_COMPOSE(idx, 3, 0, 0);
730 ctl->private_value = AK_COMPOSE(idx, 1, 1, 0);
736 ctl->private_data = ak;
737 err = snd_ctl_add(ak->card,
738 snd_ctl_new(ctl, SNDRV_CTL_ELEM_ACCESS_READ|
739 SNDRV_CTL_ELEM_ACCESS_WRITE));
750 EXPORT_SYMBOL(snd_akm4xxx_build_controls);
752 static int __init alsa_akm4xxx_module_init(void)
757 static void __exit alsa_akm4xxx_module_exit(void)
761 module_init(alsa_akm4xxx_module_init)
762 module_exit(alsa_akm4xxx_module_exit)