diff mbox series

[03/10] ASoC: audio-graph: Support Codec with multiple endpoints

Message ID 1595135417-16589-4-git-send-email-spujar@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Audio graph card updates and usage with Tegra210 audio | expand

Commit Message

Sameer Pujar July 19, 2020, 5:10 a.m. UTC
If a Codec port has multiple endpoints, only first endpoint gets parsed
and remaining are ignored. This can be fixed by removing 'dup_codec' flag
passed to graph_dai_link_of_dpcm() and thus it loops over all endpoints
of Codec. Similarly graph_count_dpcm() is updated as well.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 sound/soc/generic/audio-graph-card.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

Comments

Kuninori Morimoto July 19, 2020, 11:37 p.m. UTC | #1
Hi Sameer

> If a Codec port has multiple endpoints, only first endpoint gets parsed
> and remaining are ignored. This can be fixed by removing 'dup_codec' flag
> passed to graph_dai_link_of_dpcm() and thus it loops over all endpoints
> of Codec. Similarly graph_count_dpcm() is updated as well.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> ---
>  sound/soc/generic/audio-graph-card.c | 28 +++++++++-------------------
>  1 file changed, 9 insertions(+), 19 deletions(-)
> 
> diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
> index 1e20562..b1903f9 100644
> --- a/sound/soc/generic/audio-graph-card.c
> +++ b/sound/soc/generic/audio-graph-card.c
> @@ -201,8 +201,7 @@ static void graph_parse_mclk_fs(struct device_node *top,
>  static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
>  				  struct device_node *cpu_ep,
>  				  struct device_node *codec_ep,
> -				  struct link_info *li,
> -				  int dup_codec)
> +				  struct link_info *li)

This patch breaks DPCM connection which is used for MIXer

Thank you for your help !!

Best regards
---
Kuninori Morimoto
Sameer Pujar July 20, 2020, 4:14 a.m. UTC | #2
On 7/20/2020 5:07 AM, Kuninori Morimoto wrote:
> External email: Use caution opening links or attachments
>
>
> Hi Sameer
>
>> If a Codec port has multiple endpoints, only first endpoint gets parsed
>> and remaining are ignored. This can be fixed by removing 'dup_codec' flag
>> passed to graph_dai_link_of_dpcm() and thus it loops over all endpoints
>> of Codec. Similarly graph_count_dpcm() is updated as well.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> ---
>>   sound/soc/generic/audio-graph-card.c | 28 +++++++++-------------------
>>   1 file changed, 9 insertions(+), 19 deletions(-)
>>
>> diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
>> index 1e20562..b1903f9 100644
>> --- a/sound/soc/generic/audio-graph-card.c
>> +++ b/sound/soc/generic/audio-graph-card.c
>> @@ -201,8 +201,7 @@ static void graph_parse_mclk_fs(struct device_node *top,
>>   static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
>>                                  struct device_node *cpu_ep,
>>                                  struct device_node *codec_ep,
>> -                               struct link_info *li,
>> -                               int dup_codec)
>> +                               struct link_info *li)
> This patch breaks DPCM connection which is used for MIXer

Could you please elaborate a bit more as to what is broken with this? 
The problem I am trying to solve here is to have multiple endpoints for 
Codec port.

>
> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto
Kuninori Morimoto July 20, 2020, 5:13 a.m. UTC | #3
Hi Sameer

> >> diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
> >> index 1e20562..b1903f9 100644
> >> --- a/sound/soc/generic/audio-graph-card.c
> >> +++ b/sound/soc/generic/audio-graph-card.c
> >> @@ -201,8 +201,7 @@ static void graph_parse_mclk_fs(struct device_node *top,
> >>   static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
> >>                                  struct device_node *cpu_ep,
> >>                                  struct device_node *codec_ep,
> >> -                               struct link_info *li,
> >> -                               int dup_codec)
> >> +                               struct link_info *li)
> > This patch breaks DPCM connection which is used for MIXer
> 
> Could you please elaborate a bit more as to what is broken with this?
> The problem I am trying to solve here is to have multiple endpoints
> for Codec port.

For example MIXer, it is like below.
If you removes "dup_codec", it breaks MIXer and/or TDM split mode.

	CPU0  ---+---- DAI
	         |
	CPU1  ---+

	cpu {
		ports {
			port@0 {
				cpu_0: endpoint {
					remote-endpoint = <&codec_0>;
				};
			};
			port@1 {
				cpu_1: endpoint {
					remote-endpoint = <&codec_1>;
				};
			};
		};
	};

	codec {
		port {
			codec_0: endpoint {
				remote-endpoint = <&cpu_0>;
			};
			codec_1: endpoint {
				remote-endpoint = <&cpu_1>;
			};
		}
	};

Thank you for your help !!

