Skip to contentSkip to conversation

ASoC: simple-card: share similar function

PATCH In review Kuninori Morimoto 2 participants 13 messages Mar 20, 2019 – Mar 21, 2019

Subsystems (3)
lore
Share & tools
lore

Kuninori Morimoto

author maintainer
#0 lore raw

v2 cover ASoC: simple-card: share similar function

Hi Mark

v1 patch-set had compile error at 8) patch.
These are v2.

Kuninori Morimoto (11):
1) ASoC: simple-card-utils: add asoc_simple_debug_info()
2) ASoC: simple_card_utils: share common priv for simple-card/audio-graph
3) ASoC: simple-card-utils: share asoc_simple_startup()
4) ASoC: simple-card-utils: share asoc_simple_shutdown()
5) ASoC: simple-card-utils: share asoc_simple_hw_param()
6) ASoC: simple-card-utils: share asoc_simple_dai_init()
7) ASoC: simple-card-utils: share asoc_simple_be_hw_params_fixup()
8) ASoC: simple-card-utils: share asoc_simple_card_init_priv()
9) ASoC: simple-card-utils: separate asoc_simple_card_parse_dai()
10) ASoC: simple-card-utils: rename asoc_simple_card_xxx() to asoc_simple_()
11) ASoC: simple-card-utils: test memory allocation

 include/sound/simple_card_utils.h     | 236 ++++++++++++++-------
 sound/soc/generic/audio-graph-card.c  | 367 ++++++++++++++------------------
 sound/soc/generic/simple-card-utils.c | 379 ++++++++++++++++++----------------
 sound/soc/generic/simple-card.c       | 344 ++++++++++--------------------
 4 files changed, 622 insertions(+), 704 deletions(-)
Signature · 7 lines
2.7.4



Best regards
---
Kuninori Morimoto
author maintainer
#1 lore raw

PATCH v2 1/11 ASoC: simple-card-utils: add asoc_simple_debug_info()

From: Kuninori Morimoto <[email protected]>

Current simple-card-utils has dev_dbg(), but people want to add #define DEBUG at simple-card/audio-graph, not simple-card-utils. And, people want to get all information.
This patch adds new asoc_simple_debug_info() to indicates information.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     | 72 +++++++++++++++++++++++++++++++++++
 sound/soc/generic/audio-graph-card.c  |  2 +
 sound/soc/generic/simple-card-utils.c | 12 ------
 sound/soc/generic/simple-card.c       |  2 +
 4 files changed, 76 insertions(+), 12 deletions(-)
include/sound/simple_card_utils.h +72 -0
index 7afe453..0199ad0 100644
@@ -129,4 +129,76 @@ int asoc_simple_card_init_jack(struct snd_soc_card *card,
 			       struct asoc_simple_jack *sjack,
 			       int is_hp, char *prefix);
 
+
+#ifdef DEBUG
+inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv,
+				  char *name,
+				  struct asoc_simple_dai *dai)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+
+	if (dai->name)
+		dev_dbg(dev, "%s dai name = %s\n",
+			name, dai->name);
+	if (dai->sysclk)
+		dev_dbg(dev, "%s sysclk = %d\n",
+			name, dai->sysclk);
+
+	dev_dbg(dev, "%s direction = %s\n",
+		name, dai->clk_direction ? "OUT" : "IN");
+
+	if (dai->slots)
+		dev_dbg(dev, "%s slots = %d\n", name, dai->slots);
+	if (dai->slot_width)
+		dev_dbg(dev, "%s slot width = %d\n", name, dai->slot_width);
+	if (dai->tx_slot_mask)
+		dev_dbg(dev, "%s tx slot mask = %d\n", name, dai->tx_slot_mask);
+	if (dai->rx_slot_mask)
+		dev_dbg(dev, "%s rx slot mask = %d\n", name, dai->rx_slot_mask);
+	if (dai->clk)
+		dev_dbg(dev, "%s clk %luHz\n", name, clk_get_rate(dai->clk));
+}
+
+inline void asoc_simple_debug_info(struct asoc_simple_priv *priv)
+{
+	struct snd_soc_card *card = simple_priv_to_card(priv);
+	struct device *dev = simple_priv_to_dev(priv);
+
+	int i;
+
+	if (card->name)
+		dev_dbg(dev, "Card Name: %s\n", card->name);
+
+	for (i = 0; i < card->num_links; i++) {
+		struct simple_dai_props *props = simple_priv_to_props(priv, i);
+		struct snd_soc_dai_link *link = simple_priv_to_link(priv, i);
+
+		dev_dbg(dev, "DAI%d\n", i);
+
+		asoc_simple_debug_dai(priv, "cpu", props->cpu_dai);
+		asoc_simple_debug_dai(priv, "codec", props->codec_dai);
+
+		if (link->name)
+			dev_dbg(dev, "dai name = %s\n", link->name);
+
+		dev_dbg(dev, "dai format = %04x\n", link->dai_fmt);
+
+		if (props->adata.convert_rate)
+			dev_dbg(dev, "convert_rate = %d\n",
+				props->adata.convert_rate);
+		if (props->adata.convert_channels)
+			dev_dbg(dev, "convert_channels = %d\n",
+				props->adata.convert_channels);
+		if (props->codec_conf && props->codec_conf->name_prefix)
+			dev_dbg(dev, "name prefix = %s\n",
+				props->codec_conf->name_prefix);
+		if (props->mclk_fs)
+			dev_dbg(dev, "mclk-fs = %d\n",
+				props->mclk_fs);
+	}
+}
+#else
+#define  asoc_simple_debug_info(priv)
+#endif /* DEBUG */
+
 #endif /* __SIMPLE_CARD_UTILS_H */
sound/soc/generic/audio-graph-card.c +2 -0
index 7dd772a..2a95355 100644
@@ -712,6 +712,8 @@ static int graph_probe(struct platform_device *pdev)
 
 	snd_soc_card_set_drvdata(card, priv);
 
+	asoc_simple_debug_info(priv);
+
 	ret = devm_snd_soc_register_card(dev, card);
 	if (ret < 0)
 		goto err;
