Commit a44652e8 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Inki Dae

drm/exynos/mixer: simplify poweron flag

The driver uses bool protected by mutex to track power state.
The patch replaces this combo with single bit and atomic bitops.
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Reviewed-by: default avatarJoonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent bf56608a
...@@ -69,6 +69,10 @@ enum mixer_version_id { ...@@ -69,6 +69,10 @@ enum mixer_version_id {
MXR_VER_128_0_0_184, MXR_VER_128_0_0_184,
}; };
enum mixer_flag_bits {
MXR_BIT_POWERED,
};
struct mixer_context { struct mixer_context {
struct platform_device *pdev; struct platform_device *pdev;
struct device *dev; struct device *dev;
...@@ -76,13 +80,12 @@ struct mixer_context { ...@@ -76,13 +80,12 @@ struct mixer_context {
struct exynos_drm_crtc *crtc; struct exynos_drm_crtc *crtc;
struct exynos_drm_plane planes[MIXER_WIN_NR]; struct exynos_drm_plane planes[MIXER_WIN_NR];
int pipe; int pipe;
unsigned long flags;
bool interlace; bool interlace;
bool powered;
bool vp_enabled; bool vp_enabled;
bool has_sclk; bool has_sclk;
u32 int_en; u32 int_en;
struct mutex mixer_mutex;
struct mixer_resources mixer_res; struct mixer_resources mixer_res;
enum mixer_version_id mxr_ver; enum mixer_version_id mxr_ver;
wait_queue_head_t wait_vsync_queue; wait_queue_head_t wait_vsync_queue;
...@@ -899,7 +902,7 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc) ...@@ -899,7 +902,7 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)
struct mixer_context *mixer_ctx = crtc->ctx; struct mixer_context *mixer_ctx = crtc->ctx;
struct mixer_resources *res = &mixer_ctx->mixer_res; struct mixer_resources *res = &mixer_ctx->mixer_res;
if (!mixer_ctx->powered) { if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) {
mixer_ctx->int_en |= MXR_INT_EN_VSYNC; mixer_ctx->int_en |= MXR_INT_EN_VSYNC;
return 0; return 0;
} }
...@@ -916,7 +919,7 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc) ...@@ -916,7 +919,7 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc)
struct mixer_context *mixer_ctx = crtc->ctx; struct mixer_context *mixer_ctx = crtc->ctx;
struct mixer_resources *res = &mixer_ctx->mixer_res; struct mixer_resources *res = &mixer_ctx->mixer_res;
if (!mixer_ctx->powered) { if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags)) {
mixer_ctx->int_en &= MXR_INT_EN_VSYNC; mixer_ctx->int_en &= MXR_INT_EN_VSYNC;
return; return;
} }
...@@ -932,12 +935,8 @@ static void mixer_win_commit(struct exynos_drm_crtc *crtc, unsigned int win) ...@@ -932,12 +935,8 @@ static void mixer_win_commit(struct exynos_drm_crtc *crtc, unsigned int win)
DRM_DEBUG_KMS("win: %d\n", win); DRM_DEBUG_KMS("win: %d\n", win);
mutex_lock(&mixer_ctx->mixer_mutex); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
if (!mixer_ctx->powered) {
mutex_unlock(&mixer_ctx->mixer_mutex);
return; return;
}
mutex_unlock(&mixer_ctx->mixer_mutex);
if (win > 1 && mixer_ctx->vp_enabled) if (win > 1 && mixer_ctx->vp_enabled)
vp_video_buffer(mixer_ctx, win); vp_video_buffer(mixer_ctx, win);
...@@ -953,12 +952,8 @@ static void mixer_win_disable(struct exynos_drm_crtc *crtc, unsigned int win) ...@@ -953,12 +952,8 @@ static void mixer_win_disable(struct exynos_drm_crtc *crtc, unsigned int win)
DRM_DEBUG_KMS("win: %d\n", win); DRM_DEBUG_KMS("win: %d\n", win);
mutex_lock(&mixer_ctx->mixer_mutex); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
if (!mixer_ctx->powered) {
mutex_unlock(&mixer_ctx->mixer_mutex);
return; return;
}
mutex_unlock(&mixer_ctx->mixer_mutex);
spin_lock_irqsave(&res->reg_slock, flags); spin_lock_irqsave(&res->reg_slock, flags);
mixer_vsync_set_update(mixer_ctx, false); mixer_vsync_set_update(mixer_ctx, false);
...@@ -974,12 +969,8 @@ static void mixer_wait_for_vblank(struct exynos_drm_crtc *crtc) ...@@ -974,12 +969,8 @@ static void mixer_wait_for_vblank(struct exynos_drm_crtc *crtc)
struct mixer_context *mixer_ctx = crtc->ctx; struct mixer_context *mixer_ctx = crtc->ctx;
int err; int err;
mutex_lock(&mixer_ctx->mixer_mutex); if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
if (!mixer_ctx->powered) {
mutex_unlock(&mixer_ctx->mixer_mutex);
return; return;
}
mutex_unlock(&mixer_ctx->mixer_mutex);
err = drm_vblank_get(mixer_ctx->drm_dev, mixer_ctx->pipe); err = drm_vblank_get(mixer_ctx->drm_dev, mixer_ctx->pipe);
if (err < 0) { if (err < 0) {
...@@ -1007,13 +998,8 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) ...@@ -1007,13 +998,8 @@ static void mixer_enable(struct exynos_drm_crtc *crtc)
struct mixer_resources *res = &ctx->mixer_res; struct mixer_resources *res = &ctx->mixer_res;
int ret; int ret;
mutex_lock(&ctx->mixer_mutex); if (test_bit(MXR_BIT_POWERED, &ctx->flags))
if (ctx->powered) {
mutex_unlock(&ctx->mixer_mutex);
return; return;
}
mutex_unlock(&ctx->mixer_mutex);
pm_runtime_get_sync(ctx->dev); pm_runtime_get_sync(ctx->dev);
...@@ -1045,9 +1031,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc) ...@@ -1045,9 +1031,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc)
} }
} }
mutex_lock(&ctx->mixer_mutex); set_bit(MXR_BIT_POWERED, &ctx->flags);
ctx->powered = true;
mutex_unlock(&ctx->mixer_mutex);
mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET); mixer_reg_writemask(res, MXR_STATUS, ~0, MXR_STATUS_SOFT_RESET);
...@@ -1063,12 +1047,8 @@ static void mixer_disable(struct exynos_drm_crtc *crtc) ...@@ -1063,12 +1047,8 @@ static void mixer_disable(struct exynos_drm_crtc *crtc)
struct mixer_resources *res = &ctx->mixer_res; struct mixer_resources *res = &ctx->mixer_res;
int i; int i;
mutex_lock(&ctx->mixer_mutex); if (!test_bit(MXR_BIT_POWERED, &ctx->flags))
if (!ctx->powered) {
mutex_unlock(&ctx->mixer_mutex);
return; return;
}
mutex_unlock(&ctx->mixer_mutex);
mixer_stop(ctx); mixer_stop(ctx);
mixer_regs_dump(ctx); mixer_regs_dump(ctx);
...@@ -1078,9 +1058,7 @@ static void mixer_disable(struct exynos_drm_crtc *crtc) ...@@ -1078,9 +1058,7 @@ static void mixer_disable(struct exynos_drm_crtc *crtc)
ctx->int_en = mixer_reg_read(res, MXR_INT_EN); ctx->int_en = mixer_reg_read(res, MXR_INT_EN);
mutex_lock(&ctx->mixer_mutex); clear_bit(MXR_BIT_POWERED, &ctx->flags);
ctx->powered = false;
mutex_unlock(&ctx->mixer_mutex);
clk_disable_unprepare(res->hdmi); clk_disable_unprepare(res->hdmi);
clk_disable_unprepare(res->mixer); clk_disable_unprepare(res->mixer);
...@@ -1242,8 +1220,6 @@ static int mixer_probe(struct platform_device *pdev) ...@@ -1242,8 +1220,6 @@ static int mixer_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
} }
mutex_init(&ctx->mixer_mutex);
if (dev->of_node) { if (dev->of_node) {
const struct of_device_id *match; const struct of_device_id *match;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment