Hi, Yongqiang:
I would like the title could clearly express what does this patch do. I think what this patch do is to implement prepare/unprepare interface for dpi driver. And you could describe why do this in commit message.
On Wed, 2019-11-27 at 09:17 +0800, yongqiang.niu@mediatek.com wrote:
From: Yongqiang Niu yongqiang.niu@mediatek.com
Fix external display vblank timeout issue
I think you move dpi_power_on to more early stage. But why this would fix vblank timeout. Please describe more about this so that I would agree this patch.
This is a bug fix, so please add a 'Fixes' tag.
Signed-off-by: Yongqiang Niu yongqiang.niu@mediatek.com
drivers/gpu/drm/mediatek/mtk_dpi.c | 14 +++++++++----- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 6 ++++++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_dpi.c b/drivers/gpu/drm/mediatek/mtk_dpi.c index be6d95c..38cabbe 100644 --- a/drivers/gpu/drm/mediatek/mtk_dpi.c +++ b/drivers/gpu/drm/mediatek/mtk_dpi.c @@ -387,8 +387,12 @@ static int mtk_dpi_power_on(struct mtk_dpi *dpi) { int ret;
- if (++dpi->refcount != 1)
if (++dpi->refcount != 1) {
dev_warn(dpi->dev, "%s refcount: %d\n", __func__, dpi->refcount);
return 0;
}
DRM_DEBUG_DRIVER("%s refcount %d\n", __func__, dpi->refcount);
ret = clk_prepare_enable(dpi->engine_clk); if (ret) {
@@ -563,14 +567,14 @@ static int mtk_dpi_atomic_check(struct drm_encoder *encoder, .atomic_check = mtk_dpi_atomic_check, };
-static void mtk_dpi_start(struct mtk_ddp_comp *comp) +static void mtk_dpi_prepare(struct mtk_ddp_comp *comp) { struct mtk_dpi *dpi = container_of(comp, struct mtk_dpi, ddp_comp);
mtk_dpi_power_on(dpi); }
-static void mtk_dpi_stop(struct mtk_ddp_comp *comp) +static void mtk_dpi_unprepare(struct mtk_ddp_comp *comp) { struct mtk_dpi *dpi = container_of(comp, struct mtk_dpi, ddp_comp);
@@ -578,8 +582,8 @@ static void mtk_dpi_stop(struct mtk_ddp_comp *comp) }
static const struct mtk_ddp_comp_funcs mtk_dpi_funcs = {
- .start = mtk_dpi_start,
- .stop = mtk_dpi_stop,
- .prepare = mtk_dpi_prepare,
- .unprepare = mtk_dpi_unprepare,
};
static int mtk_dpi_bind(struct device *dev, struct device *master, void *data) diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index 7eca02f..a6d3d97 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -345,6 +345,9 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) return ret; }
- for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
mtk_ddp_comp_prepare(mtk_crtc->ddp_comp[i]);
- ret = mtk_disp_mutex_prepare(mtk_crtc->mutex); if (ret < 0) { DRM_ERROR("Failed to enable mutex clock: %d\n", ret);
@@ -434,6 +437,9 @@ static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) mtk_crtc_ddp_clk_disable(mtk_crtc); mtk_disp_mutex_unprepare(mtk_crtc->mutex);
for (i = 0; i < mtk_crtc->ddp_comp_nr; i++)
mtk_ddp_comp_unprepare(mtk_crtc->ddp_comp[i]);
pm_runtime_put(drm->dev);
if (crtc->state->event && !crtc->state->active) {
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h index 5b0a3d4..097b90d 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h @@ -78,6 +78,8 @@ struct mtk_ddp_comp_funcs { void (*stop)(struct mtk_ddp_comp *comp); void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc); void (*disable_vblank)(struct mtk_ddp_comp *comp);
- void (*prepare)(struct mtk_ddp_comp *comp);
- void (*unprepare)(struct mtk_ddp_comp *comp); unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp); unsigned int (*layer_nr)(struct mtk_ddp_comp *comp); void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx,
@@ -117,6 +119,18 @@ static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp, comp->funcs->config(comp, w, h, vrefresh, bpc, cmdq_pkt); }
+static inline void mtk_ddp_comp_prepare(struct mtk_ddp_comp *comp) +{
- if (comp->funcs && comp->funcs->prepare)
comp->funcs->prepare(comp);
+}
+static inline void mtk_ddp_comp_unprepare(struct mtk_ddp_comp *comp) +{
- if (comp->funcs && comp->funcs->unprepare)
comp->funcs->unprepare(comp);
+}
static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp) { if (comp->funcs && comp->funcs->start)