Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1439188 > unrolled thread

[PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll

Started byChris Zhong <zyw@rock-chips.com>
First post2016-07-08 11:10 +0200
Last post2016-07-11 11:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll Chris Zhong <zyw@rock-chips.com> - 2016-07-08 11:10 +0200
    Re: [PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll John Keeping <john@metanate.com> - 2016-07-08 16:20 +0200
      Re: [PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll Mark yao <mark.yao@rock-chips.com> - 2016-07-11 02:50 +0200
        Re: [PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll John Keeping <john@metanate.com> - 2016-07-11 11:30 +0200

#1439188 — [PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll

FromChris Zhong <zyw@rock-chips.com>
Date2016-07-08 11:10 +0200
Subject[PATCH 5/7] drm/rockchip: dw-mipi: support HPD poll
Message-ID<rSzXk-2G5-17@gated-at.bofh.it>
At the first time of bind, there is no any panel attach in mipi. Add a
DRM_CONNECTOR_POLL_HPD porperty to detect the panel status, when panel
probe, the dw_mipi_dsi_host_attach would be called, then mipi-dsi will
trigger a event to notify the drm framework.

Signed-off-by: Chris Zhong <zyw@rock-chips.com>
---

 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 41 ++++++++++++++++++++++++++++------
 1 file changed, 34 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 15ba796..72d7f48 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -285,6 +285,7 @@ struct dw_mipi_dsi {
 	struct drm_encoder encoder;
 	struct drm_connector connector;
 	struct mipi_dsi_host dsi_host;
+	struct device_node *panel_node;
 	struct drm_panel *panel;
 	struct device *dev;
 	struct regmap *grf_regmap;
@@ -462,7 +463,6 @@ static int dw_mipi_dsi_phy_init(struct dw_mipi_dsi *dsi)
 	dsi_write(dsi, DSI_PHY_RSTZ, PHY_ENFORCEPLL | PHY_ENABLECLK |
 				     PHY_UNRSTZ | PHY_UNSHUTDOWNZ);
 
-
 	ret = readx_poll_timeout(readl, dsi->base + DSI_PHY_STATUS,
 				 val, val & LOCK, 1000, PHY_STATUS_TIMEOUT_US);
 	if (ret < 0) {
@@ -550,11 +550,11 @@ static int dw_mipi_dsi_host_attach(struct mipi_dsi_host *host,
 	dsi->lanes = device->lanes;
 	dsi->channel = device->channel;
 	dsi->format = device->format;
-	dsi->panel = of_drm_find_panel(device->dev.of_node);
-	if (dsi->panel)
-		return drm_panel_attach(dsi->panel, &dsi->connector);
+	dsi->panel_node = device->dev.of_node;
+	if (dsi->connector.dev)
+		drm_helper_hpd_irq_event(dsi->connector.dev);
 
-	return -EINVAL;
+	return 0;
 }
 
 static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
@@ -562,7 +562,10 @@ static int dw_mipi_dsi_host_detach(struct mipi_dsi_host *host,
 {
 	struct dw_mipi_dsi *dsi = host_to_dsi(host);
 
-	drm_panel_detach(dsi->panel);
+	dsi->panel_node = NULL;
+
+	if (dsi->connector.dev)
+		drm_helper_hpd_irq_event(dsi->connector.dev);
 
 	return 0;
 }
@@ -1022,13 +1025,33 @@ static struct drm_connector_helper_funcs dw_mipi_dsi_connector_helper_funcs = {
 static enum drm_connector_status
 dw_mipi_dsi_detect(struct drm_connector *connector, bool force)
 {
-	return connector_status_connected;
+	struct dw_mipi_dsi *dsi = con_to_dsi(connector);
+
+
+	if (!dsi->panel) {
+		dsi->panel = of_drm_find_panel(dsi->panel_node);
+		if (dsi->panel)
+			drm_panel_attach(dsi->panel, &dsi->connector);
+	} else if (!dsi->panel_node) {
+		struct drm_encoder *encoder;
+
+		encoder = platform_get_drvdata(to_platform_device(dsi->dev));
+		dw_mipi_dsi_encoder_disable(encoder);
+		drm_panel_detach(dsi->panel);
+		dsi->panel = NULL;
+	}
+
+	if (dsi->panel)
+		return connector_status_connected;
+
+	return connector_status_disconnected;
 }
 
 static void dw_mipi_dsi_drm_connector_destroy(struct drm_connector *connector)
 {
 	drm_connector_unregister(connector);
 	drm_connector_cleanup(connector);
+	connector->dev = NULL;
 }
 
 static struct drm_connector_funcs dw_mipi_dsi_atomic_connector_funcs = {
@@ -1069,6 +1092,8 @@ static int dw_mipi_dsi_register(struct drm_device *drm,
 		return ret;
 	}
 
+	connector->polled = DRM_CONNECTOR_POLL_HPD;
+
 	drm_connector_helper_add(connector,
 			&dw_mipi_dsi_connector_helper_funcs);
 
@@ -1225,6 +1250,8 @@ static void dw_mipi_dsi_unbind(struct device *dev, struct device *master,
 {
 	struct dw_mipi_dsi *dsi = dev_get_drvdata(dev);
 
+	dw_mipi_dsi_encoder_disable(&dsi->encoder);
+
 	mipi_dsi_host_unregister(&dsi->dsi_host);
 	pm_runtime_disable(dev);
 	clk_disable_unprepare(dsi->pllref_clk);
-- 
2.6.3

[toc] | [next] | [standalone]


#1439504

FromJohn Keeping <john@metanate.com>
Date2016-07-08 16:20 +0200
Message-ID<rSENk-5T8-29@gated-at.bofh.it>
In reply to#1439188
On Fri,  8 Jul 2016 17:04:59 +0800, Chris Zhong wrote:

> At the first time of bind, there is no any panel attach in mipi. Add a
> DRM_CONNECTOR_POLL_HPD porperty to detect the panel status, when panel
> probe, the dw_mipi_dsi_host_attach would be called, then mipi-dsi will
> trigger a event to notify the drm framework.
> 
> Signed-off-by: Chris Zhong <zyw@rock-chips.com>

Can we do something like this instead?  We know that the panel must
always be attached and this has the advantage that the display size will
be known when the framebuffer console loads.

-- >8 --
Subject: [PATCH] drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded

This ensures that the output resolution is known before fbcon loads.

Signed-off-by: John Keeping <john@metanate.com>
---
 drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index 6ef5f3be8468..c0499266d116 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -1154,10 +1154,17 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
 
 	dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
 	dsi->dsi_host.dev = dev;
-	return mipi_dsi_host_register(&dsi->dsi_host);
+	ret = mipi_dsi_host_register(&dsi->dsi_host);
+	if (!ret && !dsi->panel) {
+		mipi_dsi_host_unregister(&dsi->dsi_host);
+		drm_encoder_cleanup(&dsi->encoder);
+		drm_connector_cleanup(&dsi->connector);
+		ret = -EPROBE_DEFER;
+	}
 
 err_pllref:
-	clk_disable_unprepare(dsi->pllref_clk);
+	if (ret)
+		clk_disable_unprepare(dsi->pllref_clk);
 	return ret;
 }
 

[toc] | [prev] | [next] | [standalone]


#1440189

FromMark yao <mark.yao@rock-chips.com>
Date2016-07-11 02:50 +0200
Message-ID<rTxA5-8bO-1@gated-at.bofh.it>
In reply to#1439504
On 2016年07月08日 21:52, John Keeping wrote:
> On Fri,  8 Jul 2016 17:04:59 +0800, Chris Zhong wrote:
>
>> At the first time of bind, there is no any panel attach in mipi. Add a
>> DRM_CONNECTOR_POLL_HPD porperty to detect the panel status, when panel
>> probe, the dw_mipi_dsi_host_attach would be called, then mipi-dsi will
>> trigger a event to notify the drm framework.
>>
>> Signed-off-by: Chris Zhong <zyw@rock-chips.com>
> Can we do something like this instead?  We know that the panel must
> always be attached and this has the advantage that the display size will
> be known when the framebuffer console loads.
>
> -- >8 --
> Subject: [PATCH] drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded
>
> This ensures that the output resolution is known before fbcon loads.
>
> Signed-off-by: John Keeping <john@metanate.com>
> ---
>   drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 11 +++++++++--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> index 6ef5f3be8468..c0499266d116 100644
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> @@ -1154,10 +1154,17 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
>   
>   	dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
>   	dsi->dsi_host.dev = dev;
> -	return mipi_dsi_host_register(&dsi->dsi_host);
> +	ret = mipi_dsi_host_register(&dsi->dsi_host);
> +	if (!ret && !dsi->panel) {
> +		mipi_dsi_host_unregister(&dsi->dsi_host);
> +		drm_encoder_cleanup(&dsi->encoder);
> +		drm_connector_cleanup(&dsi->connector);
> +		ret = -EPROBE_DEFER;

Hi John

Do you verify this patch? I do the similar change before, but found 
panel can't probe.

mipi_dsi_host_register will call device_add, I think the panel probe 
need this.

Seems that mipi panel probe request mipi_dsi_host_register, 
mipi_dsi_host_register request panel on your patch, endless loop.

Thanks.

> +	}
>   
>   err_pllref:
> -	clk_disable_unprepare(dsi->pllref_clk);
> +	if (ret)
> +		clk_disable_unprepare(dsi->pllref_clk);
>   	return ret;
>   }
>   
>
>
>


-- 
Mark Yao

[toc] | [prev] | [next] | [standalone]


#1440394

FromJohn Keeping <john@metanate.com>
Date2016-07-11 11:30 +0200
Message-ID<rTFHj-55x-7@gated-at.bofh.it>
In reply to#1440189
On Mon, 11 Jul 2016 08:46:53 +0800, Mark yao wrote:

> On 2016年07月08日 21:52, John Keeping wrote:
> > On Fri,  8 Jul 2016 17:04:59 +0800, Chris Zhong wrote:
> >  
> >> At the first time of bind, there is no any panel attach in mipi. Add a
> >> DRM_CONNECTOR_POLL_HPD porperty to detect the panel status, when panel
> >> probe, the dw_mipi_dsi_host_attach would be called, then mipi-dsi will
> >> trigger a event to notify the drm framework.
> >>
> >> Signed-off-by: Chris Zhong <zyw@rock-chips.com>  
> > Can we do something like this instead?  We know that the panel must
> > always be attached and this has the advantage that the display size will
> > be known when the framebuffer console loads.
> >  
> > -- >8 --  
> > Subject: [PATCH] drm/rockchip: dw-mipi-dsi: defer probe if panel is not loaded
> >
> > This ensures that the output resolution is known before fbcon loads.
> >
> > Signed-off-by: John Keeping <john@metanate.com>
> > ---
> >   drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 11 +++++++++--
> >   1 file changed, 9 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > index 6ef5f3be8468..c0499266d116 100644
> > --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> > @@ -1154,10 +1154,17 @@ static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
> >   
> >   	dsi->dsi_host.ops = &dw_mipi_dsi_host_ops;
> >   	dsi->dsi_host.dev = dev;
> > -	return mipi_dsi_host_register(&dsi->dsi_host);
> > +	ret = mipi_dsi_host_register(&dsi->dsi_host);
> > +	if (!ret && !dsi->panel) {
> > +		mipi_dsi_host_unregister(&dsi->dsi_host);
> > +		drm_encoder_cleanup(&dsi->encoder);
> > +		drm_connector_cleanup(&dsi->connector);
> > +		ret = -EPROBE_DEFER;  
> 
> Do you verify this patch? I do the similar change before, but found 
> panel can't probe.
> 
> mipi_dsi_host_register will call device_add, I think the panel probe 
> need this.
> 
> Seems that mipi panel probe request mipi_dsi_host_register, 
> mipi_dsi_host_register request panel on your patch, endless loop.

Yes, I've been running this patch for months.  It's possible that I have
another patch that is needed to get this to work correctly (I have a
whole set of Rockchip MIPI patches that I need to find time to submit,
for now I've pushed a branch to Github [1]).

I don't know what you mean about the panel probe requesting
mipi_dsi_host_register, the panel probe calls mipi_dsi_attach() and is
itself called from mipi_dsi_host_register().  My patch doesn't change
this at all, the only change is that if the panel driver is not
available, then the probe fails.  Later, once the panel driver has been
registered the probe will succeed.  This is no different from the
current behaviour if the order of probing drivers happens to load the
panel before dw-mipi-dsi.

[1] https://github.com/johnkeeping/linux/commits/topic/rockchip-mipi

> > +	}
> >   
> >   err_pllref:
> > -	clk_disable_unprepare(dsi->pllref_clk);
> > +	if (ret)
> > +		clk_disable_unprepare(dsi->pllref_clk);
> >   	return ret;
> >   }
> >   
> >
> >
> >  
> 
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web