Commit 095db161b236ba398de79691937d7fb63bd498be

Authored by Fancy Fang
1 parent 9c4609783e

MLK-21150-2 drm/bridge: sec-dsim: refine hblank word count compute

When there is no existing horizontal blanking word counts in
'dsim_hblank_par' tables, these data requires to be computed
according to the 'hfp', 'hbp' and 'hsa' timings which are in
pixel unit. So the pixel unit data requires to be converted
to word count unit data correctly to match the PLL output clk
frequency.

Signed-off-by: Fancy Fang <chen.fang@nxp.com>
(cherry picked from commit af9ab0d4362d9298978e2ac62033f65ea1cc09ed)

Showing 1 changed file with 19 additions and 6 deletions Side-by-side Diff

drivers/gpu/drm/bridge/sec-dsim.c
... ... @@ -265,6 +265,10 @@
265 265  
266 266 #define MIPI_FIFO_TIMEOUT msecs_to_jiffies(250)
267 267  
  268 +#define MIPI_HFP_PKT_OVERHEAD 6
  269 +#define MIPI_HBP_PKT_OVERHEAD 6
  270 +#define MIPI_HSA_PKT_OVERHEAD 6
  271 +
268 272 #define to_sec_mipi_dsim(dsi) container_of(dsi, struct sec_mipi_dsim, dsi_host)
269 273 #define conn_to_sec_mipi_dsim(conn) \
270 274 container_of(conn, struct sec_mipi_dsim, connector)
... ... @@ -863,7 +867,7 @@
863 867  
864 868 static void sec_mipi_dsim_set_main_mode(struct sec_mipi_dsim *dsim)
865 869 {
866   - uint32_t bpp, hfp_wc, hbp_wc, hsa_wc;
  870 + uint32_t bpp, hfp_wc, hbp_wc, hsa_wc, wc;
867 871 uint32_t mdresol = 0, mvporch = 0, mhporch = 0, msync = 0;
868 872 struct videomode *vmode = &dsim->vmode;
869 873  
... ... @@ -880,8 +884,14 @@
880 884  
881 885 /* calculate hfp & hbp word counts */
882 886 if (dsim->panel || !dsim->hpar) {
883   - hfp_wc = vmode->hfront_porch * (bpp >> 3);
884   - hbp_wc = vmode->hback_porch * (bpp >> 3);
  887 + wc = DIV_ROUND_UP(vmode->hfront_porch * (bpp >> 3),
  888 + dsim->lanes);
  889 + hfp_wc = wc > MIPI_HFP_PKT_OVERHEAD ?
  890 + wc - MIPI_HFP_PKT_OVERHEAD : vmode->hfront_porch;
  891 + wc = DIV_ROUND_UP(vmode->hback_porch * (bpp >> 3),
  892 + dsim->lanes);
  893 + hbp_wc = wc > MIPI_HBP_PKT_OVERHEAD ?
  894 + wc - MIPI_HBP_PKT_OVERHEAD : vmode->hback_porch;
885 895 } else {
886 896 hfp_wc = dsim->hpar->hfp_wc;
887 897 hbp_wc = dsim->hpar->hbp_wc;
... ... @@ -893,9 +903,12 @@
893 903 dsim_write(dsim, mhporch, DSIM_MHPORCH);
894 904  
895 905 /* calculate hsa word counts */
896   - if (dsim->panel || !dsim->hpar)
897   - hsa_wc = vmode->hsync_len * (bpp >> 3);
898   - else
  906 + if (dsim->panel || !dsim->hpar) {
  907 + wc = DIV_ROUND_UP(vmode->hsync_len * (bpp >> 3),
  908 + dsim->lanes);
  909 + hsa_wc = wc > MIPI_HSA_PKT_OVERHEAD ?
  910 + wc - MIPI_HSA_PKT_OVERHEAD : vmode->hsync_len;
  911 + } else
899 912 hsa_wc = dsim->hpar->hsa_wc;
900 913  
901 914 msync |= MSYNC_SET_MAINVSA(vmode->vsync_len) |