diff mbox series

[v5,3/4] ASoC: mediatek: mt8192: refactor for I2S8/I2S9 DAI links of headset

Message ID 20220319114111.11496-4-jiaxin.yu@mediatek.com (mailing list archive)
State New, archived
Headers show
Series ASoC: mediatek: mt8192: support rt1015p_rt5682s | expand

Commit Message

Jiaxin Yu March 19, 2022, 11:41 a.m. UTC
MT8192 platform use rt5682 codec, so through the snd_soc_of_get_dai_link_codes()
to complete the configuration of I2S8/I2S9 dai_link's codecs.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
---
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 34 ++++++++++++++-----
 1 file changed, 26 insertions(+), 8 deletions(-)

Comments

Tzung-Bi Shih March 21, 2022, 3:59 a.m. UTC | #1
On Sat, Mar 19, 2022 at 07:41:10PM +0800, Jiaxin Yu wrote:
> @@ -1145,6 +1140,13 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
>  		goto err_speaker_codec;
>  	}
>  
> +	headset_codec = of_get_child_by_name(pdev->dev.of_node, "mediatek,headset-codec");
> +	if (!headset_codec) {
> +		ret = -EINVAL;
> +		dev_err_probe(&pdev->dev, ret, "Property 'headset_codec' missing or invalid\n");
> +		goto err_headset_codec;
> +	}