sound/soc/generic/simple-card-utils.c +0 -12
index 5c1424f..f5ba5ad 100644
@@ -49,9 +49,6 @@ void asoc_simple_card_parse_convert(struct device *dev,
 	/* channels transfer */
 	snprintf(prop, sizeof(prop), "%s%s", prefix, "convert-channels");
 	of_property_read_u32(np, prop, &data->convert_channels);
-
-	dev_dbg(dev, "convert_rate     %d\n", data->convert_rate);
-	dev_dbg(dev, "convert_channels %d\n", data->convert_channels);
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_convert);
 
@@ -93,8 +90,6 @@ int asoc_simple_card_parse_daifmt(struct device *dev,
 
 	*retfmt = daifmt;
 
-	dev_dbg(dev, "format : %04x\n", daifmt);
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt);
@@ -116,8 +111,6 @@ int asoc_simple_card_set_dailink_name(struct device *dev,
 
 		dai_link->name		= name;
 		dai_link->stream_name	= name;
-
-		dev_dbg(dev, "name : %s\n", name);
 	}
 
 	return ret;
@@ -146,8 +139,6 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
 	if (!card->name && card->dai_link)
 		card->name = card->dai_link->name;
 
-	dev_dbg(card->dev, "Card Name: %s\n", card->name ? card->name : "");
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
@@ -211,9 +202,6 @@ int asoc_simple_card_parse_clk(struct device *dev,
 	if (of_property_read_bool(node, "system-clock-direction-out"))
 		simple_dai->clk_direction = SND_SOC_CLOCK_OUT;
 
-	dev_dbg(dev, "%s : sysclk = %d, direction %d\n", dai_name,
-		simple_dai->sysclk, simple_dai->clk_direction);
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);
sound/soc/generic/simple-card.c +2 -0
index b792638..7789962 100644
@@ -813,6 +813,8 @@ static int simple_probe(struct platform_device *pdev)
 
 	snd_soc_card_set_drvdata(card, priv);
 
+	asoc_simple_debug_info(priv);
+
 	ret = devm_snd_soc_register_card(dev, card);
 	if (ret < 0)
 		goto err;
Signature · 1 line
2.7.4
author maintainer
#2 lore raw

PATCH v2 2/11 ASoC: simple_card_utils: share common priv for simple-card/audio-graph

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

Historically, simple-card/simple-scu-card/audio-graph/audio-graph-scu are similar but different generic sound card. simple-scu-card which was for DPCM was merged into simple-card, and audio-graph-scu which was for DPCM was merged into audio-graph. simple-card is for non OF graph sound card, and
audio-graph is for OF graph sound card.
And, small detail difference (= function parameter, naming, etc) between simple-card/audio-graph has been unified.

So today, the difference between simple-card/audio-graph are just using OF graph style, or not.
In other words, there should no difference other than OF graph sytle. simple-card/audio-graph are using own priv today , but we can merge it. This patch merge it at simple_card_utils.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h    | 23 +++++++++
 sound/soc/generic/audio-graph-card.c | 96 ++++++++++++++----------------------
 sound/soc/generic/simple-card.c      | 57 +++++++--------------
 3 files changed, 76 insertions(+), 100 deletions(-)
include/sound/simple_card_utils.h +23 -0
index 0199ad0..c0161ec 100644
@@ -37,6 +37,29 @@ struct asoc_simple_jack {
 	struct snd_soc_jack_gpio gpio;
 };
 
+struct asoc_simple_priv {
+	struct snd_soc_card snd_card;
+	struct simple_dai_props {
+		struct asoc_simple_dai *cpu_dai;
+		struct asoc_simple_dai *codec_dai;
+		struct snd_soc_dai_link_component codecs; /* single codec */
+		struct snd_soc_dai_link_component platforms;
+		struct asoc_simple_card_data adata;
+		struct snd_soc_codec_conf *codec_conf;
+		unsigned int mclk_fs;
+	} *dai_props;
+	struct asoc_simple_jack hp_jack;
+	struct asoc_simple_jack mic_jack;
+	struct snd_soc_dai_link *dai_link;
+	struct asoc_simple_dai *dais;
+	struct snd_soc_codec_conf *codec_conf;
+	struct gpio_desc *pa_gpio;
+};
+#define simple_priv_to_card(priv)	(&(priv)->snd_card)
+#define simple_priv_to_props(priv, i)	((priv)->dai_props + (i))
+#define simple_priv_to_dev(priv)	(simple_priv_to_card(priv)->dev)
+#define simple_priv_to_link(priv, i)	(simple_priv_to_card(priv)->dai_link + (i))
+
 int asoc_simple_card_parse_daifmt(struct device *dev,
 				  struct device_node *node,
 				  struct device_node *codec,
sound/soc/generic/audio-graph-card.c +36 -60

241 lines not on this page · raw message

sound/soc/generic/simple-card.c +17 -40

163 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#3 lore raw

PATCH v2 3/11 ASoC: simple-card-utils: share asoc_simple_startup()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_startup() between in these 2 drivers.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  2 +-
 sound/soc/generic/audio-graph-card.c  | 20 +-------------------
 sound/soc/generic/simple-card-utils.c | 22 ++++++++++++++++++++--
 sound/soc/generic/simple-card.c       | 21 +--------------------
 4 files changed, 23 insertions(+), 42 deletions(-)
include/sound/simple_card_utils.h +1 -1
index c0161ec..0653fb9 100644
@@ -84,8 +84,8 @@ int asoc_simple_card_parse_clk(struct device *dev,
 			       struct asoc_simple_dai *simple_dai,
 			       const char *dai_name,
 			       struct snd_soc_dai_link_component *dlc);
-int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai);
 void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
+int asoc_simple_startup(struct snd_pcm_substream *substream);
 
 #define asoc_simple_card_parse_cpu(node, dai_link,				\
 				   list_name, cells_name, is_single_link)	\
sound/soc/generic/audio-graph-card.c +1 -19
index 656ca49..29ae71b 100644
@@ -56,24 +56,6 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = {
 			       SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 };
 
-static int graph_startup(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-	int ret;
-
-	ret = asoc_simple_card_clk_enable(dai_props->cpu_dai);
-	if (ret)
-		return ret;
-
-	ret = asoc_simple_card_clk_enable(dai_props->codec_dai);
-	if (ret)
-		asoc_simple_card_clk_disable(dai_props->cpu_dai);
-
-	return ret;
-}
-
 static void graph_shutdown(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -117,7 +99,7 @@ static int graph_hw_params(struct snd_pcm_substream *substream,
 }
 
 static const struct snd_soc_ops graph_ops = {
-	.startup	= graph_startup,
+	.startup	= asoc_simple_startup,
 	.shutdown	= graph_shutdown,
 	.hw_params	= graph_hw_params,
 };
sound/soc/generic/simple-card-utils.c +20 -2
index f5ba5ad..83ea1af 100644
@@ -143,14 +143,13 @@ int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_card_name);
 
