diff mbox series

[4/4] drm/bridge: ti-sn65dsi86: Add NO_CONNECTOR support

Message ID 20210811235253.924867-5-robdclark@gmail.com
State New
Headers show
Series drm/msm+ti-sn65dsi86: Fix NO_CONNECTOR fallout | expand

Commit Message

Rob Clark Aug. 11, 2021, 11:52 p.m. UTC
From: Rob Clark <robdclark@chromium.org>

Slightly awkward to fish out the display_info when we aren't creating
own connector.  But I don't see an obvious better way.

Signed-off-by: Rob Clark <robdclark@chromium.org>
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 34 +++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 5 deletions(-)

Comments

Doug Anderson Aug. 12, 2021, 5:22 p.m. UTC | #1
Hi,

On Wed, Aug 11, 2021 at 4:51 PM Rob Clark <robdclark@gmail.com> wrote:
>

> From: Rob Clark <robdclark@chromium.org>

>

> Slightly awkward to fish out the display_info when we aren't creating

> own connector.  But I don't see an obvious better way.

>

> Signed-off-by: Rob Clark <robdclark@chromium.org>

> ---

>  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 34 +++++++++++++++++++++++----

>  1 file changed, 29 insertions(+), 5 deletions(-)

>

> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c

> index 38dcc49eccaf..dc8112bab3d3 100644

> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c

> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c

> @@ -693,9 +693,11 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge,

>                 return ret;

>         }

>

> -       ret = ti_sn_bridge_connector_init(pdata);

> -       if (ret < 0)

> -               goto err_conn_init;

> +       if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {

> +               ret = ti_sn_bridge_connector_init(pdata);

> +               if (ret < 0)

> +                       goto err_conn_init;

> +       }

>

>         /*

>          * TODO: ideally finding host resource and dsi dev registration needs

> @@ -757,7 +759,8 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge,

>  err_dsi_attach:

>         mipi_dsi_device_unregister(dsi);

>  err_dsi_host:

> -       drm_connector_cleanup(&pdata->connector);

> +       if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))

> +               drm_connector_cleanup(&pdata->connector);

>  err_conn_init:

>         drm_dp_aux_unregister(&pdata->aux);

>         return ret;

> @@ -806,9 +809,30 @@ static void ti_sn_bridge_set_dsi_rate(struct ti_sn65dsi86 *pdata)

>         regmap_write(pdata->regmap, SN_DSIA_CLK_FREQ_REG, val);

>  }

>

> +/*

> + * Find the connector and fish out the bpc from display_info.  It would

> + * be nice if we could get this instead from drm_bridge_state, but that

> + * doesn't yet appear to be the case.

> + */

>  static unsigned int ti_sn_bridge_get_bpp(struct ti_sn65dsi86 *pdata)

>  {

> -       if (pdata->connector.display_info.bpc <= 6)

> +       struct drm_bridge *bridge = &pdata->bridge;

> +       struct drm_connector_list_iter conn_iter;

> +       struct drm_connector *connector;

> +       unsigned bpc = 0;

> +

> +       drm_connector_list_iter_begin(bridge->dev, &conn_iter);

> +       drm_for_each_connector_iter(connector, &conn_iter) {

> +               if (drm_connector_has_possible_encoder(connector, bridge->encoder)) {

> +                       bpc = connector->display_info.bpc;

> +                       break;

> +               }

> +       }

> +       drm_connector_list_iter_end(&conn_iter);


This looks reasonable to me. I'll plan to apply it to drm-misc-next
sometime next week to give Laurent a chance to comment on whether this
causes any problems with his planned support for full DP using this
bridge chip. IIUC that means it'll hit mainline 1 rev later, but as
per IRC comments this should be fine.

Reviewed-by: Douglas Anderson <dianders@chromium.org>



-Doug
Laurent Pinchart Aug. 12, 2021, 7:26 p.m. UTC | #2
Hi Rob,

Thank you for the patch.

On Wed, Aug 11, 2021 at 04:52:50PM -0700, Rob Clark wrote:
> From: Rob Clark <robdclark@chromium.org>

> 

> Slightly awkward to fish out the display_info when we aren't creating

> own connector.  But I don't see an obvious better way.


We need a bit more than this, to support the NO_CONNECTOR case, the
bridge has to implement a few extra operations, and set the bridge .ops
field. I've submitted two patches to do so a while ago:

- [RFC PATCH 08/11] drm/bridge: ti-sn65dsi86: Implement bridge connector operations ([1])
- [RFC PATCH 09/11] drm/bridge: ti-sn65dsi86: Make connector creation optional ([2])

The second patch is similar to the first half of this patch, but misses
the cleanup code. I'll try to rebase this and resubmit, but it may take
a bit of time.

[1] https://lore.kernel.org/dri-devel/20210322030128.2283-9-laurent.pinchart+renesas@ideasonboard.com/
[2] https://lore.kernel.org/dri-devel/20210322030128.2283-10-laurent.pinchart+renesas@ideasonboard.com/

> Signed-off-by: Rob Clark <robdclark@chromium.org>

> ---

>  drivers/gpu/drm/bridge/ti-sn65dsi86.c | 34 +++++++++++++++++++++++----

>  1 file changed, 29 insertions(+), 5 deletions(-)

> 

> diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c

> index 38dcc49eccaf..dc8112bab3d3 100644

> --- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c

> +++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c

> @@ -693,9 +693,11 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge,

>  		return ret;

>  	}

>  

> -	ret = ti_sn_bridge_connector_init(pdata);

> -	if (ret < 0)

> -		goto err_conn_init;

> +	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {

> +		ret = ti_sn_bridge_connector_init(pdata);

> +		if (ret < 0)

> +			goto err_conn_init;

> +	}

>  

>  	/*

>  	 * TODO: ideally finding host resource and dsi dev registration needs

> @@ -757,7 +759,8 @@ static int ti_sn_bridge_attach(struct drm_bridge *bridge,

>  err_dsi_attach:

>  	mipi_dsi_device_unregister(dsi);

>  err_dsi_host:

> -	drm_connector_cleanup(&pdata->connector);

> +	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))

> +		drm_connector_cleanup(&pdata->connector);

>  err_conn_init:

>  	drm_dp_aux_unregister(&pdata->aux);

>  	return ret;

> @@ -806,9 +809,30 @@ static void ti_sn_bridge_set_dsi_rate(struct ti_sn65dsi86 *pdata)

>  	regmap_write(pdata->regmap, SN_DSIA_CLK_FREQ_REG, val);

>  }

>  

> +/*

> + * Find the connector and fish out the bpc from display_info.  It would

> + * be nice if we could get this instead from drm_bridge_state, but that

> + * doesn't yet appear to be the case.

> + */


This should be done with

	struct drm_atomic_state *state = old_bridge_state->base.state;
	struct drm_connector *connector;

	connector = drm_atomic_get_new_connector_for_encoder(state,
							     bridge->encoder);

>  static unsigned int ti_sn_bridge_get_bpp(struct ti_sn65dsi86 *pdata)

>  {

> -	if (pdata->connector.display_info.bpc <= 6)

> +	struct drm_bridge *bridge = &pdata->bridge;

> +	struct drm_connector_list_iter conn_iter;

> +	struct drm_connector *connector;

> +	unsigned bpc = 0;

> +

> +	drm_connector_list_iter_begin(bridge->dev, &conn_iter);

> +	drm_for_each_connector_iter(connector, &conn_iter) {

> +		if (drm_connector_has_possible_encoder(connector, bridge->encoder)) {

> +			bpc = connector->display_info.bpc;

> +			break;

> +		}

> +	}

> +	drm_connector_list_iter_end(&conn_iter);

> +

> +	WARN_ON(bpc == 0);

> +

> +	if (bpc <= 6)

>  		return 18;

>  	else

>  		return 24;


-- 
Regards,

Laurent Pinchart
Doug Anderson Aug. 12, 2021, 8:08 p.m. UTC | #3
Laurent,

On Thu, Aug 12, 2021 at 12:26 PM Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>

> Hi Rob,

>

> Thank you for the patch.

>

> On Wed, Aug 11, 2021 at 04:52:50PM -0700, Rob Clark wrote:

> > From: Rob Clark <robdclark@chromium.org>

> >

> > Slightly awkward to fish out the display_info when we aren't creating

> > own connector.  But I don't see an obvious better way.

>

> We need a bit more than this, to support the NO_CONNECTOR case, the

> bridge has to implement a few extra operations, and set the bridge .ops

> field. I've submitted two patches to do so a while ago:

>

> - [RFC PATCH 08/11] drm/bridge: ti-sn65dsi86: Implement bridge connector operations ([1])


Rob asked me about this over IRC, so if he left it out and it's needed
then it's my fault. However, I don't believe it's needed until your
series making this bridge chip support full DP. For the the eDP case
the bridge chip driver in ToT no longer queries the EDID itself. It
simply provides an AUX bus to the panel driver and the panel driver
queries the EDID. I think that means we don't need to add
DRM_BRIDGE_OP_EDID, right?

I was also wondering if in the full DP case we should actually model
the physical DP jack as a drm_bridge and have it work the same way. It
would get probed via the DP AUX bus just like a panel. I seem to
remember Stephen Boyd was talking about modeling the DP connector as a
drm_bridge because it would allow us to handle the fact that some TCPC
chips could only support HBR2 whereas others could support HBR3. Maybe
it would end up being a fairly elegant solution?

> - [RFC PATCH 09/11] drm/bridge: ti-sn65dsi86: Make connector creation optional ([2])

>

> The second patch is similar to the first half of this patch, but misses

> the cleanup code. I'll try to rebase this and resubmit, but it may take

> a bit of time.


Whoops! You're right that Rob's patch won't work at all because we'll
just hit the "Fix bridge driver to make connector optional!" case. I
should have noticed that. :(

-Doug
Laurent Pinchart Sept. 23, 2021, 12:39 a.m. UTC | #4
Hi Rob and Doug,

On Mon, Sep 20, 2021 at 11:32:02AM -0700, Rob Clark wrote:
> On Thu, Aug 12, 2021 at 1:08 PM Doug Anderson wrote:

> > On Thu, Aug 12, 2021 at 12:26 PM Laurent Pinchart wrote:

> > > On Wed, Aug 11, 2021 at 04:52:50PM -0700, Rob Clark wrote:

> > > > From: Rob Clark <robdclark@chromium.org>

> > > >

> > > > Slightly awkward to fish out the display_info when we aren't creating

> > > > own connector.  But I don't see an obvious better way.

> > >

> > > We need a bit more than this, to support the NO_CONNECTOR case, the

> > > bridge has to implement a few extra operations, and set the bridge .ops

> > > field. I've submitted two patches to do so a while ago:

> > >

> > > - [RFC PATCH 08/11] drm/bridge: ti-sn65dsi86: Implement bridge connector operations ([1])

> >

> > Rob asked me about this over IRC, so if he left it out and it's needed

> > then it's my fault. However, I don't believe it's needed until your

> > series making this bridge chip support full DP. For the the eDP case

> > the bridge chip driver in ToT no longer queries the EDID itself. It

> > simply provides an AUX bus to the panel driver and the panel driver

> > queries the EDID. I think that means we don't need to add

> > DRM_BRIDGE_OP_EDID, right?


That's right.

> > I was also wondering if in the full DP case we should actually model

> > the physical DP jack as a drm_bridge and have it work the same way. It

> > would get probed via the DP AUX bus just like a panel. I seem to

> > remember Stephen Boyd was talking about modeling the DP connector as a

> > drm_bridge because it would allow us to handle the fact that some TCPC

> > chips could only support HBR2 whereas others could support HBR3. Maybe

> > it would end up being a fairly elegant solution?


Physical connectors are already handled as bridges, see
drivers/gpu/drm/bridge/display-connector.c. I however don't think it
should handle EDID retrieval, because that's really not an operation
implemented by the connector itself.

> > > - [RFC PATCH 09/11] drm/bridge: ti-sn65dsi86: Make connector creation optional ([2])

> > >

> > > The second patch is similar to the first half of this patch, but misses

> > > the cleanup code. I'll try to rebase this and resubmit, but it may take

> > > a bit of time.

> >

> > Whoops! You're right that Rob's patch won't work at all because we'll

> > just hit the "Fix bridge driver to make connector optional!" case. I

> > should have noticed that. :(

> 

> Yes, indeed.. once I fix that, I get no display..

> 

> Not sure if Laurent is still working on his series, otherwise I can

> try to figure out what bridge ops are missing


I am, but too slowly. I don't mind fast-tracking the changes you need
though.

-- 
Regards,

Laurent Pinchart
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/ti-sn65dsi86.c b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
index 38dcc49eccaf..dc8112bab3d3 100644
--- a/drivers/gpu/drm/bridge/ti-sn65dsi86.c
+++ b/drivers/gpu/drm/bridge/ti-sn65dsi86.c
@@ -693,9 +693,11 @@  static int ti_sn_bridge_attach(struct drm_bridge *bridge,
 		return ret;
 	}
 
-	ret = ti_sn_bridge_connector_init(pdata);
-	if (ret < 0)
-		goto err_conn_init;
+	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)) {
+		ret = ti_sn_bridge_connector_init(pdata);
+		if (ret < 0)
+			goto err_conn_init;
+	}
 
 	/*
 	 * TODO: ideally finding host resource and dsi dev registration needs
@@ -757,7 +759,8 @@  static int ti_sn_bridge_attach(struct drm_bridge *bridge,
 err_dsi_attach:
 	mipi_dsi_device_unregister(dsi);
 err_dsi_host:
-	drm_connector_cleanup(&pdata->connector);
+	if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
+		drm_connector_cleanup(&pdata->connector);
 err_conn_init:
 	drm_dp_aux_unregister(&pdata->aux);
 	return ret;
@@ -806,9 +809,30 @@  static void ti_sn_bridge_set_dsi_rate(struct ti_sn65dsi86 *pdata)
 	regmap_write(pdata->regmap, SN_DSIA_CLK_FREQ_REG, val);
 }
 
+/*
+ * Find the connector and fish out the bpc from display_info.  It would
+ * be nice if we could get this instead from drm_bridge_state, but that
+ * doesn't yet appear to be the case.
+ */
 static unsigned int ti_sn_bridge_get_bpp(struct ti_sn65dsi86 *pdata)
 {
-	if (pdata->connector.display_info.bpc <= 6)
+	struct drm_bridge *bridge = &pdata->bridge;
+	struct drm_connector_list_iter conn_iter;
+	struct drm_connector *connector;
+	unsigned bpc = 0;
+
+	drm_connector_list_iter_begin(bridge->dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
+		if (drm_connector_has_possible_encoder(connector, bridge->encoder)) {
+			bpc = connector->display_info.bpc;
+			break;
+		}
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	WARN_ON(bpc == 0);
+
+	if (bpc <= 6)
 		return 18;
 	else
 		return 24;