Skip to content

Commit

Permalink
Apply insert_pcuv patch
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaris committed Sep 7, 2024
1 parent cea19e5 commit 0fb2430
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
28 changes: 28 additions & 0 deletions drivers/gpu/drm/bridge/synopsys/dw-hdmi-i2s-audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static int dw_hdmi_i2s_prepare(struct device *dev, void *data,
struct dw_hdmi *hdmi = audio->hdmi;
u8 conf0 = 0;
u8 conf1 = 0;
u8 conf2 = 0;
u8 inputclkfs = 0;

/* it cares I2S only */
Expand All @@ -50,6 +51,8 @@ static int dw_hdmi_i2s_prepare(struct device *dev, void *data,
return -EINVAL;
}

dev_info(dev, "before reset AUD_CONF2=%x\n", hdmi_read(audio, HDMI_AUD_CONF2));

/* 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);
Expand Down Expand Up @@ -101,6 +104,30 @@ static int dw_hdmi_i2s_prepare(struct device *dev, void *data,
return -EINVAL;
}

/*
* dw-hdmi introduced insert_pcuv bit in
* version 2.10a.
*
* This single bit (bit 2 of HDMI_AUD_CONF2)
* when set to 1 will enable the insertion of the PCUV
* (Parity, Channel Status, User bit and Validity)
* bits on the incoming audio stream.
*
* Support is limited to Linear PCM audio. If
* neglected, the lack of valid PCUV bits
* on L-PCM streams will cause anything from
* mild cracking to full blown extreme
* clipping depending on the HDMI audio
* implementation of the sink.
*
*/

if (hdmi_read(audio, HDMI_DESIGN_ID) >= 0x21 &&
!(hparms->iec.status[0] & IEC958_AES0_NONAUDIO)) {
dev_info(dev, "after reset AUD_CONF2=%x\n", hdmi_read(audio, HDMI_AUD_CONF2));
conf2 = HDMI_AUD_CONF2_INSERT_PCUV;
}

dw_hdmi_set_sample_rate(hdmi, hparms->sample_rate);
dw_hdmi_set_channel_status(hdmi, hparms->iec.status);
dw_hdmi_set_channel_count(hdmi, hparms->channels);
Expand All @@ -109,6 +136,7 @@ static int dw_hdmi_i2s_prepare(struct device *dev, void *data,
hdmi_write(audio, inputclkfs, HDMI_AUD_INPUTCLKFS);
hdmi_write(audio, conf0, HDMI_AUD_CONF0);
hdmi_write(audio, conf1, HDMI_AUD_CONF1);
hdmi_write(audio, conf2, HDMI_AUD_CONF2);

return 0;
}
Expand Down
5 changes: 5 additions & 0 deletions drivers/gpu/drm/bridge/synopsys/dw-hdmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ enum {
HDMI_AUD_CONF1_WIDTH_16 = 0x10,
HDMI_AUD_CONF1_WIDTH_24 = 0x18,

/* AUD_CONF2 field values */
HDMI_AUD_CONF2_HBR = 0x01,
HDMI_AUD_CONF2_NLPCM = 0x02,
HDMI_AUD_CONF2_INSERT_PCUV = 0x04,

/* AUD_CTS3 field values */
HDMI_AUD_CTS3_N_SHIFT_OFFSET = 5,
HDMI_AUD_CTS3_N_SHIFT_MASK = 0xe0,
Expand Down

0 comments on commit 0fb2430

Please sign in to comment.