aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r--sound/soc/soc-core.c39
1 files changed, 39 insertions, 0 deletions
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