alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio
@ 2021-01-20  8:08 Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 1/5] ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data Tzung-Bi Shih
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2021-01-20  8:08 UTC (permalink / raw)
  To: broonie, robh+dt; +Cc: tzungbi, alsa-devel, devicetree

The 1st and 2nd patches refactor the machine driver.

The 3rd patch changes the platform driver to support TDM 8 channel output.

The 4th patch adds an optional DT property.

The 5th patch makes the machine driver support DP audio if the optional DT
property is specified.

Tzung-Bi Shih (5):
  ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data
  ASoC: mediatek: mt8192-mt6359: simplify mt8192_rt5682_init
  ASoC: mediatek: mt8192: change mclk_multiple of TDM from 128 to 512
  ASoC: dt-bindings: mt8192-mt6359: add hdmi-codec property
  ASoC: mediatek: mt8192-mt6359: support audio over DP

 .../sound/mt8192-mt6359-rt1015-rt5682.yaml    |  5 ++
 sound/soc/mediatek/mt8192/mt8192-dai-tdm.c    |  2 +-
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 54 ++++++++++++++++---
 3 files changed, 52 insertions(+), 9 deletions(-)

-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data
  2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
@ 2021-01-20  8:08 ` Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 2/5] ASoC: mediatek: mt8192-mt6359: simplify mt8192_rt5682_init Tzung-Bi Shih
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2021-01-20  8:08 UTC (permalink / raw)
  To: broonie, robh+dt; +Cc: tzungbi, alsa-devel, devicetree

Moves headset_jack to card specific data.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c   | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index a988ce1e58de..72d337fc8534 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -31,7 +31,9 @@
 #define RT5682_CODEC_DAI	"rt5682-aif1"
 #define RT5682_DEV0_NAME	"rt5682.1-001a"
 
-static struct snd_soc_jack headset_jack;
+struct mt8192_mt6359_priv {
+	struct snd_soc_jack headset_jack;
+};
 
 static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream,
 				       struct snd_pcm_hw_params *params)
@@ -305,7 +307,8 @@ static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_component *cmpnt_codec =
 		asoc_rtd_to_codec(rtd, 0)->component;
-	struct snd_soc_jack *jack = &headset_jack;
+	struct mt8192_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	struct snd_soc_jack *jack = &priv->headset_jack;
 	int ret;
 
 	ret = snd_soc_card_jack_new(rtd->card, "Headset Jack",
@@ -1038,6 +1041,7 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 	int ret, i;
 	struct snd_soc_dai_link *dai_link;
 	const struct of_device_id *match;
+	struct mt8192_mt6359_priv *priv;
 
 	platform_node = of_parse_phandle(pdev->dev.of_node,
 					 "mediatek,platform", 0);
@@ -1083,6 +1087,11 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 			dai_link->platforms->of_node = platform_node;
 	}
 
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	snd_soc_card_set_drvdata(card, priv);
+
 	ret = mt8192_afe_gpio_init(&pdev->dev);
 	if (ret) {
 		dev_err(&pdev->dev, "init gpio error %d\n", ret);
-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] ASoC: mediatek: mt8192-mt6359: simplify mt8192_rt5682_init
  2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 1/5] ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data Tzung-Bi Shih
@ 2021-01-20  8:08 ` Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 3/5] ASoC: mediatek: mt8192: change mclk_multiple of TDM from 128 to 512 Tzung-Bi Shih
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2021-01-20  8:08 UTC (permalink / raw)
  To: broonie, robh+dt; +Cc: tzungbi, alsa-devel, devicetree

Returns snd_soc_component_set_jack() directly in mt8192_rt5682_init.
No need to have another block to check the return value.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index 72d337fc8534..8ea24b32a535 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -326,13 +326,7 @@ static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd)
 	snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP);
 	snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN);
 
-	ret = snd_soc_component_set_jack(cmpnt_codec, jack, NULL);
-	if (ret) {
-		dev_err(rtd->dev, "Headset Jack set failed: %d\n", ret);
-		return ret;
-	}
-
-	return 0;
+	return snd_soc_component_set_jack(cmpnt_codec, jack, NULL);
 };
 
 static int mt8192_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] ASoC: mediatek: mt8192: change mclk_multiple of TDM from 128 to 512
  2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 1/5] ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 2/5] ASoC: mediatek: mt8192-mt6359: simplify mt8192_rt5682_init Tzung-Bi Shih
@ 2021-01-20  8:08 ` Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 4/5] ASoC: dt-bindings: mt8192-mt6359: add hdmi-codec property Tzung-Bi Shih
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2021-01-20  8:08 UTC (permalink / raw)
  To: broonie, robh+dt; +Cc: tzungbi, alsa-devel, devicetree

mclk = rate * mclk_multiple
bclk = rate * channel * sample_width

If TDM outputs 8 channels and 32 bits, bclk will be greater than mclk.

Changes the ratio from 128 to 512.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 sound/soc/mediatek/mt8192/mt8192-dai-tdm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/mediatek/mt8192/mt8192-dai-tdm.c b/sound/soc/mediatek/mt8192/mt8192-dai-tdm.c
index 8383536b7ae0..f5de1d769679 100644
--- a/sound/soc/mediatek/mt8192/mt8192-dai-tdm.c
+++ b/sound/soc/mediatek/mt8192/mt8192-dai-tdm.c
@@ -738,7 +738,7 @@ static struct mtk_afe_tdm_priv *init_tdm_priv_data(struct mtk_base_afe *afe)
 	if (!tdm_priv)
 		return NULL;
 
-	tdm_priv->mclk_multiple = 128;
+	tdm_priv->mclk_multiple = 512;
 	tdm_priv->bck_id = MT8192_I2S4_BCK;
 	tdm_priv->mclk_id = MT8192_I2S4_MCK;
 	tdm_priv->id = MT8192_DAI_TDM;
-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] ASoC: dt-bindings: mt8192-mt6359: add hdmi-codec property
  2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
                   ` (2 preceding siblings ...)
  2021-01-20  8:08 ` [PATCH 3/5] ASoC: mediatek: mt8192: change mclk_multiple of TDM from 128 to 512 Tzung-Bi Shih
@ 2021-01-20  8:08 ` Tzung-Bi Shih
  2021-01-20  8:08 ` [PATCH 5/5] ASoC: mediatek: mt8192-mt6359: support audio over DP Tzung-Bi Shih
  2021-01-21  0:05 ` [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2021-01-20  8:08 UTC (permalink / raw)
  To: broonie, robh+dt; +Cc: tzungbi, alsa-devel, devicetree

Adds optional property "hdmi-codec".

If specified, the machine driver should:
- Exposes a device that can write audio data to the DP bridge.
- Detects jack plug events.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml          | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml b/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml
index 54650823b29a..5a5b765b859a 100644
--- a/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml
+++ b/Documentation/devicetree/bindings/sound/mt8192-mt6359-rt1015-rt5682.yaml
@@ -23,6 +23,10 @@ properties:
     $ref: "/schemas/types.yaml#/definitions/phandle"
     description: The phandle of MT8192 ASoC platform.
 
+  mediatek,hdmi-codec:
+    $ref: "/schemas/types.yaml#/definitions/phandle"
+    description: The phandle of HDMI codec.
+
 additionalProperties: false
 
 required:
@@ -35,6 +39,7 @@ examples:
     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>;
-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] ASoC: mediatek: mt8192-mt6359: support audio over DP
  2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
                   ` (3 preceding siblings ...)
  2021-01-20  8:08 ` [PATCH 4/5] ASoC: dt-bindings: mt8192-mt6359: add hdmi-codec property Tzung-Bi Shih
