[alsa-devel] [PATCH 3/4] ASoC: add Component level set_jack

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Thu Aug 24 02:58:07 CEST 2017


From: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>

In current ALSA SoC, Codec only has set_jack feature.
Codec will be merged into Component in next generation ALSA SoC,
thus current Codec specific feature need to be merged into it.
This is glue patch for it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx at renesas.com>
---
 include/sound/soc.h  |  4 ++++
 sound/soc/soc-core.c | 11 +++++++++++
 sound/soc/soc-jack.c | 22 ++++++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/include/sound/soc.h b/include/sound/soc.h
index 9333f65..e817830 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -797,6 +797,8 @@ struct snd_soc_component_driver {
 			  int clk_id, int source, unsigned int freq, int dir);
 	int (*set_pll)(struct snd_soc_component *component, int pll_id,
 		       int source, unsigned int freq_in, unsigned int freq_out);
+	int (*set_jack)(struct snd_soc_component *component,
+			struct snd_soc_jack *jack,  void *data);
 
 	/* DT */
 	int (*of_xlate_dai_name)(struct snd_soc_component *component,
@@ -881,6 +883,8 @@ struct snd_soc_component {
 			  int clk_id, int source, unsigned int freq, int dir);
 	int (*set_pll)(struct snd_soc_component *component, int pll_id,
 		       int source, unsigned int freq_in, unsigned int freq_out);
+	int (*set_jack)(struct snd_soc_component *component,
+			struct snd_soc_jack *jack,  void *data);
 
 	/* machine specific init */
 	int (*init)(struct snd_soc_component *component);
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ece380a..c2ef155 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -3224,6 +3224,7 @@ static int snd_soc_component_initialize(struct snd_soc_component *component,
 	component->resume = component->driver->resume;
 	component->set_sysclk = component->driver->set_sysclk;
 	component->set_pll = component->driver->set_pll;
+	component->set_jack = component->driver->set_jack;
 
 	dapm = &component->dapm;
 	dapm->dev = dev;
@@ -3543,6 +3544,14 @@ static int snd_soc_codec_set_pll_(struct snd_soc_component *component,
 	return snd_soc_codec_set_pll(codec, pll_id, source, freq_in, freq_out);
 }
 
+static int snd_soc_codec_set_jack_(struct snd_soc_component *component,
+			       struct snd_soc_jack *jack, void *data)
+{
+	struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
+
+	return snd_soc_codec_set_jack(codec, jack, data);
+}
+
 static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm,
 	enum snd_soc_bias_level level)
 {
@@ -3598,6 +3607,8 @@ int snd_soc_register_codec(struct device *dev,
 		codec->component.set_sysclk = snd_soc_codec_set_sysclk_;
 	if (codec_drv->set_pll)
 		codec->component.set_pll = snd_soc_codec_set_pll_;
+	if (codec_drv->set_jack)
+		codec->component.set_jack = snd_soc_codec_set_jack_;
 	codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
 
 	dapm = snd_soc_codec_get_dapm(codec);
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index 42ca9f1..84835a4 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -41,6 +41,28 @@ int snd_soc_codec_set_jack(struct snd_soc_codec *codec,
 EXPORT_SYMBOL_GPL(snd_soc_codec_set_jack);
 
 /**
+ * snd_soc_component_set_jack - configure component jack.
+ * @component: COMPONENTs
+ * @jack: structure to use for the jack
+ * @data: can be used if codec driver need extra data for configuring jack
+ *
+ * Configures and enables jack detection function.
+ */
+int snd_soc_component_set_jack(struct snd_soc_component *component,
+			       struct snd_soc_jack *jack, void *data)
+{
+	/* will be removed */
+	if (component->set_jack)
+		return component->set_jack(component, jack, data);
+
+	if (component->driver->set_jack)
+		return component->driver->set_jack(component, jack, data);
+
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL_GPL(snd_soc_component_set_jack);
+
+/**
  * snd_soc_card_jack_new - Create a new jack
  * @card:  ASoC card
  * @id:    an identifying string for this jack
-- 
1.9.1



More information about the Alsa-devel mailing list