Linux-mediatek Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "Shuijing Li (李水静)" <Shuijing.Li@mediatek.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"Jitao Shi (石记涛)" <jitao.shi@mediatek.com>,
	"daniel@ffwll.ch" <daniel@ffwll.ch>,
	"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>
Subject: Re: [PATCH v4] drm/mediatek: dsi: Add dsi per-frame lp code for mt8188
Date: Fri, 9 Aug 2024 08:15:44 +0000	[thread overview]
Message-ID: <ac28d576de8ef20ff0927fc1779c7ede57c8d251.camel@mediatek.com> (raw)
In-Reply-To: <20240801081144.22372-1-shuijing.li@mediatek.com>

Hi, Shuijing:

On Thu, 2024-08-01 at 16:11 +0800, Shuijing Li wrote:
> Adding the per-frame lp function of mt8188, which can keep HFP in HS and
> reduce the time required for each line to enter and exit low power.
> Per Frame LP:
>   |<----------One Active Frame-------->|
> --______________________________________----___________________
>   ^HSA+HBP^^RGB^^HFP^^HSA+HBP^^RGB^^HFP^    ^HSA+HBP^^RGB^^HFP^
> 
> Per Line LP:
>   |<---------------One Active Frame----------->|
> --______________--______________--______________----______________
>   ^HSA+HBP^^RGB^  ^HSA+HBP^^RGB^  ^HSA+HBP^^RGB^    ^HSA+HBP^^RGB^
> 
> Signed-off-by: Shuijing Li <shuijing.li@mediatek.com>
> ---

[snip]

> +
>  static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
>  {
>  	u32 horizontal_sync_active_byte;
> @@ -449,57 +560,61 @@ static void mtk_dsi_config_vdo_timing(struct mtk_dsi *dsi)
>  	writel(vm->vfront_porch, dsi->regs + DSI_VFP_NL);
>  	writel(vm->vactive, dsi->regs + DSI_VACT_NL);
>  
> -	if (dsi->driver_data->has_size_ctl)
> -		writel(FIELD_PREP(DSI_HEIGHT, vm->vactive) |
> -		       FIELD_PREP(DSI_WIDTH, vm->hactive),
> -		       dsi->regs + DSI_SIZE_CON);

If support_per_frame_lp is true, this code would not be execute,
but has_size_ctl is true in mt8188.
Does this mean when support_per_frame_lp is true, has_size_ctl should be false?

Regards,
CK

> -
> -	horizontal_sync_active_byte = (vm->hsync_len * dsi_tmp_buf_bpp - 10);
> -
> -	if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
> -		horizontal_backporch_byte = vm->hback_porch * dsi_tmp_buf_bpp - 10;
> -	else
> -		horizontal_backporch_byte = (vm->hback_porch + vm->hsync_len) *
> -					    dsi_tmp_buf_bpp - 10;
> -
> -	data_phy_cycles = timing->lpx + timing->da_hs_prepare +
> -			  timing->da_hs_zero + timing->da_hs_exit + 3;
> -
> -	delta = dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 : 12;
> -	delta += dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET ? 0 : 2;
> +	if (dsi->driver_data->support_per_frame_lp)
> +		mtk_dsi_config_vdo_timing_per_frame_lp(dsi);
> +	else {
> +		if (dsi->driver_data->has_size_ctl)
> +			writel(FIELD_PREP(DSI_HEIGHT, vm->vactive) |
> +				FIELD_PREP(DSI_WIDTH, vm->hactive),
> +				dsi->regs + DSI_SIZE_CON);
>  
> -	horizontal_frontporch_byte = vm->hfront_porch * dsi_tmp_buf_bpp;
> -	horizontal_front_back_byte = horizontal_frontporch_byte + horizontal_backporch_byte;
> -	data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta;
> +		horizontal_sync_active_byte = (vm->hsync_len * dsi_tmp_buf_bpp - 10);
>  
> -	if (horizontal_front_back_byte > data_phy_cycles_byte) {
> -		horizontal_frontporch_byte -= data_phy_cycles_byte *
> -					      horizontal_frontporch_byte /
> -					      horizontal_front_back_byte;
> -
> -		horizontal_backporch_byte -= data_phy_cycles_byte *
> -					     horizontal_backporch_byte /
> -					     horizontal_front_back_byte;
> -	} else {
> -		DRM_WARN("HFP + HBP less than d-phy, FPS will under 60Hz\n");
> -	}
> -
> -	if ((dsi->mode_flags & MIPI_DSI_HS_PKT_END_ALIGNED) &&
> -	    (dsi->lanes == 4)) {
> -		horizontal_sync_active_byte =
> -			roundup(horizontal_sync_active_byte, dsi->lanes) - 2;
> -		horizontal_frontporch_byte =
> -			roundup(horizontal_frontporch_byte, dsi->lanes) - 2;
> -		horizontal_backporch_byte =
> -			roundup(horizontal_backporch_byte, dsi->lanes) - 2;
> -		horizontal_backporch_byte -=
> -			(vm->hactive * dsi_tmp_buf_bpp + 2) % dsi->lanes;
> +		if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE)
> +			horizontal_backporch_byte = vm->hback_porch * dsi_tmp_buf_bpp - 10;
> +		else
> +			horizontal_backporch_byte = (vm->hback_porch + vm->hsync_len) *
> +							dsi_tmp_buf_bpp - 10;
> +
> +		data_phy_cycles = timing->lpx + timing->da_hs_prepare +
> +				timing->da_hs_zero + timing->da_hs_exit + 3;
> +
> +		delta = dsi->mode_flags & MIPI_DSI_MODE_VIDEO_BURST ? 18 : 12;
> +		delta += dsi->mode_flags & MIPI_DSI_MODE_NO_EOT_PACKET ? 0 : 2;
> +
> +		horizontal_frontporch_byte = vm->hfront_porch * dsi_tmp_buf_bpp;
> +		horizontal_front_back_byte = horizontal_frontporch_byte + horizontal_backporch_byte;
> +		data_phy_cycles_byte = data_phy_cycles * dsi->lanes + delta;
> +
> +		if (horizontal_front_back_byte > data_phy_cycles_byte) {
> +			horizontal_frontporch_byte -= data_phy_cycles_byte *
> +							horizontal_frontporch_byte /
> +							horizontal_front_back_byte;
> +
> +			horizontal_backporch_byte -= data_phy_cycles_byte *
> +							horizontal_backporch_byte /
> +							horizontal_front_back_byte;
> +		} else {
> +			DRM_WARN("HFP + HBP less than d-phy, FPS will under 60Hz\n");
> +		}
> +
> +		if ((dsi->mode_flags & MIPI_DSI_HS_PKT_END_ALIGNED) &&
> +			(dsi->lanes == 4)) {
> +			horizontal_sync_active_byte =
> +				roundup(horizontal_sync_active_byte, dsi->lanes) - 2;
> +			horizontal_frontporch_byte =
> +				roundup(horizontal_frontporch_byte, dsi->lanes) - 2;
> +			horizontal_backporch_byte =
> +				roundup(horizontal_backporch_byte, dsi->lanes) - 2;
> +			horizontal_backporch_byte -=
> +				(vm->hactive * dsi_tmp_buf_bpp + 2) % dsi->lanes;
> +		}
> +
> +		writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC);
> +		writel(horizontal_backporch_byte, dsi->regs + DSI_HBP_WC);
> +		writel(horizontal_frontporch_byte, dsi->regs + DSI_HFP_WC);
>  	}
>  
> -	writel(horizontal_sync_active_byte, dsi->regs + DSI_HSA_WC);
> -	writel(horizontal_backporch_byte, dsi->regs + DSI_HBP_WC);
> -	writel(horizontal_frontporch_byte, dsi->regs + DSI_HFP_WC);
> -
>  	mtk_dsi_ps_control(dsi, false);
>  }
>  
> @@ -1197,6 +1312,7 @@ static const struct mtk_dsi_driver_data mt8188_dsi_driver_data = {
>  	.has_shadow_ctl = true,
>  	.has_size_ctl = true,
>  	.cmdq_long_packet_ctl = true,
> +	.support_per_frame_lp = true,
>  };
>  

  parent reply	other threads:[~2024-08-09  8:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-01  8:11 [PATCH v4] drm/mediatek: dsi: Add dsi per-frame lp code for mt8188 Shuijing Li
2024-08-01  8:47 ` AngeloGioacchino Del Regno
2024-08-09  8:15 ` CK Hu (胡俊光) [this message]
2024-08-09  8:54 ` CK Hu (胡俊光)
2024-08-12  1:01 ` CK Hu (胡俊光)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac28d576de8ef20ff0927fc1779c7ede57c8d251.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Shuijing.Li@mediatek.com \
    --cc=airlied@gmail.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jitao.shi@mediatek.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=p.zabel@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox