]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/mediatek: mtk_dpi: Use an array for pixclk factor calculation
authorAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Mon, 17 Feb 2025 15:47:56 +0000 (16:47 +0100)
committerChun-Kuang Hu <chunkuang.hu@kernel.org>
Sun, 2 Mar 2025 10:48:24 +0000 (10:48 +0000)
commit9f163874b30ab8cd74d3858f557d0be52d3b1969
treea1203c44921748a56c57222d853f1262a35f64a4
parent1deb6ed55ab1322e917cf48647274e72466ba046
drm/mediatek: mtk_dpi: Use an array for pixclk factor calculation

Setting the TVD PLL clock requires to multiply the target pixel
clock by a specific constant factor to achieve the target PLL
frequency, and this is done to reduce jitter to acceptable levels.

On all MediaTek SoCs, the factor is not retrieved by any real kind
of calculation but rather by checking if the target pixel clock
is less than a specified frequency, hence assigning a function
pointer for just a bunch of if branches does enlarge the code
size for little reason.

Remove all SoC-specific functions, add a structure `mtk_dpi_factor`
that holds a clock frequency and corresponding PLL factor, and
declare the constraints for each SoC in form of an array of said
structure.
Instead of function pointers, this structure (and its size) is then
assigned to each SoC's platform data.

The "calculation" is then performed with a new static function
mtk_dpi_calculate_factor(dpi, mode_clk) that iterates through all
of the entries of the aforementioned array and returns the right
factor.

If no factor is found, the lowest possible factor is returned,
mimicking the same flow as all of the old per-SoC calculation
functions.

This commit brings no functional change.

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/20250217154836.108895-4-angelogioacchino.delregno@collabora.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
drivers/gpu/drm/mediatek/mtk_dpi.c