Thread (9 messages) 9 messages, 3 authors, 2020-02-25

Re: [PATCH v3 1/1] drm: sun4i: hdmi: Add support for sun4i HDMI encoder audio

From: Maxime Ripard <hidden>
Date: 2020-02-03 12:23:34
Also in: dri-devel, lkml

Hi,

On Thu, Jan 30, 2020 at 08:20:55AM +0200, Stefan Mavrodiev wrote:
On 1/29/20 6:43 PM, Maxime Ripard wrote:
quoted
On Tue, Jan 28, 2020 at 04:06:42PM +0200, Stefan Mavrodiev wrote:
quoted
diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index 68d4644ac2dc..4cd35c97c503 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -23,6 +23,8 @@
  #include <drm/drm_print.h>
  #include <drm/drm_probe_helper.h>

+#include <sound/soc.h>
+
  #include "sun4i_backend.h"
  #include "sun4i_crtc.h"
  #include "sun4i_drv.h"
@@ -87,6 +89,10 @@ static void sun4i_hdmi_disable(struct drm_encoder *encoder)

  	DRM_DEBUG_DRIVER("Disabling the HDMI Output\n");

+#ifdef CONFIG_DRM_SUN4I_HDMI_AUDIO
+	sun4i_hdmi_audio_destroy(hdmi);
+#endif
+
  	val = readl(hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
  	val &= ~SUN4I_HDMI_VID_CTRL_ENABLE;
  	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
@@ -114,6 +120,11 @@ static void sun4i_hdmi_enable(struct drm_encoder *encoder)
  		val |= SUN4I_HDMI_VID_CTRL_HDMI_MODE;

  	writel(val, hdmi->base + SUN4I_HDMI_VID_CTRL_REG);
+
+#ifdef CONFIG_DRM_SUN4I_HDMI_AUDIO
+	if (hdmi->hdmi_audio && sun4i_hdmi_audio_create(hdmi))
+		DRM_ERROR("Couldn't create the HDMI audio adapter\n");
+#endif
I really don't think we should be creating / removing the audio card
at enable / disable time.
For me it's unnatural to have sound card all the time, even when the HDMI
is not plugged-in.
It's also a matter of being consistent: pretty much everyone else is
doing it:
  * vc4 (RaspberryPi)
    https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/vc4/vc4_hdmi.c#L1437

  * omap
    https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/omapdrm/dss/hdmi4.c#L620

  * sti
    https://elixir.bootlin.com/linux/v5.5.1/source/drivers/gpu/drm/sti/sti_hdmi.c#L1310

  * msm
    https://elixir.bootlin.com/linux/v5.5.1/source/drivers/gpu/drm/msm/hdmi/hdmi.c#L597

etc...

If we were to think about this at a more theorical level though, it's
pretty much the same case than having a sound card but no headphone
attached, or having a display engine but no display attached. In both
case, you register the driver before having a sink, you just let the
userspace know that there's nothing connected on the other end.

Maxime
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help