Re: [PATCH 1/1] drm/mediatek: fine tune the dsi panel's power sequence

2019-11-08 Thread kbuild test robot
Hi Jitao,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc6 next-20191108]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:
https://github.com/0day-ci/linux/commits/Jitao-Shi/drm-mediatek-fine-tune-the-dsi-panel-s-power-sequence/20191108-202844
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
847120f859cc45e074204f4cf33c8df069306eb2
config: arm-allmodconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 7.4.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=arm 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All errors (new ones prefixed by >>):

   drivers/gpu/drm/mediatek/mtk_dsi.c: In function 'mtk_dsi_poweron':
>> drivers/gpu/drm/mediatek/mtk_dsi.c:567:7: error: implicit declaration of 
>> function 'drm_panel_prepare_power'; did you mean 'drm_panel_prepare'? 
>> [-Werror=implicit-function-declaration]
  if (drm_panel_prepare_power(dsi->panel))
  ^~~
  drm_panel_prepare
>> drivers/gpu/drm/mediatek/mtk_dsi.c:622:7: error: implicit declaration of 
>> function 'drm_panel_unprepare_power'; did you mean 'drm_panel_unprepare'? 
>> [-Werror=implicit-function-declaration]
  if (drm_panel_unprepare_power(dsi->panel))
  ^
  drm_panel_unprepare
   cc1: some warnings being treated as errors

vim +567 drivers/gpu/drm/mediatek/mtk_dsi.c

   522  
   523  static int mtk_dsi_poweron(struct mtk_dsi *dsi)
   524  {
   525  struct device *dev = dsi->dev;
   526  int ret;
   527  u64 pixel_clock, total_bits;
   528  u32 htotal, htotal_bits, bit_per_pixel, overhead_cycles, 
overhead_bits;
   529  
   530  if (++dsi->refcount != 1)
   531  return 0;
   532  
   533  switch (dsi->format) {
   534  case MIPI_DSI_FMT_RGB565:
   535  bit_per_pixel = 16;
   536  break;
   537  case MIPI_DSI_FMT_RGB666_PACKED:
   538  bit_per_pixel = 18;
   539  break;
   540  case MIPI_DSI_FMT_RGB666:
   541  case MIPI_DSI_FMT_RGB888:
   542  default:
   543  bit_per_pixel = 24;
   544  break;
   545  }
   546  
   547  /**
   548   * htotal_time = htotal * byte_per_pixel / num_lanes
   549   * overhead_time = lpx + hs_prepare + hs_zero + hs_trail + 
hs_exit
   550   * mipi_ratio = (htotal_time + overhead_time) / htotal_time
   551   * data_rate = pixel_clock * bit_per_pixel * mipi_ratio / 
num_lanes;
   552   */
   553  pixel_clock = dsi->vm.pixelclock;
   554  htotal = dsi->vm.hactive + dsi->vm.hback_porch + 
dsi->vm.hfront_porch +
   555  dsi->vm.hsync_len;
   556  htotal_bits = htotal * bit_per_pixel;
   557  
   558  overhead_cycles = T_LPX + T_HS_PREP + T_HS_ZERO + T_HS_TRAIL +
   559  T_HS_EXIT;
   560  overhead_bits = overhead_cycles * dsi->lanes * 8;
   561  total_bits = htotal_bits + overhead_bits;
   562  
   563  dsi->data_rate = DIV_ROUND_UP_ULL(pixel_clock * total_bits,
   564htotal * dsi->lanes);
   565  
   566  if (dsi->panel) {
 > 567  if (drm_panel_prepare_power(dsi->panel))
   568  DRM_INFO("can't prepare power the panel\n");
   569  }
   570  
   571  ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
   572  if (ret < 0) {
   573  dev_err(dev, "Failed to set data rate: %d\n", ret);
   574  goto err_prepare_power;
   575  }
   576  
   577  phy_power_on(dsi->phy);
   578  
   579  ret = clk_prepare_enable(dsi->engine_clk);
   580  if (ret < 0) {
   581  dev_err(dev, "Failed to enable engine clock: %d\n", 
ret);
   582  goto err_phy_power_off;
   583  }
   584  
   585  ret = clk_prepare_enable(dsi->digital_clk);
   586  if (ret < 0) {
   587  dev_err(dev, "Failed to enable digital clock: %d\n", 
ret);
   588  goto err_disable_engine_clk;
   589  }
   590  
   591  mtk_dsi_enable(dsi);
   592  mtk_dsi_reset_engine(dsi);
   593  mtk_dsi_phy_timconfig(dsi);
   594  
   595  mtk_dsi_rxtx_control(dsi);
   596  mtk_dsi_ps_control_vact(dsi);
   597

[PATCH 1/1] drm/mediatek: fine tune the dsi panel's power sequence

2019-11-06 Thread Jitao Shi
Add the drm_panel_prepare_power and drm_panel_unprepare_power control.
Turn on panel power(drm_panel_prepare_power) and control before dsi
enable. And then dsi enable, send dcs cmd in drm_panel_prepare, last
turn on backlight.

Signed-off-by: Jitao Shi 
---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c 
b/drivers/gpu/drm/mediatek/mtk_dsi.c
index 224afb666881..b635724b209b 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -563,10 +563,15 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
dsi->data_rate = DIV_ROUND_UP_ULL(pixel_clock * total_bits,
  htotal * dsi->lanes);
 
+   if (dsi->panel) {
+   if (drm_panel_prepare_power(dsi->panel))
+   DRM_INFO("can't prepare power the panel\n");
+   }
+
ret = clk_set_rate(dsi->hs_clk, dsi->data_rate);
if (ret < 0) {
dev_err(dev, "Failed to set data rate: %d\n", ret);
-   goto err_refcount;
+   goto err_prepare_power;
}
 
phy_power_on(dsi->phy);
@@ -605,13 +610,18 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)
}
 
return 0;
+
 err_disable_digital_clk:
clk_disable_unprepare(dsi->digital_clk);
 err_disable_engine_clk:
clk_disable_unprepare(dsi->engine_clk);
 err_phy_power_off:
phy_power_off(dsi->phy);
-err_refcount:
+err_prepare_power:
+   if (dsi->panel) {
+   if (drm_panel_unprepare_power(dsi->panel))
+   DRM_INFO("Can't unprepare power the panel\n");
+   }
dsi->refcount--;
return ret;
 }
@@ -652,6 +662,11 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
clk_disable_unprepare(dsi->digital_clk);
 
phy_power_off(dsi->phy);
+
+   if (dsi->panel) {
+   if (drm_panel_unprepare_power(dsi->panel))
+   DRM_INFO("Can't unprepare power the panel\n");
+   }
 }
 
 static void mtk_output_dsi_enable(struct mtk_dsi *dsi)
-- 
2.21.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel