All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Philippe CORNU <philippe.cornu@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	David Airlie <airlied@linux.ie>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Russell King <linux@armlinux.org.uk>,
	Mark Rutland <mark.rutland@arm.com>,
	Rob Herring <robh+dt@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	Yannick Fertre <yannick.fertre@st.com>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Archit Taneja <architt@codeaurora.org>,
	Eric Anholt <eric@anholt.net>, Chris Zhong <zyw@rock-chips.com>
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Fabien Dessenne <fabien.dessenne@st.com>,
	Ludovic Barre <ludovic.barre@st.com>,
	Mickael Reulier <mickael.reulier@st.com>,
	Vincent Abriou <vincent.abriou@st.com>,
	Gabriel Fernandez <gabriel.fernandez@st.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 1/5] drm/stm: ltdc: Add bridge support
Date: Tue, 23 May 2017 11:11:34 +0900	[thread overview]
Message-ID: <c9b45faa-89f9-c31c-a5c4-2780fdb79d62@samsung.com> (raw)
In-Reply-To: <1495207218-11372-2-git-send-email-philippe.cornu@st.com>

Hi Philippe,

W dniu 2017-05-20 o 00:20, Philippe CORNU pisze:
> Add the bridge support, used by DSI host and HDMI/LVDS bridges.
>
> Signed-off-by: Philippe CORNU <philippe.cornu@st.com>
> ---
>   drivers/gpu/drm/stm/ltdc.c | 74 ++++++++++++++++++++++++++++++++++------------
>   drivers/gpu/drm/stm/ltdc.h |  1 +
>   2 files changed, 56 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 7b2d63b..809e420 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -858,6 +858,43 @@ static struct drm_encoder *ltdc_rgb_encoder_create(struct drm_device *ddev)
>   	return encoder;
>   }
>   
> +static const struct drm_encoder_funcs bridge_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
> +struct drm_encoder *bridge_encoder_create(struct drm_device *ddev,
> +					  struct drm_bridge *bridge)
> +{
> +	struct drm_encoder *encoder;
> +	int ret;
> +
> +	encoder = devm_kzalloc(ddev->dev, sizeof(*encoder), GFP_KERNEL);
> +	if (!encoder)
> +		return NULL;
> +
> +	encoder->possible_crtcs = CRTC_MASK;
> +	encoder->possible_clones = 0; /* No cloning support */
> +
> +	drm_encoder_init(ddev, encoder, &bridge_encoder_funcs,
> +			 DRM_MODE_ENCODER_TMDS, NULL);
> +
> +	drm_encoder_helper_add(encoder, NULL);
> +
> +	/* Link drm_bridge to encoder */
> +	bridge->encoder = encoder;
> +	encoder->bridge = bridge;

I think the above two lines are redundant, drm_bridge_attach should do that.

> +
> +	ret = drm_bridge_attach(encoder, bridge, NULL);
> +	if (ret) {
> +		drm_encoder_cleanup(encoder);
> +		return NULL;
> +	}
> +
> +	DRM_DEBUG_DRIVER("Bridge encoder:%d created\n", encoder->base.id);
> +
> +	return encoder;
> +}
> +
>   /*
>    * DRM_CONNECTOR
>    */
> @@ -967,12 +1004,13 @@ static int ltdc_get_caps(struct drm_device *ddev)
>   	return 0;
>   }
>   
> -static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
> +static int ltdc_parse_dt(struct drm_device *ddev)
>   {
> +	struct ltdc_device *ldev = ddev->dev_private;
>   	struct device *dev = ddev->dev;
>   	struct device_node *np = dev->of_node;
> -	struct device_node *entity, *port = NULL;
> -	struct drm_panel *panel = NULL;
> +	struct device_node *entity;
> +	int ret;
>   
>   	DRM_DEBUG_DRIVER("\n");
>   
> @@ -985,21 +1023,13 @@ static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
>   		if (!of_device_is_available(entity))
>   			continue;
>   
> -		port = of_graph_get_remote_port_parent(entity);
> -		if (port) {
> -			panel = of_drm_find_panel(port);
> -			of_node_put(port);
> -			if (panel) {
> -				DRM_DEBUG_DRIVER("remote panel %s\n",
> -						 port->full_name);
> -			} else {
> -				DRM_DEBUG_DRIVER("panel missing\n");
> -				of_node_put(entity);
> -			}
> -		}
> +		ret = drm_of_find_panel_or_bridge(np, 0, 0,
> +						  &ldev->panel, &ldev->bridge);
> +		if (ret)
> +			return ret;
>   	}
>   
> -	return panel;
> +	return 0;
>   }
>   
>   int ltdc_load(struct drm_device *ddev)
> @@ -1017,9 +1047,9 @@ int ltdc_load(struct drm_device *ddev)
>   
>   	DRM_DEBUG_DRIVER("\n");
>   
> -	ldev->panel = ltdc_get_panel(ddev);
> -	if (!ldev->panel)
> -		return -EPROBE_DEFER;
> +	ret = ltdc_parse_dt(ddev);
> +	if (ret)
> +		return ret;
>   
>   	rstc = of_reset_control_get(np, NULL);
>   
> @@ -1077,6 +1107,12 @@ int ltdc_load(struct drm_device *ddev)
>   
>   	DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version);
>   
> +	if (ldev->bridge) {
> +		encoder = bridge_encoder_create(ddev, ldev->bridge);
> +		if (!encoder)
> +			return -EINVAL;
> +	}
> +

I guess you could add 'else' clause after closing bracket - ldev->bridge 
and ldev->panel are mutually exclusive, but it is up to you.

Beside this:
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>

Regards
Andrzej

>   	if (ldev->panel) {
>   		encoder = ltdc_rgb_encoder_create(ddev);
>   		if (!encoder) {
> diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
> index 5427ef4..0083cad 100644
> --- a/drivers/gpu/drm/stm/ltdc.h
> +++ b/drivers/gpu/drm/stm/ltdc.h
> @@ -25,6 +25,7 @@ struct ltdc_device {
>   	void __iomem *regs;
>   	struct clk *pixel_clk;	/* lcd pixel clock */
>   	struct drm_panel *panel;
> +	struct drm_bridge *bridge;
>   	struct spinlock lock;	/* protecting irq status register */
>   	struct ltdc_caps caps;
>   	u32 clut[256];		/* color look up table */

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: a.hajda@samsung.com (Andrzej Hajda)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 1/5] drm/stm: ltdc: Add bridge support
Date: Tue, 23 May 2017 11:11:34 +0900	[thread overview]
Message-ID: <c9b45faa-89f9-c31c-a5c4-2780fdb79d62@samsung.com> (raw)
In-Reply-To: <1495207218-11372-2-git-send-email-philippe.cornu@st.com>

Hi Philippe,

W dniu 2017-05-20 o 00:20, Philippe CORNU pisze:
> Add the bridge support, used by DSI host and HDMI/LVDS bridges.
>
> Signed-off-by: Philippe CORNU <philippe.cornu@st.com>
> ---
>   drivers/gpu/drm/stm/ltdc.c | 74 ++++++++++++++++++++++++++++++++++------------
>   drivers/gpu/drm/stm/ltdc.h |  1 +
>   2 files changed, 56 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c
> index 7b2d63b..809e420 100644
> --- a/drivers/gpu/drm/stm/ltdc.c
> +++ b/drivers/gpu/drm/stm/ltdc.c
> @@ -858,6 +858,43 @@ static struct drm_encoder *ltdc_rgb_encoder_create(struct drm_device *ddev)
>   	return encoder;
>   }
>   
> +static const struct drm_encoder_funcs bridge_encoder_funcs = {
> +	.destroy = drm_encoder_cleanup,
> +};
> +
> +struct drm_encoder *bridge_encoder_create(struct drm_device *ddev,
> +					  struct drm_bridge *bridge)
> +{
> +	struct drm_encoder *encoder;
> +	int ret;
> +
> +	encoder = devm_kzalloc(ddev->dev, sizeof(*encoder), GFP_KERNEL);
> +	if (!encoder)
> +		return NULL;
> +
> +	encoder->possible_crtcs = CRTC_MASK;
> +	encoder->possible_clones = 0; /* No cloning support */
> +
> +	drm_encoder_init(ddev, encoder, &bridge_encoder_funcs,
> +			 DRM_MODE_ENCODER_TMDS, NULL);
> +
> +	drm_encoder_helper_add(encoder, NULL);
> +
> +	/* Link drm_bridge to encoder */
> +	bridge->encoder = encoder;
> +	encoder->bridge = bridge;

I think the above two lines are redundant, drm_bridge_attach should do that.

> +
> +	ret = drm_bridge_attach(encoder, bridge, NULL);
> +	if (ret) {
> +		drm_encoder_cleanup(encoder);
> +		return NULL;
> +	}
> +
> +	DRM_DEBUG_DRIVER("Bridge encoder:%d created\n", encoder->base.id);
> +
> +	return encoder;
> +}
> +
>   /*
>    * DRM_CONNECTOR
>    */
> @@ -967,12 +1004,13 @@ static int ltdc_get_caps(struct drm_device *ddev)
>   	return 0;
>   }
>   
> -static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
> +static int ltdc_parse_dt(struct drm_device *ddev)
>   {
> +	struct ltdc_device *ldev = ddev->dev_private;
>   	struct device *dev = ddev->dev;
>   	struct device_node *np = dev->of_node;
> -	struct device_node *entity, *port = NULL;
> -	struct drm_panel *panel = NULL;
> +	struct device_node *entity;
> +	int ret;
>   
>   	DRM_DEBUG_DRIVER("\n");
>   
> @@ -985,21 +1023,13 @@ static struct drm_panel *ltdc_get_panel(struct drm_device *ddev)
>   		if (!of_device_is_available(entity))
>   			continue;
>   
> -		port = of_graph_get_remote_port_parent(entity);
> -		if (port) {
> -			panel = of_drm_find_panel(port);
> -			of_node_put(port);
> -			if (panel) {
> -				DRM_DEBUG_DRIVER("remote panel %s\n",
> -						 port->full_name);
> -			} else {
> -				DRM_DEBUG_DRIVER("panel missing\n");
> -				of_node_put(entity);
> -			}
> -		}
> +		ret = drm_of_find_panel_or_bridge(np, 0, 0,
> +						  &ldev->panel, &ldev->bridge);
> +		if (ret)
> +			return ret;
>   	}
>   
> -	return panel;
> +	return 0;
>   }
>   
>   int ltdc_load(struct drm_device *ddev)
> @@ -1017,9 +1047,9 @@ int ltdc_load(struct drm_device *ddev)
>   
>   	DRM_DEBUG_DRIVER("\n");
>   
> -	ldev->panel = ltdc_get_panel(ddev);
> -	if (!ldev->panel)
> -		return -EPROBE_DEFER;
> +	ret = ltdc_parse_dt(ddev);
> +	if (ret)
> +		return ret;
>   
>   	rstc = of_reset_control_get(np, NULL);
>   
> @@ -1077,6 +1107,12 @@ int ltdc_load(struct drm_device *ddev)
>   
>   	DRM_INFO("ltdc hw version 0x%08x - ready\n", ldev->caps.hw_version);
>   
> +	if (ldev->bridge) {
> +		encoder = bridge_encoder_create(ddev, ldev->bridge);
> +		if (!encoder)
> +			return -EINVAL;
> +	}
> +

I guess you could add 'else' clause after closing bracket - ldev->bridge 
and ldev->panel are mutually exclusive, but it is up to you.

Beside this:
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>

Regards
Andrzej

>   	if (ldev->panel) {
>   		encoder = ltdc_rgb_encoder_create(ddev);
>   		if (!encoder) {
> diff --git a/drivers/gpu/drm/stm/ltdc.h b/drivers/gpu/drm/stm/ltdc.h
> index 5427ef4..0083cad 100644
> --- a/drivers/gpu/drm/stm/ltdc.h
> +++ b/drivers/gpu/drm/stm/ltdc.h
> @@ -25,6 +25,7 @@ struct ltdc_device {
>   	void __iomem *regs;
>   	struct clk *pixel_clk;	/* lcd pixel clock */
>   	struct drm_panel *panel;
> +	struct drm_bridge *bridge;
>   	struct spinlock lock;	/* protecting irq status register */
>   	struct ltdc_caps caps;
>   	u32 clut[256];		/* color look up table */

  parent reply	other threads:[~2017-05-23  2:11 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 15:20 [PATCH v2 0/5] STM32 DSI HOST Philippe CORNU
2017-05-19 15:20 ` Philippe CORNU
2017-05-19 15:20 ` [PATCH v2 2/5] dt-bindings: display: Add Synopsys DW MIPI DSI DRM bridge driver Philippe CORNU
2017-05-19 15:20   ` Philippe CORNU
     [not found]   ` <1495207218-11372-3-git-send-email-philippe.cornu-qxv4g6HH51o@public.gmane.org>
2017-05-23 15:14     ` Rob Herring
2017-05-23 15:14       ` Rob Herring
     [not found] ` <1495207218-11372-1-git-send-email-philippe.cornu-qxv4g6HH51o@public.gmane.org>
2017-05-19 15:20   ` [PATCH v2 1/5] drm/stm: ltdc: Add bridge support Philippe CORNU
2017-05-19 15:20     ` Philippe CORNU
     [not found]     ` <1495207218-11372-2-git-send-email-philippe.cornu-qxv4g6HH51o@public.gmane.org>
2017-05-19 19:33       ` Eric Anholt
2017-05-19 19:33         ` Eric Anholt
2017-05-23  2:11     ` Andrzej Hajda [this message]
2017-05-23  2:11       ` Andrzej Hajda
2017-05-19 15:20   ` [PATCH v2 3/5] drm/bridge/synopsys: Add MIPI DSI host controller bridge Philippe CORNU
2017-05-19 15:20     ` Philippe CORNU
     [not found]     ` <1495207218-11372-4-git-send-email-philippe.cornu-qxv4g6HH51o@public.gmane.org>
2017-05-19 15:33       ` Neil Armstrong
2017-05-19 15:33         ` Neil Armstrong
2017-05-19 16:16         ` Philippe CORNU
2017-05-19 16:16           ` Philippe CORNU
2017-05-25 11:23       ` Archit Taneja
2017-05-25 11:23         ` Archit Taneja
2017-06-02 15:08         ` Philippe CORNU
2017-06-02 15:08           ` Philippe CORNU
2017-05-19 15:20   ` [PATCH v2 4/5] dt-bindings: display: Add STM32 DSI host driver Philippe CORNU
2017-05-19 15:20     ` Philippe CORNU
     [not found]     ` <1495207218-11372-5-git-send-email-philippe.cornu-qxv4g6HH51o@public.gmane.org>
2017-05-23 15:17       ` Rob Herring
2017-05-23 15:17         ` Rob Herring
2017-05-19 15:20   ` [PATCH v2 5/5] drm/stm: " Philippe CORNU
2017-05-19 15:20     ` Philippe CORNU

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=c9b45faa-89f9-c31c-a5c4-2780fdb79d62@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=airlied@linux.ie \
    --cc=alexandre.torgue@st.com \
    --cc=architt@codeaurora.org \
    --cc=arnd@arndb.de \
    --cc=benjamin.gaignard@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=fabien.dessenne@st.com \
    --cc=gabriel.fernandez@st.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=ludovic.barre@st.com \
    --cc=mark.rutland@arm.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mickael.reulier@st.com \
    --cc=narmstrong@baylibre.com \
    --cc=philippe.cornu@st.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vincent.abriou@st.com \
    --cc=yannick.fertre@st.com \
    --cc=zyw@rock-chips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.