From patchwork Wed Nov 28 06:00:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Sharma X-Patchwork-Id: 1814901 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 407153FC54 for ; Wed, 28 Nov 2012 10:10:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 42E02E6355 for ; Wed, 28 Nov 2012 02:10:26 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D843E5C73 for ; Tue, 27 Nov 2012 21:38:20 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0ME6008SBNM8UAJ0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 28 Nov 2012 14:37:22 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.122]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 0F.98.01231.213A5B05; Wed, 28 Nov 2012 14:37:22 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-0e-50b5a312ff01 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 9E.98.01231.213A5B05; Wed, 28 Nov 2012 14:37:22 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0ME600H8SNLYVZ60@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 28 Nov 2012 14:37:22 +0900 (KST) From: Rahul Sharma To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm/exynos: add runtime pm support for mixer Date: Wed, 28 Nov 2012 11:30:24 +0530 Message-id: <1354082425-13431-3-git-send-email-rahul.sharma@samsung.com> X-Mailer: git-send-email 1.7.0.4 In-reply-to: <1354082425-13431-1-git-send-email-rahul.sharma@samsung.com> References: <1354082425-13431-1-git-send-email-rahul.sharma@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNLMWRmVeSWpSXmKPExsWyRsSkSldo8dYAgxOTzSyufH3P5sDocb/7 OFMAYxSXTUpqTmZZapG+XQJXxsn+10wF5yQrOjsiGhj3i3YxcnJICJhI3F64jR3CFpO4cG89 WxcjF4eQwFJGiXsv5rDDFG2/eYUJIjGdUWLPia+MEM5qJonrbR/ZQKrYBHQlZh98xghiiwgo S/yduArMZhYolLg3/Q+YLSzgKPH/yH9WEJtFQFXiwoJ+oA0cHLwCHhJtzcwQyxQkWpcdAlvM KeApcXzCDzBbCKjk19VdjBCtAhLfJh9iAWmVEJCV2HSAGeQcCYHLbBIXHlyBOlpS4uCKGywT GIUXMDKsYhRNLUguKE5KzzXUK07MLS7NS9dLzs/dxAgMwdP/nkntYFzZYHGIUYCDUYmH18Fx a4AQa2JZcWXuIUYJDmYlEV6eNqAQb0piZVVqUX58UWlOavEhRh+gSyYyS4km5wPjI68k3tDY xNzU2NTSyMjM1BSHsJI4b7NHSoCQQHpiSWp2ampBahHMOCYOTqkGxoD13ad9VcTErJlnKv4q SF5yc9cq/T1VM5dvuNn4zErIZ9Hrm63FzS5BtXrzDJdLPvsQ5drxIofln+/NVdMSftw6ZVWs 9vRsT59fufm2gP3/LzV+Xenuo+qjfffyiy0/E5QPT6hfM/WBafqFN/LfBe4uOMrIvrf0a8VR 18f7jvenW79eeU8nKVCJpTgj0VCLuag4EQA0X5scbgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupikeLIzCtJLcpLzFFi42I5/e+xoK7Q4q0BBhfPqlpc+fqezYHR4373 caYAxqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wc oLFKCmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMIaxoyT/a+ZCs5JVnR2RDQw 7hftYuTkkBAwkdh+8woThC0mceHeerYuRi4OIYHpjBJ7TnxlhHBWM0lcb/vIBlLFJqArMfvg M0YQW0RAWeLvxFVgNrNAocS96X/AbGEBR4n/R/6zgtgsAqoSFxb0s3cxcnDwCnhItDUzQyxT kGhddogdxOYU8JQ4PuEHmC0EVPLr6i7GCYy8CxgZVjGKphYkFxQnpeca6hUn5haX5qXrJefn bmIEB/gzqR2MKxssDjEKcDAq8fA6OG4NEGJNLCuuzD3EKMHBrCTCy9MGFOJNSaysSi3Kjy8q zUktPsToA3TURGYp0eR8YPTllcQbGpuYmxqbWppYmJhZ4hBWEudt9kgJEBJITyxJzU5NLUgt ghnHxMEp1cDYfdvnZ9yze3xCkju1XubZxe/57yB7gP2ukmqay+36ix0HhE+9+KizRmP16knR O6M/lnbnnLu75+CVrxXR+0tXF7/YnC4h6JhW5qyv9O9KQBZj3uKLVftXN0m5BMXJxaoczBVj +vXvzEGexgaWlLPbFl3nuzPTJXyva9u/043Ny5pi7HPE/X2VWIozEg21mIuKEwG70uuCnQIA AA== X-CFilter-Loop: Reflected X-Mailman-Approved-At: Wed, 28 Nov 2012 02:04:54 -0800 Cc: kgene.kim@samsung.com, sw0312.kim@samsung.com, joshi@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org This patch adds support for runtime power management for drm mixer driver. Signed-off-by: Rahul Sharma Signed-off-by: Shirish S --- drivers/gpu/drm/exynos/exynos_mixer.c | 65 +++++++++++++++++++++++++++++---- 1 files changed, 58 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 0d3ed28..b15b770 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -679,8 +679,6 @@ static void mixer_poweron(struct mixer_context *ctx) ctx->powered = true; mutex_unlock(&ctx->mixer_mutex); - pm_runtime_get_sync(ctx->dev); - clk_enable(res->mixer); if (ctx->vp_enabled) { clk_enable(res->vp); @@ -710,8 +708,6 @@ static void mixer_poweroff(struct mixer_context *ctx) clk_disable(res->sclk_mixer); } - pm_runtime_put_sync(ctx->dev); - mutex_lock(&ctx->mixer_mutex); ctx->powered = false; @@ -754,12 +750,14 @@ static void mixer_dpms(void *ctx, int mode) switch (mode) { case DRM_MODE_DPMS_ON: - mixer_poweron(mixer_ctx); + if (pm_runtime_suspended(mixer_ctx->dev)) + pm_runtime_get_sync(mixer_ctx->dev); break; case DRM_MODE_DPMS_STANDBY: case DRM_MODE_DPMS_SUSPEND: case DRM_MODE_DPMS_OFF: - mixer_poweroff(mixer_ctx); + if (!pm_runtime_suspended(mixer_ctx->dev)) + pm_runtime_put_sync(mixer_ctx->dev); break; default: DRM_DEBUG_KMS("unknown dpms mode: %d\n", mode); @@ -1193,13 +1191,66 @@ static int mixer_suspend(struct device *dev) struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev); struct mixer_context *ctx = drm_hdmi_ctx->ctx; + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); + + if (pm_runtime_suspended(dev)) { + DRM_DEBUG_KMS("%s : Already suspended\n", __func__); + return 0; + } + mixer_poweroff(ctx); return 0; } + +static int mixer_resume(struct device *dev) +{ + struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev); + struct mixer_context *ctx = drm_hdmi_ctx->ctx; + + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); + + if (!pm_runtime_suspended(dev)) { + DRM_DEBUG_KMS("%s : Already resumed\n", __func__); + return 0; + } + + mixer_poweron(ctx); + + return 0; +} #endif -static SIMPLE_DEV_PM_OPS(mixer_pm_ops, mixer_suspend, NULL); +#ifdef CONFIG_PM_RUNTIME +static int mixer_runtime_suspend(struct device *dev) +{ + struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev); + struct mixer_context *ctx = drm_hdmi_ctx->ctx; + + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); + + mixer_poweroff(ctx); + + return 0; +} + +static int mixer_runtime_resume(struct device *dev) +{ + struct exynos_drm_hdmi_context *drm_hdmi_ctx = get_mixer_context(dev); + struct mixer_context *ctx = drm_hdmi_ctx->ctx; + + DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); + + mixer_poweron(ctx); + + return 0; +} +#endif + +static const struct dev_pm_ops mixer_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(mixer_suspend, mixer_resume) + SET_RUNTIME_PM_OPS(mixer_runtime_suspend, mixer_runtime_resume, NULL) +}; struct platform_driver mixer_driver = { .driver = {