Lines Matching full:mc

113 static int soc_mixer_reg_to_ctl(struct soc_mixer_control *mc, unsigned int reg_val,  in soc_mixer_reg_to_ctl()  argument
118 if (mc->sign_bit) in soc_mixer_reg_to_ctl()
119 val = sign_extend32(val, mc->sign_bit); in soc_mixer_reg_to_ctl()
121 val -= mc->min; in soc_mixer_reg_to_ctl()
123 if (mc->invert) in soc_mixer_reg_to_ctl()
129 static unsigned int soc_mixer_ctl_to_reg(struct soc_mixer_control *mc, int val, in soc_mixer_ctl_to_reg() argument
135 if (mc->invert) in soc_mixer_ctl_to_reg()
138 reg_val = val + mc->min; in soc_mixer_ctl_to_reg()
143 static int soc_mixer_valid_ctl(struct soc_mixer_control *mc, long val, int max) in soc_mixer_valid_ctl() argument
148 if (mc->platform_max && val > mc->platform_max) in soc_mixer_valid_ctl()
157 static int soc_mixer_mask(struct soc_mixer_control *mc) in soc_mixer_mask() argument
159 if (mc->sign_bit) in soc_mixer_mask()
160 return GENMASK(mc->sign_bit, 0); in soc_mixer_mask()
162 return GENMASK(fls(mc->max) - 1, 0); in soc_mixer_mask()
165 static int soc_mixer_sx_mask(struct soc_mixer_control *mc) in soc_mixer_sx_mask() argument
168 return GENMASK(fls(mc->min + mc->max) - 2, 0); in soc_mixer_sx_mask()
173 struct soc_mixer_control *mc, int max) in soc_info_volsw() argument
185 if (mc->platform_max && mc->platform_max < max) in soc_info_volsw()
186 max = mc->platform_max; in soc_info_volsw()
188 uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1; in soc_info_volsw()
197 struct soc_mixer_control *mc, int mask, int max) in soc_put_volsw() argument
205 ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[0], max); in soc_put_volsw()
209 val1 = soc_mixer_ctl_to_reg(mc, ucontrol->value.integer.value[0], in soc_put_volsw()
210 mask, mc->shift, max); in soc_put_volsw()
211 val_mask = mask << mc->shift; in soc_put_volsw()
213 if (snd_soc_volsw_is_stereo(mc)) { in soc_put_volsw()
214 ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[1], max); in soc_put_volsw()
218 if (mc->reg == mc->rreg) { in soc_put_volsw()
219 val1 |= soc_mixer_ctl_to_reg(mc, in soc_put_volsw()
221 mask, mc->rshift, max); in soc_put_volsw()
222 val_mask |= mask << mc->rshift; in soc_put_volsw()
224 val2 = soc_mixer_ctl_to_reg(mc, in soc_put_volsw()
226 mask, mc->shift, max); in soc_put_volsw()
231 ret = snd_soc_component_update_bits(component, mc->reg, val_mask, val1); in soc_put_volsw()
236 int err = snd_soc_component_update_bits(component, mc->rreg, in soc_put_volsw()
248 struct soc_mixer_control *mc, int mask, int max) in soc_get_volsw() argument
254 reg_val = snd_soc_component_read(component, mc->reg); in soc_get_volsw()
255 val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max); in soc_get_volsw()
259 if (snd_soc_volsw_is_stereo(mc)) { in soc_get_volsw()
260 if (mc->reg == mc->rreg) { in soc_get_volsw()
261 val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->rshift, max); in soc_get_volsw()
263 reg_val = snd_soc_component_read(component, mc->rreg); in soc_get_volsw()
264 val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max); in soc_get_volsw()
286 struct soc_mixer_control *mc = in snd_soc_info_volsw() local
289 return soc_info_volsw(kcontrol, uinfo, mc, mc->max - mc->min); in snd_soc_info_volsw()
309 struct soc_mixer_control *mc = in snd_soc_info_volsw_sx() local
312 return soc_info_volsw(kcontrol, uinfo, mc, mc->max); in snd_soc_info_volsw_sx()
329 struct soc_mixer_control *mc = in snd_soc_get_volsw() local
331 unsigned int mask = soc_mixer_mask(mc); in snd_soc_get_volsw()
333 return soc_get_volsw(kcontrol, ucontrol, mc, mask, mc->max - mc->min); in snd_soc_get_volsw()
350 struct soc_mixer_control *mc = in snd_soc_put_volsw() local
352 unsigned int mask = soc_mixer_mask(mc); in snd_soc_put_volsw()
354 return soc_put_volsw(kcontrol, ucontrol, mc, mask, mc->max - mc->min); in snd_soc_put_volsw()
371 struct soc_mixer_control *mc = in snd_soc_get_volsw_sx() local
373 unsigned int mask = soc_mixer_sx_mask(mc); in snd_soc_get_volsw_sx()
375 return soc_get_volsw(kcontrol, ucontrol, mc, mask, mc->max); in snd_soc_get_volsw_sx()
391 struct soc_mixer_control *mc = in snd_soc_put_volsw_sx() local
393 unsigned int mask = soc_mixer_sx_mask(mc); in snd_soc_put_volsw_sx()
395 return soc_put_volsw(kcontrol, ucontrol, mc, mask, mc->max); in snd_soc_put_volsw_sx()
401 struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value; in snd_soc_clip_to_platform_max() local
405 if (!mc->platform_max) in snd_soc_clip_to_platform_max()
412 if (uctl.value.integer.value[0] > mc->platform_max) in snd_soc_clip_to_platform_max()
413 uctl.value.integer.value[0] = mc->platform_max; in snd_soc_clip_to_platform_max()
415 if (snd_soc_volsw_is_stereo(mc) && in snd_soc_clip_to_platform_max()
416 uctl.value.integer.value[1] > mc->platform_max) in snd_soc_clip_to_platform_max()
417 uctl.value.integer.value[1] = mc->platform_max; in snd_soc_clip_to_platform_max()
446 struct soc_mixer_control *mc = in snd_soc_limit_volume() local
449 if (max <= mc->max - mc->min) { in snd_soc_limit_volume()
450 mc->platform_max = max; in snd_soc_limit_volume()
630 struct soc_mreg_control *mc = in snd_soc_info_xr_sx() local
635 uinfo->value.integer.min = mc->min; in snd_soc_info_xr_sx()
636 uinfo->value.integer.max = mc->max; in snd_soc_info_xr_sx()
660 struct soc_mreg_control *mc = in snd_soc_get_xr_sx() local
662 unsigned int regbase = mc->regbase; in snd_soc_get_xr_sx()
663 unsigned int regcount = mc->regcount; in snd_soc_get_xr_sx()
666 unsigned long mask = GENMASK(mc->nbits - 1, 0); in snd_soc_get_xr_sx()
676 if (mc->min < 0 && val > mc->max) in snd_soc_get_xr_sx()
678 if (mc->invert) in snd_soc_get_xr_sx()
679 val = mc->max - val; in snd_soc_get_xr_sx()
704 struct soc_mreg_control *mc = in snd_soc_put_xr_sx() local
706 unsigned int regbase = mc->regbase; in snd_soc_put_xr_sx()
707 unsigned int regcount = mc->regcount; in snd_soc_put_xr_sx()
710 unsigned long mask = GENMASK(mc->nbits - 1, 0); in snd_soc_put_xr_sx()
715 if (val < mc->min || val > mc->max) in snd_soc_put_xr_sx()
717 if (mc->invert) in snd_soc_put_xr_sx()
718 val = mc->max - val; in snd_soc_put_xr_sx()
751 struct soc_mixer_control *mc = in snd_soc_get_strobe() local
753 unsigned int invert = mc->invert != 0; in snd_soc_get_strobe()
754 unsigned int mask = BIT(mc->shift); in snd_soc_get_strobe()
757 val = snd_soc_component_read(component, mc->reg); in snd_soc_get_strobe()
760 if (mc->shift != 0 && val != 0) in snd_soc_get_strobe()
761 val = val >> mc->shift; in snd_soc_get_strobe()
783 struct soc_mixer_control *mc = in snd_soc_put_strobe() local
786 unsigned int invert = mc->invert != 0; in snd_soc_put_strobe()
787 unsigned int mask = BIT(mc->shift); in snd_soc_put_strobe()
792 ret = snd_soc_component_update_bits(component, mc->reg, mask, val1); in snd_soc_put_strobe()
796 return snd_soc_component_update_bits(component, mc->reg, mask, val2); in snd_soc_put_strobe()