Commit 1d496907 authored by Krunoslav Kovac's avatar Krunoslav Kovac Committed by Alex Deucher
Browse files

drm/amd/display: Engage PSR synchronously



[Why & How]
The intended use is to force PSR into active state and ignore all
events until explicit EXIT.
A new event force_static is added to power module. It is then sent
to FW.

Signed-off-by: default avatarKrunoslav Kovac <Krunoslav.Kovac@amd.com>
Acked-by: default avatarBindu Ramamurthy <bindu.r@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent fa896813
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -9611,7 +9611,7 @@ bool amdgpu_dm_psr_enable(struct dc_stream_state *stream)
					   &stream, 1,
					   &params);

	return dc_link_set_psr_allow_active(link, true, false);
	return dc_link_set_psr_allow_active(link, true, false, false);
}

/*
@@ -9625,7 +9625,7 @@ static bool amdgpu_dm_psr_disable(struct dc_stream_state *stream)

	DRM_DEBUG_DRIVER("Disabling psr...\n");

	return dc_link_set_psr_allow_active(stream->link, false, true);
	return dc_link_set_psr_allow_active(stream->link, false, true, false);
}

/*
+3 −3
Original line number Diff line number Diff line
@@ -2333,11 +2333,11 @@ static int psr_get(void *data, u64 *val)
{
	struct amdgpu_dm_connector *connector = data;
	struct dc_link *link = connector->dc_link;
	uint32_t psr_state = 0;
	enum dc_psr_state state = PSR_STATE0;

	dc_link_get_psr_state(link, &psr_state);
	dc_link_get_psr_state(link, &state);

	*val = psr_state;
	*val = state;

	return 0;
}
+3 −2
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_m

	if (edp_link) {
		clk_mgr->psr_allow_active_cache = edp_link->psr_settings.psr_allow_active;
		dc_link_set_psr_allow_active(edp_link, false, false);
		dc_link_set_psr_allow_active(edp_link, false, false, false);
	}

}
@@ -104,7 +104,8 @@ void clk_mgr_optimize_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr)
	struct dc_link *edp_link = get_edp_link(dc);

	if (edp_link)
		dc_link_set_psr_allow_active(edp_link, clk_mgr->psr_allow_active_cache, false);
		dc_link_set_psr_allow_active(edp_link,
				clk_mgr->psr_allow_active_cache, false, false);

	if (dc->hwss.optimize_pwr_state)
		dc->hwss.optimize_pwr_state(dc, dc->current_state);
+2 −2
Original line number Diff line number Diff line
@@ -3058,9 +3058,9 @@ bool dc_set_psr_allow_active(struct dc *dc, bool enable)

		if (link->psr_settings.psr_feature_enabled) {
			if (enable && !link->psr_settings.psr_allow_active)
				return dc_link_set_psr_allow_active(link, true, false);
				return dc_link_set_psr_allow_active(link, true, false, false);
			else if (!enable && link->psr_settings.psr_allow_active)
				return dc_link_set_psr_allow_active(link, false, true);
				return dc_link_set_psr_allow_active(link, false, true, false);
		}
	}

+12 −6
Original line number Diff line number Diff line
@@ -2565,17 +2565,23 @@ bool dc_link_set_backlight_level(const struct dc_link *link,
	return true;
}

bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, bool wait)
bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active,
		bool wait, bool force_static)
{
	struct dc  *dc = link->ctx->dc;
	struct dmcu *dmcu = dc->res_pool->dmcu;
	struct dmub_psr *psr = dc->res_pool->psr;

	if (psr == NULL && force_static)
		return false;

	link->psr_settings.psr_allow_active = allow_active;

	if (psr != NULL && link->psr_settings.psr_feature_enabled)
	if (psr != NULL && link->psr_settings.psr_feature_enabled) {
		if (force_static && psr->funcs->psr_force_static)
			psr->funcs->psr_force_static(psr);
		psr->funcs->psr_enable(psr, allow_active, wait);
	else if ((dmcu != NULL && dmcu->funcs->is_dmcu_initialized(dmcu)) && link->psr_settings.psr_feature_enabled)
	} else if ((dmcu != NULL && dmcu->funcs->is_dmcu_initialized(dmcu)) && link->psr_settings.psr_feature_enabled)
		dmcu->funcs->set_psr_enable(dmcu, allow_active, wait);
	else
		return false;
@@ -2583,16 +2589,16 @@ bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, bool
	return true;
}

bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state)
bool dc_link_get_psr_state(const struct dc_link *link, enum dc_psr_state *state)
{
	struct dc  *dc = link->ctx->dc;
	struct dmcu *dmcu = dc->res_pool->dmcu;
	struct dmub_psr *psr = dc->res_pool->psr;

	if (psr != NULL && link->psr_settings.psr_feature_enabled)
		psr->funcs->psr_get_state(psr, psr_state);
		psr->funcs->psr_get_state(psr, state);
	else if (dmcu != NULL && link->psr_settings.psr_feature_enabled)
		dmcu->funcs->get_psr_state(dmcu, psr_state);
		dmcu->funcs->get_psr_state(dmcu, state);

	return true;
}
Loading