-static int max9877_get_reg(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct soc_mixer_control *mc =
- (struct soc_mixer_control *)kcontrol->private_value;
- unsigned int reg = mc->reg;
- unsigned int shift = mc->shift;
- unsigned int mask = mc->max;
- unsigned int invert = mc->invert;
- unsigned int val;
- int ret;
-
- ret = regmap_read(regmap, reg, &val);
- if (ret != 0)
- return ret;
-
- ucontrol->value.integer.value[0] = (val >> shift) & mask;
-
- if (invert)
- ucontrol->value.integer.value[0] =
- mask - ucontrol->value.integer.value[0];
-
- return 0;
-}
-
-static int max9877_set_reg(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct soc_mixer_control *mc =
- (struct soc_mixer_control *)kcontrol->private_value;
- unsigned int reg = mc->reg;
- unsigned int shift = mc->shift;
- unsigned int mask = mc->max;
- unsigned int invert = mc->invert;
- unsigned int val = (ucontrol->value.integer.value[0] & mask);
- bool change;
- int ret;
-
- if (invert)
- val = mask - val;
-
- ret = regmap_update_bits_check(regmap, reg, mask << shift,
- val << shift, &change);
- if (ret != 0)
- return ret;
-
- if (change)
- return 1;
- else
- return 0;
-}
-
-static int max9877_get_2reg(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct soc_mixer_control *mc =
- (struct soc_mixer_control *)kcontrol->private_value;
- unsigned int reg = mc->reg;
- unsigned int reg2 = mc->rreg;
- unsigned int shift = mc->shift;
- unsigned int mask = mc->max;
- unsigned int val;
- int ret;
-
- ret = regmap_read(regmap, reg, &val);
- if (ret != 0)
- return ret;
- ucontrol->value.integer.value[0] = (val >> shift) & mask;
-
- ret = regmap_read(regmap, reg2, &val);
- if (ret != 0)
- return ret;
- ucontrol->value.integer.value[1] = (val >> shift) & mask;
-
- return 0;
-}
-
-static int max9877_set_2reg(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- struct soc_mixer_control *mc =
- (struct soc_mixer_control *)kcontrol->private_value;
- unsigned int reg = mc->reg;
- unsigned int reg2 = mc->rreg;
- unsigned int shift = mc->shift;
- unsigned int mask = mc->max;
- unsigned int val = (ucontrol->value.integer.value[0] & mask);
- unsigned int val2 = (ucontrol->value.integer.value[1] & mask);
- bool change1, change2;
- int ret;
-
- ret = regmap_update_bits_check(regmap, reg, mask << shift,
- val << shift, &change1);
- if (ret != 0)
- return ret;
-
- ret = regmap_update_bits_check(regmap, reg2, mask << shift,
- val2 << shift, &change2);
- if (ret != 0)
- return ret;
-
- if (change1 || change2)
- return 1;
- else
- return 0;
-}
-
-static int max9877_get_out_mode(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- unsigned int val;
- int ret;
-
- ret = regmap_read(regmap, MAX9877_OUTPUT_MODE, &val);
- if (ret != 0)
- return ret;
-
- val &= MAX9877_OUTMODE_MASK;
- if (val)
- val--;
-
- ucontrol->value.integer.value[0] = val;
-
- return 0;
-}
-
-static int max9877_set_out_mode(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- unsigned int val;
- bool change;
- int ret;
-
- val = ucontrol->value.integer.value[0] + 1;
-
- ret = regmap_update_bits_check(regmap, MAX9877_OUTPUT_MODE,
- MAX9877_OUTMODE_MASK, val, &change);
- if (ret != 0)
- return ret;
-
- if (change)
- return 1;
- else
- return 0;
-}
-
-static int max9877_get_osc_mode(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- unsigned int val;
- int ret;
-
- ret = regmap_read(regmap, MAX9877_OUTPUT_MODE, &val);
- if (ret != 0)
- return ret;
-
- val &= MAX9877_OSC_MASK;
- val >>= MAX9877_OSC_OFFSET;
-
- ucontrol->value.integer.value[0] = val;
-
- return 0;
-}
-
-static int max9877_set_osc_mode(struct snd_kcontrol *kcontrol,
- struct snd_ctl_elem_value *ucontrol)
-{
- unsigned int val;
- bool change;
- int ret;
-
- val = ucontrol->value.integer.value[0] << MAX9877_OSC_OFFSET;
- ret = regmap_update_bits_check(regmap, MAX9877_OUTPUT_MODE,
- MAX9877_OSC_MASK, val, &change);
- if (ret != 0)
- return ret;
-
- if (change)
- return 1;
- else
- return 0;
-}
-