aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/exynos/exynos_drm_fimd.c
diff options
context:
space:
mode:
authorInki Dae <inki.dae@samsung.com>2011-12-16 07:49:03 -0500
committerInki Dae <inki.dae@samsung.com>2011-12-28 21:21:42 -0500
commitc32b06ef7dd63a5e0b14a02c96ef308796c157cc (patch)
tree4a2cecf7e9f97cc42879cd7afd8567df4582f66a /drivers/gpu/drm/exynos/exynos_drm_fimd.c
parent52c68814cd7f3592292a02b890b5b8625e9069a7 (diff)
drm/exynos: added mutex lock and code clean.
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Diffstat (limited to 'drivers/gpu/drm/exynos/exynos_drm_fimd.c')
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_fimd.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 777b93c07186..ca83139cd309 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -87,6 +87,7 @@ struct fimd_context {
87 u32 vidcon0; 87 u32 vidcon0;
88 u32 vidcon1; 88 u32 vidcon1;
89 bool suspended; 89 bool suspended;
90 struct mutex lock;
90 91
91 struct fb_videomode *timing; 92 struct fb_videomode *timing;
92}; 93};
@@ -137,11 +138,22 @@ static struct exynos_drm_display_ops fimd_display_ops = {
137 138
138static void fimd_dpms(struct device *subdrv_dev, int mode) 139static void fimd_dpms(struct device *subdrv_dev, int mode)
139{ 140{
141 struct fimd_context *ctx = get_fimd_context(subdrv_dev);
142
140 DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode); 143 DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode);
141 144
145 mutex_lock(&ctx->lock);
146
142 switch (mode) { 147 switch (mode) {
143 case DRM_MODE_DPMS_ON: 148 case DRM_MODE_DPMS_ON:
144 pm_runtime_get_sync(subdrv_dev); 149 /*
150 * enable fimd hardware only if suspended status.
151 *
152 * P.S. fimd_dpms function would be called at booting time so
153 * clk_enable could be called double time.
154 */
155 if (ctx->suspended)
156 pm_runtime_get_sync(subdrv_dev);
145 break; 157 break;
146 case DRM_MODE_DPMS_STANDBY: 158 case DRM_MODE_DPMS_STANDBY:
147 case DRM_MODE_DPMS_SUSPEND: 159 case DRM_MODE_DPMS_SUSPEND:
@@ -152,6 +164,8 @@ static void fimd_dpms(struct device *subdrv_dev, int mode)
152 DRM_DEBUG_KMS("unspecified mode %d\n", mode); 164 DRM_DEBUG_KMS("unspecified mode %d\n", mode);
153 break; 165 break;
154 } 166 }
167
168 mutex_unlock(&ctx->lock);
155} 169}
156 170
157static void fimd_apply(struct device *subdrv_dev) 171static void fimd_apply(struct device *subdrv_dev)
@@ -803,13 +817,6 @@ static int __devinit fimd_probe(struct platform_device *pdev)
803 goto err_req_irq; 817 goto err_req_irq;
804 } 818 }
805 819
806 pm_runtime_set_active(dev);
807 pm_runtime_enable(dev);
808 pm_runtime_get_sync(dev);
809
810 for (win = 0; win < WINDOWS_NR; win++)
811 fimd_clear_win(ctx, win);
812
813 ctx->clkdiv = fimd_calc_clkdiv(ctx, timing); 820 ctx->clkdiv = fimd_calc_clkdiv(ctx, timing);
814 ctx->vidcon0 = pdata->vidcon0; 821 ctx->vidcon0 = pdata->vidcon0;
815 ctx->vidcon1 = pdata->vidcon1; 822 ctx->vidcon1 = pdata->vidcon1;
@@ -831,7 +838,17 @@ static int __devinit fimd_probe(struct platform_device *pdev)
831 subdrv->manager.display_ops = &fimd_display_ops; 838 subdrv->manager.display_ops = &fimd_display_ops;
832 subdrv->manager.dev = dev; 839 subdrv->manager.dev = dev;
833 840
841 mutex_init(&ctx->lock);
842
834 platform_set_drvdata(pdev, ctx); 843 platform_set_drvdata(pdev, ctx);
844
845 pm_runtime_set_active(dev);
846 pm_runtime_enable(dev);
847 pm_runtime_get_sync(dev);
848
849 for (win = 0; win < WINDOWS_NR; win++)
850 fimd_clear_win(ctx, win);
851
835 exynos_drm_subdrv_register(subdrv); 852 exynos_drm_subdrv_register(subdrv);
836 853
837 return 0; 854 return 0;
@@ -894,7 +911,6 @@ out:
894#ifdef CONFIG_PM_SLEEP 911#ifdef CONFIG_PM_SLEEP
895static int fimd_suspend(struct device *dev) 912static int fimd_suspend(struct device *dev)
896{ 913{
897 struct fimd_context *ctx = get_fimd_context(dev);
898 int ret; 914 int ret;
899 915
900 if (pm_runtime_suspended(dev)) 916 if (pm_runtime_suspended(dev))
@@ -904,13 +920,11 @@ static int fimd_suspend(struct device *dev)
904 if (ret < 0) 920 if (ret < 0)
905 return ret; 921 return ret;
906 922
907 ctx->suspended = true;
908 return 0; 923 return 0;
909} 924}
910 925
911static int fimd_resume(struct device *dev) 926static int fimd_resume(struct device *dev)
912{ 927{
913 struct fimd_context *ctx = get_fimd_context(dev);
914 int ret; 928 int ret;
915 929
916 ret = pm_runtime_resume(dev); 930 ret = pm_runtime_resume(dev);
@@ -931,7 +945,6 @@ static int fimd_resume(struct device *dev)
931 945
932 pm_runtime_enable(dev); 946 pm_runtime_enable(dev);
933 947
934 ctx->suspended = false;
935 return 0; 948 return 0;
936} 949}
937#endif 950#endif