diff mbox series

[v3,08/13] ASoC: audio-graph: Expose helpers from audio graph

Message ID 1601573587-15288-9-git-send-email-spujar@nvidia.com
State New
Headers show
Series Audio graph card updates and usage with Tegra210 audio | expand

Commit Message

Sameer Pujar Oct. 1, 2020, 5:33 p.m. UTC
This commit exposes following functions which can be used by a sound
card driver based on audio graph driver. Idea is vendors can have a
thin driver and re-use common stuff from audio graph driver.

 - graph_card_probe()
 - graph_get_dais_count()
 - graph_parse_of()

In doing so a new header file is added for audio graph which can be
included by vendor drivers.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
Cc: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/sound/graph_card.h           | 19 +++++++++++++++++++
 sound/soc/generic/audio-graph-card.c | 11 +++++++----
 2 files changed, 26 insertions(+), 4 deletions(-)
 create mode 100644 include/sound/graph_card.h

Comments

kernel test robot Oct. 2, 2020, 3:06 a.m. UTC | #1
Hi Sameer,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tegra/for-next]
[also build test WARNING on v5.9-rc7 next-20201001]
[cannot apply to asoc/for-next robh/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sameer-Pujar/Audio-graph-card-updates-and-usage-with-Tegra210-audio/20201002-013648
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/b7b97805bc967aae0ce3009c1bbf17b0f232e18b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sameer-Pujar/Audio-graph-card-updates-and-usage-with-Tegra210-audio/20201002-013648
        git checkout b7b97805bc967aae0ce3009c1bbf17b0f232e18b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   sound/soc/generic/audio-graph-card.c: In function 'soc_component_is_pcm':
   sound/soc/generic/audio-graph-card.c:116:28: error: implicit declaration of function 'snd_soc_find_dai_with_mutex' [-Werror=implicit-function-declaration]
     116 |  struct snd_soc_dai *dai = snd_soc_find_dai_with_mutex(dlc);
         |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   sound/soc/generic/audio-graph-card.c:116:28: warning: initialization of 'struct snd_soc_dai *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
   sound/soc/generic/audio-graph-card.c: At top level:
>> sound/soc/generic/audio-graph-card.c:532:5: warning: no previous prototype for 'graph_parse_of' [-Wmissing-prototypes]
     532 | int graph_parse_of(struct asoc_simple_priv *priv)
         |     ^~~~~~~~~~~~~~
>> sound/soc/generic/audio-graph-card.c:608:6: warning: no previous prototype for 'graph_get_dais_count' [-Wmissing-prototypes]
     608 | void graph_get_dais_count(struct asoc_simple_priv *priv,
         |      ^~~~~~~~~~~~~~~~~~~~
>> sound/soc/generic/audio-graph-card.c:667:5: warning: no previous prototype for 'graph_card_probe' [-Wmissing-prototypes]
     667 | int graph_card_probe(struct snd_soc_card *card)
         |     ^~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/graph_parse_of +532 sound/soc/generic/audio-graph-card.c

   531	
 > 532	int graph_parse_of(struct asoc_simple_priv *priv)
   533	{
   534		struct snd_soc_card *card = simple_priv_to_card(priv);
   535		struct link_info li;
   536		int ret;
   537	
   538		ret = asoc_simple_parse_widgets(card, NULL);
   539		if (ret < 0)
   540			return ret;
   541	
   542		ret = asoc_simple_parse_routing(card, NULL);
   543		if (ret < 0)
   544			return ret;
   545	
   546		memset(&li, 0, sizeof(li));
   547		for (li.cpu = 1; li.cpu >= 0; li.cpu--) {
   548			/*
   549			 * Detect all CPU first, and Detect all Codec 2nd.
   550			 *
   551			 * In Normal sound case, all DAIs are detected
   552			 * as "CPU-Codec".
   553			 *
   554			 * In DPCM sound case,
   555			 * all CPUs   are detected as "CPU-dummy", and
   556			 * all Codecs are detected as "dummy-Codec".
   557			 * To avoid random sub-device numbering,
   558			 * detect "dummy-Codec" in last;
   559			 */
   560			ret = graph_for_each_link(priv, &li,
   561						  graph_dai_link_of,
   562						  graph_dai_link_of_dpcm);
   563			if (ret < 0)
   564				return ret;
   565		}
   566	
   567		return asoc_simple_parse_card_name(card, NULL);
   568	}
   569	EXPORT_SYMBOL_GPL(graph_parse_of);
   570	
   571	static int graph_count_noml(struct asoc_simple_priv *priv,
   572				    struct device_node *cpu_ep,
   573				    struct device_node *codec_ep,
   574				    struct link_info *li)
   575	{
   576		struct device *dev = simple_priv_to_dev(priv);
   577	
   578		li->link += 1; /* 1xCPU-Codec */
   579		li->dais += 2; /* 1xCPU + 1xCodec */
   580	
   581		dev_dbg(dev, "Count As Normal\n");
   582	
   583		return 0;
   584	}
   585	
   586	static int graph_count_dpcm(struct asoc_simple_priv *priv,
   587				    struct device_node *cpu_ep,
   588				    struct device_node *codec_ep,
   589				    struct link_info *li,
   590				    int dup_codec)
   591	{
   592		struct device *dev = simple_priv_to_dev(priv);
   593	
   594		li->link++; /* 1xCPU-dummy */
   595		li->dais++; /* 1xCPU */
   596	
   597		if (!dup_codec && codec_ep) {
   598			li->link++; /* 1xdummy-Codec */
   599			li->conf++; /* 1xdummy-Codec */
   600			li->dais++; /* 1xCodec */
   601		}
   602	
   603		dev_dbg(dev, "Count As DPCM\n");
   604	
   605		return 0;
   606	}
   607	
 > 608	void graph_get_dais_count(struct asoc_simple_priv *priv,
   609				  struct link_info *li)
   610	{
   611		struct device *dev = simple_priv_to_dev(priv);
   612	
   613		/*
   614		 * link_num :	number of links.
   615		 *		CPU-Codec / CPU-dummy / dummy-Codec
   616		 * dais_num :	number of DAIs
   617		 * ccnf_num :	number of codec_conf
   618		 *		same number for "dummy-Codec"
   619		 *
   620		 * ex1)
   621		 * CPU0 --- Codec0	link : 5
   622		 * CPU1 --- Codec1	dais : 7
   623		 * CPU2 -/		ccnf : 1
   624		 * CPU3 --- Codec2
   625		 *
   626		 *	=> 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec
   627		 *	=> 7 DAIs  = 4xCPU + 3xCodec
   628		 *	=> 1 ccnf  = 1xdummy-Codec
   629		 *
   630		 * ex2)
   631		 * CPU0 --- Codec0	link : 5
   632		 * CPU1 --- Codec1	dais : 6
   633		 * CPU2 -/		ccnf : 1
   634		 * CPU3 -/
   635		 *
   636		 *	=> 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec
   637		 *	=> 6 DAIs  = 4xCPU + 2xCodec
   638		 *	=> 1 ccnf  = 1xdummy-Codec
   639		 *
   640		 * ex3)
   641		 * CPU0 --- Codec0	link : 6
   642		 * CPU1 -/		dais : 6
   643		 * CPU2 --- Codec1	ccnf : 2
   644		 * CPU3 -/
   645		 *
   646		 *	=> 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec
   647		 *	=> 6 DAIs  = 4xCPU + 2xCodec
   648		 *	=> 2 ccnf  = 2xdummy-Codec
   649		 *
   650		 * ex4)
   651		 * CPU0 --- Codec0 (convert-rate)	link : 3
   652		 * CPU1 --- Codec1			dais : 4
   653		 *					ccnf : 1
   654		 *
   655		 *	=> 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec
   656		 *	=> 4 DAIs  = 2xCPU + 2xCodec
   657		 *	=> 1 ccnf  = 1xdummy-Codec
   658		 */
   659		graph_for_each_link(priv, li,
   660				    graph_count_noml,
   661				    graph_count_dpcm);
   662		dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
   663			li->link, li->dais, li->conf);
   664	}
   665	EXPORT_SYMBOL_GPL(graph_get_dais_count);
   666	
 > 667	int graph_card_probe(struct snd_soc_card *card)
   668	{
   669		struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
   670		int ret;
   671	
   672		ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL);
   673		if (ret < 0)
   674			return ret;
   675	
   676		ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL);
   677		if (ret < 0)
   678			return ret;
   679	
   680		return 0;
   681	}
   682	EXPORT_SYMBOL_GPL(graph_card_probe);
   683	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Oct. 2, 2020, 3:07 a.m. UTC | #2
Hi Sameer,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tegra/for-next]
[also build test WARNING on v5.9-rc7 next-20201001]
[cannot apply to asoc/for-next robh/for-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Sameer-Pujar/Audio-graph-card-updates-and-usage-with-Tegra210-audio/20201002-013648
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
config: x86_64-randconfig-r034-20200930 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project bcd05599d0e53977a963799d6ee4f6e0bc21331b)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/b7b97805bc967aae0ce3009c1bbf17b0f232e18b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Sameer-Pujar/Audio-graph-card-updates-and-usage-with-Tegra210-audio/20201002-013648
        git checkout b7b97805bc967aae0ce3009c1bbf17b0f232e18b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   sound/soc/generic/audio-graph-card.c:116:28: error: implicit declaration of function 'snd_soc_find_dai_with_mutex' [-Werror,-Wimplicit-function-declaration]
           struct snd_soc_dai *dai = snd_soc_find_dai_with_mutex(dlc);
                                     ^
   sound/soc/generic/audio-graph-card.c:116:22: warning: incompatible integer to pointer conversion initializing 'struct snd_soc_dai *' with an expression of type 'int' [-Wint-conversion]
           struct snd_soc_dai *dai = snd_soc_find_dai_with_mutex(dlc);
                               ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> sound/soc/generic/audio-graph-card.c:532:5: warning: no previous prototype for function 'graph_parse_of' [-Wmissing-prototypes]
   int graph_parse_of(struct asoc_simple_priv *priv)
       ^
   sound/soc/generic/audio-graph-card.c:532:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int graph_parse_of(struct asoc_simple_priv *priv)
   ^
   static 
>> sound/soc/generic/audio-graph-card.c:608:6: warning: no previous prototype for function 'graph_get_dais_count' [-Wmissing-prototypes]
   void graph_get_dais_count(struct asoc_simple_priv *priv,
        ^
   sound/soc/generic/audio-graph-card.c:608:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void graph_get_dais_count(struct asoc_simple_priv *priv,
   ^
   static 
>> sound/soc/generic/audio-graph-card.c:667:5: warning: no previous prototype for function 'graph_card_probe' [-Wmissing-prototypes]
   int graph_card_probe(struct snd_soc_card *card)
       ^
   sound/soc/generic/audio-graph-card.c:667:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int graph_card_probe(struct snd_soc_card *card)
   ^
   static 
   4 warnings and 1 error generated.

vim +/graph_parse_of +532 sound/soc/generic/audio-graph-card.c

   531	
 > 532	int graph_parse_of(struct asoc_simple_priv *priv)
   533	{
   534		struct snd_soc_card *card = simple_priv_to_card(priv);
   535		struct link_info li;
   536		int ret;
   537	
   538		ret = asoc_simple_parse_widgets(card, NULL);
   539		if (ret < 0)
   540			return ret;
   541	
   542		ret = asoc_simple_parse_routing(card, NULL);
   543		if (ret < 0)
   544			return ret;
   545	
   546		memset(&li, 0, sizeof(li));
   547		for (li.cpu = 1; li.cpu >= 0; li.cpu--) {
   548			/*
   549			 * Detect all CPU first, and Detect all Codec 2nd.
   550			 *
   551			 * In Normal sound case, all DAIs are detected
   552			 * as "CPU-Codec".
   553			 *
   554			 * In DPCM sound case,
   555			 * all CPUs   are detected as "CPU-dummy", and
   556			 * all Codecs are detected as "dummy-Codec".
   557			 * To avoid random sub-device numbering,
   558			 * detect "dummy-Codec" in last;
   559			 */
   560			ret = graph_for_each_link(priv, &li,
   561						  graph_dai_link_of,
   562						  graph_dai_link_of_dpcm);
   563			if (ret < 0)
   564				return ret;
   565		}
   566	
   567		return asoc_simple_parse_card_name(card, NULL);
   568	}
   569	EXPORT_SYMBOL_GPL(graph_parse_of);
   570	
   571	static int graph_count_noml(struct asoc_simple_priv *priv,
   572				    struct device_node *cpu_ep,
   573				    struct device_node *codec_ep,
   574				    struct link_info *li)
   575	{
   576		struct device *dev = simple_priv_to_dev(priv);
   577	
   578		li->link += 1; /* 1xCPU-Codec */
   579		li->dais += 2; /* 1xCPU + 1xCodec */
   580	
   581		dev_dbg(dev, "Count As Normal\n");
   582	
   583		return 0;
   584	}
   585	
   586	static int graph_count_dpcm(struct asoc_simple_priv *priv,
   587				    struct device_node *cpu_ep,
   588				    struct device_node *codec_ep,
   589				    struct link_info *li,
   590				    int dup_codec)
   591	{
   592		struct device *dev = simple_priv_to_dev(priv);
   593	
   594		li->link++; /* 1xCPU-dummy */
   595		li->dais++; /* 1xCPU */
   596	
   597		if (!dup_codec && codec_ep) {
   598			li->link++; /* 1xdummy-Codec */
   599			li->conf++; /* 1xdummy-Codec */
   600			li->dais++; /* 1xCodec */
   601		}
   602	
   603		dev_dbg(dev, "Count As DPCM\n");
   604	
   605		return 0;
   606	}
   607	
 > 608	void graph_get_dais_count(struct asoc_simple_priv *priv,
   609				  struct link_info *li)
   610	{
   611		struct device *dev = simple_priv_to_dev(priv);
   612	
   613		/*
   614		 * link_num :	number of links.
   615		 *		CPU-Codec / CPU-dummy / dummy-Codec
   616		 * dais_num :	number of DAIs
   617		 * ccnf_num :	number of codec_conf
   618		 *		same number for "dummy-Codec"
   619		 *
   620		 * ex1)
   621		 * CPU0 --- Codec0	link : 5
   622		 * CPU1 --- Codec1	dais : 7
   623		 * CPU2 -/		ccnf : 1
   624		 * CPU3 --- Codec2
   625		 *
   626		 *	=> 5 links = 2xCPU-Codec + 2xCPU-dummy + 1xdummy-Codec
   627		 *	=> 7 DAIs  = 4xCPU + 3xCodec
   628		 *	=> 1 ccnf  = 1xdummy-Codec
   629		 *
   630		 * ex2)
   631		 * CPU0 --- Codec0	link : 5
   632		 * CPU1 --- Codec1	dais : 6
   633		 * CPU2 -/		ccnf : 1
   634		 * CPU3 -/
   635		 *
   636		 *	=> 5 links = 1xCPU-Codec + 3xCPU-dummy + 1xdummy-Codec
   637		 *	=> 6 DAIs  = 4xCPU + 2xCodec
   638		 *	=> 1 ccnf  = 1xdummy-Codec
   639		 *
   640		 * ex3)
   641		 * CPU0 --- Codec0	link : 6
   642		 * CPU1 -/		dais : 6
   643		 * CPU2 --- Codec1	ccnf : 2
   644		 * CPU3 -/
   645		 *
   646		 *	=> 6 links = 0xCPU-Codec + 4xCPU-dummy + 2xdummy-Codec
   647		 *	=> 6 DAIs  = 4xCPU + 2xCodec
   648		 *	=> 2 ccnf  = 2xdummy-Codec
   649		 *
   650		 * ex4)
   651		 * CPU0 --- Codec0 (convert-rate)	link : 3
   652		 * CPU1 --- Codec1			dais : 4
   653		 *					ccnf : 1
   654		 *
   655		 *	=> 3 links = 1xCPU-Codec + 1xCPU-dummy + 1xdummy-Codec
   656		 *	=> 4 DAIs  = 2xCPU + 2xCodec
   657		 *	=> 1 ccnf  = 1xdummy-Codec
   658		 */
   659		graph_for_each_link(priv, li,
   660				    graph_count_noml,
   661				    graph_count_dpcm);
   662		dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
   663			li->link, li->dais, li->conf);
   664	}
   665	EXPORT_SYMBOL_GPL(graph_get_dais_count);
   666	
 > 667	int graph_card_probe(struct snd_soc_card *card)
   668	{
   669		struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
   670		int ret;
   671	
   672		ret = asoc_simple_init_hp(card, &priv->hp_jack, NULL);
   673		if (ret < 0)
   674			return ret;
   675	
   676		ret = asoc_simple_init_mic(card, &priv->mic_jack, NULL);
   677		if (ret < 0)
   678			return ret;
   679	
   680		return 0;
   681	}
   682	EXPORT_SYMBOL_GPL(graph_card_probe);
   683	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/include/sound/graph_card.h b/include/sound/graph_card.h
new file mode 100644
index 0000000..0372c1c
--- /dev/null
+++ b/include/sound/graph_card.h
@@ -0,0 +1,19 @@ 
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * ASoC audio graph card support
+ *
+ */
+
+#ifndef __GRAPH_CARD_H
+#define __GRAPH_CARD_H
+
+#include <sound/simple_card_utils.h>
+
+int graph_card_probe(struct snd_soc_card *card);
+
+void graph_get_dais_count(struct asoc_simple_priv *priv,
+			  struct link_info *li);
+
+int graph_parse_of(struct asoc_simple_priv *priv);
+
+#endif /* __GRAPH_CARD_H */
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index fb34e34..ae234bf 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -529,7 +529,7 @@  static int graph_for_each_link(struct asoc_simple_priv *priv,
 	return 0;
 }
 
-static int graph_parse_of(struct asoc_simple_priv *priv)
+int graph_parse_of(struct asoc_simple_priv *priv)
 {
 	struct snd_soc_card *card = simple_priv_to_card(priv);
 	struct link_info li;
@@ -566,6 +566,7 @@  static int graph_parse_of(struct asoc_simple_priv *priv)
 
 	return asoc_simple_parse_card_name(card, NULL);
 }
+EXPORT_SYMBOL_GPL(graph_parse_of);
 
 static int graph_count_noml(struct asoc_simple_priv *priv,
 			    struct device_node *cpu_ep,
@@ -604,8 +605,8 @@  static int graph_count_dpcm(struct asoc_simple_priv *priv,
 	return 0;
 }
 
-static void graph_get_dais_count(struct asoc_simple_priv *priv,
-				 struct link_info *li)
+void graph_get_dais_count(struct asoc_simple_priv *priv,
+			  struct link_info *li)
 {
 	struct device *dev = simple_priv_to_dev(priv);
 
@@ -661,8 +662,9 @@  static void graph_get_dais_count(struct asoc_simple_priv *priv,
 	dev_dbg(dev, "link %d, dais %d, ccnf %d\n",
 		li->link, li->dais, li->conf);
 }
+EXPORT_SYMBOL_GPL(graph_get_dais_count);
 
-static int graph_card_probe(struct snd_soc_card *card)
+int graph_card_probe(struct snd_soc_card *card)
 {
 	struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
 	int ret;
@@ -677,6 +679,7 @@  static int graph_card_probe(struct snd_soc_card *card)
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(graph_card_probe);
 
 static int graph_probe(struct platform_device *pdev)
 {