(to be neat) Does it have any reason to prevent from using of_parse_phandle()
but of_get_child_by_name()?
Jiaxin Yu March 21, 2022, 9:14 a.m. UTC | #2
On Mon, 2022-03-21 at 11:59 +0800, Tzung-Bi Shih wrote:
> On Sat, Mar 19, 2022 at 07:41:10PM +0800, Jiaxin Yu wrote:
> > @@ -1145,6 +1140,13 @@ static int mt8192_mt6359_dev_probe(struct
> > platform_device *pdev)
> >  		goto err_speaker_codec;
> >  	}
> >  
> > +	headset_codec = of_get_child_by_name(pdev->dev.of_node,
> > "mediatek,headset-codec");
> > +	if (!headset_codec) {
> > +		ret = -EINVAL;
> > +		dev_err_probe(&pdev->dev, ret, "Property
> > 'headset_codec' missing or invalid\n");
> > +		goto err_headset_codec;
> > +	}
> 
> (to be neat) Does it have any reason to prevent from using
> of_parse_phandle()
> but of_get_child_by_name()?

Hi Tzung-Bi,

"mediatek,headset-codec" is a child node of pdev->dev.of_node, so I use
of_get_child_by_name() to get and   pass it to
snd_soc_of_get_dai_link_codecs().

Jiaxin.Yu
Thanks
Tzung-Bi Shih March 21, 2022, 9:21 a.m. UTC | #3
On Mon, Mar 21, 2022 at 05:14:08PM +0800, Jiaxin Yu wrote:
> On Mon, 2022-03-21 at 11:59 +0800, Tzung-Bi Shih wrote:
> > On Sat, Mar 19, 2022 at 07:41:10PM +0800, Jiaxin Yu wrote:
> > > @@ -1145,6 +1140,13 @@ static int mt8192_mt6359_dev_probe(struct
> > > platform_device *pdev)
> > >  		goto err_speaker_codec;
> > >  	}
> > >  
> > > +	headset_codec = of_get_child_by_name(pdev->dev.of_node,
> > > "mediatek,headset-codec");
> > > +	if (!headset_codec) {
> > > +		ret = -EINVAL;
> > > +		dev_err_probe(&pdev->dev, ret, "Property
> > > 'headset_codec' missing or invalid\n");
> > > +		goto err_headset_codec;
> > > +	}
> > 
> > (to be neat) Does it have any reason to prevent from using
> > of_parse_phandle()
> > but of_get_child_by_name()?
> 
> "mediatek,headset-codec" is a child node of pdev->dev.of_node, so I use
> of_get_child_by_name() to get and   pass it to
> snd_soc_of_get_dai_link_codecs().

"mediatek,platform" and "mediatek,hdmi-codec" are also children of
pdev->dev.of_node.  I guess my question is: why doesn't it also use
of_parse_phandle() for "mediatek,headset-codec"?  Did I misunderstand?
Jiaxin Yu March 21, 2022, 2:38 p.m. UTC | #4
On Mon, 2022-03-21 at 17:21 +0800, Tzung-Bi Shih wrote:
> On Mon, Mar 21, 2022 at 05:14:08PM +0800, Jiaxin Yu wrote:
> > On Mon, 2022-03-21 at 11:59 +0800, Tzung-Bi Shih wrote:
> > > On Sat, Mar 19, 2022 at 07:41:10PM +0800, Jiaxin Yu wrote:
> > > > @@ -1145,6 +1140,13 @@ static int
> > > > mt8192_mt6359_dev_probe(struct
> > > > platform_device *pdev)
> > > >  		goto err_speaker_codec;
> > > >  	}
> > > >  
> > > > +	headset_codec = of_get_child_by_name(pdev->dev.of_node,
> > > > "mediatek,headset-codec");
> > > > +	if (!headset_codec) {
> > > > +		ret = -EINVAL;
> > > > +		dev_err_probe(&pdev->dev, ret, "Property
> > > > 'headset_codec' missing or invalid\n");
> > > > +		goto err_headset_codec;
> > > > +	}
> > > 
> > > (to be neat) Does it have any reason to prevent from using
> > > of_parse_phandle()
> > > but of_get_child_by_name()?
> > 
> > "mediatek,headset-codec" is a child node of pdev->dev.of_node, so I
> > use
> > of_get_child_by_name() to get and   pass it to
> > snd_soc_of_get_dai_link_codecs().
> 
> "mediatek,platform" and "mediatek,hdmi-codec" are also children of
> pdev->dev.of_node.  I guess my question is: why doesn't it also use
> of_parse_phandle() for "mediatek,headset-codec"?  Did I
> misunderstand?
Hi Tzung-Bi,

The following is from bindings, "mediatek,speaker-codec" and
"mediatek,headset-codec" are sub nodes of sound but "mediatek,platform"
and "mediatek,hdmi-codec" are the name of properties. So we can't get
the sub node pointer through of_parse_phandle().

      sound: mt8192-sound {
          compatible = "mediatek,mt8192_mt6359_rt1015_rt5682";
          mediatek,platform = <&afe>;
          mediatek,hdmi-codec = <&anx_bridge_dp>;
          pinctrl-names = "aud_clk_mosi_off",
                          "aud_clk_mosi_on";
          pinctrl-0 = <&aud_clk_mosi_off>;
          pinctrl-1 = <&aud_clk_mosi_on>;
 
          mediatek,headset-codec {
              sound-dai = <&rt5682>;
          };
 
          mediatek,speaker-codec {
              sound-dai = <&rt1015_l>,
                          <&rt1015_r>;
          };
      };
Tzung-Bi Shih March 21, 2022, 3:23 p.m. UTC | #5
On Mon, Mar 21, 2022 at 10:38:48PM +0800, Jiaxin Yu wrote:
> On Mon, 2022-03-21 at 17:21 +0800, Tzung-Bi Shih wrote:
> > On Mon, Mar 21, 2022 at 05:14:08PM +0800, Jiaxin Yu wrote:
> > > On Mon, 2022-03-21 at 11:59 +0800, Tzung-Bi Shih wrote:
> > > > On Sat, Mar 19, 2022 at 07:41:10PM +0800, Jiaxin Yu wrote:
> > > > > @@ -1145,6 +1140,13 @@ static int
> > > > > mt8192_mt6359_dev_probe(struct
> > > > > platform_device *pdev)
> > > > >  		goto err_speaker_codec;
> > > > >  	}
> > > > >  
> > > > > +	headset_codec = of_get_child_by_name(pdev->dev.of_node,
> > > > > "mediatek,headset-codec");
> > > > > +	if (!headset_codec) {
> > > > > +		ret = -EINVAL;
> > > > > +		dev_err_probe(&pdev->dev, ret, "Property
> > > > > 'headset_codec' missing or invalid\n");
> > > > > +		goto err_headset_codec;
> > > > > +	}
> > > > 
> > > > (to be neat) Does it have any reason to prevent from using
> > > > of_parse_phandle()
> > > > but of_get_child_by_name()?
> > > 
> > > "mediatek,headset-codec" is a child node of pdev->dev.of_node, so I
> > > use
> > > of_get_child_by_name() to get and   pass it to
> > > snd_soc_of_get_dai_link_codecs().
> > 
> > "mediatek,platform" and "mediatek,hdmi-codec" are also children of
> > pdev->dev.of_node.  I guess my question is: why doesn't it also use
> > of_parse_phandle() for "mediatek,headset-codec"?  Did I
> > misunderstand?
> 
> The following is from bindings, "mediatek,speaker-codec" and
> "mediatek,headset-codec" are sub nodes of sound but "mediatek,platform"
> and "mediatek,hdmi-codec" are the name of properties. So we can't get
> the sub node pointer through of_parse_phandle().
> 
>       sound: mt8192-sound {
>           compatible = "mediatek,mt8192_mt6359_rt1015_rt5682";
>           mediatek,platform = <&afe>;
>           mediatek,hdmi-codec = <&anx_bridge_dp>;
>           pinctrl-names = "aud_clk_mosi_off",
>                           "aud_clk_mosi_on";
>           pinctrl-0 = <&aud_clk_mosi_off>;
>           pinctrl-1 = <&aud_clk_mosi_on>;
>  
>           mediatek,headset-codec {
>               sound-dai = <&rt5682>;
>           };
>  
>           mediatek,speaker-codec {
>               sound-dai = <&rt1015_l>,
>                           <&rt1015_r>;
>           };
>       };

Got it, thanks for the explanation.  Will provide my R-b tag in another
thread.
Tzung-Bi Shih March 21, 2022, 3:24 p.m. UTC | #6
On Sat, Mar 19, 2022 at 07:41:10PM +0800, Jiaxin Yu wrote:
> MT8192 platform use rt5682 codec, so through the snd_soc_of_get_dai_link_codes()
> to complete the configuration of I2S8/I2S9 dai_link's codecs.
> 
> Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
diff mbox series

Patch

diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index e42bbb5d7c35..d77f7c701513 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -28,9 +28,6 @@ 
 #define RT1015_DEV0_NAME	"rt1015.1-0028"
 #define RT1015_DEV1_NAME	"rt1015.1-0029"
 
-#define RT5682_CODEC_DAI	"rt5682-aif1"
-#define RT5682_DEV0_NAME	"rt5682.1-001a"
-
 struct mt8192_mt6359_priv {
 	struct snd_soc_jack headset_jack;
 	struct snd_soc_jack hdmi_jack;
@@ -626,14 +623,12 @@  SND_SOC_DAILINK_DEFS(i2s7,
 
 SND_SOC_DAILINK_DEFS(i2s8,
 		     DAILINK_COMP_ARRAY(COMP_CPU("I2S8")),
-		     DAILINK_COMP_ARRAY(COMP_CODEC(RT5682_DEV0_NAME,
-						   RT5682_CODEC_DAI)),
+		     DAILINK_COMP_ARRAY(COMP_EMPTY()),
 		     DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 SND_SOC_DAILINK_DEFS(i2s9,
 		     DAILINK_COMP_ARRAY(COMP_CPU("I2S9")),
-		     DAILINK_COMP_ARRAY(COMP_CODEC(RT5682_DEV0_NAME,
-						   RT5682_CODEC_DAI)),
+		     DAILINK_COMP_ARRAY(COMP_EMPTY()),
 		     DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 SND_SOC_DAILINK_DEFS(connsys_i2s,
@@ -1114,7 +1109,7 @@  static int mt8192_mt6359_card_set_be_link(struct snd_soc_card *card,
 static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card;
-	struct device_node *platform_node, *hdmi_codec, *speaker_codec;
+	struct device_node *platform_node, *hdmi_codec, *headset_codec, *speaker_codec;
 	int ret, i;
 	struct snd_soc_dai_link *dai_link;
 	struct mt8192_mt6359_priv *priv;
@@ -1145,6 +1140,13 @@  static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 		goto err_speaker_codec;
 	}
 
+	headset_codec = of_get_child_by_name(pdev->dev.of_node, "mediatek,headset-codec");
+	if (!headset_codec) {
+		ret = -EINVAL;
+		dev_err_probe(&pdev->dev, ret, "Property 'headset_codec' missing or invalid\n");
+		goto err_headset_codec;
+	}
+
 	for_each_card_prelinks(card, i, dai_link) {
 		ret = mt8192_mt6359_card_set_be_link(card, dai_link, speaker_codec, "I2S3");
 		if (ret) {
@@ -1153,6 +1155,20 @@  static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 			goto err_probe;
 		}
 
+		ret = mt8192_mt6359_card_set_be_link(card, dai_link, headset_codec, "I2S8");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n",
+				      dai_link->name);
+			goto err_probe;
+		}
+
+		ret = mt8192_mt6359_card_set_be_link(card, dai_link, headset_codec, "I2S9");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "%s set headset_codec fail\n",
+				      dai_link->name);
+			goto err_probe;
+		}
+
 		if (hdmi_codec && strcmp(dai_link->name, "TDM") == 0) {
 			dai_link->codecs->of_node = hdmi_codec;
 			dai_link->ignore = 0;
@@ -1183,6 +1199,8 @@  static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 		dev_err_probe(&pdev->dev, ret, "%s snd_soc_register_card fail\n", __func__);
 
 err_probe:
+	of_node_put(headset_codec);
+err_headset_codec:
 	of_node_put(speaker_codec);
 err_speaker_codec:
 	of_node_put(hdmi_codec);