linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Archit Taneja <architt@codeaurora.org>
To: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	dri-devel@lists.freedesktop.org
Cc: linux-renesas-soc@vger.kernel.org,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Inki Dae <inki.dae@samsung.com>,
	Joonyoung Shim <jy0922.shim@samsung.com>,
	Seung-Woo Kim <sw0312.kim@samsung.com>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Stefan Agner <stefan@agner.ch>,
	Alison Wang <alison.wang@freescale.com>,
	Xinliang Liu <z.liuxinliang@hisilicon.com>,
	Rongrong Zou <zourongrong@gmail.com>,
	Xinwei Kong <kong.kongxinwei@hisilicon.com>,
	Chen Feng <puck.chen@hisilicon.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	CK Hu <ck.hu@mediatek.com>, Rob Clark <robdclark@gmail.com>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Vincent Abriou <vincent.abriou@st.com>,
	Maxime Ripard <maxime.ripard@free-electrons.com>
Subject: Re: [PATCH v3 03/13] drm: bridge: Link encoder and bridge in core code
Date: Tue, 29 Nov 2016 15:57:06 +0530	[thread overview]
Message-ID: <94e6b51f-71bf-8734-a843-e236ea1e8ff1@codeaurora.org> (raw)
In-Reply-To: <1480410283-28698-4-git-send-email-laurent.pinchart+renesas@ideasonboard.com>



On 11/29/2016 02:34 PM, Laurent Pinchart wrote:
> Instead of linking encoders and bridges in every driver (and getting it
> wrong half of the time, as many drivers forget to set the drm_bridge
> encoder pointer), do so in core code. The drm_bridge_attach() function
> needs the encoder and optional previous bridge to perform that task,
> update all the callers.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>  drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c   |  4 +-
>  drivers/gpu/drm/bridge/analogix/analogix_dp_core.c |  4 +-
>  drivers/gpu/drm/bridge/dw-hdmi.c                   |  3 +-
>  drivers/gpu/drm/drm_bridge.c                       | 46 ++++++++++++++++------
>  drivers/gpu/drm/drm_simple_kms_helper.c            |  4 +-
>  drivers/gpu/drm/exynos/exynos_dp.c                 |  5 +--
>  drivers/gpu/drm/exynos/exynos_drm_dsi.c            |  6 +--
>  drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c          |  5 +--
>  drivers/gpu/drm/hisilicon/kirin/dw_drm_dsi.c       |  5 +--
>  drivers/gpu/drm/imx/imx-ldb.c                      |  6 +--
>  drivers/gpu/drm/imx/parallel-display.c             |  4 +-
>  drivers/gpu/drm/mediatek/mtk_dpi.c                 |  8 ++--
>  drivers/gpu/drm/mediatek/mtk_dsi.c                 | 24 ++---------
>  drivers/gpu/drm/mediatek/mtk_hdmi.c                | 11 +++---
>  drivers/gpu/drm/msm/dsi/dsi_manager.c              | 17 +++++---
>  drivers/gpu/drm/msm/edp/edp_bridge.c               |  2 +-
>  drivers/gpu/drm/msm/hdmi/hdmi_bridge.c             |  2 +-
>  drivers/gpu/drm/rcar-du/rcar_du_hdmienc.c          |  5 +--
>  drivers/gpu/drm/sti/sti_dvo.c                      |  3 +-
>  drivers/gpu/drm/sti/sti_hda.c                      |  3 +-
>  drivers/gpu/drm/sti/sti_hdmi.c                     |  3 +-
>  drivers/gpu/drm/sun4i/sun4i_rgb.c                  | 13 +++---
>  include/drm/drm_bridge.h                           |  3 +-
>  23 files changed, 83 insertions(+), 103 deletions(-)
>
> diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
> index 6119b5085501..e7799b6ee829 100644
> --- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
> +++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_output.c
> @@ -230,9 +230,7 @@ static int atmel_hlcdc_attach_endpoint(struct drm_device *dev,
>  	of_node_put(np);
>
>  	if (bridge) {
> -		output->encoder.bridge = bridge;
> -		bridge->encoder = &output->encoder;
> -		ret = drm_bridge_attach(dev, bridge);
> +		ret = drm_bridge_attach(&output->encoder, bridge, NULL);
>  		if (!ret)
>  			return 0;
>  	}
> diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> index 6e0447f329a2..1835f1fdad19 100644
> --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
> @@ -1227,12 +1227,10 @@ static int analogix_dp_create_bridge(struct drm_device *drm_dev,
>
>  	dp->bridge = bridge;
>
> -	dp->encoder->bridge = bridge;
>  	bridge->driver_private = dp;
> -	bridge->encoder = dp->encoder;
>  	bridge->funcs = &analogix_dp_bridge_funcs;
>
> -	ret = drm_bridge_attach(drm_dev, bridge);
> +	ret = drm_bridge_attach(dp->encoder, bridge, NULL);
>  	if (ret) {
>  		DRM_ERROR("failed to attach drm bridge\n");
>  		return -EINVAL;
> diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
> index b71088dab268..432e0e3fff72 100644
> --- a/drivers/gpu/drm/bridge/dw-hdmi.c
> +++ b/drivers/gpu/drm/bridge/dw-hdmi.c
> @@ -1841,13 +1841,12 @@ static int dw_hdmi_register(struct drm_device *drm, struct dw_hdmi *hdmi)
>  	hdmi->bridge = bridge;
>  	bridge->driver_private = hdmi;
>  	bridge->funcs = &dw_hdmi_bridge_funcs;
> -	ret = drm_bridge_attach(drm, bridge);
> +	ret = drm_bridge_attach(encoder, bridge, NULL);
>  	if (ret) {
>  		DRM_ERROR("Failed to initialize bridge with drm\n");
>  		return -EINVAL;
>  	}
>
> -	encoder->bridge = bridge;
>  	hdmi->connector.polled = DRM_CONNECTOR_POLL_HPD;
>
>  	drm_connector_helper_add(&hdmi->connector,
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index 0ee052b7c21a..850bd6509ef1 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -26,6 +26,7 @@
>  #include <linux/mutex.h>
>
>  #include <drm/drm_bridge.h>
> +#include <drm/drm_encoder.h>
>
>  /**
>   * DOC: overview
> @@ -92,32 +93,53 @@ void drm_bridge_remove(struct drm_bridge *bridge)
>  EXPORT_SYMBOL(drm_bridge_remove);
>
>  /**
> - * drm_bridge_attach - associate given bridge to our DRM device
> + * drm_bridge_attach - attach the bridge to an encoder's chain
>   *
> - * @dev: DRM device
> - * @bridge: bridge control structure
> + * @encoder: DRM encoder
> + * @bridge: bridge to attach
> + * @previous: previous bridge in the chain (optional)
>   *
> - * Called by a kms driver to link one of our encoder/bridge to the given
> - * bridge.
> + * Called by a kms driver to link the bridge to an encoder's chain. The previous
> + * argument specifies the previous bridge in the chain. If NULL, the bridge is
> + * linked directly at the encoder's output. Otherwise it is linked at the
> + * previous bridge's output.
>   *
> - * Note that setting up links between the bridge and our encoder/bridge
> - * objects needs to be handled by the kms driver itself.
> + * If non-NULL the previous bridge must be already attached by a call to this
> + * function.
>   *
>   * RETURNS:
>   * Zero on success, error code on failure
>   */
> -int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge)
> +int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
> +		      struct drm_bridge *previous)
>  {
> -	if (!dev || !bridge)
> +	int ret;
> +
> +	if (!encoder || !bridge)
> +		return -EINVAL;

I think we could derive previous from the encoder itself. Something like:

	previous = encoder->bridge;
	while (previous && previous->next)
		previous = previous->next;
		
> +
> +	if (previous && (!previous->dev || previous->encoder != encoder))
>  		return -EINVAL;
>
>  	if (bridge->dev)
>  		return -EBUSY;
>
> -	bridge->dev = dev;
> +	bridge->dev = encoder->dev;
> +	bridge->encoder = encoder;
> +
> +	if (bridge->funcs->attach) {
> +		ret = bridge->funcs->attach(bridge);
> +		if (ret < 0) {
> +			bridge->dev = NULL;
> +			bridge->encoder = NULL;
> +			return ret;
> +		}
> +	}
>
> -	if (bridge->funcs->attach)
> -		return bridge->funcs->attach(bridge);
> +	if (previous)
> +		previous->next = bridge;
> +	else
> +		encoder->bridge = bridge;
>
>  	return 0;
>  }

<snip>

Archit

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

  parent reply	other threads:[~2016-11-29 10:27 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-29  9:04 [PATCH v3 00/13] R-Car DU: Use drm bridge API Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 01/13] drm: Don't include <drm/drm_encoder.h> in <drm/drm_crtc.h> Laurent Pinchart
2016-11-29  9:30   ` Daniel Vetter
2016-11-29  9:37     ` Laurent Pinchart
2016-12-02 21:21   ` Sinclair Yeh
2016-11-29  9:04 ` [PATCH v3 02/13] drm: Fix compilation warning caused by static inline forward declaration Laurent Pinchart
2016-11-29  9:31   ` Daniel Vetter
2016-11-29  9:04 ` [PATCH v3 03/13] drm: bridge: Link encoder and bridge in core code Laurent Pinchart
2016-11-29  9:35   ` Daniel Vetter
2016-11-29  9:43     ` Laurent Pinchart
2016-11-29 10:05       ` Daniel Vetter
2016-11-29 18:02         ` Laurent Pinchart
2016-11-29 18:51           ` Laurent Pinchart
2016-11-29 10:27   ` Archit Taneja [this message]
2016-11-29 17:57     ` Laurent Pinchart
2016-11-30  5:05       ` Archit Taneja
2016-11-30 10:23         ` Laurent Pinchart
2016-11-30 11:00           ` Archit Taneja
2016-11-30 11:05             ` Laurent Pinchart
2016-11-30 13:27               ` Archit Taneja
2016-11-29 17:01   ` Stefan Agner
2016-11-29 19:58   ` Boris Brezillon
2016-11-30 15:30   ` Vincent ABRIOU
2016-11-29  9:04 ` [PATCH v3 04/13] drm: bridge: Detach bridge from encoder at encoder cleanup time Laurent Pinchart
2016-11-29  9:48   ` Daniel Vetter
2016-11-29 19:00     ` Laurent Pinchart
2016-11-29 10:34   ` Archit Taneja
2016-11-29 18:56     ` Laurent Pinchart
2016-11-29 20:22       ` Daniel Vetter
2016-11-29  9:04 ` [PATCH v3 05/13] drm: bridge: Add LVDS encoder DT bindings Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 06/13] drm: bridge: Add LVDS encoder driver Laurent Pinchart
2016-11-29  9:54   ` Daniel Vetter
2016-11-29 20:57     ` Laurent Pinchart
2017-01-04  1:33       ` Laurent Pinchart
2017-01-04  8:18       ` Daniel Vetter
2017-01-04 13:08         ` Laurent Pinchart
2017-01-04 13:51           ` Daniel Vetter
2017-01-04 14:33             ` Laurent Pinchart
2017-01-04 14:58               ` Daniel Vetter
2017-01-04 15:13                 ` Laurent Pinchart
2017-03-02  0:30                   ` Laurent Pinchart
2017-03-02  7:05                     ` Daniel Vetter
2016-11-29  9:04 ` [PATCH v3 07/13] drm: bridge: vga-dac: Add adi,adv7123 compatible string Laurent Pinchart
2016-11-29  9:50   ` Maxime Ripard
2016-11-29  9:04 ` [PATCH v3 08/13] drm: bridge: lvds-encoder: Add thine,thc63lvdm83d " Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 09/13] drm: Add encoder_type field to the drm_bridge structure Laurent Pinchart
2016-11-29  9:56   ` Daniel Vetter
2016-11-29  9:58     ` Laurent Pinchart
2016-11-29 10:27       ` Daniel Vetter
2016-11-29 17:49         ` Laurent Pinchart
2016-11-29 20:25           ` Daniel Vetter
2016-11-29 22:42             ` Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 10/13] drm: bridge: Set bridges' encoder type Laurent Pinchart
2016-11-29  9:04 ` [PATCH v3 11/13] drm: Set on-chip " Laurent Pinchart
2016-11-30 15:28   ` Vincent ABRIOU
2016-11-29  9:04 ` [PATCH v3 12/13] drm: rcar-du: Replace manual bridge implementation with DRM bridge Laurent Pinchart
2016-12-27 12:40   ` Geert Uytterhoeven
2016-11-29  9:04 ` [PATCH v3 13/13] drm: rcar-du: Initialize encoder's type based on the bridge's type Laurent Pinchart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94e6b51f-71bf-8734-a843-e236ea1e8ff1@codeaurora.org \
    --to=architt@codeaurora.org \
    --cc=alison.wang@freescale.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=ck.hu@mediatek.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=jingoohan1@gmail.com \
    --cc=jy0922.shim@samsung.com \
    --cc=kong.kongxinwei@hisilicon.com \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=p.zabel@pengutronix.de \
    --cc=puck.chen@hisilicon.com \
    --cc=robdclark@gmail.com \
    --cc=stefan@agner.ch \
    --cc=sw0312.kim@samsung.com \
    --cc=vincent.abriou@st.com \
    --cc=z.liuxinliang@hisilicon.com \
    --cc=zourongrong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).