All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: dw_hdmi: Gate audio sampler clock from the enablement functions
@ 2017-03-10  9:35 ` Romain Perier
  0 siblings, 0 replies; 34+ messages in thread
From: Romain Perier @ 2017-03-10  9:35 UTC (permalink / raw)
  To: Archit Taneja, David Airlie
  Cc: Heiko Stuebner, dri-devel, linux-rockchip, linux-arm-kernel,
	linux-kernel, Romain Perier

Currently, the audio sampler clock is enabled from dw_hdmi_setup() at
step E. and is kept enabled for later use. This clock should be enabled
and disabled along with the actual audio stream and not always on (that
is bad for PM). Futhermore, this might cause sound glitches with some
HDMI devices, as the CTS+N is forced to zero when the stream is disabled
while the audio clock is still running.

This commit adds a parameter to hdmi_audio_enable_clk() that controls
when the audio sample clock must be enabled or disabled. Then, it moves
the call to this function into dw_hdmi_audio_enable() and
dw_hdmi_audio_disable().

Signed-off-by: Romain Perier <romain.perier@collabora.com>
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index b621fc7..5b6090c 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -537,6 +537,12 @@ void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate)
 }
 EXPORT_SYMBOL_GPL(dw_hdmi_set_sample_rate);
 
+static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi, bool enable)
+{
+	hdmi_modb(hdmi, enable ? 0 : HDMI_MC_CLKDIS_AUDCLK_DISABLE,
+		  HDMI_MC_CLKDIS_AUDCLK_DISABLE, HDMI_MC_CLKDIS);
+}
+
 void dw_hdmi_audio_enable(struct dw_hdmi *hdmi)
 {
 	unsigned long flags;
@@ -544,6 +550,7 @@ void dw_hdmi_audio_enable(struct dw_hdmi *hdmi)
 	spin_lock_irqsave(&hdmi->audio_lock, flags);
 	hdmi->audio_enable = true;
 	hdmi_set_cts_n(hdmi, hdmi->audio_cts, hdmi->audio_n);
+	hdmi_enable_audio_clk(hdmi, true);
 	spin_unlock_irqrestore(&hdmi->audio_lock, flags);
 }
 EXPORT_SYMBOL_GPL(dw_hdmi_audio_enable);
@@ -554,6 +561,7 @@ void dw_hdmi_audio_disable(struct dw_hdmi *hdmi)
 
 	spin_lock_irqsave(&hdmi->audio_lock, flags);
 	hdmi->audio_enable = false;
+	hdmi_enable_audio_clk(hdmi, false);
 	hdmi_set_cts_n(hdmi, hdmi->audio_cts, 0);
 	spin_unlock_irqrestore(&hdmi->audio_lock, flags);
 }
@@ -1343,11 +1351,6 @@ static void dw_hdmi_enable_video_path(struct dw_hdmi *hdmi)
 	}
 }
 
-static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi)
-{
-	hdmi_modb(hdmi, 0, HDMI_MC_CLKDIS_AUDCLK_DISABLE, HDMI_MC_CLKDIS);
-}
-
 /* Workaround to clear the overflow condition */
 static void dw_hdmi_clear_overflow(struct dw_hdmi *hdmi)
 {
@@ -1430,7 +1433,7 @@ static int dw_hdmi_setup(struct dw_hdmi *hdmi, struct drm_display_mode *mode)
 
 		/* HDMI Initialization Step E - Configure audio */
 		hdmi_clk_regenerator_update_pixel_clock(hdmi);
-		hdmi_enable_audio_clk(hdmi);
+		hdmi_enable_audio_clk(hdmi, true);
 	}
 
 	/* not for DVI mode */
-- 
2.9.3

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

end of thread, other threads:[~2017-03-14  8:13 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10  9:35 [PATCH] drm: dw_hdmi: Gate audio sampler clock from the enablement functions Romain Perier
2017-03-10  9:35 ` Romain Perier
2017-03-10  9:35 ` Romain Perier
2017-03-10  9:46 ` Russell King - ARM Linux
2017-03-10  9:46   ` Russell King - ARM Linux
2017-03-10  9:46   ` Russell King - ARM Linux
2017-03-10 10:21   ` Romain Perier
2017-03-10 10:21     ` Romain Perier
2017-03-10 10:27     ` Russell King - ARM Linux
2017-03-10 10:27       ` Russell King - ARM Linux
2017-03-10 10:58       ` Romain Perier
2017-03-10 10:58         ` Romain Perier
2017-03-10 11:15         ` Russell King - ARM Linux
2017-03-10 11:15           ` Russell King - ARM Linux
2017-03-10 12:58           ` Romain Perier
2017-03-10 12:58             ` Romain Perier
2017-03-13  9:27 ` Neil Armstrong
2017-03-13  9:27   ` Neil Armstrong
2017-03-13  9:27   ` Neil Armstrong
2017-03-13  9:36   ` Russell King - ARM Linux
2017-03-13  9:36     ` Russell King - ARM Linux
2017-03-13 12:55     ` Jose Abreu
2017-03-13 12:55       ` Jose Abreu
2017-03-13 12:55       ` Jose Abreu
2017-03-13 13:10       ` Russell King - ARM Linux
2017-03-13 13:10         ` Russell King - ARM Linux
2017-03-13 18:49         ` Jose Abreu
2017-03-13 18:49           ` Jose Abreu
2017-03-13 18:49           ` Jose Abreu
2017-03-14  7:53           ` Romain Perier
2017-03-14  7:53             ` Romain Perier
2017-03-14  8:13             ` Neil Armstrong
2017-03-14  8:13               ` Neil Armstrong
2017-03-14  8:13               ` Neil Armstrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.