aboutsummaryrefslogtreecommitdiff
path: root/include/sound/soc.h
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-03-04 10:33:17 +0100
committerMark Brown <broonie@kernel.org>2015-03-04 17:09:51 +0000
commit970939964c26db4643f58d4e84487821962e0b65 (patch)
treea218095f0664eb0702bb6d87b41e65b8c618f49b /include/sound/soc.h
parentc472b93990e02c31f02322ddf0fdd9d571169310 (diff)
ASoC: Allow to register jacks at the card level
Jacks are typically card level elements, but are currently registered with a CODEC. When it was originally introduced snd_soc_jack_new() took a snd_soc_card as its parameter, but at that time DAPM was only implemented at the CODEC level and there was only one CODEC per card. This made it clear which CODEC to use for the jack DAPM operations. But the multi-component patchset added support for having multiple CODECs per card and with it the API was updated to register jacks with a specific CODEC instance instead. Subsequently DAPM support at the card level has been introduced, but the snd_soc_jack_new() API has so remained unchanged. This leaves us with the issue that the DAPM pins that are managed by the jack detection logic usually are part of the card DAPM context but are accessed through a CODEC DAPM context. Currently this works fine, but might break in the future if we take a more hierarchical approach to DAPM contexts. Furthermore with componentization progressing systems that do not register a snd_soc_codec might appear, while these system may still want to able to register a jack. This patch addresses these issues by adding a new function called snd_soc_card_jack_new() that can be used to register jacks with the card rather than a CODEC. This new function is mostly identical to snd_soc_jack_new() except that it additionally allows to directly specify the DAPM pins associated with the jack. This was done since most users of snd_soc_jack_new() typically call snd_soc_jack_add_pins() right after it, which is not necessary with the new API and allows to reduce the amount of boiler plate code. The old snd_soc_jack_new() is re-implemented as a wrapper around snd_soc_card_jack_new(). Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'include/sound/soc.h')
-rw-r--r--include/sound/soc.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 0d1ade195628..99d9ce272209 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -450,8 +450,10 @@ int soc_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai);
/* Jack reporting */
-int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
- struct snd_soc_jack *jack);
+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);
+
void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
struct snd_soc_jack_pin *pins);
@@ -659,7 +661,7 @@ struct snd_soc_jack_gpio {
struct snd_soc_jack {
struct mutex mutex;
struct snd_jack *jack;
- struct snd_soc_codec *codec;
+ struct snd_soc_card *card;
struct list_head pins;
int status;
struct blocking_notifier_head notifier;
@@ -1482,6 +1484,26 @@ static inline struct snd_soc_platform *snd_soc_kcontrol_platform(
return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol));
}
+/**
+ * snd_soc_jack_new - Create a new jack
+ * @codec: ASoC CODEC
+ * @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
+ *
+ * Creates a new jack object.
+ *
+ * Returns zero if successful, or a negative error code on failure.
+ * On success jack will be initialised.
+ */
+static inline int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id,
+ int type, struct snd_soc_jack *jack)
+{
+ return snd_soc_card_jack_new(codec->component.card, id, type, jack,
+ NULL, 0);
+}
+
int snd_soc_util_init(void);
void snd_soc_util_exit(void);