Lines Matching full:mc

113 static int soc_mixer_reg_to_ctl(struct soc_mixer_control *mc, unsigned int reg_val,
118 if (mc->sign_bit)
119 val = sign_extend32(val, mc->sign_bit);
121 val = clamp(val, mc->min, mc->max);
122 val -= mc->min;
124 if (mc->invert)
130 static unsigned int soc_mixer_ctl_to_reg(struct soc_mixer_control *mc, int val,
136 if (mc->invert)
139 reg_val = val + mc->min;
144 static int soc_mixer_valid_ctl(struct soc_mixer_control *mc, long val, int max)
149 if (mc->platform_max && val > mc->platform_max)
158 static int soc_mixer_mask(struct soc_mixer_control *mc)
160 if (mc->sign_bit)
161 return GENMASK(mc->sign_bit, 0);
163 return GENMASK(fls(mc->max) - 1, 0);
166 static int soc_mixer_sx_mask(struct soc_mixer_control *mc)
169 return GENMASK(fls(mc->min + mc->max) - 2, 0);
174 struct soc_mixer_control *mc, int max)
186 if (mc->platform_max && mc->platform_max < max)
187 max = mc->platform_max;
189 uinfo->count = snd_soc_volsw_is_stereo(mc) ? 2 : 1;
198 struct soc_mixer_control *mc, int mask, int max)
206 ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[0], max);
210 val1 = soc_mixer_ctl_to_reg(mc, ucontrol->value.integer.value[0],
211 mask, mc->shift, max);
212 val_mask = mask << mc->shift;
214 if (snd_soc_volsw_is_stereo(mc)) {
215 ret = soc_mixer_valid_ctl(mc, ucontrol->value.integer.value[1], max);
219 if (mc->reg == mc->rreg) {
220 val1 |= soc_mixer_ctl_to_reg(mc,
222 mask, mc->rshift, max);
223 val_mask |= mask << mc->rshift;
225 val2 = soc_mixer_ctl_to_reg(mc,
227 mask, mc->shift, max);
232 ret = snd_soc_component_update_bits(component, mc->reg, val_mask, val1);
237 int err = snd_soc_component_update_bits(component, mc->rreg,
249 struct soc_mixer_control *mc, int mask, int max)
255 reg_val = snd_soc_component_read(component, mc->reg);
256 val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max);
260 if (snd_soc_volsw_is_stereo(mc)) {
261 if (mc->reg == mc->rreg) {
262 val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->rshift, max);
264 reg_val = snd_soc_component_read(component, mc->rreg);
265 val = soc_mixer_reg_to_ctl(mc, reg_val, mask, mc->shift, max);
287 struct soc_mixer_control *mc =
290 return soc_info_volsw(kcontrol, uinfo, mc, mc->max - mc->min);
310 struct soc_mixer_control *mc =
313 return soc_info_volsw(kcontrol, uinfo, mc, mc->max);
330 struct soc_mixer_control *mc =
332 unsigned int mask = soc_mixer_mask(mc);
334 return soc_get_volsw(kcontrol, ucontrol, mc, mask, mc->max - mc->min);
351 struct soc_mixer_control *mc =
353 unsigned int mask = soc_mixer_mask(mc);
355 return soc_put_volsw(kcontrol, ucontrol, mc, mask, mc->max - mc->min);
372 struct soc_mixer_control *mc =
374 unsigned int mask = soc_mixer_sx_mask(mc);
376 return soc_get_volsw(kcontrol, ucontrol, mc, mask, mc->max);
392 struct soc_mixer_control *mc =
394 unsigned int mask = soc_mixer_sx_mask(mc);
396 return soc_put_volsw(kcontrol, ucontrol, mc, mask, mc->max);
402 struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
406 if (!mc->platform_max)
417 if (uctl->value.integer.value[0] > mc->platform_max)
418 uctl->value.integer.value[0] = mc->platform_max;
420 if (snd_soc_volsw_is_stereo(mc) &&
421 uctl->value.integer.value[1] > mc->platform_max)
422 uctl->value.integer.value[1] = mc->platform_max;
451 struct soc_mixer_control *mc =
454 if (max <= mc->max - mc->min) {
455 mc->platform_max = max;
635 struct soc_mreg_control *mc =
640 uinfo->value.integer.min = mc->min;
641 uinfo->value.integer.max = mc->max;
665 struct soc_mreg_control *mc =
667 unsigned int regbase = mc->regbase;
668 unsigned int regcount = mc->regcount;
671 unsigned long mask = GENMASK(mc->nbits - 1, 0);
681 if (mc->min < 0 && val > mc->max)
683 if (mc->invert)
684 val = mc->max - val;
709 struct soc_mreg_control *mc =
711 unsigned int regbase = mc->regbase;
712 unsigned int regcount = mc->regcount;
715 unsigned long mask = GENMASK(mc->nbits - 1, 0);
720 if (val < mc->min || val > mc->max)
722 if (mc->invert)
723 val = mc->max - val;
756 struct soc_mixer_control *mc =
758 unsigned int invert = mc->invert != 0;
759 unsigned int mask = BIT(mc->shift);
762 val = snd_soc_component_read(component, mc->reg);
765 if (mc->shift != 0 && val != 0)
766 val = val >> mc->shift;
788 struct soc_mixer_control *mc =
791 unsigned int invert = mc->invert != 0;
792 unsigned int mask = BIT(mc->shift);
797 ret = snd_soc_component_update_bits(component, mc->reg, mask, val1);
801 return snd_soc_component_update_bits(component, mc->reg, mask, val2);