Skip to content

Commit cde7e2e

Browse files
mediatek-jitaoChun-Kuang Hu
authored andcommitted
drm/mediatek: Separate poweron/poweroff from enable/disable and define new funcs
In order to match the changes of "Use the drm_panel_bridge API", the poweron/poweroff of dsi is extracted from enable/disable and defined as new funcs (atomic_pre_enable/atomic_post_disable). Since dsi_poweron is moved from dsi_enable to pre_enable function, in order to avoid poweron failure, the operation of dsi register fails to cause bus hang. Therefore, the protection mechanism is added to the dsi_enable function. Fixes: 2dd8075 ("drm/mediatek: mtk_dsi: Use the drm_panel_bridge API") Link: https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/ Signed-off-by: Jitao Shi <[email protected]> Signed-off-by: Xinlei Lee <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: Rex-BC Chen <[email protected]> Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 7f6335c commit cde7e2e

File tree

1 file changed

+34
-19
lines changed

1 file changed

+34
-19
lines changed

drivers/gpu/drm/mediatek/mtk_dsi.c

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -691,16 +691,6 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
691691
if (--dsi->refcount != 0)
692692
return;
693693

694-
/*
695-
* mtk_dsi_stop() and mtk_dsi_start() is asymmetric, since
696-
* mtk_dsi_stop() should be called after mtk_drm_crtc_atomic_disable(),
697-
* which needs irq for vblank, and mtk_dsi_stop() will disable irq.
698-
* mtk_dsi_start() needs to be called in mtk_output_dsi_enable(),
699-
* after dsi is fully set.
700-
*/
701-
mtk_dsi_stop(dsi);
702-
703-
mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500);
704694
mtk_dsi_reset_engine(dsi);
705695
mtk_dsi_lane0_ulp_mode_enter(dsi);
706696
mtk_dsi_clk_ulp_mode_enter(dsi);
@@ -715,17 +705,9 @@ static void mtk_dsi_poweroff(struct mtk_dsi *dsi)
715705

716706
static void mtk_output_dsi_enable(struct mtk_dsi *dsi)
717707
{
718-
int ret;
719-
720708
if (dsi->enabled)
721709
return;
722710

723-
ret = mtk_dsi_poweron(dsi);
724-
if (ret < 0) {
725-
DRM_ERROR("failed to power on dsi\n");
726-
return;
727-
}
728-
729711
mtk_dsi_set_mode(dsi);
730712
mtk_dsi_clk_hs_mode(dsi, 1);
731713

@@ -739,7 +721,16 @@ static void mtk_output_dsi_disable(struct mtk_dsi *dsi)
739721
if (!dsi->enabled)
740722
return;
741723

742-
mtk_dsi_poweroff(dsi);
724+
/*
725+
* mtk_dsi_stop() and mtk_dsi_start() is asymmetric, since
726+
* mtk_dsi_stop() should be called after mtk_drm_crtc_atomic_disable(),
727+
* which needs irq for vblank, and mtk_dsi_stop() will disable irq.
728+
* mtk_dsi_start() needs to be called in mtk_output_dsi_enable(),
729+
* after dsi is fully set.
730+
*/
731+
mtk_dsi_stop(dsi);
732+
733+
mtk_dsi_switch_to_cmd_mode(dsi, VM_DONE_INT_FLAG, 500);
743734

744735
dsi->enabled = false;
745736
}
@@ -776,13 +767,37 @@ static void mtk_dsi_bridge_atomic_enable(struct drm_bridge *bridge,
776767
{
777768
struct mtk_dsi *dsi = bridge_to_dsi(bridge);
778769

770+
if (dsi->refcount == 0)
771+
return;
772+
779773
mtk_output_dsi_enable(dsi);
780774
}
781775

776+
static void mtk_dsi_bridge_atomic_pre_enable(struct drm_bridge *bridge,
777+
struct drm_bridge_state *old_bridge_state)
778+
{
779+
struct mtk_dsi *dsi = bridge_to_dsi(bridge);
780+
int ret;
781+
782+
ret = mtk_dsi_poweron(dsi);
783+
if (ret < 0)
784+
DRM_ERROR("failed to power on dsi\n");
785+
}
786+
787+
static void mtk_dsi_bridge_atomic_post_disable(struct drm_bridge *bridge,
788+
struct drm_bridge_state *old_bridge_state)
789+
{
790+
struct mtk_dsi *dsi = bridge_to_dsi(bridge);
791+
792+
mtk_dsi_poweroff(dsi);
793+
}
794+
782795
static const struct drm_bridge_funcs mtk_dsi_bridge_funcs = {
783796
.attach = mtk_dsi_bridge_attach,
784797
.atomic_disable = mtk_dsi_bridge_atomic_disable,
785798
.atomic_enable = mtk_dsi_bridge_atomic_enable,
799+
.atomic_pre_enable = mtk_dsi_bridge_atomic_pre_enable,
800+
.atomic_post_disable = mtk_dsi_bridge_atomic_post_disable,
786801
.mode_set = mtk_dsi_bridge_mode_set,
787802
};
788803

0 commit comments

Comments
 (0)