-int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai)
+static int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai)
 {
 	if (dai)
 		return clk_prepare_enable(dai->clk);
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(asoc_simple_card_clk_enable);
 
 void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai)
 {
@@ -206,6 +205,25 @@ int asoc_simple_card_parse_clk(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_clk);
 
+int asoc_simple_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
+	int ret;
+
+	ret = asoc_simple_card_clk_enable(dai_props->cpu_dai);
+	if (ret)
+		return ret;
+
+	ret = asoc_simple_card_clk_enable(dai_props->codec_dai);
+	if (ret)
+		asoc_simple_card_clk_disable(dai_props->cpu_dai);
+
+	return ret;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_startup);
+
 int asoc_simple_card_parse_dai(struct device_node *node,
 				    struct snd_soc_dai_link_component *dlc,
 				    struct device_node **dai_of_node,
sound/soc/generic/simple-card.c +1 -20
index 628c19a..d0ea573 100644
@@ -26,25 +26,6 @@ struct link_info {
 #define CELL	"#sound-dai-cells"
 #define PREFIX	"simple-audio-card,"
 
-static int simple_startup(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props =
-		simple_priv_to_props(priv, rtd->num);
-	int ret;
-
-	ret = asoc_simple_card_clk_enable(dai_props->cpu_dai);
-	if (ret)
-		return ret;
-
-	ret = asoc_simple_card_clk_enable(dai_props->codec_dai);
-	if (ret)
-		asoc_simple_card_clk_disable(dai_props->cpu_dai);
-
-	return ret;
-}
-
 static void simple_shutdown(struct snd_pcm_substream *substream)
 {
 	struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -114,7 +95,7 @@ static int simple_hw_params(struct snd_pcm_substream *substream,
 }
 
 static const struct snd_soc_ops simple_ops = {
-	.startup	= simple_startup,
+	.startup	= asoc_simple_startup,
 	.shutdown	= simple_shutdown,
 	.hw_params	= simple_hw_params,
 };
Signature · 1 line
2.7.4
author maintainer
#4 lore raw

PATCH v2 4/11 ASoC: simple-card-utils: share asoc_simple_shutdown()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_shutdown() between in these 2 drivers.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  2 +-
 sound/soc/generic/audio-graph-card.c  | 13 +------------
 sound/soc/generic/simple-card-utils.c | 16 ++++++++++++++--
 sound/soc/generic/simple-card.c       | 14 +-------------
 4 files changed, 17 insertions(+), 28 deletions(-)
include/sound/simple_card_utils.h +1 -1
index 0653fb9..edda646 100644
@@ -84,8 +84,8 @@ int asoc_simple_card_parse_clk(struct device *dev,
 			       struct asoc_simple_dai *simple_dai,
 			       const char *dai_name,
 			       struct snd_soc_dai_link_component *dlc);
-void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai);
 int asoc_simple_startup(struct snd_pcm_substream *substream);
+void asoc_simple_shutdown(struct snd_pcm_substream *substream);
 
 #define asoc_simple_card_parse_cpu(node, dai_link,				\
 				   list_name, cells_name, is_single_link)	\
sound/soc/generic/audio-graph-card.c +1 -12
index 29ae71b..f3577b5 100644
@@ -56,17 +56,6 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = {
 			       SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 };
 
-static void graph_shutdown(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-
-	asoc_simple_card_clk_disable(dai_props->cpu_dai);
-
-	asoc_simple_card_clk_disable(dai_props->codec_dai);
-}
-
 static int graph_hw_params(struct snd_pcm_substream *substream,
 			   struct snd_pcm_hw_params *params)
 {
@@ -100,7 +89,7 @@ static int graph_hw_params(struct snd_pcm_substream *substream,
 
 static const struct snd_soc_ops graph_ops = {
 	.startup	= asoc_simple_startup,
-	.shutdown	= graph_shutdown,
+	.shutdown	= asoc_simple_shutdown,
 	.hw_params	= graph_hw_params,
 };
 
sound/soc/generic/simple-card-utils.c +14 -2
index 83ea1af..7ede163 100644
@@ -151,12 +151,11 @@ static int asoc_simple_card_clk_enable(struct asoc_simple_dai *dai)
 	return 0;
 }
 
-void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai)
+static void asoc_simple_card_clk_disable(struct asoc_simple_dai *dai)
 {
 	if (dai)
 		clk_disable_unprepare(dai->clk);
 }
-EXPORT_SYMBOL_GPL(asoc_simple_card_clk_disable);
 
 int asoc_simple_card_parse_clk(struct device *dev,
 			       struct device_node *node,
@@ -224,6 +223,19 @@ int asoc_simple_startup(struct snd_pcm_substream *substream)
 }
 EXPORT_SYMBOL_GPL(asoc_simple_startup);
 
+void asoc_simple_shutdown(struct snd_pcm_substream *substream)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	struct simple_dai_props *dai_props =
+		simple_priv_to_props(priv, rtd->num);
+
+	asoc_simple_card_clk_disable(dai_props->cpu_dai);
+
+	asoc_simple_card_clk_disable(dai_props->codec_dai);
+}
+EXPORT_SYMBOL_GPL(asoc_simple_shutdown);
+
 int asoc_simple_card_parse_dai(struct device_node *node,
 				    struct snd_soc_dai_link_component *dlc,
 				    struct device_node **dai_of_node,
sound/soc/generic/simple-card.c +1 -13
index d0ea573..bb57c48 100644
@@ -26,18 +26,6 @@ struct link_info {
 #define CELL	"#sound-dai-cells"
 #define PREFIX	"simple-audio-card,"
 
-static void simple_shutdown(struct snd_pcm_substream *substream)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props =
-		simple_priv_to_props(priv, rtd->num);
-
-	asoc_simple_card_clk_disable(dai_props->cpu_dai);
-
-	asoc_simple_card_clk_disable(dai_props->codec_dai);
-}
-
 static int simple_set_clk_rate(struct asoc_simple_dai *simple_dai,
 			       unsigned long rate)
 {
@@ -96,7 +84,7 @@ static int simple_hw_params(struct snd_pcm_substream *substream,
 
 static const struct snd_soc_ops simple_ops = {
 	.startup	= asoc_simple_startup,
-	.shutdown	= simple_shutdown,
+	.shutdown	= asoc_simple_shutdown,
 	.hw_params	= simple_hw_params,
 };
 
Signature · 1 line
2.7.4
author maintainer
#5 lore raw

PATCH v2 5/11 ASoC: simple-card-utils: share asoc_simple_hw_param()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_hw_param() between in these 2 drivers.

One note is that only simple-card supports simple_set_clk_rate() at hw_param from commit e9be4ffd4f40fcb ("ASoC: simple-card: set cpu dai clk in hw_params").
By this patch, audio-graph has same feature.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  2 ++
 sound/soc/generic/audio-graph-card.c  | 33 +-------------------
 sound/soc/generic/simple-card-utils.c | 57 ++++++++++++++++++++++++++++++++++
 sound/soc/generic/simple-card.c       | 58 +----------------------------------
 4 files changed, 61 insertions(+), 89 deletions(-)
include/sound/simple_card_utils.h +2 -0
index edda646..89ae084 100644
@@ -86,6 +86,8 @@ int asoc_simple_card_parse_clk(struct device *dev,
 			       struct snd_soc_dai_link_component *dlc);
 int asoc_simple_startup(struct snd_pcm_substream *substream);
 void asoc_simple_shutdown(struct snd_pcm_substream *substream);
+int asoc_simple_hw_params(struct snd_pcm_substream *substream,
+			  struct snd_pcm_hw_params *params);
 
 #define asoc_simple_card_parse_cpu(node, dai_link,				\
 				   list_name, cells_name, is_single_link)	\
sound/soc/generic/audio-graph-card.c +1 -32
index f3577b5..51160ad 100644
@@ -56,41 +56,10 @@ static const struct snd_soc_dapm_widget graph_dapm_widgets[] = {
 			       SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
 };
 
-static int graph_hw_params(struct snd_pcm_substream *substream,
-			   struct snd_pcm_hw_params *params)
-{
-	struct snd_soc_pcm_runtime *rtd = substream->private_data;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-	unsigned int mclk, mclk_fs = 0;
-	int ret = 0;
-
-	if (dai_props->mclk_fs)
-		mclk_fs = dai_props->mclk_fs;
-
-	if (mclk_fs) {
-		mclk = params_rate(params) * mclk_fs;
-		ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk,
-					     SND_SOC_CLOCK_IN);
-		if (ret && ret != -ENOTSUPP)
-			goto err;
-
-		ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk,
-					     SND_SOC_CLOCK_OUT);
-		if (ret && ret != -ENOTSUPP)
-			goto err;
-	}
-	return 0;
-err:
-	return ret;
-}
-
 static const struct snd_soc_ops graph_ops = {
 	.startup	= asoc_simple_startup,
 	.shutdown	= asoc_simple_shutdown,
-	.hw_params	= graph_hw_params,
+	.hw_params	= asoc_simple_hw_params,
 };
 
 static int graph_dai_init(struct snd_soc_pcm_runtime *rtd)
sound/soc/generic/simple-card-utils.c +57 -0

63 lines not on this page · raw message

sound/soc/generic/simple-card.c +1 -57

67 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#6 lore raw

PATCH v2 6/11 ASoC: simple-card-utils: share asoc_simple_dai_init()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_dai_init() between in these 2 drivers.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  4 +---
 sound/soc/generic/audio-graph-card.c  | 23 ++---------------------
 sound/soc/generic/simple-card-utils.c | 25 ++++++++++++++++++++++---
 sound/soc/generic/simple-card.c       | 25 +++----------------------
 4 files changed, 28 insertions(+), 49 deletions(-)
include/sound/simple_card_utils.h +1 -3
index 89ae084..2043437 100644
@@ -88,6 +88,7 @@ int asoc_simple_startup(struct snd_pcm_substream *substream);
 void asoc_simple_shutdown(struct snd_pcm_substream *substream);
 int asoc_simple_hw_params(struct snd_pcm_substream *substream,
 			  struct snd_pcm_hw_params *params);
+int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd);
 
 #define asoc_simple_card_parse_cpu(node, dai_link,				\
 				   list_name, cells_name, is_single_link)	\
@@ -130,9 +131,6 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep,
 					&(dai)->slots,		\
 					&(dai)->slot_width);
 
-int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
-			      struct asoc_simple_dai *simple_dai);
-
 void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link);
 void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
 				      int is_single_links);
sound/soc/generic/audio-graph-card.c +2 -21
index 51160ad..b1ceefc 100644
@@ -62,25 +62,6 @@ static const struct snd_soc_ops graph_ops = {
 	.hw_params	= asoc_simple_hw_params,
 };
 
-static int graph_dai_init(struct snd_soc_pcm_runtime *rtd)
-{
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-	int ret = 0;
-
-	ret = asoc_simple_card_init_dai(rtd->codec_dai,
-					dai_props->codec_dai);
-	if (ret < 0)
-		return ret;
-
-	ret = asoc_simple_card_init_dai(rtd->cpu_dai,
-					dai_props->cpu_dai);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
 static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				    struct snd_pcm_hw_params *params)
 {
@@ -255,7 +236,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	dai_link->dpcm_playback		= 1;
 	dai_link->dpcm_capture		= 1;
 	dai_link->ops			= &graph_ops;
-	dai_link->init			= graph_dai_init;
+	dai_link->init			= asoc_simple_dai_init;
 
 	return 0;
 }
@@ -327,7 +308,7 @@ static int graph_dai_link_of(struct asoc_simple_priv *priv,
 		return ret;
 
 	dai_link->ops = &graph_ops;
-	dai_link->init = graph_dai_init;
+	dai_link->init = asoc_simple_dai_init;
 
 	asoc_simple_card_canonicalize_platform(dai_link);
 	asoc_simple_card_canonicalize_cpu(dai_link,
sound/soc/generic/simple-card-utils.c +22 -3
index de23cf8..c9b53b3 100644
@@ -436,8 +436,8 @@ int asoc_simple_card_parse_graph_dai(struct device_node *ep,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_card_parse_graph_dai);
 
-int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
-			      struct asoc_simple_dai *simple_dai)
+static int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
+				     struct asoc_simple_dai *simple_dai)
 {
 	int ret;
 
@@ -467,7 +467,26 @@ int asoc_simple_card_init_dai(struct snd_soc_dai *dai,
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(asoc_simple_card_init_dai);
+
+int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
+	int ret;
+
+	ret = asoc_simple_card_init_dai(rtd->codec_dai,
+					dai_props->codec_dai);
+	if (ret < 0)
+		return ret;
+
+	ret = asoc_simple_card_init_dai(rtd->cpu_dai,
+					dai_props->cpu_dai);
+	if (ret < 0)
+		return ret;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_dai_init);
 
 void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link)
 {
sound/soc/generic/simple-card.c +3 -22
index 7e83647..bf4482e 100644
@@ -32,25 +32,6 @@ static const struct snd_soc_ops simple_ops = {
 	.hw_params	= asoc_simple_hw_params,
 };
 
-static int simple_dai_init(struct snd_soc_pcm_runtime *rtd)
-{
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-	int ret;
-
-	ret = asoc_simple_card_init_dai(rtd->codec_dai,
-					dai_props->codec_dai);
-	if (ret < 0)
-		return ret;
-
-	ret = asoc_simple_card_init_dai(rtd->cpu_dai,
-					dai_props->cpu_dai);
-	if (ret < 0)
-		return ret;
-
-	return 0;
-}
-
 static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				     struct snd_pcm_hw_params *params)
 {
@@ -221,7 +202,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	dai_link->dpcm_playback		= 1;
 	dai_link->dpcm_capture		= 1;
 	dai_link->ops			= &simple_ops;
-	dai_link->init			= simple_dai_init;
+	dai_link->init			= asoc_simple_dai_init;
 
 	return 0;
 }
@@ -316,7 +297,7 @@ static int simple_dai_link_of(struct asoc_simple_priv *priv,
 		goto dai_link_of_err;
 
 	dai_link->ops = &simple_ops;
-	dai_link->init = simple_dai_init;
+	dai_link->init = asoc_simple_dai_init;
 
 	asoc_simple_card_canonicalize_cpu(dai_link, single_cpu);
 	asoc_simple_card_canonicalize_platform(dai_link);
@@ -694,7 +675,7 @@ static int simple_probe(struct platform_device *pdev)
 		dai_link->stream_name	= cinfo->name;
 		dai_link->cpu_dai_name	= cinfo->cpu_dai.name;
 		dai_link->dai_fmt	= cinfo->daifmt;
-		dai_link->init		= simple_dai_init;
+		dai_link->init		= asoc_simple_dai_init;
 		memcpy(priv->dai_props->cpu_dai, &cinfo->cpu_dai,
 					sizeof(*priv->dai_props->cpu_dai));
 		memcpy(priv->dai_props->codec_dai, &cinfo->codec_dai,
Signature · 1 line
2.7.4
author maintainer
#7 lore raw

PATCH v2 7/11 ASoC: simple-card-utils: share asoc_simple_be_hw_params_fixup()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph have almost same functions. This patch shares asoc_simple_be_hw_params_fixup() between in these 2 drivers.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  2 ++
 sound/soc/generic/audio-graph-card.c  | 13 +------------
 sound/soc/generic/simple-card-utils.c | 12 ++++++++++++
 sound/soc/generic/simple-card.c       | 13 +------------
 4 files changed, 16 insertions(+), 24 deletions(-)
include/sound/simple_card_utils.h +2 -0
index 2043437..20d41bb 100644
@@ -89,6 +89,8 @@ void asoc_simple_shutdown(struct snd_pcm_substream *substream);
 int asoc_simple_hw_params(struct snd_pcm_substream *substream,
 			  struct snd_pcm_hw_params *params);
 int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd);
+int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				   struct snd_pcm_hw_params *params);
 
 #define asoc_simple_card_parse_cpu(node, dai_link,				\
 				   list_name, cells_name, is_single_link)	\
sound/soc/generic/audio-graph-card.c +1 -12
index b1ceefc..605126f 100644
@@ -62,17 +62,6 @@ static const struct snd_soc_ops graph_ops = {
 	.hw_params	= asoc_simple_hw_params,
 };
 
-static int graph_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				    struct snd_pcm_hw_params *params)
-{
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-
-	asoc_simple_card_convert_fixup(&dai_props->adata, params);
-
-	return 0;
-}
-
 static void graph_parse_convert(struct device *dev,
 				struct device_node *ep,
 				struct asoc_simple_card_data *adata)
@@ -186,7 +175,7 @@ static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 
 		/* BE settings */
 		dai_link->no_pcm		= 1;
-		dai_link->be_hw_params_fixup	= graph_be_hw_params_fixup;
+		dai_link->be_hw_params_fixup	= asoc_simple_be_hw_params_fixup;
 
 		dai =
 		dai_props->codec_dai	= &priv->dais[li->dais++];
sound/soc/generic/simple-card-utils.c +12 -0
index c9b53b3..ec4a010 100644
@@ -293,6 +293,18 @@ int asoc_simple_hw_params(struct snd_pcm_substream *substream,
 }
 EXPORT_SYMBOL_GPL(asoc_simple_hw_params);
 
+int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+				   struct snd_pcm_hw_params *params)
+{
+	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
+
+	asoc_simple_card_convert_fixup(&dai_props->adata, params);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_be_hw_params_fixup);
+
 int asoc_simple_card_parse_dai(struct device_node *node,
 				    struct snd_soc_dai_link_component *dlc,
 				    struct device_node **dai_of_node,
sound/soc/generic/simple-card.c +1 -12
index bf4482e..60a88a5 100644
@@ -32,17 +32,6 @@ static const struct snd_soc_ops simple_ops = {
 	.hw_params	= asoc_simple_hw_params,
 };
 
-static int simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-				     struct snd_pcm_hw_params *params)
-{
-	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card);
-	struct simple_dai_props *dai_props = simple_priv_to_props(priv, rtd->num);
-
-	asoc_simple_card_convert_fixup(&dai_props->adata, params);
-
-	return 0;
-}
-
 static void simple_parse_convert(struct device *dev,
 				 struct device_node *np,
 				 struct asoc_simple_card_data *adata)
@@ -154,7 +143,7 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 
 		/* BE settings */
 		dai_link->no_pcm		= 1;
-		dai_link->be_hw_params_fixup	= simple_be_hw_params_fixup;
+		dai_link->be_hw_params_fixup	= asoc_simple_be_hw_params_fixup;
 
 		dai =
 		dai_props->codec_dai	= &priv->dais[li->dais++];
Signature · 1 line
2.7.4
author maintainer
#8 lore raw

PATCH v2 8/11 ASoC: simple-card-utils: share asoc_simple_card_init_priv()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph are initializing each priv, but it is same operation.
This patch adds new asoc_simple_card_init_priv() and initialize priv by same operation.

---
v1 -> v2

- add missing EXPORT_SYMBOL_GPL()

 include/sound/simple_card_utils.h     | 10 ++++++-
 sound/soc/generic/audio-graph-card.c  | 45 +++-------------------------
 sound/soc/generic/simple-card-utils.c | 49 ++++++++++++++++++++++++++++++
 sound/soc/generic/simple-card.c       | 56 +++++++----------------------------
 4 files changed, 73 insertions(+), 87 deletions(-)
include/sound/simple_card_utils.h +9 -1
index 20d41bb..c0be02d 100644
@@ -60,6 +60,13 @@ struct asoc_simple_priv {
 #define simple_priv_to_dev(priv)	(simple_priv_to_card(priv)->dev)
 #define simple_priv_to_link(priv, i)	(simple_priv_to_card(priv)->dai_link + (i))
 
+struct link_info {
+	int dais; /* number of dai  */
+	int link; /* number of link */
+	int conf; /* number of codec_conf */
+	int cpu;  /* turn for CPU / Codec */
+};
+
 int asoc_simple_card_parse_daifmt(struct device *dev,
 				  struct device_node *node,
 				  struct device_node *codec,
@@ -153,7 +160,8 @@ int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
 int asoc_simple_card_init_jack(struct snd_soc_card *card,
 			       struct asoc_simple_jack *sjack,
 			       int is_hp, char *prefix);
-
+int asoc_simple_card_init_priv(struct asoc_simple_priv *priv,
+			       struct link_info *li);
 
 #ifdef DEBUG
 inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv,
sound/soc/generic/audio-graph-card.c +4 -41

72 lines not on this page · raw message

sound/soc/generic/simple-card-utils.c +49 -0

55 lines not on this page · raw message

sound/soc/generic/simple-card.c +11 -45

90 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#9 lore raw

Applied "ASoC: simple-card-utils: share asoc_simple_card_init_priv()" to the asoc tree

The patch

ASoC: simple-card-utils: share asoc_simple_card_init_priv()

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 65a5056b21202eff7f54243e587183f4bb6ed352 Mon Sep 17 00:00:00 2001

From: Kuninori Morimoto <[email protected]>
Date: Wed, 20 Mar 2019 13:56:26 +0900
Subject: [PATCH] ASoC: simple-card-utils: share asoc_simple_card_init_priv()

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph are initializing each priv, but it is same operation.
This patch adds new asoc_simple_card_init_priv() and initialize priv by same operation.

---
 include/sound/simple_card_utils.h     | 10 ++++-
 sound/soc/generic/audio-graph-card.c  | 45 ++-------------------
 sound/soc/generic/simple-card-utils.c | 49 +++++++++++++++++++++++
 sound/soc/generic/simple-card.c       | 56 ++++++---------------------
 4 files changed, 73 insertions(+), 87 deletions(-)
include/sound/simple_card_utils.h +9 -1
index 20d41bb14ea8..c0be02de6993 100644
@@ -60,6 +60,13 @@ struct asoc_simple_priv {
 #define simple_priv_to_dev(priv)	(simple_priv_to_card(priv)->dev)
 #define simple_priv_to_link(priv, i)	(simple_priv_to_card(priv)->dai_link + (i))
 
+struct link_info {
+	int dais; /* number of dai  */
+	int link; /* number of link */
+	int conf; /* number of codec_conf */
+	int cpu;  /* turn for CPU / Codec */
+};
+
 int asoc_simple_card_parse_daifmt(struct device *dev,
 				  struct device_node *node,
 				  struct device_node *codec,
@@ -153,7 +160,8 @@ int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
 int asoc_simple_card_init_jack(struct snd_soc_card *card,
 			       struct asoc_simple_jack *sjack,
 			       int is_hp, char *prefix);
-
+int asoc_simple_card_init_priv(struct asoc_simple_priv *priv,
+			       struct link_info *li);
 
 #ifdef DEBUG
 inline void asoc_simple_debug_dai(struct asoc_simple_priv *priv,
sound/soc/generic/audio-graph-card.c +4 -41

72 lines not on this page · raw message

sound/soc/generic/simple-card-utils.c +49 -0

55 lines not on this page · raw message

sound/soc/generic/simple-card.c +11 -45

90 lines not on this page · raw message

Signature · 1 line
2.20.1
author maintainer
#10 lore raw

PATCH v2 9/11 ASoC: simple-card-utils: separate asoc_simple_card_parse_dai()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

The difference between simple-card / audio-graph are just using OF graph style, or not. In other words, other things should be same. This means, simple-card/audio-graph common functions should be implemented at simple-card-utils, and its own functions should be implemented at each files.

Current simple-card / audio-graph are using asoc_simple_card_parse_dai() which is different implementation. But, these are implemanted at simple-card-utils.
It should be implemanted at each files.
This patch separate these into each files.

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  39 ++--------
 sound/soc/generic/audio-graph-card.c  | 114 ++++++++++++++++++++++++---
 sound/soc/generic/simple-card-utils.c | 143 ----------------------------------
 sound/soc/generic/simple-card.c       |  58 ++++++++++++--
 4 files changed, 164 insertions(+), 190 deletions(-)
include/sound/simple_card_utils.h +8 -31
index c0be02d..0c070c2 100644
@@ -99,40 +99,17 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd);
 int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				   struct snd_pcm_hw_params *params);
 
-#define asoc_simple_card_parse_cpu(node, dai_link,				\
-				   list_name, cells_name, is_single_link)	\
-	asoc_simple_card_parse_dai(node, NULL,					\
-		&dai_link->cpu_of_node,						\
-		&dai_link->cpu_dai_name, list_name, cells_name, is_single_link)
-#define asoc_simple_card_parse_codec(node, dai_link, list_name, cells_name)	\
+#define asoc_simple_card_parse_cpu(node, dai_link, is_single_link)	\
+	asoc_simple_card_parse_dai(node, NULL,				\
+		&dai_link->cpu_of_node,					\
+		&dai_link->cpu_dai_name, is_single_link)
+#define asoc_simple_card_parse_codec(node, dai_link)	\
 	asoc_simple_card_parse_dai(node, dai_link->codecs,			\
 				   &dai_link->codec_of_node,			\
-				   &dai_link->codec_dai_name,			\
-				   list_name, cells_name, NULL)
-#define asoc_simple_card_parse_platform(node, dai_link, list_name, cells_name)	\
+				   &dai_link->codec_dai_name, NULL)
+#define asoc_simple_card_parse_platform(node, dai_link)	\
 	asoc_simple_card_parse_dai(node, dai_link->platforms,			\
-		&dai_link->platform_of_node,					\
-		NULL, list_name, cells_name, NULL)
-int asoc_simple_card_parse_dai(struct device_node *node,
-				  struct snd_soc_dai_link_component *dlc,
-				  struct device_node **endpoint_np,
-				  const char **dai_name,
-				  const char *list_name,
-				  const char *cells_name,
-				  int *is_single_links);
-
-#define asoc_simple_card_parse_graph_cpu(ep, dai_link)			\
-	asoc_simple_card_parse_graph_dai(ep, NULL,			\
-					 &dai_link->cpu_of_node,	\
-					 &dai_link->cpu_dai_name)
-#define asoc_simple_card_parse_graph_codec(ep, dai_link)		\
-	asoc_simple_card_parse_graph_dai(ep, dai_link->codecs,		\
-					 &dai_link->codec_of_node,	\
-					 &dai_link->codec_dai_name)
-int asoc_simple_card_parse_graph_dai(struct device_node *ep,
-				     struct snd_soc_dai_link_component *dlc,
-				     struct device_node **endpoint_np,
-				     const char **dai_name);
+		&dai_link->platform_of_node, NULL, NULL)
 
 #define asoc_simple_card_of_parse_tdm(np, dai)			\
 	snd_soc_of_parse_tdm_slot(np,	&(dai)->tx_slot_mask,	\
sound/soc/generic/audio-graph-card.c +105 -9

165 lines not on this page · raw message

sound/soc/generic/simple-card-utils.c +0 -143

149 lines not on this page · raw message

sound/soc/generic/simple-card.c +51 -7

88 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#11 lore raw

PATCH v2 10/11 ASoC: simple-card-utils: rename asoc_simple_card_xxx() to asoc_simple_()

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

Current simple-card-utils is using asoc_simple_card_xxx() for each function naming, but it is very verbose.
Thus it is easy to be over 80 char.
This patch renames it to asoc_simple_xxx().

---
v1 -> v2

- no change

 include/sound/simple_card_utils.h     |  90 ++++++++++++-------------
 sound/soc/generic/audio-graph-card.c  |  98 +++++++++++++--------------
 sound/soc/generic/simple-card-utils.c | 122 +++++++++++++++++-----------------
 sound/soc/generic/simple-card.c       |  98 +++++++++++++--------------
 4 files changed, 204 insertions(+), 204 deletions(-)
include/sound/simple_card_utils.h +45 -45
index 0c070c2..67dc3ee 100644
@@ -10,10 +10,10 @@
 
 #include <sound/soc.h>
 
-#define asoc_simple_card_init_hp(card, sjack, prefix) \
-	asoc_simple_card_init_jack(card, sjack, 1, prefix)
-#define asoc_simple_card_init_mic(card, sjack, prefix) \
-	asoc_simple_card_init_jack(card, sjack, 0, prefix)
+#define asoc_simple_init_hp(card, sjack, prefix) \
+	asoc_simple_init_jack(card, sjack, 1, prefix)
+#define asoc_simple_init_mic(card, sjack, prefix) \
+	asoc_simple_init_jack(card, sjack, 0, prefix)
 
 struct asoc_simple_dai {
 	const char *name;
@@ -26,7 +26,7 @@ struct asoc_simple_dai {
 	struct clk *clk;
 };
 
-struct asoc_simple_card_data {
+struct asoc_simple_data {
 	u32 convert_rate;
 	u32 convert_channels;
 };
@@ -44,7 +44,7 @@ struct asoc_simple_priv {
 		struct asoc_simple_dai *codec_dai;
 		struct snd_soc_dai_link_component codecs; /* single codec */
 		struct snd_soc_dai_link_component platforms;
-		struct asoc_simple_card_data adata;
+		struct asoc_simple_data adata;
 		struct snd_soc_codec_conf *codec_conf;
 		unsigned int mclk_fs;
 	} *dai_props;
@@ -67,30 +67,30 @@ struct link_info {
 	int cpu;  /* turn for CPU / Codec */
 };
 
-int asoc_simple_card_parse_daifmt(struct device *dev,
-				  struct device_node *node,
-				  struct device_node *codec,
-				  char *prefix,
-				  unsigned int *retfmt);
+int asoc_simple_parse_daifmt(struct device *dev,
+			     struct device_node *node,
+			     struct device_node *codec,
+			     char *prefix,
+			     unsigned int *retfmt);
 __printf(3, 4)
-int asoc_simple_card_set_dailink_name(struct device *dev,
-				      struct snd_soc_dai_link *dai_link,
-				      const char *fmt, ...);
-int asoc_simple_card_parse_card_name(struct snd_soc_card *card,
-				     char *prefix);
-
-#define asoc_simple_card_parse_clk_cpu(dev, node, dai_link, simple_dai)		\
-	asoc_simple_card_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \
+int asoc_simple_set_dailink_name(struct device *dev,
+				 struct snd_soc_dai_link *dai_link,
+				 const char *fmt, ...);
+int asoc_simple_parse_card_name(struct snd_soc_card *card,
+				char *prefix);
+
+#define asoc_simple_parse_clk_cpu(dev, node, dai_link, simple_dai)		\
+	asoc_simple_parse_clk(dev, node, dai_link->cpu_of_node, simple_dai, \
 				   dai_link->cpu_dai_name, NULL)
-#define asoc_simple_card_parse_clk_codec(dev, node, dai_link, simple_dai)	\
-	asoc_simple_card_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\
+#define asoc_simple_parse_clk_codec(dev, node, dai_link, simple_dai)	\
+	asoc_simple_parse_clk(dev, node, dai_link->codec_of_node, simple_dai,\
 				   dai_link->codec_dai_name, dai_link->codecs)
-int asoc_simple_card_parse_clk(struct device *dev,
-			       struct device_node *node,
-			       struct device_node *dai_of_node,
-			       struct asoc_simple_dai *simple_dai,
-			       const char *dai_name,
-			       struct snd_soc_dai_link_component *dlc);
+int asoc_simple_parse_clk(struct device *dev,
+			  struct device_node *node,
+			  struct device_node *dai_of_node,
+			  struct asoc_simple_dai *simple_dai,
+			  const char *dai_name,
+			  struct snd_soc_dai_link_component *dlc);
 int asoc_simple_startup(struct snd_pcm_substream *substream);
 void asoc_simple_shutdown(struct snd_pcm_substream *substream);
 int asoc_simple_hw_params(struct snd_pcm_substream *substream,
@@ -99,45 +99,45 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd);
 int asoc_simple_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				   struct snd_pcm_hw_params *params);
 
-#define asoc_simple_card_parse_cpu(node, dai_link, is_single_link)	\
-	asoc_simple_card_parse_dai(node, NULL,				\
+#define asoc_simple_parse_cpu(node, dai_link, is_single_link)	\
+	asoc_simple_parse_dai(node, NULL,				\
 		&dai_link->cpu_of_node,					\
 		&dai_link->cpu_dai_name, is_single_link)
-#define asoc_simple_card_parse_codec(node, dai_link)	\
-	asoc_simple_card_parse_dai(node, dai_link->codecs,			\
+#define asoc_simple_parse_codec(node, dai_link)	\
+	asoc_simple_parse_dai(node, dai_link->codecs,			\
 				   &dai_link->codec_of_node,			\
 				   &dai_link->codec_dai_name, NULL)
-#define asoc_simple_card_parse_platform(node, dai_link)	\
-	asoc_simple_card_parse_dai(node, dai_link->platforms,			\
+#define asoc_simple_parse_platform(node, dai_link)	\
+	asoc_simple_parse_dai(node, dai_link->platforms,			\
 		&dai_link->platform_of_node, NULL, NULL)
 
-#define asoc_simple_card_of_parse_tdm(np, dai)			\
+#define asoc_simple_parse_tdm(np, dai)			\
 	snd_soc_of_parse_tdm_slot(np,	&(dai)->tx_slot_mask,	\
 					&(dai)->rx_slot_mask,	\
 					&(dai)->slots,		\
 					&(dai)->slot_width);
 
-void asoc_simple_card_canonicalize_platform(struct snd_soc_dai_link *dai_link);
-void asoc_simple_card_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
+void asoc_simple_canonicalize_platform(struct snd_soc_dai_link *dai_link);
+void asoc_simple_canonicalize_cpu(struct snd_soc_dai_link *dai_link,
 				      int is_single_links);
 
-int asoc_simple_card_clean_reference(struct snd_soc_card *card);
+int asoc_simple_clean_reference(struct snd_soc_card *card);
 
-void asoc_simple_card_convert_fixup(struct asoc_simple_card_data *data,
+void asoc_simple_convert_fixup(struct asoc_simple_data *data,
 				      struct snd_pcm_hw_params *params);
-void asoc_simple_card_parse_convert(struct device *dev,
-				    struct device_node *np, char *prefix,
-				    struct asoc_simple_card_data *data);
+void asoc_simple_parse_convert(struct device *dev,
+			       struct device_node *np, char *prefix,
+			       struct asoc_simple_data *data);
 
-int asoc_simple_card_of_parse_routing(struct snd_soc_card *card,
+int asoc_simple_parse_routing(struct snd_soc_card *card,
 				      char *prefix);
-int asoc_simple_card_of_parse_widgets(struct snd_soc_card *card,
+int asoc_simple_parse_widgets(struct snd_soc_card *card,
 				      char *prefix);
 
-int asoc_simple_card_init_jack(struct snd_soc_card *card,
+int asoc_simple_init_jack(struct snd_soc_card *card,
 			       struct asoc_simple_jack *sjack,
 			       int is_hp, char *prefix);
-int asoc_simple_card_init_priv(struct asoc_simple_priv *priv,
+int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 			       struct link_info *li);
 
 #ifdef DEBUG
sound/soc/generic/audio-graph-card.c +49 -49

235 lines not on this page · raw message

sound/soc/generic/simple-card-utils.c +61 -61

270 lines not on this page · raw message

sound/soc/generic/simple-card.c +49 -49

237 lines not on this page · raw message

Signature · 1 line
2.7.4
author maintainer
#12 lore raw

PATCH v2 11/11 ASoC: simple-card-utils: test memory allocation

In reply to Kuninori Morimoto

From: Kuninori Morimoto <[email protected]>

li->conf will be 0 if it was not DPCM case. Then, 1) we shouldn't call devm_kcalloc() with size 0,
2) we need NULL pointer check if li->conf was not 0. This patch fixed above issues.
Special thanks to Pierre-Louis Bossart

---
v1 -> v2

- no change

 sound/soc/generic/simple-card-utils.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
sound/soc/generic/simple-card-utils.c +7 -2
index a794f76..4ed6834 100644
@@ -495,16 +495,21 @@ int asoc_simple_init_priv(struct asoc_simple_priv *priv,
 	struct snd_soc_dai_link *dai_link;
 	struct simple_dai_props *dai_props;
 	struct asoc_simple_dai *dais;
-	struct snd_soc_codec_conf *cconf;
+	struct snd_soc_codec_conf *cconf = NULL;
 	int i;
 
 	dai_props = devm_kcalloc(dev, li->link, sizeof(*dai_props), GFP_KERNEL);
 	dai_link  = devm_kcalloc(dev, li->link, sizeof(*dai_link),  GFP_KERNEL);
 	dais      = devm_kcalloc(dev, li->dais, sizeof(*dais),      GFP_KERNEL);
-	cconf     = devm_kcalloc(dev, li->conf, sizeof(*cconf),     GFP_KERNEL);
 	if (!dai_props || !dai_link || !dais)
 		return -ENOMEM;
 
+	if (li->conf) {
+		cconf = devm_kcalloc(dev, li->conf, sizeof(*cconf), GFP_KERNEL);
+		if (!cconf)
+			return -ENOMEM;
+	}
+
 	/*
 	 * Use snd_soc_dai_link_component instead of legacy style
 	 * It is codec only. but cpu/platform will be supported in the future.
Signature · 1 line
2.7.4