Commit d1ebfdd8 authored by Wyatt Wood's avatar Wyatt Wood Committed by Alex Deucher

drm/amd/display: Unify psr feature flags

[Why]
As it stands, psr has feature flags in dm, stream, and link. Most are
not defined well enough, and different dm layers have different uses for
these same flags.

[How]
We define a new structure called psr_settings in dc_link that will hold
the following psr feature flags:

psr_feature_enable - psr is supported
psr_allow_active - psr is currently active
psr_version - internal psr version supported
psr_frame_capture_indication_req
psr_sdp_transmit_line_num_deadline
The last two flags were moved out of the power module
for the purposes of consolidating psr flags.
Their use is already well-defined.

Psr caps reported by sink will also be stored in dc_link,
in dpcd_caps.psr_caps.
Signed-off-by: default avatarWyatt Wood <wyatt.wood@amd.com>
Reviewed-by: default avatarAnthony Koo <Anthony.Koo@amd.com>
Acked-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 44efb784
...@@ -4330,14 +4330,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector, ...@@ -4330,14 +4330,10 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A)
mod_build_hf_vsif_infopacket(stream, &stream->vsp_infopacket, false, false); mod_build_hf_vsif_infopacket(stream, &stream->vsp_infopacket, false, false);
if (stream->link->psr_feature_enabled) { if (stream->link->psr_settings.psr_feature_enabled) {
struct dc *core_dc = stream->link->ctx->dc; struct dc *core_dc = stream->link->ctx->dc;
if (dc_is_dmcu_initialized(core_dc)) { if (dc_is_dmcu_initialized(core_dc)) {
struct dmcu *dmcu = core_dc->res_pool->dmcu;
stream->psr_version = dmcu->dmcu_version.psr_version;
// //
// should decide stream support vsc sdp colorimetry capability // should decide stream support vsc sdp colorimetry capability
// before building vsc info packet // before building vsc info packet
...@@ -6824,7 +6820,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, ...@@ -6824,7 +6820,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
} }
mutex_lock(&dm->dc_lock); mutex_lock(&dm->dc_lock);
if ((acrtc_state->update_type > UPDATE_TYPE_FAST) && if ((acrtc_state->update_type > UPDATE_TYPE_FAST) &&
acrtc_state->stream->link->psr_allow_active) acrtc_state->stream->link->psr_settings.psr_allow_active)
amdgpu_dm_psr_disable(acrtc_state->stream); amdgpu_dm_psr_disable(acrtc_state->stream);
dc_commit_updates_for_stream(dm->dc, dc_commit_updates_for_stream(dm->dc,
...@@ -6835,12 +6831,12 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, ...@@ -6835,12 +6831,12 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
dc_state); dc_state);
if ((acrtc_state->update_type > UPDATE_TYPE_FAST) && if ((acrtc_state->update_type > UPDATE_TYPE_FAST) &&
acrtc_state->stream->psr_version && acrtc_state->stream->link->psr_settings.psr_version != PSR_VERSION_UNSUPPORTED &&
!acrtc_state->stream->link->psr_feature_enabled) !acrtc_state->stream->link->psr_settings.psr_feature_enabled)
amdgpu_dm_link_setup_psr(acrtc_state->stream); amdgpu_dm_link_setup_psr(acrtc_state->stream);
else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) && else if ((acrtc_state->update_type == UPDATE_TYPE_FAST) &&
acrtc_state->stream->link->psr_feature_enabled && acrtc_state->stream->link->psr_settings.psr_feature_enabled &&
!acrtc_state->stream->link->psr_allow_active) { !acrtc_state->stream->link->psr_settings.psr_allow_active) {
amdgpu_dm_psr_enable(acrtc_state->stream); amdgpu_dm_psr_enable(acrtc_state->stream);
} }
...@@ -7154,7 +7150,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) ...@@ -7154,7 +7150,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
DRM_DEBUG_DRIVER("Atomic commit: RESET. crtc id %d:[%p]\n", acrtc->crtc_id, acrtc); DRM_DEBUG_DRIVER("Atomic commit: RESET. crtc id %d:[%p]\n", acrtc->crtc_id, acrtc);
/* i.e. reset mode */ /* i.e. reset mode */
if (dm_old_crtc_state->stream) { if (dm_old_crtc_state->stream) {
if (dm_old_crtc_state->stream->link->psr_allow_active) if (dm_old_crtc_state->stream->link->psr_settings.psr_allow_active)
amdgpu_dm_psr_disable(dm_old_crtc_state->stream); amdgpu_dm_psr_disable(dm_old_crtc_state->stream);
remove_stream(adev, acrtc, dm_old_crtc_state->stream); remove_stream(adev, acrtc, dm_old_crtc_state->stream);
...@@ -8603,8 +8599,17 @@ static void amdgpu_dm_set_psr_caps(struct dc_link *link) ...@@ -8603,8 +8599,17 @@ static void amdgpu_dm_set_psr_caps(struct dc_link *link)
return; return;
if (dm_helpers_dp_read_dpcd(NULL, link, DP_PSR_SUPPORT, if (dm_helpers_dp_read_dpcd(NULL, link, DP_PSR_SUPPORT,
dpcd_data, sizeof(dpcd_data))) { dpcd_data, sizeof(dpcd_data))) {
link->psr_feature_enabled = dpcd_data[0] ? true:false; link->dpcd_caps.psr_caps.psr_version = dpcd_data[0];
DRM_INFO("PSR support:%d\n", link->psr_feature_enabled);
if (dpcd_data[0] == 0) {
link->psr_settings.psr_version = PSR_VERSION_UNSUPPORTED;
link->psr_settings.psr_feature_enabled = false;
} else {
link->psr_settings.psr_version = PSR_VERSION_1;
link->psr_settings.psr_feature_enabled = true;
}
DRM_INFO("PSR support:%d\n", link->psr_settings.psr_feature_enabled);
} }
} }
...@@ -8628,7 +8633,7 @@ static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream) ...@@ -8628,7 +8633,7 @@ static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream)
link = stream->link; link = stream->link;
dc = link->ctx->dc; dc = link->ctx->dc;
psr_config.psr_version = dc->res_pool->dmcu->dmcu_version.psr_version; psr_config.psr_version = link->dpcd_caps.psr_caps.psr_version;
if (psr_config.psr_version > 0) { if (psr_config.psr_version > 0) {
psr_config.psr_exit_link_training_required = 0x1; psr_config.psr_exit_link_training_required = 0x1;
...@@ -8640,7 +8645,7 @@ static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream) ...@@ -8640,7 +8645,7 @@ static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream)
ret = dc_link_setup_psr(link, stream, &psr_config, &psr_context); ret = dc_link_setup_psr(link, stream, &psr_config, &psr_context);
} }
DRM_DEBUG_DRIVER("PSR link: %d\n", link->psr_feature_enabled); DRM_DEBUG_DRIVER("PSR link: %d\n", link->psr_settings.psr_feature_enabled);
return ret; return ret;
} }
......
...@@ -90,7 +90,7 @@ void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_m ...@@ -90,7 +90,7 @@ void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_m
dc->hwss.exit_optimized_pwr_state(dc, dc->current_state); dc->hwss.exit_optimized_pwr_state(dc, dc->current_state);
if (edp_link) { if (edp_link) {
clk_mgr->psr_allow_active_cache = edp_link->psr_allow_active; 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);
} }
......
...@@ -66,6 +66,8 @@ ...@@ -66,6 +66,8 @@
#include "dce/dce_i2c.h" #include "dce/dce_i2c.h"
#include "dmub/inc/dmub_cmd_dal.h"
#define CTX \ #define CTX \
dc->ctx dc->ctx
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include "dmcu.h" #include "dmcu.h"
#include "hw/clk_mgr.h" #include "hw/clk_mgr.h"
#include "dce/dmub_psr.h" #include "dce/dmub_psr.h"
#include "dmub/inc/dmub_cmd_dal.h"
#define DC_LOGGER_INIT(logger) #define DC_LOGGER_INIT(logger)
...@@ -1529,6 +1530,8 @@ static bool dc_link_construct(struct dc_link *link, ...@@ -1529,6 +1530,8 @@ static bool dc_link_construct(struct dc_link *link,
*/ */
program_hpd_filter(link); program_hpd_filter(link);
link->psr_settings.psr_version = PSR_VERSION_UNSUPPORTED;
return true; return true;
device_tag_fail: device_tag_fail:
link->link_enc->funcs->destroy(&link->link_enc); link->link_enc->funcs->destroy(&link->link_enc);
...@@ -2521,12 +2524,12 @@ bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, bool ...@@ -2521,12 +2524,12 @@ bool dc_link_set_psr_allow_active(struct dc_link *link, bool allow_active, bool
struct dmcu *dmcu = dc->res_pool->dmcu; struct dmcu *dmcu = dc->res_pool->dmcu;
struct dmub_psr *psr = dc->res_pool->psr; struct dmub_psr *psr = dc->res_pool->psr;
if (psr != NULL && link->psr_feature_enabled) if (psr != NULL && link->psr_settings.psr_feature_enabled)
psr->funcs->psr_enable(psr, allow_active); psr->funcs->psr_enable(psr, allow_active);
else if ((dmcu != NULL && dmcu->funcs->is_dmcu_initialized(dmcu)) && link->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); dmcu->funcs->set_psr_enable(dmcu, allow_active, wait);
link->psr_allow_active = allow_active; link->psr_settings.psr_allow_active = allow_active;
return true; return true;
} }
...@@ -2537,9 +2540,9 @@ bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state) ...@@ -2537,9 +2540,9 @@ bool dc_link_get_psr_state(const struct dc_link *link, uint32_t *psr_state)
struct dmcu *dmcu = dc->res_pool->dmcu; struct dmcu *dmcu = dc->res_pool->dmcu;
struct dmub_psr *psr = dc->res_pool->psr; struct dmub_psr *psr = dc->res_pool->psr;
if (psr != NULL && link->psr_feature_enabled) if (psr != NULL && link->psr_settings.psr_feature_enabled)
psr->funcs->psr_get_state(psr, psr_state); psr->funcs->psr_get_state(psr, psr_state);
else if (dmcu != NULL && link->psr_feature_enabled) else if (dmcu != NULL && link->psr_settings.psr_feature_enabled)
dmcu->funcs->get_psr_state(dmcu, psr_state); dmcu->funcs->get_psr_state(dmcu, psr_state);
return true; return true;
...@@ -2710,14 +2713,14 @@ bool dc_link_setup_psr(struct dc_link *link, ...@@ -2710,14 +2713,14 @@ bool dc_link_setup_psr(struct dc_link *link,
psr_context->frame_delay = 0; psr_context->frame_delay = 0;
if (psr) if (psr)
link->psr_feature_enabled = psr->funcs->psr_copy_settings(psr, link, psr_context); link->psr_settings.psr_feature_enabled = psr->funcs->psr_copy_settings(psr, link, psr_context);
else else
link->psr_feature_enabled = dmcu->funcs->setup_psr(dmcu, link, psr_context); link->psr_settings.psr_feature_enabled = dmcu->funcs->setup_psr(dmcu, link, psr_context);
/* psr_enabled == 0 indicates setup_psr did not succeed, but this /* psr_enabled == 0 indicates setup_psr did not succeed, but this
* should not happen since firmware should be running at this point * should not happen since firmware should be running at this point
*/ */
if (link->psr_feature_enabled == 0) if (link->psr_settings.psr_feature_enabled == 0)
ASSERT(0); ASSERT(0);
return true; return true;
......
...@@ -2417,7 +2417,7 @@ static bool handle_hpd_irq_psr_sink(struct dc_link *link) ...@@ -2417,7 +2417,7 @@ static bool handle_hpd_irq_psr_sink(struct dc_link *link)
{ {
union dpcd_psr_configuration psr_configuration; union dpcd_psr_configuration psr_configuration;
if (!link->psr_feature_enabled) if (!link->psr_settings.psr_feature_enabled)
return false; return false;
dm_helpers_dp_read_dpcd( dm_helpers_dp_read_dpcd(
......
...@@ -990,6 +990,7 @@ struct dpcd_caps { ...@@ -990,6 +990,7 @@ struct dpcd_caps {
union dpcd_fec_capability fec_cap; union dpcd_fec_capability fec_cap;
struct dpcd_dsc_capabilities dsc_caps; struct dpcd_dsc_capabilities dsc_caps;
struct dc_lttpr_caps lttpr_caps; struct dc_lttpr_caps lttpr_caps;
struct psr_caps psr_caps;
}; };
......
...@@ -740,5 +740,11 @@ struct dpcd_dsc_capabilities { ...@@ -740,5 +740,11 @@ struct dpcd_dsc_capabilities {
union dpcd_dsc_ext_capabilities dsc_ext_caps; union dpcd_dsc_ext_capabilities dsc_ext_caps;
}; };
/* These parameters are from PSR capabilities reported by Sink DPCD */
struct psr_caps {
unsigned char psr_version;
unsigned int psr_rfb_setup_time;
bool psr_exit_link_training_required;
};
#endif /* DC_DP_TYPES_H */ #endif /* DC_DP_TYPES_H */
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "dc.h" #include "dc.h"
#include "dc_types.h" #include "dc_types.h"
#include "grph_object_defs.h" #include "grph_object_defs.h"
#include "dmub/inc/dmub_cmd_dal.h"
enum dc_link_fec_state { enum dc_link_fec_state {
dc_link_fec_not_ready, dc_link_fec_not_ready,
...@@ -66,6 +67,22 @@ struct time_stamp { ...@@ -66,6 +67,22 @@ struct time_stamp {
struct link_trace { struct link_trace {
struct time_stamp time_stamp; struct time_stamp time_stamp;
}; };
/* PSR feature flags */
struct psr_settings {
bool psr_feature_enabled; // PSR is supported by sink
bool psr_allow_active; // PSR is currently active
enum psr_version psr_version; // Internal PSR version, determined based on DPCD
/* These parameters are calculated in Driver,
* based on display timing and Sink capabilities.
* If VBLANK region is too small and Sink takes a long time
* to set up RFB, it may take an extra frame to enter PSR state.
*/
bool psr_frame_capture_indication_req;
unsigned int psr_sdp_transmit_line_num_deadline;
};
/* /*
* A link contains one or more sinks and their connected status. * A link contains one or more sinks and their connected status.
* The currently active signal type (HDMI, DP-SST, DP-MST) is also reported. * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
...@@ -130,10 +147,10 @@ struct dc_link { ...@@ -130,10 +147,10 @@ struct dc_link {
struct hdcp_caps hdcp_caps; struct hdcp_caps hdcp_caps;
#endif #endif
enum edp_revision edp_revision; enum edp_revision edp_revision;
bool psr_feature_enabled;
bool psr_allow_active;
union dpcd_sink_ext_caps dpcd_sink_ext_caps; union dpcd_sink_ext_caps dpcd_sink_ext_caps;
struct psr_settings psr_settings;
/* MST record stream using this link */ /* MST record stream using this link */
struct link_flags { struct link_flags {
bool dp_keep_receiver_powered; bool dp_keep_receiver_powered;
......
...@@ -167,8 +167,6 @@ struct dc_stream_state { ...@@ -167,8 +167,6 @@ struct dc_stream_state {
/* TODO: custom INFO packets */ /* TODO: custom INFO packets */
/* TODO: ABM info (DMCU) */ /* TODO: ABM info (DMCU) */
/* PSR info */
unsigned char psr_version;
/* TODO: CEA VIC */ /* TODO: CEA VIC */
/* DMCU info */ /* DMCU info */
......
...@@ -53,16 +53,15 @@ static bool dmub_psr_set_version(struct dmub_psr *dmub, struct dc_stream_state * ...@@ -53,16 +53,15 @@ static bool dmub_psr_set_version(struct dmub_psr *dmub, struct dc_stream_state *
union dmub_rb_cmd cmd; union dmub_rb_cmd cmd;
struct dc_context *dc = dmub->ctx; struct dc_context *dc = dmub->ctx;
if (stream->link->psr_settings.psr_version == PSR_VERSION_UNSUPPORTED)
return false;
cmd.psr_set_version.header.type = DMUB_CMD__PSR; cmd.psr_set_version.header.type = DMUB_CMD__PSR;
cmd.psr_set_version.header.sub_type = DMUB_CMD__PSR_SET_VERSION; cmd.psr_set_version.header.sub_type = DMUB_CMD__PSR_SET_VERSION;
cmd.psr_set_version.psr_set_version_data.version = stream->link->psr_settings.psr_version;
cmd.psr_set_version.header.payload_bytes = sizeof(struct dmub_cmd_psr_set_version_data);
if (stream->psr_version == 0x0) // Unsupported dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.psr_set_version.header);
return false;
else if (stream->psr_version == 0x1)
cmd.psr_set_version.psr_set_version_data.version = PSR_VERSION_1;
cmd.psr_enable.header.payload_bytes = sizeof(struct dmub_cmd_psr_set_version_data);
dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd.psr_enable.header);
dc_dmub_srv_cmd_execute(dc->dmub_srv); dc_dmub_srv_cmd_execute(dc->dmub_srv);
dc_dmub_srv_wait_idle(dc->dmub_srv); dc_dmub_srv_wait_idle(dc->dmub_srv);
......
...@@ -1432,7 +1432,7 @@ static enum dc_status apply_single_controller_ctx_to_hw( ...@@ -1432,7 +1432,7 @@ static enum dc_status apply_single_controller_ctx_to_hw(
pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->bottom_pipe != 0; pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->bottom_pipe != 0;
pipe_ctx->stream->link->psr_feature_enabled = false; pipe_ctx->stream->link->psr_settings.psr_feature_enabled = false;
return DC_OK; return DC_OK;
} }
...@@ -1838,7 +1838,7 @@ static bool should_enable_fbc(struct dc *dc, ...@@ -1838,7 +1838,7 @@ static bool should_enable_fbc(struct dc *dc,
return false; return false;
/* PSR should not be enabled */ /* PSR should not be enabled */
if (pipe_ctx->stream->link->psr_feature_enabled) if (pipe_ctx->stream->link->psr_settings.psr_feature_enabled)
return false; return false;
/* Nothing to compress */ /* Nothing to compress */
......
...@@ -41,6 +41,7 @@ enum dmub_cmd_psr_type { ...@@ -41,6 +41,7 @@ enum dmub_cmd_psr_type {
enum psr_version { enum psr_version {
PSR_VERSION_1 = 0, PSR_VERSION_1 = 0,
PSR_VERSION_UNSUPPORTED = 0xFFFFFFFF,
}; };
enum dmub_cmd_abm_type { enum dmub_cmd_abm_type {
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "mod_shared.h" #include "mod_shared.h"
#include "mod_freesync.h" #include "mod_freesync.h"
#include "dc.h" #include "dc.h"
#include "dmub/inc/dmub_cmd_dal.h"
enum vsc_packet_revision { enum vsc_packet_revision {
vsc_packet_undefined = 0, vsc_packet_undefined = 0,
...@@ -144,7 +145,7 @@ void mod_build_vsc_infopacket(const struct dc_stream_state *stream, ...@@ -144,7 +145,7 @@ void mod_build_vsc_infopacket(const struct dc_stream_state *stream,
} }
/*VSC packet set to 2 when DP revision >= 1.2*/ /*VSC packet set to 2 when DP revision >= 1.2*/
if (stream->psr_version != 0) if (stream->link->psr_settings.psr_version != PSR_VERSION_UNSUPPORTED)
vsc_packet_revision = vsc_packet_rev2; vsc_packet_revision = vsc_packet_rev2;
/* Update to revision 5 for extended colorimetry support */ /* Update to revision 5 for extended colorimetry support */
......
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