From 24edb38f8fc6fec74fdea5ae5a7f9c1f0d46c290 Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Tue, 18 Feb 2025 16:14:33 +0800 Subject: [PATCH] drm/bridge: synopsys: dw-hdmi: Add support for cts-manual The current driver use HDMI hardware's auto CTS mode. We found that at high sample rates, the auto-calculated CTS value is incorrect, leading to silent outputs on devices that rely on n/cts to recover the sample rate, such as TV. Auto CTS mode was introduced in commit fdbdcc83ffd7 ("drm/bridge: dw-hdmi: Use automatic CTS generation mode when using non-AHB audio") to handle cases where audio clock and TMDS clock are not sourced from the same PLL. However, on RK platforms where both clocks are derived from the same PLL. This patch adds a "cts-manual" property to allow manual CTS configuration when clocks are co-sourced. Fixes: fdbdcc83ffd7 ("drm/bridge: dw-hdmi: Use automatic CTS generation mode when using non-AHB audio") Signed-off-by: Sugar Zhang Change-Id: I2f52499150d3e37652e21c0b863447e1a6ac5831 --- drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c index 169c60893248..0fcb06c19297 100644 --- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c @@ -335,6 +335,7 @@ struct dw_hdmi { bool logo_plug_out; /* hdmi is plug out when kernel logo */ bool update; bool hdr2sdr; /* from hdr to sdr */ + bool cts_manual; }; #define HDMI_IH_PHY_STAT0_RX_SENSE \ @@ -1068,7 +1069,7 @@ static void hdmi_set_clk_regenerator(struct dw_hdmi *hdmi, config3 = hdmi_readb(hdmi, HDMI_CONFIG3_ID); /* Compute CTS when using internal AHB audio or General Parallel audio*/ - if ((config3 & HDMI_CONFIG3_AHBAUDDMA) || (config3 & HDMI_CONFIG3_GPAUD)) { + if ((config3 & HDMI_CONFIG3_AHBAUDDMA) || (config3 & HDMI_CONFIG3_GPAUD) || hdmi->cts_manual) { /* * Compute the CTS value from the N value. Note that CTS and N * can be up to 20 bits in total, so we need 64-bit math. Also @@ -5207,6 +5208,8 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, config0 = hdmi_readb(hdmi, HDMI_CONFIG0_ID); config3 = hdmi_readb(hdmi, HDMI_CONFIG3_ID); + hdmi->cts_manual = of_property_read_bool(np, "rockchip,cts-manual"); + if (iores && config3 & HDMI_CONFIG3_AHBAUDDMA) { struct dw_hdmi_audio_data audio;