[PATCH 28/29] drm/bridge: tc358768: Convert to atomic helpers

From: Maxime Ripard
Date: Wed Jan 15 2025 - 16:10:41 EST


The tc358768 driver follows the drm_encoder->crtc pointer that is
deprecated and shouldn't be used by atomic drivers.

This was due to the fact that we did't have any other alternative to
retrieve the CRTC pointer. Fortunately, the crtc pointer is now provided
in the bridge state, so we can move to atomic callbacks and drop that
deprecated pointer usage.

Signed-off-by: Maxime Ripard <mripard@xxxxxxxxxx>
---
drivers/gpu/drm/bridge/tc358768.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/bridge/tc358768.c b/drivers/gpu/drm/bridge/tc358768.c
index ec79b0dd0e2cd6dfbdd8aee54d6a8d9cf8bfb060..043ecfa5f9bac49c30a2fe9f708b5fba9d235bdc 100644
--- a/drivers/gpu/drm/bridge/tc358768.c
+++ b/drivers/gpu/drm/bridge/tc358768.c
@@ -600,17 +600,29 @@ static void tc358768_bridge_disable(struct drm_bridge *bridge)
ret = tc358768_clear_error(priv);
if (ret)
dev_warn(priv->dev, "Software disable failed: %d\n", ret);
}

+static void tc358768_bridge_atomic_disable(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state)
+{
+ tc358768_bridge_disable(bridge);
+}
+
static void tc358768_bridge_post_disable(struct drm_bridge *bridge)
{
struct tc358768_priv *priv = bridge_to_tc358768(bridge);

tc358768_hw_disable(priv);
}

+static void tc358768_bridge_atomic_post_disable(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state)
+{
+ tc358768_bridge_post_disable(bridge);
+}
+
static int tc358768_setup_pll(struct tc358768_priv *priv,
const struct drm_display_mode *mode)
{
u32 fbd, prd, frs;
int ret;
@@ -680,11 +692,12 @@ static u32 tc358768_dsi_bytes_to_ns(struct tc358768_priv *priv, u32 val)
u64 n = priv->dsiclk / 4 * priv->dsi_lanes;

return (u32)div_u64(m, n);
}

-static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)
+static void tc358768_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state)
{
struct tc358768_priv *priv = bridge_to_tc358768(bridge);
struct mipi_dsi_device *dsi_dev = priv->output.dev;
unsigned long mode_flags = dsi_dev->mode_flags;
u32 val, val2, lptxcnt, hact, data_type;
@@ -717,11 +730,11 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)
dev_err(dev, "Software reset failed: %d\n", ret);
tc358768_hw_disable(priv);
return;
}

- mode = &bridge->encoder->crtc->state->adjusted_mode;
+ mode = &bridge_state->crtc->state->adjusted_mode;
ret = tc358768_setup_pll(priv, mode);
if (ret) {
dev_err(dev, "PLL setup failed: %d\n", ret);
tc358768_hw_disable(priv);
return;
@@ -1081,11 +1094,12 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)
tc358768_bridge_disable(bridge);
tc358768_bridge_post_disable(bridge);
}
}

-static void tc358768_bridge_enable(struct drm_bridge *bridge)
+static void tc358768_bridge_atomic_enable(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state)
{
struct tc358768_priv *priv = bridge_to_tc358768(bridge);
int ret;

if (!priv->enabled) {
@@ -1164,14 +1178,14 @@ static bool tc358768_mode_fixup(struct drm_bridge *bridge,

static const struct drm_bridge_funcs tc358768_bridge_funcs = {
.attach = tc358768_bridge_attach,
.mode_valid = tc358768_bridge_mode_valid,
.mode_fixup = tc358768_mode_fixup,
- .pre_enable = tc358768_bridge_pre_enable,
- .enable = tc358768_bridge_enable,
- .disable = tc358768_bridge_disable,
- .post_disable = tc358768_bridge_post_disable,
+ .atomic_pre_enable = tc358768_bridge_atomic_pre_enable,
+ .atomic_enable = tc358768_bridge_atomic_enable,
+ .atomic_disable = tc358768_bridge_atomic_disable,
+ .atomic_post_disable = tc358768_bridge_atomic_post_disable,

.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 = tc358768_atomic_get_input_bus_fmts,

--
2.47.1