From f0c414b0953af021d0db203a0945783b364b00d6 Mon Sep 17 00:00:00 2001 From: Finley Xiao Date: Tue, 9 May 2017 21:34:24 +0800 Subject: [PATCH] drm/rockchip: vop: export rockchip_drm_register_notifier_to_dmc This function registers a notifier to dmc devfreq, devfreq thread will lock the mutex of vop when scaling frequency, so vop_crtc will not be disabled when it is waiting for line flag. Change-Id: I886e5dc5d36a0f14f35662cec3423a2c5550a7a6 Signed-off-by: Finley Xiao --- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 33 +++++++++++++++++++++ include/soc/rockchip/rockchip_dmc.h | 9 ++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index 3871ca7c17a5..5ff202b129fb 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -209,9 +210,14 @@ struct vop { /* vop dclk reset */ struct reset_control *dclk_rst; + struct devfreq *devfreq; + struct notifier_block dmc_nb; + struct vop_win win[]; }; +struct vop *dmc_vop; + static inline void vop_writel(struct vop *vop, uint32_t offset, uint32_t v) { writel(v, vop->regs + offset); @@ -2444,6 +2450,30 @@ out: } EXPORT_SYMBOL(rockchip_drm_wait_line_flag); +static int dmc_notifier_call(struct notifier_block *nb, unsigned long event, + void *data) +{ + if (event == DEVFREQ_PRECHANGE) + mutex_lock(&dmc_vop->vop_lock); + else if (event == DEVFREQ_POSTCHANGE) + mutex_unlock(&dmc_vop->vop_lock); + + return NOTIFY_OK; +} + +int rockchip_drm_register_notifier_to_dmc(struct devfreq *devfreq) +{ + if (!dmc_vop) + return -ENOMEM; + + dmc_vop->devfreq = devfreq; + dmc_vop->dmc_nb.notifier_call = dmc_notifier_call; + devfreq_register_notifier(dmc_vop->devfreq, &dmc_vop->dmc_nb, + DEVFREQ_TRANSITION_NOTIFIER); + return 0; +} +EXPORT_SYMBOL(rockchip_drm_register_notifier_to_dmc); + static int vop_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -2533,6 +2563,9 @@ static int vop_bind(struct device *dev, struct device *master, void *data) return ret; pm_runtime_enable(&pdev->dev); + + dmc_vop = vop; + return 0; } diff --git a/include/soc/rockchip/rockchip_dmc.h b/include/soc/rockchip/rockchip_dmc.h index f85073f1f59d..ef5fb47efab9 100644 --- a/include/soc/rockchip/rockchip_dmc.h +++ b/include/soc/rockchip/rockchip_dmc.h @@ -17,4 +17,13 @@ int rockchip_pm_register_notify_to_dmc(struct devfreq *devfreq); +#ifdef CONFIG_DRM +int rockchip_drm_register_notifier_to_dmc(struct devfreq *devfreq); +#else +static inline int rockchip_drm_register_notifier_to_dmc(struct devfreq *devfreq) +{ + return 0; +} +#endif + #endif -- 2.34.1