diff options
author | Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> | 2020-05-28 04:48:03 +0300 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2020-05-30 04:11:28 +0300 |
commit | 3359e9b6fa3eafeeb79d5f0ec8a04f3fe6986db1 (patch) | |
tree | 4b6a18562336280dac611ec3b056085fe5211058 /sound/soc/soc-card.c | |
parent | 209c6cdfd28360f030f88ae9adb69f633e6bcd2d (diff) | |
download | linux-3359e9b6fa3eafeeb79d5f0ec8a04f3fe6986db1.tar.xz |
ASoC: soc-card: move snd_soc_card_jack_new() to soc-card
Card related function should be implemented at soc-card now.
This patch moves it.
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/878shc25kc.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-card.c')
-rw-r--r-- | sound/soc/soc-card.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/soc/soc-card.c b/sound/soc/soc-card.c index 340ab682cc76..aa9dbb89f8a1 100644 --- a/sound/soc/soc-card.c +++ b/sound/soc/soc-card.c @@ -6,6 +6,7 @@ // Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> // #include <sound/soc.h> +#include <sound/jack.h> #define soc_card_ret(dai, ret) _soc_card_ret(dai, __func__, ret) static inline int _soc_card_ret(struct snd_soc_card *card, @@ -40,3 +41,41 @@ struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, return NULL; } EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); + +/** + * snd_soc_card_jack_new - Create a new jack + * @card: ASoC card + * @id: an identifying string for this jack + * @type: a bitmask of enum snd_jack_type values that can be detected by + * this jack + * @jack: structure to use for the jack + * @pins: Array of jack pins to be added to the jack or NULL + * @num_pins: Number of elements in the @pins array + * + * Creates a new jack object. + * + * Returns zero if successful, or a negative error code on failure. + * On success jack will be initialised. + */ +int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, + struct snd_soc_jack *jack, + struct snd_soc_jack_pin *pins, unsigned int num_pins) +{ + int ret; + + mutex_init(&jack->mutex); + jack->card = card; + INIT_LIST_HEAD(&jack->pins); + INIT_LIST_HEAD(&jack->jack_zones); + BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); + + ret = snd_jack_new(card->snd_card, id, type, &jack->jack, false, false); + if (ret) + goto end; + + if (num_pins) + ret = snd_soc_jack_add_pins(jack, num_pins, pins); +end: + return soc_card_ret(card, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_card_jack_new); |