From patchwork Mon Aug 26 15:26:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 11114873 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D4FB1395 for ; Mon, 26 Aug 2019 15:27:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 360DC217F5 for ; Mon, 26 Aug 2019 15:27:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 360DC217F5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3D6166E21D; Mon, 26 Aug 2019 15:27:00 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2DE9C6E21D for ; Mon, 26 Aug 2019 15:26:59 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 7114528BD81; Mon, 26 Aug 2019 16:26:57 +0100 (BST) From: Boris Brezillon To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 06/21] drm/exynos: Implement bridge_funcs instead of encoder_helper_funcs Date: Mon, 26 Aug 2019 17:26:34 +0200 Message-Id: <20190826152649.13820-7-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190826152649.13820-1-boris.brezillon@collabora.com> References: <20190826152649.13820-1-boris.brezillon@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nikita Yushchenko , Jernej Skrabec , Laurent Pinchart , Neil Armstrong , Andrey Smirnov , Jonas Karlman , Seung-Woo Kim , Kyungmin Park , Thierry Reding , Chris Healy , Boris Brezillon , kernel@collabora.com, Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Those hooks are called exactly at the same time except the bridge funcs have pre_enable()/post_disable() hooks which allows us to get rid of the hack resetting encoder->bridge.next (was needed to control the encoder/bridge enable/disable sequence). Signed-off-by: Boris Brezillon --- Changes in v2: * New patch (replacement for "drm/exynos: Get rid of exynos_dsi->out_bridge") --- drivers/gpu/drm/exynos/exynos_drm_dsi.c | 55 ++++++++++++++++--------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index c555cecfe1f5..4f713b0ac244 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1374,40 +1374,48 @@ static void exynos_dsi_unregister_te_irq(struct exynos_dsi *dsi) } } -static void exynos_dsi_enable(struct drm_encoder *encoder) +static void exynos_dsi_pre_enable(struct drm_bridge *bridge) { + struct drm_encoder *encoder = bridge_to_encoder(bridge); struct exynos_dsi *dsi = encoder_to_dsi(encoder); - int ret; if (dsi->state & DSIM_STATE_ENABLED) return; pm_runtime_get_sync(dsi->dev); - dsi->state |= DSIM_STATE_ENABLED; if (dsi->panel) { + int ret; + ret = drm_panel_prepare(dsi->panel); WARN_ON(ret && ret != -ENOSYS); - } else { - drm_bridge_pre_enable(dsi->out_bridge); } +} + +static void exynos_dsi_enable(struct drm_bridge *bridge) +{ + struct drm_encoder *encoder = bridge_to_encoder(bridge); + struct exynos_dsi *dsi = encoder_to_dsi(encoder); + + if (dsi->state & DSIM_STATE_ENABLED) + return; exynos_dsi_set_display_mode(dsi); exynos_dsi_set_display_enable(dsi, true); if (dsi->panel) { + int ret; + ret = drm_panel_enable(dsi->panel); WARN_ON(ret && ret != -ENOSYS); - } else { - drm_bridge_enable(dsi->out_bridge); } - dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE; - return; + dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE | DSIM_STATE_ENABLED; } -static void exynos_dsi_disable(struct drm_encoder *encoder) +static void exynos_dsi_disable(struct drm_bridge *bridge) { + struct drm_encoder *encoder = bridge_to_encoder(bridge); struct exynos_dsi *dsi = encoder_to_dsi(encoder); if (!(dsi->state & DSIM_STATE_ENABLED)) @@ -1415,11 +1423,18 @@ static void exynos_dsi_disable(struct drm_encoder *encoder) dsi->state &= ~DSIM_STATE_VIDOUT_AVAILABLE; - drm_panel_disable(dsi->panel); - drm_bridge_disable(dsi->out_bridge); exynos_dsi_set_display_enable(dsi, false); drm_panel_unprepare(dsi->panel); - drm_bridge_post_disable(dsi->out_bridge); +} + +static void exynos_dsi_post_disable(struct drm_bridge *bridge) +{ + struct drm_encoder *encoder = bridge_to_encoder(bridge); + struct exynos_dsi *dsi = encoder_to_dsi(encoder); + + if (!(dsi->state & DSIM_STATE_ENABLED)) + return; + dsi->state &= ~DSIM_STATE_ENABLED; pm_runtime_put_sync(dsi->dev); } @@ -1489,9 +1504,11 @@ static int exynos_dsi_create_connector(struct drm_encoder *encoder) return 0; } -static const struct drm_encoder_helper_funcs exynos_dsi_encoder_helper_funcs = { +static const struct drm_bridge_funcs exynos_dsi_bridge_funcs = { + .pre_enable = exynos_dsi_pre_enable, .enable = exynos_dsi_enable, .disable = exynos_dsi_disable, + .post_disable = exynos_dsi_post_disable, }; static const struct drm_encoder_funcs exynos_dsi_encoder_funcs = { @@ -1512,7 +1529,6 @@ static int exynos_dsi_host_attach(struct mipi_dsi_host *host, if (out_bridge) { drm_bridge_attach(encoder, out_bridge, NULL); dsi->out_bridge = out_bridge; - encoder->bridge.next = NULL; } else { int ret = exynos_dsi_create_connector(encoder); @@ -1569,7 +1585,8 @@ static int exynos_dsi_host_detach(struct mipi_dsi_host *host, if (dsi->panel) { mutex_lock(&drm->mode_config.mutex); - exynos_dsi_disable(&dsi->encoder); + exynos_dsi_disable(&dsi->encoder.bridge); + exynos_dsi_post_disable(&dsi->encoder.bridge); drm_panel_detach(dsi->panel); dsi->panel = NULL; dsi->connector.status = connector_status_disconnected; @@ -1674,11 +1691,10 @@ static int exynos_dsi_bind(struct device *dev, struct device *master, struct drm_bridge *in_bridge; int ret; + encoder->bridge.funcs = &exynos_dsi_bridge_funcs; drm_encoder_init(drm_dev, encoder, &exynos_dsi_encoder_funcs, DRM_MODE_ENCODER_TMDS, NULL); - drm_encoder_helper_add(encoder, &exynos_dsi_encoder_helper_funcs); - ret = exynos_drm_set_possible_crtcs(encoder, EXYNOS_DISPLAY_TYPE_LCD); if (ret < 0) return ret; @@ -1698,7 +1714,8 @@ static void exynos_dsi_unbind(struct device *dev, struct device *master, struct drm_encoder *encoder = dev_get_drvdata(dev); struct exynos_dsi *dsi = encoder_to_dsi(encoder); - exynos_dsi_disable(encoder); + exynos_dsi_disable(&encoder->bridge); + exynos_dsi_post_disable(&encoder->bridge); mipi_dsi_host_unregister(&dsi->dsi_host); }