Skip to contentSkip to conversation

bridge/ti-sn65dsi86.c: convert to atomic operations

PATCH Applied Sam Ravnborg 3 participants 4 messages Jul 4, 2022 – Jul 6, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover bridge/ti-sn65dsi86.c: convert to atomic operations

This patch is what is left on a previous attempt to make the ti-sn65dsi86 support DRM_BRIDGE_ATTACH_NO_CONNECTOR.

I ran into several challenges on the way:
- I never found a way to retreive bpc when the driver
do not create the connector - and the driver needs it. There may be ways to change how bpc is used but as I have no access to HW it is not easy to change much.
- My understanding of the driver is limited so I dropped trying to do the proper implmentation of format negotiation
- I had made a small macro to encapsulate a few of the common functions in drm_bridge_funcs - but looking at it with fresh eyes told me this is not a good idea.

I dropped previous a-b / r-b as the driver has changed a bit since last submission.
Especially to Kieran - sorry for letting you wait so long for almost nothing.

Previous attempt:
https://lore.kernel.org/dri-devel/[email protected]/

Sam

Sam Ravnborg (1):
drm/bridge: ti-sn65dsi86: Use atomic variants of drm_bridge_funcs

 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
#1 lore raw

PATCH v2 1/1 drm/bridge: ti-sn65dsi86: Use atomic variants of drm_bridge_funcs

Move away from the deprecated enable/disable operations in drm_bridge_funcs and enable atomic use.

v3:
- Drop use of DRM_BRIDGE_STATE_OPS

v2:
- fix build (kernel test robot <[email protected]>)

Cc Kieran Bingham <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Neil Armstrong <[email protected]>
Cc Robert Foss <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Jonas Karlman <[email protected]>
Cc Jernej Skrabec <[email protected]>
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +15 -8
index c2b9227f7042..d6dd4d99a229 100644
@@ -752,7 +752,8 @@ ti_sn_bridge_mode_valid(struct drm_bridge *bridge,
 	return MODE_OK;
 }
 
-static void ti_sn_bridge_disable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_disable(struct drm_bridge *bridge,
+					struct drm_bridge_state *old_bridge_state)
 {
 	struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1011,7 +1012,8 @@ static int ti_sn_link_training(struct ti_sn65dsi86 *pdata, int dp_rate_idx,
 	return ret;
 }
 
-static void ti_sn_bridge_enable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_enable(struct drm_bridge *bridge,
+				       struct drm_bridge_state *old_bridge_state)
 {
 	struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 	const char *last_err_str = "No supported DP rate";
@@ -1080,7 +1082,8 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge)
 			   VSTREAM_ENABLE);
 }
 
-static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+					   struct drm_bridge_state *old_bridge_state)
 {
 	struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1093,7 +1096,8 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
 	usleep_range(100, 110);
 }
 
-static void ti_sn_bridge_post_disable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_post_disable(struct drm_bridge *bridge,
+					     struct drm_bridge_state *old_bridge_state)
 {
 	struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1114,10 +1118,13 @@ static const struct drm_bridge_funcs ti_sn_bridge_funcs = {
 	.attach = ti_sn_bridge_attach,
 	.detach = ti_sn_bridge_detach,
 	.mode_valid = ti_sn_bridge_mode_valid,
-	.pre_enable = ti_sn_bridge_pre_enable,
-	.enable = ti_sn_bridge_enable,
-	.disable = ti_sn_bridge_disable,
-	.post_disable = ti_sn_bridge_post_disable,
+	.atomic_pre_enable = ti_sn_bridge_atomic_pre_enable,
+	.atomic_enable = ti_sn_bridge_atomic_enable,
+	.atomic_disable = ti_sn_bridge_atomic_disable,
+	.atomic_post_disable = ti_sn_bridge_atomic_post_disable,
+	.atomic_reset = drm_atomic_helper_bridge_reset,
+	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 };
 
 static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata,
Signature · 1 line
2.34.1
Reviewed-by on v2 1/1 Applied
#2 lore raw

Re: [PATCH v2 1/1] drm/bridge: ti-sn65dsi86: Use atomic variants of drm_bridge_funcs

Quoted 86 lines · Sam Ravnborg

Move away from the deprecated enable/disable operations in drm_bridge_funcs and enable atomic use.

v3:
- Drop use of DRM_BRIDGE_STATE_OPS

v2:
- fix build (kernel test robot <[email protected]>)

Cc Kieran Bingham <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Neil Armstrong <[email protected]>
Cc Robert Foss <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Jonas Karlman <[email protected]>
Cc Jernej Skrabec <[email protected]>
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +15 -9
index c2b9227f7042..d6dd4d99a229 100644
@@ -752,7 +752,8 @@ ti_sn_bridge_mode_valid(struct drm_bridge *bridge,
        return MODE_OK;
 }
 
-static void ti_sn_bridge_disable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_disable(struct drm_bridge *bridge,
+                                       struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1011,7 +1012,8 @@ static int ti_sn_link_training(struct ti_sn65dsi86 *pdata, int dp_rate_idx,
        return ret;
 }
 
-static void ti_sn_bridge_enable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
        const char *last_err_str = "No supported DP rate";
@@ -1080,7 +1082,8 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge)
                           VSTREAM_ENABLE);
 }
 
-static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1093,7 +1096,8 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
        usleep_range(100, 110);
 }
 
-static void ti_sn_bridge_post_disable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_post_disable(struct drm_bridge *bridge,
+                                            struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1114,10 +1118,13 @@ static const struct drm_bridge_funcs ti_sn_bridge_funcs = {
        .attach = ti_sn_bridge_attach,
        .detach = ti_sn_bridge_detach,
        .mode_valid = ti_sn_bridge_mode_valid,
-       .pre_enable = ti_sn_bridge_pre_enable,
-       .enable = ti_sn_bridge_enable,
-       .disable = ti_sn_bridge_disable,
-       .post_disable = ti_sn_bridge_post_disable,
+       .atomic_pre_enable = ti_sn_bridge_atomic_pre_enable,
+       .atomic_enable = ti_sn_bridge_atomic_enable,
+       .atomic_disable = ti_sn_bridge_atomic_disable,
+       .atomic_post_disable = ti_sn_bridge_atomic_post_disable,
+       .atomic_reset = drm_atomic_helper_bridge_reset,
+       .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 };
 
 static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata,
--
Quoted 2 lines

2.34.1

Applied to drm-misc-next.

#3 lore raw

Re: [PATCH v2 1/1] drm/bridge: ti-sn65dsi86: Use atomic variants of drm_bridge_funcs

In reply to Sam Ravnborg

Hi Sam

Quoted 3 lines · Sam Ravnborg

Move away from the deprecated enable/disable operations in drm_bridge_funcs and enable atomic use.

If you're moving to the atomic API, shouldn't you also be getting the mode from the provided state, rather than ti_sn_bridge_set_video_timings() having a rummage to find the crtc and encoder state via &pdata->bridge.encoder->crtc->state->adjusted_mode?

https://elixir.bootlin.com/linux/latest/source/drivers/gpu/drm/bridge/ti-sn65dsi86.c#L904

Dave

Quoted 84 lines

v3:
- Drop use of DRM_BRIDGE_STATE_OPS

v2:
- fix build (kernel test robot <[email protected]>)

Cc Kieran Bingham <[email protected]>
Cc Douglas Anderson <[email protected]>
Cc Andrzej Hajda <[email protected]>
Cc Neil Armstrong <[email protected]>
Cc Robert Foss <[email protected]>
Cc Laurent Pinchart <[email protected]>
Cc Jonas Karlman <[email protected]>
Cc Jernej Skrabec <[email protected]>
---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/bridge/ti-sn65dsi86.c +15 -9
index c2b9227f7042..d6dd4d99a229 100644
@@ -752,7 +752,8 @@ ti_sn_bridge_mode_valid(struct drm_bridge *bridge,
        return MODE_OK;
 }
 
-static void ti_sn_bridge_disable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_disable(struct drm_bridge *bridge,
+                                       struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1011,7 +1012,8 @@ static int ti_sn_link_training(struct ti_sn65dsi86 *pdata, int dp_rate_idx,
        return ret;
 }
 
-static void ti_sn_bridge_enable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_enable(struct drm_bridge *bridge,
+                                      struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
        const char *last_err_str = "No supported DP rate";
@@ -1080,7 +1082,8 @@ static void ti_sn_bridge_enable(struct drm_bridge *bridge)
                           VSTREAM_ENABLE);
 }
 
-static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_pre_enable(struct drm_bridge *bridge,
+                                          struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1093,7 +1096,8 @@ static void ti_sn_bridge_pre_enable(struct drm_bridge *bridge)
        usleep_range(100, 110);
 }
 
-static void ti_sn_bridge_post_disable(struct drm_bridge *bridge)
+static void ti_sn_bridge_atomic_post_disable(struct drm_bridge *bridge,
+                                            struct drm_bridge_state *old_bridge_state)
 {
        struct ti_sn65dsi86 *pdata = bridge_to_ti_sn65dsi86(bridge);
 
@@ -1114,10 +1118,13 @@ static const struct drm_bridge_funcs ti_sn_bridge_funcs = {
        .attach = ti_sn_bridge_attach,
        .detach = ti_sn_bridge_detach,
        .mode_valid = ti_sn_bridge_mode_valid,
-       .pre_enable = ti_sn_bridge_pre_enable,
-       .enable = ti_sn_bridge_enable,
-       .disable = ti_sn_bridge_disable,
-       .post_disable = ti_sn_bridge_post_disable,
+       .atomic_pre_enable = ti_sn_bridge_atomic_pre_enable,
+       .atomic_enable = ti_sn_bridge_atomic_enable,
+       .atomic_disable = ti_sn_bridge_atomic_disable,
+       .atomic_post_disable = ti_sn_bridge_atomic_post_disable,
+       .atomic_reset = drm_atomic_helper_bridge_reset,
+       .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+       .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
 };
 
 static void ti_sn_bridge_parse_lanes(struct ti_sn65dsi86 *pdata,
--

2.34.1