dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [v3 0/3] ASoC: mediatek:mt8186: fix both the speaker and hdmi
@ 2023-07-30 18:08 Jiaxin Yu
  2023-07-30 18:08 ` [v3 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX Jiaxin Yu
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Jiaxin Yu @ 2023-07-30 18:08 UTC (permalink / raw)
  To: broonie, andrzej.hajda, neil.armstrong, robert.foss,
	Laurent.pinchart, kuninori.morimoto.gx,
	angelogioacchino.delregno, nfraprado
  Cc: alsa-devel, chunxu.li, allen-kh.cheng, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek, Jiaxin Yu,
	ajye_huang, linux-arm-kernel

The speaker and hdmi of mt8186 platform are shared the same port of I2S,
when connect the external display, use build-in speakers to play audio,
they both playback at the same time. So we want to manage the playback
device through DAPM events.

Jiaxin Yu (3):
  ASoC: hdmi-codec: Add event handler for hdmi TX
  ASoC: mediatek: mt8186: correct the HDMI widgets
  drm/bridge: it6505: Add audio support

 drivers/gpu/drm/bridge/ite-it6505.c           | 81 +++++++++++++++++--
 include/sound/hdmi-codec.h                    |  6 ++
 sound/soc/codecs/hdmi-codec.c                 | 32 +++++++-
 .../mt8186/mt8186-mt6366-da7219-max98357.c    |  2 +-
 .../mt8186/mt8186-mt6366-rt1019-rt5682s.c     |  2 +-
 5 files changed, 113 insertions(+), 10 deletions(-)

-- 
2.25.1


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

* [v3 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX
  2023-07-30 18:08 [v3 0/3] ASoC: mediatek:mt8186: fix both the speaker and hdmi Jiaxin Yu
@ 2023-07-30 18:08 ` Jiaxin Yu
  2023-07-30 18:08 ` [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets Jiaxin Yu
  2023-07-30 18:08 ` [v3 3/3] drm/bridge: it6505: Add audio support Jiaxin Yu
  2 siblings, 0 replies; 14+ messages in thread
From: Jiaxin Yu @ 2023-07-30 18:08 UTC (permalink / raw)
  To: broonie, andrzej.hajda, neil.armstrong, robert.foss,
	Laurent.pinchart, kuninori.morimoto.gx,
	angelogioacchino.delregno, nfraprado
  Cc: alsa-devel, chunxu.li, allen-kh.cheng, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek, Jiaxin Yu,
	ajye_huang, linux-arm-kernel

If the speaker and hdmi are connect to the same port of I2S,
when try to switch to speaker playback, we will find that hdmi
is always turned on automatically. The connection as follows:

			==> hdmi-codec ==> it6505(HDMI output)
DL1(FE) ==> I2S3(BE)
			==> rt1015p(SPEAKER output)

So in order to separately control their power on/off, we have
added a dapm widget to notify each output. Also the machine driver
need add a _PIN_SWITCH() on the output of the device that will
cause DAPM to keep the device powered down when not in use.

The purpose of adding .trigger callback here is to enable hdmi-codec
to notify the dp output driver to power on or off device.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
---
 include/sound/hdmi-codec.h    |  6 ++++++
 sound/soc/codecs/hdmi-codec.c | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h
index 9b162ac1e08e..ea834a838754 100644
--- a/include/sound/hdmi-codec.h
+++ b/include/sound/hdmi-codec.h
@@ -81,6 +81,12 @@ struct hdmi_codec_ops {
 		       struct hdmi_codec_daifmt *fmt,
 		       struct hdmi_codec_params *hparms);
 
