Skip to content
Snippets Groups Projects
Verified Commit 070bac23 authored by Maxime Ripard's avatar Maxime Ripard
Browse files

drm/bridge: tc358768: Convert to atomic helpers


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

Fortunately, the atomic hooks provide the drm_atomic_state and we can
access our current CRTC from that, going from the bridge to its encoder,
to its connector, and to its CRTC.

Let's convert this bridge driver to atomic so we can get rid of the
drm_encoder->crtc dereference.

Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20250313-bridge-connector-v6-15-511c54a604fb@kernel.org


Signed-off-by: Maxime Ripard's avatarMaxime Ripard <mripard@kernel.org>
parent 9c77154b
No related branches found
No related tags found
No related merge requests found
...@@ -581,7 +581,8 @@ tc358768_bridge_mode_valid(struct drm_bridge *bridge, ...@@ -581,7 +581,8 @@ tc358768_bridge_mode_valid(struct drm_bridge *bridge,
return MODE_OK; return MODE_OK;
} }
static void tc358768_bridge_disable(struct drm_bridge *bridge) static void tc358768_bridge_atomic_disable(struct drm_bridge *bridge,
struct drm_atomic_state *state)
{ {
struct tc358768_priv *priv = bridge_to_tc358768(bridge); struct tc358768_priv *priv = bridge_to_tc358768(bridge);
int ret; int ret;
...@@ -603,7 +604,8 @@ static void tc358768_bridge_disable(struct drm_bridge *bridge) ...@@ -603,7 +604,8 @@ static void tc358768_bridge_disable(struct drm_bridge *bridge)
dev_warn(priv->dev, "Software disable failed: %d\n", ret); dev_warn(priv->dev, "Software disable failed: %d\n", ret);
} }
static void tc358768_bridge_post_disable(struct drm_bridge *bridge) static void tc358768_bridge_atomic_post_disable(struct drm_bridge *bridge,
struct drm_atomic_state *state)
{ {
struct tc358768_priv *priv = bridge_to_tc358768(bridge); struct tc358768_priv *priv = bridge_to_tc358768(bridge);
...@@ -683,13 +685,17 @@ static u32 tc358768_dsi_bytes_to_ns(struct tc358768_priv *priv, u32 val) ...@@ -683,13 +685,17 @@ static u32 tc358768_dsi_bytes_to_ns(struct tc358768_priv *priv, u32 val)
return (u32)div_u64(m, n); 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_atomic_state *state)
{ {
struct tc358768_priv *priv = bridge_to_tc358768(bridge); struct tc358768_priv *priv = bridge_to_tc358768(bridge);
struct mipi_dsi_device *dsi_dev = priv->output.dev; struct mipi_dsi_device *dsi_dev = priv->output.dev;
unsigned long mode_flags = dsi_dev->mode_flags; unsigned long mode_flags = dsi_dev->mode_flags;
u32 val, val2, lptxcnt, hact, data_type; u32 val, val2, lptxcnt, hact, data_type;
s32 raw_val; s32 raw_val;
struct drm_crtc_state *crtc_state;
struct drm_connector_state *conn_state;
struct drm_connector *connector;
const struct drm_display_mode *mode; const struct drm_display_mode *mode;
u32 hsbyteclk_ps, dsiclk_ps, ui_ps; u32 hsbyteclk_ps, dsiclk_ps, ui_ps;
u32 dsiclk, hsbyteclk; u32 dsiclk, hsbyteclk;
...@@ -720,7 +726,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) ...@@ -720,7 +726,10 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)
return; return;
} }
mode = &bridge->encoder->crtc->state->adjusted_mode; connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
conn_state = drm_atomic_get_new_connector_state(state, connector);
crtc_state = drm_atomic_get_new_crtc_state(state, conn_state->crtc);
mode = &crtc_state->adjusted_mode;
ret = tc358768_setup_pll(priv, mode); ret = tc358768_setup_pll(priv, mode);
if (ret) { if (ret) {
dev_err(dev, "PLL setup failed: %d\n", ret); dev_err(dev, "PLL setup failed: %d\n", ret);
...@@ -1081,7 +1090,8 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge) ...@@ -1081,7 +1090,8 @@ static void tc358768_bridge_pre_enable(struct drm_bridge *bridge)
dev_err(dev, "Bridge pre_enable failed: %d\n", ret); dev_err(dev, "Bridge pre_enable failed: %d\n", ret);
} }
static void tc358768_bridge_enable(struct drm_bridge *bridge) static void tc358768_bridge_atomic_enable(struct drm_bridge *bridge,
struct drm_atomic_state *state)
{ {
struct tc358768_priv *priv = bridge_to_tc358768(bridge); struct tc358768_priv *priv = bridge_to_tc358768(bridge);
int ret; int ret;
...@@ -1161,10 +1171,10 @@ static const struct drm_bridge_funcs tc358768_bridge_funcs = { ...@@ -1161,10 +1171,10 @@ static const struct drm_bridge_funcs tc358768_bridge_funcs = {
.attach = tc358768_bridge_attach, .attach = tc358768_bridge_attach,
.mode_valid = tc358768_bridge_mode_valid, .mode_valid = tc358768_bridge_mode_valid,
.mode_fixup = tc358768_mode_fixup, .mode_fixup = tc358768_mode_fixup,
.pre_enable = tc358768_bridge_pre_enable, .atomic_pre_enable = tc358768_bridge_atomic_pre_enable,
.enable = tc358768_bridge_enable, .atomic_enable = tc358768_bridge_atomic_enable,
.disable = tc358768_bridge_disable, .atomic_disable = tc358768_bridge_atomic_disable,
.post_disable = tc358768_bridge_post_disable, .atomic_post_disable = tc358768_bridge_atomic_post_disable,
.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment