]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/mediatek: mtk_hdmi: Move N/CTS setting to new function
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Tue, 15 Apr 2025 10:43:09 +0000 (12:43 +0200)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Mon, 21 Apr 2025 13:40:02 +0000 (13:40 +0000)
In preparation for splitting common bits of this driver, moving
the hdmi_rec_n_table struct array, and the hdmi_recommended_n(),
hdmi_mode_clock_to_hz(), hdmi_expected_cts() functions, add one
function called mtk_hdmi_get_ncts() that sets both N and CTS in
a single call.

Reviewed-by: CK Hu <ck.hu@mediatek.com>
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20250415104321.51149-12-angelogioacchino.delregno@collabora.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
drivers/gpu/drm/mediatek/mtk_hdmi.c

index 60ec16f6827ff057b861850ed8420c8486a7d2e3..0933b22b81ff4a9907a8d8db486d94e4dda00173 100644 (file)
@@ -675,6 +675,13 @@ static unsigned int hdmi_expected_cts(unsigned int audio_sample_rate,
                                     128 * audio_sample_rate);
 }
 
+static void mtk_hdmi_get_ncts(unsigned int sample_rate, unsigned int clock,
+                             unsigned int *n, unsigned int *cts)
+{
+       *n = hdmi_recommended_n(sample_rate, clock);
+       *cts = hdmi_expected_cts(sample_rate, clock, *n);
+}
+
 static void do_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi, unsigned int n,
                                    unsigned int cts)
 {
@@ -705,8 +712,7 @@ static void mtk_hdmi_hw_aud_set_ncts(struct mtk_hdmi *hdmi,
 {
        unsigned int n, cts;
 
-       n = hdmi_recommended_n(sample_rate, clock);
-       cts = hdmi_expected_cts(sample_rate, clock, n);
+       mtk_hdmi_get_ncts(sample_rate, clock, &n, &cts);
 
        dev_dbg(hdmi->dev, "%s: sample_rate=%u, clock=%d, cts=%u, n=%u\n",
                __func__, sample_rate, clock, n, cts);