Best regards
---
Kuninori Morimoto
Sameer Pujar Aug. 3, 2020, 12:02 p.m. UTC | #4
On 7/20/2020 10:43 AM, Kuninori Morimoto wrote:
> External email: Use caution opening links or attachments
>
>
> Hi Sameer
>
>>>> diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
>>>> index 1e20562..b1903f9 100644
>>>> --- a/sound/soc/generic/audio-graph-card.c
>>>> +++ b/sound/soc/generic/audio-graph-card.c
>>>> @@ -201,8 +201,7 @@ static void graph_parse_mclk_fs(struct device_node *top,
>>>>    static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
>>>>                                   struct device_node *cpu_ep,
>>>>                                   struct device_node *codec_ep,
>>>> -                               struct link_info *li,
>>>> -                               int dup_codec)
>>>> +                               struct link_info *li)
>>> This patch breaks DPCM connection which is used for MIXer
>> Could you please elaborate a bit more as to what is broken with this?
>> The problem I am trying to solve here is to have multiple endpoints
>> for Codec port.
> For example MIXer, it is like below.
> If you removes "dup_codec", it breaks MIXer and/or TDM split mode.
>
>          CPU0  ---+---- DAI
>                   |
>          CPU1  ---+
>
>          cpu {
>                  ports {
>                          port@0 {
>                                  cpu_0: endpoint {
>                                          remote-endpoint = <&codec_0>;
>                                  };
>                          };
>                          port@1 {
>                                  cpu_1: endpoint {
>                                          remote-endpoint = <&codec_1>;
>                                  };
>                          };
>                  };
>          };
>
>          codec {
>                  port {
>                          codec_0: endpoint {
>                                  remote-endpoint = <&cpu_0>;
>                          };
>                          codec_1: endpoint {
>                                  remote-endpoint = <&cpu_1>;
>                          };
>                  }
>          };

Thanks Kuninori for explaining above and for giving a background in an 
'off-list' thread. I will re-work on the patch by limiting the changes 
to specific flag so that it does not affect any other user.

> Thank you for your help !!
>
> Best regards
> ---
> Kuninori Morimoto
diff mbox series

Patch

diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c
index 1e20562..b1903f9 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -201,8 +201,7 @@  static void graph_parse_mclk_fs(struct device_node *top,
 static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 				  struct device_node *cpu_ep,
 				  struct device_node *codec_ep,
-				  struct link_info *li,
-				  int dup_codec)
+				  struct link_info *li)
 {
 	struct device *dev = simple_priv_to_dev(priv);
 	struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
@@ -217,10 +216,6 @@  static int graph_dai_link_of_dpcm(struct asoc_simple_priv *priv,
 	struct snd_soc_dai_link_component *codecs = dai_link->codecs;
 	int ret;
 
-	/* Do it all CPU endpoint, and 1st Codec endpoint */
-	if (!li->cpu && dup_codec)
-		return 0;
-
 	port	= of_get_parent(ep);
 	ports	= of_get_parent(port);
 	node	= of_graph_get_port_parent(ep);
@@ -415,7 +410,7 @@  static int graph_for_each_link(struct asoc_simple_priv *priv,
 			int (*func_dpcm)(struct asoc_simple_priv *priv,
 					 struct device_node *cpu_ep,
 					 struct device_node *codec_ep,
-					 struct link_info *li, int dup_codec))
+					 struct link_info *li))
 {
 	struct of_phandle_iterator it;
 	struct device *dev = simple_priv_to_dev(priv);
@@ -424,7 +419,6 @@  static int graph_for_each_link(struct asoc_simple_priv *priv,
 	struct device_node *cpu_ep;
 	struct device_node *codec_ep;
 	struct device_node *codec_port;
-	struct device_node *codec_port_old = NULL;
 	struct asoc_simple_data adata;
 	uintptr_t dpcm_selectable = (uintptr_t)of_device_get_match_data(dev);
 	int rc, ret;
@@ -457,8 +451,7 @@  static int graph_for_each_link(struct asoc_simple_priv *priv,
 			if (dpcm_selectable &&
 			    ((of_get_child_count(codec_port) > 1) ||
 			     adata.convert_rate || adata.convert_channels))
-				ret = func_dpcm(priv, cpu_ep, codec_ep, li,
-						(codec_port_old == codec_port));
+				ret = func_dpcm(priv, cpu_ep, codec_ep, li);
 			/* else normal sound */
 			else
 				ret = func_noml(priv, cpu_ep, codec_ep, li);
@@ -468,8 +461,6 @@  static int graph_for_each_link(struct asoc_simple_priv *priv,
 
 			if (ret < 0)
 				return ret;
-
-			codec_port_old = codec_port;
 		}
 	}
 
@@ -532,19 +523,18 @@  static int graph_count_noml(struct asoc_simple_priv *priv,
 static int graph_count_dpcm(struct asoc_simple_priv *priv,
 			    struct device_node *cpu_ep,
 			    struct device_node *codec_ep,
-			    struct link_info *li,
-			    int dup_codec)
+			    struct link_info *li)
 {
 	struct device *dev = simple_priv_to_dev(priv);
 
+	/* CPU */
 	li->link++; /* 1xCPU-dummy */
 	li->dais++; /* 1xCPU */
 
-	if (!dup_codec) {
-		li->link++; /* 1xdummy-Codec */
-		li->conf++; /* 1xdummy-Codec */
-		li->dais++; /* 1xCodec */
-	}
+	/* Codec */
+	li->link++; /* 1xdummy-Codec */
+	li->conf++; /* 1xdummy-Codec */
+	li->dais++; /* 1xCodec */
 
 	dev_dbg(dev, "Count As DPCM\n");