Commit b4d93679 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/atomic: Convert get_existing_state callers to get_old/new_state, v4.

This is a straightforward conversion that converts all the users of
get_existing_state in atomic core to use get_old_state or get_new_state

Changes since v1:
- Fix using the wrong state in drm_atomic_helper_update_legacy_modeset_state.
Changes since v2:
- Use the correct state in disable_outputs()
Changes since v3:
- Rebase for link status training.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/df91a9f9-005e-bcbd-1f74-03c38e1e21dd@linux.intel.comReviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
parent 2107777c
...@@ -1374,7 +1374,7 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state, ...@@ -1374,7 +1374,7 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
return 0; return 0;
if (conn_state->crtc) { if (conn_state->crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state, crtc_state = drm_atomic_get_new_crtc_state(conn_state->state,
conn_state->crtc); conn_state->crtc);
crtc_state->connector_mask &= crtc_state->connector_mask &=
...@@ -1492,7 +1492,7 @@ drm_atomic_add_affected_planes(struct drm_atomic_state *state, ...@@ -1492,7 +1492,7 @@ drm_atomic_add_affected_planes(struct drm_atomic_state *state,
{ {
struct drm_plane *plane; struct drm_plane *plane;
WARN_ON(!drm_atomic_get_existing_crtc_state(state, crtc)); WARN_ON(!drm_atomic_get_new_crtc_state(state, crtc));
drm_for_each_plane_mask(plane, state->dev, crtc->state->plane_mask) { drm_for_each_plane_mask(plane, state->dev, crtc->state->plane_mask) {
struct drm_plane_state *plane_state = struct drm_plane_state *plane_state =
......
...@@ -70,7 +70,7 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state, ...@@ -70,7 +70,7 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
if (old_plane_state->crtc) { if (old_plane_state->crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(state, crtc_state = drm_atomic_get_new_crtc_state(state,
old_plane_state->crtc); old_plane_state->crtc);
if (WARN_ON(!crtc_state)) if (WARN_ON(!crtc_state))
...@@ -80,8 +80,7 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state, ...@@ -80,8 +80,7 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
} }
if (plane_state->crtc) { if (plane_state->crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(state, crtc_state = drm_atomic_get_new_crtc_state(state, plane_state->crtc);
plane_state->crtc);
if (WARN_ON(!crtc_state)) if (WARN_ON(!crtc_state))
return; return;
...@@ -150,7 +149,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state, ...@@ -150,7 +149,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
drm_for_each_connector_iter(connector, &conn_iter) { drm_for_each_connector_iter(connector, &conn_iter) {
struct drm_crtc_state *crtc_state; struct drm_crtc_state *crtc_state;
if (drm_atomic_get_existing_connector_state(state, connector)) if (drm_atomic_get_new_connector_state(state, connector))
continue; continue;
encoder = connector->state->best_encoder; encoder = connector->state->best_encoder;
...@@ -178,7 +177,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state, ...@@ -178,7 +177,7 @@ static int handle_conflicting_encoders(struct drm_atomic_state *state,
new_conn_state->crtc->base.id, new_conn_state->crtc->name, new_conn_state->crtc->base.id, new_conn_state->crtc->name,
connector->base.id, connector->name); connector->base.id, connector->name);
crtc_state = drm_atomic_get_existing_crtc_state(state, new_conn_state->crtc); crtc_state = drm_atomic_get_new_crtc_state(state, new_conn_state->crtc);
ret = drm_atomic_set_crtc_for_connector(new_conn_state, NULL); ret = drm_atomic_set_crtc_for_connector(new_conn_state, NULL);
if (ret) if (ret)
...@@ -219,7 +218,7 @@ set_best_encoder(struct drm_atomic_state *state, ...@@ -219,7 +218,7 @@ set_best_encoder(struct drm_atomic_state *state,
*/ */
WARN_ON(!crtc && encoder != conn_state->best_encoder); WARN_ON(!crtc && encoder != conn_state->best_encoder);
if (crtc) { if (crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
crtc_state->encoder_mask &= crtc_state->encoder_mask &=
~(1 << drm_encoder_index(conn_state->best_encoder)); ~(1 << drm_encoder_index(conn_state->best_encoder));
...@@ -230,7 +229,7 @@ set_best_encoder(struct drm_atomic_state *state, ...@@ -230,7 +229,7 @@ set_best_encoder(struct drm_atomic_state *state,
crtc = conn_state->crtc; crtc = conn_state->crtc;
WARN_ON(!crtc); WARN_ON(!crtc);
if (crtc) { if (crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
crtc_state->encoder_mask |= crtc_state->encoder_mask |=
1 << drm_encoder_index(encoder); 1 << drm_encoder_index(encoder);
...@@ -263,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state, ...@@ -263,7 +262,7 @@ steal_encoder(struct drm_atomic_state *state,
set_best_encoder(state, new_connector_state, NULL); set_best_encoder(state, new_connector_state, NULL);
crtc_state = drm_atomic_get_existing_crtc_state(state, encoder_crtc); crtc_state = drm_atomic_get_new_crtc_state(state, encoder_crtc);
crtc_state->connectors_changed = true; crtc_state->connectors_changed = true;
return; return;
...@@ -286,12 +285,12 @@ update_connector_routing(struct drm_atomic_state *state, ...@@ -286,12 +285,12 @@ update_connector_routing(struct drm_atomic_state *state,
if (old_connector_state->crtc != new_connector_state->crtc) { if (old_connector_state->crtc != new_connector_state->crtc) {
if (old_connector_state->crtc) { if (old_connector_state->crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(state, old_connector_state->crtc); crtc_state = drm_atomic_get_new_crtc_state(state, old_connector_state->crtc);
crtc_state->connectors_changed = true; crtc_state->connectors_changed = true;
} }
if (new_connector_state->crtc) { if (new_connector_state->crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(state, new_connector_state->crtc); crtc_state = drm_atomic_get_new_crtc_state(state, new_connector_state->crtc);
crtc_state->connectors_changed = true; crtc_state->connectors_changed = true;
} }
} }
...@@ -350,7 +349,7 @@ update_connector_routing(struct drm_atomic_state *state, ...@@ -350,7 +349,7 @@ update_connector_routing(struct drm_atomic_state *state,
set_best_encoder(state, new_connector_state, new_encoder); set_best_encoder(state, new_connector_state, new_encoder);
crtc_state = drm_atomic_get_existing_crtc_state(state, new_connector_state->crtc); crtc_state = drm_atomic_get_new_crtc_state(state, new_connector_state->crtc);
crtc_state->connectors_changed = true; crtc_state->connectors_changed = true;
DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n", DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",
...@@ -392,7 +391,7 @@ mode_fixup(struct drm_atomic_state *state) ...@@ -392,7 +391,7 @@ mode_fixup(struct drm_atomic_state *state)
continue; continue;
new_crtc_state = new_crtc_state =
drm_atomic_get_existing_crtc_state(state, new_conn_state->crtc); drm_atomic_get_new_crtc_state(state, new_conn_state->crtc);
/* /*
* Each encoder has at most one connector (since we always steal * Each encoder has at most one connector (since we always steal
...@@ -534,7 +533,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev, ...@@ -534,7 +533,7 @@ drm_atomic_helper_check_modeset(struct drm_device *dev,
if (ret) if (ret)
return ret; return ret;
if (old_connector_state->crtc) { if (old_connector_state->crtc) {
new_crtc_state = drm_atomic_get_existing_crtc_state(state, new_crtc_state = drm_atomic_get_new_crtc_state(state,
old_connector_state->crtc); old_connector_state->crtc);
if (old_connector_state->link_status != if (old_connector_state->link_status !=
new_connector_state->link_status) new_connector_state->link_status)
...@@ -711,8 +710,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) ...@@ -711,8 +710,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state)
if (!old_conn_state->crtc) if (!old_conn_state->crtc)
continue; continue;
old_crtc_state = drm_atomic_get_existing_crtc_state(old_state, old_crtc_state = drm_atomic_get_old_crtc_state(old_state, old_conn_state->crtc);
old_conn_state->crtc);
if (!old_crtc_state->active || if (!old_crtc_state->active ||
!drm_atomic_crtc_needs_modeset(old_conn_state->crtc->state)) !drm_atomic_crtc_needs_modeset(old_conn_state->crtc->state))
...@@ -841,14 +839,17 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev, ...@@ -841,14 +839,17 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
/* set legacy state in the crtc structure */ /* set legacy state in the crtc structure */
for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) { for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
struct drm_plane *primary = crtc->primary; struct drm_plane *primary = crtc->primary;
struct drm_plane_state *new_plane_state;
crtc->mode = new_crtc_state->mode; crtc->mode = new_crtc_state->mode;
crtc->enabled = new_crtc_state->enable; crtc->enabled = new_crtc_state->enable;
if (drm_atomic_get_existing_plane_state(old_state, primary) && new_plane_state =
primary->state->crtc == crtc) { drm_atomic_get_new_plane_state(old_state, primary);
crtc->x = primary->state->src_x >> 16;
crtc->y = primary->state->src_y >> 16; if (new_plane_state && new_plane_state->crtc == crtc) {
crtc->x = new_plane_state->src_x >> 16;
crtc->y = new_plane_state->src_y >> 16;
} }
if (new_crtc_state->enable) if (new_crtc_state->enable)
...@@ -1850,7 +1851,7 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state) ...@@ -1850,7 +1851,7 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)
drm_for_each_plane_mask(plane, crtc->dev, plane_mask) { drm_for_each_plane_mask(plane, crtc->dev, plane_mask) {
struct drm_plane_state *old_plane_state = struct drm_plane_state *old_plane_state =
drm_atomic_get_existing_plane_state(old_state, plane); drm_atomic_get_old_plane_state(old_state, plane);
const struct drm_plane_helper_funcs *plane_funcs; const struct drm_plane_helper_funcs *plane_funcs;
plane_funcs = plane->helper_private; plane_funcs = plane->helper_private;
...@@ -2953,7 +2954,7 @@ int drm_atomic_helper_page_flip_target( ...@@ -2953,7 +2954,7 @@ int drm_atomic_helper_page_flip_target(
if (ret != 0) if (ret != 0)
goto fail; goto fail;
crtc_state = drm_atomic_get_existing_crtc_state(state, crtc); crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
if (WARN_ON(!crtc_state)) { if (WARN_ON(!crtc_state)) {
ret = -EINVAL; ret = -EINVAL;
goto fail; goto fail;
......
...@@ -387,8 +387,7 @@ int drm_atomic_normalize_zpos(struct drm_device *dev, ...@@ -387,8 +387,7 @@ int drm_atomic_normalize_zpos(struct drm_device *dev,
if (!crtc) if (!crtc)
continue; continue;
if (plane->state->zpos != plane_state->zpos) { if (plane->state->zpos != plane_state->zpos) {
crtc_state = crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
drm_atomic_get_existing_crtc_state(state, crtc);
crtc_state->zpos_changed = true; crtc_state->zpos_changed = true;
} }
} }
......
...@@ -86,7 +86,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane, ...@@ -86,7 +86,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
int ret; int ret;
pipe = container_of(plane, struct drm_simple_display_pipe, plane); pipe = container_of(plane, struct drm_simple_display_pipe, plane);
crtc_state = drm_atomic_get_existing_crtc_state(plane_state->state, crtc_state = drm_atomic_get_new_crtc_state(plane_state->state,
&pipe->crtc); &pipe->crtc);
if (crtc_state->enable != !!plane_state->crtc) if (crtc_state->enable != !!plane_state->crtc)
return -EINVAL; /* plane must match crtc enable state */ return -EINVAL; /* plane must match crtc enable state */
......
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