Lines Matching refs:wm
18 static void snd_wm8776_write(struct snd_wm8776 *wm, u16 addr, u16 data)
24 wm->regs[addr] = data;
25 wm->ops.write(wm, bus_addr, bus_data);
30 static void snd_wm8776_activate_ctl(struct snd_wm8776 *wm,
34 struct snd_card *card = wm->card;
55 static void snd_wm8776_update_agc_ctl(struct snd_wm8776 *wm)
59 switch (wm->agc_mode) {
76 if (wm->ctl[i].flags & flags_off)
77 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, false);
78 else if (wm->ctl[i].flags & flags_on)
79 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, true);
82 static void snd_wm8776_set_agc(struct snd_wm8776 *wm, u16 agc, u16 nothing)
84 u16 alc1 = wm->regs[WM8776_REG_ALCCTRL1] & ~WM8776_ALC1_LCT_MASK;
85 u16 alc2 = wm->regs[WM8776_REG_ALCCTRL2] & ~WM8776_ALC2_LCEN;
89 wm->agc_mode = WM8776_AGC_OFF;
93 wm->agc_mode = WM8776_AGC_LIM;
98 wm->agc_mode = WM8776_AGC_ALC_R;
103 wm->agc_mode = WM8776_AGC_ALC_L;
108 wm->agc_mode = WM8776_AGC_ALC_STEREO;
111 snd_wm8776_write(wm, WM8776_REG_ALCCTRL1, alc1);
112 snd_wm8776_write(wm, WM8776_REG_ALCCTRL2, alc2);
113 snd_wm8776_update_agc_ctl(wm);
116 static void snd_wm8776_get_agc(struct snd_wm8776 *wm, u16 *mode, u16 *nothing)
118 *mode = wm->agc_mode;
412 void snd_wm8776_init(struct snd_wm8776 *wm)
424 memcpy(wm->ctl, snd_wm8776_default_ctl, sizeof(wm->ctl));
426 snd_wm8776_write(wm, WM8776_REG_RESET, 0x00); /* reset */
430 snd_wm8776_write(wm, i, default_values[i]);
433 void snd_wm8776_resume(struct snd_wm8776 *wm)
438 snd_wm8776_write(wm, i, wm->regs[i]);
441 void snd_wm8776_set_power(struct snd_wm8776 *wm, u16 power)
443 snd_wm8776_write(wm, WM8776_REG_PWRDOWN, power);
446 void snd_wm8776_volume_restore(struct snd_wm8776 *wm)
448 u16 val = wm->regs[WM8776_REG_DACRVOL];
450 snd_wm8776_write(wm, WM8776_REG_DACRVOL, val | WM8776_VOL_UPDATE);
458 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
462 uinfo->count = (wm->ctl[n].flags & WM8776_FLAG_STEREO) ? 2 : 1;
463 uinfo->value.integer.min = wm->ctl[n].min;
464 uinfo->value.integer.max = wm->ctl[n].max;
472 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
475 return snd_ctl_enum_info(uinfo, 1, wm->ctl[n].max,
476 wm->ctl[n].enum_names);
482 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
486 if (wm->ctl[n].get)
487 wm->ctl[n].get(wm, &val1, &val2);
489 val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1;
490 val1 >>= __ffs(wm->ctl[n].mask1);
491 if (wm->ctl[n].flags & WM8776_FLAG_STEREO) {
492 val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2;
493 val2 >>= __ffs(wm->ctl[n].mask2);
494 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE)
498 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) {
499 val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min);
500 if (wm->ctl[n].flags & WM8776_FLAG_STEREO)
501 val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min);
504 if (wm->ctl[n].flags & WM8776_FLAG_STEREO)
513 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
520 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) {
521 regval1 = wm->ctl[n].max - (regval1 - wm->ctl[n].min);
522 regval2 = wm->ctl[n].max - (regval2 - wm->ctl[n].min);
524 if (wm->ctl[n].set)
525 wm->ctl[n].set(wm, regval1, regval2);
527 val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1;
528 val |= regval1 << __ffs(wm->ctl[n].mask1);
530 if (wm->ctl[n].flags & WM8776_FLAG_STEREO &&
531 wm->ctl[n].reg1 == wm->ctl[n].reg2) {
532 val &= ~wm->ctl[n].mask2;
533 val |= regval2 << __ffs(wm->ctl[n].mask2);
535 snd_wm8776_write(wm, wm->ctl[n].reg1, val);
537 if (wm->ctl[n].flags & WM8776_FLAG_STEREO &&
538 wm->ctl[n].reg1 != wm->ctl[n].reg2) {
539 val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2;
540 val |= regval2 << __ffs(wm->ctl[n].mask2);
541 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE)
543 snd_wm8776_write(wm, wm->ctl[n].reg2, val);
550 static int snd_wm8776_add_control(struct snd_wm8776 *wm, int num)
558 cont.name = wm->ctl[num].name;
560 if (wm->ctl[num].flags & WM8776_FLAG_LIM ||
561 wm->ctl[num].flags & WM8776_FLAG_ALC)
567 switch (wm->ctl[num].type) {
571 cont.tlv.p = wm->ctl[num].tlv;
574 wm->ctl[num].max = 1;
575 if (wm->ctl[num].flags & WM8776_FLAG_STEREO)
586 ctl = snd_ctl_new1(&cont, wm);
590 return snd_ctl_add(wm->card, ctl);
593 int snd_wm8776_build_controls(struct snd_wm8776 *wm)
598 if (wm->ctl[i].name) {
599 err = snd_wm8776_add_control(wm, i);