Linux-Amlogic Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sam Ravnborg <sam@ravnborg.org>
To: Neil Armstrong <narmstrong@baylibre.com>
Cc: daniel@ffwll.ch, Laurent.pinchart@ideasonboard.com,
	robert.foss@linaro.org, jonas@kwiboo.se,
	jernej.skrabec@gmail.com, martin.blumenstingl@googlemail.com,
	dri-devel@lists.freedesktop.org,
	linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/7] drm/bridge: display-connector: implement bus fmts callbacks
Date: Thu, 14 Oct 2021 19:45:15 +0200	[thread overview]
Message-ID: <YWhsq6nxf88Uwnbx@ravnborg.org> (raw)
In-Reply-To: <20211014152606.2289528-2-narmstrong@baylibre.com>

Hi Neil,

code looks fine. A few improvement proposals to the comments.
With the include order fixed and the comments considered:
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

	Sam

On Thu, Oct 14, 2021 at 05:26:00PM +0200, Neil Armstrong wrote:
> Since this bridge is tied to the connector, it acts like a passthrough,
> so concerning the output & input bus formats, either pass the bus formats from the
> previous bridge or return fallback data like done in the bridge function:
> drm_atomic_bridge_chain_select_bus_fmts() & select_bus_fmt_recursive.
> 
> This permits avoiding skipping the negociation if the remaining bridge chain has
> all the bits in place.
> 
> Without this bus fmt negociation breaks on drm/meson HDMI pipeline when attaching
> dw-hdmi with DRM_BRIDGE_ATTACH_NO_CONNECTOR, because the last bridge of the
> display-connector doesn't implement buf fmt callbacks and MEDIA_BUS_FMT_FIXED
> is used leading to select an unsupported default bus format from dw-hdmi.
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/gpu/drm/bridge/display-connector.c | 88 ++++++++++++++++++++++
>  1 file changed, 88 insertions(+)
> 
> diff --git a/drivers/gpu/drm/bridge/display-connector.c b/drivers/gpu/drm/bridge/display-connector.c
> index 05eb759da6fc..9697ac173157 100644
> --- a/drivers/gpu/drm/bridge/display-connector.c
> +++ b/drivers/gpu/drm/bridge/display-connector.c
> @@ -14,6 +14,7 @@
>  #include <linux/regulator/consumer.h>
>  
>  #include <drm/drm_bridge.h>
> +#include <drm/drm_atomic_helper.h>
>  #include <drm/drm_edid.h>
Alphabetic order.

>  
>  struct display_connector {
> @@ -87,10 +88,97 @@ static struct edid *display_connector_get_edid(struct drm_bridge *bridge,
>  	return drm_get_edid(connector, conn->bridge.ddc);
>  }
>  
> +/*
> + * Since this bridge is tied to the connector, it acts like a passthrough,
> + * so concerning the output bus formats, either pass the bus formats from the
> + * previous bridge or return fallback data like done in the bridge function:
> + * drm_atomic_bridge_chain_select_bus_fmts().
> + * This permits avoiding skipping the negociation if the bridge chain has all
> + * bits in place.
negociation if => negotiation of

Consider the following wording:
This supports negotiation if the bridge chain has all bits in place.

> + */
> +static u32 *display_connector_get_output_bus_fmts(struct drm_bridge *bridge,
> +					struct drm_bridge_state *bridge_state,
> +					struct drm_crtc_state *crtc_state,
> +					struct drm_connector_state *conn_state,
> +					unsigned int *num_output_fmts)
> +{
> +	struct drm_bridge *prev_bridge = drm_bridge_get_prev_bridge(bridge);
> +	struct drm_bridge_state *prev_bridge_state;
> +
> +	if (!prev_bridge || !prev_bridge->funcs->atomic_get_output_bus_fmts) {
> +		struct drm_connector *conn = conn_state->connector;
> +		u32 *out_bus_fmts;
> +
> +		*num_output_fmts = 1;
> +		out_bus_fmts = kmalloc(sizeof(*out_bus_fmts), GFP_KERNEL);
> +		if (!out_bus_fmts)
> +			return NULL;
> +
> +		if (conn->display_info.num_bus_formats &&
> +		    conn->display_info.bus_formats)
> +			out_bus_fmts[0] = conn->display_info.bus_formats[0];
> +		else
> +			out_bus_fmts[0] = MEDIA_BUS_FMT_FIXED;
> +
> +		return out_bus_fmts;
> +	}
> +
> +	prev_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
> +							    prev_bridge);
> +
> +	return prev_bridge->funcs->atomic_get_output_bus_fmts(prev_bridge, prev_bridge_state,
> +							      crtc_state, conn_state,
> +							      num_output_fmts);
> +}
> +
> +/*
> + * Since this bridge is tied to the connector, it acts like a passthrough,
> + * so concerning the input bus formats, either pass the bus formats from the
> + * previous bridge or return fallback data like done in the bridge function:
> + * select_bus_fmt_recursive() when atomic_get_input_bus_fmts is not supported.
Maybe use this this:
from the previous bridge or MEDIA_BUS_FMT_FIXED (like select_bus_fmt_recursive())


> + * This permits avoiding skipping the negociation if the bridge chain has all
> + * bits in place.
Like above
> + */
> +static u32 *display_connector_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)
> +{
> +	struct drm_bridge *prev_bridge = drm_bridge_get_prev_bridge(bridge);
> +	struct drm_bridge_state *prev_bridge_state;
> +
> +	if (!prev_bridge || !prev_bridge->funcs->atomic_get_input_bus_fmts) {
> +		u32 *in_bus_fmts;
> +
> +		*num_input_fmts = 1;
> +		in_bus_fmts = kmalloc(sizeof(*in_bus_fmts), GFP_KERNEL);
> +		if (!in_bus_fmts)
> +			return NULL;
> +
> +		in_bus_fmts[0] = MEDIA_BUS_FMT_FIXED;
> +
> +		return in_bus_fmts;
> +	}
> +
> +	prev_bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
> +							    prev_bridge);
> +
> +	return prev_bridge->funcs->atomic_get_input_bus_fmts(prev_bridge, prev_bridge_state,
> +							     crtc_state, conn_state, output_fmt,
> +							     num_input_fmts);
> +}
> +
>  static const struct drm_bridge_funcs display_connector_bridge_funcs = {
>  	.attach = display_connector_attach,
>  	.detect = display_connector_detect,
>  	.get_edid = display_connector_get_edid,
> +	.atomic_get_output_bus_fmts = display_connector_get_output_bus_fmts,
> +	.atomic_get_input_bus_fmts = display_connector_get_input_bus_fmts,
> +	.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,
>  };
>  
>  static irqreturn_t display_connector_hpd_irq(int irq, void *arg)
> -- 
> 2.25.1

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2021-10-14 17:45 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-14 15:25 [PATCH 0/7] drm/meson: rework encoders to pass ATTACH_NO_CONNECTOR Neil Armstrong
2021-10-14 15:26 ` [PATCH 1/7] drm/bridge: display-connector: implement bus fmts callbacks Neil Armstrong
2021-10-14 17:45   ` Sam Ravnborg [this message]
2021-10-14 15:26 ` [PATCH 2/7] drm/meson: remove useless recursive components matching Neil Armstrong
2021-10-14 17:49   ` Sam Ravnborg
2021-10-15  7:53     ` Neil Armstrong
2021-10-14 15:26 ` [PATCH 3/7] drm/meson: split out encoder from meson_dw_hdmi Neil Armstrong
2021-10-14 18:07   ` Sam Ravnborg
2021-10-15  7:55     ` Neil Armstrong
2021-10-14 15:26 ` [PATCH 4/7] drm/bridge: synopsys: dw-hdmi: also allow interlace on bridge Neil Armstrong
2021-10-14 18:08   ` Sam Ravnborg
2021-10-15  8:01     ` Neil Armstrong
2021-10-14 15:26 ` [PATCH 5/7] drm/meson: encoder_hdmi: switch to bridge DRM_BRIDGE_ATTACH_NO_CONNECTOR Neil Armstrong
2021-10-14 18:19   ` Sam Ravnborg
2021-10-14 15:26 ` [PATCH 6/7] drm/meson: rename venc_cvbs to encoder_cvbs Neil Armstrong
2021-10-14 18:15   ` Sam Ravnborg
2021-10-14 15:26 ` [PATCH 7/7] drm/meson: encoder_cvbs: switch to bridge with ATTACH_NO_CONNECTOR Neil Armstrong
2021-10-14 18:15   ` Sam Ravnborg
2021-10-15  7:56     ` Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YWhsq6nxf88Uwnbx@ravnborg.org \
    --to=sam@ravnborg.org \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=robert.foss@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox