diff mbox series

[RESEND,v2] drm/bridge/tc358775: Fixes bus formats read

Message ID 1603349147-3495-1-git-send-email-simhavcs@gmail.com
State Superseded
Headers show
Series [RESEND,v2] drm/bridge/tc358775: Fixes bus formats read | expand

Commit Message

Vinay Simha BN Oct. 22, 2020, 6:45 a.m. UTC
- atomic_check removed
- video data input and output formats added
- bus formats read from drm_bridge_state.output_bus_cfg.format
  and .atomic_get_input_bus_fmts() instead of connector

Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>


---
v1:
 * Laurent Pinchart review comments incorporated
   drm_bridge_state.output_bus_cfg.format
   instead of connector
v2:
 * Laurent Pinchart review comments incorporated
   atomic_check removed
   video data input and output formats added
---
 drivers/gpu/drm/bridge/tc358775.c | 75 ++++++++++++++++++++++++++++++---------
 1 file changed, 58 insertions(+), 17 deletions(-)

-- 
2.7.4

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

Comments

Sam Ravnborg Nov. 8, 2020, 10:16 a.m. UTC | #1
Hi Laurent,

On Thu, Oct 22, 2020 at 12:15:47PM +0530, Vinay Simha BN wrote:
> - atomic_check removed

> - video data input and output formats added

> - bus formats read from drm_bridge_state.output_bus_cfg.format

>   and .atomic_get_input_bus_fmts() instead of connector

> 

> Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>


could you try to find time to review this patch?

You already provided valuable feedback and it looks fine to me.
But it would be perfect if you could find time to take a look.

Thanks in advance,

	Sam

> 

> ---

> v1:

>  * Laurent Pinchart review comments incorporated

>    drm_bridge_state.output_bus_cfg.format

>    instead of connector

> v2:

>  * Laurent Pinchart review comments incorporated

>    atomic_check removed

>    video data input and output formats added

> ---

>  drivers/gpu/drm/bridge/tc358775.c | 75 ++++++++++++++++++++++++++++++---------

>  1 file changed, 58 insertions(+), 17 deletions(-)

> 

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

> index 2272adc..cc27570 100644

> --- a/drivers/gpu/drm/bridge/tc358775.c

> +++ b/drivers/gpu/drm/bridge/tc358775.c

> @@ -271,6 +271,20 @@ struct tc_data {

>  	struct gpio_desc	*stby_gpio;

>  	u8			lvds_link; /* single-link or dual-link */

>  	u8			bpc;

> +	u32			output_bus_fmt;

> +};

> +

> +static const u32 tc_lvds_in_bus_fmts[] = {

> +	MEDIA_BUS_FMT_RGB565_1X16,

> +	MEDIA_BUS_FMT_RGB666_1X18,

> +	MEDIA_BUS_FMT_RGB666_1X24_CPADHI,

> +	MEDIA_BUS_FMT_RBG888_1X24,

> +};

> +

> +static const u32 tc_lvds_out_bus_fmts[] = {

> +	MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,

> +	MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,

> +	MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,

>  };

>  

>  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)

> @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16 addr, u32 val)

>  			ret, addr);

>  }

>  

> -/* helper function to access bus_formats */

> -static struct drm_connector *get_connector(struct drm_encoder *encoder)

> -{

> -	struct drm_device *dev = encoder->dev;

> -	struct drm_connector *connector;

> -

> -	list_for_each_entry(connector, &dev->mode_config.connector_list, head)

> -		if (connector->encoder == encoder)

> -			return connector;

> -

> -	return NULL;

> -}

> -

>  static void tc_bridge_enable(struct drm_bridge *bridge)

>  {

>  	struct tc_data *tc = bridge_to_tc(bridge);

> @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge *bridge)

>  	u32 val = 0;

>  	u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;

>  	struct drm_display_mode *mode;

> -	struct drm_connector *connector = get_connector(bridge->encoder);

> +	struct drm_bridge_state *state =

> +			drm_priv_to_bridge_state(bridge->base.state);

> +

> +	tc->output_bus_fmt = state->output_bus_cfg.format;

>  

>  	mode = &bridge->encoder->crtc->state->adjusted_mode;

>  

> @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge *bridge)

>  	d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));

>  

>  	dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",

> -		connector->display_info.bus_formats[0],

> +		tc->output_bus_fmt,

>  		tc->bpc);

>  	/*

>  	 * Default hardware register settings of tc358775 configured

>  	 * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format

>  	 */

> -	if (connector->display_info.bus_formats[0] ==

> -		MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

> +	if (tc->output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

>  		/* VESA-24 */

>  		d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, LVI_R3));

>  		d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, LVI_G0));

> @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)

>  	return 0;

>  }

>  

> +static u32 *

> +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,

> +			     struct drm_bridge_state *bridge_state,

> +			     struct drm_crtc_state *crtc_state,

> +			     struct drm_connector_state *conn_state,

> +			     u32 output_fmt,

> +			     unsigned int *num_input_fmts)

> +{

> +	u32 *input_fmts = NULL;

> +	u8 i;

> +

> +	*num_input_fmts = 0;

> +

> +	for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {

> +		if (output_fmt == tc_lvds_out_bus_fmts[i])

> +			break;

> +	}

> +

> +	if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))

> +		return NULL;

> +

> +	*num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);

> +

> +	input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),

> +			     GFP_KERNEL);

> +	if (!input_fmts)

> +		return NULL;

> +

> +	for (i = 0; i < ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)

> +		input_fmts[i] = tc_lvds_in_bus_fmts[i];

> +

> +	return input_fmts;

> +}

> +

>  static int tc_bridge_attach(struct drm_bridge *bridge,

>  			    enum drm_bridge_attach_flags flags)

>  {

> @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge,

>  }

>  

>  static const struct drm_bridge_funcs tc_bridge_funcs = {

> +	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,

> +	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,

> +	.atomic_reset = drm_atomic_helper_bridge_reset,

> +	.atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,

>  	.attach = tc_bridge_attach,

>  	.pre_enable = tc_bridge_pre_enable,

>  	.enable = tc_bridge_enable,

> -- 

> 2.7.4

> 

> _______________________________________________

> dri-devel mailing list

> dri-devel@lists.freedesktop.org

> https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Vinay Simha BN Dec. 17, 2020, 5:09 a.m. UTC | #2
Laurent,

Please review the patch, so that we can push the input_format to the
mainline, which completes the overall features handled wrt bridge.

On Sun, Nov 8, 2020 at 3:47 PM Sam Ravnborg <sam@ravnborg.org> wrote:

> Hi Laurent,

>

> On Thu, Oct 22, 2020 at 12:15:47PM +0530, Vinay Simha BN wrote:

> > - atomic_check removed

> > - video data input and output formats added

> > - bus formats read from drm_bridge_state.output_bus_cfg.format

> >   and .atomic_get_input_bus_fmts() instead of connector

> >

> > Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>

>

> could you try to find time to review this patch?

>

> You already provided valuable feedback and it looks fine to me.

> But it would be perfect if you could find time to take a look.

>

> Thanks in advance,

>

>         Sam

>

> >

> > ---

> > v1:

> >  * Laurent Pinchart review comments incorporated

> >    drm_bridge_state.output_bus_cfg.format

> >    instead of connector

> > v2:

> >  * Laurent Pinchart review comments incorporated

> >    atomic_check removed

> >    video data input and output formats added

> > ---

> >  drivers/gpu/drm/bridge/tc358775.c | 75

> ++++++++++++++++++++++++++++++---------

> >  1 file changed, 58 insertions(+), 17 deletions(-)

> >

> > diff --git a/drivers/gpu/drm/bridge/tc358775.c

> b/drivers/gpu/drm/bridge/tc358775.c

> > index 2272adc..cc27570 100644

> > --- a/drivers/gpu/drm/bridge/tc358775.c

> > +++ b/drivers/gpu/drm/bridge/tc358775.c

> > @@ -271,6 +271,20 @@ struct tc_data {

> >       struct gpio_desc        *stby_gpio;

> >       u8                      lvds_link; /* single-link or dual-link */

> >       u8                      bpc;

> > +     u32                     output_bus_fmt;

> > +};

> > +

> > +static const u32 tc_lvds_in_bus_fmts[] = {

> > +     MEDIA_BUS_FMT_RGB565_1X16,

> > +     MEDIA_BUS_FMT_RGB666_1X18,

> > +     MEDIA_BUS_FMT_RGB666_1X24_CPADHI,

> > +     MEDIA_BUS_FMT_RBG888_1X24,

> > +};

> > +

> > +static const u32 tc_lvds_out_bus_fmts[] = {

> > +     MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,

> > +     MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,

> > +     MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,

> >  };

> >

> >  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)

> > @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16

> addr, u32 val)

> >                       ret, addr);

> >  }

> >

> > -/* helper function to access bus_formats */

> > -static struct drm_connector *get_connector(struct drm_encoder *encoder)

> > -{

> > -     struct drm_device *dev = encoder->dev;

> > -     struct drm_connector *connector;

> > -

> > -     list_for_each_entry(connector, &dev->mode_config.connector_list,

> head)

> > -             if (connector->encoder == encoder)

> > -                     return connector;

> > -

> > -     return NULL;

> > -}

> > -

> >  static void tc_bridge_enable(struct drm_bridge *bridge)

> >  {

> >       struct tc_data *tc = bridge_to_tc(bridge);

> > @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge

> *bridge)

> >       u32 val = 0;

> >       u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;

> >       struct drm_display_mode *mode;

> > -     struct drm_connector *connector = get_connector(bridge->encoder);

> > +     struct drm_bridge_state *state =

> > +                     drm_priv_to_bridge_state(bridge->base.state);

> > +

> > +     tc->output_bus_fmt = state->output_bus_cfg.format;

> >

> >       mode = &bridge->encoder->crtc->state->adjusted_mode;

> >

> > @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge

> *bridge)

> >       d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));

> >

> >       dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",

> > -             connector->display_info.bus_formats[0],

> > +             tc->output_bus_fmt,

> >               tc->bpc);

> >       /*

> >        * Default hardware register settings of tc358775 configured

> >        * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format

> >        */

> > -     if (connector->display_info.bus_formats[0] ==

> > -             MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

> > +     if (tc->output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

> >               /* VESA-24 */

> >               d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1,

> LVI_R2, LVI_R3));

> >               d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7,

> LVI_R5, LVI_G0));

> > @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node

> *np, struct tc_data *tc)

> >       return 0;

> >  }

> >

> > +static u32 *

> > +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,

> > +                          struct drm_bridge_state *bridge_state,

> > +                          struct drm_crtc_state *crtc_state,

> > +                          struct drm_connector_state *conn_state,

> > +                          u32 output_fmt,

> > +                          unsigned int *num_input_fmts)

> > +{

> > +     u32 *input_fmts = NULL;

> > +     u8 i;

> > +

> > +     *num_input_fmts = 0;

> > +

> > +     for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {

> > +             if (output_fmt == tc_lvds_out_bus_fmts[i])

> > +                     break;

> > +     }

> > +

> > +     if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))

> > +             return NULL;

> > +

> > +     *num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);

> > +

> > +     input_fmts = kcalloc(*num_input_fmts,

> ARRAY_SIZE(tc_lvds_in_bus_fmts),

> > +                          GFP_KERNEL);

> > +     if (!input_fmts)

> > +             return NULL;

> > +

> > +     for (i = 0; i < ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)

> > +             input_fmts[i] = tc_lvds_in_bus_fmts[i];

> > +

> > +     return input_fmts;

> > +}

> > +

> >  static int tc_bridge_attach(struct drm_bridge *bridge,

> >                           enum drm_bridge_attach_flags flags)

> >  {

> > @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge

> *bridge,

> >  }

> >

> >  static const struct drm_bridge_funcs tc_bridge_funcs = {

> > +     .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,

> > +     .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,

> > +     .atomic_reset = drm_atomic_helper_bridge_reset,

> > +     .atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,

> >       .attach = tc_bridge_attach,

> >       .pre_enable = tc_bridge_pre_enable,

> >       .enable = tc_bridge_enable,

> > --

> > 2.7.4

> >

> > _______________________________________________

> > dri-devel mailing list

> > dri-devel@lists.freedesktop.org

> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

>



-- 
regards,
vinaysimha
<div dir="ltr"><div>Laurent,</div><div><br></div><div>Please review the patch, so that we can push the input_format to the mainline, which completes the overall features handled wrt bridge.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 8, 2020 at 3:47 PM Sam Ravnborg &lt;<a href="mailto:sam@ravnborg.org">sam@ravnborg.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Laurent,<br>
<br>
On Thu, Oct 22, 2020 at 12:15:47PM +0530, Vinay Simha BN wrote:<br>
&gt; - atomic_check removed<br>
&gt; - video data input and output formats added<br>
&gt; - bus formats read from drm_bridge_state.output_bus_cfg.format<br>
&gt;   and .atomic_get_input_bus_fmts() instead of connector<br>
&gt; <br>
&gt; Signed-off-by: Vinay Simha BN &lt;<a href="mailto:simhavcs@gmail.com" target="_blank">simhavcs@gmail.com</a>&gt;<br>
<br>
could you try to find time to review this patch?<br>
<br>
You already provided valuable feedback and it looks fine to me.<br>
But it would be perfect if you could find time to take a look.<br>
<br>
Thanks in advance,<br>
<br>
        Sam<br>
<br>
&gt; <br>
&gt; ---<br>
&gt; v1:<br>
&gt;  * Laurent Pinchart review comments incorporated<br>
&gt;    drm_bridge_state.output_bus_cfg.format<br>
&gt;    instead of connector<br>
&gt; v2:<br>
&gt;  * Laurent Pinchart review comments incorporated<br>
&gt;    atomic_check removed<br>
&gt;    video data input and output formats added<br>
&gt; ---<br>
&gt;  drivers/gpu/drm/bridge/tc358775.c | 75 ++++++++++++++++++++++++++++++---------<br>
&gt;  1 file changed, 58 insertions(+), 17 deletions(-)<br>
&gt; <br>
&gt; diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c<br>
&gt; index 2272adc..cc27570 100644<br>
&gt; --- a/drivers/gpu/drm/bridge/tc358775.c<br>
&gt; +++ b/drivers/gpu/drm/bridge/tc358775.c<br>
&gt; @@ -271,6 +271,20 @@ struct tc_data {<br>
&gt;       struct gpio_desc        *stby_gpio;<br>
&gt;       u8                      lvds_link; /* single-link or dual-link */<br>
&gt;       u8                      bpc;<br>
&gt; +     u32                     output_bus_fmt;<br>
&gt; +};<br>
&gt; +<br>
&gt; +static const u32 tc_lvds_in_bus_fmts[] = {<br>
&gt; +     MEDIA_BUS_FMT_RGB565_1X16,<br>
&gt; +     MEDIA_BUS_FMT_RGB666_1X18,<br>
&gt; +     MEDIA_BUS_FMT_RGB666_1X24_CPADHI,<br>
&gt; +     MEDIA_BUS_FMT_RBG888_1X24,<br>
&gt; +};<br>
&gt; +<br>
&gt; +static const u32 tc_lvds_out_bus_fmts[] = {<br>
&gt; +     MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,<br>
&gt; +     MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,<br>
&gt; +     MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,<br>
&gt;  };<br>
&gt;  <br>
&gt;  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)<br>
&gt; @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16 addr, u32 val)<br>
&gt;                       ret, addr);<br>
&gt;  }<br>
&gt;  <br>
&gt; -/* helper function to access bus_formats */<br>
&gt; -static struct drm_connector *get_connector(struct drm_encoder *encoder)<br>
&gt; -{<br>
&gt; -     struct drm_device *dev = encoder-&gt;dev;<br>
&gt; -     struct drm_connector *connector;<br>
&gt; -<br>
&gt; -     list_for_each_entry(connector, &amp;dev-&gt;mode_config.connector_list, head)<br>
&gt; -             if (connector-&gt;encoder == encoder)<br>
&gt; -                     return connector;<br>
&gt; -<br>
&gt; -     return NULL;<br>
&gt; -}<br>
&gt; -<br>
&gt;  static void tc_bridge_enable(struct drm_bridge *bridge)<br>
&gt;  {<br>
&gt;       struct tc_data *tc = bridge_to_tc(bridge);<br>
&gt; @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge *bridge)<br>
&gt;       u32 val = 0;<br>
&gt;       u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;<br>
&gt;       struct drm_display_mode *mode;<br>
&gt; -     struct drm_connector *connector = get_connector(bridge-&gt;encoder);<br>
&gt; +     struct drm_bridge_state *state =<br>
&gt; +                     drm_priv_to_bridge_state(bridge-&gt;base.state);<br>
&gt; +<br>
&gt; +     tc-&gt;output_bus_fmt = state-&gt;output_bus_cfg.format;<br>
&gt;  <br>
&gt;       mode = &amp;bridge-&gt;encoder-&gt;crtc-&gt;state-&gt;adjusted_mode;<br>
&gt;  <br>
&gt; @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge *bridge)<br>
&gt;       d2l_write(tc-&gt;i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));<br>
&gt;  <br>
&gt;       dev_dbg(tc-&gt;dev, &quot;bus_formats %04x bpc %d\n&quot;,<br>
&gt; -             connector-&gt;display_info.bus_formats[0],<br>
&gt; +             tc-&gt;output_bus_fmt,<br>
&gt;               tc-&gt;bpc);<br>
&gt;       /*<br>
&gt;        * Default hardware register settings of tc358775 configured<br>
&gt;        * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format<br>
&gt;        */<br>
&gt; -     if (connector-&gt;display_info.bus_formats[0] ==<br>
&gt; -             MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {<br>
&gt; +     if (tc-&gt;output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {<br>
&gt;               /* VESA-24 */<br>
&gt;               d2l_write(tc-&gt;i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, LVI_R3));<br>
&gt;               d2l_write(tc-&gt;i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, LVI_G0));<br>
&gt; @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)<br>
&gt;       return 0;<br>
&gt;  }<br>
&gt;  <br>
&gt; +static u32 *<br>
&gt; +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,<br>
&gt; +                          struct drm_bridge_state *bridge_state,<br>
&gt; +                          struct drm_crtc_state *crtc_state,<br>
&gt; +                          struct drm_connector_state *conn_state,<br>
&gt; +                          u32 output_fmt,<br>
&gt; +                          unsigned int *num_input_fmts)<br>
&gt; +{<br>
&gt; +     u32 *input_fmts = NULL;<br>
&gt; +     u8 i;<br>
&gt; +<br>
&gt; +     *num_input_fmts = 0;<br>
&gt; +<br>
&gt; +     for (i = 0 ; i &lt; ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {<br>
&gt; +             if (output_fmt == tc_lvds_out_bus_fmts[i])<br>
&gt; +                     break;<br>
&gt; +     }<br>
&gt; +<br>
&gt; +     if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))<br>
&gt; +             return NULL;<br>
&gt; +<br>
&gt; +     *num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);<br>
&gt; +<br>
&gt; +     input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),<br>
&gt; +                          GFP_KERNEL);<br>
&gt; +     if (!input_fmts)<br>
&gt; +             return NULL;<br>
&gt; +<br>
&gt; +     for (i = 0; i &lt; ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)<br>
&gt; +             input_fmts[i] = tc_lvds_in_bus_fmts[i];<br>
&gt; +<br>
&gt; +     return input_fmts;<br>
&gt; +}<br>
&gt; +<br>
&gt;  static int tc_bridge_attach(struct drm_bridge *bridge,<br>
&gt;                           enum drm_bridge_attach_flags flags)<br>
&gt;  {<br>
&gt; @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge,<br>
&gt;  }<br>
&gt;  <br>
&gt;  static const struct drm_bridge_funcs tc_bridge_funcs = {<br>
&gt; +     .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,<br>
&gt; +     .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,<br>
&gt; +     .atomic_reset = drm_atomic_helper_bridge_reset,<br>
&gt; +     .atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,<br>
&gt;       .attach = tc_bridge_attach,<br>
&gt;       .pre_enable = tc_bridge_pre_enable,<br>
&gt;       .enable = tc_bridge_enable,<br>
&gt; -- <br>
&gt; 2.7.4<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; dri-devel mailing list<br>
&gt; <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
&gt; <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">regards,<br>vinaysimha</div>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Vinay Simha BN Jan. 5, 2021, 4:55 a.m. UTC | #3
Laurent,

Please review the patch, so that we can push the input_format to the
mainline, which completes the overall features handled wrt bridge.

On Thu, Dec 17, 2020 at 10:39 AM Vinay Simha B N <simhavcs@gmail.com> wrote:

> Laurent,

>

> Please review the patch, so that we can push the input_format to the

> mainline, which completes the overall features handled wrt bridge.

>

> On Sun, Nov 8, 2020 at 3:47 PM Sam Ravnborg <sam@ravnborg.org> wrote:

>

>> Hi Laurent,

>>

>> On Thu, Oct 22, 2020 at 12:15:47PM +0530, Vinay Simha BN wrote:

>> > - atomic_check removed

>> > - video data input and output formats added

>> > - bus formats read from drm_bridge_state.output_bus_cfg.format

>> >   and .atomic_get_input_bus_fmts() instead of connector

>> >

>> > Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>

>>

>> could you try to find time to review this patch?

>>

>> You already provided valuable feedback and it looks fine to me.

>> But it would be perfect if you could find time to take a look.

>>

>> Thanks in advance,

>>

>>         Sam

>>

>> >

>> > ---

>> > v1:

>> >  * Laurent Pinchart review comments incorporated

>> >    drm_bridge_state.output_bus_cfg.format

>> >    instead of connector

>> > v2:

>> >  * Laurent Pinchart review comments incorporated

>> >    atomic_check removed

>> >    video data input and output formats added

>> > ---

>> >  drivers/gpu/drm/bridge/tc358775.c | 75

>> ++++++++++++++++++++++++++++++---------

>> >  1 file changed, 58 insertions(+), 17 deletions(-)

>> >

>> > diff --git a/drivers/gpu/drm/bridge/tc358775.c

>> b/drivers/gpu/drm/bridge/tc358775.c

>> > index 2272adc..cc27570 100644

>> > --- a/drivers/gpu/drm/bridge/tc358775.c

>> > +++ b/drivers/gpu/drm/bridge/tc358775.c

>> > @@ -271,6 +271,20 @@ struct tc_data {

>> >       struct gpio_desc        *stby_gpio;

>> >       u8                      lvds_link; /* single-link or dual-link */

>> >       u8                      bpc;

>> > +     u32                     output_bus_fmt;

>> > +};

>> > +

>> > +static const u32 tc_lvds_in_bus_fmts[] = {

>> > +     MEDIA_BUS_FMT_RGB565_1X16,

>> > +     MEDIA_BUS_FMT_RGB666_1X18,

>> > +     MEDIA_BUS_FMT_RGB666_1X24_CPADHI,

>> > +     MEDIA_BUS_FMT_RBG888_1X24,

>> > +};

>> > +

>> > +static const u32 tc_lvds_out_bus_fmts[] = {

>> > +     MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,

>> > +     MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,

>> > +     MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,

>> >  };

>> >

>> >  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)

>> > @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16

>> addr, u32 val)

>> >                       ret, addr);

>> >  }

>> >

>> > -/* helper function to access bus_formats */

>> > -static struct drm_connector *get_connector(struct drm_encoder *encoder)

>> > -{

>> > -     struct drm_device *dev = encoder->dev;

>> > -     struct drm_connector *connector;

>> > -

>> > -     list_for_each_entry(connector, &dev->mode_config.connector_list,

>> head)

>> > -             if (connector->encoder == encoder)

>> > -                     return connector;

>> > -

>> > -     return NULL;

>> > -}

>> > -

>> >  static void tc_bridge_enable(struct drm_bridge *bridge)

>> >  {

>> >       struct tc_data *tc = bridge_to_tc(bridge);

>> > @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge

>> *bridge)

>> >       u32 val = 0;

>> >       u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;

>> >       struct drm_display_mode *mode;

>> > -     struct drm_connector *connector = get_connector(bridge->encoder);

>> > +     struct drm_bridge_state *state =

>> > +                     drm_priv_to_bridge_state(bridge->base.state);

>> > +

>> > +     tc->output_bus_fmt = state->output_bus_cfg.format;

>> >

>> >       mode = &bridge->encoder->crtc->state->adjusted_mode;

>> >

>> > @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge

>> *bridge)

>> >       d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));

>> >

>> >       dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",

>> > -             connector->display_info.bus_formats[0],

>> > +             tc->output_bus_fmt,

>> >               tc->bpc);

>> >       /*

>> >        * Default hardware register settings of tc358775 configured

>> >        * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format

>> >        */

>> > -     if (connector->display_info.bus_formats[0] ==

>> > -             MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

>> > +     if (tc->output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

>> >               /* VESA-24 */

>> >               d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1,

>> LVI_R2, LVI_R3));

>> >               d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7,

>> LVI_R5, LVI_G0));

>> > @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node

>> *np, struct tc_data *tc)

>> >       return 0;

>> >  }

>> >

>> > +static u32 *

>> > +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,

>> > +                          struct drm_bridge_state *bridge_state,

>> > +                          struct drm_crtc_state *crtc_state,

>> > +                          struct drm_connector_state *conn_state,

>> > +                          u32 output_fmt,

>> > +                          unsigned int *num_input_fmts)

>> > +{

>> > +     u32 *input_fmts = NULL;

>> > +     u8 i;

>> > +

>> > +     *num_input_fmts = 0;

>> > +

>> > +     for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {

>> > +             if (output_fmt == tc_lvds_out_bus_fmts[i])

>> > +                     break;

>> > +     }

>> > +

>> > +     if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))

>> > +             return NULL;

>> > +

>> > +     *num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);

>> > +

>> > +     input_fmts = kcalloc(*num_input_fmts,

>> ARRAY_SIZE(tc_lvds_in_bus_fmts),

>> > +                          GFP_KERNEL);

>> > +     if (!input_fmts)

>> > +             return NULL;

>> > +

>> > +     for (i = 0; i < ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)

>> > +             input_fmts[i] = tc_lvds_in_bus_fmts[i];

>> > +

>> > +     return input_fmts;

>> > +}

>> > +

>> >  static int tc_bridge_attach(struct drm_bridge *bridge,

>> >                           enum drm_bridge_attach_flags flags)

>> >  {

>> > @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge

>> *bridge,

>> >  }

>> >

>> >  static const struct drm_bridge_funcs tc_bridge_funcs = {

>> > +     .atomic_duplicate_state =

>> drm_atomic_helper_bridge_duplicate_state,

>> > +     .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,

>> > +     .atomic_reset = drm_atomic_helper_bridge_reset,

>> > +     .atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,

>> >       .attach = tc_bridge_attach,

>> >       .pre_enable = tc_bridge_pre_enable,

>> >       .enable = tc_bridge_enable,

>> > --

>> > 2.7.4

>> >

>> > _______________________________________________

>> > dri-devel mailing list

>> > dri-devel@lists.freedesktop.org

>> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

>>

>

>

> --

> regards,

> vinaysimha

>



-- 
regards,
vinaysimha
<div dir="ltr"><div>Laurent,</div><div><br></div><div>Please review the patch, so that 
we can push the input_format to the mainline, which completes the 
overall features handled wrt bridge.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 17, 2020 at 10:39 AM Vinay Simha B N &lt;<a href="mailto:simhavcs@gmail.com">simhavcs@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Laurent,</div><div><br></div><div>Please review the patch, so that we can push the input_format to the mainline, which completes the overall features handled wrt bridge.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Nov 8, 2020 at 3:47 PM Sam Ravnborg &lt;<a href="mailto:sam@ravnborg.org" target="_blank">sam@ravnborg.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Laurent,<br>
<br>
On Thu, Oct 22, 2020 at 12:15:47PM +0530, Vinay Simha BN wrote:<br>
&gt; - atomic_check removed<br>
&gt; - video data input and output formats added<br>
&gt; - bus formats read from drm_bridge_state.output_bus_cfg.format<br>
&gt;   and .atomic_get_input_bus_fmts() instead of connector<br>
&gt; <br>
&gt; Signed-off-by: Vinay Simha BN &lt;<a href="mailto:simhavcs@gmail.com" target="_blank">simhavcs@gmail.com</a>&gt;<br>
<br>
could you try to find time to review this patch?<br>
<br>
You already provided valuable feedback and it looks fine to me.<br>
But it would be perfect if you could find time to take a look.<br>
<br>
Thanks in advance,<br>
<br>
        Sam<br>
<br>
&gt; <br>
&gt; ---<br>
&gt; v1:<br>
&gt;  * Laurent Pinchart review comments incorporated<br>
&gt;    drm_bridge_state.output_bus_cfg.format<br>
&gt;    instead of connector<br>
&gt; v2:<br>
&gt;  * Laurent Pinchart review comments incorporated<br>
&gt;    atomic_check removed<br>
&gt;    video data input and output formats added<br>
&gt; ---<br>
&gt;  drivers/gpu/drm/bridge/tc358775.c | 75 ++++++++++++++++++++++++++++++---------<br>
&gt;  1 file changed, 58 insertions(+), 17 deletions(-)<br>
&gt; <br>
&gt; diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c<br>
&gt; index 2272adc..cc27570 100644<br>
&gt; --- a/drivers/gpu/drm/bridge/tc358775.c<br>
&gt; +++ b/drivers/gpu/drm/bridge/tc358775.c<br>
&gt; @@ -271,6 +271,20 @@ struct tc_data {<br>
&gt;       struct gpio_desc        *stby_gpio;<br>
&gt;       u8                      lvds_link; /* single-link or dual-link */<br>
&gt;       u8                      bpc;<br>
&gt; +     u32                     output_bus_fmt;<br>
&gt; +};<br>
&gt; +<br>
&gt; +static const u32 tc_lvds_in_bus_fmts[] = {<br>
&gt; +     MEDIA_BUS_FMT_RGB565_1X16,<br>
&gt; +     MEDIA_BUS_FMT_RGB666_1X18,<br>
&gt; +     MEDIA_BUS_FMT_RGB666_1X24_CPADHI,<br>
&gt; +     MEDIA_BUS_FMT_RBG888_1X24,<br>
&gt; +};<br>
&gt; +<br>
&gt; +static const u32 tc_lvds_out_bus_fmts[] = {<br>
&gt; +     MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,<br>
&gt; +     MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,<br>
&gt; +     MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,<br>
&gt;  };<br>
&gt;  <br>
&gt;  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)<br>
&gt; @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16 addr, u32 val)<br>
&gt;                       ret, addr);<br>
&gt;  }<br>
&gt;  <br>
&gt; -/* helper function to access bus_formats */<br>
&gt; -static struct drm_connector *get_connector(struct drm_encoder *encoder)<br>
&gt; -{<br>
&gt; -     struct drm_device *dev = encoder-&gt;dev;<br>
&gt; -     struct drm_connector *connector;<br>
&gt; -<br>
&gt; -     list_for_each_entry(connector, &amp;dev-&gt;mode_config.connector_list, head)<br>
&gt; -             if (connector-&gt;encoder == encoder)<br>
&gt; -                     return connector;<br>
&gt; -<br>
&gt; -     return NULL;<br>
&gt; -}<br>
&gt; -<br>
&gt;  static void tc_bridge_enable(struct drm_bridge *bridge)<br>
&gt;  {<br>
&gt;       struct tc_data *tc = bridge_to_tc(bridge);<br>
&gt; @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge *bridge)<br>
&gt;       u32 val = 0;<br>
&gt;       u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;<br>
&gt;       struct drm_display_mode *mode;<br>
&gt; -     struct drm_connector *connector = get_connector(bridge-&gt;encoder);<br>
&gt; +     struct drm_bridge_state *state =<br>
&gt; +                     drm_priv_to_bridge_state(bridge-&gt;base.state);<br>
&gt; +<br>
&gt; +     tc-&gt;output_bus_fmt = state-&gt;output_bus_cfg.format;<br>
&gt;  <br>
&gt;       mode = &amp;bridge-&gt;encoder-&gt;crtc-&gt;state-&gt;adjusted_mode;<br>
&gt;  <br>
&gt; @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge *bridge)<br>
&gt;       d2l_write(tc-&gt;i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));<br>
&gt;  <br>
&gt;       dev_dbg(tc-&gt;dev, &quot;bus_formats %04x bpc %d\n&quot;,<br>
&gt; -             connector-&gt;display_info.bus_formats[0],<br>
&gt; +             tc-&gt;output_bus_fmt,<br>
&gt;               tc-&gt;bpc);<br>
&gt;       /*<br>
&gt;        * Default hardware register settings of tc358775 configured<br>
&gt;        * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format<br>
&gt;        */<br>
&gt; -     if (connector-&gt;display_info.bus_formats[0] ==<br>
&gt; -             MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {<br>
&gt; +     if (tc-&gt;output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {<br>
&gt;               /* VESA-24 */<br>
&gt;               d2l_write(tc-&gt;i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, LVI_R3));<br>
&gt;               d2l_write(tc-&gt;i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, LVI_G0));<br>
&gt; @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)<br>
&gt;       return 0;<br>
&gt;  }<br>
&gt;  <br>
&gt; +static u32 *<br>
&gt; +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,<br>
&gt; +                          struct drm_bridge_state *bridge_state,<br>
&gt; +                          struct drm_crtc_state *crtc_state,<br>
&gt; +                          struct drm_connector_state *conn_state,<br>
&gt; +                          u32 output_fmt,<br>
&gt; +                          unsigned int *num_input_fmts)<br>
&gt; +{<br>
&gt; +     u32 *input_fmts = NULL;<br>
&gt; +     u8 i;<br>
&gt; +<br>
&gt; +     *num_input_fmts = 0;<br>
&gt; +<br>
&gt; +     for (i = 0 ; i &lt; ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {<br>
&gt; +             if (output_fmt == tc_lvds_out_bus_fmts[i])<br>
&gt; +                     break;<br>
&gt; +     }<br>
&gt; +<br>
&gt; +     if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))<br>
&gt; +             return NULL;<br>
&gt; +<br>
&gt; +     *num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);<br>
&gt; +<br>
&gt; +     input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),<br>
&gt; +                          GFP_KERNEL);<br>
&gt; +     if (!input_fmts)<br>
&gt; +             return NULL;<br>
&gt; +<br>
&gt; +     for (i = 0; i &lt; ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)<br>
&gt; +             input_fmts[i] = tc_lvds_in_bus_fmts[i];<br>
&gt; +<br>
&gt; +     return input_fmts;<br>
&gt; +}<br>
&gt; +<br>
&gt;  static int tc_bridge_attach(struct drm_bridge *bridge,<br>
&gt;                           enum drm_bridge_attach_flags flags)<br>
&gt;  {<br>
&gt; @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge,<br>
&gt;  }<br>
&gt;  <br>
&gt;  static const struct drm_bridge_funcs tc_bridge_funcs = {<br>
&gt; +     .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,<br>
&gt; +     .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,<br>
&gt; +     .atomic_reset = drm_atomic_helper_bridge_reset,<br>
&gt; +     .atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,<br>
&gt;       .attach = tc_bridge_attach,<br>
&gt;       .pre_enable = tc_bridge_pre_enable,<br>
&gt;       .enable = tc_bridge_enable,<br>
&gt; -- <br>
&gt; 2.7.4<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; dri-devel mailing list<br>
&gt; <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
&gt; <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr">regards,<br>vinaysimha</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">regards,<br>vinaysimha</div>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Laurent Pinchart Jan. 14, 2021, 6:23 a.m. UTC | #4
Hi Vinay,

Thank you for the patch.

I'm afraid I've had close to no time for DRM bridge maintenance over the
past few months, and I don't expect the situation to improve soon.  I
know how painful it can be to keep pinging without receiving any reply.
I'm sorry about that, we have a shortage of maintainers for this part of
the subsystem and it seems difficult to recruit.

On Thu, Oct 22, 2020 at 12:15:47PM +0530, Vinay Simha BN wrote:
> - atomic_check removed

> - video data input and output formats added

> - bus formats read from drm_bridge_state.output_bus_cfg.format

>   and .atomic_get_input_bus_fmts() instead of connector

> 

> Signed-off-by: Vinay Simha BN <simhavcs@gmail.com>

> 

> ---

> v1:

>  * Laurent Pinchart review comments incorporated

>    drm_bridge_state.output_bus_cfg.format

>    instead of connector

> v2:

>  * Laurent Pinchart review comments incorporated

>    atomic_check removed

>    video data input and output formats added

> ---

>  drivers/gpu/drm/bridge/tc358775.c | 75 ++++++++++++++++++++++++++++++---------

>  1 file changed, 58 insertions(+), 17 deletions(-)

> 

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

> index 2272adc..cc27570 100644

> --- a/drivers/gpu/drm/bridge/tc358775.c

> +++ b/drivers/gpu/drm/bridge/tc358775.c

> @@ -271,6 +271,20 @@ struct tc_data {

>  	struct gpio_desc	*stby_gpio;

>  	u8			lvds_link; /* single-link or dual-link */

>  	u8			bpc;

> +	u32			output_bus_fmt;

> +};

> +

> +static const u32 tc_lvds_in_bus_fmts[] = {

> +	MEDIA_BUS_FMT_RGB565_1X16,

> +	MEDIA_BUS_FMT_RGB666_1X18,

> +	MEDIA_BUS_FMT_RGB666_1X24_CPADHI,

> +	MEDIA_BUS_FMT_RBG888_1X24,

> +};

> +

> +static const u32 tc_lvds_out_bus_fmts[] = {

> +	MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,

> +	MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,

> +	MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,

>  };

>  

>  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)

> @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16 addr, u32 val)

>  			ret, addr);

>  }

>  

> -/* helper function to access bus_formats */

> -static struct drm_connector *get_connector(struct drm_encoder *encoder)

> -{

> -	struct drm_device *dev = encoder->dev;

> -	struct drm_connector *connector;

> -

> -	list_for_each_entry(connector, &dev->mode_config.connector_list, head)

> -		if (connector->encoder == encoder)

> -			return connector;

> -

> -	return NULL;

> -}

> -

>  static void tc_bridge_enable(struct drm_bridge *bridge)

>  {

>  	struct tc_data *tc = bridge_to_tc(bridge);

> @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge *bridge)

>  	u32 val = 0;

>  	u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;

>  	struct drm_display_mode *mode;

> -	struct drm_connector *connector = get_connector(bridge->encoder);

> +	struct drm_bridge_state *state =

> +			drm_priv_to_bridge_state(bridge->base.state);

> +

> +	tc->output_bus_fmt = state->output_bus_cfg.format;

>  

>  	mode = &bridge->encoder->crtc->state->adjusted_mode;

>  

> @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge *bridge)

>  	d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));

>  

>  	dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",

> -		connector->display_info.bus_formats[0],

> +		tc->output_bus_fmt,

>  		tc->bpc);

>  	/*

>  	 * Default hardware register settings of tc358775 configured

>  	 * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format

>  	 */

> -	if (connector->display_info.bus_formats[0] ==

> -		MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {

> +	if (tc->output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {


As output_bus_fmt is only used in this function, I would make this a
local variable and drop the output_bus_fmt field from tc_data. You could
even use state->output_bus_cfg.format directly in the two locations
where the value is needed without a local variable, up to you.

>  		/* VESA-24 */

>  		d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, LVI_R3));

>  		d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, LVI_G0));

