Commit ff19b786 authored by Maarten Lankhorst's avatar Maarten Lankhorst Committed by Daniel Vetter

drm/atomic: Always call steal_encoder, v2.

There's no need to have a separate function to get the crtc
which is stolen, this can already be found when actually
stealing the encoder.

drm_for_each_connector already checks for connection_mutex, so
use that macro now.

Changes since v1:
- Do not check for NULL crtc in connector_state,
  this may happen when a crtc is disabled and its encoder stolen.
- Because of this, use connector->state->crtc instead of conn_state->crtc.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1456996662-8704-4-git-send-email-maarten.lankhorst@linux.intel.com
parent b282e969
...@@ -106,25 +106,6 @@ check_pending_encoder_assignment(struct drm_atomic_state *state, ...@@ -106,25 +106,6 @@ check_pending_encoder_assignment(struct drm_atomic_state *state,
return true; return true;
} }
static struct drm_crtc *
get_current_crtc_for_encoder(struct drm_device *dev,
struct drm_encoder *encoder)
{
struct drm_mode_config *config = &dev->mode_config;
struct drm_connector *connector;
WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
drm_for_each_connector(connector, dev) {
if (connector->state->best_encoder != encoder)
continue;
return connector->state->crtc;
}
return NULL;
}
static void static void
set_best_encoder(struct drm_atomic_state *state, set_best_encoder(struct drm_atomic_state *state,
struct drm_connector_state *conn_state, struct drm_connector_state *conn_state,
...@@ -168,38 +149,18 @@ set_best_encoder(struct drm_atomic_state *state, ...@@ -168,38 +149,18 @@ set_best_encoder(struct drm_atomic_state *state,
static int static int
steal_encoder(struct drm_atomic_state *state, steal_encoder(struct drm_atomic_state *state,
struct drm_encoder *encoder, struct drm_encoder *encoder)
struct drm_crtc *encoder_crtc)
{ {
struct drm_mode_config *config = &state->dev->mode_config;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
struct drm_connector *connector; struct drm_connector *connector;
struct drm_connector_state *connector_state; struct drm_connector_state *connector_state;
/* drm_for_each_connector(connector, state->dev) {
* We can only steal an encoder coming from a connector, which means we struct drm_crtc *encoder_crtc;
* must already hold the connection_mutex.
*/
WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
encoder->base.id, encoder->name,
encoder_crtc->base.id, encoder_crtc->name);
crtc_state = drm_atomic_get_crtc_state(state, encoder_crtc);
if (IS_ERR(crtc_state))
return PTR_ERR(crtc_state);
crtc_state->connectors_changed = true;
list_for_each_entry(connector, &config->connector_list, head) {
if (connector->state->best_encoder != encoder) if (connector->state->best_encoder != encoder)
continue; continue;
DRM_DEBUG_ATOMIC("Stealing encoder from [CONNECTOR:%d:%s]\n",
connector->base.id,
connector->name);
connector_state = drm_atomic_get_connector_state(state, connector_state = drm_atomic_get_connector_state(state,
connector); connector);
if (IS_ERR(connector_state)) if (IS_ERR(connector_state))
...@@ -208,7 +169,18 @@ steal_encoder(struct drm_atomic_state *state, ...@@ -208,7 +169,18 @@ steal_encoder(struct drm_atomic_state *state,
if (connector_state->best_encoder != encoder) if (connector_state->best_encoder != encoder)
continue; continue;
encoder_crtc = connector->state->crtc;
DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
encoder->base.id, encoder->name,
encoder_crtc->base.id, encoder_crtc->name);
set_best_encoder(state, connector_state, NULL); set_best_encoder(state, connector_state, NULL);
crtc_state = drm_atomic_get_existing_crtc_state(state, encoder_crtc);
crtc_state->connectors_changed = true;
return 0;
} }
return 0; return 0;
...@@ -221,7 +193,6 @@ update_connector_routing(struct drm_atomic_state *state, ...@@ -221,7 +193,6 @@ update_connector_routing(struct drm_atomic_state *state,
{ {
const struct drm_connector_helper_funcs *funcs; const struct drm_connector_helper_funcs *funcs;
struct drm_encoder *new_encoder; struct drm_encoder *new_encoder;
struct drm_crtc *encoder_crtc;
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
int idx, ret; int idx, ret;
...@@ -299,17 +270,12 @@ update_connector_routing(struct drm_atomic_state *state, ...@@ -299,17 +270,12 @@ update_connector_routing(struct drm_atomic_state *state,
return -EINVAL; return -EINVAL;
} }
encoder_crtc = get_current_crtc_for_encoder(state->dev, ret = steal_encoder(state, new_encoder);
new_encoder); if (ret) {
DRM_DEBUG_ATOMIC("Encoder stealing failed for [CONNECTOR:%d:%s]\n",
if (encoder_crtc) { connector->base.id,
ret = steal_encoder(state, new_encoder, encoder_crtc); connector->name);
if (ret) { return ret;
DRM_DEBUG_ATOMIC("Encoder stealing failed for [CONNECTOR:%d:%s]\n",
connector->base.id,
connector->name);
return ret;
}
} }
if (WARN_ON(!connector_state->crtc)) if (WARN_ON(!connector_state->crtc))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment