Lines Matching +full:max +full:- +full:functions

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Lowlevel functions for WM8776 codec
7 * Copyright (c) 2012 Ondrej Zary <linux@rainbow-software.org>
16 /* low-level access */
24 wm->regs[addr] = data; in snd_wm8776_write()
25 wm->ops.write(wm, bus_addr, bus_data); in snd_wm8776_write()
28 /* register-level functions */
34 struct snd_card *card = wm->card; in snd_wm8776_activate_ctl()
46 index_offset = snd_ctl_get_ioff(kctl, &kctl->id); in snd_wm8776_activate_ctl()
47 vd = &kctl->vd[index_offset]; in snd_wm8776_activate_ctl()
49 vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_wm8776_activate_ctl()
51 vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; in snd_wm8776_activate_ctl()
52 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, &kctl->id); in snd_wm8776_activate_ctl()
59 switch (wm->agc_mode) { in snd_wm8776_update_agc_ctl()
76 if (wm->ctl[i].flags & flags_off) in snd_wm8776_update_agc_ctl()
77 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, false); in snd_wm8776_update_agc_ctl()
78 else if (wm->ctl[i].flags & flags_on) in snd_wm8776_update_agc_ctl()
79 snd_wm8776_activate_ctl(wm, wm->ctl[i].name, true); in snd_wm8776_update_agc_ctl()
84 u16 alc1 = wm->regs[WM8776_REG_ALCCTRL1] & ~WM8776_ALC1_LCT_MASK; in snd_wm8776_set_agc()
85 u16 alc2 = wm->regs[WM8776_REG_ALCCTRL2] & ~WM8776_ALC2_LCEN; in snd_wm8776_set_agc()
89 wm->agc_mode = WM8776_AGC_OFF; in snd_wm8776_set_agc()
93 wm->agc_mode = WM8776_AGC_LIM; in snd_wm8776_set_agc()
98 wm->agc_mode = WM8776_AGC_ALC_R; in snd_wm8776_set_agc()
103 wm->agc_mode = WM8776_AGC_ALC_L; in snd_wm8776_set_agc()
108 wm->agc_mode = WM8776_AGC_ALC_STEREO; in snd_wm8776_set_agc()
118 *mode = wm->agc_mode; in snd_wm8776_get_agc()
123 static const DECLARE_TLV_DB_SCALE(wm8776_hp_tlv, -7400, 100, 1);
124 static const DECLARE_TLV_DB_SCALE(wm8776_dac_tlv, -12750, 50, 1);
125 static const DECLARE_TLV_DB_SCALE(wm8776_adc_tlv, -10350, 50, 1);
126 static const DECLARE_TLV_DB_SCALE(wm8776_lct_tlv, -1600, 100, 0);
128 static const DECLARE_TLV_DB_SCALE(wm8776_ngth_tlv, -7800, 600, 0);
129 static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_lim_tlv, -1200, 100, 0);
130 static const DECLARE_TLV_DB_SCALE(wm8776_maxatten_alc_tlv, -2100, 400, 0);
141 .max = 0xff,
168 .max = 0x7f,
228 .max = 0xff,
275 .max = 5, /* .enum_names item count */
285 .max = 15,
293 .max = 11, /* .enum_names item count */
304 .max = 11, /* .enum_names item count */
314 .max = 8, /* .enum_names item count */
326 .max = 12,
335 .max = 15,
344 .max = 11, /* .enum_names item count */
355 .max = 11, /* .enum_names item count */
367 .max = 7,
377 .max = 15,
387 .max = 16, /* .enum_names item count */
405 .max = 7,
410 /* exported functions */
424 memcpy(wm->ctl, snd_wm8776_default_ctl, sizeof(wm->ctl)); in snd_wm8776_init()
438 snd_wm8776_write(wm, i, wm->regs[i]); in snd_wm8776_resume()
448 u16 val = wm->regs[WM8776_REG_DACRVOL]; in snd_wm8776_volume_restore()
459 int n = kcontrol->private_value; in snd_wm8776_volume_info()
461 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_wm8776_volume_info()
462 uinfo->count = (wm->ctl[n].flags & WM8776_FLAG_STEREO) ? 2 : 1; in snd_wm8776_volume_info()
463 uinfo->value.integer.min = wm->ctl[n].min; in snd_wm8776_volume_info()
464 uinfo->value.integer.max = wm->ctl[n].max; in snd_wm8776_volume_info()
473 int n = kcontrol->private_value; in snd_wm8776_enum_info()
475 return snd_ctl_enum_info(uinfo, 1, wm->ctl[n].max, in snd_wm8776_enum_info()
476 wm->ctl[n].enum_names); in snd_wm8776_enum_info()
483 int n = kcontrol->private_value; in snd_wm8776_ctl_get()
486 if (wm->ctl[n].get) in snd_wm8776_ctl_get()
487 wm->ctl[n].get(wm, &val1, &val2); in snd_wm8776_ctl_get()
489 val1 = wm->regs[wm->ctl[n].reg1] & wm->ctl[n].mask1; in snd_wm8776_ctl_get()
490 val1 >>= __ffs(wm->ctl[n].mask1); in snd_wm8776_ctl_get()
491 if (wm->ctl[n].flags & WM8776_FLAG_STEREO) { in snd_wm8776_ctl_get()
492 val2 = wm->regs[wm->ctl[n].reg2] & wm->ctl[n].mask2; in snd_wm8776_ctl_get()
493 val2 >>= __ffs(wm->ctl[n].mask2); in snd_wm8776_ctl_get()
494 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE) in snd_wm8776_ctl_get()
498 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) { in snd_wm8776_ctl_get()
499 val1 = wm->ctl[n].max - (val1 - wm->ctl[n].min); in snd_wm8776_ctl_get()
500 if (wm->ctl[n].flags & WM8776_FLAG_STEREO) in snd_wm8776_ctl_get()
501 val2 = wm->ctl[n].max - (val2 - wm->ctl[n].min); in snd_wm8776_ctl_get()
503 ucontrol->value.integer.value[0] = val1; in snd_wm8776_ctl_get()
504 if (wm->ctl[n].flags & WM8776_FLAG_STEREO) in snd_wm8776_ctl_get()
505 ucontrol->value.integer.value[1] = val2; in snd_wm8776_ctl_get()
514 int n = kcontrol->private_value; in snd_wm8776_ctl_put()
518 regval1 = ucontrol->value.integer.value[0]; in snd_wm8776_ctl_put()
519 regval2 = ucontrol->value.integer.value[1]; in snd_wm8776_ctl_put()
520 if (wm->ctl[n].flags & WM8776_FLAG_INVERT) { in snd_wm8776_ctl_put()
521 regval1 = wm->ctl[n].max - (regval1 - wm->ctl[n].min); in snd_wm8776_ctl_put()
522 regval2 = wm->ctl[n].max - (regval2 - wm->ctl[n].min); in snd_wm8776_ctl_put()
524 if (wm->ctl[n].set) in snd_wm8776_ctl_put()
525 wm->ctl[n].set(wm, regval1, regval2); in snd_wm8776_ctl_put()
527 val = wm->regs[wm->ctl[n].reg1] & ~wm->ctl[n].mask1; in snd_wm8776_ctl_put()
528 val |= regval1 << __ffs(wm->ctl[n].mask1); in snd_wm8776_ctl_put()
530 if (wm->ctl[n].flags & WM8776_FLAG_STEREO && in snd_wm8776_ctl_put()
531 wm->ctl[n].reg1 == wm->ctl[n].reg2) { in snd_wm8776_ctl_put()
532 val &= ~wm->ctl[n].mask2; in snd_wm8776_ctl_put()
533 val |= regval2 << __ffs(wm->ctl[n].mask2); in snd_wm8776_ctl_put()
535 snd_wm8776_write(wm, wm->ctl[n].reg1, val); in snd_wm8776_ctl_put()
537 if (wm->ctl[n].flags & WM8776_FLAG_STEREO && in snd_wm8776_ctl_put()
538 wm->ctl[n].reg1 != wm->ctl[n].reg2) { in snd_wm8776_ctl_put()
539 val = wm->regs[wm->ctl[n].reg2] & ~wm->ctl[n].mask2; in snd_wm8776_ctl_put()
540 val |= regval2 << __ffs(wm->ctl[n].mask2); in snd_wm8776_ctl_put()
541 if (wm->ctl[n].flags & WM8776_FLAG_VOL_UPDATE) in snd_wm8776_ctl_put()
543 snd_wm8776_write(wm, wm->ctl[n].reg2, val); in snd_wm8776_ctl_put()
558 cont.name = wm->ctl[num].name; in snd_wm8776_add_control()
560 if (wm->ctl[num].flags & WM8776_FLAG_LIM || in snd_wm8776_add_control()
561 wm->ctl[num].flags & WM8776_FLAG_ALC) in snd_wm8776_add_control()
567 switch (wm->ctl[num].type) { in snd_wm8776_add_control()
571 cont.tlv.p = wm->ctl[num].tlv; in snd_wm8776_add_control()
574 wm->ctl[num].max = 1; in snd_wm8776_add_control()
575 if (wm->ctl[num].flags & WM8776_FLAG_STEREO) in snd_wm8776_add_control()
584 return -EINVAL; in snd_wm8776_add_control()
588 return -ENOMEM; in snd_wm8776_add_control()
590 return snd_ctl_add(wm->card, ctl); in snd_wm8776_add_control()
598 if (wm->ctl[i].name) { in snd_wm8776_build_controls()