drm/bridge: dw-hdmi: improve i2s support
Jerome Brunet
reviewercover drm/bridge: dw-hdmi: improve i2s support
The purpose of this patchset is to improve the support of the i2s interface of the synopsys hdmi controller.
Once applied, the interface should support all the usual i2s bus formats, 8 channels playback and properly setup the channel number and allocation in the infoframes.
Also, the dw-hdmi i2s interface will now provide the eld to the generic hdmi-codec so it can expose the related controls to user space.
This work was inspired by Jonas Karlman's work, available here [0].
This was tested the Amlogic meson-g12a-sei510 platform. For this specific platform, which uses codec2codec links, there is a runtime dependency for patch 8 on this ASoC series [1].
[0]: https://github.com/Kwiboo/linux-rockchip/commits/rockchip-5.2-for-libreelec-v5.2.3
[1]: https://lkml.kernel.org/r/[email protected]
Jerome Brunet (8):
drm/bridge: dw-hdmi-i2s: support more i2s format drm/bridge: dw-hdmi: move audio channel setup out of ahb drm/bridge: dw-hdmi: set channel count in the infoframes drm/bridge: dw-hdmi-i2s: enable lpcm multi channels drm/bridge: dw-hdmi-i2s: set the channel allocation drm/bridge: dw-hdmi-i2s: reset audio fifo before applying new params drm/bridge: dw-hdmi-i2s: enable only the required i2s lanes drm/bridge: dw-hdmi-i2s: add .get_eld support
.../drm/bridge/synopsys/dw-hdmi-ahb-audio.c | 20 ++----- .../gpu/drm/bridge/synopsys/dw-hdmi-audio.h | 1 + .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 59 +++++++++++++++++-- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 37 ++++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 13 +++- include/drm/bridge/dw_hdmi.h | 2 + 6 files changed, 107 insertions(+), 25 deletions(-)
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 1/8 drm/bridge: dw-hdmi-i2s: support more i2s format
The dw-hdmi-i2s supports more formats than just regular i2s. Add support for left justified, right justified and dsp modes A and B.
--- .../drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 26 ++++++++++++++++--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 6 +++-- 2 files changed, 27 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +23 -3
@@ -44,9 +44,8 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,u8 inputclkfs =0 ;/* it cares I2S only */ -if ((fmt->fmt !=HDMI_I2S ) || - (fmt->bit_clk_master | fmt->frame_clk_master)) { -dev_err (dev,"unsupported format/settings\n" ); +if (fmt->bit_clk_master | fmt->frame_clk_master) { +dev_err (dev,"unsupported clock settings\n" );return -EINVAL ; }
@@ -63,6 +62,27 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,break ; } +switch (fmt->fmt) { +case HDMI_I2S : + conf1 |=HDMI_AUD_CONF1_MODE_I2S ; +break ; +case HDMI_RIGHT_J : + conf1 |=HDMI_AUD_CONF1_MODE_RIGHT_J ; +break ; +case HDMI_LEFT_J : + conf1 |=HDMI_AUD_CONF1_MODE_LEFT_J ; +break ; +case HDMI_DSP_A : + conf1 |=HDMI_AUD_CONF1_MODE_BURST_1 ; +break ; +case HDMI_DSP_B : + conf1 |=HDMI_AUD_CONF1_MODE_BURST_2 ; +break ; +default : +dev_err (dev,"unsupported format\n" ); +return -EINVAL ; + } +dw_hdmi_set_sample_rate (hdmi, hparms->sample_rate);hdmi_write (audio, inputclkfs,HDMI_AUD_INPUTCLKFS );
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +4 -2
@@ -869,8 +869,10 @@ enum {/* AUD_CONF1 field values */ HDMI_AUD_CONF1_MODE_I2S =0x00 , -HDMI_AUD_CONF1_MODE_RIGHT_J =0x02 , -HDMI_AUD_CONF1_MODE_LEFT_J =0x04 , +HDMI_AUD_CONF1_MODE_RIGHT_J =0x20 , +HDMI_AUD_CONF1_MODE_LEFT_J =0x40 , +HDMI_AUD_CONF1_MODE_BURST_1 =0x60 , +HDMI_AUD_CONF1_MODE_BURST_2 =0x80 ,HDMI_AUD_CONF1_WIDTH_16 =0x10 , HDMI_AUD_CONF1_WIDTH_24 = 0x18,
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 2/8 drm/bridge: dw-hdmi: move audio channel setup out of ahb
In reply to Jerome BrunetPart 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.
--- .../drm/bridge/synopsys/dw-hdmi-ahb-audio.c | 20 +++--------- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 32 +++++++++++++++++++ include/drm/bridge/dw_hdmi.h | 2 ++ 3 files changed, 38 insertions(+), 16 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-ahb-audio.c +4 -16
@@ -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 :
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +32 -0
@@ -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)
include/drm/bridge/dw_hdmi.h +2 -0
@@ -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);
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 3/8 drm/bridge: dw-hdmi: set channel count in the infoframes
In reply to Jerome BrunetSet the number of channel in the infoframes
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -0
@@ -663,6 +663,10 @@ void dw_hdmi_set_channel_count(struct dw_hdmi *hdmi, unsigned int cnt)hdmi_modb (hdmi, layout,HDMI_FC_AUDSCONF_AUD_PACKET_LAYOUT_MASK ,HDMI_FC_AUDSCONF ); +/* Set the audio infoframes channel count */ +hdmi_modb (hdmi, (cnt -1 ) <<HDMI_FC_AUDICONF0_CC_OFFSET , +HDMI_FC_AUDICONF0_CC_MASK ,HDMI_FC_AUDICONF0 ); +mutex_unlock (&hdmi->audio_mutex); }EXPORT_SYMBOL_GPL (dw_hdmi_set_channel_count);
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 4/8 drm/bridge: dw-hdmi-i2s: enable lpcm multi channels
In reply to Jerome BrunetProperly setup the channel count and layout in dw-hdmi i2s driver so we are not limited to 2 channels.
Also correct the maximum channel reported by the DAI from 6 to 8 ch
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +2 -1
@@ -84,6 +84,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_count (hdmi, hparms->channels);hdmi_write (audio, inputclkfs,HDMI_AUD_INPUTCLKFS );hdmi_write (audio, conf0,HDMI_AUD_CONF0 );
@@ -139,7 +140,7 @@ static int snd_dw_hdmi_probe(struct platform_device *pdev) pdata.ops = &dw_hdmi_i2s_ops; pdata.i2s =1 ; - pdata.max_i2s_channels =6 ; + pdata.max_i2s_channels =8 ; pdata.data = audio;memset (&pdevinfo,0 ,sizeof (pdevinfo));
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 5/8 drm/bridge: dw-hdmi-i2s: set the channel allocation
In reply to Jerome Brunetsetup the channel allocation provided by the generic hdmi-codec driver
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +1 -0
@@ -85,6 +85,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_count (hdmi, hparms->channels); +dw_hdmi_set_channel_allocation (hdmi, hparms->cea.channel_allocation);hdmi_write (audio, inputclkfs,HDMI_AUD_INPUTCLKFS );hdmi_write (audio, conf0,HDMI_AUD_CONF0 );
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 6/8 drm/bridge: dw-hdmi-i2s: reset audio fifo before applying new params
In reply to Jerome BrunetWhen changing the audio hw params, reset the audio fifo to make sure any old remaining data is flushed.
The databook mentions that such reset should be followed by a reset of the i2s block to make sure the samples stay aligned
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 6 ++++-- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +4 -2
@@ -49,6 +49,10 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,return -EINVAL ; } +/* Reset the FIFOs before applying new params */ +hdmi_write (audio,HDMI_AUD_CONF0_SW_RESET ,HDMI_AUD_CONF0 ); +hdmi_write (audio, (u8 )~HDMI_MC_SWRSTZ_I2SSWRST_REQ ,HDMI_MC_SWRSTZ ); + inputclkfs =HDMI_AUD_INPUTCLKFS_64FS ; conf0 =HDMI_AUD_CONF0_I2S_ALL_ENABLE ;
@@ -102,8 +106,6 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)struct dw_hdmi *hdmi = audio->hdmi;dw_hdmi_audio_disable (hdmi); - -hdmi_write (audio,HDMI_AUD_CONF0_SW_RESET ,HDMI_AUD_CONF0 ); } static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +1 -0
@@ -940,6 +940,7 @@ enum {HDMI_MC_CLKDIS_PIXELCLK_DISABLE =0x1 ,/* MC_SWRSTZ field values */ +HDMI_MC_SWRSTZ_I2SSWRST_REQ =0x08 , HDMI_MC_SWRSTZ_TMDSSWRST_REQ = 0x02,/* MC_FLOWCTRL field values */
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 7/8 drm/bridge: dw-hdmi-i2s: enable only the required i2s lanes
In reply to Jerome BrunetEnable the i2s lanes depending on the number of channel in the stream
--- .../gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 15 ++++++++++++++- drivers/gpu/drm/bridge/synopsys/dw-hdmi.h | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +14 -1
@@ -54,7 +54,20 @@ static int dw_hdmi_i2s_hw_params(struct device *dev, void *data,hdmi_write (audio, (u8 )~HDMI_MC_SWRSTZ_I2SSWRST_REQ ,HDMI_MC_SWRSTZ ); inputclkfs =HDMI_AUD_INPUTCLKFS_64FS ; - conf0 =HDMI_AUD_CONF0_I2S_ALL_ENABLE ; + conf0 = (HDMI_AUD_CONF0_I2S_SELECT |HDMI_AUD_CONF0_I2S_EN0 ); + +/* Enable the required i2s lanes */ +switch (hparms->channels) { + case 7 ... 8: + conf0 |=HDMI_AUD_CONF0_I2S_EN3 ; +/* Fall-thru */ + case 5 ... 6: + conf0 |=HDMI_AUD_CONF0_I2S_EN2 ; +/* Fall-thru */ + case 3 ... 4: + conf0 |=HDMI_AUD_CONF0_I2S_EN1 ; +/* Fall-thru */ + }switch (hparms->sample_width) {case 16 :
drivers/gpu/drm/bridge/synopsys/dw-hdmi.h +5 -1
@@ -865,7 +865,11 @@ enum {/* AUD_CONF0 field values */ HDMI_AUD_CONF0_SW_RESET =0x80 , -HDMI_AUD_CONF0_I2S_ALL_ENABLE =0x2F , +HDMI_AUD_CONF0_I2S_SELECT =0x20 , +HDMI_AUD_CONF0_I2S_EN3 =0x08 , +HDMI_AUD_CONF0_I2S_EN2 =0x04 , +HDMI_AUD_CONF0_I2S_EN1 =0x02 , +HDMI_AUD_CONF0_I2S_EN0 =0x01 ,/* AUD_CONF1 field values */ HDMI_AUD_CONF1_MODE_I2S = 0x00,
Signature · 1 line
2.21.0
Jerome Brunet
reviewerPATCH 8/8 drm/bridge: dw-hdmi-i2s: add .get_eld support
In reply to Jerome BrunetProvide the eld to the generic hdmi-codec driver.
This will let the driver enforce the maximum channel number and set the channel allocation depending on the hdmi sink.
--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h | 1 + drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 10 ++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 1 + 3 files changed, 12 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h +1 -0
@@ -14,6 +14,7 @@ struct dw_hdmi_audio_data {struct dw_hdmi_i2s_audio_data {struct dw_hdmi *hdmi; +u8 *eld;void (*write)(struct dw_hdmi *hdmi,u8 val,int offset);u8 (*read)(struct dw_hdmi *hdmi,int offset);
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +10 -0
@@ -121,6 +121,15 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)dw_hdmi_audio_disable (hdmi); } +static int dw_hdmi_i2s_get_eld (struct device *dev,void *data,uint8_t *buf, +size_t len) +{ +struct dw_hdmi_i2s_audio_data *audio = data; + +memcpy (buf, audio->eld,min (sizeof (audio->eld), len)); +return 0 ; +} +static int dw_hdmi_i2s_get_dai_id (struct snd_soc_component *component,struct device_node *endpoint) {
@@ -144,6 +153,7 @@ static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,static struct hdmi_codec_ops dw_hdmi_i2s_ops = { .hw_params = dw_hdmi_i2s_hw_params, .audio_shutdown = dw_hdmi_i2s_audio_shutdown, + .get_eld = dw_hdmi_i2s_get_eld, .get_dai_id = dw_hdmi_i2s_get_dai_id, };
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -0
@@ -2797,6 +2797,7 @@ __dw_hdmi_probe(struct platform_device *pdev,struct dw_hdmi_i2s_audio_data audio; audio.hdmi = hdmi; + audio.eld = hdmi->connector.eld; audio.write = hdmi_writeb; audio.read = hdmi_readb; hdmi->enable_audio = dw_hdmi_i2s_audio_enable;
Signature · 1 line
2.21.0
Re: [PATCH 8/8] drm/bridge: dw-hdmi-i2s: add .get_eld support
Quoted 29 lines · Jerome Brunet
Provide the eld to the generic hdmi-codec driver.
This will let the driver enforce the maximum channel number and set the channel allocation depending on the hdmi sink.Cc Jonas Karlman <[email protected]>Signed-off-by Jerome Brunet <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h | 1 + drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 10 ++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 1 + 3 files changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h +1
-0@@ -14,6 +14,7 @@ struct dw_hdmi_audio_data {struct dw_hdmi_i2s_audio_data {struct dw_hdmi *hdmi; +u8 *eld;void (*write)(struct dw_hdmi *hdmi,u8 val,int offset);u8 (*read)(struct dw_hdmi *hdmi,int offset);drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +0
-0
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data) · line 129
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +6
-0@@ -121,6 +121,15 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)dw_hdmi_audio_disable (hdmi); } +static int dw_hdmi_i2s_get_eld (struct device *dev,void *data,uint8_t *buf, +size_t len) +{ +struct dw_hdmi_i2s_audio_data *audio = data; + +memcpy (buf, audio->eld,min (sizeof (audio->eld), len));
Above sizeof does not work as intended, sizeof(audio->eld) is probably the size of a pointer and not MAX_ELD_BYTES (128), resulting in only part of the ELD gets copied to buf.
Thanks for reworking dw-hdmi multi channel lpcm support!, this works on Rockchip for most parts.
Without the [1] patch (reset cts+n after clock is enabled) audio sometime stay silent when switching between e.g. 2ch 44.1khz and 6ch 48khz tracks. It is not fully clear to me why reset cts+n helps, if that have negative affects on other platforms or if there is another way to solve loosing audio.
I also have a small issue with the channel allocation being selected by hdmi-codec, my soundbar reports LPCM 6.1ch instead of LPCM 7.1ch when I play a 7.1ch speaker test clip. I have a hdmi-codec patch to fix selection of channel allocation in queue.
For patch 1-7:
[1] https://github.com/Kwiboo/linux-rockchip/commit/c0839e874f843ad173ddde958303d6878394ef92
Regards,
Jonas
Quoted 26 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +4
-0+return 0 ; +} +static int dw_hdmi_i2s_get_dai_id (struct snd_soc_component *component,struct device_node *endpoint) {@@ -144,6 +153,7 @@ static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,static struct hdmi_codec_ops dw_hdmi_i2s_ops = { .hw_params = dw_hdmi_i2s_hw_params, .audio_shutdown = dw_hdmi_i2s_audio_shutdown, + .get_eld = dw_hdmi_i2s_get_eld, .get_dai_id = dw_hdmi_i2s_get_dai_id, };drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-0@@ -2797,6 +2797,7 @@ __dw_hdmi_probe(struct platform_device *pdev,struct dw_hdmi_i2s_audio_data audio; audio.hdmi = hdmi; + audio.eld = hdmi->connector.eld; audio.write = hdmi_writeb; audio.read = hdmi_readb; hdmi->enable_audio = dw_hdmi_i2s_audio_enable;
Jerome Brunet
reviewerRe: [PATCH 8/8] drm/bridge: dw-hdmi-i2s: add .get_eld support
Quoted 33 lines · Jonas Karlman
Quoted 32 lines · Jerome Brunet
Provide the eld to the generic hdmi-codec driver.
This will let the driver enforce the maximum channel number and set the channel allocation depending on the hdmi sink.Cc Jonas Karlman <[email protected]>Signed-off-by Jerome Brunet <[email protected]>--- drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h | 1 + drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c | 10 ++++++++++ drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 1 + 3 files changed, 12 insertions(+)drivers/gpu/drm/bridge/synopsys/dw-hdmi-audio.h +1
-0@@ -14,6 +14,7 @@ struct dw_hdmi_audio_data {struct dw_hdmi_i2s_audio_data {struct dw_hdmi *hdmi; +u8 *eld;void (*write)(struct dw_hdmi *hdmi,u8 val,int offset);u8 (*read)(struct dw_hdmi *hdmi,int offset);drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +0
-0@@ -121,6 +121,15 @@ static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data)dw_hdmi_audio_disable (hdmi); }
Quoted 9 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c static void dw_hdmi_i2s_audio_shutdown(struct device *dev, void *data) · line 129
Quoted 6 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +6
-0+static int dw_hdmi_i2s_get_eld (struct device *dev,void *data,uint8_t *buf, +size_t len) +{ +struct dw_hdmi_i2s_audio_data *audio = data; + +memcpy (buf, audio->eld,min (sizeof (audio->eld), len));Above sizeof does not work as intended,
sizeof(audio->eld)is probably the size of a pointer and notMAX_ELD_BYTES(128), resulting in only part of the ELD gets copied to buf.
Silly ... thanks for pointing this out. I'll respin
Quoted 7 lines
Thanks for reworking dw-hdmi multi channel lpcm support!, this works on Rockchip for most parts.
Without the [1] patch (reset cts+n after clock is enabled) audio sometime stay silent when switching between e.g. 2ch 44.1khz and 6ch 48khz tracks. It is not fully clear to me why reset cts+n helps, if that have
negative affects on other platforms or if there is another way to
solve loosing audio.
I did not see that issue my self but I guess could propose this change ?
Quoted 4 lines
I also have a small issue with the channel allocation being selected by hdmi-codec, my soundbar reports LPCM 6.1ch instead of LPCM 7.1ch when I play a 7.1ch speaker test clip. I have a hdmi-codec patch to fix selection of channel allocation in
queue.
Yes, I know there is still a few problems around that and stale eld. But those problem are not really coming from the i2s interface of the dw-hdmi itself and should be dealt with separatly.
This is just the beginning ;)
Quoted 38 lines
For patch 1-7:
Reviewed-by Jonas Karlman <[email protected]>[1] https://github.com/Kwiboo/linux-rockchip/commit/c0839e874f843ad173ddde958303d6878394ef92
Regards,
JonasQuoted 26 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c +4
-0+return 0 ; +} +static int dw_hdmi_i2s_get_dai_id (struct snd_soc_component *component,struct device_node *endpoint) {@@ -144,6 +153,7 @@ static int dw_hdmi_i2s_get_dai_id(struct snd_soc_component *component,static struct hdmi_codec_ops dw_hdmi_i2s_ops = { .hw_params = dw_hdmi_i2s_hw_params, .audio_shutdown = dw_hdmi_i2s_audio_shutdown, + .get_eld = dw_hdmi_i2s_get_eld, .get_dai_id = dw_hdmi_i2s_get_dai_id, };drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1
-0@@ -2797,6 +2797,7 @@ __dw_hdmi_probe(struct platform_device *pdev,struct dw_hdmi_i2s_audio_data audio; audio.hdmi = hdmi; + audio.eld = hdmi->connector.eld; audio.write = hdmi_writeb; audio.read = hdmi_readb; hdmi->enable_audio = dw_hdmi_i2s_audio_enable;