@@ -444,7 +444,10 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
444444 u32 horizontal_sync_active_byte ;
445445 u32 horizontal_backporch_byte ;
446446 u32 horizontal_frontporch_byte ;
447+ u32 horizontal_front_back_byte ;
448+ u32 data_phy_cycles_byte ;
447449 u32 dsi_tmp_buf_bpp , data_phy_cycles ;
450+ u32 delta ;
448451 struct mtk_phy_timing * timing = & dsi -> phy_timing ;
449452
450453 struct videomode * vm = & dsi -> vm ;
@@ -466,50 +469,30 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
466469 horizontal_sync_active_byte = (vm -> hsync_len * dsi_tmp_buf_bpp - 10 );
467470
468471 if (dsi -> mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE )
469- horizontal_backporch_byte = vm -> hback_porch * dsi_tmp_buf_bpp ;
472+ horizontal_backporch_byte = vm -> hback_porch * dsi_tmp_buf_bpp - 10 ;
470473 else
471474 horizontal_backporch_byte = (vm -> hback_porch + vm -> hsync_len ) *
472- dsi_tmp_buf_bpp ;
475+ dsi_tmp_buf_bpp - 10 ;
473476
474477 data_phy_cycles = timing -> lpx + timing -> da_hs_prepare +
475- timing -> da_hs_zero + timing -> da_hs_exit ;
476-
477- if (dsi -> mode_flags & MIPI_DSI_MODE_VIDEO_BURST ) {
478- if ((vm -> hfront_porch + vm -> hback_porch ) * dsi_tmp_buf_bpp >
479- data_phy_cycles * dsi -> lanes + 18 ) {
480- horizontal_frontporch_byte =
481- vm -> hfront_porch * dsi_tmp_buf_bpp -
482- (data_phy_cycles * dsi -> lanes + 18 ) *
483- vm -> hfront_porch /
484- (vm -> hfront_porch + vm -> hback_porch );
485-
486- horizontal_backporch_byte =
487- horizontal_backporch_byte -
488- (data_phy_cycles * dsi -> lanes + 18 ) *
489- vm -> hback_porch /
490- (vm -> hfront_porch + vm -> hback_porch );
491- } else {
492- DRM_WARN ("HFP less than d-phy, FPS will under 60Hz\n" );
493- horizontal_frontporch_byte = vm -> hfront_porch *
494- dsi_tmp_buf_bpp ;
495- }
478+ timing -> da_hs_zero + timing -> da_hs_exit + 3 ;
479+
480+ delta = dsi -> mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 : 12 ;
481+
482+ horizontal_frontporch_byte = vm -> hfront_porch * dsi_tmp_buf_bpp ;
483+ horizontal_front_back_byte = horizontal_frontporch_byte + horizontal_backporch_byte ;
484+ data_phy_cycles_byte = data_phy_cycles * dsi -> lanes + delta ;
485+
486+ if (horizontal_front_back_byte > data_phy_cycles_byte ) {
487+ horizontal_frontporch_byte -= data_phy_cycles_byte *
488+ horizontal_frontporch_byte /
489+ horizontal_front_back_byte ;
490+
491+ horizontal_backporch_byte -= data_phy_cycles_byte *
492+ horizontal_backporch_byte /
493+ horizontal_front_back_byte ;
496494 } else {
497- if ((vm -> hfront_porch + vm -> hback_porch ) * dsi_tmp_buf_bpp >
498- data_phy_cycles * dsi -> lanes + 12 ) {
499- horizontal_frontporch_byte =
500- vm -> hfront_porch * dsi_tmp_buf_bpp -
501- (data_phy_cycles * dsi -> lanes + 12 ) *
502- vm -> hfront_porch /
503- (vm -> hfront_porch + vm -> hback_porch );
504- horizontal_backporch_byte = horizontal_backporch_byte -
505- (data_phy_cycles * dsi -> lanes + 12 ) *
506- vm -> hback_porch /
507- (vm -> hfront_porch + vm -> hback_porch );
508- } else {
509- DRM_WARN ("HFP less than d-phy, FPS will under 60Hz\n" );
510- horizontal_frontporch_byte = vm -> hfront_porch *
511- dsi_tmp_buf_bpp ;
512- }
495+ DRM_WARN ("HFP + HBP less than d-phy, FPS will under 60Hz\n" );
513496 }
514497
515498 writel (horizontal_sync_active_byte , dsi -> regs + DSI_HSA_WC );
0 commit comments