aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/display/dc
diff options
context:
space:
mode:
authorAnthony Koo <Anthony.Koo@amd.com>2018-08-21 14:40:28 -0500
committerAlex Deucher <alexander.deucher@amd.com>2018-08-27 11:10:51 -0500
commit98e6436d3af5fef7ca9b59d865dd5807ede36fb9 (patch)
tree1ece2c3ff69196a3b22b001da1b6d1a8b58cac7e /drivers/gpu/drm/amd/display/dc
parentdrm/amdgpu: fill in amdgpu_dm_remove_sink_from_freesync_module (diff)
downloadlinux-dev-98e6436d3af5fef7ca9b59d865dd5807ede36fb9.tar.xz
linux-dev-98e6436d3af5fef7ca9b59d865dd5807ede36fb9.zip
drm/amd/display: Refactor FreeSync module
Remove dependency on internal sink map and instead use existing stream and plane state Signed-off-by: Anthony Koo <Anthony.Koo@amd.com> Signed-off-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Tony Cheng <Tony.Cheng@amd.com> Acked-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc')
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc.c60
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c3
-rw-r--r--drivers/gpu/drm/amd/display/dc/core/dc_resource.c110
-rw-r--r--drivers/gpu/drm/amd/display/dc/dc_hw_types.h6
-rw-r--r--drivers/gpu/drm/amd/display/dc/dc_stream.h29
-rw-r--r--drivers/gpu/drm/amd/display/dc/dc_types.h22
-rw-r--r--drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c34
-rw-r--r--drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c27
8 files changed, 118 insertions, 173 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 71742635e797..a4df627d6936 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -188,11 +188,9 @@ failed_alloc:
*****************************************************************************
*/
bool dc_stream_adjust_vmin_vmax(struct dc *dc,
- struct dc_stream_state **streams, int num_streams,
- int vmin, int vmax)
+ struct dc_stream_state *stream,
+ struct dc_crtc_timing_adjust *adjust)
{
- /* TODO: Support multiple streams */
- struct dc_stream_state *stream = streams[0];
int i = 0;
bool ret = false;
@@ -200,11 +198,11 @@ bool dc_stream_adjust_vmin_vmax(struct dc *dc,
struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (pipe->stream == stream && pipe->stream_res.stream_enc) {
- dc->hwss.set_drr(&pipe, 1, vmin, vmax);
-
- /* build and update the info frame */
- resource_build_info_frame(pipe);
- dc->hwss.update_info_frame(pipe);
+ pipe->stream->adjust = *adjust;
+ dc->hwss.set_drr(&pipe,
+ 1,
+ adjust->v_total_min,
+ adjust->v_total_max);
ret = true;
}
@@ -217,7 +215,7 @@ bool dc_stream_get_crtc_position(struct dc *dc,
unsigned int *v_pos, unsigned int *nom_v_pos)
{
/* TODO: Support multiple streams */
- struct dc_stream_state *stream = streams[0];
+ const struct dc_stream_state *stream = streams[0];
int i = 0;
bool ret = false;
struct crtc_position position;
@@ -1257,8 +1255,25 @@ static enum surface_update_type check_update_surfaces_for_stream(
if (stream_status == NULL || stream_status->plane_count != surface_count)
return UPDATE_TYPE_FULL;
- if (stream_update)
- return UPDATE_TYPE_FULL;
+ /* some stream updates require passive update */
+ if (stream_update) {
+ if ((stream_update->src.height != 0) &&
+ (stream_update->src.width != 0))
+ return UPDATE_TYPE_FULL;
+
+ if ((stream_update->dst.height != 0) &&
+ (stream_update->dst.width != 0))
+ return UPDATE_TYPE_FULL;
+
+ if (stream_update->out_transfer_func)
+ return UPDATE_TYPE_FULL;
+
+ if (stream_update->hdr_static_metadata)
+ return UPDATE_TYPE_FULL;
+
+ if (stream_update->abm_level)
+ return UPDATE_TYPE_FULL;
+ }
for (i = 0 ; i < surface_count; i++) {
enum surface_update_type type =
@@ -1337,7 +1352,6 @@ static void commit_planes_for_stream(struct dc *dc,
return;
}
- /* Full fe update*/
for (j = 0; j < dc->res_pool->pipe_count; j++) {
struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
@@ -1348,11 +1362,22 @@ static void commit_planes_for_stream(struct dc *dc,
top_pipe_to_program = pipe_ctx;
- if (update_type == UPDATE_TYPE_FAST || !pipe_ctx->plane_state)
+ if (!pipe_ctx->plane_state)
+ continue;
+
+ /* Fast update*/
+ // VRR program can be done as part of FAST UPDATE
+ if (stream_update && stream_update->adjust)
+ dc->hwss.set_drr(&pipe_ctx, 1,
+ stream_update->adjust->v_total_min,
+ stream_update->adjust->v_total_max);
+
+ /* Full fe update*/
+ if (update_type == UPDATE_TYPE_FAST)
continue;
stream_status =
- stream_get_status(context, pipe_ctx->stream);
+ stream_get_status(context, pipe_ctx->stream);
dc->hwss.apply_ctx_for_surface(
dc, pipe_ctx->stream, stream_status->plane_count, context);
@@ -1407,7 +1432,7 @@ static void commit_planes_for_stream(struct dc *dc,
dc->hwss.pipe_control_lock(dc, top_pipe_to_program, false);
}
- if (stream && stream_update && update_type > UPDATE_TYPE_FAST)
+ if (stream && stream_update)
for (j = 0; j < dc->res_pool->pipe_count; j++) {
struct pipe_ctx *pipe_ctx =
&context->res_ctx.pipe_ctx[j];
@@ -1415,7 +1440,8 @@ static void commit_planes_for_stream(struct dc *dc,
if (pipe_ctx->stream != stream)
continue;
- if (stream_update->hdr_static_metadata) {
+ if (stream_update->hdr_static_metadata ||
+ (stream_update->vrr_infopacket)) {
resource_build_info_frame(pipe_ctx);
dc->hwss.update_info_frame(pipe_ctx);
}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index a7553b6d59c2..d91df5ef0cb3 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -2389,6 +2389,9 @@ static bool retrieve_link_cap(struct dc_link *link)
dp_wa_power_up_0010FA(link, dpcd_data, sizeof(dpcd_data));
+ down_strm_port_count.raw = dpcd_data[DP_DOWN_STREAM_PORT_COUNT -
+ DP_DPCD_REV];
+
link->dpcd_caps.allow_invalid_MSA_timing_param =
down_strm_port_count.bits.IGNORE_MSA_TIMING_PARAM;
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 2c348b11b9a5..4468b240929a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -2475,119 +2475,13 @@ static void set_spd_info_packet(
{
/* SPD info packet for FreeSync */
- unsigned char checksum = 0;
- unsigned int idx, payload_size = 0;
-
/* Check if Freesync is supported. Return if false. If true,
* set the corresponding bit in the info packet
*/
- if (stream->freesync_ctx.supported == false)
+ if (!stream->vrr_infopacket.valid)
return;
- if (dc_is_hdmi_signal(stream->signal)) {
-
- /* HEADER */
-
- /* HB0 = Packet Type = 0x83 (Source Product
- * Descriptor InfoFrame)
- */
- info_packet->hb0 = HDMI_INFOFRAME_TYPE_SPD;
-
- /* HB1 = Version = 0x01 */
- info_packet->hb1 = 0x01;
-
- /* HB2 = [Bits 7:5 = 0] [Bits 4:0 = Length = 0x08] */
- info_packet->hb2 = 0x08;
-
- payload_size = 0x08;
-
- } else if (dc_is_dp_signal(stream->signal)) {
-
- /* HEADER */
-
- /* HB0 = Secondary-data Packet ID = 0 - Only non-zero
- * when used to associate audio related info packets
- */
- info_packet->hb0 = 0x00;
-
- /* HB1 = Packet Type = 0x83 (Source Product
- * Descriptor InfoFrame)
- */
- info_packet->hb1 = HDMI_INFOFRAME_TYPE_SPD;
-
- /* HB2 = [Bits 7:0 = Least significant eight bits -
- * For INFOFRAME, the value must be 1Bh]
- */
- info_packet->hb2 = 0x1B;
-
- /* HB3 = [Bits 7:2 = INFOFRAME SDP Version Number = 0x1]
- * [Bits 1:0 = Most significant two bits = 0x00]
- */
- info_packet->hb3 = 0x04;
-
- payload_size = 0x1B;
- }
-
- /* PB1 = 0x1A (24bit AMD IEEE OUI (0x00001A) - Byte 0) */
- info_packet->sb[1] = 0x1A;
-
- /* PB2 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 1) */
- info_packet->sb[2] = 0x00;
-
- /* PB3 = 0x00 (24bit AMD IEEE OUI (0x00001A) - Byte 2) */
- info_packet->sb[3] = 0x00;
-
- /* PB4 = Reserved */
- info_packet->sb[4] = 0x00;
-
- /* PB5 = Reserved */
- info_packet->sb[5] = 0x00;
-
- /* PB6 = [Bits 7:3 = Reserved] */
- info_packet->sb[6] = 0x00;
-
- if (stream->freesync_ctx.supported == true)
- /* PB6 = [Bit 0 = FreeSync Supported] */
- info_packet->sb[6] |= 0x01;
-
- if (stream->freesync_ctx.enabled == true)
- /* PB6 = [Bit 1 = FreeSync Enabled] */
- info_packet->sb[6] |= 0x02;
-
- if (stream->freesync_ctx.active == true)
- /* PB6 = [Bit 2 = FreeSync Active] */
- info_packet->sb[6] |= 0x04;
-
- /* PB7 = FreeSync Minimum refresh rate (Hz) */
- info_packet->sb[7] = (unsigned char) (stream->freesync_ctx.
- min_refresh_in_micro_hz / 1000000);
-
- /* PB8 = FreeSync Maximum refresh rate (Hz)
- *
- * Note: We do not use the maximum capable refresh rate
- * of the panel, because we should never go above the field
- * rate of the mode timing set.
- */
- info_packet->sb[8] = (unsigned char) (stream->freesync_ctx.
- nominal_refresh_in_micro_hz / 1000000);
-
- /* PB9 - PB27 = Reserved */
- for (idx = 9; idx <= 27; idx++)
- info_packet->sb[idx] = 0x00;
-
- /* Calculate checksum */
- checksum += info_packet->hb0;
- checksum += info_packet->hb1;
- checksum += info_packet->hb2;
- checksum += info_packet->hb3;
-
- for (idx = 1; idx <= payload_size; idx++)
- checksum += info_packet->sb[idx];
-
- /* PB0 = Checksum (one byte complement) */
- info_packet->sb[0] = (unsigned char) (0x100 - checksum);
-
- info_packet->valid = true;
+ *info_packet = stream->vrr_infopacket;
}
static void set_hdr_static_info_packet(
diff --git a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
index b789cb2b354b..57f57cf0fe2a 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_hw_types.h
@@ -708,12 +708,6 @@ struct crtc_trigger_info {
enum trigger_delay delay;
};
-enum vrr_state {
- VRR_STATE_OFF = 0,
- VRR_STATE_VARIABLE,
- VRR_STATE_FIXED,
-};
-
struct dc_crtc_timing_adjust {
uint32_t v_total_min;
uint32_t v_total_max;
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h b/drivers/gpu/drm/amd/display/dc/dc_stream.h
index cbfe418006cb..67101a525e3d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_stream.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h
@@ -45,19 +45,25 @@ struct dc_stream_status {
struct dc_link *link;
};
+// TODO: References to this needs to be removed..
+struct freesync_context {
+ bool dummy;
+};
+
struct dc_stream_state {
struct dc_sink *sink;
struct dc_crtc_timing timing;
- struct dc_crtc_timing_adjust timing_adjust;
- struct vrr_params vrr_params;
+ struct dc_crtc_timing_adjust adjust;
+ struct dc_info_packet vrr_infopacket;
struct rect src; /* composition area */
struct rect dst; /* stream addressable area */
- struct audio_info audio_info;
-
+ // TODO: References to this needs to be removed..
struct freesync_context freesync_ctx;
+ struct audio_info audio_info;
+
struct dc_info_packet hdr_static_metadata;
PHYSICAL_ADDRESS_LOC dmdata_address;
bool use_dynamic_meta;
@@ -120,6 +126,8 @@ struct dc_stream_update {
unsigned int *abm_level;
unsigned long long *periodic_fn_vsync_delta;
+ struct dc_crtc_timing_adjust *adjust;
+ struct dc_info_packet *vrr_infopacket;
};
bool dc_is_stream_unchanged(
@@ -258,10 +266,8 @@ bool dc_stream_set_cursor_position(
bool dc_stream_adjust_vmin_vmax(struct dc *dc,
- struct dc_stream_state **stream,
- int num_streams,
- int vmin,
- int vmax);
+ struct dc_stream_state *stream,
+ struct dc_crtc_timing_adjust *adjust);
bool dc_stream_get_crtc_position(struct dc *dc,
struct dc_stream_state **stream,
@@ -288,13 +294,6 @@ void dc_stream_set_static_screen_events(struct dc *dc,
void dc_stream_set_dither_option(struct dc_stream_state *stream,
enum dc_dither_option option);
-
-bool dc_stream_adjust_vmin_vmax(struct dc *dc,
- struct dc_stream_state **stream,
- int num_streams,
- int vmin,
- int vmax);
-
bool dc_stream_get_crtc_position(struct dc *dc,
struct dc_stream_state **stream,
int num_streams,
diff --git a/drivers/gpu/drm/amd/display/dc/dc_types.h b/drivers/gpu/drm/amd/display/dc/dc_types.h
index 8c6eb78b0c3b..58a6ef80a60e 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_types.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_types.h
@@ -513,13 +513,11 @@ struct audio_info {
struct audio_mode modes[DC_MAX_AUDIO_DESC_COUNT];
};
-struct vrr_params {
- enum vrr_state state;
- uint32_t window_min;
- uint32_t window_max;
- uint32_t inserted_frame_duration_in_us;
- uint32_t frames_to_insert;
- uint32_t frame_counter;
+enum dc_infoframe_type {
+ DC_HDMI_INFOFRAME_TYPE_VENDOR = 0x81,
+ DC_HDMI_INFOFRAME_TYPE_AVI = 0x82,
+ DC_HDMI_INFOFRAME_TYPE_SPD = 0x83,
+ DC_HDMI_INFOFRAME_TYPE_AUDIO = 0x84,
};
struct dc_info_packet {
@@ -539,16 +537,6 @@ struct dc_plane_flip_time {
unsigned int prev_update_time_in_us;
};
-// Will combine with vrr_params at some point.
-struct freesync_context {
- bool supported;
- bool enabled;
- bool active;
-
- unsigned int min_refresh_in_micro_hz;
- unsigned int nominal_refresh_in_micro_hz;
-};
-
struct psr_config {
unsigned char psr_version;
unsigned int psr_rfb_setup_time;
diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
index 2f2c5155c5aa..ae4792494fe7 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
@@ -1286,6 +1286,8 @@ static enum dc_status dce110_enable_stream_timing(
struct pipe_ctx *pipe_ctx_old = &dc->current_state->res_ctx.
pipe_ctx[pipe_ctx->pipe_idx];
struct tg_color black_color = {0};
+ struct drr_params params = {0};
+ unsigned int event_triggers = 0;
if (!pipe_ctx_old->stream) {
@@ -1315,9 +1317,19 @@ static enum dc_status dce110_enable_stream_timing(
&stream->timing,
true);
- pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
- pipe_ctx->stream_res.tg,
- 0x182);
+ params.vertical_total_min = stream->adjust.v_total_min;
+ params.vertical_total_max = stream->adjust.v_total_max;
+ if (pipe_ctx->stream_res.tg->funcs->set_drr)
+ pipe_ctx->stream_res.tg->funcs->set_drr(
+ pipe_ctx->stream_res.tg, &params);
+
+ // DRR should set trigger event to monitor surface update event
+ if (stream->adjust.v_total_min != 0 &&
+ stream->adjust.v_total_max != 0)
+ event_triggers = 0x80;
+ if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control)
+ pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
+ pipe_ctx->stream_res.tg, event_triggers);
}
if (!pipe_ctx_old->stream) {
@@ -1328,8 +1340,6 @@ static enum dc_status dce110_enable_stream_timing(
}
}
-
-
return DC_OK;
}
@@ -1719,16 +1729,24 @@ static void set_drr(struct pipe_ctx **pipe_ctx,
{
int i = 0;
struct drr_params params = {0};
+ // DRR should set trigger event to monitor surface update event
+ unsigned int event_triggers = 0x80;
params.vertical_total_max = vmax;
params.vertical_total_min = vmin;
/* TODO: If multiple pipes are to be supported, you need
- * some GSL stuff
+ * some GSL stuff. Static screen triggers may be programmed differently
+ * as well.
*/
-
for (i = 0; i < num_pipes; i++) {
- pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, &params);
+ pipe_ctx[i]->stream_res.tg->funcs->set_drr(
+ pipe_ctx[i]->stream_res.tg, &params);
+
+ if (vmax != 0 && vmin != 0)
+ pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
+ pipe_ctx[i]->stream_res.tg,
+ event_triggers);
}
}
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index 6d27f1db3c69..4b8bedb625b4 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -631,6 +631,8 @@ static enum dc_status dcn10_enable_stream_timing(
struct dc_stream_state *stream = pipe_ctx->stream;
enum dc_color_space color_space;
struct tg_color black_color = {0};
+ struct drr_params params = {0};
+ unsigned int event_triggers = 0;
/* by upper caller loop, pipe0 is parent pipe and be called first.
* back end is set up by for pipe0. Other children pipe share back end
@@ -698,6 +700,19 @@ static enum dc_status dcn10_enable_stream_timing(
return DC_ERROR_UNEXPECTED;
}
+ params.vertical_total_min = stream->adjust.v_total_min;
+ params.vertical_total_max = stream->adjust.v_total_max;
+ if (pipe_ctx->stream_res.tg->funcs->set_drr)
+ pipe_ctx->stream_res.tg->funcs->set_drr(
+ pipe_ctx->stream_res.tg, &params);
+
+ // DRR should set trigger event to monitor surface update event
+ if (stream->adjust.v_total_min != 0 && stream->adjust.v_total_max != 0)
+ event_triggers = 0x80;
+ if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control)
+ pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
+ pipe_ctx->stream_res.tg, event_triggers);
+
/* TODO program crtc source select for non-virtual signal*/
/* TODO program FMT */
/* TODO setup link_enc */
@@ -2399,15 +2414,23 @@ static void set_drr(struct pipe_ctx **pipe_ctx,
{
int i = 0;
struct drr_params params = {0};
+ // DRR should set trigger event to monitor surface update event
+ unsigned int event_triggers = 0x80;
params.vertical_total_max = vmax;
params.vertical_total_min = vmin;
/* TODO: If multiple pipes are to be supported, you need
- * some GSL stuff
+ * some GSL stuff. Static screen triggers may be programmed differently
+ * as well.
*/
for (i = 0; i < num_pipes; i++) {
- pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, &params);
+ pipe_ctx[i]->stream_res.tg->funcs->set_drr(
+ pipe_ctx[i]->stream_res.tg, &params);
+ if (vmax != 0 && vmin != 0)
+ pipe_ctx[i]->stream_res.tg->funcs->set_static_screen_control(
+ pipe_ctx[i]->stream_res.tg,
+ event_triggers);
}
}