drm/bridge: dw-hdmi: move audio channel setup out of ahb
authorJerome Brunet <jbrunet@baylibre.com>
Mon, 12 Aug 2019 12:07:20 +0000 (14:07 +0200)
committerNeil Armstrong <narmstrong@baylibre.com>
Wed, 14 Aug 2019 13:03:11 +0000 (15:03 +0200)
Part of the channel count setup done in dw-hdmi ahb should
actually be done whatever the interface providing the data.

Let's move it to dw-hdmi driver instead.

Reviewed-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Jerome Brunet <jbrunet@baylibre.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190812120726.1528-3-jbrunet@baylibre.com
drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
include/drm/bridge/dw_hdmi.h

index a494186ae6ce14cf7fbad18442daf035277eb9e1..2b7539701b42249311baa42e78f220ad1fc0b1d1 100644 (file)
@@ -63,10 +63,6 @@ enum {
        HDMI_REVISION_ID = 0x0001,
        HDMI_IH_AHBDMAAUD_STAT0 = 0x0109,
        HDMI_IH_MUTE_AHBDMAAUD_STAT0 = 0x0189,
-       HDMI_FC_AUDICONF2 = 0x1027,
-       HDMI_FC_AUDSCONF = 0x1063,
-       HDMI_FC_AUDSCONF_LAYOUT1 = 1 << 0,
-       HDMI_FC_AUDSCONF_LAYOUT0 = 0 << 0,
        HDMI_AHB_DMA_CONF0 = 0x3600,
        HDMI_AHB_DMA_START = 0x3601,
        HDMI_AHB_DMA_STOP = 0x3602,
@@ -403,7 +399,7 @@ static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
 {
        struct snd_pcm_runtime *runtime = substream->runtime;
        struct snd_dw_hdmi *dw = substream->private_data;
-       u8 threshold, conf0, conf1, layout, ca;
+       u8 threshold, conf0, conf1, ca;
 
        /* Setup as per 3.0.5 FSL 4.1.0 BSP */
        switch (dw->revision) {
@@ -434,20 +430,12 @@ static int dw_hdmi_prepare(struct snd_pcm_substream *substream)
        conf1 = default_hdmi_channel_config[runtime->channels - 2].conf1;
        ca = default_hdmi_channel_config[runtime->channels - 2].ca;
 
-       /*
-        * For >2 channel PCM audio, we need to select layout 1
-        * and set an appropriate channel map.
-        */
-       if (runtime->channels > 2)
-               layout = HDMI_FC_AUDSCONF_LAYOUT1;
-       else
-               layout = HDMI_FC_AUDSCONF_LAYOUT0;
-
        writeb_relaxed(threshold, dw->data.base + HDMI_AHB_DMA_THRSLD);
        writeb_relaxed(conf0, dw->data.base + HDMI_AHB_DMA_CONF0);
        writeb_relaxed(conf1, dw->data.base + HDMI_AHB_DMA_CONF1);
-       writeb_relaxed(layout, dw->data.base + HDMI_FC_AUDSCONF);
-       writeb_relaxed(ca, dw->data.base + HDMI_FC_AUDICONF2);
+
+       dw_hdmi_set_channel_count(dw->data.hdmi, runtime->channels);
+       dw_hdmi_set_channel_allocation(dw->data.hdmi, ca);
 
        switch (runtime->format) {
        case SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE:
index 83b94b66e464e63c81ffb8d02462544a0057ffe2..ae46b770943ecc33f70d18b46de43b525726c816 100644 (file)
@@ -645,6 +645,38 @@ void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate)
 }
 EXPORT_SYMBOL_GPL(dw_hdmi_set_sample_rate);
 
+void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt)
+{
+       u8 layout;
+
+       mutex_lock(&hdmi->audio_mutex);
+
+       /*
+        * For >2 channel PCM audio, we need to select layout 1
+        * and set an appropriate channel map.
+        */
+       if (cnt > 2)
+               layout = HDMI_FC_AUDSCONF_AUD_PACKET_LAYOUT_LAYOUT1;
+       else
+               layout = HDMI_FC_AUDSCONF_AUD_PACKET_LAYOUT_LAYOUT0;
+
+       hdmi_modb(hdmi, layout, HDMI_FC_AUDSCONF_AUD_PACKET_LAYOUT_MASK,
+                 HDMI_FC_AUDSCONF);
+
+       mutex_unlock(&hdmi->audio_mutex);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_count);
+
+void dw_hdmi_set_channel_allocation(struct dw_hdmi *hdmi, unsigned int ca)
+{
+       mutex_lock(&hdmi->audio_mutex);
+
+       hdmi_writeb(hdmi, ca, HDMI_FC_AUDICONF2);
+
+       mutex_unlock(&hdmi->audio_mutex);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_allocation);
+
 static void hdmi_enable_audio_clk(struct dw_hdmi *hdmi, bool enable)
 {
        if (enable)
index c402364aec0dbc63d7a9d87a14c2460e7d94c136..cf528c2898570d72d38eedb233505b63f6d548fd 100644 (file)
@@ -155,6 +155,8 @@ void dw_hdmi_resume(struct dw_hdmi *hdmi);
 void dw_hdmi_setup_rx_sense(struct dw_hdmi *hdmi, bool hpd, bool rx_sense);
 
 void dw_hdmi_set_sample_rate(struct dw_hdmi *hdmi, unsigned int rate);
+void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt);
+void dw_hdmi_set_channel_allocation(struct dw_hdmi *hdmi, unsigned int ca);
 void dw_hdmi_audio_enable(struct dw_hdmi *hdmi);
 void dw_hdmi_audio_disable(struct dw_hdmi *hdmi);
 void dw_hdmi_set_high_tmds_clock_ratio(struct dw_hdmi *hdmi);