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;
51 static void snd_wm8776_update_agc_ctl(struct snd_wm8776 *wm)
55 switch (wm->agc_mode) {
72 if (wm->ctl[i].flags & flags_off)
73 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, false);
74 else if (wm->ctl[i].flags & flags_on)
75 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, true);
78 static void snd_wm8776_set_agc(struct snd_wm8776 *wm, u16 agc, u16 nothing)
80 u16 alc1 = wm->regs[WM8776_REG_ALCCTRL1] & ~WM8776_ALC1_LCT_MASK;
81 u16 alc2 = wm->regs[WM8776_REG_ALCCTRL2] & ~WM8776_ALC2_LCEN;
85 wm->agc_mode = WM8776_AGC_OFF;
89 wm->agc_mode = WM8776_AGC_LIM;
94 wm->agc_mode = WM8776_AGC_ALC_R;
99 wm->agc_mode = WM8776_AGC_ALC_L;
104 wm->agc_mode = WM8776_AGC_ALC_STEREO;
107 snd_wm8776_write(wm, WM8776_REG_ALCCTRL1, alc1);
108 snd_wm8776_write(wm, WM8776_REG_ALCCTRL2, alc2);
109 snd_wm8776_update_agc_ctl(wm);
112 static void snd_wm8776_get_agc(struct snd_wm8776 *wm, u16 *mode, u16 *nothing)
114 *mode = wm->agc_mode;
408 void snd_wm8776_init(struct snd_wm8776 *wm)
420 memcpy(wm->ctl, snd_wm8776_default_ctl, sizeof(wm->ctl));
422 snd_wm8776_write(wm, WM8776_REG_RESET, 0x00); /* reset */
426 snd_wm8776_write(wm, i, default_values[i]);
429 void snd_wm8776_resume(struct snd_wm8776 *wm)
434 snd_wm8776_write(wm, i, wm->regs[i]);
437 void snd_wm8776_set_power(struct snd_wm8776 *wm, u16 power)
439 snd_wm8776_write(wm, WM8776_REG_PWRDOWN, power);
442 void snd_wm8776_volume_restore(struct snd_wm8776 *wm)
444 u16 val = wm->regs[WM8776_REG_DACRVOL];
446 snd_wm8776_write(wm, WM8776_REG_DACRVOL, val | WM8776_VOL_UPDATE);
454 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
458 uinfo->count = (wm->ctl[n].flags & WM8776_FLAG_STEREO) ? 2 : 1;
459 uinfo->value.integer.min = wm->ctl[n].min;
460 uinfo->value.integer.max = wm->ctl[n].max;
468 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
471 return snd_ctl_enum_info(uinfo, 1, wm->ctl[n].max,
472 wm->ctl[n].enum_names);
478 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
482 if (wm->ctl[n].get)
483 wm->ctl[n].get(wm, &val1, &val2);
485 val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1;
486 val1 >>= __ffs(wm->ctl[n].mask1);
487 if (wm->ctl[n].flags & WM8776_FLAG_STEREO) {
488 val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2;
489 val2 >>= __ffs(wm->ctl[n].mask2);
490 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE)
494 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) {
495 val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min);
496 if (wm->ctl[n].flags & WM8776_FLAG_STEREO)
497 val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min);
500 if (wm->ctl[n].flags & WM8776_FLAG_STEREO)
509 struct snd_wm8776 *wm = snd_kcontrol_chip(kcontrol);
516 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) {
517 regval1 = wm->ctl[n].max - (regval1 - wm->ctl[n].min);
518 regval2 = wm->ctl[n].max - (regval2 - wm->ctl[n].min);
520 if (wm->ctl[n].set)
521 wm->ctl[n].set(wm, regval1, regval2);
523 val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1;
524 val |= regval1 << __ffs(wm->ctl[n].mask1);
526 if (wm->ctl[n].flags & WM8776_FLAG_STEREO &&
527 wm->ctl[n].reg1 == wm->ctl[n].reg2) {
528 val &= ~wm->ctl[n].mask2;
529 val |= regval2 << __ffs(wm->ctl[n].mask2);
531 snd_wm8776_write(wm, wm->ctl[n].reg1, val);
533 if (wm->ctl[n].flags & WM8776_FLAG_STEREO &&
534 wm->ctl[n].reg1 != wm->ctl[n].reg2) {
535 val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2;
536 val |= regval2 << __ffs(wm->ctl[n].mask2);
537 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE)
539 snd_wm8776_write(wm, wm->ctl[n].reg2, val);
546 static int snd_wm8776_add_control(struct snd_wm8776 *wm, int num)
554 cont.name = wm->ctl[num].name;
556 if (wm->ctl[num].flags & WM8776_FLAG_LIM ||
557 wm->ctl[num].flags & WM8776_FLAG_ALC)
563 switch (wm->ctl[num].type) {
567 cont.tlv.p = wm->ctl[num].tlv;
570 wm->ctl[num].max = 1;
571 if (wm->ctl[num].flags & WM8776_FLAG_STEREO)
582 ctl = snd_ctl_new1(&cont, wm);
586 return snd_ctl_add(wm->card, ctl);
589 int snd_wm8776_build_controls(struct snd_wm8776 *wm)
594 if (wm->ctl[i].name) {
595 err = snd_wm8776_add_control(wm, i);