From d11895591041b0fcc35be7a0a9bd8f9481c956fe Mon Sep 17 00:00:00 2001 From: Mark Yao Date: Wed, 14 Dec 2016 18:30:24 +0800 Subject: [PATCH] drm/rockchip: boot_logo: add vop loader power protect Change-Id: I018aef21831b7df05393cfe6dd4782bc1f4a8938 Signed-off-by: Mark Yao --- drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 9 +++++---- drivers/gpu/drm/rockchip/rockchip_drm_drv.h | 2 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 5b4f1daa45e9..915ca8606ee2 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -471,14 +471,15 @@ static int update_state(struct drm_device *drm_dev, crtc_state->active = true; } else { - const struct drm_crtc_helper_funcs *funcs; const struct drm_encoder_helper_funcs *encoder_helper_funcs; const struct drm_connector_helper_funcs *connector_helper_funcs; + struct rockchip_drm_private *priv = drm_dev->dev_private; struct drm_encoder *encoder; + int pipe = drm_crtc_index(crtc); - funcs = crtc->helper_private; connector_helper_funcs = connector->helper_private; - if (!funcs || !funcs->enable || + if (!priv->crtc_funcs[pipe] || + !priv->crtc_funcs[pipe]->loader_protect || !connector_helper_funcs || !connector_helper_funcs->best_encoder) return -ENXIO; @@ -490,7 +491,7 @@ static int update_state(struct drm_device *drm_dev, conn_state); if (ret) return ret; - funcs->enable(crtc); + priv->crtc_funcs[pipe]->loader_protect(crtc, true); } primary_state = drm_atomic_get_plane_state(state, crtc->primary); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h index 77860ef22364..f66a814a52dc 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.h +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.h @@ -34,10 +34,12 @@ struct iommu_domain; /* * Rockchip drm private crtc funcs. + * @loader_protect: protect loader logo crtc's power * @enable_vblank: enable crtc vblank irq. * @disable_vblank: disable crtc vblank irq. */ struct rockchip_crtc_funcs { + int (*loader_protect)(struct drm_crtc *crtc, bool on); int (*enable_vblank)(struct drm_crtc *crtc); void (*disable_vblank)(struct drm_crtc *crtc); void (*wait_for_update)(struct drm_crtc *crtc); diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 5017f8ccd496..0ef34f76b908 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -174,6 +174,7 @@ struct vop { /* mutex vsync_ work */ struct mutex vsync_mutex; bool vsync_work_pending; + bool loader_protect; struct completion dsp_hold_completion; struct completion wait_update_complete; struct drm_pending_vblank_event *event; @@ -1303,7 +1304,27 @@ static void vop_crtc_cancel_pending_vblank(struct drm_crtc *crtc, spin_unlock_irqrestore(&drm->event_lock, flags); } +static int vop_crtc_loader_protect(struct drm_crtc *crtc, bool on) +{ + struct vop *vop = to_vop(crtc); + + if (on == vop->loader_protect) + return 0; + + if (on) { + vop_enable(crtc); + vop->loader_protect = true; + } else { + vop_crtc_disable(crtc); + + vop->loader_protect = false; + } + + return 0; +} + static const struct rockchip_crtc_funcs private_crtc_funcs = { + .loader_protect = vop_crtc_loader_protect, .enable_vblank = vop_crtc_enable_vblank, .disable_vblank = vop_crtc_disable_vblank, .wait_for_update = vop_crtc_wait_for_update, -- 2.34.1