> @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)

>  	return 0;

>  }

>  

> +static u32 *

> +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,

> +			     struct drm_bridge_state *bridge_state,

> +			     struct drm_crtc_state *crtc_state,

> +			     struct drm_connector_state *conn_state,

> +			     u32 output_fmt,

> +			     unsigned int *num_input_fmts)

> +{

> +	u32 *input_fmts = NULL;

> +	u8 i;


You can make this an unsigned int, a u8 won't save space of CPU time.

> +

> +	*num_input_fmts = 0;

> +

> +	for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {

> +		if (output_fmt == tc_lvds_out_bus_fmts[i])

> +			break;

> +	}

> +

> +	if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))

> +		return NULL;

> +

> +	*num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);

> +

> +	input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),

> +			     GFP_KERNEL);

> +	if (!input_fmts)

> +		return NULL;

> +

> +	for (i = 0; i < ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)

> +		input_fmts[i] = tc_lvds_in_bus_fmts[i];


This could be written

	memcpy(input_fmts, tc_lvds_in_bus_fmts, sizeof(input_fmts));

With those small changes,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


> +

> +	return input_fmts;

> +}

> +

>  static int tc_bridge_attach(struct drm_bridge *bridge,

>  			    enum drm_bridge_attach_flags flags)

>  {

> @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge,

>  }

>  

>  static const struct drm_bridge_funcs tc_bridge_funcs = {

> +	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,

> +	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,

> +	.atomic_reset = drm_atomic_helper_bridge_reset,

> +	.atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,

>  	.attach = tc_bridge_attach,

>  	.pre_enable = tc_bridge_pre_enable,

>  	.enable = tc_bridge_enable,


-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox series

Patch

diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c
index 2272adc..cc27570 100644
--- a/drivers/gpu/drm/bridge/tc358775.c
+++ b/drivers/gpu/drm/bridge/tc358775.c
@@ -271,6 +271,20 @@  struct tc_data {
 	struct gpio_desc	*stby_gpio;
 	u8			lvds_link; /* single-link or dual-link */
 	u8			bpc;
+	u32			output_bus_fmt;
+};
+
+static const u32 tc_lvds_in_bus_fmts[] = {
+	MEDIA_BUS_FMT_RGB565_1X16,
+	MEDIA_BUS_FMT_RGB666_1X18,
+	MEDIA_BUS_FMT_RGB666_1X24_CPADHI,
+	MEDIA_BUS_FMT_RBG888_1X24,
+};
+
+static const u32 tc_lvds_out_bus_fmts[] = {
+	MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,
+	MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,
+	MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,
 };
 
 static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)
@@ -359,19 +373,6 @@  static void d2l_write(struct i2c_client *i2c, u16 addr, u32 val)
 			ret, addr);
 }
 
-/* helper function to access bus_formats */
-static struct drm_connector *get_connector(struct drm_encoder *encoder)
-{
-	struct drm_device *dev = encoder->dev;
-	struct drm_connector *connector;
-
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
-		if (connector->encoder == encoder)
-			return connector;
-
-	return NULL;
-}
-
 static void tc_bridge_enable(struct drm_bridge *bridge)
 {
 	struct tc_data *tc = bridge_to_tc(bridge);
@@ -380,7 +381,10 @@  static void tc_bridge_enable(struct drm_bridge *bridge)
 	u32 val = 0;
 	u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;
 	struct drm_display_mode *mode;
-	struct drm_connector *connector = get_connector(bridge->encoder);
+	struct drm_bridge_state *state =
+			drm_priv_to_bridge_state(bridge->base.state);
+
+	tc->output_bus_fmt = state->output_bus_cfg.format;
 
 	mode = &bridge->encoder->crtc->state->adjusted_mode;
 
@@ -451,14 +455,13 @@  static void tc_bridge_enable(struct drm_bridge *bridge)
 	d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));
 
 	dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",
-		connector->display_info.bus_formats[0],
+		tc->output_bus_fmt,
 		tc->bpc);
 	/*
 	 * Default hardware register settings of tc358775 configured
 	 * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format
 	 */
-	if (connector->display_info.bus_formats[0] ==
-		MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {
+	if (tc->output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {
 		/* VESA-24 */
 		d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, LVI_R3));
 		d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, LVI_G0));
@@ -590,6 +593,40 @@  static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)
 	return 0;
 }
 
+static u32 *
+tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,
+			     struct drm_bridge_state *bridge_state,
+			     struct drm_crtc_state *crtc_state,
+			     struct drm_connector_state *conn_state,
+			     u32 output_fmt,
+			     unsigned int *num_input_fmts)
+{
+	u32 *input_fmts = NULL;
+	u8 i;
+
+	*num_input_fmts = 0;
+
+	for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {
+		if (output_fmt == tc_lvds_out_bus_fmts[i])
+			break;
+	}
+
+	if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))
+		return NULL;
+
+	*num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);
+
+	input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),
+			     GFP_KERNEL);
+	if (!input_fmts)
+		return NULL;
+
+	for (i = 0; i < ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)
+		input_fmts[i] = tc_lvds_in_bus_fmts[i];
+
+	return input_fmts;
+}
+
 static int tc_bridge_attach(struct drm_bridge *bridge,
 			    enum drm_bridge_attach_flags flags)
 {
@@ -639,6 +676,10 @@  static int tc_bridge_attach(struct drm_bridge *bridge,
 }
 
 static const struct drm_bridge_funcs tc_bridge_funcs = {
+	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+	.atomic_reset = drm_atomic_helper_bridge_reset,
+	.atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,
 	.attach = tc_bridge_attach,
 	.pre_enable = tc_bridge_pre_enable,
 	.enable = tc_bridge_enable,