Skip to contentSkip to conversation

drm: bridge/dw_hdmi: add audio sample channel status setting

PATCH Superseded Cheng-Yi Chiang 3 participants 6 messages Sep 5, 2019 – Sep 9, 2019

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm: bridge/dw_hdmi: add audio sample channel status setting

From: Yakir Yang <[email protected]>

When transmitting IEC60985 linear PCM audio, we configure the Aduio Sample Channel Status information of all the channel status bits in the IEC60958 frame.
Refer to 60958-3 page 10 for frequency, original frequency, and wordlength setting.

This fix the issue that audio does not come out on some monitors (e.g. LG 22CV241)

Note that these registers are only for interfaces:
I2S audio interface, General Purpose Audio (GPA), or AHB audio DMA (AHBAUDDMA).
For S/PDIF interface this information comes from the stream.

Currently this function dw_hdmi_set_channel_status is only called from dw-hdmi-i2s-audio in I2S setup.

---
Original patch by Yakir Yang is at

https://lore.kernel.org/patchwork/patch/539653/

Change from v1 to v2:
1. Remove the version check because this will only be called by dw-hdmi-i2s-audio, and the registers are available in I2S setup.
2. Set these registers in dw_hdmi_i2s_hw_params.
3. Fix the sample width setting so it can use 16 or 24 bits.

 .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     | 70 +++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.h     | 20 ++++++
 include/drm/bridge/dw_hdmi.h                  |  2 +
 4 files changed, 93 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
index 34d8e837555f..b801a28b0f17 100644
@@ -102,6 +102,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
 	}
 
 	dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
+	dw_hdmi_set_channel_status(hdmi, hparms->sample_width);
 	dw_hdmi_set_channel_count(hdmi, hparms->channels);
 	dw_hdmi_set_channel_allocation(hdmi, hparms->cea.channel_allocation);
 
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +70 -0

76 lines not on this page · raw message

drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +20 -0
index 6988f12d89d9..619ebc1c8354 100644
@@ -158,6 +158,17 @@
 #define HDMI_FC_SPDDEVICEINF                    0x1062
 #define HDMI_FC_AUDSCONF                        0x1063
 #define HDMI_FC_AUDSSTAT                        0x1064
+#define HDMI_FC_AUDSV                           0x1065
+#define HDMI_FC_AUDSU                           0x1066
+#define HDMI_FC_AUDSCHNLS0                      0x1067
+#define HDMI_FC_AUDSCHNLS1                      0x1068
+#define HDMI_FC_AUDSCHNLS2                      0x1069
+#define HDMI_FC_AUDSCHNLS3                      0x106a
+#define HDMI_FC_AUDSCHNLS4                      0x106b
+#define HDMI_FC_AUDSCHNLS5                      0x106c
+#define HDMI_FC_AUDSCHNLS6                      0x106d
+#define HDMI_FC_AUDSCHNLS7                      0x106e
+#define HDMI_FC_AUDSCHNLS8                      0x106f
 #define HDMI_FC_DATACH0FILL                     0x1070
 #define HDMI_FC_DATACH1FILL                     0x1071
 #define HDMI_FC_DATACH2FILL                     0x1072
@@ -706,6 +717,15 @@ enum {
 /* HDMI_FC_AUDSCHNLS7 field values */
 	HDMI_FC_AUDSCHNLS7_ACCURACY_OFFSET = 4,
 	HDMI_FC_AUDSCHNLS7_ACCURACY_MASK = 0x30,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_MASK = 0x0f,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_192K = 0xe,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_176K4 = 0xc,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_96K = 0xa,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_768K = 0x9,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_88K2 = 0x8,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_32K = 0x3,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_48K = 0x2,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_44K1 = 0x0,
 
 /* HDMI_FC_AUDSCHNLS8 field values */
 	HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_MASK = 0xf0,
include/drm/bridge/dw_hdmi.h +2 -0
index cf528c289857..12144d2f80f4 100644
@@ -156,6 +156,8 @@ 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_status(struct dw_hdmi *hdmi,
+				unsigned int sample_width);
 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);
Signature · 1 line
2.23.0.187.g17f5b7556c-goog
#1 lore raw

Sorry for the noise.
Removed original author [email protected] from the thread because that mail is obsolete.
Yakir is now using [email protected].

Quoted 186 lines · Cheng-Yi Chiang

From: Yakir Yang <[email protected]>

When transmitting IEC60985 linear PCM audio, we configure the Aduio Sample Channel Status information of all the channel status bits in the IEC60958 frame.
Refer to 60958-3 page 10 for frequency, original frequency, and wordlength setting.

This fix the issue that audio does not come out on some monitors (e.g. LG 22CV241)

Note that these registers are only for interfaces:
I2S audio interface, General Purpose Audio (GPA), or AHB audio DMA (AHBAUDDMA).
For S/PDIF interface this information comes from the stream.

Currently this function dw_hdmi_set_channel_status is only called from dw-hdmi-i2s-audio in I2S setup.

