Skip to contentSkip to conversation

drm/tegra: hdmi: Setup audio only if configured

PATCH In review Thierry Reding 2 participants 2 messages Apr 16, 2019

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

PATCH v2 1/1 drm/tegra: hdmi: Setup audio only if configured

From: Thierry Reding <[email protected]>

The audio configuration is only valid if the HDMI codec has been properly set up. Do not attempt to set up audio before that happens because it causes a division by zero.

Note that this is only problematic on Tegra20 and Tegra30. Later chips implement the division instructions which return zero when dividing by zero and don't throw an exception.

Fixes db5adf4d6dce ("drm/tegra: hdmi: Fix audio to work with any pixel clock rate")

---
Changes in v2:
- setup audio at ->enable() time if it has been configured, otherwise audio playback needs to be restarted after the display goes through a disable/enable cycle

 drivers/gpu/drm/tegra/hdmi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/tegra/hdmi.c +9 -3
index 47c55974756d..d23c4bfde790 100644
@@ -1260,9 +1260,15 @@ static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder)
 
 	hdmi->dvi = !tegra_output_is_hdmi(output);
 	if (!hdmi->dvi) {
-		err = tegra_hdmi_setup_audio(hdmi);
-		if (err < 0)
-			hdmi->dvi = true;
+		/*
+		 * Make sure that the audio format has been configured before
+		 * enabling audio, otherwise we may try to divide by zero.
+		*/
+		if (hdmi->format.sample_rate > 0) {
+			err = tegra_hdmi_setup_audio(hdmi);
+			if (err < 0)
+				hdmi->dvi = true;
+		}
 	}
 
 	if (hdmi->config->has_hda)
Signature · 6 lines
2.21.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Tested-by on v2 1/1
#1 lore raw

16.04.2019 18:16, Thierry Reding пишет:

Quoted 36 lines

From: Thierry Reding <[email protected]>

The audio configuration is only valid if the HDMI codec has been properly set up. Do not attempt to set up audio before that happens because it causes a division by zero.

Note that this is only problematic on Tegra20 and Tegra30. Later chips implement the division instructions which return zero when dividing by zero and don't throw an exception.

Fixes db5adf4d6dce ("drm/tegra: hdmi: Fix audio to work with any pixel clock rate")

---
Changes in v2:
- setup audio at ->enable() time if it has been configured, otherwise audio playback needs to be restarted after the display goes through a disable/enable cycle

 drivers/gpu/drm/tegra/hdmi.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/tegra/hdmi.c +2 -3
index 47c55974756d..d23c4bfde790 100644
@@ -1260,9 +1260,15 @@ static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder)
 
 	hdmi->dvi = !tegra_output_is_hdmi(output);
 	if (!hdmi->dvi) {
-		err = tegra_hdmi_setup_audio(hdmi);
-		if (err < 0)
-			hdmi->dvi = true;
+		/*
+		 * Make sure that the audio format has been configured before

drivers/gpu/drm/tegra/hdmi.c static void tegra_hdmi_encoder_enable(struct drm_encoder *encoder) · line 1274

Quoted 10 lines
drivers/gpu/drm/tegra/hdmi.c +7 -0
+		 * enabling audio, otherwise we may try to divide by zero.
+		*/
+		if (hdmi->format.sample_rate > 0) {
+			err = tegra_hdmi_setup_audio(hdmi);
+			if (err < 0)
+				hdmi->dvi = true;
+		}
 	}
 
 	if (hdmi->config->has_hda)

Thank you very much!

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel