Re: [PATCH] drm/bridge: tc358767: Support input format negotiation hook

From: Sam Ravnborg
Date: Mon Nov 06 2023 - 07:54:14 EST


Hi Aradhya,

On Tue, Oct 31, 2023 at 12:58:46AM +0530, Aradhya Bhatia wrote:
> With new connector model, tc358767 will not create the connector, when
> DRM_BRIDGE_ATTACH_NO_CONNECTOR is set and display-controller driver will
> rely on format negotiation to setup the encoder format.
>
> Add the missing input-format negotiation hook in the
> drm_bridge_funcs to complete DRM_BRIDGE_ATTACH_NO_CONNECTOR support.
>
> Input format is selected to MEDIA_BUS_FMT_RGB888_1X24 as default, as is
> the case with older model.
>
> Reported-by: Jan Kiszka <jan.kiszka@xxxxxxxxxxx>
> Signed-off-by: Aradhya Bhatia <a-bhatia1@xxxxxx>
> ---
>
> Notes:
>
> * Since I do not have hardware with me, this was just build tested. I would
> appreciate it if someone could test and review it, especically somebody, who
> uses the bridge for DPI/DSI to eDP format conversion.
>
> * The Toshiba TC358767 bridge is not enabled in arm64 defconfig by default,
> when it should be. Hence, I sent a quick patch[0] earlier.
>
> [0]: https://lore.kernel.org/all/20231030152834.18450-1-a-bhatia1@xxxxxx/
>
> drivers/gpu/drm/bridge/tc358767.c | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c
> index ef2e373606ba..0affcefdeb1c 100644
> --- a/drivers/gpu/drm/bridge/tc358767.c
> +++ b/drivers/gpu/drm/bridge/tc358767.c
> @@ -1751,6 +1751,30 @@ tc_dpi_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
> return input_fmts;
> }
>
> +static u32 *
> +tc_edp_atomic_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;
> +
> + *num_input_fmts = 0;
> +
> + input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
> + GFP_KERNEL);
> + if (!input_fmts)
> + return NULL;
> +
> + /* This is the DSI/DPI-end bus format */
> + input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
> + *num_input_fmts = 1;
> +
> + return input_fmts;
> +}

You could benefit from using the helper:
drm_atomic_helper_bridge_propagate_bus_fmt()

Sam