From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A06E6C433DB for ; Wed, 24 Mar 2021 01:11:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 69EA960201 for ; Wed, 24 Mar 2021 01:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233946AbhCXBK7 (ORCPT ); Tue, 23 Mar 2021 21:10:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230011AbhCXBKu (ORCPT ); Tue, 23 Mar 2021 21:10:50 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 210EEC061763 for ; Tue, 23 Mar 2021 18:10:50 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 44D19580; Wed, 24 Mar 2021 02:10:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616548246; bh=ewIb2TwnfOIvni7PhSmVcvP0SGvIAruPHE1GjohJHjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ucdb+92sPHbOOgWq5pBMvjKh3qBFhgAoJ5YwvFRszjGP0CO9GrC2UWP8FeOcc4rnU z23lr31lMRMBMSWg/W9vjkWzPSyBBq8VrgLqBaMG3iuZg3objZd8cdUV6Bzwwgi9IK 1D+ysMh+bngltLy01t8dQP895ZBzZUQ3PBStAz1o= Date: Wed, 24 Mar 2021 03:10:03 +0200 From: Laurent Pinchart To: Jagan Teki Cc: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com, linux-sunxi@googlegroups.com Subject: Re: [PATCH v4 2/4] drm: sun4i: dsi: Add bridge support Message-ID: References: <20210322140152.101709-1-jagan@amarulasolutions.com> <20210322140152.101709-3-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210322140152.101709-3-jagan@amarulasolutions.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jagan, Thank you for the patch. On Mon, Mar 22, 2021 at 07:31:50PM +0530, Jagan Teki wrote: > Some display panels would come up with a non-DSI output which Did you mean input instead of output ? > can have an option to connect DSI interface by means of bridge > converter. > > This DSI to non-DSI bridge converter would require a bridge > driver that would communicate the DSI controller for bridge > functionalities. > > So, add support for bridge functionalities in Allwinner DSI > controller. > > Cc: Samuel Holland > Signed-off-by: Jagan Teki > --- > Note: > Samuel Holland, The existing kms hotplug dropped in order to > attach the bridge properly. > > However, I did try several ways to support hotplug with the > bridge but it's resulting in a deadlock where bind never attach > bridge until bridge pointer found and bridge pointer cannot > found until bind finishes. Any inputs on this would be appreciated. > > Changes for v4: > - none > Changes for v3: > - updated with new API's > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 34 +++++++++++++++++--------- > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 2 +- > 2 files changed, 23 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > index 2e9e7b2d4145..39321299dc27 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > @@ -773,6 +773,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (dsi->panel) > drm_panel_prepare(dsi->panel); > > + if (dsi->panel_bridge) > + dsi->panel_bridge->funcs->pre_enable(dsi->panel_bridge); > + > /* > * FIXME: This should be moved after the switch to HS mode. > * > @@ -788,6 +791,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (dsi->panel) > drm_panel_enable(dsi->panel); > > + if (dsi->panel_bridge) > + dsi->panel_bridge->funcs->enable(dsi->panel_bridge); > + > sun6i_dsi_start(dsi, DSI_START_HSC); > > udelay(1000); > @@ -804,6 +810,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > if (dsi->panel) { > drm_panel_disable(dsi->panel); > drm_panel_unprepare(dsi->panel); > + } else if (dsi->panel_bridge) { > + dsi->panel_bridge->funcs->disable(dsi->panel_bridge); > + dsi->panel_bridge->funcs->post_disable(dsi->panel_bridge); > } Instead of having code paths that depend on whether you have a panel or a bridge, it would be better to wrap the panel a bridge (using drivers/gpu/drm/bridge/panel.c). The dsi->panel_bridge pointer should be renamed to next_bridge, and all the code (except in probe) can the use next_bridge without caring if it's a direct connection to a panel or another bridge. Furthermore, the encoder should call bridge functions explicitly, this should be handled by the DRM core. > > phy_power_off(dsi->dphy); > @@ -964,23 +973,17 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > struct mipi_dsi_device *device) > { > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > - struct drm_panel *panel; > int ret; > > ret = drm_of_find_panel_or_bridge(dsi->dev->of_node, 0, 0, > - &panel, NULL); > + &dsi->panel, &dsi->panel_bridge); > if (ret) > return ret; > > - if (!dsi->drm || !dsi->drm->registered) > - return -EPROBE_DEFER; > - > - dsi->panel = panel; > dsi->device = device; > > - drm_kms_helper_hotplug_event(dsi->drm); > - > - dev_info(host->dev, "Attached device %s\n", device->name); > + dev_info(host->dev, "Attached %s %s\n", > + device->name, dsi->panel ? "panel" : "bridge"); > > return 0; > } > @@ -991,9 +994,10 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > dsi->panel = NULL; > + dsi->panel_bridge = NULL; > dsi->device = NULL; > > - drm_kms_helper_hotplug_event(dsi->drm); > + drm_of_panel_bridge_remove(dsi->dev->of_node, 0, 0); > > return 0; > } > @@ -1082,7 +1086,13 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, > > drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); > > - dsi->drm = drm; > + if (dsi->panel_bridge) { > + ret = drm_bridge_attach(&dsi->encoder, dsi->panel_bridge, NULL, 0); > + if (ret) { > + dev_err(dsi->dev, "Couldn't attach drm bridge\n"); > + goto err_cleanup_connector; > + } > + } > > return 0; > > @@ -1096,7 +1106,7 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, > { > struct sun6i_dsi *dsi = dev_get_drvdata(dev); > > - dsi->drm = NULL; > + drm_encoder_cleanup(&dsi->encoder); > } > > static const struct component_ops sun6i_dsi_ops = { > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > index c863900ae3b4..370ecb356a63 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > @@ -29,8 +29,8 @@ struct sun6i_dsi { > > struct device *dev; > struct mipi_dsi_device *device; > - struct drm_device *drm; > struct drm_panel *panel; > + struct drm_bridge *panel_bridge; > }; > > static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host) -- Regards, Laurent Pinchart From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F4BAC433DB for ; Wed, 24 Mar 2021 01:12:46 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 2BF99619DC for ; Wed, 24 Mar 2021 01:12:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2BF99619DC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ie94CLh0gGALw1zSnon9UUMJWj9+gVvPjVb4YDl6C3I=; b=U2vOJVUZiJen9lqBnKNH3Tqk0 o8aHDZsVS0+7pRMmr9dasR1libop2zdahiitwCLs71/xOZ1C2PBiGljnPYWvu9BgK2WJvwUJokI28 4/bfWm4vGpty05tSWkX6mridd2BZFfq8Og3N7nZsUqjgyfyh8O8WqtzpXA2yweXgiWsQMcNH3M1tI IrIfHyBgjpxC2B7aHcTD+QZgix3fU2hCJ1Smu0wPsDApd3gk+uo4pow+7Ub25pXW1EaRwsm1pENHT TPsYU5KzemnJT0V2M3zUTRBFEX0fgImS3M1icfUXG5cRWV91eE9z6aj95fT0XWI6+MusBaFfT+GG5 b7GBOcUtQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lOs2y-00G3pw-1P; Wed, 24 Mar 2021 01:10:56 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lOs2p-00G3pS-V8 for linux-arm-kernel@lists.infradead.org; Wed, 24 Mar 2021 01:10:50 +0000 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 44D19580; Wed, 24 Mar 2021 02:10:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616548246; bh=ewIb2TwnfOIvni7PhSmVcvP0SGvIAruPHE1GjohJHjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ucdb+92sPHbOOgWq5pBMvjKh3qBFhgAoJ5YwvFRszjGP0CO9GrC2UWP8FeOcc4rnU z23lr31lMRMBMSWg/W9vjkWzPSyBBq8VrgLqBaMG3iuZg3objZd8cdUV6Bzwwgi9IK 1D+ysMh+bngltLy01t8dQP895ZBzZUQ3PBStAz1o= Date: Wed, 24 Mar 2021 03:10:03 +0200 From: Laurent Pinchart To: Jagan Teki Cc: Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-amarula@amarulasolutions.com, linux-sunxi@googlegroups.com Subject: Re: [PATCH v4 2/4] drm: sun4i: dsi: Add bridge support Message-ID: References: <20210322140152.101709-1-jagan@amarulasolutions.com> <20210322140152.101709-3-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210322140152.101709-3-jagan@amarulasolutions.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210324_011048_131646_440622EF X-CRM114-Status: GOOD ( 33.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Jagan, Thank you for the patch. On Mon, Mar 22, 2021 at 07:31:50PM +0530, Jagan Teki wrote: > Some display panels would come up with a non-DSI output which Did you mean input instead of output ? > can have an option to connect DSI interface by means of bridge > converter. > > This DSI to non-DSI bridge converter would require a bridge > driver that would communicate the DSI controller for bridge > functionalities. > > So, add support for bridge functionalities in Allwinner DSI > controller. > > Cc: Samuel Holland > Signed-off-by: Jagan Teki > --- > Note: > Samuel Holland, The existing kms hotplug dropped in order to > attach the bridge properly. > > However, I did try several ways to support hotplug with the > bridge but it's resulting in a deadlock where bind never attach > bridge until bridge pointer found and bridge pointer cannot > found until bind finishes. Any inputs on this would be appreciated. > > Changes for v4: > - none > Changes for v3: > - updated with new API's > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 34 +++++++++++++++++--------- > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 2 +- > 2 files changed, 23 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > index 2e9e7b2d4145..39321299dc27 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > @@ -773,6 +773,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (dsi->panel) > drm_panel_prepare(dsi->panel); > > + if (dsi->panel_bridge) > + dsi->panel_bridge->funcs->pre_enable(dsi->panel_bridge); > + > /* > * FIXME: This should be moved after the switch to HS mode. > * > @@ -788,6 +791,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (dsi->panel) > drm_panel_enable(dsi->panel); > > + if (dsi->panel_bridge) > + dsi->panel_bridge->funcs->enable(dsi->panel_bridge); > + > sun6i_dsi_start(dsi, DSI_START_HSC); > > udelay(1000); > @@ -804,6 +810,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > if (dsi->panel) { > drm_panel_disable(dsi->panel); > drm_panel_unprepare(dsi->panel); > + } else if (dsi->panel_bridge) { > + dsi->panel_bridge->funcs->disable(dsi->panel_bridge); > + dsi->panel_bridge->funcs->post_disable(dsi->panel_bridge); > } Instead of having code paths that depend on whether you have a panel or a bridge, it would be better to wrap the panel a bridge (using drivers/gpu/drm/bridge/panel.c). The dsi->panel_bridge pointer should be renamed to next_bridge, and all the code (except in probe) can the use next_bridge without caring if it's a direct connection to a panel or another bridge. Furthermore, the encoder should call bridge functions explicitly, this should be handled by the DRM core. > > phy_power_off(dsi->dphy); > @@ -964,23 +973,17 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > struct mipi_dsi_device *device) > { > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > - struct drm_panel *panel; > int ret; > > ret = drm_of_find_panel_or_bridge(dsi->dev->of_node, 0, 0, > - &panel, NULL); > + &dsi->panel, &dsi->panel_bridge); > if (ret) > return ret; > > - if (!dsi->drm || !dsi->drm->registered) > - return -EPROBE_DEFER; > - > - dsi->panel = panel; > dsi->device = device; > > - drm_kms_helper_hotplug_event(dsi->drm); > - > - dev_info(host->dev, "Attached device %s\n", device->name); > + dev_info(host->dev, "Attached %s %s\n", > + device->name, dsi->panel ? "panel" : "bridge"); > > return 0; > } > @@ -991,9 +994,10 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > dsi->panel = NULL; > + dsi->panel_bridge = NULL; > dsi->device = NULL; > > - drm_kms_helper_hotplug_event(dsi->drm); > + drm_of_panel_bridge_remove(dsi->dev->of_node, 0, 0); > > return 0; > } > @@ -1082,7 +1086,13 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, > > drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); > > - dsi->drm = drm; > + if (dsi->panel_bridge) { > + ret = drm_bridge_attach(&dsi->encoder, dsi->panel_bridge, NULL, 0); > + if (ret) { > + dev_err(dsi->dev, "Couldn't attach drm bridge\n"); > + goto err_cleanup_connector; > + } > + } > > return 0; > > @@ -1096,7 +1106,7 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, > { > struct sun6i_dsi *dsi = dev_get_drvdata(dev); > > - dsi->drm = NULL; > + drm_encoder_cleanup(&dsi->encoder); > } > > static const struct component_ops sun6i_dsi_ops = { > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > index c863900ae3b4..370ecb356a63 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > @@ -29,8 +29,8 @@ struct sun6i_dsi { > > struct device *dev; > struct mipi_dsi_device *device; > - struct drm_device *drm; > struct drm_panel *panel; > + struct drm_bridge *panel_bridge; > }; > > static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host) -- Regards, Laurent Pinchart _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8172CC433C1 for ; Wed, 24 Mar 2021 01:10:51 +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 04466619DC for ; Wed, 24 Mar 2021 01:10:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04466619DC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.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 1EB316E202; Wed, 24 Mar 2021 01:10:50 +0000 (UTC) Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0A5C6E202 for ; Wed, 24 Mar 2021 01:10:48 +0000 (UTC) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 44D19580; Wed, 24 Mar 2021 02:10:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1616548246; bh=ewIb2TwnfOIvni7PhSmVcvP0SGvIAruPHE1GjohJHjs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ucdb+92sPHbOOgWq5pBMvjKh3qBFhgAoJ5YwvFRszjGP0CO9GrC2UWP8FeOcc4rnU z23lr31lMRMBMSWg/W9vjkWzPSyBBq8VrgLqBaMG3iuZg3objZd8cdUV6Bzwwgi9IK 1D+ysMh+bngltLy01t8dQP895ZBzZUQ3PBStAz1o= Date: Wed, 24 Mar 2021 03:10:03 +0200 From: Laurent Pinchart To: Jagan Teki Subject: Re: [PATCH v4 2/4] drm: sun4i: dsi: Add bridge support Message-ID: References: <20210322140152.101709-1-jagan@amarulasolutions.com> <20210322140152.101709-3-jagan@amarulasolutions.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210322140152.101709-3-jagan@amarulasolutions.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jernej Skrabec , Samuel Holland , linux-sunxi@googlegroups.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Chen-Yu Tsai , linux-amarula@amarulasolutions.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Jagan, Thank you for the patch. On Mon, Mar 22, 2021 at 07:31:50PM +0530, Jagan Teki wrote: > Some display panels would come up with a non-DSI output which Did you mean input instead of output ? > can have an option to connect DSI interface by means of bridge > converter. > > This DSI to non-DSI bridge converter would require a bridge > driver that would communicate the DSI controller for bridge > functionalities. > > So, add support for bridge functionalities in Allwinner DSI > controller. > > Cc: Samuel Holland > Signed-off-by: Jagan Teki > --- > Note: > Samuel Holland, The existing kms hotplug dropped in order to > attach the bridge properly. > > However, I did try several ways to support hotplug with the > bridge but it's resulting in a deadlock where bind never attach > bridge until bridge pointer found and bridge pointer cannot > found until bind finishes. Any inputs on this would be appreciated. > > Changes for v4: > - none > Changes for v3: > - updated with new API's > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 34 +++++++++++++++++--------- > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 2 +- > 2 files changed, 23 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > index 2e9e7b2d4145..39321299dc27 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > @@ -773,6 +773,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (dsi->panel) > drm_panel_prepare(dsi->panel); > > + if (dsi->panel_bridge) > + dsi->panel_bridge->funcs->pre_enable(dsi->panel_bridge); > + > /* > * FIXME: This should be moved after the switch to HS mode. > * > @@ -788,6 +791,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (dsi->panel) > drm_panel_enable(dsi->panel); > > + if (dsi->panel_bridge) > + dsi->panel_bridge->funcs->enable(dsi->panel_bridge); > + > sun6i_dsi_start(dsi, DSI_START_HSC); > > udelay(1000); > @@ -804,6 +810,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > if (dsi->panel) { > drm_panel_disable(dsi->panel); > drm_panel_unprepare(dsi->panel); > + } else if (dsi->panel_bridge) { > + dsi->panel_bridge->funcs->disable(dsi->panel_bridge); > + dsi->panel_bridge->funcs->post_disable(dsi->panel_bridge); > } Instead of having code paths that depend on whether you have a panel or a bridge, it would be better to wrap the panel a bridge (using drivers/gpu/drm/bridge/panel.c). The dsi->panel_bridge pointer should be renamed to next_bridge, and all the code (except in probe) can the use next_bridge without caring if it's a direct connection to a panel or another bridge. Furthermore, the encoder should call bridge functions explicitly, this should be handled by the DRM core. > > phy_power_off(dsi->dphy); > @@ -964,23 +973,17 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > struct mipi_dsi_device *device) > { > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > - struct drm_panel *panel; > int ret; > > ret = drm_of_find_panel_or_bridge(dsi->dev->of_node, 0, 0, > - &panel, NULL); > + &dsi->panel, &dsi->panel_bridge); > if (ret) > return ret; > > - if (!dsi->drm || !dsi->drm->registered) > - return -EPROBE_DEFER; > - > - dsi->panel = panel; > dsi->device = device; > > - drm_kms_helper_hotplug_event(dsi->drm); > - > - dev_info(host->dev, "Attached device %s\n", device->name); > + dev_info(host->dev, "Attached %s %s\n", > + device->name, dsi->panel ? "panel" : "bridge"); > > return 0; > } > @@ -991,9 +994,10 @@ static int sun6i_dsi_detach(struct mipi_dsi_host *host, > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > dsi->panel = NULL; > + dsi->panel_bridge = NULL; > dsi->device = NULL; > > - drm_kms_helper_hotplug_event(dsi->drm); > + drm_of_panel_bridge_remove(dsi->dev->of_node, 0, 0); > > return 0; > } > @@ -1082,7 +1086,13 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, > > drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); > > - dsi->drm = drm; > + if (dsi->panel_bridge) { > + ret = drm_bridge_attach(&dsi->encoder, dsi->panel_bridge, NULL, 0); > + if (ret) { > + dev_err(dsi->dev, "Couldn't attach drm bridge\n"); > + goto err_cleanup_connector; > + } > + } > > return 0; > > @@ -1096,7 +1106,7 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, > { > struct sun6i_dsi *dsi = dev_get_drvdata(dev); > > - dsi->drm = NULL; > + drm_encoder_cleanup(&dsi->encoder); > } > > static const struct component_ops sun6i_dsi_ops = { > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > index c863900ae3b4..370ecb356a63 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > @@ -29,8 +29,8 @@ struct sun6i_dsi { > > struct device *dev; > struct mipi_dsi_device *device; > - struct drm_device *drm; > struct drm_panel *panel; > + struct drm_bridge *panel_bridge; > }; > > static inline struct sun6i_dsi *host_to_sun6i_dsi(struct mipi_dsi_host *host) -- Regards, Laurent Pinchart _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel