From patchwork Fri Jul 25 19:22:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 4630901 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 36FF99F2B8 for ; Sun, 27 Jul 2014 11:49:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1EDB820145 for ; Sun, 27 Jul 2014 11:49:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 033CF2012F for ; Sun, 27 Jul 2014 11:49:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 055BE6E1DB; Sun, 27 Jul 2014 04:49:52 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id E05546E19C for ; Fri, 25 Jul 2014 12:25:19 -0700 (PDT) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N9A007VR8M6Q360@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Sat, 26 Jul 2014 04:25:18 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 83.D3.24374.E1FA2D35; Sat, 26 Jul 2014 04:25:18 +0900 (KST) X-AuditID: cbfee68d-b7fd46d000005f36-d3-53d2af1e50b4 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 28.C5.05196.E1FA2D35; Sat, 26 Jul 2014 04:25:18 +0900 (KST) Received: from chromebld-server.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N9A00DP98LUTO60@mmp1.samsung.com>; Sat, 26 Jul 2014 04:25:18 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH V6 2/8] drm/panel: Add support for prepare and unprepare routines Date: Sat, 26 Jul 2014 00:52:04 +0530 Message-id: <1406316130-4744-3-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1406316130-4744-1-git-send-email-ajaykumar.rs@samsung.com> References: <1406316130-4744-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprOIsWRmVeSWpSXmKPExsWyRsSkTldu/aVgg1lXtS0OvD/IYrHhzUJm i4UP7zJbzD9yjtXiytf3bBaT7k9gsbi88BKrxfddX9gtZpzfx2Sx6vAGdovnC38wW8w9mGvx c9c8Fgdej73fFrB47Jx1l91jwaZSj/vdx5k8+rasYvT4vEkugC2KyyYlNSezLLVI3y6BK2Pr ++WsBW9dKlbvO8XcwDjFsouRk0NCwESi9fMbFghbTOLCvfVsXYxcHEICSxklZvQfZ4Epuv7u KVRiEaPEh687mCCcCUwS144tYAKpYhPQltg2/SZQBweHiECKxPO/fCA1zALfGCUuLFzHBlIj LBAs0XHxCpjNIqAq8eXvZFYQm1fAXeLMvl9gvRICChJzJtmAhDkFPCSabr4DO0IIqOTxiums IDMlBM6xS1zZ8Z4FYo6AxLfJh6B6ZSU2HWCGOFpS4uCKGywTGIUXMDKsYhRNLUguKE5KLzLU K07MLS7NS9dLzs/dxAiMlNP/nv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zTq+rvR9mI4aV/78L2LWVa9v/g1kFu6+ 1Fl4y8Zoykx27im/z+QtiUyvn9QlZP7prKNa7pNZ193ndr4TUos56HC76KwiU0JOb/3pU/fc zu+cL8bYU8zasbCxcB2XgJ8SS3FGoqEWc1FxIgBX8sjU2QIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Sun, 27 Jul 2014 04:49:39 -0700 Cc: seanpaul@google.com, daniel.vetter@ffwll.ch, joshi@samsung.com, ajaynumb@gmail.com, prashanth.g@samsung.com, Ajay Kumar X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we have 2 new callbacks(prepare and unprepare) for drm_panel, make changes in all the drm drivers which use the drm_panel framework to support the new callbacks. Signed-off-by: Ajay Kumar --- drivers/gpu/drm/exynos/exynos_drm_dpi.c | 8 +++-- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 7 +++++ drivers/gpu/drm/panel/panel-ld9040.c | 18 +++++++++-- drivers/gpu/drm/panel/panel-s6e8aa0.c | 18 +++++++++-- drivers/gpu/drm/panel/panel-simple.c | 51 ++++++++++++++++++++++++------- drivers/gpu/drm/tegra/output.c | 2 ++ 6 files changed, 85 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dpi.c b/drivers/gpu/drm/exynos/exynos_drm_dpi.c index 3aa1c7e..fa08f05 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dpi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dpi.c @@ -125,14 +125,18 @@ static int exynos_dpi_create_connector(struct exynos_drm_display *display, static void exynos_dpi_poweron(struct exynos_dpi *ctx) { - if (ctx->panel) + if (ctx->panel) { + drm_panel_prepare(ctx->panel); drm_panel_enable(ctx->panel); + } } static void exynos_dpi_poweroff(struct exynos_dpi *ctx) { - if (ctx->panel) + if (ctx->panel) { drm_panel_disable(ctx->panel); + drm_panel_unprepare(ctx->panel); + } } static void exynos_dpi_dpms(struct exynos_drm_display *display, int mode) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 5e78d45..2f58e45 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1333,6 +1333,12 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi) if (ret < 0) return ret; + ret = drm_panel_prepare(dsi->panel); + if (ret < 0) { + exynos_dsi_poweroff(dsi); + return ret; + } + ret = drm_panel_enable(dsi->panel); if (ret < 0) { exynos_dsi_poweroff(dsi); @@ -1354,6 +1360,7 @@ static void exynos_dsi_disable(struct exynos_dsi *dsi) exynos_dsi_set_display_enable(dsi, false); drm_panel_disable(dsi->panel); + drm_panel_unprepare(dsi->panel); exynos_dsi_poweroff(dsi); dsi->state &= ~DSIM_STATE_ENABLED; diff --git a/drivers/gpu/drm/panel/panel-ld9040.c b/drivers/gpu/drm/panel/panel-ld9040.c index db1601f..046d9fe 100644 --- a/drivers/gpu/drm/panel/panel-ld9040.c +++ b/drivers/gpu/drm/panel/panel-ld9040.c @@ -214,7 +214,7 @@ static int ld9040_power_off(struct ld9040 *ctx) return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); } -static int ld9040_disable(struct drm_panel *panel) +static int ld9040_unprepare(struct drm_panel *panel) { struct ld9040 *ctx = panel_to_ld9040(panel); @@ -228,7 +228,12 @@ static int ld9040_disable(struct drm_panel *panel) return ld9040_power_off(ctx); } -static int ld9040_enable(struct drm_panel *panel) +static int ld9040_disable(struct drm_panel *panel) +{ + return 0; +} + +static int ld9040_prepare(struct drm_panel *panel) { struct ld9040 *ctx = panel_to_ld9040(panel); int ret; @@ -242,11 +247,16 @@ static int ld9040_enable(struct drm_panel *panel) ret = ld9040_clear_error(ctx); if (ret < 0) - ld9040_disable(panel); + ld9040_unprepare(panel); return ret; } +static int ld9040_enable(struct drm_panel *panel) +{ + return 0; +} + static int ld9040_get_modes(struct drm_panel *panel) { struct drm_connector *connector = panel->connector; @@ -272,7 +282,9 @@ static int ld9040_get_modes(struct drm_panel *panel) } static const struct drm_panel_funcs ld9040_drm_funcs = { + .unprepare = ld9040_unprepare, .disable = ld9040_disable, + .prepare = ld9040_prepare, .enable = ld9040_enable, .get_modes = ld9040_get_modes, }; diff --git a/drivers/gpu/drm/panel/panel-s6e8aa0.c b/drivers/gpu/drm/panel/panel-s6e8aa0.c index 06e57a2..51c657a 100644 --- a/drivers/gpu/drm/panel/panel-s6e8aa0.c +++ b/drivers/gpu/drm/panel/panel-s6e8aa0.c @@ -887,7 +887,7 @@ static int s6e8aa0_power_off(struct s6e8aa0 *ctx) return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); } -static int s6e8aa0_disable(struct drm_panel *panel) +static int s6e8aa0_unprepare(struct drm_panel *panel) { struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); @@ -900,7 +900,12 @@ static int s6e8aa0_disable(struct drm_panel *panel) return s6e8aa0_power_off(ctx); } -static int s6e8aa0_enable(struct drm_panel *panel) +static int s6e8aa0_disable(struct drm_panel *panel) +{ + return 0; +} + +static int s6e8aa0_prepare(struct drm_panel *panel) { struct s6e8aa0 *ctx = panel_to_s6e8aa0(panel); int ret; @@ -913,11 +918,16 @@ static int s6e8aa0_enable(struct drm_panel *panel) ret = ctx->error; if (ret < 0) - s6e8aa0_disable(panel); + s6e8aa0_unprepare(panel); return ret; } +static int s6e8aa0_enable(struct drm_panel *panel) +{ + return 0; +} + static int s6e8aa0_get_modes(struct drm_panel *panel) { struct drm_connector *connector = panel->connector; @@ -943,7 +953,9 @@ static int s6e8aa0_get_modes(struct drm_panel *panel) } static const struct drm_panel_funcs s6e8aa0_drm_funcs = { + .unprepare = s6e8aa0_unprepare, .disable = s6e8aa0_disable, + .prepare = s6e8aa0_prepare, .enable = s6e8aa0_enable, .get_modes = s6e8aa0_get_modes, }; diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index a251361..fb0cfe2 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -45,7 +45,8 @@ struct panel_desc { struct panel_simple { struct drm_panel base; - bool enabled; + bool panel_enabled; + bool backlight_enabled; const struct panel_desc *desc; @@ -93,11 +94,28 @@ static int panel_simple_get_fixed_modes(struct panel_simple *panel) return num; } +static int panel_simple_unprepare(struct drm_panel *panel) +{ + struct panel_simple *p = to_panel_simple(panel); + + if (!p->panel_enabled) + return 0; + + if (p->enable_gpio) + gpiod_set_value_cansleep(p->enable_gpio, 0); + + regulator_disable(p->supply); + + p->panel_enabled = false; + + return 0; +} + static int panel_simple_disable(struct drm_panel *panel) { struct panel_simple *p = to_panel_simple(panel); - if (!p->enabled) + if (!p->backlight_enabled) return 0; if (p->backlight) { @@ -105,21 +123,17 @@ static int panel_simple_disable(struct drm_panel *panel) backlight_update_status(p->backlight); } - if (p->enable_gpio) - gpiod_set_value_cansleep(p->enable_gpio, 0); - - regulator_disable(p->supply); - p->enabled = false; + p->backlight_enabled = false; return 0; } -static int panel_simple_enable(struct drm_panel *panel) +static int panel_simple_prepare(struct drm_panel *panel) { struct panel_simple *p = to_panel_simple(panel); int err; - if (p->enabled) + if (p->panel_enabled) return 0; err = regulator_enable(p->supply); @@ -131,12 +145,24 @@ static int panel_simple_enable(struct drm_panel *panel) if (p->enable_gpio) gpiod_set_value_cansleep(p->enable_gpio, 1); + p->panel_enabled = true; + + return 0; +} + +static int panel_simple_enable(struct drm_panel *panel) +{ + struct panel_simple *p = to_panel_simple(panel); + + if (p->backlight_enabled) + return 0; + if (p->backlight) { p->backlight->props.power = FB_BLANK_UNBLANK; backlight_update_status(p->backlight); } - p->enabled = true; + p->backlight_enabled = true; return 0; } @@ -164,6 +190,8 @@ static int panel_simple_get_modes(struct drm_panel *panel) static const struct drm_panel_funcs panel_simple_funcs = { .disable = panel_simple_disable, + .unprepare = panel_simple_unprepare, + .prepare = panel_simple_prepare, .enable = panel_simple_enable, .get_modes = panel_simple_get_modes, }; @@ -178,7 +206,8 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) if (!panel) return -ENOMEM; - panel->enabled = false; + panel->panel_enabled = false; + panel->backlight_enabled = false; panel->desc = desc; panel->supply = devm_regulator_get(dev, "power"); diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index 446837e..b574ee6 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -139,9 +139,11 @@ static void tegra_encoder_dpms(struct drm_encoder *encoder, int mode) if (mode != DRM_MODE_DPMS_ON) { drm_panel_disable(panel); + drm_panel_unprepare(panel); tegra_output_disable(output); } else { tegra_output_enable(output); + drm_panel_prepare(panel); drm_panel_enable(panel); } }