From patchwork Mon May 30 16:39:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Senna Tschudin X-Patchwork-Id: 9141821 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 33D9260777 for ; Mon, 30 May 2016 16:42:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26F9B2796F for ; Mon, 30 May 2016 16:42:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B50827D17; Mon, 30 May 2016 16:42:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id C62192796F for ; Mon, 30 May 2016 16:42:58 +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 1b7QG0-0000MF-Se; Mon, 30 May 2016 16:41:36 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1b7QFq-0000H1-UT for linux-arm-kernel@lists.infradead.org; Mon, 30 May 2016 16:41:27 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: peter) with ESMTPSA id D171E2636DB From: Peter Senna Tschudin To: airlied@linux.ie, akpm@linux-foundation.org, davem@davemloft.net, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, enric.balletbo@collabora.com, galak@codeaurora.org, gregkh@linuxfoundation.org, heiko@sntech.de, ijc+devicetree@hellion.org.uk, jslaby@suse.cz, kernel@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, linux@roeck-us.net, mark.rutland@arm.com, martin.donnelly@ge.com, martyn.welch@collabora.co.uk, mchehab@osg.samsung.com, pawel.moll@arm.com, peter.senna@collabora.com, p.zabel@pengutronix.de, rmk+kernel@armlinux.org.uk, robh+dt@kernel.org, shawnguo@kernel.org, tiwai@suse.com, treding@nvidia.com, ykk@rock-chips.com Subject: [PATCH 1/5] drm/imx-ldb: Add support to drm-bridge Date: Mon, 30 May 2016 18:39:41 +0200 Message-Id: <1464626385-19253-2-git-send-email-peter.senna@collabora.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1464626385-19253-1-git-send-email-peter.senna@collabora.com> References: <1464626385-19253-1-git-send-email-peter.senna@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160530_094127_367321_95107046 X-CRM114-Status: GOOD ( 16.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add support to attach a drm_bridge to imx-ldb in addition to existing support to attach a LVDS panel. Signed-off-by: Peter Senna Tschudin --- drivers/gpu/drm/imx/imx-ldb.c | 75 +++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c index a58eee5..7233a81 100644 --- a/drivers/gpu/drm/imx/imx-ldb.c +++ b/drivers/gpu/drm/imx/imx-ldb.c @@ -57,7 +57,11 @@ struct imx_ldb_channel { struct imx_ldb *ldb; struct drm_connector connector; struct drm_encoder encoder; + + /* Defines what is connected to the ldb, only one at a time */ struct drm_panel *panel; + struct drm_bridge *ext_bridge; + struct device_node *child; int chno; void *edid; @@ -295,6 +299,10 @@ static void imx_ldb_encoder_mode_set(struct drm_encoder *encoder, } } +static void imx_ldb_encoder_enable(struct drm_encoder *encoder) +{ +} + static void imx_ldb_encoder_disable(struct drm_encoder *encoder) { struct imx_ldb_channel *imx_ldb_ch = enc_to_imx_ldb_ch(encoder); @@ -373,6 +381,7 @@ static const struct drm_encoder_helper_funcs imx_ldb_encoder_helper_funcs = { .prepare = imx_ldb_encoder_prepare, .commit = imx_ldb_encoder_commit, .mode_set = imx_ldb_encoder_mode_set, + .enable = imx_ldb_encoder_enable, .disable = imx_ldb_encoder_disable, }; @@ -417,16 +426,28 @@ static int imx_ldb_register(struct drm_device *drm, drm_encoder_init(drm, &imx_ldb_ch->encoder, &imx_ldb_encoder_funcs, DRM_MODE_ENCODER_LVDS, NULL); - drm_connector_helper_add(&imx_ldb_ch->connector, - &imx_ldb_connector_helper_funcs); - drm_connector_init(drm, &imx_ldb_ch->connector, - &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS); - - if (imx_ldb_ch->panel) + if (imx_ldb_ch->panel) { + drm_connector_helper_add(&imx_ldb_ch->connector, + &imx_ldb_connector_helper_funcs); + drm_connector_init(drm, &imx_ldb_ch->connector, + &imx_ldb_connector_funcs, + DRM_MODE_CONNECTOR_LVDS); drm_panel_attach(imx_ldb_ch->panel, &imx_ldb_ch->connector); - drm_mode_connector_attach_encoder(&imx_ldb_ch->connector, - &imx_ldb_ch->encoder); + drm_mode_connector_attach_encoder(&imx_ldb_ch->connector, + &imx_ldb_ch->encoder); + } + + if (imx_ldb_ch->ext_bridge) { + imx_ldb_ch->ext_bridge->encoder = &imx_ldb_ch->encoder; + + imx_ldb_ch->encoder.bridge = imx_ldb_ch->ext_bridge; + ret = drm_bridge_attach(drm, imx_ldb_ch->ext_bridge); + if (ret) { + DRM_ERROR("Failed to initialize bridge with drm\n"); + return ret; + } + } return 0; } @@ -583,23 +604,35 @@ static int imx_ldb_bind(struct device *dev, struct device *master, void *data) endpoint = of_get_child_by_name(port, "endpoint"); if (endpoint) { remote = of_graph_get_remote_port_parent(endpoint); - if (remote) - channel->panel = of_drm_find_panel(remote); - else - return -EPROBE_DEFER; - if (!channel->panel) { - dev_err(dev, "panel not found: %s\n", - remote->full_name); - return -EPROBE_DEFER; + if (remote) { + /* Only one of these two will succeed */ + channel->panel = + of_drm_find_panel(remote); + + channel->ext_bridge = + of_drm_find_bridge(remote); + + /* + * If the bridge is compiled as a + * module, it may take some time until + * the bridge driver is available. + * Defer until the bridge driver is + * ready. + */ + if (!channel->panel && + !channel->ext_bridge) + return -EPROBE_DEFER; } } } - edidp = of_get_property(child, "edid", &channel->edid_len); - if (edidp) { - channel->edid = kmemdup(edidp, channel->edid_len, - GFP_KERNEL); - } else if (!channel->panel) { + if (channel->panel) { + edidp = of_get_property(child, "edid", + &channel->edid_len); + if (edidp) + channel->edid = kmemdup(edidp, + channel->edid_len, GFP_KERNEL); + } else { ret = of_get_drm_display_mode(child, &channel->mode, 0); if (!ret) channel->mode_valid = 1;