diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-07-17 16:01:08 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-07-22 18:15:57 -0400 |
commit | 0f2780ad4c2a398528c7bb1572158d6e894e5dd2 (patch) | |
tree | bcaf015bda60b9af68573a6c0ec75d5245845323 | |
parent | 00200107a296cad3a950049a5ad7134a0d962b8d (diff) |
ASoC: Add function to register component controls
We have now everything in place to actual let a component register controls. Add
a function which allows to do so.
Also update snd_soc_add_codec_controls() and snd_soc_platform_controls() to use
this new function internally. And while we are at it also change the
num_controls parameter of those two functions from int to unsigned int.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | include/sound/soc.h | 6 | ||||
-rw-r--r-- | sound/soc/soc-core.c | 35 |
2 files changed, 29 insertions, 12 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h index 5ee6ddde4831..50ff6f3459aa 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
@@ -507,10 +507,12 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | |||
507 | const char *prefix); | 507 | const char *prefix); |
508 | struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, | 508 | struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, |
509 | const char *name); | 509 | const char *name); |
510 | int snd_soc_add_component_controls(struct snd_soc_component *component, | ||
511 | const struct snd_kcontrol_new *controls, unsigned int num_controls); | ||
510 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, | 512 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, |
511 | const struct snd_kcontrol_new *controls, int num_controls); | 513 | const struct snd_kcontrol_new *controls, unsigned int num_controls); |
512 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, | 514 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, |
513 | const struct snd_kcontrol_new *controls, int num_controls); | 515 | const struct snd_kcontrol_new *controls, unsigned int num_controls); |
514 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, | 516 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, |
515 | const struct snd_kcontrol_new *controls, int num_controls); | 517 | const struct snd_kcontrol_new *controls, int num_controls); |
516 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai, | 518 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai, |
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a0ae3d2263d1..28caa63ae526 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -2394,6 +2394,25 @@ struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, | |||
2394 | EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); | 2394 | EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); |
2395 | 2395 | ||
2396 | /** | 2396 | /** |
2397 | * snd_soc_add_component_controls - Add an array of controls to a component. | ||
2398 | * | ||
2399 | * @component: Component to add controls to | ||
2400 | * @controls: Array of controls to add | ||
2401 | * @num_controls: Number of elements in the array | ||
2402 | * | ||
2403 | * Return: 0 for success, else error. | ||
2404 | */ | ||
2405 | int snd_soc_add_component_controls(struct snd_soc_component *component, | ||
2406 | const struct snd_kcontrol_new *controls, unsigned int num_controls) | ||
2407 | { | ||
2408 | struct snd_card *card = component->card->snd_card; | ||
2409 | |||
2410 | return snd_soc_add_controls(card, component->dev, controls, | ||
2411 | num_controls, component->name_prefix, component); | ||
2412 | } | ||
2413 | EXPORT_SYMBOL_GPL(snd_soc_add_component_controls); | ||
2414 | |||
2415 | /** | ||
2397 | * snd_soc_add_codec_controls - add an array of controls to a codec. | 2416 | * snd_soc_add_codec_controls - add an array of controls to a codec. |
2398 | * Convenience function to add a list of controls. Many codecs were | 2417 | * Convenience function to add a list of controls. Many codecs were |
2399 | * duplicating this code. | 2418 | * duplicating this code. |
@@ -2405,12 +2424,10 @@ EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); | |||
2405 | * Return 0 for success, else error. | 2424 | * Return 0 for success, else error. |
2406 | */ | 2425 | */ |
2407 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, | 2426 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, |
2408 | const struct snd_kcontrol_new *controls, int num_controls) | 2427 | const struct snd_kcontrol_new *controls, unsigned int num_controls) |
2409 | { | 2428 | { |
2410 | struct snd_card *card = codec->component.card->snd_card; | 2429 | return snd_soc_add_component_controls(&codec->component, controls, |
2411 | 2430 | num_controls); | |
2412 | return snd_soc_add_controls(card, codec->dev, controls, num_controls, | ||
2413 | codec->component.name_prefix, &codec->component); | ||
2414 | } | 2431 | } |
2415 | EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); | 2432 | EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); |
2416 | 2433 | ||
@@ -2425,12 +2442,10 @@ EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); | |||
2425 | * Return 0 for success, else error. | 2442 | * Return 0 for success, else error. |
2426 | */ | 2443 | */ |
2427 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, | 2444 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, |
2428 | const struct snd_kcontrol_new *controls, int num_controls) | 2445 | const struct snd_kcontrol_new *controls, unsigned int num_controls) |
2429 | { | 2446 | { |
2430 | struct snd_card *card = platform->component.card->snd_card; | 2447 | return snd_soc_add_component_controls(&platform->component, controls, |
2431 | 2448 | num_controls); | |
2432 | return snd_soc_add_controls(card, platform->dev, controls, num_controls, | ||
2433 | NULL, &platform->component); | ||
2434 | } | 2449 | } |
2435 | EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); | 2450 | EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); |
2436 | 2451 | ||