Skip to contentSkip to conversation

drm/display: add hw_params callback function to drm_connector_hdmi_audio_ops

PATCH In review Jianfeng Liu 6 participants 21 messages Sep 25, 2025 – Apr 14

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/display: add hw_params callback function to drm_connector_hdmi_audio_ops

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
#1 lore raw
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 10 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

Quoted 25 lines

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

--srini

Quoted 26 lines
Quoted 25 lines

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
#3 lore raw
Quoted 49 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

Quoted 5 lines

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 30 lines

--srini

Quoted 26 lines
Quoted 25 lines

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
Signature · 2 lines
With best wishes
Dmitry
#4 lore raw
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Srinivas, any response from your side?

Signature · 2 lines
With best wishes
Dmitry
#5 lore raw
In reply to Dmitry Baryshkov
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

TBH, Am not sure, I did not find anything that was obvious from the code.

--srini

Quoted 32 lines
Quoted 31 lines

--srini

Quoted 26 lines
Quoted 25 lines

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
#6 lore raw
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 42 lines

TBH, Am not sure, I did not find anything that was obvious from the code.

--srini

Quoted 32 lines
Quoted 31 lines

--srini

Quoted 26 lines
Quoted 25 lines

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
Signature · 2 lines
With best wishes
Dmitry
#7 lore raw
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

Its also doable to move out the clock related settings from prepare to startup which should work aswell.

--srini

Quoted 44 lines
Quoted 43 lines

TBH, Am not sure, I did not find anything that was obvious from the code.

--srini

Quoted 32 lines
Quoted 31 lines

--srini

Quoted 26 lines
Quoted 25 lines

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
Signature · 1 line
2.43.0
#8 lore raw
Quoted 86 lines · Srinivas Kandagatla
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 4 lines

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

As I wrote, previously it was done as a part of hw_params, which is also not optimal as hdmi-codec clearly defines both callbacks as optional, requiring only one of them. Do you know, what is actually required on the DP side for the DSP to be able to preapre()?

Quoted 4 lines

Its also doable to move out the clock related settings from prepare to startup which should work aswell.

Signature · 2 lines
With best wishes
Dmitry
#9 lore raw
Quoted 92 lines · Dmitry Baryshkov
Quoted 86 lines · Srinivas Kandagatla
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 4 lines

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

Quoted 4 lines

As I wrote, previously it was done as a part of hw_params, which is also not optimal as hdmi-codec clearly defines both callbacks as optional, requiring only one of them. Do you know, what is actually required on the DP side for the DSP to be able to preapre()?

Srinivas, did you have a chance to look at this? Or the .hw_prepare ordering? I really don't want to land this fix only to face the same issue because on some of the platforms .hw_prepare() callbacks will be called in a different order.

Quoted 9 lines
Quoted 5 lines

Its also doable to move out the clock related settings from prepare to startup which should work aswell.

Signature · 2 lines
With best wishes
Dmitry
Signature · 2 lines
With best wishes
Dmitry
#10 lore raw
Quoted 98 lines · Dmitry Baryshkov
Quoted 92 lines · Dmitry Baryshkov
Quoted 86 lines · Srinivas Kandagatla
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 4 lines

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

Quoted 4 lines

As I wrote, previously it was done as a part of hw_params, which is also not optimal as hdmi-codec clearly defines both callbacks as optional, requiring only one of them. Do you know, what is actually required on the DP side for the DSP to be able to preapre()?

Quoted 5 lines

Srinivas, did you have a chance to look at this? Or the .hw_prepare ordering? I really don't want to land this fix only to face the same issue because on some of the platforms .hw_prepare() callbacks will be called in a different order.

Dmitry, few days back Krzysztof was enabling DP audio on T14s, and we have seen that the DSP is not happy and returning error 1 when we try to prepare the dp port. The exact reason is codec is not ready at that point.

By adding this patch, Krzystof managed to get DP working. XElite platforms were working before 2fef64eec23a ("ASoC: hdmi-codec:
Add a prepare) patch was merged, basically 2fef64eec23a broke what was working before.

Am happy with this patch, better move to hw_params instead of prepare.

--srini

Quoted 10 lines
Quoted 9 lines
Quoted 5 lines

