Skip to contentSkip to conversation

ASoC: mediatek:mt8186: fix both the speaker and hdmi

PATCH In review Jiaxin Yu 4 participants 14 messages Jul 30, 2023 – Jan 31, 2024

Subsystems (6)
DRM drivers Sound DRM misc ASoC +2 more subsystems
lore
Share & tools
lore

Jiaxin Yu

author
#0 lore raw

v3 cover ASoC: mediatek:mt8186: fix both the speaker and hdmi

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(-)
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v3 1/3 ASoC: hdmi-codec: Add event handler for hdmi TX

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.

---
 include/sound/hdmi-codec.h    |  6 ++++++
 sound/soc/codecs/hdmi-codec.c | 32 ++++++++++++++++++++++++++++++--
 2 files changed, 36 insertions(+), 2 deletions(-)
include/sound/hdmi-codec.h +6 -0
index 9b162ac1e08e..ea834a838754 100644
@@ -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
sound/soc/codecs/hdmi-codec.c +30 -2
index d21f69f05342..6766b55c9b56 100644
@@ -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;
 	}
Signature · 1 line
2.25.1
author
#2 lore raw

PATCH v3 2/3 ASoC: mediatek: mt8186: correct the HDMI widgets

In reply to Jiaxin Yu

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

---
 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(-)
sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +1 -1
index 0432f9d89020..ae51d70e2c0b 100644
@@ -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),
sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +1 -1
index 9c11016f032c..a39e37fa4e02 100644
@@ -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),
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Quoted 2 lines · Jiaxin Yu

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?

#4 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Quoted 6 lines · Mark Brown
Quoted 2 lines · Jiaxin Yu

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;

maintainer
#5 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Quoted 10 lines · Jiaxin Yu (俞家鑫)
Quoted 6 lines · Mark Brown
Quoted 2 lines · Jiaxin Yu

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.

...

Quoted 11 lines

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.

#6 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Quoted 28 lines · Mark Brown
Quoted 8 lines · Jiaxin Yu (俞家鑫)
Quoted 4 lines · Mark Brown
Quoted 2 lines · Jiaxin Yu

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.

...

Quoted 8 lines

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 ==
Quoted 7 lines

snd_soc_dapm_line

Quoted 1 line
Quoted 1 line

2769 p->sink->id ==
snd_soc_dapm_input)
{
2770 ep = 0;

Quoted 7 lines

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.

maintainer
#7 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Quoted 4 lines · Jiaxin Yu (俞家鑫)

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.

#8 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Il 03/08/23 21:33, Mark Brown ha scritto:

Quoted 10 lines · Jiaxin Yu (俞家鑫)
Quoted 5 lines

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

#9 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Quoted 20 lines · AngeloGioacchino Del Regno

Il 03/08/23 21:33, Mark Brown ha scritto:

Quoted 11 lines · Jiaxin Yu (俞家鑫)
Quoted 9 lines

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?

Quoted 5 lines

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,

Quoted 7 lines

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

#10 lore raw

Re: [v3 2/3] ASoC: mediatek: mt8186: correct the HDMI widgets

Il 31/01/24 13:25, Jiaxin Yu (俞家鑫) ha scritto:

Quoted 26 lines · AngeloGioacchino Del Regno
Quoted 25 lines

Il 03/08/23 21:33, Mark Brown ha scritto:

Quoted 11 lines · Jiaxin Yu (俞家鑫)
Quoted 9 lines

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?

Quoted 5 lines

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?

Quoted 9 lines
Quoted 2 lines

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

author
#11 lore raw

PATCH v3 3/3 drm/bridge: it6505: Add audio support

In reply to Jiaxin Yu

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.

---
 drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++---
 1 file changed, 75 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +75 -6
index 504d51c42f79..1cfcb0731288 100644
@@ -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);
Signature · 1 line
2.25.1
#12 lore raw

Re: [v3 3/3] drm/bridge: it6505: Add audio support

Il 30/07/23 20:08, Jiaxin Yu ha scritto:

Quoted 9 lines

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.

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

drivers/gpu/drm/bridge/ite-it6505.c static void it6505_stop_link_train(struct it6505 *it6505) · line 2165

Quoted 13 lines
---
  drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++---
  1 file changed, 75 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
index 504d51c42f79..1cfcb0731288 100644
@@ -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;

Quoted 21 lines
drivers/gpu/drm/bridge/ite-it6505.c +2 -5
  	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,

drivers/gpu/drm/bridge/ite-it6505.c static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data) · line 2854

Quoted 10 lines
drivers/gpu/drm/bridge/ite-it6505.c +10 -0
+				  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

#13 lore raw

Re: [v3 3/3] drm/bridge: it6505: Add audio support

Quoted 66 lines · AngeloGioacchino Del Regno

Il 30/07/23 20:08, Jiaxin Yu ha scritto:

Quoted 9 lines

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.

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

drivers/gpu/drm/bridge/ite-it6505.c static void it6505_stop_link_train(struct it6505 *it6505) · line 2165

Quoted 13 lines
---
  drivers/gpu/drm/bridge/ite-it6505.c | 81 ++++++++++++++++++++++++++---
  1 file changed, 75 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/ite-it6505.c +0 -1
index 504d51c42f79..1cfcb0731288 100644
@@ -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;

Quoted 21 lines
drivers/gpu/drm/bridge/ite-it6505.c +2 -5
      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,

drivers/gpu/drm/bridge/ite-it6505.c static void __maybe_unused it6505_audio_shutdown(struct device *dev, void *data) · line 2854

Quoted 10 lines
drivers/gpu/drm/bridge/ite-it6505.c +10 -0
+                               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.

Quoted 1 line

Can you please respin this series?

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