+	/*
+	 * PCM trigger callback.
+	 * Optional
+	 */
+	int (*trigger)(struct device *dev, int cmd);
+
 	/*
 	 * Shuts down the audio stream.
 	 * Mandatory
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index d21f69f05342..6766b55c9b56 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -276,7 +276,31 @@ struct hdmi_codec_priv {
 	u8 iec_status[AES_IEC958_STATUS_SIZE];
 };
 
+static int hdmi_tx_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+	struct hdmi_codec_priv *hcp = snd_soc_component_get_drvdata(component);
+
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		if (hcp->hcd.ops->trigger)
+			hcp->hcd.ops->trigger(component->dev->parent, SNDRV_PCM_TRIGGER_START);
+		break;
+	case SND_SOC_DAPM_POST_PMD:
+		if (hcp->hcd.ops->trigger)
+			hcp->hcd.ops->trigger(component->dev->parent, SNDRV_PCM_TRIGGER_STOP);
+		break;
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static const struct snd_soc_dapm_widget hdmi_widgets[] = {
+	SND_SOC_DAPM_OUT_DRV_E("SDB", SND_SOC_NOPM, 0, 0, NULL, 0, hdmi_tx_event,
+			       SND_SOC_DAPM_POST_PMD | SND_SOC_DAPM_PRE_PMU),
 	SND_SOC_DAPM_OUTPUT("TX"),
 	SND_SOC_DAPM_OUTPUT("RX"),
 };
@@ -831,9 +855,13 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai)
 	struct hdmi_codec_daifmt *daifmt;
 	struct snd_soc_dapm_route route[] = {
 		{
-			.sink = "TX",
+			.sink = "SDB",
 			.source = dai->driver->playback.stream_name,
 		},
+		{
+			.sink = "TX",
+			.source = "SDB",
+		},
 		{
 			.sink = dai->driver->capture.stream_name,
 			.source = "RX",
@@ -848,7 +876,7 @@ static int hdmi_dai_probe(struct snd_soc_dai *dai)
 		if (!route[i].source || !route[i].sink)
 			continue;
 
-		ret = snd_soc_dapm_add_routes(dapm, &route[i], 1);
+		ret = snd_soc_dapm_add_routes(dapm, route, ARRAY_SIZE(route));
 		if (ret)
 			return ret;
 	}
-- 
2.25.1


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

* [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-07-30 18:08 [v3 0/3] ASoC: mediatek:mt8186: fix both the speaker and hdmi Jiaxin Yu
  2023-07-30 18:08 ` [v3 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX Jiaxin Yu
@ 2023-07-30 18:08 ` Jiaxin Yu
  2023-07-31 11:50   ` Mark Brown
  2023-07-30 18:08 ` [v3 3/3] drm/bridge: it6505: Add audio support Jiaxin Yu
  2 siblings, 1 reply; 14+ messages in thread
From: Jiaxin Yu @ 2023-07-30 18:08 UTC (permalink / raw)
  To: broonie, andrzej.hajda, neil.armstrong, robert.foss,
	Laurent.pinchart, kuninori.morimoto.gx,
	angelogioacchino.delregno, nfraprado
  Cc: alsa-devel, chunxu.li, allen-kh.cheng, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek, Jiaxin Yu,
	ajye_huang, linux-arm-kernel

Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger
DAPM events to hdmi-codec when userspace control the DPAM pin.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
---
 sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c | 2 +-
 sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
index 0432f9d89020..ae51d70e2c0b 100644
--- a/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
+++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
@@ -964,7 +964,7 @@ mt8186_mt6366_da7219_max98357_widgets[] = {
 	SND_SOC_DAPM_SPK("Speakers", NULL),
 	SND_SOC_DAPM_HP("Headphones", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
-	SND_SOC_DAPM_OUTPUT("HDMI1"),
+	SND_SOC_DAPM_LINE("HDMI1", NULL),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER(SOF_DMA_UL1, SND_SOC_NOPM, 0, 0, NULL, 0),
diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
index 9c11016f032c..a39e37fa4e02 100644
--- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
+++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c
@@ -1032,7 +1032,7 @@ mt8186_mt6366_rt1019_rt5682s_widgets[] = {
 	SND_SOC_DAPM_SPK("Speakers", NULL),
 	SND_SOC_DAPM_HP("Headphone", NULL),
 	SND_SOC_DAPM_MIC("Headset Mic", NULL),
-	SND_SOC_DAPM_OUTPUT("HDMI1"),
+	SND_SOC_DAPM_LINE("HDMI1", NULL),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL1, SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0),
 	SND_SOC_DAPM_MIXER(SOF_DMA_UL1, SND_SOC_NOPM, 0, 0, NULL, 0),
-- 
2.25.1


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

* [v3 3/3] drm/bridge: it6505: Add audio support
  2023-07-30 18:08 [v3 0/3] ASoC: mediatek:mt8186: fix both the speaker and hdmi Jiaxin Yu
  2023-07-30 18:08 ` [v3 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX Jiaxin Yu
  2023-07-30 18:08 ` [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets Jiaxin Yu
@ 2023-07-30 18:08 ` Jiaxin Yu
  2023-11-21 12:54   ` AngeloGioacchino Del Regno
  2 siblings, 1 reply; 14+ messages in thread
From: Jiaxin Yu @ 2023-07-30 18:08 UTC (permalink / raw)
  To: broonie, andrzej.hajda, neil.armstrong, robert.foss,
	Laurent.pinchart, kuninori.morimoto.gx,
	angelogioacchino.delregno, nfraprado
  Cc: alsa-devel, chunxu.li, allen-kh.cheng, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek, Jiaxin Yu,
	ajye_huang, linux-arm-kernel

Add audio support for it6505

1. Bridge to hdmi-codec to support audio feature. At the same time,
   the function of automatically detecting audio is removed.
2. It is observed that some DP-to-HDMI dongles will get into bad
   states if sending InfoFrame without audio data. Defer to enable
   it6505's audio feature when PCM triggers START or RESUME.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
---
 drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++---
 1 file changed, 75 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
index 504d51c42f79..1cfcb0731288 100644
--- a/drivers/gpu/drm/bridge/ite-it6505.c
+++ b/drivers/gpu/drm/bridge/ite-it6505.c
@@ -2162,7 +2162,6 @@ static void it6505_stop_link_train(struct it6505 *it6505)
 
 static void it6505_link_train_ok(struct it6505 *it6505)
 {
-	struct device *dev = &it6505->client->dev;
 
 	it6505->link_state = LINK_OK;
 	/* disalbe mute enable avi info frame */
@@ -2170,11 +2169,6 @@ static void it6505_link_train_ok(struct it6505 *it6505)
 	it6505_set_bits(it6505, REG_INFOFRAME_CTRL,
 			EN_VID_CTRL_PKT, EN_VID_CTRL_PKT);
 
-	if (it6505_audio_input(it6505)) {
-		DRM_DEV_DEBUG_DRIVER(dev, "Enable audio!");
-		it6505_enable_audio(it6505);
-	}
-
 	if (it6505->hdcp_desired)
 		it6505_start_hdcp(it6505);
 }
@@ -2846,6 +2840,45 @@ static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data)
 		it6505_disable_audio(it6505);
 }
 
+static int it6505_audio_hw_params(struct device *dev, void *data,
+				  struct hdmi_codec_daifmt *daifmt,
+				  struct hdmi_codec_params *params)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	return it6505_audio_setup_hw_params(it6505, params);
+}
+
+static int it6505_audio_setup_trigger(struct it6505 *it6505, int cmd)
+{
+	struct device *dev = &it6505->client->dev;
+
+	DRM_DEV_DEBUG_DRIVER(dev, "event: %d", cmd);
+
+	switch (cmd) {
+	case SNDRV_PCM_TRIGGER_START:
+	case SNDRV_PCM_TRIGGER_RESUME:
+		queue_delayed_work(system_wq, &it6505->delayed_audio,
+				   msecs_to_jiffies(180));
+		break;
+	case SNDRV_PCM_TRIGGER_STOP:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
+		cancel_delayed_work(&it6505->delayed_audio);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int it6505_audio_trigger(struct device *dev, int cmd)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+
+	return it6505_audio_setup_trigger(it6505, cmd);
+}
+
 static int __maybe_unused it6505_audio_hook_plugged_cb(struct device *dev,
 						       void *data,
 						       hdmi_codec_plugged_cb fn,
@@ -2860,6 +2893,36 @@ static int __maybe_unused it6505_audio_hook_plugged_cb(struct device *dev,
 	return 0;
 }
 
+static const struct hdmi_codec_ops it6505_audio_codec_ops = {
+	.hw_params = it6505_audio_hw_params,
+	.trigger = it6505_audio_trigger,
+	.audio_shutdown = it6505_audio_shutdown,
+	.hook_plugged_cb = it6505_audio_hook_plugged_cb,
+};
+
+static int it6505_register_audio_driver(struct device *dev)
+{
+	struct it6505 *it6505 = dev_get_drvdata(dev);
+	struct hdmi_codec_pdata codec_data = {
+		.ops = &it6505_audio_codec_ops,
+		.max_i2s_channels = 8,
+		.i2s = 1,
+		.data = it6505,
+	};
+	struct platform_device *pdev;
+
+	pdev = platform_device_register_data(dev, HDMI_CODEC_DRV_NAME,
+					     PLATFORM_DEVID_AUTO, &codec_data,
+					     sizeof(codec_data));
+	if (IS_ERR(pdev))
+		return PTR_ERR(pdev);
+
+	INIT_DELAYED_WORK(&it6505->delayed_audio, it6505_delayed_audio);
+	DRM_DEV_DEBUG_DRIVER(dev, "bound to %s", HDMI_CODEC_DRV_NAME);
+
+	return 0;
+}
+
 static inline struct it6505 *bridge_to_it6505(struct drm_bridge *bridge)
 {
 	return container_of(bridge, struct it6505, bridge);
@@ -3421,6 +3484,12 @@ static int it6505_i2c_probe(struct i2c_client *client)
 		return err;
 	}
 
+	err = it6505_register_audio_driver(dev);
+	if (err < 0) {
+		DRM_DEV_ERROR(dev, "Failed to register audio driver: %d", err);
+		return err;
+	}
+
 	INIT_WORK(&it6505->link_works, it6505_link_training_work);
 	INIT_WORK(&it6505->hdcp_wait_ksv_list, it6505_hdcp_wait_ksv_list);
 	INIT_DELAYED_WORK(&it6505->hdcp_work, it6505_hdcp_work);
-- 
2.25.1


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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-07-30 18:08 ` [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets Jiaxin Yu
@ 2023-07-31 11:50   ` Mark Brown
  2023-08-02 14:52     ` Jiaxin Yu (俞家鑫)
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2023-07-31 11:50 UTC (permalink / raw)
  To: Jiaxin Yu
  Cc: neil.armstrong, alsa-devel, chunxu.li, nfraprado,
	kuninori.morimoto.gx, dri-devel, linux-kernel, robert.foss,
	Project_Global_Chrome_Upstream_Group, linux-mediatek,
	Laurent.pinchart, andrzej.hajda, allen-kh.cheng, ajye_huang,
	linux-arm-kernel, angelogioacchino.delregno

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

On Mon, Jul 31, 2023 at 02:08:02AM +0800, Jiaxin Yu wrote:

> Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger
> DAPM events to hdmi-codec when userspace control the DPAM pin.

Why?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-07-31 11:50   ` Mark Brown
@ 2023-08-02 14:52     ` Jiaxin Yu (俞家鑫)
  2023-08-02 16:38       ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: Jiaxin Yu (俞家鑫) @ 2023-08-02 14:52 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, neil.armstrong, nfraprado,
	Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek,
	robert.foss, andrzej.hajda, angelogioacchino.delregno,
	ajye_huang, linux-arm-kernel, Laurent.pinchart

[-- Attachment #1: Type: text/html, Size: 5723 bytes --]

[-- Attachment #2: Type: text/plain, Size: 2113 bytes --]

On Mon, 2023-07-31 at 12:50 +0100, Mark Brown wrote:
> On Mon, Jul 31, 2023 at 02:08:02AM +0800, Jiaxin Yu wrote:
> 
> > Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger
> > DAPM events to hdmi-codec when userspace control the DPAM pin.
> 
> Why?

I have defined an SOC_DAPM_PIN_SWITCH that named as "HDMI1", if I use
SND_SOC_DAPM_OUTPUT, it can't be controlled by HDMI1's PIN_SWITCH.

 994 static const struct snd_kcontrol_new
 995 mt8186_mt6366_da7219_max98357_controls[] = {
 996         SOC_DAPM_PIN_SWITCH("Speakers"),
 997         SOC_DAPM_PIN_SWITCH("Headphones"),
 998         SOC_DAPM_PIN_SWITCH("Headset Mic"),
 999         SOC_DAPM_PIN_SWITCH("HDMI1"),

I think SND_SOC_DAPM_OUTPUT must be judged as ep, so I want to define
HDMI1 as a snd_soc_dapm_spk's widget.
From the perspective of hardware connection, their relationship is
indeed equal, so I find SOC_SOC_DAPM_LINE to define HDMI1.


                       ==> hdmi-codec ==> it6505(HDMI output)
DL1(FE) ==> I2S3(BE)
                       ==> rt1015p(SPEAKER output)

2738 static void dapm_update_widget_flags(struct snd_soc_dapm_widget
*w)
2739 {
2740         enum snd_soc_dapm_direction dir;
2741         struct snd_soc_dapm_path *p;
2742         unsigned int ep;
2743         ...
2760         case snd_soc_dapm_output:
2761                 /* On a fully routed card a output is never a sink
*/
2762                 if (w->dapm->card->fully_routed)
2763                         return;
2764                 ep = SND_SOC_DAPM_EP_SINK;
2765                 snd_soc_dapm_widget_for_each_sink_path(w, p) {
2766                         if (p->sink->id == snd_soc_dapm_spk ||
2767                                 p->sink->id == snd_soc_dapm_hp ||
2768                                 p->sink->id == snd_soc_dapm_line
||
2769                                 p->sink->id == snd_soc_dapm_input)
{
2770                                         ep = 0;
2771                                         break;
2772                         }
2773                 }
2774                 break;

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-08-02 14:52     ` Jiaxin Yu (俞家鑫)
@ 2023-08-02 16:38       ` Mark Brown
  2023-08-03  7:20         ` Jiaxin Yu (俞家鑫)
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2023-08-02 16:38 UTC (permalink / raw)
  To: Jiaxin Yu (俞家鑫)
  Cc: alsa-devel, neil.armstrong, nfraprado,
	Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek,
	robert.foss, andrzej.hajda, angelogioacchino.delregno,
	ajye_huang, linux-arm-kernel, Laurent.pinchart

[-- Attachment #1: Type: text/plain, Size: 1346 bytes --]

On Wed, Aug 02, 2023 at 02:52:57PM +0000, Jiaxin Yu (俞家鑫) wrote:
> On Mon, 2023-07-31 at 12:50 +0100, Mark Brown wrote:
> > On Mon, Jul 31, 2023 at 02:08:02AM +0800, Jiaxin Yu wrote:

> > > Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger
> > > DAPM events to hdmi-codec when userspace control the DPAM pin.

> > Why?

> I have defined an SOC_DAPM_PIN_SWITCH that named as "HDMI1", if I use
> SND_SOC_DAPM_OUTPUT, it can't be controlled by HDMI1's PIN_SWITCH.

...

> 2762                 if (w->dapm->card->fully_routed)
> 2763                         return;
> 2764                 ep = SND_SOC_DAPM_EP_SINK;
> 2765                 snd_soc_dapm_widget_for_each_sink_path(w, p) {
> 2766                         if (p->sink->id == snd_soc_dapm_spk ||
> 2767                                 p->sink->id == snd_soc_dapm_hp ||
> 2768                                 p->sink->id == snd_soc_dapm_line
> ||
> 2769                                 p->sink->id == snd_soc_dapm_input)
> {
> 2770                                         ep = 0;

The expectation here is that you'll connect the output to a widget that
corresponds to the physical output on your board and put the pin switch
on that, ideally with a label that corresponds to case markings or what
the physical output is called on the board.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-08-02 16:38       ` Mark Brown
@ 2023-08-03  7:20         ` Jiaxin Yu (俞家鑫)
  2023-08-03 19:33           ` Mark Brown
  0 siblings, 1 reply; 14+ messages in thread
From: Jiaxin Yu (俞家鑫) @ 2023-08-03  7:20 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, neil.armstrong, nfraprado,
	Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek,
	robert.foss, andrzej.hajda, angelogioacchino.delregno,
	ajye_huang, linux-arm-kernel, Laurent.pinchart

[-- Attachment #1: Type: text/html, Size: 4930 bytes --]

[-- Attachment #2: Type: text/plain, Size: 1803 bytes --]

On Wed, 2023-08-02 at 17:38 +0100, Mark Brown wrote:
> On Wed, Aug 02, 2023 at 02:52:57PM +0000, Jiaxin Yu (俞家鑫) wrote:
> > On Mon, 2023-07-31 at 12:50 +0100, Mark Brown wrote:
> > > On Mon, Jul 31, 2023 at 02:08:02AM +0800, Jiaxin Yu wrote:
> > > > Use SND_SOC_DAPM_LINE instead of SND_SOC_DAPM_OUTPUT to trigger
> > > > DAPM events to hdmi-codec when userspace control the DPAM pin.
> > > Why?
> > I have defined an SOC_DAPM_PIN_SWITCH that named as "HDMI1", if I
> > use
> > SND_SOC_DAPM_OUTPUT, it can't be controlled by HDMI1's PIN_SWITCH.
> 
> ...
> 
> > 2762                 if (w->dapm->card->fully_routed)
> > 2763                         return;
> > 2764                 ep = SND_SOC_DAPM_EP_SINK;
> > 2765                 snd_soc_dapm_widget_for_each_sink_path(w, p) {
> > 2766                         if (p->sink->id == snd_soc_dapm_spk ||
> > 2767                                 p->sink->id == snd_soc_dapm_hp
> > ||
> > 2768                                 p->sink->id ==
> > snd_soc_dapm_line
> > > > 
> > 
> > 2769                                 p->sink->id ==
> > snd_soc_dapm_input)
> > {
> > 2770                                         ep = 0;
> 
> The expectation here is that you'll connect the output to a widget
> that
> corresponds to the physical output on your board and put the pin
> switch
> on that, ideally with a label that corresponds to case markings or
> what
> the physical output is called on the board.

Dear brown,

I agree with you, in fact the speaker is indeed doing this way. But
about the hdmi that on the board, I did not find a defination link
snd_soc_dapm_hdmi, so I use snd_soc_dapm_line to replace. The purpose
is to control it link speaker. Or what do you suggest I should do? 

Thank you very much.

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-08-03  7:20         ` Jiaxin Yu (俞家鑫)
@ 2023-08-03 19:33           ` Mark Brown
  2024-01-31 11:42             ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2023-08-03 19:33 UTC (permalink / raw)
  To: Jiaxin Yu (俞家鑫)
  Cc: alsa-devel, neil.armstrong, nfraprado,
	Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek,
	robert.foss, andrzej.hajda, angelogioacchino.delregno,
	ajye_huang, linux-arm-kernel, Laurent.pinchart

[-- Attachment #1: Type: text/plain, Size: 567 bytes --]

On Thu, Aug 03, 2023 at 07:20:15AM +0000, Jiaxin Yu (俞家鑫) wrote:

> I agree with you, in fact the speaker is indeed doing this way. But
> about the hdmi that on the board, I did not find a defination link
> snd_soc_dapm_hdmi, so I use snd_soc_dapm_line to replace. The purpose
> is to control it link speaker. Or what do you suggest I should do? 

I think the sensible thing here is to define a DIGITAL_OUTPUT() which
can be used for HDMI, S/PDIF and anything else that comes up and isn't
clearly wrong like reusing one of the analog descriptions is.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [v3 3/3] drm/bridge: it6505: Add audio support
  2023-07-30 18:08 ` [v3 3/3] drm/bridge: it6505: Add audio support Jiaxin Yu
@ 2023-11-21 12:54   ` AngeloGioacchino Del Regno
  2023-11-28  3:17     ` Chen-Yu Tsai
  0 siblings, 1 reply; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-11-21 12:54 UTC (permalink / raw)
  To: Jiaxin Yu, broonie, andrzej.hajda, neil.armstrong, robert.foss,
	Laurent.pinchart, kuninori.morimoto.gx, nfraprado
  Cc: alsa-devel, chunxu.li, allen-kh.cheng, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, linux-mediatek, ajye_huang,
	linux-arm-kernel

Il 30/07/23 20:08, Jiaxin Yu ha scritto:
> Add audio support for it6505
> 
> 1. Bridge to hdmi-codec to support audio feature. At the same time,
>     the function of automatically detecting audio is removed.
> 2. It is observed that some DP-to-HDMI dongles will get into bad
>     states if sending InfoFrame without audio data. Defer to enable
>     it6505's audio feature when PCM triggers START or RESUME.
> 
> Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>

Hello Jiaxin,
this patch doesn't apply anymore (and it won't build anymore) upstream.

> ---
>   drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++---
>   1 file changed, 75 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> index 504d51c42f79..1cfcb0731288 100644
> --- a/drivers/gpu/drm/bridge/ite-it6505.c
> +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> @@ -2162,7 +2162,6 @@ static void it6505_stop_link_train(struct it6505 *it6505)
>   
>   static void it6505_link_train_ok(struct it6505 *it6505)
>   {
> -	struct device *dev = &it6505->client->dev;

This is because this changed to `struct device *dev = it6505->dev;`

>   
>   	it6505->link_state = LINK_OK;
>   	/* disalbe mute enable avi info frame */
> @@ -2170,11 +2169,6 @@ static void it6505_link_train_ok(struct it6505 *it6505)
>   	it6505_set_bits(it6505, REG_INFOFRAME_CTRL,
>   			EN_VID_CTRL_PKT, EN_VID_CTRL_PKT);
>   
> -	if (it6505_audio_input(it6505)) {
> -		DRM_DEV_DEBUG_DRIVER(dev, "Enable audio!");
> -		it6505_enable_audio(it6505);
> -	}
> -
>   	if (it6505->hdcp_desired)
>   		it6505_start_hdcp(it6505);
>   }
> @@ -2846,6 +2840,45 @@ static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data)
>   		it6505_disable_audio(it6505);
>   }
>   
> +static int it6505_audio_hw_params(struct device *dev, void *data,
> +				  struct hdmi_codec_daifmt *daifmt,
> +				  struct hdmi_codec_params *params)
> +{
> +	struct it6505 *it6505 = dev_get_drvdata(dev);
> +
> +	return it6505_audio_setup_hw_params(it6505, params);
> +}
> +
> +static int it6505_audio_setup_trigger(struct it6505 *it6505, int cmd)
> +{
> +	struct device *dev = &it6505->client->dev;

...and because you'll have to change this one, and other occurrences of that
as well.

Can you please respin this series?

Thanks,
Angelo



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

* Re: [v3 3/3] drm/bridge: it6505: Add audio support
  2023-11-21 12:54   ` AngeloGioacchino Del Regno
@ 2023-11-28  3:17     ` Chen-Yu Tsai
  0 siblings, 0 replies; 14+ messages in thread
From: Chen-Yu Tsai @ 2023-11-28  3:17 UTC (permalink / raw)
  To: AngeloGioacchino Del Regno, Jiaxin Yu
  Cc: neil.armstrong, alsa-devel, chunxu.li, nfraprado,
	kuninori.morimoto.gx, dri-devel, linux-kernel, robert.foss,
	Project_Global_Chrome_Upstream_Group, broonie, linux-mediatek,
	Laurent.pinchart, andrzej.hajda, ajye_huang, linux-arm-kernel,
	allen-kh.cheng

On Tue, Nov 21, 2023 at 8:54 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> Il 30/07/23 20:08, Jiaxin Yu ha scritto:
> > Add audio support for it6505
> >
> > 1. Bridge to hdmi-codec to support audio feature. At the same time,
> >     the function of automatically detecting audio is removed.
> > 2. It is observed that some DP-to-HDMI dongles will get into bad
> >     states if sending InfoFrame without audio data. Defer to enable
> >     it6505's audio feature when PCM triggers START or RESUME.
> >
> > Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
>
> Hello Jiaxin,
> this patch doesn't apply anymore (and it won't build anymore) upstream.
>
> > ---
> >   drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++---
> >   1 file changed, 75 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/bridge/ite-it6505.c b/drivers/gpu/drm/bridge/ite-it6505.c
> > index 504d51c42f79..1cfcb0731288 100644
> > --- a/drivers/gpu/drm/bridge/ite-it6505.c
> > +++ b/drivers/gpu/drm/bridge/ite-it6505.c
> > @@ -2162,7 +2162,6 @@ static void it6505_stop_link_train(struct it6505 *it6505)
> >
> >   static void it6505_link_train_ok(struct it6505 *it6505)
> >   {
> > -     struct device *dev = &it6505->client->dev;
>
> This is because this changed to `struct device *dev = it6505->dev;`
>
> >
> >       it6505->link_state = LINK_OK;
> >       /* disalbe mute enable avi info frame */
> > @@ -2170,11 +2169,6 @@ static void it6505_link_train_ok(struct it6505 *it6505)
> >       it6505_set_bits(it6505, REG_INFOFRAME_CTRL,
> >                       EN_VID_CTRL_PKT, EN_VID_CTRL_PKT);
> >
> > -     if (it6505_audio_input(it6505)) {
> > -             DRM_DEV_DEBUG_DRIVER(dev, "Enable audio!");
> > -             it6505_enable_audio(it6505);
> > -     }
> > -
> >       if (it6505->hdcp_desired)
> >               it6505_start_hdcp(it6505);
> >   }
> > @@ -2846,6 +2840,45 @@ static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data)
> >               it6505_disable_audio(it6505);
> >   }
> >
> > +static int it6505_audio_hw_params(struct device *dev, void *data,
> > +                               struct hdmi_codec_daifmt *daifmt,
> > +                               struct hdmi_codec_params *params)
> > +{
> > +     struct it6505 *it6505 = dev_get_drvdata(dev);
> > +
> > +     return it6505_audio_setup_hw_params(it6505, params);
> > +}
> > +
> > +static int it6505_audio_setup_trigger(struct it6505 *it6505, int cmd)
> > +{
> > +     struct device *dev = &it6505->client->dev;
>
> ...and because you'll have to change this one, and other occurrences of that
> as well.
>
> Can you please respin this series?

Please also add a patch adding #sound-dai-cells to the it6505 binding.

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2023-08-03 19:33           ` Mark Brown
@ 2024-01-31 11:42             ` AngeloGioacchino Del Regno
  2024-01-31 12:25               ` Jiaxin Yu (俞家鑫)
  0 siblings, 1 reply; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-01-31 11:42 UTC (permalink / raw)
  To: Jiaxin Yu (俞家鑫)
  Cc: alsa-devel, neil.armstrong, nfraprado,
	Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, Mark Brown, linux-mediatek,
	robert.foss, andrzej.hajda, Chen-Yu Tsai, ajye_huang,
	linux-arm-kernel, Laurent.pinchart

Il 03/08/23 21:33, Mark Brown ha scritto:
> On Thu, Aug 03, 2023 at 07:20:15AM +0000, Jiaxin Yu (俞家鑫) wrote:
> 
>> I agree with you, in fact the speaker is indeed doing this way. But
>> about the hdmi that on the board, I did not find a defination link
>> snd_soc_dapm_hdmi, so I use snd_soc_dapm_line to replace. The purpose
>> is to control it link speaker. Or what do you suggest I should do?
> 
> I think the sensible thing here is to define a DIGITAL_OUTPUT() which
> can be used for HDMI, S/PDIF and anything else that comes up and isn't
> clearly wrong like reusing one of the analog descriptions is.

Hello Jiaxin,

the MT8186 Corsola Chromebooks are broken upstream without this series.

Are you still interested in upstreaming this one?

Thanks,
Angelo

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2024-01-31 11:42             ` AngeloGioacchino Del Regno
@ 2024-01-31 12:25               ` Jiaxin Yu (俞家鑫)
  2024-01-31 12:37                 ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 14+ messages in thread
From: Jiaxin Yu (俞家鑫) @ 2024-01-31 12:25 UTC (permalink / raw)
  To: angelogioacchino.delregno
  Cc: neil.armstrong, alsa-devel, Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, nfraprado, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, broonie, linux-mediatek,
	robert.foss, andrzej.hajda, wenst, ajye_huang, linux-arm-kernel,
	Laurent.pinchart

[-- Attachment #1: Type: text/html, Size: 3106 bytes --]

[-- Attachment #2: Type: text/plain, Size: 1170 bytes --]

On Wed, 2024-01-31 at 12:42 +0100, AngeloGioacchino Del Regno wrote:
> Il 03/08/23 21:33, Mark Brown ha scritto:
> > On Thu, Aug 03, 2023 at 07:20:15AM +0000, Jiaxin Yu (俞家鑫) wrote:
> > 
> > > I agree with you, in fact the speaker is indeed doing this way.
> > > But
> > > about the hdmi that on the board, I did not find a defination
> > > link
> > > snd_soc_dapm_hdmi, so I use snd_soc_dapm_line to replace. The
> > > purpose
> > > is to control it link speaker. Or what do you suggest I should
> > > do?
> > 
> > I think the sensible thing here is to define a DIGITAL_OUTPUT()
> > which
> > can be used for HDMI, S/PDIF and anything else that comes up and
> > isn't
> > clearly wrong like reusing one of the analog descriptions is.
> 
> Hello Jiaxin,
> 
> the MT8186 Corsola Chromebooks are broken upstream without this
> series.
> 
> Are you still interested in upstreaming this one?
> 
> Thanks,
> Angelo

Hello Angelo, 

No, I'm still interesting in upstream this series. It's just that I
have less time recently. I'm considering revisiting this issue next
mouth. Do you have any suggestions for this?

Thanks,
Jiaxin.Yu

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

* Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets
  2024-01-31 12:25               ` Jiaxin Yu (俞家鑫)
@ 2024-01-31 12:37                 ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 14+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-01-31 12:37 UTC (permalink / raw)
  To: Jiaxin Yu (俞家鑫)
  Cc: neil.armstrong, alsa-devel, Chunxu Li (李春旭),
	Allen-KH Cheng (程冠勲),
	kuninori.morimoto.gx, nfraprado, linux-kernel, dri-devel,
	Project_Global_Chrome_Upstream_Group, broonie, linux-mediatek,
	robert.foss, andrzej.hajda, wenst, ajye_huang, linux-arm-kernel,
	Laurent.pinchart

Il 31/01/24 13:25, Jiaxin Yu (俞家鑫) ha scritto:
> On Wed, 2024-01-31 at 12:42 +0100, AngeloGioacchino Del Regno wrote:
>> Il 03/08/23 21:33, Mark Brown ha scritto:
>>> On Thu, Aug 03, 2023 at 07:20:15AM +0000, Jiaxin Yu (俞家鑫) wrote:
>>>
>>>> I agree with you, in fact the speaker is indeed doing this way.
>>>> But
>>>> about the hdmi that on the board, I did not find a defination
>>>> link
>>>> snd_soc_dapm_hdmi, so I use snd_soc_dapm_line to replace. The
>>>> purpose
>>>> is to control it link speaker. Or what do you suggest I should
>>>> do?
>>>
>>> I think the sensible thing here is to define a DIGITAL_OUTPUT()
>>> which
>>> can be used for HDMI, S/PDIF and anything else that comes up and
>>> isn't
>>> clearly wrong like reusing one of the analog descriptions is.
>>
>> Hello Jiaxin,
>>
>> the MT8186 Corsola Chromebooks are broken upstream without this
>> series.
>>
>> Are you still interested in upstreaming this one?
>>
>> Thanks,
>> Angelo
> 
> Hello Angelo,
> 
> No, I'm still interesting in upstream this series. It's just that I
> have less time recently. I'm considering revisiting this issue next
> mouth. Do you have any suggestions for this?
> 

Nothing on top of Mark's suggestions.

Angelo



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

end of thread, other threads:[~2024-01-31 12:37 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-30 18:08 [v3 0/3] ASoC: mediatek:mt8186: fix both the speaker and hdmi Jiaxin Yu
2023-07-30 18:08 ` [v3 1/3] ASoC: hdmi-codec: Add event handler for hdmi TX Jiaxin Yu
2023-07-30 18:08 ` [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets Jiaxin Yu
2023-07-31 11:50   ` Mark Brown
2023-08-02 14:52     ` Jiaxin Yu (俞家鑫)
2023-08-02 16:38       ` Mark Brown
2023-08-03  7:20         ` Jiaxin Yu (俞家鑫)
2023-08-03 19:33           ` Mark Brown
2024-01-31 11:42             ` AngeloGioacchino Del Regno
2024-01-31 12:25               ` Jiaxin Yu (俞家鑫)
2024-01-31 12:37                 ` AngeloGioacchino Del Regno
2023-07-30 18:08 ` [v3 3/3] drm/bridge: it6505: Add audio support Jiaxin Yu
2023-11-21 12:54   ` AngeloGioacchino Del Regno
2023-11-28  3:17     ` Chen-Yu Tsai

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).