diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2010-05-07 07:24:11 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-05-07 11:42:40 -0400 |
commit | bd843edf81dc1200f71b61d4804af0e2918e8ae3 (patch) | |
tree | 6a7bc1962b6cbe70ac6b8fe8e5ae1a57e3321b7c | |
parent | 826e962c4689172e25acde72eafebc063253b69d (diff) |
ASoC: tpa6130a2: Fix for the custom kcontrol functions
Since the functions arre only used for volume register,
change their name, and also fix them to properly
handle the cases, when via soc core the volume is
limited.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 0cf3e3862e7b..fa4fa33a51aa 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
@@ -176,7 +176,7 @@ exit: | |||
176 | return ret; | 176 | return ret; |
177 | } | 177 | } |
178 | 178 | ||
179 | static int tpa6130a2_get_reg(struct snd_kcontrol *kcontrol, | 179 | static int tpa6130a2_get_volsw(struct snd_kcontrol *kcontrol, |
180 | struct snd_ctl_elem_value *ucontrol) | 180 | struct snd_ctl_elem_value *ucontrol) |
181 | { | 181 | { |
182 | struct soc_mixer_control *mc = | 182 | struct soc_mixer_control *mc = |
@@ -184,7 +184,8 @@ static int tpa6130a2_get_reg(struct snd_kcontrol *kcontrol, | |||
184 | struct tpa6130a2_data *data; | 184 | struct tpa6130a2_data *data; |
185 | unsigned int reg = mc->reg; | 185 | unsigned int reg = mc->reg; |
186 | unsigned int shift = mc->shift; | 186 | unsigned int shift = mc->shift; |
187 | unsigned int mask = mc->max; | 187 | int max = mc->max; |
188 | unsigned int mask = (1 << fls(max)) - 1; | ||
188 | unsigned int invert = mc->invert; | 189 | unsigned int invert = mc->invert; |
189 | 190 | ||
190 | BUG_ON(tpa6130a2_client == NULL); | 191 | BUG_ON(tpa6130a2_client == NULL); |
@@ -197,13 +198,13 @@ static int tpa6130a2_get_reg(struct snd_kcontrol *kcontrol, | |||
197 | 198 | ||
198 | if (invert) | 199 | if (invert) |
199 | ucontrol->value.integer.value[0] = | 200 | ucontrol->value.integer.value[0] = |
200 | mask - ucontrol->value.integer.value[0]; | 201 | max - ucontrol->value.integer.value[0]; |
201 | 202 | ||
202 | mutex_unlock(&data->mutex); | 203 | mutex_unlock(&data->mutex); |
203 | return 0; | 204 | return 0; |
204 | } | 205 | } |
205 | 206 | ||
206 | static int tpa6130a2_set_reg(struct snd_kcontrol *kcontrol, | 207 | static int tpa6130a2_put_volsw(struct snd_kcontrol *kcontrol, |
207 | struct snd_ctl_elem_value *ucontrol) | 208 | struct snd_ctl_elem_value *ucontrol) |
208 | { | 209 | { |
209 | struct soc_mixer_control *mc = | 210 | struct soc_mixer_control *mc = |
@@ -211,7 +212,8 @@ static int tpa6130a2_set_reg(struct snd_kcontrol *kcontrol, | |||
211 | struct tpa6130a2_data *data; | 212 | struct tpa6130a2_data *data; |
212 | unsigned int reg = mc->reg; | 213 | unsigned int reg = mc->reg; |
213 | unsigned int shift = mc->shift; | 214 | unsigned int shift = mc->shift; |
214 | unsigned int mask = mc->max; | 215 | int max = mc->max; |
216 | unsigned int mask = (1 << fls(max)) - 1; | ||
215 | unsigned int invert = mc->invert; | 217 | unsigned int invert = mc->invert; |
216 | unsigned int val = (ucontrol->value.integer.value[0] & mask); | 218 | unsigned int val = (ucontrol->value.integer.value[0] & mask); |
217 | unsigned int val_reg; | 219 | unsigned int val_reg; |
@@ -220,7 +222,7 @@ static int tpa6130a2_set_reg(struct snd_kcontrol *kcontrol, | |||
220 | data = i2c_get_clientdata(tpa6130a2_client); | 222 | data = i2c_get_clientdata(tpa6130a2_client); |
221 | 223 | ||
222 | if (invert) | 224 | if (invert) |
223 | val = mask - val; | 225 | val = max - val; |
224 | 226 | ||
225 | mutex_lock(&data->mutex); | 227 | mutex_lock(&data->mutex); |
226 | 228 | ||
@@ -260,7 +262,7 @@ static const unsigned int tpa6130_tlv[] = { | |||
260 | static const struct snd_kcontrol_new tpa6130a2_controls[] = { | 262 | static const struct snd_kcontrol_new tpa6130a2_controls[] = { |
261 | SOC_SINGLE_EXT_TLV("TPA6130A2 Headphone Playback Volume", | 263 | SOC_SINGLE_EXT_TLV("TPA6130A2 Headphone Playback Volume", |
262 | TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0, | 264 | TPA6130A2_REG_VOL_MUTE, 0, 0x3f, 0, |
263 | tpa6130a2_get_reg, tpa6130a2_set_reg, | 265 | tpa6130a2_get_volsw, tpa6130a2_put_volsw, |
264 | tpa6130_tlv), | 266 | tpa6130_tlv), |
265 | }; | 267 | }; |
266 | 268 | ||
@@ -274,7 +276,7 @@ static const unsigned int tpa6140_tlv[] = { | |||
274 | static const struct snd_kcontrol_new tpa6140a2_controls[] = { | 276 | static const struct snd_kcontrol_new tpa6140a2_controls[] = { |
275 | SOC_SINGLE_EXT_TLV("TPA6140A2 Headphone Playback Volume", | 277 | SOC_SINGLE_EXT_TLV("TPA6140A2 Headphone Playback Volume", |
276 | TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0, | 278 | TPA6130A2_REG_VOL_MUTE, 1, 0x1f, 0, |
277 | tpa6130a2_get_reg, tpa6130a2_set_reg, | 279 | tpa6130a2_get_volsw, tpa6130a2_put_volsw, |
278 | tpa6140_tlv), | 280 | tpa6140_tlv), |
279 | }; | 281 | }; |
280 | 282 | ||