From: Marek Vasut <marex@denx.de>
To: dri-devel@lists.freedesktop.org
Cc: Marek Vasut <marex@denx.de>,
Neil Armstrong <narmstrong@baylibre.com>,
Sam Ravnborg <sam@ravnborg.org>,
Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Maxime Ripard <maxime@cerno.tech>
Subject: [PATCH 2/7] drm/bridge: Add new atomic_get_input_bus_cfgs callback
Date: Sat, 19 Feb 2022 01:28:39 +0100 [thread overview]
Message-ID: <20220219002844.362157-3-marex@denx.de> (raw)
In-Reply-To: <20220219002844.362157-1-marex@denx.de>
Add new .atomic_get_input_bus_cfgs callback into struct drm_bridge_funcs {}.
This is an extended version of .atomic_get_input_bus_fmts callback which
only returns list of bus formats supported by a bridge and provides no way
to e.g. limit clock frequency required between neighboring bridges.
The new .atomic_get_input_bus_cfgs callback returns list of struct drm_bus_cfg,
which currently contains format and bus flags, but can be extended with other
members, like desired clock frequency, as required.
The .atomic_get_input_bus_cfgs should replace the .atomic_get_input_bus_fmts
once drivers get converted over. The conversion could be done using a script.
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
Cc: Maxime Ripard <maxime@cerno.tech>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
---
drivers/gpu/drm/drm_bridge.c | 47 ++++++++++++++++++++++++------------
include/drm/drm_bridge.h | 42 ++++++++++++++++++++++++++++++++
2 files changed, 74 insertions(+), 15 deletions(-)
diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index f052d50106758..a069c50cc7d6b 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -841,7 +841,8 @@ static int select_bus_fmt_recursive(struct drm_bridge *first_bridge,
* hope that it can handle this situation gracefully (by providing
* appropriate default values).
*/
- if (!cur_bridge->funcs->atomic_get_input_bus_fmts) {
+ if (!cur_bridge->funcs->atomic_get_input_bus_cfgs &&
+ !cur_bridge->funcs->atomic_get_input_bus_fmts) {
if (cur_bridge != first_bridge) {
fixed_bus_cfg.format = MEDIA_BUS_FMT_FIXED;
ret = select_bus_fmt_recursive(first_bridge,
@@ -865,32 +866,48 @@ static int select_bus_fmt_recursive(struct drm_bridge *first_bridge,
}
/*
- * If the driver implements ->atomic_get_input_bus_fmts() it
- * should also implement the atomic state hooks.
+ * If the driver implements ->atomic_get_input_bus_cfgs()
+ * or legacy ->atomic_get_input_bus_fmts() it should also
+ * implement the atomic state hooks.
*/
if (WARN_ON(!cur_state))
return -EINVAL;
- in_bus_fmts = cur_bridge->funcs->atomic_get_input_bus_fmts(cur_bridge,
+ if (cur_bridge->funcs->atomic_get_input_bus_cfgs) {
+ in_bus_cfgs = cur_bridge->funcs->atomic_get_input_bus_cfgs(
+ cur_bridge,
+ cur_state,
+ crtc_state,
+ conn_state,
+ out_bus_cfg,
+ &num_in_bus_fmts);
+ if (!num_in_bus_fmts)
+ return -ENOTSUPP;
+ else if (!in_bus_cfgs)
+ return -ENOMEM;
+ } else {
+ in_bus_fmts = cur_bridge->funcs->atomic_get_input_bus_fmts(
+ cur_bridge,
cur_state,
crtc_state,
conn_state,
out_bus_cfg->format,
&num_in_bus_fmts);
- if (!num_in_bus_fmts)
- return -ENOTSUPP;
- else if (!in_bus_fmts)
- return -ENOMEM;
+ if (!num_in_bus_fmts)
+ return -ENOTSUPP;
+ else if (!in_bus_fmts)
+ return -ENOMEM;
- /* Transcribe in_bus_fmts to in_bus_cfgs */
- in_bus_cfgs = kcalloc(num_in_bus_fmts, sizeof(*in_bus_cfgs), GFP_KERNEL);
- if (!in_bus_cfgs)
- return -ENOMEM;
+ /* Transcribe in_bus_fmts to in_bus_cfgs */
+ in_bus_cfgs = kcalloc(num_in_bus_fmts, sizeof(*in_bus_cfgs), GFP_KERNEL);
+ if (!in_bus_cfgs)
+ return -ENOMEM;
- for (i = 0; i < num_in_bus_fmts; i++)
- in_bus_cfgs[i].format = in_bus_fmts[i];
+ for (i = 0; i < num_in_bus_fmts; i++)
+ in_bus_cfgs[i].format = in_bus_fmts[i];
- kfree(in_bus_fmts);
+ kfree(in_bus_fmts);
+ }
if (first_bridge == cur_bridge) {
cur_state->input_bus_cfg.format = in_bus_cfgs[0].format;
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index 061d87313fac9..b2fe0ee7294b5 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -439,6 +439,48 @@ struct drm_bridge_funcs {
struct drm_connector_state *conn_state,
unsigned int *num_output_fmts);
+ /**
+ * @atomic_get_input_bus_cfgs:
+ *
+ * Return the supported bus configurations on the input end of a bridge
+ * for a specific output bus format.
+ *
+ * The returned array must be allocated with kmalloc() and will be
+ * freed by the caller. If the allocation fails, NULL should be
+ * returned. num_output_fmts must be set to the returned array size.
+ * Formats listed in the returned array should be listed in decreasing
+ * preference order (the core will try all formats until it finds one
+ * that works). When the format is not supported NULL should be
+ * returned and num_output_fmts should be set to 0.
+ *
+ * This method is called on all elements of the bridge chain as part of
+ * the bus format negotiation process that happens in
+ * drm_atomic_bridge_chain_select_bus_fmts().
+ * This method is optional. When not implemented, the core will bypass
+ * bus format negotiation on this element of the bridge without
+ * failing, and the previous element in the chain will be passed
+ * MEDIA_BUS_FMT_FIXED as its output bus format.
+ *
+ * Bridge drivers that need to support being linked to bridges that are
+ * not supporting bus format negotiation should handle the
+ * output_fmt == MEDIA_BUS_FMT_FIXED case appropriately, by selecting a
+ * sensible default value or extracting this information from somewhere
+ * else (FW property, &drm_display_mode, &drm_display_info, ...)
+ *
+ * Note: Even if input format selection on the first bridge has no
+ * impact on the negotiation process (bus format negotiation stops once
+ * we reach the first element of the chain), drivers are expected to
+ * return accurate input formats as the input format may be used to
+ * configure the CRTC output appropriately.
+ */
+ struct drm_bus_cfg *(*atomic_get_input_bus_cfgs)
+ (struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ struct drm_bus_cfg *output_cfg,
+ unsigned int *num_input_cfgs);
+
/**
* @atomic_get_input_bus_fmts:
*
--
2.34.1
next prev parent reply other threads:[~2022-02-19 0:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-19 0:28 [RFC][PATCH 0/7] drm/bridge: Add support for selecting DSI host HS clock from DSI bridge Marek Vasut
2022-02-19 0:28 ` [PATCH 1/7] drm/bridge: Pass struct drm_bus_cfg to select_bus_fmt_recursive() Marek Vasut
2022-02-19 0:28 ` Marek Vasut [this message]
2022-02-19 0:28 ` [PATCH 3/7] drm/bridge: Extend struct drm_bus_cfg with clock field Marek Vasut
2022-02-24 15:19 ` Maxime Ripard
2022-02-24 20:07 ` Marek Vasut
2022-02-25 10:51 ` Maxime Ripard
2022-02-19 0:28 ` [PATCH 4/7] drm/bridge: dw-mipi-dsi: Move PLL setup into atomic_enable Marek Vasut
2022-02-19 0:28 ` [PATCH 5/7] drm/bridge: dw-mipi-dsi: Pass bridge state into dw_mipi_dsi_get_lane_mbps() Marek Vasut
2022-02-19 0:28 ` [PATCH 6/7] drm/bridge: dw-mipi-dsi: Prefer DSI bus clock settings from bridge_state Marek Vasut
2022-02-19 0:28 ` [PATCH 7/7] drm/bridge: tc358767: Add support for PLL clock derivation from DSI HS clock Marek Vasut
2022-02-24 15:40 ` [RFC][PATCH 0/7] drm/bridge: Add support for selecting DSI host HS clock from DSI bridge Maxime Ripard
2022-02-24 20:24 ` Marek Vasut
2022-02-25 8:40 ` Maxime Ripard
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=20220219002844.362157-3-marex@denx.de \
--to=marex@denx.de \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=maxime@cerno.tech \
--cc=narmstrong@baylibre.com \
--cc=sam@ravnborg.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