Skip to content

Commit 41180de

Browse files
AngeloGioacchino Del RegnoChun-Kuang Hu
authored andcommitted
drm/mediatek: mtk_dpi: Move pixel clock setting flow to function
In preparation for adding support for the DPI IP found in MT8195 and in MT8188 used for HDMI, move the code flow for calculation and setting of the DPI pixel clock to a separate function called mtk_dpi_set_pixel_clk(). This was done because, on those platforms, the DPI instance that is used for HDMI will get its pixel clock from the HDMI clock, hence it is not necessary, nor desirable, to calculate or set the pixel clock in DPI. Reviewed-by: CK Hu <[email protected]> Signed-off-by: AngeloGioacchino Del Regno <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 9f16387 commit 41180de

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

drivers/gpu/drm/mediatek/mtk_dpi.c

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -537,26 +537,17 @@ static unsigned int mtk_dpi_calculate_factor(struct mtk_dpi *dpi, int mode_clk)
537537
return dpi_factor[dpi->conf->num_dpi_factor - 1].factor;
538538
}
539539

540-
static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
541-
struct drm_display_mode *mode)
540+
static void mtk_dpi_set_pixel_clk(struct mtk_dpi *dpi, struct videomode *vm, int mode_clk)
542541
{
543-
struct mtk_dpi_polarities dpi_pol;
544-
struct mtk_dpi_sync_param hsync;
545-
struct mtk_dpi_sync_param vsync_lodd = { 0 };
546-
struct mtk_dpi_sync_param vsync_leven = { 0 };
547-
struct mtk_dpi_sync_param vsync_rodd = { 0 };
548-
struct mtk_dpi_sync_param vsync_reven = { 0 };
549-
struct videomode vm = { 0 };
550542
unsigned long pll_rate;
551543
unsigned int factor;
552544

553545
/* let pll_rate can fix the valid range of tvdpll (1G~2GHz) */
554-
factor = mtk_dpi_calculate_factor(dpi, mode->clock);
555-
drm_display_mode_to_videomode(mode, &vm);
556-
pll_rate = vm.pixelclock * factor;
546+
factor = mtk_dpi_calculate_factor(dpi, mode_clk);
547+
pll_rate = vm->pixelclock * factor;
557548

558549
dev_dbg(dpi->dev, "Want PLL %lu Hz, pixel clock %lu Hz\n",
559-
pll_rate, vm.pixelclock);
550+
pll_rate, vm->pixelclock);
560551

561552
clk_set_rate(dpi->tvd_clk, pll_rate);
562553
pll_rate = clk_get_rate(dpi->tvd_clk);
@@ -566,20 +557,34 @@ static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
566557
* pixels for each iteration: divide the clock by this number and
567558
* adjust the display porches accordingly.
568559
*/
569-
vm.pixelclock = pll_rate / factor;
570-
vm.pixelclock /= dpi->conf->pixels_per_iter;
560+
vm->pixelclock = pll_rate / factor;
561+
vm->pixelclock /= dpi->conf->pixels_per_iter;
571562

572563
if ((dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_LE) ||
573564
(dpi->output_fmt == MEDIA_BUS_FMT_RGB888_2X12_BE))
574-
clk_set_rate(dpi->pixel_clk, vm.pixelclock * 2);
565+
clk_set_rate(dpi->pixel_clk, vm->pixelclock * 2);
575566
else
576-
clk_set_rate(dpi->pixel_clk, vm.pixelclock);
567+
clk_set_rate(dpi->pixel_clk, vm->pixelclock);
577568

578-
579-
vm.pixelclock = clk_get_rate(dpi->pixel_clk);
569+
vm->pixelclock = clk_get_rate(dpi->pixel_clk);
580570

581571
dev_dbg(dpi->dev, "Got PLL %lu Hz, pixel clock %lu Hz\n",
582-
pll_rate, vm.pixelclock);
572+
pll_rate, vm->pixelclock);
573+
}
574+
575+
static int mtk_dpi_set_display_mode(struct mtk_dpi *dpi,
576+
struct drm_display_mode *mode)
577+
{
578+
struct mtk_dpi_polarities dpi_pol;
579+
struct mtk_dpi_sync_param hsync;
580+
struct mtk_dpi_sync_param vsync_lodd = { 0 };
581+
struct mtk_dpi_sync_param vsync_leven = { 0 };
582+
struct mtk_dpi_sync_param vsync_rodd = { 0 };
583+
struct mtk_dpi_sync_param vsync_reven = { 0 };
584+
struct videomode vm = { 0 };
585+
586+
drm_display_mode_to_videomode(mode, &vm);
587+
mtk_dpi_set_pixel_clk(dpi, &vm, mode->clock);
583588

584589
dpi_pol.ck_pol = MTK_DPI_POLARITY_FALLING;
585590
dpi_pol.de_pol = MTK_DPI_POLARITY_RISING;

0 commit comments

Comments
 (0)