@@ -777,10 +777,15 @@ EXPORT_SYMBOL(drm_atomic_helper_bridge_duplicate_state);
* that don't subclass the bridge state.
*/
void drm_atomic_helper_bridge_destroy_state(struct drm_bridge *bridge,
struct drm_bridge_state *state)
{
+ if (state->connector) {
+ drm_connector_put(state->connector);
+ state->connector = NULL;
+ }
+
kfree(state);
}
EXPORT_SYMBOL(drm_atomic_helper_bridge_destroy_state);
/**
@@ -803,10 +803,15 @@ static int drm_atomic_bridge_check(struct drm_bridge *bridge,
bridge_state = drm_atomic_get_new_bridge_state(crtc_state->state,
bridge);
if (WARN_ON(!bridge_state))
return -EINVAL;
+ bridge_state->crtc = crtc_state->crtc;
+
+ drm_connector_get(conn_state->connector);
+ bridge_state->connector = conn_state->connector;
+
if (bridge->funcs->atomic_check) {
ret = bridge->funcs->atomic_check(bridge, bridge_state,
crtc_state, conn_state);
if (ret)
return ret;
@@ -1197,10 +1197,24 @@ struct drm_bridge_state {
/**
* @bridge: the bridge this state refers to
*/
struct drm_bridge *bridge;
+ /**
+ * @crtc: CRTC the bridge is connected to, NULL if disabled.
+ *
+ * Do not change this directly.
+ */
+ struct drm_crtc *crtc;
+
+ /**
+ * @connector: The connector the bridge is connected to, NULL if disabled.
+ *
+ * Do not change this directly.
+ */
+ struct drm_connector *connector;
+
/**
* @input_bus_cfg: input bus configuration
*/
struct drm_bus_cfg input_bus_cfg;
Now that connectors are no longer necessarily created by the bridges drivers themselves but might be created by drm_bridge_connector, it's pretty hard for bridge drivers to retrieve pointers to the connector and CRTC they are attached to. Indeed, the only way to retrieve the CRTC is to follow the drm_bridge encoder field, and then the drm_encoder crtc field, both of them being deprecated. And for the connector, since we can have multiple connectors attached to a CRTC, we don't really have a reliable way to get it. Let's provide both pointers in the drm_bridge_state structure so we don't have to follow deprecated, non-atomic, pointers, and be more consistent with the other KMS entities. Signed-off-by: Maxime Ripard <mripard@kernel.org> --- drivers/gpu/drm/drm_atomic_state_helper.c | 5 +++++ drivers/gpu/drm/drm_bridge.c | 5 +++++ include/drm/drm_atomic.h | 14 ++++++++++++++ 3 files changed, 24 insertions(+)