<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 <<a href="mailto:simhavcs@gmail.com">simhavcs@gmail.com</a>> 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 <<a href="mailto:sam@ravnborg.org" target="_blank">sam@ravnborg.org</a>> 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>
> - atomic_check removed<br>
> - video data input and output formats added<br>
> - bus formats read from drm_bridge_state.output_bus_cfg.format<br>
>   and .atomic_get_input_bus_fmts() instead of connector<br>
> <br>
> Signed-off-by: Vinay Simha BN <<a href="mailto:simhavcs@gmail.com" target="_blank">simhavcs@gmail.com</a>><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>
> <br>
> ---<br>
> v1:<br>
>  * Laurent Pinchart review comments incorporated<br>
>    drm_bridge_state.output_bus_cfg.format<br>
>    instead of connector<br>
> v2:<br>
>  * Laurent Pinchart review comments incorporated<br>
>    atomic_check removed<br>
>    video data input and output formats added<br>
> ---<br>
>  drivers/gpu/drm/bridge/tc358775.c | 75 ++++++++++++++++++++++++++++++---------<br>
>  1 file changed, 58 insertions(+), 17 deletions(-)<br>
> <br>
> diff --git a/drivers/gpu/drm/bridge/tc358775.c b/drivers/gpu/drm/bridge/tc358775.c<br>
> index 2272adc..cc27570 100644<br>
> --- a/drivers/gpu/drm/bridge/tc358775.c<br>
> +++ b/drivers/gpu/drm/bridge/tc358775.c<br>
> @@ -271,6 +271,20 @@ struct tc_data {<br>
>       struct gpio_desc        *stby_gpio;<br>
>       u8                      lvds_link; /* single-link or dual-link */<br>
>       u8                      bpc;<br>
> +     u32                     output_bus_fmt;<br>
> +};<br>
> +<br>
> +static const u32 tc_lvds_in_bus_fmts[] = {<br>
> +     MEDIA_BUS_FMT_RGB565_1X16,<br>
> +     MEDIA_BUS_FMT_RGB666_1X18,<br>
> +     MEDIA_BUS_FMT_RGB666_1X24_CPADHI,<br>
> +     MEDIA_BUS_FMT_RBG888_1X24,<br>
> +};<br>
> +<br>
> +static const u32 tc_lvds_out_bus_fmts[] = {<br>
> +     MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA,<br>
> +     MEDIA_BUS_FMT_RGB888_1X7X4_SPWG,<br>
> +     MEDIA_BUS_FMT_RGB666_1X7X3_SPWG,<br>
>  };<br>
>  <br>
>  static inline struct tc_data *bridge_to_tc(struct drm_bridge *b)<br>
> @@ -359,19 +373,6 @@ static void d2l_write(struct i2c_client *i2c, u16 addr, u32 val)<br>
>                       ret, addr);<br>
>  }<br>
>  <br>
> -/* helper function to access bus_formats */<br>
> -static struct drm_connector *get_connector(struct drm_encoder *encoder)<br>
> -{<br>
> -     struct drm_device *dev = encoder->dev;<br>
> -     struct drm_connector *connector;<br>
> -<br>
> -     list_for_each_entry(connector, &dev->mode_config.connector_list, head)<br>
> -             if (connector->encoder == encoder)<br>
> -                     return connector;<br>
> -<br>
> -     return NULL;<br>
> -}<br>
> -<br>
>  static void tc_bridge_enable(struct drm_bridge *bridge)<br>
>  {<br>
>       struct tc_data *tc = bridge_to_tc(bridge);<br>
> @@ -380,7 +381,10 @@ static void tc_bridge_enable(struct drm_bridge *bridge)<br>
>       u32 val = 0;<br>
>       u16 dsiclk, clkdiv, byteclk, t1, t2, t3, vsdelay;<br>
>       struct drm_display_mode *mode;<br>
> -     struct drm_connector *connector = get_connector(bridge->encoder);<br>
> +     struct drm_bridge_state *state =<br>
> +                     drm_priv_to_bridge_state(bridge->base.state);<br>
> +<br>
> +     tc->output_bus_fmt = state->output_bus_cfg.format;<br>
>  <br>
>       mode = &bridge->encoder->crtc->state->adjusted_mode;<br>
>  <br>
> @@ -451,14 +455,13 @@ static void tc_bridge_enable(struct drm_bridge *bridge)<br>
>       d2l_write(tc->i2c, LVPHY0, LV_PHY0_PRBS_ON(4) | LV_PHY0_ND(6));<br>
>  <br>
>       dev_dbg(tc->dev, "bus_formats %04x bpc %d\n",<br>
> -             connector->display_info.bus_formats[0],<br>
> +             tc->output_bus_fmt,<br>
>               tc->bpc);<br>
>       /*<br>
>        * Default hardware register settings of tc358775 configured<br>
>        * with MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA jeida-24 format<br>
>        */<br>
> -     if (connector->display_info.bus_formats[0] ==<br>
> -             MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {<br>
> +     if (tc->output_bus_fmt == MEDIA_BUS_FMT_RGB888_1X7X4_SPWG) {<br>
>               /* VESA-24 */<br>
>               d2l_write(tc->i2c, LV_MX0003, LV_MX(LVI_R0, LVI_R1, LVI_R2, LVI_R3));<br>
>               d2l_write(tc->i2c, LV_MX0407, LV_MX(LVI_R4, LVI_R7, LVI_R5, LVI_G0));<br>
> @@ -590,6 +593,40 @@ static int tc358775_parse_dt(struct device_node *np, struct tc_data *tc)<br>
>       return 0;<br>
>  }<br>
>  <br>
> +static u32 *<br>
> +tc_bridge_get_input_bus_fmts(struct drm_bridge *bridge,<br>
> +                          struct drm_bridge_state *bridge_state,<br>
> +                          struct drm_crtc_state *crtc_state,<br>
> +                          struct drm_connector_state *conn_state,<br>
> +                          u32 output_fmt,<br>
> +                          unsigned int *num_input_fmts)<br>
> +{<br>
> +     u32 *input_fmts = NULL;<br>
> +     u8 i;<br>
> +<br>
> +     *num_input_fmts = 0;<br>
> +<br>
> +     for (i = 0 ; i < ARRAY_SIZE(tc_lvds_out_bus_fmts) ; ++i) {<br>
> +             if (output_fmt == tc_lvds_out_bus_fmts[i])<br>
> +                     break;<br>
> +     }<br>
> +<br>
> +     if (i == ARRAY_SIZE(tc_lvds_out_bus_fmts))<br>
> +             return NULL;<br>
> +<br>
> +     *num_input_fmts = ARRAY_SIZE(tc_lvds_in_bus_fmts);<br>
> +<br>
> +     input_fmts = kcalloc(*num_input_fmts, ARRAY_SIZE(tc_lvds_in_bus_fmts),<br>
> +                          GFP_KERNEL);<br>
> +     if (!input_fmts)<br>
> +             return NULL;<br>
> +<br>
> +     for (i = 0; i < ARRAY_SIZE(tc_lvds_in_bus_fmts); ++i)<br>
> +             input_fmts[i] = tc_lvds_in_bus_fmts[i];<br>
> +<br>
> +     return input_fmts;<br>
> +}<br>
> +<br>
>  static int tc_bridge_attach(struct drm_bridge *bridge,<br>
>                           enum drm_bridge_attach_flags flags)<br>
>  {<br>
> @@ -639,6 +676,10 @@ static int tc_bridge_attach(struct drm_bridge *bridge,<br>
>  }<br>
>  <br>
>  static const struct drm_bridge_funcs tc_bridge_funcs = {<br>
> +     .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,<br>
> +     .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,<br>
> +     .atomic_reset = drm_atomic_helper_bridge_reset,<br>
> +     .atomic_get_input_bus_fmts = tc_bridge_get_input_bus_fmts,<br>
>       .attach = tc_bridge_attach,<br>
>       .pre_enable = tc_bridge_pre_enable,<br>
>       .enable = tc_bridge_enable,<br>
> -- <br>
> 2.7.4<br>
> <br>
> _______________________________________________<br>
> dri-devel mailing list<br>
> <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
> <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>