| Message ID | 20190315130825.9005-4-jagan@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-amarula+bncBD7MFH7A7EEBBZOHV3SAKGQEQ23JMRQ@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 33E4F3F033 for <linux-amarula@patchwork.amarulasolutions.com>; Fri, 15 Mar 2019 14:08:54 +0100 (CET) Received: by mail-pg1-f199.google.com with SMTP id d10sf9997493pgv.23 for <linux-amarula@patchwork.amarulasolutions.com>; Fri, 15 Mar 2019 06:08:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1552655333; cv=pass; d=google.com; s=arc-20160816; b=nUqMP7o2u/UBzBxG77R13/rRZExtDOd28A8PAacn2Sg4jIgAkC1u0K5lewJVPcXHx5 9O7tlP6W1IzMRRCqJyxL3IIssHfpZJttbs4/nTDdA9XDSzbMF5DUxRBuEgekvxsVjXXx Ga1+IEum1ci0Np21LdHWaM+n5w4HF/syPtKtFbWVi6q4KKzGP30qYE3O0mHOra7KLylu h+26K6/MOeksvEuiN4sbS+WjqVVbYQBJ/Rk+I5wdYCyHDYMTISZpK3wbdMBAdAMIi4lm Zz9c0RaB6FGK1h671RXqeyOz6cvnq4HRg+haQ0ZId3KSyKBwn/GSJ3MyF3XdEtr0GOVw CQGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=tktU5X2KDjaAYhxvMDk5IJQFPqBaNK35AVRXzFfU9Qo=; b=EGldVFHUOCYBYptIBkG+4njOgxg1r0wzaTQ2Z9YHDfZs8yayYJl8jBwJTqw9qFFJdu 7W9r8Zl+r1M8xYMWKwJ5hzlw+KYatfU6f/AZGHMlaoksXDeXTSOwlMTizeOMD+cHS0gp AxblLQ6yjVZlvP0watczLGTebuzw71Vi+sPvHHhermCTX4aOFIHh3tLKJd1NG1lmwqyo j/dPxc+wZiUSQNOxVx0jzlDgXaJ9wa0FJfLyO+DSQtz46QsZwaHkA2p/hfuxJQWrvguo OJm6lZ8DbNP9LM4eDN+yY0jGjPtyezoXZt89BemcJtw+Q2DKpg5K7XULj0+QU7UCjqwx QmGw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=B2hki3AV; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=tktU5X2KDjaAYhxvMDk5IJQFPqBaNK35AVRXzFfU9Qo=; b=qCBeiaBTbMlghav4Th7YCjXbuYw10sEgL95wiEgNyvbvOddfzKVCOlhp0UcWEzWgoE wESb5Sr1SyhjB9c1lr/yPkexucZGBT0rGrbiugrMCPhmMr3ILZGRaPGtuHrWphGf8qmR HdCE/Bju6+RPWeFBODj2IEf1GXqiuyrQ9dW2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=tktU5X2KDjaAYhxvMDk5IJQFPqBaNK35AVRXzFfU9Qo=; b=qSOKWMUkKCNg5OHZmpKShCefzaUoqvVaBaUWUa6QZlekjhMKMUiRkswPEJ8wYgcIWK AZae1ZXVkX1z0a6NSgbbIjiQZVjOt7az6G1/k6xWR7arlJzoaiZBa6LUEzQ9bD5972dr lUXvk1lJWzUPrTFph+LafgtYgNj4RkPtSX7wvShMHxyGuVU40pgPn2MrSRXacn8VZHOf qNO96dtETchI8T+BQlIE+JnT6yk0nqX9d0lxFeypHEoMp/1zhiV53dzvrZ4nm2hrntl0 mpz5rMOMPVhL6g8bHaz2z17ZoT6Rp17aSXiafvqNjV0VLT3dckjeD421Q5U/VOCwxtzs +Big== X-Gm-Message-State: APjAAAWTKHPIx70cpHFhN/HBZo+yfslzHVq3rxQcvKgS2P3eoJqTMQbh SLK1HTzdxdZZ/vps8WyuHa8juUJ+ X-Google-Smtp-Source: APXvYqxlaPRCaSOS7m26CvyikpN/3rRO2ckXyAxFGF7tdViyQhEmJeVoWTK1HGb+v0PVdtVRMrxtNw== X-Received: by 2002:a17:902:b60a:: with SMTP id b10mr1131656pls.147.1552655333012; Fri, 15 Mar 2019 06:08:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:6257:: with SMTP id q23ls3551741pgv.6.gmail; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) X-Received: by 2002:a62:489d:: with SMTP id q29mr3927963pfi.119.1552655332517; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552655332; cv=none; d=google.com; s=arc-20160816; b=LoRUwN/dp5zzODLm3jefjm3vNWbtt0XtxaHg/0xcESpL7lUd0g7XOElslH6BNpy2RN qHZjNodS54D8JdO61C+mLAV5yoH5no4T+7t2E1gRV3Z2BZLRAx9uUsV2udPRoxDpnyXF ljAXKRpsQdafhgskePwJvoaePbgTIq+v066m7mATIGrCoZu57ploxeAtQg6yoo6U22HG NhG6LxFwFvVtrqO/h58c6tIFeL5+4pidZVTN4wQFO6ym/Xe6G8ZtoRwbZswlUzzUSJeH ALyFPENUXRtFhu4QvtuJ8WE6ImAgiMHvt9MJ6i1tbkrzJOo4deTazcMEXecQBxkS/T0w KtHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=MUOsJO/ekVDHiTmtCVq8d27ElQS89ZxoIWk8a+ZsNC8=; b=JtwHAGCQ7RTiCcsErvYF2ssXom4QTpEYzfvE+c1PfinRWIaekvgQc0eGVagt3wSppc D1KXlM9ZW0kdAlbT4R497HZq/J6es1qIyXWXM885W9DoZ5qsDbbRzmn89/qecCyQZ64g IvulI5NSLj01NO2jnJrSZBRX5q0nvYkAXBrMuD2LDmgu+EjRB2AeX8iSqRYvX7GsxC4e V3F97+g2S8sVsF5cO4Qi0MWpQVXXGz3OvmY+RiIJ9+0PG2I1gFO1rx2EUtI9PtA70RYG pfdqkdPP17H0QQ2yJe1iZf9UkxXkgARB64O6JbnMKsJlLG1rihSMp2ez2IZvPlFEPJW/ U4Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=B2hki3AV; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id g14sor2918771pgn.40.2019.03.15.06.08.52 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Fri, 15 Mar 2019 06:08:52 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:5321:: with SMTP id h33mr3378181pgb.168.1552655332222; Fri, 15 Mar 2019 06:08:52 -0700 (PDT) Received: from localhost.localdomain ([183.82.230.185]) by smtp.gmail.com with ESMTPSA id e2sm854008pfa.64.2019.03.15.06.08.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Mar 2019 06:08:51 -0700 (PDT) From: Jagan Teki <jagan@amarulasolutions.com> To: Andrzej Hajda <a.hajda@samsung.com>, Laurent Pinchart <Laurent.pinchart@ideasonboard.com>, Chen-Yu Tsai <wens@csie.org>, Maxime Ripard <maxime.ripard@bootlin.com>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com> Cc: Michael Trimarchi <michael@amarulasolutions.com>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, linux-amarula@amarulasolutions.com, Jagan Teki <jagan@amarulasolutions.com> Subject: [PATCH 3/6] drm/sun4i: dsi: Add bridge support Date: Fri, 15 Mar 2019 18:38:22 +0530 Message-Id: <20190315130825.9005-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190315130825.9005-1-jagan@amarulasolutions.com> References: <20190315130825.9005-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=B2hki3AV; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
| Series |
drm/bridge: Add ICN6211 MIPI-DSI/RGB bridge
|
|
Commit Message
Jagan Teki
March 15, 2019, 1:08 p.m. UTC
Some display panels would come up with a non-DSI output which
can have an option to connect DSI interface by means of bridge
convertor.
This DSI to non-DSI bridge convertor would require a bridge
driver that would communicate the DSI controller for bridge
functionalities.
So, add support for bridge functionalities in Allwinner DSI
controller.
Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
---
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++-------
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 +
2 files changed, 49 insertions(+), 17 deletions(-)
Comments
Hi, On Fri, 2019-03-15 at 18:38 +0530, Jagan Teki wrote: > Some display panels would come up with a non-DSI output which > can have an option to connect DSI interface by means of bridge > convertor. > > This DSI to non-DSI bridge convertor would require a bridge > driver that would communicate the DSI controller for bridge > functionalities. > > So, add support for bridge functionalities in Allwinner DSI > controller. See a few comments below. > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> > --- > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++------- > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + > 2 files changed, 49 insertions(+), 17 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > index 0960b96b62cc..64d74313b842 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (!IS_ERR(dsi->panel)) > drm_panel_prepare(dsi->panel); > > + if (!IS_ERR(dsi->bridge)) > + drm_bridge_pre_enable(dsi->bridge); > + > /* > * FIXME: This should be moved after the switch to HS mode. > * > @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > if (!IS_ERR(dsi->panel)) > drm_panel_enable(dsi->panel); > > + if (!IS_ERR(dsi->bridge)) > + drm_bridge_enable(dsi->bridge); > + > sun6i_dsi_start(dsi, DSI_START_HSC); > > udelay(1000); > @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > if (!IS_ERR(dsi->panel)) { > drm_panel_disable(dsi->panel); > drm_panel_unprepare(dsi->panel); > + } else if (!IS_ERR(dsi->bridge)) { > + drm_bridge_disable(dsi->bridge); > + drm_bridge_post_disable(dsi->bridge); > } > > phy_power_off(dsi->dphy); > @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > dsi->device = device; > - dsi->panel = of_drm_find_panel(device->dev.of_node); > - if (IS_ERR(dsi->panel)) > - return PTR_ERR(dsi->panel); > > - dev_info(host->dev, "Attached device %s\n", device->name); > + dsi->bridge = of_drm_find_bridge(device->dev.of_node); > + if (!dsi->bridge) { You are using IS_ERR to check that the bridge is alive in the changes above, but switch to checking that it's non-NULL at this point. Are both guaranteed to be interchangeable? > + dsi->panel = of_drm_find_panel(device->dev.of_node); > + if (IS_ERR(dsi->panel)) > + return PTR_ERR(dsi->panel); > + } You should probably use drm_of_find_panel_or_bridge instead of duplicating the logic here. > + dev_info(host->dev, "Attached %s %s\n", > + dsi->bridge ? "bridge" : "panel", device->name); > > return 0; > } > @@ -1055,8 +1069,10 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, > struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm); > int ret; > > - if (!dsi->panel) > + if (!(dsi->panel || dsi->bridge)) { > + dev_info(drm->dev, "No panel or bridge found... DSI output disabled\n"); > return -EPROBE_DEFER; > + } > > dsi->drv = drv; > > @@ -1078,19 +1094,29 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, > } > dsi->encoder.possible_crtcs = BIT(0); > > - drm_connector_helper_add(&dsi->connector, > - &sun6i_dsi_connector_helper_funcs); > - ret = drm_connector_init(drm, &dsi->connector, > - &sun6i_dsi_connector_funcs, > - DRM_MODE_CONNECTOR_DSI); > - if (ret) { > - dev_err(dsi->dev, > - "Couldn't initialise the DSI connector\n"); > - goto err_cleanup_connector; > + if (dsi->panel) { > + drm_connector_helper_add(&dsi->connector, > + &sun6i_dsi_connector_helper_funcs); > + ret = drm_connector_init(drm, &dsi->connector, > + &sun6i_dsi_connector_funcs, > + DRM_MODE_CONNECTOR_DSI); > + if (ret) { > + dev_err(dsi->dev, > + "Couldn't initialise the DSI connector\n"); > + goto err_cleanup_connector; > + } > + > + drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); > + drm_panel_attach(dsi->panel, &dsi->connector); > } > > - drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); > - drm_panel_attach(dsi->panel, &dsi->connector); > + if (dsi->bridge) { > + ret = drm_bridge_attach(&dsi->encoder, dsi->bridge, NULL); > + if (ret) { > + dev_err(dsi->dev, "Couldn't attach the DSI bridge\n"); > + goto err_cleanup_connector; > + } > + } > > return 0; > > @@ -1104,7 +1130,12 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, > { > struct sun6i_dsi *dsi = dev_get_drvdata(dev); > > - drm_panel_detach(dsi->panel); > + if (dsi->panel) > + drm_panel_detach(dsi->panel); > + > + if (dsi->bridge) > + drm_bridge_detach(dsi->bridge); As I mentionned in the first patch, this is quite suspicious since the DRM core should be in charge of detaching the bridge, not the driver. Cheers, Paul > + > } > > 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 5c4983212f89..76874ff8e3ef 100644 > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h > @@ -36,6 +36,7 @@ struct sun6i_dsi { > struct sun4i_tcon *tcon; > struct mipi_dsi_device *device; > struct drm_panel *panel; > + struct drm_bridge *bridge; > const struct sun6i_dsi_variant *variant; > }; > > -- > 2.18.0.321.gffc6fa0e3 >
On Fri, Mar 15, 2019 at 02:32:55PM +0100, Paul Kocialkowski wrote: > Hi, > > On Fri, 2019-03-15 at 18:38 +0530, Jagan Teki wrote: > > Some display panels would come up with a non-DSI output which > > can have an option to connect DSI interface by means of bridge > > convertor. > > > > This DSI to non-DSI bridge convertor would require a bridge > > driver that would communicate the DSI controller for bridge > > functionalities. > > > > So, add support for bridge functionalities in Allwinner DSI > > controller. > > See a few comments below. > > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> > > --- > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++------- > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + > > 2 files changed, 49 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > index 0960b96b62cc..64d74313b842 100644 > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > > if (!IS_ERR(dsi->panel)) > > drm_panel_prepare(dsi->panel); > > > > + if (!IS_ERR(dsi->bridge)) > > + drm_bridge_pre_enable(dsi->bridge); > > + > > /* > > * FIXME: This should be moved after the switch to HS mode. > > * > > @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > > if (!IS_ERR(dsi->panel)) > > drm_panel_enable(dsi->panel); > > > > + if (!IS_ERR(dsi->bridge)) > > + drm_bridge_enable(dsi->bridge); > > + > > sun6i_dsi_start(dsi, DSI_START_HSC); > > > > udelay(1000); > > @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > > if (!IS_ERR(dsi->panel)) { > > drm_panel_disable(dsi->panel); > > drm_panel_unprepare(dsi->panel); > > + } else if (!IS_ERR(dsi->bridge)) { > > + drm_bridge_disable(dsi->bridge); > > + drm_bridge_post_disable(dsi->bridge); > > } > > > > phy_power_off(dsi->dphy); > > @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > > > dsi->device = device; > > - dsi->panel = of_drm_find_panel(device->dev.of_node); > > - if (IS_ERR(dsi->panel)) > > - return PTR_ERR(dsi->panel); > > > > - dev_info(host->dev, "Attached device %s\n", device->name); > > + dsi->bridge = of_drm_find_bridge(device->dev.of_node); > > + if (!dsi->bridge) { > > You are using IS_ERR to check that the bridge is alive in the changes > above, but switch to checking that it's non-NULL at this point. > > Are both guaranteed to be interchangeable? They aren't. Any ERR_PTR will be !NULL > > + dsi->panel = of_drm_find_panel(device->dev.of_node); > > + if (IS_ERR(dsi->panel)) > > + return PTR_ERR(dsi->panel); > > + } > > You should probably use drm_of_find_panel_or_bridge instead of > duplicating the logic here. Or we can even use the drm_panel_bridge_add to simplify things. Maxime
Hi, On Fri, 2019-03-15 at 14:45 +0100, Maxime Ripard wrote: > On Fri, Mar 15, 2019 at 02:32:55PM +0100, Paul Kocialkowski wrote: > > Hi, > > > > On Fri, 2019-03-15 at 18:38 +0530, Jagan Teki wrote: > > > Some display panels would come up with a non-DSI output which > > > can have an option to connect DSI interface by means of bridge > > > convertor. > > > > > > This DSI to non-DSI bridge convertor would require a bridge > > > driver that would communicate the DSI controller for bridge > > > functionalities. > > > > > > So, add support for bridge functionalities in Allwinner DSI > > > controller. > > > > See a few comments below. > > > > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> > > > --- > > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++------- > > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + > > > 2 files changed, 49 insertions(+), 17 deletions(-) > > > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > index 0960b96b62cc..64d74313b842 100644 > > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > > @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > > > if (!IS_ERR(dsi->panel)) > > > drm_panel_prepare(dsi->panel); > > > > > > + if (!IS_ERR(dsi->bridge)) > > > + drm_bridge_pre_enable(dsi->bridge); > > > + > > > /* > > > * FIXME: This should be moved after the switch to HS mode. > > > * > > > @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > > > if (!IS_ERR(dsi->panel)) > > > drm_panel_enable(dsi->panel); > > > > > > + if (!IS_ERR(dsi->bridge)) > > > + drm_bridge_enable(dsi->bridge); > > > + > > > sun6i_dsi_start(dsi, DSI_START_HSC); > > > > > > udelay(1000); > > > @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > > > if (!IS_ERR(dsi->panel)) { > > > drm_panel_disable(dsi->panel); > > > drm_panel_unprepare(dsi->panel); > > > + } else if (!IS_ERR(dsi->bridge)) { > > > + drm_bridge_disable(dsi->bridge); > > > + drm_bridge_post_disable(dsi->bridge); > > > } > > > > > > phy_power_off(dsi->dphy); > > > @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > > > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > > > > > dsi->device = device; > > > - dsi->panel = of_drm_find_panel(device->dev.of_node); > > > - if (IS_ERR(dsi->panel)) > > > - return PTR_ERR(dsi->panel); > > > > > > - dev_info(host->dev, "Attached device %s\n", device->name); > > > + dsi->bridge = of_drm_find_bridge(device->dev.of_node); > > > + if (!dsi->bridge) { > > > > You are using IS_ERR to check that the bridge is alive in the changes > > above, but switch to checking that it's non-NULL at this point. > > > > Are both guaranteed to be interchangeable? > > They aren't. Any ERR_PTR will be !NULL > > > > + dsi->panel = of_drm_find_panel(device->dev.of_node); > > > + if (IS_ERR(dsi->panel)) > > > + return PTR_ERR(dsi->panel); > > > + } > > > > You should probably use drm_of_find_panel_or_bridge instead of > > duplicating the logic here. > > Or we can even use the drm_panel_bridge_add to simplify things. Indeed, I was just looking at that and it seems to be specifically tailored for this use case. Cheers, Paul
Hi, Jagan, On 3/15/19 4:45 PM, Maxime Ripard wrote: > On Fri, Mar 15, 2019 at 02:32:55PM +0100, Paul Kocialkowski wrote: >> Hi, >> >> On Fri, 2019-03-15 at 18:38 +0530, Jagan Teki wrote: >>> Some display panels would come up with a non-DSI output which >>> can have an option to connect DSI interface by means of bridge >>> convertor. >>> >>> This DSI to non-DSI bridge convertor would require a bridge >>> driver that would communicate the DSI controller for bridge >>> functionalities. >>> >>> So, add support for bridge functionalities in Allwinner DSI >>> controller. >> See a few comments below. >> >>> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> >>> --- >>> drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++------- >>> drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + >>> 2 files changed, 49 insertions(+), 17 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >>> index 0960b96b62cc..64d74313b842 100644 >>> --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >>> +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c >>> @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) >>> if (!IS_ERR(dsi->panel)) >>> drm_panel_prepare(dsi->panel); >>> >>> + if (!IS_ERR(dsi->bridge)) >>> + drm_bridge_pre_enable(dsi->bridge); >>> + >>> /* >>> * FIXME: This should be moved after the switch to HS mode. >>> * >>> @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) >>> if (!IS_ERR(dsi->panel)) >>> drm_panel_enable(dsi->panel); >>> >>> + if (!IS_ERR(dsi->bridge)) >>> + drm_bridge_enable(dsi->bridge); >>> + >>> sun6i_dsi_start(dsi, DSI_START_HSC); >>> >>> udelay(1000); >>> @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) >>> if (!IS_ERR(dsi->panel)) { >>> drm_panel_disable(dsi->panel); >>> drm_panel_unprepare(dsi->panel); >>> + } else if (!IS_ERR(dsi->bridge)) { >>> + drm_bridge_disable(dsi->bridge); >>> + drm_bridge_post_disable(dsi->bridge); >>> } >>> >>> phy_power_off(dsi->dphy); >>> @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, >>> struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); >>> >>> dsi->device = device; >>> - dsi->panel = of_drm_find_panel(device->dev.of_node); >>> - if (IS_ERR(dsi->panel)) >>> - return PTR_ERR(dsi->panel); >>> >>> - dev_info(host->dev, "Attached device %s\n", device->name); >>> + dsi->bridge = of_drm_find_bridge(device->dev.of_node); >>> + if (!dsi->bridge) { >> You are using IS_ERR to check that the bridge is alive in the changes >> above, but switch to checking that it's non-NULL at this point. >> >> Are both guaranteed to be interchangeable? > They aren't. Any ERR_PTR will be !NULL > >>> + dsi->panel = of_drm_find_panel(device->dev.of_node); >>> + if (IS_ERR(dsi->panel)) >>> + return PTR_ERR(dsi->panel); >>> + } >> You should probably use drm_of_find_panel_or_bridge instead of >> duplicating the logic here. > Or we can even use the drm_panel_bridge_add to simplify things. this approach is implemented by E.Anholt in VC4 dsi driver and it looks nice. > > Maxime > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Paul and Maxime, On Fri, Mar 15, 2019 at 7:03 PM Paul Kocialkowski <paul.kocialkowski@bootlin.com> wrote: > > Hi, > > On Fri, 2019-03-15 at 18:38 +0530, Jagan Teki wrote: > > Some display panels would come up with a non-DSI output which > > can have an option to connect DSI interface by means of bridge > > convertor. > > > > This DSI to non-DSI bridge convertor would require a bridge > > driver that would communicate the DSI controller for bridge > > functionalities. > > > > So, add support for bridge functionalities in Allwinner DSI > > controller. > > See a few comments below. > > > Signed-off-by: Jagan Teki <jagan@amarulasolutions.com> > > --- > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 65 +++++++++++++++++++------- > > drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h | 1 + > > 2 files changed, 49 insertions(+), 17 deletions(-) > > > > diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > index 0960b96b62cc..64d74313b842 100644 > > --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c > > @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > > if (!IS_ERR(dsi->panel)) > > drm_panel_prepare(dsi->panel); > > > > + if (!IS_ERR(dsi->bridge)) > > + drm_bridge_pre_enable(dsi->bridge); > > + > > /* > > * FIXME: This should be moved after the switch to HS mode. > > * > > @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) > > if (!IS_ERR(dsi->panel)) > > drm_panel_enable(dsi->panel); > > > > + if (!IS_ERR(dsi->bridge)) > > + drm_bridge_enable(dsi->bridge); > > + > > sun6i_dsi_start(dsi, DSI_START_HSC); > > > > udelay(1000); > > @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) > > if (!IS_ERR(dsi->panel)) { > > drm_panel_disable(dsi->panel); > > drm_panel_unprepare(dsi->panel); > > + } else if (!IS_ERR(dsi->bridge)) { > > + drm_bridge_disable(dsi->bridge); > > + drm_bridge_post_disable(dsi->bridge); > > } > > > > phy_power_off(dsi->dphy); > > @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, > > struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); > > > > dsi->device = device; > > - dsi->panel = of_drm_find_panel(device->dev.of_node); > > - if (IS_ERR(dsi->panel)) > > - return PTR_ERR(dsi->panel); > > > > - dev_info(host->dev, "Attached device %s\n", device->name); > > + dsi->bridge = of_drm_find_bridge(device->dev.of_node); > > + if (!dsi->bridge) { > > You are using IS_ERR to check that the bridge is alive in the changes > above, but switch to checking that it's non-NULL at this point. > > Are both guaranteed to be interchangeable? > > > + dsi->panel = of_drm_find_panel(device->dev.of_node); > > + if (IS_ERR(dsi->panel)) > > + return PTR_ERR(dsi->panel); > > + } > > You should probably use drm_of_find_panel_or_bridge instead of > duplicating the logic here. True, In-fact I did try this API. but pipeline were unable to bound. Usually the panel and bridge were attached first and then the pipeline bound would start from front-end (in A33) But in my below cases I have seen only panel or bridge attached but no pipeline bound at all. And I'm using drm_of_find_panel_or_bridge(host->dev->of_node, 1, 0, &dsi->panel, &dsi->bridge); in dsi attach API. Case-1, panel: &dsi { vcc-dsi-supply = <®_dcdc1>; /* VCC3V3-DSI */ status = "okay"; ports { dsi_out: port@1 { reg = <1>; dsi_out_panel: endpoint { remote-endpoint = <&panel_out_dsi>; }; }; }; panel@0 { compatible = "bananapi,s070wv20-ct16-icn6211"; reg = <0>; enable-gpios = <&pio 1 7 GPIO_ACTIVE_HIGH>; /* LCD-PWR-EN: PB7 */ reset-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* LCD-RST: PL5 */ backlight = <&backlight>; port { panel_out_dsi: endpoint { remote-endpoint = <&dsi_out_panel>; }; }; }; }; Case-2, bridge: panel { compatible = "bananapi,s070wv20-ct16", "simple-panel"; enable-gpios = <&pio 1 7 GPIO_ACTIVE_HIGH>; /* LCD-PWR-EN: PB7 */ backlight = <&backlight>; port { panel_out_bridge: endpoint { remote-endpoint = <&bridge_out_panel>; }; }; }; &dsi { vcc-dsi-supply = <®_dcdc1>; /* VCC-DSI */ status = "okay"; ports { dsi_out: port@1 { reg = <1>; dsi_out_bridge: endpoint { remote-endpoint = <&bridge_out_dsi>; }; }; }; bridge@0 { reg = <0>; compatible = "bananapi,icn6211", "chipone,icn6211"; reset-gpios = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* LCD-RST: PL5 */ #address-cells = <1>; #size-cells = <0>; ports { #address-cells = <1>; #size-cells = <0>; bridge_in: port@0 { reg = <0>; bridge_out_dsi: endpoint { remote-endpoint = <&dsi_out_bridge>; }; }; bridge_out: port@1 { reg = <1>; bridge_out_panel: endpoint { remote-endpoint = <&panel_out_bridge>; }; }; }; }; }; I think, I'm sure about the pipeline connections as per my understanding. but something loosely missed here or in the code. Please do let me know for any suggestions. Jagan.
diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 0960b96b62cc..64d74313b842 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -781,6 +781,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (!IS_ERR(dsi->panel)) drm_panel_prepare(dsi->panel); + if (!IS_ERR(dsi->bridge)) + drm_bridge_pre_enable(dsi->bridge); + /* * FIXME: This should be moved after the switch to HS mode. * @@ -796,6 +799,9 @@ static void sun6i_dsi_encoder_enable(struct drm_encoder *encoder) if (!IS_ERR(dsi->panel)) drm_panel_enable(dsi->panel); + if (!IS_ERR(dsi->bridge)) + drm_bridge_enable(dsi->bridge); + sun6i_dsi_start(dsi, DSI_START_HSC); udelay(1000); @@ -812,6 +818,9 @@ static void sun6i_dsi_encoder_disable(struct drm_encoder *encoder) if (!IS_ERR(dsi->panel)) { drm_panel_disable(dsi->panel); drm_panel_unprepare(dsi->panel); + } else if (!IS_ERR(dsi->bridge)) { + drm_bridge_disable(dsi->bridge); + drm_bridge_post_disable(dsi->bridge); } phy_power_off(dsi->dphy); @@ -973,11 +982,16 @@ static int sun6i_dsi_attach(struct mipi_dsi_host *host, struct sun6i_dsi *dsi = host_to_sun6i_dsi(host); dsi->device = device; - dsi->panel = of_drm_find_panel(device->dev.of_node); - if (IS_ERR(dsi->panel)) - return PTR_ERR(dsi->panel); - dev_info(host->dev, "Attached device %s\n", device->name); + dsi->bridge = of_drm_find_bridge(device->dev.of_node); + if (!dsi->bridge) { + dsi->panel = of_drm_find_panel(device->dev.of_node); + if (IS_ERR(dsi->panel)) + return PTR_ERR(dsi->panel); + } + + dev_info(host->dev, "Attached %s %s\n", + dsi->bridge ? "bridge" : "panel", device->name); return 0; } @@ -1055,8 +1069,10 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, struct sun4i_tcon *tcon0 = sun4i_get_tcon0(drm); int ret; - if (!dsi->panel) + if (!(dsi->panel || dsi->bridge)) { + dev_info(drm->dev, "No panel or bridge found... DSI output disabled\n"); return -EPROBE_DEFER; + } dsi->drv = drv; @@ -1078,19 +1094,29 @@ static int sun6i_dsi_bind(struct device *dev, struct device *master, } dsi->encoder.possible_crtcs = BIT(0); - drm_connector_helper_add(&dsi->connector, - &sun6i_dsi_connector_helper_funcs); - ret = drm_connector_init(drm, &dsi->connector, - &sun6i_dsi_connector_funcs, - DRM_MODE_CONNECTOR_DSI); - if (ret) { - dev_err(dsi->dev, - "Couldn't initialise the DSI connector\n"); - goto err_cleanup_connector; + if (dsi->panel) { + drm_connector_helper_add(&dsi->connector, + &sun6i_dsi_connector_helper_funcs); + ret = drm_connector_init(drm, &dsi->connector, + &sun6i_dsi_connector_funcs, + DRM_MODE_CONNECTOR_DSI); + if (ret) { + dev_err(dsi->dev, + "Couldn't initialise the DSI connector\n"); + goto err_cleanup_connector; + } + + drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); + drm_panel_attach(dsi->panel, &dsi->connector); } - drm_connector_attach_encoder(&dsi->connector, &dsi->encoder); - drm_panel_attach(dsi->panel, &dsi->connector); + if (dsi->bridge) { + ret = drm_bridge_attach(&dsi->encoder, dsi->bridge, NULL); + if (ret) { + dev_err(dsi->dev, "Couldn't attach the DSI bridge\n"); + goto err_cleanup_connector; + } + } return 0; @@ -1104,7 +1130,12 @@ static void sun6i_dsi_unbind(struct device *dev, struct device *master, { struct sun6i_dsi *dsi = dev_get_drvdata(dev); - drm_panel_detach(dsi->panel); + if (dsi->panel) + drm_panel_detach(dsi->panel); + + if (dsi->bridge) + drm_bridge_detach(dsi->bridge); + } 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 5c4983212f89..76874ff8e3ef 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.h @@ -36,6 +36,7 @@ struct sun6i_dsi { struct sun4i_tcon *tcon; struct mipi_dsi_device *device; struct drm_panel *panel; + struct drm_bridge *bridge; const struct sun6i_dsi_variant *variant; };