Skip to contentSkip to conversation

ASoC: mediatek: mt8192: support rt1015p_rt5682s

PATCH Superseded Jiaxin Yu 2 participants 4 messages Mar 11, 2022 – Mar 14, 2022

Subsystems (4)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore

Jiaxin Yu

author
#0 lore raw

v4 cover ASoC: mediatek: mt8192: support rt1015p_rt5682s

The series reuses mt8192-mt6359-rt10150rt5682.c for supporting machine driver with rt1015p speaker amplifier and rt5682s headset codec.

Changes from v3:
- fix build error: too many arguments for format [-Werror-format-extra-args]

Changes from v2:
- fix build warnings such as "data argument not used by format string"

Changes from v1:
- uses the snd_soc_of_get_dai_link_codecs to complete the configuration of dai_link's codecs
- uses definitions to simplifies card name and compatible name

Jiaxin Yu (2):
ASoC: dt-bindings: mt8192-mt6359: add new compatible for using rt1015p

    and rt5682

ASoC: mediatek: mt8192: support rt1015p_rt5682s

 .../sound/mt8192-mt6359-rt1015-rt5682.yaml    |   1 +
 sound/soc/mediatek/Kconfig                    |   1 +
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 204 +++++++++++-------
 3 files changed, 129 insertions(+), 77 deletions(-)
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v4 1/2 ASoC: dt-bindings: mt8192-mt6359: add new compatible for using rt1015p and rt5682

Adds new compatible string "mt8192_mt6359_rt1015p_rt5682s" for machines with rt1015p and rt5682s.

---
 .../devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml   | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml +1 -0
index 5a5b765b859a..7a4800b9033c 100644
@@ -18,6 +18,7 @@ properties:
     enum:
       - mediatek,mt8192_mt6359_rt1015_rt5682
       - mediatek,mt8192_mt6359_rt1015p_rt5682
+      - mediatek,mt8192_mt6359_rt1015p_rt5682s
 
   mediatek,platform:
     $ref: "/schemas/types.yaml#/definitions/phandle"
Signature · 1 line
2.18.0
author
#2 lore raw

PATCH v4 2/2 ASoC: mediatek: mt8192: support rt1015p_rt5682s

In reply to Jiaxin Yu

Supports machines with rt1015p and rt5682s. Uses new proposed compatible string "mt8192_mt6359_rt1015p_rt5682s". Using define to simplifies card name and compatible name, and uses the snd_soc_of_get_dai_link_codecs() to complete the configuration of dai_link's codecs.

---
 sound/soc/mediatek/Kconfig                    |   1 +
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 204 +++++++++++-------
 2 files changed, 128 insertions(+), 77 deletions(-)
sound/soc/mediatek/Kconfig +1 -0
index 0d154350f180..bb774dfe867f 100644
@@ -179,6 +179,7 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682
 	select SND_SOC_RT1015
 	select SND_SOC_RT1015P
 	select SND_SOC_RT5682_I2C
+	select SND_SOC_RT5682S
 	select SND_SOC_DMIC
 	help
 	  This adds ASoC driver for Mediatek MT8192 boards
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +127 -77

336 lines not on this page · raw message

Signature · 1 line
2.18.0
#3 lore raw
Quoted 4 lines · Jiaxin Yu

Supports machines with rt1015p and rt5682s. Uses new proposed compatible string "mt8192_mt6359_rt1015p_rt5682s". Using define to simplifies card name and compatible name, and uses the snd_soc_of_get_dai_link_codecs() to complete the configuration of dai_link's codecs.

Rephrase the paragraph and consider to use imperative mood as [1] suggests.

[1]: https://www.kernel.org/doc/html/latest/process/submitting-patches.html#describe-your-changes

The patch includes multiple changes. Could you further separate it into:
1. Refactor for I2S3 DAI links for original amps.
2. Refactor for I2S8 and I2S9 DAI links for original headset codec RT5682.
3. Support mt8192_mt6359_rt1015p_rt5682s for RT5682S.

Quoted 1 line

The tag can be dropped as "Supports machines with rt1015p and rt5682s" is not an idea from the bot. Put it in change logs if you would like it to be a record.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { · line 1108

Quoted 11 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +11 -0
+static int mt8192_mt6359_card_set_be_link(struct snd_soc_card *card,
+					  struct snd_soc_dai_link *link,
+					  struct device_node *node,
+					  char *link_name)
+{
+	int ret;
+
+	if (node && strcmp(link->name, link_name) == 0) {
+		ret = snd_soc_of_get_dai_link_codecs(card->dev, node, link);
+		if (ret < 0) {
+			dev_err(card->dev, "get dai link codecs fail\n");

How about using dev_err_probe()? As the callers also report errors if mt8192_mt6359_card_set_be_link() fails, the log can be dropped.

Quoted 9 lines

static int mt8192_mt6359_dev_probe(struct platform_device *pdev) {

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +2 -1
 	struct snd_soc_card *card;
-	struct device_node *platform_node, *hdmi_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;
+	struct device *dev;

[...]

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { · line 1129

Quoted 1 line
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +1 -0
+	dev = &pdev->dev;

I don't think it could help too much unless it was struggling for code columns. Please consider to drop the variable or you should s/&pdev->dev/dev/g for the function.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { · line 1164

Quoted 13 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +13 -0
+	speaker_codec = of_get_child_by_name(dev->of_node, "mediatek,speaker-codec");
+	if (!speaker_codec) {
+		ret = -EINVAL;
+		dev_err_probe(dev, ret, "Property 'speaker_codec' missing or invalid\n");
+		goto err_speaker_codec;
+	}
+
+	headset_codec = of_get_child_by_name(dev->of_node, "mediatek,headset-codec");
+	if (!headset_codec) {
+		ret = -EINVAL;
+		dev_err_probe(dev, ret, "Property 'headset_codec' missing or invalid\n");
+		goto err_headset_codec;
+	}

Are these new DT bindings? They are not in Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { · line 1169

Quoted 3 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +3 -0
+		ret = mt8192_mt6359_card_set_be_link(card, dai_link, speaker_codec, "I2S3");
+		if (ret) {
+			dev_err_probe(&pdev->dev, ret, "%s set speaker_codec fail\n",

As mentioned above, I don't think dev could help too much. However, to be consistent, either drop the dev variable or use dev here.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { · line 1177

Quoted 4 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +4 -0
+		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);

Ditto.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static const struct snd_soc_dapm_route mt8192_mt6359_rt1015p_rt5682_routes[] = { · line 1184

Quoted 4 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +4 -0
+		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);

Ditto.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static int mt8192_mt6359_dev_probe(struct platform_device *pdev) · line 1209

Quoted 5 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +1 -2
 	ret = mt8192_afe_gpio_init(&pdev->dev);
 	if (ret) {
-		dev_err(&pdev->dev, "init gpio error %d\n", ret);
-		goto put_hdmi_codec;
+		dev_err_probe(&pdev->dev, ret, "%s init gpio error\n", __func__);

Ditto.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static int mt8192_mt6359_dev_probe(struct platform_device *pdev) · line 1215

Quoted 5 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +2 -2
 	ret = devm_snd_soc_register_card(&pdev->dev, card);
-
-put_hdmi_codec:
+	if (ret)
+		dev_err_probe(&pdev->dev, ret,

Ditto.

sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c static int mt8192_mt6359_dev_probe(struct platform_device *pdev) · line 1227

Quoted 11 lines
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +8 -1
+err_probe:
+	of_node_put(headset_codec);
+err_headset_codec:
+	of_node_put(speaker_codec);
+err_speaker_codec:
 	of_node_put(hdmi_codec);
-put_platform_node:
+err_hdmi_codec:
 	of_node_put(platform_node);
+err_platform_node:
+

The new line can be dropped.

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek