From patchwork Mon Oct 27 23:57:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 5166921 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B4005C11AC for ; Mon, 27 Oct 2014 23:57:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4570201F5 for ; Mon, 27 Oct 2014 23:57:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 374F72017A for ; Mon, 27 Oct 2014 23:57:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752597AbaJ0X5x (ORCPT ); Mon, 27 Oct 2014 19:57:53 -0400 Received: from gw-1.arm.linux.org.uk ([78.32.30.217]:46217 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752369AbaJ0X5x (ORCPT ); Mon, 27 Oct 2014 19:57:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=pandora-2014; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=LaCJuf6fVnXeRmBeusfhojgwoC2rdsv2ApY6rhLGGrY=; b=oM76tSKhVbc9gdxSowmcMv/lBBh5/7Jg6azuMR6iwMEbtbJAUAlnGLwFwDsgu4/+pzYQDW41TVm2U75TxSM9iB5qhN+1CybLT83M1JTfx9Pqy1MMWbcOwKW3dXGHbe674M1zyEQc98YHoCmoayo7Ah4gC5F5//exSA0xO3JQN+o=; Received: from n2100.arm.linux.org.uk ([2001:4d48:ad52:3201:214:fdff:fe10:4f86]:35443) by pandora.arm.linux.org.uk with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.82_1-5b7a7c0-XX) (envelope-from ) id 1XiuAM-0006Ni-4O; Mon, 27 Oct 2014 23:57:38 +0000 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1XiuAI-0001Ky-OU; Mon, 27 Oct 2014 23:57:34 +0000 Date: Mon, 27 Oct 2014 23:57:34 +0000 From: Russell King - ARM Linux To: Daniel Vetter Cc: Sean Paul , Thierry Reding , Ajay Kumar , dri-devel , linux-samsung-soc , InKi Dae , Thierry Reding , Rob Clark , Ajay kumar , Jingoo Han , sunil joshi , Prashanth G Subject: Re: [PATCH V7 03/12] drm/bridge: Add helper functions for drm_bridge Message-ID: <20141027235734.GX27405@n2100.arm.linux.org.uk> References: <1409149783-12416-1-git-send-email-ajaykumar.rs@samsung.com> <1409149783-12416-4-git-send-email-ajaykumar.rs@samsung.com> <20141027190137.GT26941@phenom.ffwll.local> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 On Mon, Oct 27, 2014 at 11:26:30PM +0100, Daniel Vetter wrote: > Looking at the of_drm_find_panel function I actually wonder how that > works - the drm_panel doesn't really need to stick around afaics. > After all panel_list is global so some other driver can unload. > Russell's of support for possible_crtcs code works differently since > it only looks at per-drm_device lists. > > This bridge code here though suffers from the same. So to me this > looks rather fishy. > > It doesn't help that we have drm_of.[hc] around but not all the of > code is in there. Adding Russell too. I rather dropped the ball with imx-drm when things became difficult with asking Greg to pull my git tree - and as a result, I decided that I would no longer be helping with patch submission for imx-drm, nor trying to get it out of the staging tree anymore. I do still have the patch (dated from July) in my git tree which adds it to imx-drm - see below. Rebased to 3.18-rc2 today. I also have a patch (from April) which creates a generic OF DDC connector helper, but that remains unfinished, in the sense that it lives beside imx-drm, pulling the DDC specific code out of imx-hdmi and imx-tve, even though there's nothing imx-drm specific about it. 8<==== From: Russell King Subject: [PATCH] imx-drm: convert imx-drm to use the generic DRM OF helper Use the generic DRM OF helper to locate the possible CRTCs for the encoder, thereby shrinking the imx-drm driver some more. Acked-by: Philipp Zabel Signed-off-by: Russell King --- drivers/staging/imx-drm/imx-drm-core.c | 72 ++++++---------------------------- 1 file changed, 13 insertions(+), 59 deletions(-) diff --git a/drivers/staging/imx-drm/imx-drm-core.c b/drivers/staging/imx-drm/imx-drm-core.c index 9cb222e2996f..5e2c1f4b9165 100644 --- a/drivers/staging/imx-drm/imx-drm-core.c +++ b/drivers/staging/imx-drm/imx-drm-core.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "imx-drm.h" @@ -47,7 +48,6 @@ struct imx_drm_crtc { struct drm_crtc *crtc; int pipe; struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs; - struct device_node *port; }; static int legacyfb_depth = 16; @@ -366,9 +366,10 @@ int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc, imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs; imx_drm_crtc->pipe = imxdrm->pipes++; - imx_drm_crtc->port = port; imx_drm_crtc->crtc = crtc; + crtc->port = port; + imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc; *new_crtc = imx_drm_crtc; @@ -409,34 +410,6 @@ int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc) } EXPORT_SYMBOL_GPL(imx_drm_remove_crtc); -/* - * Find the DRM CRTC possible mask for the connected endpoint. - * - * The encoder possible masks are defined by their position in the - * mode_config crtc_list. This means that CRTCs must not be added - * or removed once the DRM device has been fully initialised. - */ -static uint32_t imx_drm_find_crtc_mask(struct imx_drm_device *imxdrm, - struct device_node *endpoint) -{ - struct device_node *port; - unsigned i; - - port = of_graph_get_remote_port(endpoint); - if (!port) - return 0; - of_node_put(port); - - for (i = 0; i < MAX_CRTC; i++) { - struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[i]; - - if (imx_drm_crtc && imx_drm_crtc->port == port) - return drm_crtc_mask(imx_drm_crtc->crtc); - } - - return 0; -} - static struct device_node *imx_drm_of_get_next_endpoint( const struct device_node *parent, struct device_node *prev) { @@ -449,35 +422,16 @@ static struct device_node *imx_drm_of_get_next_endpoint( int imx_drm_encoder_parse_of(struct drm_device *drm, struct drm_encoder *encoder, struct device_node *np) { - struct imx_drm_device *imxdrm = drm->dev_private; - struct device_node *ep = NULL; - uint32_t crtc_mask = 0; - int i; + uint32_t crtc_mask = drm_of_find_possible_crtcs(drm, np); - for (i = 0; ; i++) { - u32 mask; - - ep = imx_drm_of_get_next_endpoint(np, ep); - if (!ep) - break; - - mask = imx_drm_find_crtc_mask(imxdrm, ep); - - /* - * If we failed to find the CRTC(s) which this encoder is - * supposed to be connected to, it's because the CRTC has - * not been registered yet. Defer probing, and hope that - * the required CRTC is added later. - */ - if (mask == 0) - return -EPROBE_DEFER; - - crtc_mask |= mask; - } - - of_node_put(ep); - if (i == 0) - return -ENOENT; + /* + * If we failed to find the CRTC(s) which this encoder is + * supposed to be connected to, it's because the CRTC has + * not been registered yet. Defer probing, and hope that + * the required CRTC is added later. + */ + if (crtc_mask == 0) + return -EPROBE_DEFER; encoder->possible_crtcs = crtc_mask; @@ -511,7 +465,7 @@ int imx_drm_encoder_get_mux_id(struct device_node *node, port = of_graph_get_remote_port(ep); of_node_put(port); - if (port == imx_crtc->port) { + if (port == imx_crtc->crtc->port) { ret = of_graph_parse_endpoint(ep, &endpoint); return ret ? ret : endpoint.port; }