diff mbox series

[3/4] drm/mediatek: fine tune the dsi panel's power sequence

Message ID 20210420132614.150242-3-jitao.shi@mediatek.com
State New
Headers show
Series [1/4] drm/panel: seperate panel power control from panel prepare/unprepare | expand

Commit Message

Jitao Shi April 20, 2021, 1:26 p.m. UTC
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 <jitao.shi@mediatek.com>

---
 drivers/gpu/drm/mediatek/mtk_dsi.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

-- 
2.25.1

Comments

Chun-Kuang Hu April 23, 2021, 4:36 p.m. UTC | #1
Hi, Jitao:

Jitao Shi <jitao.shi@mediatek.com> 於 2021年4月20日 週二 下午9:26寫道:
>

> 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.


Please describe WHY do you need this patch? Fix any bug?

>

> Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>

> ---

>  drivers/gpu/drm/mediatek/mtk_dsi.c | 12 ++++++++++--

>  1 file changed, 10 insertions(+), 2 deletions(-)

>

> diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c

> index a1ff152ef468..455fe582c6b5 100644

> --- a/drivers/gpu/drm/mediatek/mtk_dsi.c

> +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c

> @@ -615,10 +615,13 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)

>         dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,

>                                           dsi->lanes);

>

> +       if (panel_bridge_prepare_power(dsi->next_bridge))


ret = panel_bridge_prepare_power(dsi->next_bridge);
if (ret)

> +               DRM_INFO("can't prepare power the panel\n");


I think you should goto err_refcount;

> +

>         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);

> @@ -661,7 +664,9 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)

>         clk_disable_unprepare(dsi->engine_clk);

>  err_phy_power_off:

>         phy_power_off(dsi->phy);

> -err_refcount:

> +err_prepare_power:

> +       if (panel_bridge_unprepare_power(dsi->next_bridge))


ret = panel_bridge_unprepare_power(dsi->next_bridge);

> +               DRM_INFO("Can't unprepare power the panel\n");

>         dsi->refcount--;

>         return ret;

>  }

> @@ -694,6 +699,9 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)

>         clk_disable_unprepare(dsi->digital_clk);

>

>         phy_power_off(dsi->phy);

> +

> +       if (panel_bridge_unprepare_power(dsi->next_bridge))


ret = panel_bridge_unprepare_power(dsi->next_bridge);

> +               DRM_INFO("Can't unprepare power the panel\n");

>  }

>

>  static void mtk_output_dsi_enable(struct mtk_dsi *dsi)

> --

> 2.25.1

> _______________________________________________

> dri-devel mailing list

> dri-devel@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Jitao Shi May 19, 2021, 3:54 a.m. UTC | #2
On Sat, 2021-04-24 at 00:36 +0800, Chun-Kuang Hu wrote:
> Hi, Jitao:

> 

> Jitao Shi <jitao.shi@mediatek.com> 於 2021年4月20日 週二 下午9:26寫道:

> >

> > 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.

> 

> Please describe WHY do you need this patch? Fix any bug?


Most panels, have five steps when poweron.

1. turn on dsi signal to LP11   --> dsi host's action
2. turn on the power supplies,  --> panel's action
3. send the DCS  cmd to panel   --> panel's action
4. start send video stream      --> dsi host's action
5. turn on backlight.           --> panel's action

we put "turn on the power supplies" and "send the DCS  cmd to panel" in
panel_prepare. And "turn on backlight" in panel_enable.

But some other panels has a special poweron sequence as the following.

1. turn on the power supplies,  --> panel's action
2. turn on dsi signal to LP11   --> dsi host's action
3. send the DCS  cmd to panel   --> panel's action
4. start send video stream      --> dsi host's action
5. turn on backlight.           --> panel's action

panel's actions are divided into three parts.

So I add a new api "drm_panel_prepare_power/rm_panel_unprepare_power" to
control the sequence.


Best Regards
Jitao

> 

> >

> > Signed-off-by: Jitao Shi <jitao.shi@mediatek.com>

> > ---

> >  drivers/gpu/drm/mediatek/mtk_dsi.c | 12 ++++++++++--

> >  1 file changed, 10 insertions(+), 2 deletions(-)

> >

> > diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c

> > index a1ff152ef468..455fe582c6b5 100644

> > --- a/drivers/gpu/drm/mediatek/mtk_dsi.c

> > +++ b/drivers/gpu/drm/mediatek/mtk_dsi.c

> > @@ -615,10 +615,13 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)

> >         dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,

> >                                           dsi->lanes);

> >

> > +       if (panel_bridge_prepare_power(dsi->next_bridge))

> 

> ret = panel_bridge_prepare_power(dsi->next_bridge);

> if (ret)

> 

> > +               DRM_INFO("can't prepare power the panel\n");

> 

> I think you should goto err_refcount;


Thanks for your review. I'll fix it next patch.

> 

> > +

> >         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);

> > @@ -661,7 +664,9 @@ static int mtk_dsi_poweron(struct mtk_dsi *dsi)

> >         clk_disable_unprepare(dsi->engine_clk);

> >  err_phy_power_off:

> >         phy_power_off(dsi->phy);

> > -err_refcount:

> > +err_prepare_power:

> > +       if (panel_bridge_unprepare_power(dsi->next_bridge))

> 

> ret = panel_bridge_unprepare_power(dsi->next_bridge);

> 

> > +               DRM_INFO("Can't unprepare power the panel\n");

> >         dsi->refcount--;

> >         return ret;

> >  }

> > @@ -694,6 +699,9 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)

> >         clk_disable_unprepare(dsi->digital_clk);

> >

> >         phy_power_off(dsi->phy);

> > +

> > +       if (panel_bridge_unprepare_power(dsi->next_bridge))

> 

> ret = panel_bridge_unprepare_power(dsi->next_bridge);

> 

> > +               DRM_INFO("Can't unprepare power the panel\n");

> >  }

> >

> >  static void mtk_output_dsi_enable(struct mtk_dsi *dsi)

> > --

> > 2.25.1

> > _______________________________________________

> > dri-devel mailing list

> > dri-devel@lists.freedesktop.org

> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/mediatek/mtk_dsi.c b/drivers/gpu/drm/mediatek/mtk_dsi.c
index a1ff152ef468..455fe582c6b5 100644
--- a/drivers/gpu/drm/mediatek/mtk_dsi.c
+++ b/drivers/gpu/drm/mediatek/mtk_dsi.c
@@ -615,10 +615,13 @@  static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	dsi->data_rate = DIV_ROUND_UP_ULL(dsi->vm.pixelclock * bit_per_pixel,
 					  dsi->lanes);
 
+	if (panel_bridge_prepare_power(dsi->next_bridge))
+		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);
@@ -661,7 +664,9 @@  static int mtk_dsi_poweron(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->engine_clk);
 err_phy_power_off:
 	phy_power_off(dsi->phy);
-err_refcount:
+err_prepare_power:
+	if (panel_bridge_unprepare_power(dsi->next_bridge))
+		DRM_INFO("Can't unprepare power the panel\n");
 	dsi->refcount--;
 	return ret;
 }
@@ -694,6 +699,9 @@  static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
 	clk_disable_unprepare(dsi->digital_clk);
 
 	phy_power_off(dsi->phy);
+
+	if (panel_bridge_unprepare_power(dsi->next_bridge))
+		DRM_INFO("Can't unprepare power the panel\n");
 }
 
 static void mtk_output_dsi_enable(struct mtk_dsi *dsi)