Its also doable to move out the clock related settings from prepare to startup which should work aswell.

Signature · 2 lines
With best wishes
Dmitry
#11 lore raw
Quoted 111 lines · Srinivas Kandagatla
Quoted 98 lines · Dmitry Baryshkov
Quoted 92 lines · Dmitry Baryshkov
Quoted 86 lines · Srinivas Kandagatla
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 4 lines

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

Quoted 4 lines

As I wrote, previously it was done as a part of hw_params, which is also not optimal as hdmi-codec clearly defines both callbacks as optional, requiring only one of them. Do you know, what is actually required on the DP side for the DSP to be able to preapre()?

Quoted 5 lines

Srinivas, did you have a chance to look at this? Or the .hw_prepare ordering? I really don't want to land this fix only to face the same issue because on some of the platforms .hw_prepare() callbacks will be called in a different order.

Dmitry, few days back Krzysztof was enabling DP audio on T14s, and we have seen that the DSP is not happy and returning error 1 when we try to prepare the dp port. The exact reason is codec is not ready at that point.

Quoted 6 lines

By adding this patch, Krzystof managed to get DP working. XElite platforms were working before 2fef64eec23a ("ASoC: hdmi-codec:
Add a prepare) patch was merged, basically 2fef64eec23a broke what was working before.

Am happy with this patch, better move to hw_params instead of prepare.

And I'm not happy with it :-)

hdmi-codec defines that one of the callbacks can be optional. We know that at .hw_params time we don't have IEC 958 status bits, so we will be programming incorrect audioframe.

Should some bits of code be moved to .audio_enable isntead? If so, which bits?

I agree that there is a regression and that this patch fixes it. I argue that the fix is incorrect.

Signature · 2 lines
With best wishes
Dmitry
#12 lore raw
Quoted 117 lines · Dmitry Baryshkov
Quoted 116 lines · Srinivas Kandagatla
Quoted 98 lines · Dmitry Baryshkov
Quoted 92 lines · Dmitry Baryshkov
Quoted 86 lines · Srinivas Kandagatla
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 4 lines

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

Quoted 4 lines

As I wrote, previously it was done as a part of hw_params, which is also not optimal as hdmi-codec clearly defines both callbacks as optional, requiring only one of them. Do you know, what is actually required on the DP side for the DSP to be able to preapre()?

Quoted 5 lines

Srinivas, did you have a chance to look at this? Or the .hw_prepare ordering? I really don't want to land this fix only to face the same issue because on some of the platforms .hw_prepare() callbacks will be called in a different order.

Dmitry, few days back Krzysztof was enabling DP audio on T14s, and we have seen that the DSP is not happy and returning error 1 when we try to prepare the dp port. The exact reason is codec is not ready at that point.

By adding this patch, Krzystof managed to get DP working. XElite platforms were working before 2fef64eec23a ("ASoC: hdmi-codec:
Add a prepare) patch was merged, basically 2fef64eec23a broke what was working before.

Quoted 7 lines
Quoted 1 line

Am happy with this patch, better move to hw_params instead of prepare.

And I'm not happy with it :-)

hdmi-codec defines that one of the callbacks can be optional. We know that at .hw_params time we don't have IEC 958 status bits, so we will be programming incorrect audioframe.

Your statement is contradicting with callbacks that are supported by hdmi-codec.

hdmi-codec uses IEC 958 status bits both in hw_params and prepare, if hw_params is not the right place, then that should be clarified and not correct for any of the codec drivers to use this callback.>

Quoted 2 lines

Should some bits of code be moved to .audio_enable isntead? If so, which bits?

I have not read the data sheet of msm dp block yet, but what it looks to me is the audio engine in the DP is powered off while dsp is trying to set it up.

--srini>

Quoted 4 lines

I agree that there is a regression and that this patch fixes it. I argue that the fix is incorrect.

#13 lore raw
Quoted 127 lines · Srinivas Kandagatla
Quoted 117 lines · Dmitry Baryshkov
Quoted 116 lines · Srinivas Kandagatla
Quoted 98 lines · Dmitry Baryshkov
Quoted 92 lines · Dmitry Baryshkov
Quoted 86 lines · Srinivas Kandagatla
Quoted 74 lines · Dmitry Baryshkov
Quoted 64 lines · Srinivas Kandagatla
Quoted 53 lines · Dmitry Baryshkov
Quoted 52 lines · Srinivas Kandagatla
Quoted 33 lines · Dmitry Baryshkov
Quoted 5 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

Quoted 10 lines

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

And a call to hdmi_codec_prepare() comes only at this place.

Srini, Mark, when selecting to only implement .prepare for codec ops I was following the commit 2fef64eec23a ("ASoC: hdmi-codec: Add a prepare hook"), which documents that IEC958 status bit is set after .hw_params(), so it's only visible during .prepare(). Is it okay to implement both callbacks? Or should the audioreach DAI driver be fixed somehow instead (I suppose it assumes that the port is available after .hw_params(), not sure if that assumption is correct)?

Quoted 6 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Quoted 7 lines
Quoted 4 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

The patch LGTM, but I would wait for response from audio maintainers.

The ordering matters in this case as we need clocks and audio configuration on DP codec side to be setup before we start configuring the dsp pipeline. Looks like that DSP is trying to setup DP endpoint even before it is ready.

q6apm prepare loads the dsp pipeline and starts configuring the endpoints, if the DP endpoint is not ready dsp would throw an error.

Quoted 7 lines
Quoted 2 lines

We might be able to pull in some dsp logs to confirm this, but I dont have a setup that I can reproduce this issue.

What would be your recommendation to proceed? Is it okay for the DAI driver to depend on the .hw_params enabling the clock? Also I see that the error regarding the clocks comes from .prepare callback too. What is the order of .prepare callbacks()? Can we influence it?

Quoted 4 lines

prepare follows hw-params, and prepare can be called multiple times

When you mean order of prepare callbacks, you mean w.r.t codec and dsp backend dia link drivers ?

Yes. Here we got a dependency from the cpu dai to be prepare()'d after the DP driver performs some actions, which were a part of hw_params() callback but were moved to be executed during prepare() callback.

Quoted 8 lines

This leads me to two sets of questions:
- In which order are those callbacks executed? Can we make the ASoC enforce some order of DAI's prepare() callbacks?

- More improtantly, isn't it a sympthom of DP driver (incorrectly) performing too much in the .hw_params() / .prepare() callback? Should we move some of the setup to the .audio_startup() instead? What is the expected split between those callbacks?

Quoted 4 lines

I have not looked at full dp sequences but, if prepare is the only place when it enables the required clocks for audio block, then it is a problem, we should do it early so that DSP can enable the required configuration in prepare.

Quoted 4 lines

As I wrote, previously it was done as a part of hw_params, which is also not optimal as hdmi-codec clearly defines both callbacks as optional, requiring only one of them. Do you know, what is actually required on the DP side for the DSP to be able to preapre()?

Quoted 5 lines

Srinivas, did you have a chance to look at this? Or the .hw_prepare ordering? I really don't want to land this fix only to face the same issue because on some of the platforms .hw_prepare() callbacks will be called in a different order.

Dmitry, few days back Krzysztof was enabling DP audio on T14s, and we have seen that the DSP is not happy and returning error 1 when we try to prepare the dp port. The exact reason is codec is not ready at that point.

By adding this patch, Krzystof managed to get DP working. XElite platforms were working before 2fef64eec23a ("ASoC: hdmi-codec:
Add a prepare) patch was merged, basically 2fef64eec23a broke what was working before.

Quoted 7 lines
Quoted 1 line

Am happy with this patch, better move to hw_params instead of prepare.

And I'm not happy with it :-)

hdmi-codec defines that one of the callbacks can be optional. We know that at .hw_params time we don't have IEC 958 status bits, so we will be programming incorrect audioframe.

Quoted 6 lines

Your statement is contradicting with callbacks that are supported by hdmi-codec.

hdmi-codec uses IEC 958 status bits both in hw_params and prepare, if hw_params is not the right place, then that should be clarified and not correct for any of the codec drivers to use this callback.>

See https://lore.kernel.org/all/[email protected]/

Quoted 6 lines
Quoted 2 lines

Should some bits of code be moved to .audio_enable isntead? If so, which bits?

I have not read the data sheet of msm dp block yet, but what it looks to me is the audio engine in the DP is powered off while dsp is trying to set it up.

Okay. What exactly is expected by the DSP? Which part, signal or clock should be on?

Signature · 2 lines
With best wishes
Dmitry
Tested-by on v2 1/1
#14 lore raw
In reply to Jianfeng Liu

Hi Jianfeng Liu,

Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 4 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

This also fixes DP audio regression on qcm6490-fairphone-fp5 (using Elite audio architecture)

[  133.986865] qcom-q6afe aprsvc:service:4:4: AFE enable for port 0x6020 failed -110
[  133.986878] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: fail to start AFE port 68
[  133.986881] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: ASoC error (-110): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0
[  134.045112] qcom-q6afe aprsvc:service:4:4: cmd = 0x100e5 returned error = 0x9
[  134.045192] qcom-q6afe aprsvc:service:4:4: DSP returned error[9]
[  134.045214] qcom-q6afe aprsvc:service:4:4: AFE enable for port 0x6020 failed -22
[  134.045231] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: fail to start AFE port 68
[  134.045243] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0

And I guess, even though I reported it after this patch was sent:

Regards
Luca

Quoted 27 lines

Tested with Radxa Dragon Q6A.

Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

---

Changes in v2:
- Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/
- Use more detailed trace log in commit message.
- Drop the empty line between Fixex and SoB.

 drivers/gpu/drm/display/drm_hdmi_audio_helper.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/display/drm_hdmi_audio_helper.c +1 -0
index 7d78b02c1446..6ca1c7ad0632 100644
@@ -130,6 +130,7 @@ EXPORT_SYMBOL(drm_connector_hdmi_audio_plugged_notify);
 
 static const struct hdmi_codec_ops drm_connector_hdmi_audio_ops = {
 	.audio_startup = drm_connector_hdmi_audio_startup,
+	.hw_params = drm_connector_hdmi_audio_prepare,
 	.prepare = drm_connector_hdmi_audio_prepare,
 	.audio_shutdown = drm_connector_hdmi_audio_shutdown,
 	.mute_stream = drm_connector_hdmi_audio_mute_stream,
#15 lore raw

Hi all,

Quoted 36 lines · Luca Weiss

Hi Jianfeng Liu,

Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 4 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

This also fixes DP audio regression on qcm6490-fairphone-fp5 (using Elite audio architecture)

[  133.986865] qcom-q6afe aprsvc:service:4:4: AFE enable for port 0x6020 failed -110
[  133.986878] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: fail to start AFE port 68
[  133.986881] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: ASoC error (-110): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0
[  134.045112] qcom-q6afe aprsvc:service:4:4: cmd = 0x100e5 returned error = 0x9
[  134.045192] qcom-q6afe aprsvc:service:4:4: DSP returned error[9]
[  134.045214] qcom-q6afe aprsvc:service:4:4: AFE enable for port 0x6020 failed -22
[  134.045231] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: fail to start AFE port 68
[  134.045243] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0
Quoted 5 lines

And I guess, even though I reported it after this patch was sent:

Is there any progress on resolving this issue? I'm still carrying this patch in my tree.

Shall I send a revert of "drm/msm/dp: reuse generic HDMI codec implementation" to at least temporarily get this working again until a more proper fix can be made?

Regards
Luca

#16 lore raw
Quoted 43 lines · Luca Weiss

Hi all,

Quoted 40 lines · Luca Weiss

Hi Jianfeng Liu,

Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 4 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

This also fixes DP audio regression on qcm6490-fairphone-fp5 (using Elite audio architecture)

[  133.986865] qcom-q6afe aprsvc:service:4:4: AFE enable for port 0x6020 failed -110
[  133.986878] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: fail to start AFE port 68
[  133.986881] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: ASoC error (-110): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0
[  134.045112] qcom-q6afe aprsvc:service:4:4: cmd = 0x100e5 returned error = 0x9
[  134.045192] qcom-q6afe aprsvc:service:4:4: DSP returned error[9]
[  134.045214] qcom-q6afe aprsvc:service:4:4: AFE enable for port 0x6020 failed -22
[  134.045231] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: fail to start AFE port 68
[  134.045243] q6afe-dai 3700000.remoteproc:glink-edge:apr:service@4:dais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0

And I guess, even though I reported it after this patch was sent:

Quoted 8 lines
Quoted 1 line

Is there any progress on resolving this issue? I'm still carrying this patch in my tree.

Shall I send a revert of "drm/msm/dp: reuse generic HDMI codec implementation" to at least temporarily get this working again until a more proper fix can be made?

My understanding was that it should be fixed by the following patch:

https://lore.kernel.org/all/[email protected]/

Quoted 3 lines

Regards
Luca

Signature · 2 lines
With best wishes
Dmitry
#17 lore raw
In reply to Jianfeng Liu
Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 7 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Tested with Radxa Dragon Q6A.

Missing Cc stable.

Quoted 3 lines
Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

---

I confirm this fixes the audio over DP/HDMI on X1E laptops. Please apply this for fixes.

Best regards,
Krzysztof

#18 lore raw
Quoted 26 lines · Krzysztof Kozlowski
Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 7 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Tested with Radxa Dragon Q6A.

Quoted 8 lines

Missing Cc stable.

Quoted 3 lines
Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

---

I confirm this fixes the audio over DP/HDMI on X1E laptops. Please apply this for fixes.

Forgot:

Best regards,
Krzysztof

#19 lore raw
Quoted 33 lines · Krzysztof Kozlowski
Quoted 32 lines · Krzysztof Kozlowski
Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 7 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Tested with Radxa Dragon Q6A.

Missing Cc stable.

Quoted 3 lines
Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

---

Quoted 6 lines
Quoted 2 lines

I confirm this fixes the audio over DP/HDMI on X1E laptops. Please apply this for fixes.

Forgot:

I'm still waiting for the response from Srini (since Oct 3rd). If you want it to be applied quicklier, let's resolve the question if it is a correct fix or not.

Signature · 2 lines
With best wishes
Dmitry
#20 lore raw
Quoted 37 lines · Dmitry Baryshkov
Quoted 36 lines · Krzysztof Kozlowski
Quoted 34 lines · Krzysztof Kozlowski
Quoted 16 lines · Jianfeng Liu

After reusing drm_hdmi_audio_* helpers and drm_bridge_connector integration in drm/msm/dp, we have dropped msm_dp_audio_hw_params and use msm_dp_audio_prepare instead. While userspace is still calling hw_params to do audio initialization, and we get the following errors:

q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started hdmi-audio-codec hdmi-audio-codec.0.auto: hdmi_codec_hw_params() started
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: q6apm_lpass_dai_prepare() started qcom-apm gprsvc:service:2:1: Error (1) Processing 0x01001002 cmd
qcom-apm gprsvc:service:2:1: DSP returned error[1001002] 1
q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: Failed to start APM port 104 q6apm-lpass-dais 3700000.remoteproc:glink-edge:gpr:service@1:bedais: ASoC error (-22): at snd_soc_dai_prepare() on DISPLAY_PORT_RX_0 MultiMedia2 Playback: ASoC error (-22): at dpcm_run_update_startup() on MultiMedia2 Playback

Quoted 7 lines

msm_dp_audio_prepare is not called because hdmi-codec driver only checks and runs hw_params before q6apm_lpass_dai_prepare(). This commit will add hw_params callback same as drm_connector_hdmi_audio_prepare, so that hdmi-codec driver can work with userspace alsa.

Tested with Radxa Dragon Q6A.

Missing Cc stable.

Quoted 3 lines
Fixes 98a8920e7b07 ("drm/msm/dp: reuse generic HDMI codec implementation")

---

I confirm this fixes the audio over DP/HDMI on X1E laptops. Please apply this for fixes.

Quoted 7 lines
Quoted 3 lines

Forgot:

I'm still waiting for the response from Srini (since Oct 3rd). If you want it to be applied quicklier, let's resolve the question if it is a correct fix or not.

In other words: from my opinion, the correct fix should be to make sure that DP part is ready after .audio_enable, rather than depending on .hw_params vs .prepare behaviour. Otherwise after some changes in ASoC or qcom soundcards we might end up in a situation when DSP's .hw_prepare is called before DP's .hw_prepare, ending up with the same issue.

Signature · 2 lines
With best wishes
Dmitry