aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc.h2
-rw-r--r--sound/soc/soc-core.c39
2 files changed, 41 insertions, 0 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 01e9c66ddc6d..9f306f0710df 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -326,6 +326,8 @@ int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
326 struct snd_ctl_elem_value *ucontrol); 326 struct snd_ctl_elem_value *ucontrol);
327int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol, 327int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
328 struct snd_ctl_elem_value *ucontrol); 328 struct snd_ctl_elem_value *ucontrol);
329int snd_soc_limit_volume(struct snd_soc_codec *codec,
330 const char *name, int max);
329 331
330/** 332/**
331 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection 333 * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index d59076e2ca84..4079223203eb 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2238,6 +2238,45 @@ int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
2238EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8); 2238EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8);
2239 2239
2240/** 2240/**
2241 * snd_soc_limit_volume - Set new limit to an existing volume control.
2242 *
2243 * @codec: where to look for the control
2244 * @name: Name of the control
2245 * @max: new maximum limit
2246 *
2247 * Return 0 for success, else error.
2248 */
2249int snd_soc_limit_volume(struct snd_soc_codec *codec,
2250 const char *name, int max)
2251{
2252 struct snd_card *card = codec->card;
2253 struct snd_kcontrol *kctl;
2254 struct soc_mixer_control *mc;
2255 int found = 0;
2256 int ret = -EINVAL;
2257
2258 /* Sanity check for name and max */
2259 if (unlikely(!name || max <= 0))
2260 return -EINVAL;
2261
2262 list_for_each_entry(kctl, &card->controls, list) {
2263 if (!strncmp(kctl->id.name, name, sizeof(kctl->id.name))) {
2264 found = 1;
2265 break;
2266 }
2267 }
2268 if (found) {
2269 mc = (struct soc_mixer_control *)kctl->private_value;
2270 if (max <= mc->max) {
2271 mc->max = max;
2272 ret = 0;
2273 }
2274 }
2275 return ret;
2276}
2277EXPORT_SYMBOL_GPL(snd_soc_limit_volume);
2278
2279/**
2241 * snd_soc_dai_set_sysclk - configure DAI system or master clock. 2280 * snd_soc_dai_set_sysclk - configure DAI system or master clock.
2242 * @dai: DAI 2281 * @dai: DAI
2243 * @clk_id: DAI specific clock ID 2282 * @clk_id: DAI specific clock ID