From patchwork Tue Jan 20 16:38:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 5673171 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 318749F2ED for ; Wed, 21 Jan 2015 02:20:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E66A2049E for ; Wed, 21 Jan 2015 02:20:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 30A8F204AB for ; Wed, 21 Jan 2015 02:20:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 945306E6EE; Tue, 20 Jan 2015 18:20:22 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F8226E22B for ; Tue, 20 Jan 2015 08:47:01 -0800 (PST) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIH00FV0IMC2V90@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 21 Jan 2015 01:47:00 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id DD.5E.18484.4868EB45; Wed, 21 Jan 2015 01:47:00 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-9f-54be8684b73d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 97.6A.20081.4868EB45; Wed, 21 Jan 2015 01:47:00 +0900 (KST) Received: from chromebld-server.sisodomain.com ([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 <0NIH00K6NILOY370@mmp2.samsung.com>; Wed, 21 Jan 2015 01:47:00 +0900 (KST) From: Ajay Kumar To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: [PATCH V9 06/14] drm/bridge: ptn3460: support drm_panel Date: Tue, 20 Jan 2015 22:08:47 +0530 Message-id: <1421771935-31618-7-git-send-email-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 2.2.0 In-reply-to: <1421771935-31618-1-git-send-email-ajaykumar.rs@samsung.com> References: <1421771935-31618-1-git-send-email-ajaykumar.rs@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpnkeLIzCtJLcpLzFFi42JZI2JSq9vSti/EYOk9XYsD7w+yWGx4s5DZ YtnafywWCx/eZbaYf+Qcq8WVr+/ZLCbdn8BicXnhJVaL3gVX2Sw2Pb7GajHj/D4mi1WHN7Bb zD2Ya/Fz1zwWBz6Pvd8WsHjsnHWX3WPBplKP+93HmTw2L6n36NuyitHj8ya5APYoLpuU1JzM stQifbsErozJT6eyF7zVqph8aTJrA+NE5S5GTg4JAROJ9ZPnskHYYhIX7q0Hsrk4hASWMkq8 /P+EBabo1fINLBCJ6YwS/w4/YYJwJjBJTGu/B1bFJqAtsW36TTBbRKCLUWLbQXWQImaBP4wS n3/tZwRJCAs4SBzff5AZxGYRUJXY2XaFHcTmFfCQ2PC+nRFinZzElluPwOKcAp4SOz5cZQWx hYBqFq8/zAwyVELgFrvElsWb2SAGCUh8m3wIaDMHUEJWYtMBZog5khIHV9xgmcAovICRYRWj aGpBckFxUnqRsV5xY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CUamA0 3HbzikbXDI2Q0zecLE2bWlk3OGcuLFtsM//xltgN746b3n+Yvd009+I+V6GSjqwXP01VwrQ5 JzPPqfRdYdb7Mz7S7fRN51N/jWWnqBjeuyHP5pdw3mAfk+k+XzaWDane/0U+7xG5wf/3Z2jd OePUroutE14/i5Wfc/aBbqyZj1rzfpvOog4lluKMREMt5qLiRABxVW5k5AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Mailman-Approved-At: Tue, 20 Jan 2015 18:20:08 -0800 Cc: kgene.kim@samsung.com, seanpaul@google.com, daniel.vetter@ffwll.ch, jg1.han@samsung.com, ajaynumb@gmail.com, bhushan.r@samsung.com, prashanth.g@samsung.com, Ajay Kumar X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_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 Add drm_panel calls to the driver to make the panel and bridge work together in tandem. Signed-off-by: Ajay Kumar Acked-by: Inki Dae Tested-by: Rahul Sharma Tested-by: Javier Martinez Canillas Tested-by: Gustavo Padovan Tested-by: Sjoerd Simons --- .../devicetree/bindings/drm/bridge/ptn3460.txt | 12 ++++++ drivers/gpu/drm/bridge/Kconfig | 1 + drivers/gpu/drm/bridge/ptn3460.c | 42 ++++++++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/Documentation/devicetree/bindings/drm/bridge/ptn3460.txt b/Documentation/devicetree/bindings/drm/bridge/ptn3460.txt index 52b93b2..663fe6c 100644 --- a/Documentation/devicetree/bindings/drm/bridge/ptn3460.txt +++ b/Documentation/devicetree/bindings/drm/bridge/ptn3460.txt @@ -17,6 +17,11 @@ Required properties: | 6 | 1600x900 | ChiMei M215HGE | +-------+------------+------------------+ + - video interfaces: Device node can contain video interface port + nodes for panel according to [1]. + +[1]: Documentation/devicetree/bindings/media/video-interfaces.txt + Example: lvds-bridge@20 { compatible = "nxp,ptn3460"; @@ -24,4 +29,11 @@ Example: powerdown-gpio = <&gpy2 5 1 0 0>; reset-gpio = <&gpx1 5 1 0 0>; edid-emulation = <5>; + ports { + port@0 { + bridge_out: endpoint { + remote-endpoint = <&panel_in>; + }; + }; + }; }; diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 4254c2b..8b426e2 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -3,5 +3,6 @@ config DRM_PTN3460 depends on DRM depends on OF && I2C select DRM_KMS_HELPER + select DRM_PANEL ---help--- ptn3460 eDP-LVDS bridge chip driver. diff --git a/drivers/gpu/drm/bridge/ptn3460.c b/drivers/gpu/drm/bridge/ptn3460.c index 7adeb60..e6d5ae7 100644 --- a/drivers/gpu/drm/bridge/ptn3460.c +++ b/drivers/gpu/drm/bridge/ptn3460.c @@ -19,6 +19,9 @@ #include #include #include +#include + +#include #include "bridge/ptn3460.h" @@ -38,6 +41,7 @@ struct ptn3460_bridge { struct i2c_client *client; struct drm_bridge bridge; struct edid *edid; + struct drm_panel *panel; int gpio_pd_n; int gpio_rst_n; u32 edid_emulation; @@ -137,6 +141,11 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) gpio_set_value(ptn_bridge->gpio_rst_n, 1); } + if (drm_panel_prepare(ptn_bridge->panel)) { + DRM_ERROR("failed to prepare panel\n"); + return; + } + /* * There's a bug in the PTN chip where it falsely asserts hotplug before * it is fully functional. We're forced to wait for the maximum start up @@ -153,6 +162,12 @@ static void ptn3460_pre_enable(struct drm_bridge *bridge) static void ptn3460_enable(struct drm_bridge *bridge) { + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); + + if (drm_panel_enable(ptn_bridge->panel)) { + DRM_ERROR("failed to enable panel\n"); + return; + } } static void ptn3460_disable(struct drm_bridge *bridge) @@ -164,6 +179,11 @@ static void ptn3460_disable(struct drm_bridge *bridge) ptn_bridge->enabled = false; + if (drm_panel_disable(ptn_bridge->panel)) { + DRM_ERROR("failed to disable panel\n"); + return; + } + if (gpio_is_valid(ptn_bridge->gpio_rst_n)) gpio_set_value(ptn_bridge->gpio_rst_n, 1); @@ -173,6 +193,12 @@ static void ptn3460_disable(struct drm_bridge *bridge) static void ptn3460_post_disable(struct drm_bridge *bridge) { + struct ptn3460_bridge *ptn_bridge = bridge_to_ptn3460(bridge); + + if (drm_panel_unprepare(ptn_bridge->panel)) { + DRM_ERROR("failed to unprepare panel\n"); + return; + } } static int ptn3460_get_modes(struct drm_connector *connector) @@ -267,6 +293,9 @@ int ptn3460_bridge_attach(struct drm_bridge *bridge) drm_mode_connector_attach_encoder(&ptn_bridge->connector, bridge->encoder); + if (ptn_bridge->panel) + drm_panel_attach(ptn_bridge->panel, &ptn_bridge->connector); + return ret; } @@ -283,6 +312,7 @@ static int ptn3460_probe(struct i2c_client *client, { struct device *dev = &client->dev; struct ptn3460_bridge *ptn_bridge; + struct device_node *endpoint, *panel_node; int ret; ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL); @@ -290,6 +320,17 @@ static int ptn3460_probe(struct i2c_client *client, return -ENOMEM; } + endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); + if (endpoint) { + panel_node = of_graph_get_remote_port_parent(endpoint); + if (panel_node) { + ptn_bridge->panel = of_drm_find_panel(panel_node); + of_node_put(panel_node); + if (!ptn_bridge->panel) + return -EPROBE_DEFER; + } + } + ptn_bridge->client = client; ptn_bridge->gpio_pd_n = of_get_named_gpio(dev->of_node, "powerdown-gpio", 0); @@ -327,6 +368,7 @@ static int ptn3460_probe(struct i2c_client *client, } ptn_bridge->bridge.funcs = &ptn3460_bridge_funcs; + ptn_bridge->bridge.of_node = dev->of_node; ret = drm_bridge_add(&ptn_bridge->bridge); if (ret) { DRM_ERROR("Failed to add bridge\n");