Commit 9e869063 authored by Leo Li's avatar Leo Li Committed by Alex Deucher

drm/amd/display: Move iteration out of dm_update_planes

[Why]
To reduce indentation of dm_update_planes, and to make it operate on
single plane instances.

[How]
Move iteration of plane states into atomic_check.
No functional change is intended.
Signed-off-by: default avatarLeo Li <sunpeng.li@amd.com>
Reviewed-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 36ca09a0
...@@ -5680,145 +5680,141 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm, ...@@ -5680,145 +5680,141 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
return ret; return ret;
} }
static int dm_update_planes_state(struct dc *dc, static int dm_update_plane_state(struct dc *dc,
struct drm_atomic_state *state, struct drm_atomic_state *state,
bool enable, struct drm_plane *plane,
bool *lock_and_validation_needed) struct drm_plane_state *old_plane_state,
struct drm_plane_state *new_plane_state,
bool enable,
bool *lock_and_validation_needed)
{ {
struct dm_atomic_state *dm_state = NULL; struct dm_atomic_state *dm_state = NULL;
struct drm_crtc *new_plane_crtc, *old_plane_crtc; struct drm_crtc *new_plane_crtc, *old_plane_crtc;
struct drm_crtc_state *old_crtc_state, *new_crtc_state; struct drm_crtc_state *old_crtc_state, *new_crtc_state;
struct drm_plane *plane;
struct drm_plane_state *old_plane_state, *new_plane_state;
struct dm_crtc_state *dm_new_crtc_state, *dm_old_crtc_state; struct dm_crtc_state *dm_new_crtc_state, *dm_old_crtc_state;
struct dm_plane_state *dm_new_plane_state, *dm_old_plane_state; struct dm_plane_state *dm_new_plane_state, *dm_old_plane_state;
int i ;
/* TODO return page_flip_needed() function */ /* TODO return page_flip_needed() function */
bool pflip_needed = !state->allow_modeset; bool pflip_needed = !state->allow_modeset;
int ret = 0; int ret = 0;
/* Add new planes, in reverse order as DC expectation */ new_plane_crtc = new_plane_state->crtc;
for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) { old_plane_crtc = old_plane_state->crtc;
new_plane_crtc = new_plane_state->crtc; dm_new_plane_state = to_dm_plane_state(new_plane_state);
old_plane_crtc = old_plane_state->crtc; dm_old_plane_state = to_dm_plane_state(old_plane_state);
dm_new_plane_state = to_dm_plane_state(new_plane_state);
dm_old_plane_state = to_dm_plane_state(old_plane_state);
/*TODO Implement atomic check for cursor plane */ /*TODO Implement atomic check for cursor plane */
if (plane->type == DRM_PLANE_TYPE_CURSOR) if (plane->type == DRM_PLANE_TYPE_CURSOR)
continue; return 0;
/* Remove any changed/removed planes */ /* Remove any changed/removed planes */
if (!enable) { if (!enable) {
if (pflip_needed && if (pflip_needed &&
plane->type != DRM_PLANE_TYPE_OVERLAY) plane->type != DRM_PLANE_TYPE_OVERLAY)
continue; return 0;
if (!old_plane_crtc) if (!old_plane_crtc)
continue; return 0;
old_crtc_state = drm_atomic_get_old_crtc_state( old_crtc_state = drm_atomic_get_old_crtc_state(
state, old_plane_crtc); state, old_plane_crtc);
dm_old_crtc_state = to_dm_crtc_state(old_crtc_state); dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);
if (!dm_old_crtc_state->stream) if (!dm_old_crtc_state->stream)
continue; return 0;
DRM_DEBUG_ATOMIC("Disabling DRM plane: %d on DRM crtc %d\n", DRM_DEBUG_ATOMIC("Disabling DRM plane: %d on DRM crtc %d\n",
plane->base.id, old_plane_crtc->base.id); plane->base.id, old_plane_crtc->base.id);
ret = dm_atomic_get_state(state, &dm_state); ret = dm_atomic_get_state(state, &dm_state);
if (ret) if (ret)
return ret; return ret;
if (!dc_remove_plane_from_context( if (!dc_remove_plane_from_context(
dc, dc,
dm_old_crtc_state->stream, dm_old_crtc_state->stream,
dm_old_plane_state->dc_state, dm_old_plane_state->dc_state,
dm_state->context)) { dm_state->context)) {
ret = EINVAL; ret = EINVAL;
return ret; return ret;
} }
dc_plane_state_release(dm_old_plane_state->dc_state); dc_plane_state_release(dm_old_plane_state->dc_state);
dm_new_plane_state->dc_state = NULL; dm_new_plane_state->dc_state = NULL;
*lock_and_validation_needed = true; *lock_and_validation_needed = true;
} else { /* Add new planes */ } else { /* Add new planes */
struct dc_plane_state *dc_new_plane_state; struct dc_plane_state *dc_new_plane_state;
if (drm_atomic_plane_disabling(plane->state, new_plane_state)) if (drm_atomic_plane_disabling(plane->state, new_plane_state))
continue; return 0;
if (!new_plane_crtc) if (!new_plane_crtc)
continue; return 0;
new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_crtc); new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_crtc);
dm_new_crtc_state = to_dm_crtc_state(new_crtc_state); dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);
if (!dm_new_crtc_state->stream) if (!dm_new_crtc_state->stream)
continue; return 0;
if (pflip_needed && if (pflip_needed && plane->type != DRM_PLANE_TYPE_OVERLAY)
plane->type != DRM_PLANE_TYPE_OVERLAY) return 0;
continue;
WARN_ON(dm_new_plane_state->dc_state); WARN_ON(dm_new_plane_state->dc_state);
dc_new_plane_state = dc_create_plane_state(dc); dc_new_plane_state = dc_create_plane_state(dc);
if (!dc_new_plane_state) if (!dc_new_plane_state)
return -ENOMEM; return -ENOMEM;
DRM_DEBUG_DRIVER("Enabling DRM plane: %d on DRM crtc %d\n", DRM_DEBUG_DRIVER("Enabling DRM plane: %d on DRM crtc %d\n",
plane->base.id, new_plane_crtc->base.id); plane->base.id, new_plane_crtc->base.id);
ret = fill_plane_attributes( ret = fill_plane_attributes(
new_plane_crtc->dev->dev_private, new_plane_crtc->dev->dev_private,
dc_new_plane_state, dc_new_plane_state,
new_plane_state, new_plane_state,
new_crtc_state); new_crtc_state);
if (ret) { if (ret) {
dc_plane_state_release(dc_new_plane_state); dc_plane_state_release(dc_new_plane_state);
return ret; return ret;
} }
ret = dm_atomic_get_state(state, &dm_state); ret = dm_atomic_get_state(state, &dm_state);
if (ret) { if (ret) {
dc_plane_state_release(dc_new_plane_state); dc_plane_state_release(dc_new_plane_state);
return ret; return ret;
} }
/* /*
* Any atomic check errors that occur after this will * Any atomic check errors that occur after this will
* not need a release. The plane state will be attached * not need a release. The plane state will be attached
* to the stream, and therefore part of the atomic * to the stream, and therefore part of the atomic
* state. It'll be released when the atomic state is * state. It'll be released when the atomic state is
* cleaned. * cleaned.
*/ */
if (!dc_add_plane_to_context( if (!dc_add_plane_to_context(
dc, dc,
dm_new_crtc_state->stream, dm_new_crtc_state->stream,
dc_new_plane_state, dc_new_plane_state,
dm_state->context)) { dm_state->context)) {
dc_plane_state_release(dc_new_plane_state);
return -EINVAL;
}
dm_new_plane_state->dc_state = dc_new_plane_state; dc_plane_state_release(dc_new_plane_state);
return -EINVAL;
}
/* Tell DC to do a full surface update every time there dm_new_plane_state->dc_state = dc_new_plane_state;
* is a plane change. Inefficient, but works for now.
*/
dm_new_plane_state->dc_state->update_flags.bits.full_update = 1;
*lock_and_validation_needed = true; /* Tell DC to do a full surface update every time there
} * is a plane change. Inefficient, but works for now.
*/
dm_new_plane_state->dc_state->update_flags.bits.full_update = 1;
*lock_and_validation_needed = true;
} }
...@@ -5976,6 +5972,8 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, ...@@ -5976,6 +5972,8 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
struct drm_connector_state *old_con_state, *new_con_state; struct drm_connector_state *old_con_state, *new_con_state;
struct drm_crtc *crtc; struct drm_crtc *crtc;
struct drm_crtc_state *old_crtc_state, *new_crtc_state; struct drm_crtc_state *old_crtc_state, *new_crtc_state;
struct drm_plane *plane;
struct drm_plane_state *old_plane_state, *new_plane_state;
enum surface_update_type update_type = UPDATE_TYPE_FAST; enum surface_update_type update_type = UPDATE_TYPE_FAST;
enum surface_update_type overall_update_type = UPDATE_TYPE_FAST; enum surface_update_type overall_update_type = UPDATE_TYPE_FAST;
...@@ -6010,9 +6008,14 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, ...@@ -6010,9 +6008,14 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
} }
/* Remove exiting planes if they are modified */ /* Remove exiting planes if they are modified */
ret = dm_update_planes_state(dc, state, false, &lock_and_validation_needed); for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
if (ret) { ret = dm_update_plane_state(dc, state, plane,
goto fail; old_plane_state,
new_plane_state,
false,
&lock_and_validation_needed);
if (ret)
goto fail;
} }
/* Disable all crtcs which require disable */ /* Disable all crtcs which require disable */
...@@ -6028,9 +6031,14 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev, ...@@ -6028,9 +6031,14 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
} }
/* Add new/modified planes */ /* Add new/modified planes */
ret = dm_update_planes_state(dc, state, true, &lock_and_validation_needed); for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
if (ret) { ret = dm_update_plane_state(dc, state, plane,
goto fail; old_plane_state,
new_plane_state,
true,
&lock_and_validation_needed);
if (ret)
goto fail;
} }
/* Run this here since we want to validate the streams we created */ /* Run this here since we want to validate the streams we created */
......
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