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

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
Loading
Loading
Loading
Loading
+114 −106
Original line number Diff line number Diff line
@@ -5680,8 +5680,11 @@ static int dm_update_crtcs_state(struct amdgpu_display_manager *dm,
	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_plane *plane,
				 struct drm_plane_state *old_plane_state,
				 struct drm_plane_state *new_plane_state,
				 bool enable,
				 bool *lock_and_validation_needed)
{
@@ -5689,18 +5692,13 @@ static int dm_update_planes_state(struct dc *dc,
	struct dm_atomic_state *dm_state = NULL;
	struct drm_crtc *new_plane_crtc, *old_plane_crtc;
	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_plane_state *dm_new_plane_state, *dm_old_plane_state;
	int i ;
	/* TODO return page_flip_needed() function */
	bool pflip_needed  = !state->allow_modeset;
	int ret = 0;


	/* Add new planes, in reverse order as DC expectation */
	for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
	new_plane_crtc = new_plane_state->crtc;
	old_plane_crtc = old_plane_state->crtc;
	dm_new_plane_state = to_dm_plane_state(new_plane_state);
@@ -5708,23 +5706,23 @@ static int dm_update_planes_state(struct dc *dc,

	/*TODO Implement atomic check for cursor plane */
	if (plane->type == DRM_PLANE_TYPE_CURSOR)
			continue;
		return 0;

	/* Remove any changed/removed planes */
	if (!enable) {
		if (pflip_needed &&
		    plane->type != DRM_PLANE_TYPE_OVERLAY)
				continue;
			return 0;

		if (!old_plane_crtc)
				continue;
			return 0;

		old_crtc_state = drm_atomic_get_old_crtc_state(
				state, old_plane_crtc);
		dm_old_crtc_state = to_dm_crtc_state(old_crtc_state);

		if (!dm_old_crtc_state->stream)
				continue;
			return 0;

		DRM_DEBUG_ATOMIC("Disabling DRM plane: %d on DRM crtc %d\n",
				plane->base.id, old_plane_crtc->base.id);
@@ -5753,20 +5751,19 @@ static int dm_update_planes_state(struct dc *dc,
		struct dc_plane_state *dc_new_plane_state;

		if (drm_atomic_plane_disabling(plane->state, new_plane_state))
				continue;
			return 0;

		if (!new_plane_crtc)
				continue;
			return 0;

		new_crtc_state = drm_atomic_get_new_crtc_state(state, new_plane_crtc);
		dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);

		if (!dm_new_crtc_state->stream)
				continue;
			return 0;

			if (pflip_needed &&
			    plane->type != DRM_PLANE_TYPE_OVERLAY)
				continue;
		if (pflip_needed && plane->type != DRM_PLANE_TYPE_OVERLAY)
			return 0;

		WARN_ON(dm_new_plane_state->dc_state);

@@ -5819,7 +5816,6 @@ static int dm_update_planes_state(struct dc *dc,

		*lock_and_validation_needed = true;
	}
	}


	return ret;
@@ -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_crtc *crtc;
	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 overall_update_type = UPDATE_TYPE_FAST;

@@ -6010,8 +6008,13 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
	}

	/* Remove exiting planes if they are modified */
	ret = dm_update_planes_state(dc, state, false, &lock_and_validation_needed);
	if (ret) {
	for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
		ret = dm_update_plane_state(dc, state, plane,
					    old_plane_state,
					    new_plane_state,
					    false,
					    &lock_and_validation_needed);
		if (ret)
			goto fail;
	}

@@ -6028,8 +6031,13 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
	}

	/* Add new/modified planes */
	ret = dm_update_planes_state(dc, state, true, &lock_and_validation_needed);
	if (ret) {
	for_each_oldnew_plane_in_state_reverse(state, plane, old_plane_state, new_plane_state, i) {
		ret = dm_update_plane_state(dc, state, plane,
					    old_plane_state,
					    new_plane_state,
					    true,
					    &lock_and_validation_needed);
		if (ret)
			goto fail;
	}