@ 2021-01-20  8:08 ` Tzung-Bi Shih
  2021-01-21  0:05 ` [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Tzung-Bi Shih @ 2021-01-20  8:08 UTC (permalink / raw)
  To: broonie, robh+dt; +Cc: tzungbi, alsa-devel, devicetree

If the DTS property is specified, the DP bridge should populate a
"hdmi-codec" platform device (sound/soc/codecs/hdmi-codec.c).

The "hdmi-codec" device is the communication relayer between the ASoC
machine driver and the DP bridge.  For example:
- Notifies DP bridge when setting hw_param.
- Notifies ASoC when jack detection events.

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../mt8192/mt8192-mt6359-rt1015-rt5682.c      | 39 ++++++++++++++++++-
 1 file changed, 37 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
index 8ea24b32a535..cc0fc72305d2 100644
--- a/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
+++ b/sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c
@@ -33,6 +33,7 @@
 
 struct mt8192_mt6359_priv {
 	struct snd_soc_jack headset_jack;
+	struct snd_soc_jack hdmi_jack;
 };
 
 static int mt8192_rt1015_i2s_hw_params(struct snd_pcm_substream *substream,
@@ -329,6 +330,23 @@ static int mt8192_rt5682_init(struct snd_soc_pcm_runtime *rtd)
 	return snd_soc_component_set_jack(cmpnt_codec, jack, NULL);
 };
 
+static int mt8192_mt6359_hdmi_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct snd_soc_component *cmpnt_codec =
+		asoc_rtd_to_codec(rtd, 0)->component;
+	struct mt8192_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card);
+	int ret;
+
+	ret = snd_soc_card_jack_new(rtd->card, "HDMI Jack", SND_JACK_LINEOUT,
+				    &priv->hdmi_jack, NULL, 0);
+	if (ret) {
+		dev_err(rtd->dev, "HDMI Jack creation failed: %d\n", ret);
+		return ret;
+	}
+
+	return snd_soc_component_set_jack(cmpnt_codec, &priv->hdmi_jack, NULL);
+}
+
 static int mt8192_i2s_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
 				      struct snd_pcm_hw_params *params)
 {
@@ -600,7 +618,7 @@ SND_SOC_DAILINK_DEFS(pcm2,
 
 SND_SOC_DAILINK_DEFS(tdm,
 		     DAILINK_COMP_ARRAY(COMP_CPU("TDM")),
-		     DAILINK_COMP_ARRAY(COMP_DUMMY()),
+		     DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "i2s-hifi")),
 		     DAILINK_COMP_ARRAY(COMP_EMPTY()));
 
 static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = {
@@ -936,8 +954,14 @@ static struct snd_soc_dai_link mt8192_mt6359_dai_links[] = {
 	{
 		.name = "TDM",
 		.no_pcm = 1,
+		.dai_fmt = SND_SOC_DAIFMT_DSP_A |
+			   SND_SOC_DAIFMT_IB_NF |
+			   SND_SOC_DAIFMT_CBM_CFM,
 		.dpcm_playback = 1,
 		.ignore_suspend = 1,
+		.be_hw_params_fixup = mt8192_i2s_hw_params_fixup,
+		.ignore = 1,
+		.init = mt8192_mt6359_hdmi_init,
 		SND_SOC_DAILINK_REG(tdm),
 	},
 };
@@ -948,6 +972,7 @@ mt8192_mt6359_rt1015_rt5682_widgets[] = {
 	SND_SOC_DAPM_SPK("Right Spk", NULL),
 	SND_SOC_DAPM_HP("Headphone Jack", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+	SND_SOC_DAPM_OUTPUT("TDM Out"),
 };
 
 static const struct snd_soc_dapm_route mt8192_mt6359_rt1015_rt5682_routes[] = {
@@ -958,6 +983,8 @@ static const struct snd_soc_dapm_route mt8192_mt6359_rt1015_rt5682_routes[] = {
 	{ "Headphone Jack", NULL, "HPOL" },
 	{ "Headphone Jack", NULL, "HPOR" },
 	{ "IN1P", NULL, "Headset Mic" },
+	/* TDM */
+	{ "TDM Out", NULL, "TDM" },
 };
 
 static const struct snd_kcontrol_new mt8192_mt6359_rt1015_rt5682_controls[] = {
@@ -1031,7 +1058,7 @@ static struct snd_soc_card mt8192_mt6359_rt1015p_rt5682_card = {
 static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 {
 	struct snd_soc_card *card;
-	struct device_node *platform_node;
+	struct device_node *platform_node, *hdmi_codec;
 	int ret, i;
 	struct snd_soc_dai_link *dai_link;
 	const struct of_device_id *match;
@@ -1051,6 +1078,9 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 	card = (struct snd_soc_card *)match->data;
 	card->dev = &pdev->dev;
 
+	hdmi_codec = of_parse_phandle(pdev->dev.of_node,
+				      "mediatek,hdmi-codec", 0);
+
 	for_each_card_prelinks(card, i, dai_link) {
 		if (strcmp(dai_link->name, "I2S3") == 0) {
 			if (card == &mt8192_mt6359_rt1015_rt5682_card) {
@@ -1077,6 +1107,11 @@ static int mt8192_mt6359_dev_probe(struct platform_device *pdev)
 			}
 		}
 
+		if (hdmi_codec && strcmp(dai_link->name, "TDM") == 0) {
+			dai_link->codecs->of_node = hdmi_codec;
+			dai_link->ignore = 0;
+		}
+
 		if (!dai_link->platforms->name)
 			dai_link->platforms->of_node = platform_node;
 	}
-- 
2.30.0.284.gd98b1dd5eaa7-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio
  2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
                   ` (4 preceding siblings ...)
  2021-01-20  8:08 ` [PATCH 5/5] ASoC: mediatek: mt8192-mt6359: support audio over DP Tzung-Bi Shih
@ 2021-01-21  0:05 ` Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2021-01-21  0:05 UTC (permalink / raw)
  To: robh+dt, Tzung-Bi Shih; +Cc: devicetree, alsa-devel

On Wed, 20 Jan 2021 16:08:45 +0800, Tzung-Bi Shih wrote:
> The 1st and 2nd patches refactor the machine driver.
> 
> The 3rd patch changes the platform driver to support TDM 8 channel output.
> 
> The 4th patch adds an optional DT property.
> 
> The 5th patch makes the machine driver support DP audio if the optional DT
> property is specified.
> 
> [...]

Applied to

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

Thanks!

[1/5] ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data
      commit: 4e37528a97bfffb2cd4f645c945759e76d583848
[2/5] ASoC: mediatek: mt8192-mt6359: simplify mt8192_rt5682_init
      commit: 12295ef97078db19683d8c0a23abc6f633ef0e23
[3/5] ASoC: mediatek: mt8192: change mclk_multiple of TDM from 128 to 512
      commit: df369921d726410a093de48d33e605fd4e0ee33c
[4/5] ASoC: dt-bindings: mt8192-mt6359: add hdmi-codec property
      commit: 9bc20e8076c96a54c9fb20228d12ff35c88447d5
[5/5] ASoC: mediatek: mt8192-mt6359: support audio over DP
      commit: 0d80c48c847842de488e76ae434ccb74397623c3

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-01-21  0:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  8:08 [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Tzung-Bi Shih
2021-01-20  8:08 ` [PATCH 1/5] ASoC: mediatek: mt8192-mt6359: move headset_jack to card specific data Tzung-Bi Shih
2021-01-20  8:08 ` [PATCH 2/5] ASoC: mediatek: mt8192-mt6359: simplify mt8192_rt5682_init Tzung-Bi Shih
2021-01-20  8:08 ` [PATCH 3/5] ASoC: mediatek: mt8192: change mclk_multiple of TDM from 128 to 512 Tzung-Bi Shih
2021-01-20  8:08 ` [PATCH 4/5] ASoC: dt-bindings: mt8192-mt6359: add hdmi-codec property Tzung-Bi Shih
2021-01-20  8:08 ` [PATCH 5/5] ASoC: mediatek: mt8192-mt6359: support audio over DP Tzung-Bi Shih
2021-01-21  0:05 ` [PATCH 0/5] ASoC: mediatek: mt8192-mt6359: support DP audio Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).