diff options
-rw-r--r-- | sound/soc/codecs/tlv320aic3x.c | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index e5b926883131..1325c0c0df50 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
@@ -147,10 +147,9 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, | |||
147 | int max = mc->max; | 147 | int max = mc->max; |
148 | unsigned int mask = (1 << fls(max)) - 1; | 148 | unsigned int mask = (1 << fls(max)) - 1; |
149 | unsigned int invert = mc->invert; | 149 | unsigned int invert = mc->invert; |
150 | unsigned short val, val_mask; | 150 | unsigned short val; |
151 | int ret; | 151 | struct snd_soc_dapm_update update; |
152 | struct snd_soc_dapm_path *path; | 152 | int connect, change; |
153 | int found = 0; | ||
154 | 153 | ||
155 | val = (ucontrol->value.integer.value[0] & mask); | 154 | val = (ucontrol->value.integer.value[0] & mask); |
156 | 155 | ||
@@ -158,42 +157,26 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, | |||
158 | if (val) | 157 | if (val) |
159 | val = mask; | 158 | val = mask; |
160 | 159 | ||
160 | connect = !!val; | ||
161 | |||
161 | if (invert) | 162 | if (invert) |
162 | val = mask - val; | 163 | val = mask - val; |
163 | val_mask = mask << shift; | ||
164 | val = val << shift; | ||
165 | |||
166 | mutex_lock(&widget->codec->mutex); | ||
167 | 164 | ||
168 | if (snd_soc_test_bits(widget->codec, reg, val_mask, val)) { | 165 | mask <<= shift; |
169 | /* find dapm widget path assoc with kcontrol */ | 166 | val <<= shift; |
170 | list_for_each_entry(path, &widget->dapm->card->paths, list) { | ||
171 | if (path->kcontrol != kcontrol) | ||
172 | continue; | ||
173 | 167 | ||
174 | /* found, now check type */ | 168 | change = snd_soc_test_bits(widget->codec, val, mask, reg); |
175 | found = 1; | 169 | if (change) { |
176 | if (val) | 170 | update.kcontrol = kcontrol; |
177 | /* new connection */ | 171 | update.reg = reg; |
178 | path->connect = invert ? 0 : 1; | 172 | update.mask = mask; |
179 | else | 173 | update.val = val; |
180 | /* old connection must be powered down */ | ||
181 | path->connect = invert ? 1 : 0; | ||
182 | 174 | ||
183 | dapm_mark_dirty(path->source, "tlv320aic3x source"); | 175 | snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, connect, |
184 | dapm_mark_dirty(path->sink, "tlv320aic3x sink"); | 176 | &update); |
185 | |||
186 | break; | ||
187 | } | ||
188 | } | 177 | } |
189 | 178 | ||
190 | mutex_unlock(&widget->codec->mutex); | 179 | return change; |
191 | |||
192 | if (found) | ||
193 | snd_soc_dapm_sync(widget->dapm); | ||
194 | |||
195 | ret = snd_soc_update_bits_locked(widget->codec, reg, val_mask, val); | ||
196 | return ret; | ||
197 | } | 180 | } |
198 | 181 | ||
199 | /* | 182 | /* |