---
Original patch by Yakir Yang is at

https://lore.kernel.org/patchwork/patch/539653/

Change from v1 to v2:
1. Remove the version check because this will only be called by dw-hdmi-i2s-audio, and the registers are available in I2S setup.
2. Set these registers in dw_hdmi_i2s_hw_params.
3. Fix the sample width setting so it can use 16 or 24 bits.

 .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     | 70 +++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.h     | 20 ++++++
 include/drm/bridge/dw_hdmi.h                  |  2 +
 4 files changed, 93 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
index 34d8e837555f..b801a28b0f17 100644
@@ -102,6 +102,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
        }
 
        dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
+       dw_hdmi_set_channel_status(hdmi, hparms->sample_width);
        dw_hdmi_set_channel_count(hdmi, hparms->channels);
        dw_hdmi_set_channel_allocation(hdmi, hparms->cea.channel_allocation);
 
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +70 -0
index bd65d0479683..d1daa369c8ae 100644
@@ -582,6 +582,76 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)
        return n;
 }
 
+/*
+ * When transmitting IEC60958 linear PCM audio, these registers allow to
+ * configure the channel status information of all the channel status
+ * bits in the IEC60958 frame. For the moment this configuration is only
+ * used when the I2S audio interface, General Purpose Audio (GPA),
+ * or AHB audio DMA (AHBAUDDMA) interface is active
+ * (for S/PDIF interface this information comes from the stream).
+ */
+void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi,
+                               unsigned int sample_width)
+{
+       u8 aud_schnl_samplerate;
+       u8 aud_schnl_8;
+       u8 word_length_bits;
+
+       switch (hdmi->sample_rate) {
+       case 32000:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_32K;
+               break;
+       case 44100:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_44K1;
+               break;
+       case 48000:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_48K;
+               break;
+       case 88200:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_88K2;
+               break;
+       case 96000:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_96K;
+               break;
+       case 176400:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_176K4;
+               break;
+       case 192000:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_192K;
+               break;
+       case 768000:
+               aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_768K;
+               break;
+       default:
+               dev_warn(hdmi->dev, "Unsupported audio sample rate (%u)\n",
+                        hdmi->sample_rate);
+               return;
+       }
+
+       /* set channel status register */
+       hdmi_modb(hdmi, aud_schnl_samplerate, HDMI_FC_AUDSCHNLS7_SMPRATE_MASK,
+                 HDMI_FC_AUDSCHNLS7);
+
+       /*
+        * Set original frequency to be the same as frequency.
+        * Use one-complement value as stated in IEC60958-3 page 13.
+        */
+       aud_schnl_8 = (~aud_schnl_samplerate) <<
+                       HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_OFFSET;
+
+       /*
+        * Refer to IEC60958-3 page 12. We can accept 16 bits or 24 bits.
+        * Otherwise, set the register to 0t o indicate using default value.
+        */
+       word_length_bits = (sample_width == 16) ? 0x2 :
+                           ((sample_width == 24) ? 0xb : 0);
+
+       aud_schnl_8 |= word_length_bits << HDMI_FC_AUDSCHNLS8_WORDLEGNTH_OFFSET;
+
+       hdmi_writeb(hdmi, aud_schnl_8, HDMI_FC_AUDSCHNLS8);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_status);
+
 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi,
        unsigned long pixel_clk, unsigned int sample_rate)
 {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +20 -0
index 6988f12d89d9..619ebc1c8354 100644
@@ -158,6 +158,17 @@
 #define HDMI_FC_SPDDEVICEINF                    0x1062
 #define HDMI_FC_AUDSCONF                        0x1063
 #define HDMI_FC_AUDSSTAT                        0x1064
+#define HDMI_FC_AUDSV                           0x1065
+#define HDMI_FC_AUDSU                           0x1066
+#define HDMI_FC_AUDSCHNLS0                      0x1067
+#define HDMI_FC_AUDSCHNLS1                      0x1068
+#define HDMI_FC_AUDSCHNLS2                      0x1069
+#define HDMI_FC_AUDSCHNLS3                      0x106a
+#define HDMI_FC_AUDSCHNLS4                      0x106b
+#define HDMI_FC_AUDSCHNLS5                      0x106c
+#define HDMI_FC_AUDSCHNLS6                      0x106d
+#define HDMI_FC_AUDSCHNLS7                      0x106e
+#define HDMI_FC_AUDSCHNLS8                      0x106f
 #define HDMI_FC_DATACH0FILL                     0x1070
 #define HDMI_FC_DATACH1FILL                     0x1071
 #define HDMI_FC_DATACH2FILL                     0x1072
@@ -706,6 +717,15 @@ enum {
 /* HDMI_FC_AUDSCHNLS7 field values */
        HDMI_FC_AUDSCHNLS7_ACCURACY_OFFSET = 4,
        HDMI_FC_AUDSCHNLS7_ACCURACY_MASK = 0x30,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_MASK = 0x0f,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_192K = 0xe,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_176K4 = 0xc,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_96K = 0xa,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_768K = 0x9,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_88K2 = 0x8,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_32K = 0x3,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_48K = 0x2,
+       HDMI_FC_AUDSCHNLS7_SMPRATE_44K1 = 0x0,
 
 /* HDMI_FC_AUDSCHNLS8 field values */
        HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_MASK = 0xf0,
include/drm/bridge/dw_hdmi.h +2 -1
index cf528c289857..12144d2f80f4 100644
@@ -156,6 +156,8 @@ 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_status(struct dw_hdmi *hdmi,
+                               unsigned int sample_width);
 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);
--

2.23.0.187.g17f5b7556c-goog

Reviewed-by on v2 1/1
#2 lore raw
In reply to Cheng-Yi Chiang

Dne četrtek, 05. september 2019 ob 11:43:25 CEST je Cheng-Yi Chiang napisal(a):

Quoted 93 lines

From: Yakir Yang <[email protected]>

When transmitting IEC60985 linear PCM audio, we configure the Aduio Sample Channel Status information of all the channel status bits in the IEC60958 frame.
Refer to 60958-3 page 10 for frequency, original frequency, and wordlength setting.

This fix the issue that audio does not come out on some monitors (e.g. LG 22CV241)

Note that these registers are only for interfaces:
I2S audio interface, General Purpose Audio (GPA), or AHB audio DMA (AHBAUDDMA).
For S/PDIF interface this information comes from the stream.

Currently this function dw_hdmi_set_channel_status is only called from dw-hdmi-i2s-audio in I2S setup.

---
Original patch by Yakir Yang is at

https://lore.kernel.org/patchwork/patch/539653/

Change from v1 to v2:
1. Remove the version check because this will only be called by dw-hdmi-i2s-audio, and the registers are available in I2S setup.
2. Set these registers in dw_hdmi_i2s_hw_params.
3. Fix the sample width setting so it can use 16 or 24 bits.

 .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     | 70 +++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.h     | 20 ++++++
 include/drm/bridge/dw_hdmi.h                  |  2 +
 4 files changed, 93 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c index 34d8e837555f..b801a28b0f17 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
@@ -102,6 +102,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev,
 void *data, }
 
 	dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
+	dw_hdmi_set_channel_status(hdmi, hparms->sample_width);
 	dw_hdmi_set_channel_count(hdmi, hparms->channels);
 	dw_hdmi_set_channel_allocation(hdmi, hparms-
 cea.channel_allocation);
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index
bd65d0479683..d1daa369c8ae 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +32 -0
@@ -582,6 +582,76 @@ static unsigned int hdmi_compute_n(unsigned int freq,
 unsigned long pixel_clk) return n;
 }
 
+/*
+ * When transmitting IEC60958 linear PCM audio, these registers allow to
+ * configure the channel status information of all the channel status
+ * bits in the IEC60958 frame. For the moment this configuration is only
+ * used when the I2S audio interface, General Purpose Audio (GPA),
+ * or AHB audio DMA (AHBAUDDMA) interface is active
+ * (for S/PDIF interface this information comes from the stream).
+ */
+void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi,
+				unsigned int sample_width)
+{
+	u8 aud_schnl_samplerate;
+	u8 aud_schnl_8;
+	u8 word_length_bits;
+
+	switch (hdmi->sample_rate) {
+	case 32000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_32K;
+		break;
+	case 44100:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_44K1;
+		break;
+	case 48000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_48K;
+		break;
+	case 88200:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_88K2;
+		break;
+	case 96000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_96K;
+		break;
+	case 176400:

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, · line 626

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10 -0
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_176K4;
+		break;
+	case 192000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_192K;
+		break;
+	case 768000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_768K;
+		break;
+	default:
+		dev_warn(hdmi->dev, "Unsupported audio sample rate (%u)

\n",

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)

Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6 -0
+			 hdmi->sample_rate);
+		return;
+	}
+
+	/* set channel status register */
+	hdmi_modb(hdmi, aud_schnl_samplerate, 

HDMI_FC_AUDSCHNLS7_SMPRATE_MASK,

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)

Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +12 -0
+		  HDMI_FC_AUDSCHNLS7);
+
+	/*
+	 * Set original frequency to be the same as frequency.
+	 * Use one-complement value as stated in IEC60958-3 page 13.
+	 */
+	aud_schnl_8 = (~aud_schnl_samplerate) <<
+			HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_OFFSET;
+
+	/*
+	 * Refer to IEC60958-3 page 12. We can accept 16 bits or 24 bits.
+	 * Otherwise, set the register to 0t o indicate using default 

value.

Nit: "0t 0" -> "0 to"

With that fixed, this patch is:

Best regards,
Jernej

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -0
+	 */
+	word_length_bits = (sample_width == 16) ? 0x2 :
+			    ((sample_width == 24) ? 0xb : 0);
+
+	aud_schnl_8 |= word_length_bits << 

