Commit 3cecda03 authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Inki Dae

drm/exynos: split exynos_crtc->dpms in enable() and disable()

To follow more closely the new atomic API we split the dpms()
helper into the enable() and disable() helper to get exactly the
same semantics.
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
parent c4d96f16
...@@ -603,75 +603,39 @@ static void decon_init(struct decon_context *ctx) ...@@ -603,75 +603,39 @@ static void decon_init(struct decon_context *ctx)
writel(VIDCON1_VCLK_HOLD, ctx->regs + VIDCON1(0)); writel(VIDCON1_VCLK_HOLD, ctx->regs + VIDCON1(0));
} }
static int decon_poweron(struct decon_context *ctx) static void decon_enable(struct exynos_drm_crtc *crtc)
{ {
int ret; struct decon_context *ctx = crtc->ctx;
if (!ctx->suspended) if (!ctx->suspended)
return 0; return;
ctx->suspended = false; ctx->suspended = false;
pm_runtime_get_sync(ctx->dev); pm_runtime_get_sync(ctx->dev);
ret = clk_prepare_enable(ctx->pclk); clk_prepare_enable(ctx->pclk);
if (ret < 0) { clk_prepare_enable(ctx->aclk);
DRM_ERROR("Failed to prepare_enable the pclk [%d]\n", ret); clk_prepare_enable(ctx->eclk);
goto pclk_err; clk_prepare_enable(ctx->vclk);
}
ret = clk_prepare_enable(ctx->aclk);
if (ret < 0) {
DRM_ERROR("Failed to prepare_enable the aclk [%d]\n", ret);
goto aclk_err;
}
ret = clk_prepare_enable(ctx->eclk);
if (ret < 0) {
DRM_ERROR("Failed to prepare_enable the eclk [%d]\n", ret);
goto eclk_err;
}
ret = clk_prepare_enable(ctx->vclk);
if (ret < 0) {
DRM_ERROR("Failed to prepare_enable the vclk [%d]\n", ret);
goto vclk_err;
}
decon_init(ctx); decon_init(ctx);
/* if vblank was enabled status, enable it again. */ /* if vblank was enabled status, enable it again. */
if (test_and_clear_bit(0, &ctx->irq_flags)) { if (test_and_clear_bit(0, &ctx->irq_flags))
ret = decon_enable_vblank(ctx->crtc); decon_enable_vblank(ctx->crtc);
if (ret) {
DRM_ERROR("Failed to re-enable vblank [%d]\n", ret);
goto err;
}
}
decon_window_resume(ctx); decon_window_resume(ctx);
decon_apply(ctx); decon_apply(ctx);
return 0;
err:
clk_disable_unprepare(ctx->vclk);
vclk_err:
clk_disable_unprepare(ctx->eclk);
eclk_err:
clk_disable_unprepare(ctx->aclk);
aclk_err:
clk_disable_unprepare(ctx->pclk);
pclk_err:
ctx->suspended = true;
return ret;
} }
static int decon_poweroff(struct decon_context *ctx) static void decon_disable(struct exynos_drm_crtc *crtc)
{ {
struct decon_context *ctx = crtc->ctx;
if (ctx->suspended) if (ctx->suspended)
return 0; return;
/* /*
* We need to make sure that all windows are disabled before we * We need to make sure that all windows are disabled before we
...@@ -688,30 +652,11 @@ static int decon_poweroff(struct decon_context *ctx) ...@@ -688,30 +652,11 @@ static int decon_poweroff(struct decon_context *ctx)
pm_runtime_put_sync(ctx->dev); pm_runtime_put_sync(ctx->dev);
ctx->suspended = true; ctx->suspended = true;
return 0;
}
static void decon_dpms(struct exynos_drm_crtc *crtc, int mode)
{
DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode);
switch (mode) {
case DRM_MODE_DPMS_ON:
decon_poweron(crtc->ctx);
break;
case DRM_MODE_DPMS_STANDBY:
case DRM_MODE_DPMS_SUSPEND:
case DRM_MODE_DPMS_OFF:
decon_poweroff(crtc->ctx);
break;
default:
DRM_DEBUG_KMS("unspecified mode %d\n", mode);
break;
}
} }
static const struct exynos_drm_crtc_ops decon_crtc_ops = { static const struct exynos_drm_crtc_ops decon_crtc_ops = {
.dpms = decon_dpms, .enable = decon_enable,
.disable = decon_disable,
.mode_fixup = decon_mode_fixup, .mode_fixup = decon_mode_fixup,
.commit = decon_commit, .commit = decon_commit,
.enable_vblank = decon_enable_vblank, .enable_vblank = decon_enable_vblank,
...@@ -796,7 +741,7 @@ static void decon_unbind(struct device *dev, struct device *master, ...@@ -796,7 +741,7 @@ static void decon_unbind(struct device *dev, struct device *master,
{ {
struct decon_context *ctx = dev_get_drvdata(dev); struct decon_context *ctx = dev_get_drvdata(dev);
decon_dpms(ctx->crtc, DRM_MODE_DPMS_OFF); decon_disable(ctx->crtc);
if (ctx->display) if (ctx->display)
exynos_dpi_remove(ctx->display); exynos_dpi_remove(ctx->display);
......
...@@ -29,8 +29,8 @@ static void exynos_drm_crtc_enable(struct drm_crtc *crtc) ...@@ -29,8 +29,8 @@ static void exynos_drm_crtc_enable(struct drm_crtc *crtc)
if (exynos_crtc->enabled) if (exynos_crtc->enabled)
return; return;
if (exynos_crtc->ops->dpms) if (exynos_crtc->ops->enable)
exynos_crtc->ops->dpms(exynos_crtc, DRM_MODE_DPMS_ON); exynos_crtc->ops->enable(exynos_crtc);
exynos_crtc->enabled = true; exynos_crtc->enabled = true;
...@@ -51,8 +51,8 @@ static void exynos_drm_crtc_disable(struct drm_crtc *crtc) ...@@ -51,8 +51,8 @@ static void exynos_drm_crtc_disable(struct drm_crtc *crtc)
drm_crtc_vblank_off(crtc); drm_crtc_vblank_off(crtc);
if (exynos_crtc->ops->dpms) if (exynos_crtc->ops->disable)
exynos_crtc->ops->dpms(exynos_crtc, DRM_MODE_DPMS_OFF); exynos_crtc->ops->disable(exynos_crtc);
exynos_crtc->enabled = false; exynos_crtc->enabled = false;
} }
......
...@@ -157,7 +157,8 @@ struct exynos_drm_display { ...@@ -157,7 +157,8 @@ struct exynos_drm_display {
/* /*
* Exynos drm crtc ops * Exynos drm crtc ops
* *
* @dpms: control device power. * @enable: enable the device
* @disable: disable the device
* @mode_fixup: fix mode data before applying it * @mode_fixup: fix mode data before applying it
* @commit: set current hw specific display mode to hw. * @commit: set current hw specific display mode to hw.
* @enable_vblank: specific driver callback for enabling vblank interrupt. * @enable_vblank: specific driver callback for enabling vblank interrupt.
...@@ -175,7 +176,8 @@ struct exynos_drm_display { ...@@ -175,7 +176,8 @@ struct exynos_drm_display {
*/ */
struct exynos_drm_crtc; struct exynos_drm_crtc;
struct exynos_drm_crtc_ops { struct exynos_drm_crtc_ops {
void (*dpms)(struct exynos_drm_crtc *crtc, int mode); void (*enable)(struct exynos_drm_crtc *crtc);
void (*disable)(struct exynos_drm_crtc *crtc);
bool (*mode_fixup)(struct exynos_drm_crtc *crtc, bool (*mode_fixup)(struct exynos_drm_crtc *crtc,
const struct drm_display_mode *mode, const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode); struct drm_display_mode *adjusted_mode);
......
...@@ -805,57 +805,35 @@ static void fimd_apply(struct fimd_context *ctx) ...@@ -805,57 +805,35 @@ static void fimd_apply(struct fimd_context *ctx)
fimd_commit(ctx->crtc); fimd_commit(ctx->crtc);
} }
static int fimd_poweron(struct fimd_context *ctx) static void fimd_enable(struct exynos_drm_crtc *crtc)
{ {
int ret; struct fimd_context *ctx = crtc->ctx;
if (!ctx->suspended) if (!ctx->suspended)
return 0; return;
ctx->suspended = false; ctx->suspended = false;
pm_runtime_get_sync(ctx->dev); pm_runtime_get_sync(ctx->dev);
ret = clk_prepare_enable(ctx->bus_clk); clk_prepare_enable(ctx->bus_clk);
if (ret < 0) { clk_prepare_enable(ctx->lcd_clk);
DRM_ERROR("Failed to prepare_enable the bus clk [%d]\n", ret);
goto bus_clk_err;
}
ret = clk_prepare_enable(ctx->lcd_clk);
if (ret < 0) {
DRM_ERROR("Failed to prepare_enable the lcd clk [%d]\n", ret);
goto lcd_clk_err;
}
/* if vblank was enabled status, enable it again. */ /* if vblank was enabled status, enable it again. */
if (test_and_clear_bit(0, &ctx->irq_flags)) { if (test_and_clear_bit(0, &ctx->irq_flags))
ret = fimd_enable_vblank(ctx->crtc); fimd_enable_vblank(ctx->crtc);
if (ret) {
DRM_ERROR("Failed to re-enable vblank [%d]\n", ret);
goto enable_vblank_err;
}
}
fimd_window_resume(ctx); fimd_window_resume(ctx);
fimd_apply(ctx); fimd_apply(ctx);
return 0;
enable_vblank_err:
clk_disable_unprepare(ctx->lcd_clk);
lcd_clk_err:
clk_disable_unprepare(ctx->bus_clk);
bus_clk_err:
ctx->suspended = true;
return ret;
} }
static int fimd_poweroff(struct fimd_context *ctx) static void fimd_disable(struct exynos_drm_crtc *crtc)
{ {
struct fimd_context *ctx = crtc->ctx;
if (ctx->suspended) if (ctx->suspended)
return 0; return;
/* /*
* We need to make sure that all windows are disabled before we * We need to make sure that all windows are disabled before we
...@@ -870,26 +848,6 @@ static int fimd_poweroff(struct fimd_context *ctx) ...@@ -870,26 +848,6 @@ static int fimd_poweroff(struct fimd_context *ctx)
pm_runtime_put_sync(ctx->dev); pm_runtime_put_sync(ctx->dev);
ctx->suspended = true; ctx->suspended = true;
return 0;
}
static void fimd_dpms(struct exynos_drm_crtc *crtc, int mode)
{
DRM_DEBUG_KMS("%s, %d\n", __FILE__, mode);
switch (mode) {
case DRM_MODE_DPMS_ON:
fimd_poweron(crtc->ctx);
break;
case DRM_MODE_DPMS_STANDBY:
case DRM_MODE_DPMS_SUSPEND:
case DRM_MODE_DPMS_OFF:
fimd_poweroff(crtc->ctx);
break;
default:
DRM_DEBUG_KMS("unspecified mode %d\n", mode);
break;
}
} }
static void fimd_trigger(struct device *dev) static void fimd_trigger(struct device *dev)
...@@ -964,7 +922,8 @@ static void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable) ...@@ -964,7 +922,8 @@ static void fimd_dp_clock_enable(struct exynos_drm_crtc *crtc, bool enable)
} }
static const struct exynos_drm_crtc_ops fimd_crtc_ops = { static const struct exynos_drm_crtc_ops fimd_crtc_ops = {
.dpms = fimd_dpms, .enable = fimd_enable,
.disable = fimd_disable,
.mode_fixup = fimd_mode_fixup, .mode_fixup = fimd_mode_fixup,
.commit = fimd_commit, .commit = fimd_commit,
.enable_vblank = fimd_enable_vblank, .enable_vblank = fimd_enable_vblank,
...@@ -1051,7 +1010,7 @@ static void fimd_unbind(struct device *dev, struct device *master, ...@@ -1051,7 +1010,7 @@ static void fimd_unbind(struct device *dev, struct device *master,
{ {
struct fimd_context *ctx = dev_get_drvdata(dev); struct fimd_context *ctx = dev_get_drvdata(dev);
fimd_dpms(ctx->crtc, DRM_MODE_DPMS_OFF); fimd_disable(ctx->crtc);
fimd_iommu_detach_devices(ctx); fimd_iommu_detach_devices(ctx);
......
...@@ -153,56 +153,38 @@ static void vidi_win_disable(struct exynos_drm_crtc *crtc, unsigned int win) ...@@ -153,56 +153,38 @@ static void vidi_win_disable(struct exynos_drm_crtc *crtc, unsigned int win)
/* TODO. */ /* TODO. */
} }
static int vidi_power_on(struct vidi_context *ctx, bool enable) static void vidi_enable(struct exynos_drm_crtc *crtc)
{ {
struct vidi_context *ctx = crtc->ctx;
struct exynos_drm_plane *plane; struct exynos_drm_plane *plane;
int i; int i;
DRM_DEBUG_KMS("%s\n", __FILE__); mutex_lock(&ctx->lock);
if (enable != false && enable != true)
return -EINVAL;
if (enable) { ctx->suspended = false;
ctx->suspended = false;
/* if vblank was enabled status, enable it again. */ /* if vblank was enabled status, enable it again. */
if (test_and_clear_bit(0, &ctx->irq_flags)) if (test_and_clear_bit(0, &ctx->irq_flags))
vidi_enable_vblank(ctx->crtc); vidi_enable_vblank(ctx->crtc);
for (i = 0; i < WINDOWS_NR; i++) { for (i = 0; i < WINDOWS_NR; i++) {
plane = &ctx->planes[i]; plane = &ctx->planes[i];
if (plane->enabled) if (plane->enabled)
vidi_win_commit(ctx->crtc, i); vidi_win_commit(ctx->crtc, i);
}
} else {
ctx->suspended = true;
} }
return 0; mutex_unlock(&ctx->lock);
} }
static void vidi_dpms(struct exynos_drm_crtc *crtc, int mode) static void vidi_disable(struct exynos_drm_crtc *crtc)
{ {
struct vidi_context *ctx = crtc->ctx; struct vidi_context *ctx = crtc->ctx;
struct exynos_drm_plane *plane;
DRM_DEBUG_KMS("%d\n", mode); int i;
mutex_lock(&ctx->lock); mutex_lock(&ctx->lock);
switch (mode) { ctx->suspended = true;
case DRM_MODE_DPMS_ON:
vidi_power_on(ctx, true);
break;
case DRM_MODE_DPMS_STANDBY:
case DRM_MODE_DPMS_SUSPEND:
case DRM_MODE_DPMS_OFF:
vidi_power_on(ctx, false);
break;
default:
DRM_DEBUG_KMS("unspecified mode %d\n", mode);
break;
}
mutex_unlock(&ctx->lock); mutex_unlock(&ctx->lock);
} }
...@@ -219,7 +201,8 @@ static int vidi_ctx_initialize(struct vidi_context *ctx, ...@@ -219,7 +201,8 @@ static int vidi_ctx_initialize(struct vidi_context *ctx,
} }
static const struct exynos_drm_crtc_ops vidi_crtc_ops = { static const struct exynos_drm_crtc_ops vidi_crtc_ops = {
.dpms = vidi_dpms, .enable = vidi_enable,
.disable = vidi_disable,
.enable_vblank = vidi_enable_vblank, .enable_vblank = vidi_enable_vblank,
.disable_vblank = vidi_disable_vblank, .disable_vblank = vidi_disable_vblank,
.win_commit = vidi_win_commit, .win_commit = vidi_win_commit,
......
...@@ -1027,8 +1027,9 @@ static void mixer_window_resume(struct mixer_context *ctx) ...@@ -1027,8 +1027,9 @@ static void mixer_window_resume(struct mixer_context *ctx)
} }
} }
static void mixer_poweron(struct mixer_context *ctx) static void mixer_enable(struct exynos_drm_crtc *crtc)
{ {
struct mixer_context *ctx = crtc->ctx;
struct mixer_resources *res = &ctx->mixer_res; struct mixer_resources *res = &ctx->mixer_res;
mutex_lock(&ctx->mixer_mutex); mutex_lock(&ctx->mixer_mutex);
...@@ -1061,8 +1062,9 @@ static void mixer_poweron(struct mixer_context *ctx) ...@@ -1061,8 +1062,9 @@ static void mixer_poweron(struct mixer_context *ctx)
mixer_window_resume(ctx); mixer_window_resume(ctx);
} }
static void mixer_poweroff(struct mixer_context *ctx) static void mixer_disable(struct exynos_drm_crtc *crtc)
{ {
struct mixer_context *ctx = crtc->ctx;
struct mixer_resources *res = &ctx->mixer_res; struct mixer_resources *res = &ctx->mixer_res;
mutex_lock(&ctx->mixer_mutex); mutex_lock(&ctx->mixer_mutex);
...@@ -1093,23 +1095,6 @@ static void mixer_poweroff(struct mixer_context *ctx) ...@@ -1093,23 +1095,6 @@ static void mixer_poweroff(struct mixer_context *ctx)
pm_runtime_put_sync(ctx->dev); pm_runtime_put_sync(ctx->dev);
} }
static void mixer_dpms(struct exynos_drm_crtc *crtc, int mode)
{
switch (mode) {
case DRM_MODE_DPMS_ON:
mixer_poweron(crtc->ctx);
break;
case DRM_MODE_DPMS_STANDBY:
case DRM_MODE_DPMS_SUSPEND:
case DRM_MODE_DPMS_OFF:
mixer_poweroff(crtc->ctx);
break;
default:
DRM_DEBUG_KMS("unknown dpms mode: %d\n", mode);
break;
}
}
/* Only valid for Mixer version 16.0.33.0 */ /* Only valid for Mixer version 16.0.33.0 */
int mixer_check_mode(struct drm_display_mode *mode) int mixer_check_mode(struct drm_display_mode *mode)
{ {
...@@ -1131,7 +1116,8 @@ int mixer_check_mode(struct drm_display_mode *mode) ...@@ -1131,7 +1116,8 @@ int mixer_check_mode(struct drm_display_mode *mode)
} }
static const struct exynos_drm_crtc_ops mixer_crtc_ops = { static const struct exynos_drm_crtc_ops mixer_crtc_ops = {
.dpms = mixer_dpms, .enable = mixer_enable,
.disable = mixer_disable,
.enable_vblank = mixer_enable_vblank, .enable_vblank = mixer_enable_vblank,
.disable_vblank = mixer_disable_vblank, .disable_vblank = mixer_disable_vblank,
.wait_for_vblank = mixer_wait_for_vblank, .wait_for_vblank = mixer_wait_for_vblank,
......
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