From patchwork Thu Aug 6 14:07:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yakir Yang X-Patchwork-Id: 6959361 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF3899F39D for ; Thu, 6 Aug 2015 14:10:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C790B20658 for ; Thu, 6 Aug 2015 14:10:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8DFD12064B for ; Thu, 6 Aug 2015 14:10:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZNLsB-0007eA-7F; Thu, 06 Aug 2015 14:10:19 +0000 Received: from regular1.263xmail.com ([211.150.99.130]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZNLrr-0006DA-Pt; Thu, 06 Aug 2015 14:10:05 +0000 Received: from ykk?rock-chips.com (unknown [192.168.167.140]) by regular1.263xmail.com (Postfix) with SMTP id 8A6F66750; Thu, 6 Aug 2015 22:09:24 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id 0658143E; Thu, 6 Aug 2015 22:09:16 +0800 (CST) X-RL-SENDER: ykk@rock-chips.com X-FST-TO: heiko@sntech.de X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: ykk@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: ykk@rock-chips.com X-DNS-TYPE: 0 Received: from localhost.localdomain (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith ESMTP id 18495JP1FFM; Thu, 06 Aug 2015 22:09:19 +0800 (CST) From: Yakir Yang To: Heiko Stuebner , Russell King , Fabio Estevam , Jingoo Han , Inki Dae Subject: [RFC PATCH 2/8] drm: exynos/dp: convert to drm bridge mode Date: Thu, 6 Aug 2015 09:07:21 -0500 Message-Id: <1438870041-23130-1-git-send-email-ykk@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1438868947-22132-1-git-send-email-ykk@rock-chips.com> References: <1438868947-22132-1-git-send-email-ykk@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150806_071003_819391_7A0E9079 X-CRM114-Status: GOOD ( 15.92 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Krzysztof Kozlowski , Takashi Iwai , dri-devel@lists.freedesktop.org, Andrzej Hajda , Yakir Yang , Gustavo Padovan , Ajay Kumar , linux-samsung-soc@vger.kernel.org, Vincent Palatin , Joonyoung Shim , linux-rockchip@lists.infradead.org, Kukjin Kim , Thierry Reding , David Airlie , dianders@google.com, linux-arm-kernel@lists.infradead.org, Mark Yao , Seung-Woo Kim , linux-kernel@vger.kernel.org, Kyungmin Park , djkurtz@google.com, Philipp Zabel , Andy Yan MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 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 In order to move exynos dp code to bridge directory, we need to convert driver drm bridge mode first. As dp driver already have a ptn3460 bridge, so we need to move ptn bridge to the next bridge of dp bridge. Signed-off-by: Yakir Yang --- drivers/gpu/drm/exynos/exynos_dp_core.c | 196 ++++++++++++++++++++------------ drivers/gpu/drm/exynos/exynos_dp_core.h | 2 + 2 files changed, 126 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index a8097a4..aa99e23 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -3,6 +3,7 @@ * * Copyright (C) 2012 Samsung Electronics Co., Ltd. * Author: Jingoo Han + * Yakir Yang * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -998,59 +999,6 @@ static struct drm_connector_helper_funcs exynos_dp_connector_helper_funcs = { .best_encoder = exynos_dp_best_encoder, }; -/* returns the number of bridges attached */ -static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp, - struct drm_encoder *encoder) -{ - int ret; - - encoder->bridge = dp->bridge; - dp->bridge->encoder = encoder; - ret = drm_bridge_attach(encoder->dev, dp->bridge); - if (ret) { - DRM_ERROR("Failed to attach bridge to drm\n"); - return ret; - } - - return 0; -} - -static int exynos_dp_create_connector(struct exynos_drm_display *display, - struct drm_encoder *encoder) -{ - struct exynos_dp_device *dp = display_to_dp(display); - struct drm_connector *connector = &dp->connector; - int ret; - - dp->encoder = encoder; - - /* Pre-empt DP connector creation if there's a bridge */ - if (dp->bridge) { - ret = exynos_drm_attach_lcd_bridge(dp, encoder); - if (!ret) - return 0; - } - - connector->polled = DRM_CONNECTOR_POLL_HPD; - - ret = drm_connector_init(dp->drm_dev, connector, - &exynos_dp_connector_funcs, - DRM_MODE_CONNECTOR_eDP); - if (ret) { - DRM_ERROR("Failed to initialize connector with drm\n"); - return ret; - } - - drm_connector_helper_add(connector, &exynos_dp_connector_helper_funcs); - drm_connector_register(connector); - drm_mode_connector_attach_encoder(connector, encoder); - - if (dp->panel) - ret = drm_panel_attach(dp->panel, &dp->connector); - - return ret; -} - static void exynos_dp_phy_init(struct exynos_dp_device *dp) { if (dp->phy) @@ -1115,23 +1063,126 @@ static void exynos_dp_poweroff(struct exynos_dp_device *dp) } } -static void exynos_dp_dpms(struct exynos_drm_display *display, int mode) +/* returns the number of bridges attached */ +static int exynos_drm_attach_lcd_bridge(struct exynos_dp_device *dp, + struct drm_encoder *encoder) +{ + int ret; + + dp->bridge->next = dp->ptn_bridge; + dp->bridge->encoder = encoder; + ret = drm_bridge_attach(encoder->dev, dp->bridge); + if (ret) { + DRM_ERROR("Failed to attach ptn bridge to drm\n"); + return ret; + } + + return 0; +} + +static int exynos_dp_bridge_attach(struct drm_bridge *bridge) +{ + + struct exynos_dp_device *dp = bridge->driver_private; + struct drm_encoder *encoder = dp->encoder; + struct drm_connector *connector = &dp->connector; + int ret; + + if (!bridge->encoder) { + DRM_ERROR("Parent encoder object not found"); + return -ENODEV; + } + + encoder->bridge = bridge; + + /* Pre-empt DP connector creation if there's a bridge */ + if (dp->ptn_bridge) { + ret = exynos_drm_attach_lcd_bridge(dp, encoder); + if (ret) + return -ENODEV; + } + + connector->polled = DRM_CONNECTOR_POLL_HPD; + + ret = drm_connector_init(dp->drm_dev, connector, + &exynos_dp_connector_funcs, DRM_MODE_CONNECTOR_eDP); + if (ret) { + DRM_ERROR("Failed to initialize connector with drm\n"); + return ret; + } + + drm_connector_helper_add(connector, &exynos_dp_connector_helper_funcs); + drm_connector_register(connector); + drm_mode_connector_attach_encoder(connector, encoder); + + if (dp->panel) + ret = drm_panel_attach(dp->panel, &dp->connector); + + return ret; +} + +static void exynos_dp_bridge_nop(struct drm_bridge *bridge) +{ + /* do nothing */ +} + +static void exynos_dp_bridge_enable(struct drm_bridge *bridge) +{ + struct exynos_dp_device *dp = bridge->driver_private; + + exynos_dp_poweron(dp); + dp->dpms_mode = DRM_MODE_DPMS_ON; +} + +static void exynos_dp_bridge_disable(struct drm_bridge *bridge) +{ + struct exynos_dp_device *dp = bridge->driver_private; + + exynos_dp_poweroff(dp); + dp->dpms_mode = DRM_MODE_DPMS_OFF; +} + +static const struct drm_bridge_funcs exynos_dp_bridge_funcs = { + .enable = exynos_dp_bridge_enable, + .disable = exynos_dp_bridge_disable, + .pre_enable = exynos_dp_bridge_nop, + .post_disable = exynos_dp_bridge_nop, + .attach = exynos_dp_bridge_attach, +}; + +static int exynos_dp_create_connector(struct exynos_drm_display *display, + struct drm_encoder *encoder) { struct exynos_dp_device *dp = display_to_dp(display); + struct drm_device *drm_dev = dp->drm_dev; + struct drm_bridge *bridge; + int ret; - switch (mode) { - case DRM_MODE_DPMS_ON: - exynos_dp_poweron(dp); - break; - case DRM_MODE_DPMS_STANDBY: - case DRM_MODE_DPMS_SUSPEND: - case DRM_MODE_DPMS_OFF: - exynos_dp_poweroff(dp); - break; - default: - break; + bridge = devm_kzalloc(drm_dev->dev, sizeof(*bridge), GFP_KERNEL); + if (!bridge) { + DRM_ERROR("failed to allocate for drm bridge\n"); + return -ENOMEM; } - dp->dpms_mode = mode; + + dp->bridge = bridge; + dp->encoder = encoder; + + bridge->driver_private = dp; + bridge->encoder = dp->encoder; + bridge->funcs = &exynos_dp_bridge_funcs; + + ret = drm_bridge_attach(drm_dev, bridge); + if (ret) { + DRM_ERROR("failed to attach drm bridge\n"); + return -EINVAL; + } + + return 0; +} + +static void exynos_dp_dpms(struct exynos_drm_display *display, int mode) +{ + /* do nothing */ } static struct exynos_drm_display_ops exynos_dp_display_ops = { @@ -1243,7 +1294,7 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data) } } - if (!dp->panel && !dp->bridge) { + if (!dp->panel && !dp->ptn_bridge) { ret = exynos_dp_dt_parse_panel(dp); if (ret) return ret; @@ -1316,7 +1367,7 @@ static void exynos_dp_unbind(struct device *dev, struct device *master, { struct exynos_dp_device *dp = dev_get_drvdata(dev); - exynos_dp_dpms(&dp->display, DRM_MODE_DPMS_OFF); + exynos_dp_bridge_disable(dp->bridge); } static const struct component_ops exynos_dp_ops = { @@ -1351,9 +1402,9 @@ static int exynos_dp_probe(struct platform_device *pdev) if (endpoint) { bridge_node = of_graph_get_remote_port_parent(endpoint); if (bridge_node) { - dp->bridge = of_drm_find_bridge(bridge_node); + dp->ptn_bridge = of_drm_find_bridge(bridge_node); of_node_put(bridge_node); - if (!dp->bridge) + if (!dp->ptn_bridge) return -EPROBE_DEFER; } else { return -EPROBE_DEFER; @@ -1375,7 +1426,7 @@ static int exynos_dp_suspend(struct device *dev) { struct exynos_dp_device *dp = dev_get_drvdata(dev); - exynos_dp_dpms(&dp->display, DRM_MODE_DPMS_OFF); + exynos_dp_bridge_disable(dp->bridge); return 0; } @@ -1383,7 +1434,7 @@ static int exynos_dp_resume(struct device *dev) { struct exynos_dp_device *dp = dev_get_drvdata(dev); - exynos_dp_dpms(&dp->display, DRM_MODE_DPMS_ON); + exynos_dp_bridge_enable(dp->bridge); return 0; } #endif @@ -1410,5 +1461,6 @@ struct platform_driver dp_driver = { }; MODULE_AUTHOR("Jingoo Han "); +MODULE_AUTHOR("Yakir Yang "); MODULE_DESCRIPTION("Samsung SoC DP Driver"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.h b/drivers/gpu/drm/exynos/exynos_dp_core.h index c321ad5..f2584b8 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.h +++ b/drivers/gpu/drm/exynos/exynos_dp_core.h @@ -3,6 +3,7 @@ * * Copyright (C) 2012 Samsung Electronics Co., Ltd. * Author: Jingoo Han + * Yakir Yang * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -154,6 +155,7 @@ struct exynos_dp_device { struct drm_encoder *encoder; struct drm_panel *panel; struct drm_bridge *bridge; + struct drm_bridge *ptn_bridge; struct clk *clock; unsigned int irq; void __iomem *reg_base;