HDMI_FC_AUDSCHNLS8_WORDLEGNTH_OFFSET;

Quoted 61 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -0
+
+	hdmi_writeb(hdmi, aud_schnl_8, HDMI_FC_AUDSCHNLS8);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_status);
+
 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi,
 	unsigned long pixel_clk, unsigned int sample_rate)
 {
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h index
6988f12d89d9..619ebc1c8354 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +20 -0
@@ -158,6 +158,17 @@
 #define HDMI_FC_SPDDEVICEINF                    0x1062
 #define HDMI_FC_AUDSCONF                        0x1063
 #define HDMI_FC_AUDSSTAT                        0x1064
+#define HDMI_FC_AUDSV                           0x1065
+#define HDMI_FC_AUDSU                           0x1066
+#define HDMI_FC_AUDSCHNLS0                      0x1067
+#define HDMI_FC_AUDSCHNLS1                      0x1068
+#define HDMI_FC_AUDSCHNLS2                      0x1069
+#define HDMI_FC_AUDSCHNLS3                      0x106a
+#define HDMI_FC_AUDSCHNLS4                      0x106b
+#define HDMI_FC_AUDSCHNLS5                      0x106c
+#define HDMI_FC_AUDSCHNLS6                      0x106d
+#define HDMI_FC_AUDSCHNLS7                      0x106e
+#define HDMI_FC_AUDSCHNLS8                      0x106f
 #define HDMI_FC_DATACH0FILL                     0x1070
 #define HDMI_FC_DATACH1FILL                     0x1071
 #define HDMI_FC_DATACH2FILL                     0x1072
@@ -706,6 +717,15 @@ enum {
 /* HDMI_FC_AUDSCHNLS7 field values */
 	HDMI_FC_AUDSCHNLS7_ACCURACY_OFFSET = 4,
 	HDMI_FC_AUDSCHNLS7_ACCURACY_MASK = 0x30,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_MASK = 0x0f,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_192K = 0xe,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_176K4 = 0xc,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_96K = 0xa,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_768K = 0x9,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_88K2 = 0x8,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_32K = 0x3,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_48K = 0x2,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_44K1 = 0x0,
 
 /* HDMI_FC_AUDSCHNLS8 field values */
 	HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_MASK = 0xf0,
include/drm/bridge/dw_hdmi.h +2 -0
index cf528c289857..12144d2f80f4 100644
@@ -156,6 +156,8 @@ 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_status(struct dw_hdmi *hdmi,
+				unsigned int sample_width);
 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);

#3 lore raw
Quoted 128 lines · Jernej Škrabec

Dne četrtek, 05. september 2019 ob 11:43:25 CEST je Cheng-Yi Chiang napisal(a):

Quoted 93 lines

From: Yakir Yang <[email protected]>

When transmitting IEC60985 linear PCM audio, we configure the Aduio Sample Channel Status information of all the channel status bits in the IEC60958 frame.
Refer to 60958-3 page 10 for frequency, original frequency, and wordlength setting.

This fix the issue that audio does not come out on some monitors (e.g. LG 22CV241)

Note that these registers are only for interfaces:
I2S audio interface, General Purpose Audio (GPA), or AHB audio DMA (AHBAUDDMA).
For S/PDIF interface this information comes from the stream.

Currently this function dw_hdmi_set_channel_status is only called from dw-hdmi-i2s-audio in I2S setup.

---
Original patch by Yakir Yang is at

https://lore.kernel.org/patchwork/patch/539653/

Change from v1 to v2:
1. Remove the version check because this will only be called by dw-hdmi-i2s-audio, and the registers are available in I2S setup.
2. Set these registers in dw_hdmi_i2s_hw_params.
3. Fix the sample width setting so it can use 16 or 24 bits.

 .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     | 70 +++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.h     | 20 ++++++
 include/drm/bridge/dw_hdmi.h                  |  2 +
 4 files changed, 93 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c index 34d8e837555f..b801a28b0f17 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
@@ -102,6 +102,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev,
 void *data, }
 
      dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
+     dw_hdmi_set_channel_status(hdmi, hparms->sample_width);
      dw_hdmi_set_channel_count(hdmi, hparms->channels);
      dw_hdmi_set_channel_allocation(hdmi, hparms-
 cea.channel_allocation);
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index
bd65d0479683..d1daa369c8ae 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +32 -0
@@ -582,6 +582,76 @@ static unsigned int hdmi_compute_n(unsigned int freq,
 unsigned long pixel_clk) return n;
 }
 
+/*
+ * When transmitting IEC60958 linear PCM audio, these registers allow to
+ * configure the channel status information of all the channel status
+ * bits in the IEC60958 frame. For the moment this configuration is only
+ * used when the I2S audio interface, General Purpose Audio (GPA),
+ * or AHB audio DMA (AHBAUDDMA) interface is active
+ * (for S/PDIF interface this information comes from the stream).
+ */
+void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi,
+                             unsigned int sample_width)
+{
+     u8 aud_schnl_samplerate;
+     u8 aud_schnl_8;
+     u8 word_length_bits;
+
+     switch (hdmi->sample_rate) {
+     case 32000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_32K;
+             break;
+     case 44100:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_44K1;
+             break;
+     case 48000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_48K;
+             break;
+     case 88200:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_88K2;
+             break;
+     case 96000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_96K;
+             break;
+     case 176400:

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, · line 626

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10 -0
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_176K4;
+             break;
+     case 192000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_192K;
+             break;
+     case 768000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_768K;
+             break;
+     default:
+             dev_warn(hdmi->dev, "Unsupported audio sample rate (%u)

\n",

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)

Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +6 -0
+                      hdmi->sample_rate);
+             return;
+     }
+
+     /* set channel status register */
+     hdmi_modb(hdmi, aud_schnl_samplerate,

HDMI_FC_AUDSCHNLS7_SMPRATE_MASK,

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)

Quoted 12 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +12 -0
+               HDMI_FC_AUDSCHNLS7);
+
+     /*
+      * Set original frequency to be the same as frequency.
+      * Use one-complement value as stated in IEC60958-3 page 13.
+      */
+     aud_schnl_8 = (~aud_schnl_samplerate) <<
+                     HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_OFFSET;
+
+     /*
+      * Refer to IEC60958-3 page 12. We can accept 16 bits or 24 bits.
+      * Otherwise, set the register to 0t o indicate using default

value.

Quoted 7 lines

Nit: "0t 0" -> "0 to"

With that fixed, this patch is:

Best regards,
Jernej

Hi Jernej,
Thank you for reviewing the patch.
But as Russell pointed in the next mail,
I will update in v3 to make this patch much more simpler.

Quoted 72 lines

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)

Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -0
+      */
+     word_length_bits = (sample_width == 16) ? 0x2 :
+                         ((sample_width == 24) ? 0xb : 0);
+
+     aud_schnl_8 |= word_length_bits <<

HDMI_FC_AUDSCHNLS8_WORDLEGNTH_OFFSET;

Quoted 61 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +5 -0
+
+     hdmi_writeb(hdmi, aud_schnl_8, HDMI_FC_AUDSCHNLS8);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_status);
+
 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi,
      unsigned long pixel_clk, unsigned int sample_rate)
 {
(quoted diff) +0 -0

b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.h index
6988f12d89d9..619ebc1c8354 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +20 -0
@@ -158,6 +158,17 @@
 #define HDMI_FC_SPDDEVICEINF                    0x1062
 #define HDMI_FC_AUDSCONF                        0x1063
 #define HDMI_FC_AUDSSTAT                        0x1064
+#define HDMI_FC_AUDSV                           0x1065
+#define HDMI_FC_AUDSU                           0x1066
+#define HDMI_FC_AUDSCHNLS0                      0x1067
+#define HDMI_FC_AUDSCHNLS1                      0x1068
+#define HDMI_FC_AUDSCHNLS2                      0x1069
+#define HDMI_FC_AUDSCHNLS3                      0x106a
+#define HDMI_FC_AUDSCHNLS4                      0x106b
+#define HDMI_FC_AUDSCHNLS5                      0x106c
+#define HDMI_FC_AUDSCHNLS6                      0x106d
+#define HDMI_FC_AUDSCHNLS7                      0x106e
+#define HDMI_FC_AUDSCHNLS8                      0x106f
 #define HDMI_FC_DATACH0FILL                     0x1070
 #define HDMI_FC_DATACH1FILL                     0x1071
 #define HDMI_FC_DATACH2FILL                     0x1072
@@ -706,6 +717,15 @@ enum {
 /* HDMI_FC_AUDSCHNLS7 field values */
      HDMI_FC_AUDSCHNLS7_ACCURACY_OFFSET = 4,
      HDMI_FC_AUDSCHNLS7_ACCURACY_MASK = 0x30,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_MASK = 0x0f,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_192K = 0xe,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_176K4 = 0xc,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_96K = 0xa,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_768K = 0x9,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_88K2 = 0x8,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_32K = 0x3,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_48K = 0x2,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_44K1 = 0x0,
 
 /* HDMI_FC_AUDSCHNLS8 field values */
      HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_MASK = 0xf0,
include/drm/bridge/dw_hdmi.h +2 -0
index cf528c289857..12144d2f80f4 100644
@@ -156,6 +156,8 @@ 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_status(struct dw_hdmi *hdmi,
+                             unsigned int sample_width);
 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);

#4 lore raw
In reply to Cheng-Yi Chiang
Quoted 43 lines · Cheng-Yi Chiang

From: Yakir Yang <[email protected]>

When transmitting IEC60985 linear PCM audio, we configure the Aduio Sample Channel Status information of all the channel status bits in the IEC60958 frame.
Refer to 60958-3 page 10 for frequency, original frequency, and wordlength setting.

This fix the issue that audio does not come out on some monitors (e.g. LG 22CV241)

Note that these registers are only for interfaces:
I2S audio interface, General Purpose Audio (GPA), or AHB audio DMA (AHBAUDDMA).
For S/PDIF interface this information comes from the stream.

Currently this function dw_hdmi_set_channel_status is only called from dw-hdmi-i2s-audio in I2S setup.

---
Original patch by Yakir Yang is at

https://lore.kernel.org/patchwork/patch/539653/

Change from v1 to v2:
1. Remove the version check because this will only be called by dw-hdmi-i2s-audio, and the registers are available in I2S setup.
2. Set these registers in dw_hdmi_i2s_hw_params.
3. Fix the sample width setting so it can use 16 or 24 bits.

 .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     | 70 +++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.h     | 20 ++++++
 include/drm/bridge/dw_hdmi.h                  |  2 +
 4 files changed, 93 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +0 -0
index 34d8e837555f..b801a28b0f17 100644

drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c static int dw_hdmi_i2s_hw_params(struct device *dev, void *data, · line 108

Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
@@ -102,6 +102,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
 	}
 
 	dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
+	dw_hdmi_set_channel_status(hdmi, hparms->sample_width);
 	dw_hdmi_set_channel_count(hdmi, hparms->channels);
 	dw_hdmi_set_channel_allocation(hdmi, hparms->cea.channel_allocation);
 

dw_hdmi_i2s_hw_params() is passed the channel status data in hparams->iec.status Rather than re-creating it afresh in the driver, I'd recommend programming the already supplied channel status data into the registers.

Quoted 67 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +59 -0
index bd65d0479683..d1daa369c8ae 100644
@@ -582,6 +582,76 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)
 	return n;
 }
 
+/*
+ * When transmitting IEC60958 linear PCM audio, these registers allow to
+ * configure the channel status information of all the channel status
+ * bits in the IEC60958 frame. For the moment this configuration is only
+ * used when the I2S audio interface, General Purpose Audio (GPA),
+ * or AHB audio DMA (AHBAUDDMA) interface is active
+ * (for S/PDIF interface this information comes from the stream).
+ */
+void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi,
+				unsigned int sample_width)
+{
+	u8 aud_schnl_samplerate;
+	u8 aud_schnl_8;
+	u8 word_length_bits;
+
+	switch (hdmi->sample_rate) {
+	case 32000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_32K;
+		break;
+	case 44100:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_44K1;
+		break;
+	case 48000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_48K;
+		break;
+	case 88200:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_88K2;
+		break;
+	case 96000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_96K;
+		break;
+	case 176400:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_176K4;
+		break;
+	case 192000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_192K;
+		break;
+	case 768000:
+		aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_768K;
+		break;
+	default:
+		dev_warn(hdmi->dev, "Unsupported audio sample rate (%u)\n",
+			 hdmi->sample_rate);
+		return;
+	}
+
+	/* set channel status register */
+	hdmi_modb(hdmi, aud_schnl_samplerate, HDMI_FC_AUDSCHNLS7_SMPRATE_MASK,
+		  HDMI_FC_AUDSCHNLS7);
+
+	/*
+	 * Set original frequency to be the same as frequency.
+	 * Use one-complement value as stated in IEC60958-3 page 13.
+	 */
+	aud_schnl_8 = (~aud_schnl_samplerate) <<
+			HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_OFFSET;
+
+	/*
+	 * Refer to IEC60958-3 page 12. We can accept 16 bits or 24 bits.

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) · line 653

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +10 -0
+	 * Otherwise, set the register to 0t o indicate using default value.
+	 */
+	word_length_bits = (sample_width == 16) ? 0x2 :
+			    ((sample_width == 24) ? 0xb : 0);
+
+	aud_schnl_8 |= word_length_bits << HDMI_FC_AUDSCHNLS8_WORDLEGNTH_OFFSET;
+
+	hdmi_writeb(hdmi, aud_schnl_8, HDMI_FC_AUDSCHNLS8);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_status);

As mentioned above, the channel status data is actually already provided - so we don't really need the above at all. It just needs the data programmed into the registers.

Quoted 29 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -0
+
 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi,
 	unsigned long pixel_clk, unsigned int sample_rate)
 {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +11 -0
index 6988f12d89d9..619ebc1c8354 100644
@@ -158,6 +158,17 @@
 #define HDMI_FC_SPDDEVICEINF                    0x1062
 #define HDMI_FC_AUDSCONF                        0x1063
 #define HDMI_FC_AUDSSTAT                        0x1064
+#define HDMI_FC_AUDSV                           0x1065
+#define HDMI_FC_AUDSU                           0x1066
+#define HDMI_FC_AUDSCHNLS0                      0x1067
+#define HDMI_FC_AUDSCHNLS1                      0x1068
+#define HDMI_FC_AUDSCHNLS2                      0x1069
+#define HDMI_FC_AUDSCHNLS3                      0x106a
+#define HDMI_FC_AUDSCHNLS4                      0x106b
+#define HDMI_FC_AUDSCHNLS5                      0x106c
+#define HDMI_FC_AUDSCHNLS6                      0x106d
+#define HDMI_FC_AUDSCHNLS7                      0x106e
+#define HDMI_FC_AUDSCHNLS8                      0x106f
 #define HDMI_FC_DATACH0FILL                     0x1070
 #define HDMI_FC_DATACH1FILL                     0x1071
 #define HDMI_FC_DATACH2FILL                     0x1072
@@ -706,6 +717,15 @@ enum {
 /* HDMI_FC_AUDSCHNLS7 field values */
 	HDMI_FC_AUDSCHNLS7_ACCURACY_OFFSET = 4,

drivers/gpu/drm/bridge/synopsys/dw-hdmi.h enum { · line 728

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +9 -0
 	HDMI_FC_AUDSCHNLS7_ACCURACY_MASK = 0x30,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_MASK = 0x0f,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_192K = 0xe,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_176K4 = 0xc,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_96K = 0xa,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_768K = 0x9,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_88K2 = 0x8,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_32K = 0x3,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_48K = 0x2,
+	HDMI_FC_AUDSCHNLS7_SMPRATE_44K1 = 0x0,

These look very much like the IEC958_AES* consumer definitions in include/sound/asoundef.h.

Quoted 24 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +0 -0
 /* HDMI_FC_AUDSCHNLS8 field values */
 	HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_MASK = 0xf0,
include/drm/bridge/dw_hdmi.h +2 -0
index cf528c289857..12144d2f80f4 100644
@@ -156,6 +156,8 @@ 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_status(struct dw_hdmi *hdmi,
+				unsigned int sample_width);
 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);
Signature · 7 lines
2.23.0.187.g17f5b7556c-goog


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 3 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
#5 lore raw
Quoted 47 lines · Russell King - ARM Linux admin
Quoted 45 lines · Cheng-Yi Chiang

From: Yakir Yang <[email protected]>

When transmitting IEC60985 linear PCM audio, we configure the Aduio Sample Channel Status information of all the channel status bits in the IEC60958 frame.
Refer to 60958-3 page 10 for frequency, original frequency, and wordlength setting.

This fix the issue that audio does not come out on some monitors (e.g. LG 22CV241)

Note that these registers are only for interfaces:
I2S audio interface, General Purpose Audio (GPA), or AHB audio DMA (AHBAUDDMA).
For S/PDIF interface this information comes from the stream.

Currently this function dw_hdmi_set_channel_status is only called from dw-hdmi-i2s-audio in I2S setup.

---
Original patch by Yakir Yang is at

https://lore.kernel.org/patchwork/patch/539653/

Change from v1 to v2:
1. Remove the version check because this will only be called by dw-hdmi-i2s-audio, and the registers are available in I2S setup.
2. Set these registers in dw_hdmi_i2s_hw_params.
3. Fix the sample width setting so it can use 16 or 24 bits.

 .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c   |  1 +
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c     | 70 +++++++++++++++++++
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.h     | 20 ++++++
 include/drm/bridge/dw_hdmi.h                  |  2 +
 4 files changed, 93 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +0 -0
index 34d8e837555f..b801a28b0f17 100644
@@ -102,6 +102,7 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,
      }
 
Quoted 11 lines

drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c static int dw_hdmi_i2s_hw_params(struct device *dev, void *data, · line 108

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
      dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
+     dw_hdmi_set_channel_status(hdmi, hparms->sample_width);
      dw_hdmi_set_channel_count(hdmi, hparms->channels);
      dw_hdmi_set_channel_allocation(hdmi, hparms->cea.channel_allocation);
 

dw_hdmi_i2s_hw_params() is passed the channel status data in hparams->iec.status Rather than re-creating it afresh in the driver, I'd recommend programming the already supplied channel status data into the registers.

Hi Russell,
Thank you for pointing this out.
I did not realize that the status data is already set. I will fix in v3 to make this patch much simpler.

Quoted 73 lines
Quoted 73 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +65 -0
index bd65d0479683..d1daa369c8ae 100644
@@ -582,6 +582,76 @@ static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk)
      return n;
 }
 
+/*
+ * When transmitting IEC60958 linear PCM audio, these registers allow to
+ * configure the channel status information of all the channel status
+ * bits in the IEC60958 frame. For the moment this configuration is only
+ * used when the I2S audio interface, General Purpose Audio (GPA),
+ * or AHB audio DMA (AHBAUDDMA) interface is active
+ * (for S/PDIF interface this information comes from the stream).
+ */
+void dw_hdmi_set_channel_status(struct dw_hdmi *hdmi,
+                             unsigned int sample_width)
+{
+     u8 aud_schnl_samplerate;
+     u8 aud_schnl_8;
+     u8 word_length_bits;
+
+     switch (hdmi->sample_rate) {
+     case 32000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_32K;
+             break;
+     case 44100:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_44K1;
+             break;
+     case 48000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_48K;
+             break;
+     case 88200:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_88K2;
+             break;
+     case 96000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_96K;
+             break;
+     case 176400:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_176K4;
+             break;
+     case 192000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_192K;
+             break;
+     case 768000:
+             aud_schnl_samplerate = HDMI_FC_AUDSCHNLS7_SMPRATE_768K;
+             break;
+     default:
+             dev_warn(hdmi->dev, "Unsupported audio sample rate (%u)\n",
+                      hdmi->sample_rate);
+             return;
+     }
+
+     /* set channel status register */
+     hdmi_modb(hdmi, aud_schnl_samplerate, HDMI_FC_AUDSCHNLS7_SMPRATE_MASK,
+               HDMI_FC_AUDSCHNLS7);
+
+     /*
+      * Set original frequency to be the same as frequency.
+      * Use one-complement value as stated in IEC60958-3 page 13.
+      */
+     aud_schnl_8 = (~aud_schnl_samplerate) <<
+                     HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_OFFSET;
+
+     /*
+      * Refer to IEC60958-3 page 12. We can accept 16 bits or 24 bits.
+      * Otherwise, set the register to 0t o indicate using default value.
+      */
+     word_length_bits = (sample_width == 16) ? 0x2 :
+                         ((sample_width == 24) ? 0xb : 0);
+
+     aud_schnl_8 |= word_length_bits << HDMI_FC_AUDSCHNLS8_WORDLEGNTH_OFFSET;
Quoted 9 lines

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static unsigned int hdmi_compute_n(unsigned int freq, unsigned long pixel_clk) · line 653

Quoted 4 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -0
+
+     hdmi_writeb(hdmi, aud_schnl_8, HDMI_FC_AUDSCHNLS8);
+}
+EXPORT_SYMBOL_GPL(dw_hdmi_set_channel_status);

As mentioned above, the channel status data is actually already provided - so we don't really need the above at all. It just needs the data programmed into the registers.

ACK

Quoted 34 lines
Quoted 34 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -0
+
 static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi,
      unsigned long pixel_clk, unsigned int sample_rate)
 {
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +15 -0
index 6988f12d89d9..619ebc1c8354 100644
@@ -158,6 +158,17 @@
 #define HDMI_FC_SPDDEVICEINF                    0x1062
 #define HDMI_FC_AUDSCONF                        0x1063
 #define HDMI_FC_AUDSSTAT                        0x1064
+#define HDMI_FC_AUDSV                           0x1065
+#define HDMI_FC_AUDSU                           0x1066
+#define HDMI_FC_AUDSCHNLS0                      0x1067
+#define HDMI_FC_AUDSCHNLS1                      0x1068
+#define HDMI_FC_AUDSCHNLS2                      0x1069
+#define HDMI_FC_AUDSCHNLS3                      0x106a
+#define HDMI_FC_AUDSCHNLS4                      0x106b
+#define HDMI_FC_AUDSCHNLS5                      0x106c
+#define HDMI_FC_AUDSCHNLS6                      0x106d
+#define HDMI_FC_AUDSCHNLS7                      0x106e
+#define HDMI_FC_AUDSCHNLS8                      0x106f
 #define HDMI_FC_DATACH0FILL                     0x1070
 #define HDMI_FC_DATACH1FILL                     0x1071
 #define HDMI_FC_DATACH2FILL                     0x1072
@@ -706,6 +717,15 @@ enum {
 /* HDMI_FC_AUDSCHNLS7 field values */
      HDMI_FC_AUDSCHNLS7_ACCURACY_OFFSET = 4,
      HDMI_FC_AUDSCHNLS7_ACCURACY_MASK = 0x30,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_MASK = 0x0f,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_192K = 0xe,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_176K4 = 0xc,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_96K = 0xa,
Quoted 8 lines

drivers/gpu/drm/bridge/synopsys/dw-hdmi.h enum { · line 728

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +5 -0
+     HDMI_FC_AUDSCHNLS7_SMPRATE_768K = 0x9,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_88K2 = 0x8,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_32K = 0x3,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_48K = 0x2,
+     HDMI_FC_AUDSCHNLS7_SMPRATE_44K1 = 0x0,

These look very much like the IEC958_AES* consumer definitions in include/sound/asoundef.h.

ACK. Will remove in v3.

Quoted 30 lines
Quoted 20 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +0 -0
 /* HDMI_FC_AUDSCHNLS8 field values */
      HDMI_FC_AUDSCHNLS8_ORIGSAMPFREQ_MASK = 0xf0,
include/drm/bridge/dw_hdmi.h +2 -1
index cf528c289857..12144d2f80f4 100644
@@ -156,6 +156,8 @@ 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_status(struct dw_hdmi *hdmi,
+                             unsigned int sample_width);
 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);
--

2.23.0.187.g17f5b7556c-goog

Quoted 5 lines

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up