Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a06e0a5 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher
Browse files

drm/amd/display: Remove unnecessary dc_stream vtable



There's no need to have this as a vtable. The vtable was initially
used for stream_adjust_vmin_vmax but the condition checked here
(set_drr) is always true, hence we don't need to assign this
dynamically anymore.

Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Acked-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 2e5fa5ba
Loading
Loading
Loading
Loading
+3 −133
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ static bool create_links(
	return false;
}

static bool stream_adjust_vmin_vmax(struct dc *dc,
bool dc_stream_adjust_vmin_vmax(struct dc *dc,
		struct dc_stream_state **streams, int num_streams,
		int vmin, int vmax)
{
@@ -189,7 +189,7 @@ static bool stream_adjust_vmin_vmax(struct dc *dc,
	return ret;
}

static bool stream_get_crtc_position(struct dc *dc,
bool dc_stream_get_crtc_position(struct dc *dc,
		struct dc_stream_state **streams, int num_streams,
		unsigned int *v_pos, unsigned int *nom_v_pos)
{
@@ -214,45 +214,7 @@ static bool stream_get_crtc_position(struct dc *dc,
	return ret;
}

static bool set_gamut_remap(struct dc *dc, const struct dc_stream_state *stream)
{
	int i = 0;
	bool ret = false;
	struct pipe_ctx *pipes;

	for (i = 0; i < MAX_PIPES; i++) {
		if (dc->current_state->res_ctx.pipe_ctx[i].stream == stream) {
			pipes = &dc->current_state->res_ctx.pipe_ctx[i];
			dc->hwss.program_gamut_remap(pipes);
			ret = true;
		}
	}

	return ret;
}

static bool program_csc_matrix(struct dc *dc, struct dc_stream_state *stream)
{
	int i = 0;
	bool ret = false;
	struct pipe_ctx *pipes;

	for (i = 0; i < MAX_PIPES; i++) {
		if (dc->current_state->res_ctx.pipe_ctx[i].stream
				== stream) {

			pipes = &dc->current_state->res_ctx.pipe_ctx[i];
			dc->hwss.program_csc_matrix(pipes,
			stream->output_color_space,
			stream->csc_color_matrix.matrix);
			ret = true;
		}
	}

	return ret;
}

static void set_static_screen_events(struct dc *dc,
void dc_stream_set_static_screen_events(struct dc *dc,
		struct dc_stream_state **streams,
		int num_streams,
		const struct dc_static_screen_events *events)
@@ -343,100 +305,8 @@ static void set_test_pattern(
			cust_pattern_size);
}

static void set_dither_option(struct dc_stream_state *stream,
		enum dc_dither_option option)
{
	struct bit_depth_reduction_params params;
	struct dc_link *link = stream->status.link;
	struct pipe_ctx *pipes = NULL;
	int i;

	for (i = 0; i < MAX_PIPES; i++) {
		if (link->dc->current_state->res_ctx.pipe_ctx[i].stream ==
				stream) {
			pipes = &link->dc->current_state->res_ctx.pipe_ctx[i];
			break;
		}
	}

	memset(&params, 0, sizeof(params));
	if (!pipes)
		return;
	if (option > DITHER_OPTION_MAX)
		return;

	stream->dither_option = option;

	resource_build_bit_depth_reduction_params(stream,
				&params);
	stream->bit_depth_params = params;
	pipes->stream_res.opp->funcs->
		opp_program_bit_depth_reduction(pipes->stream_res.opp, &params);
}

void set_dpms(
	struct dc *dc,
	struct dc_stream_state *stream,
	bool dpms_off)
{
	struct pipe_ctx *pipe_ctx = NULL;
	int i;

	for (i = 0; i < MAX_PIPES; i++) {
		if (dc->current_state->res_ctx.pipe_ctx[i].stream == stream) {
			pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
			break;
		}
	}

	if (!pipe_ctx) {
		ASSERT(0);
		return;
	}

	if (stream->dpms_off != dpms_off) {
		stream->dpms_off = dpms_off;

		if (dpms_off) {
			core_link_disable_stream(pipe_ctx,
					KEEP_ACQUIRED_RESOURCE);

			dc->hwss.pplib_apply_display_requirements(
					dc, dc->current_state);
		} else {
			dc->hwss.pplib_apply_display_requirements(
					dc, dc->current_state);

			core_link_enable_stream(dc->current_state, pipe_ctx);
		}
	}
}

static void allocate_dc_stream_funcs(struct dc  *dc)
{
	if (dc->hwss.set_drr != NULL) {
		dc->stream_funcs.adjust_vmin_vmax =
				stream_adjust_vmin_vmax;
	}

	dc->stream_funcs.set_static_screen_events =
			set_static_screen_events;

	dc->stream_funcs.get_crtc_position =
			stream_get_crtc_position;

	dc->stream_funcs.set_gamut_remap =
			set_gamut_remap;

	dc->stream_funcs.program_csc_matrix =
			program_csc_matrix;

	dc->stream_funcs.set_dither_option =
			set_dither_option;

	dc->stream_funcs.set_dpms =
			set_dpms;

	dc->link_funcs.set_drive_settings =
			set_drive_settings;

+18 −0
Original line number Diff line number Diff line
@@ -251,6 +251,24 @@ bool dc_stream_set_cursor_position(
	struct dc_stream_state *stream,
	const struct dc_cursor_position *position);

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,
				 unsigned int *v_pos,
				 unsigned int *nom_v_pos);

void dc_stream_set_static_screen_events(struct dc *dc,
					struct dc_stream_state **stream,
					int num_streams,
					const struct dc_static_screen_events *events);


bool dc_stream_adjust_vmin_vmax(struct dc *dc,
				struct dc_stream_state **stream,
				int num_streams,
+30 −54
Original line number Diff line number Diff line
@@ -132,14 +132,6 @@ struct core_freesync {
#define MOD_FREESYNC_TO_CORE(mod_freesync)\
		container_of(mod_freesync, struct core_freesync, public)

static bool check_dc_support(const struct dc *dc)
{
	if (dc->stream_funcs.adjust_vmin_vmax == NULL)
		return false;

	return true;
}

struct mod_freesync *mod_freesync_create(struct dc *dc)
{
	struct core_freesync *core_freesync =
@@ -169,9 +161,6 @@ struct mod_freesync *mod_freesync_create(struct dc *dc)

	core_freesync->dc = dc;

	if (!check_dc_support(dc))
		goto fail_construct;

	/* Create initial module folder in registry for freesync enable data */
	flag.save_per_edid = true;
	flag.save_per_link = false;
@@ -599,8 +588,7 @@ static bool set_freesync_on_streams(struct core_freesync *core_freesync,
				update_stream_freesync_context(core_freesync,
						streams[stream_idx]);

				core_freesync->dc->stream_funcs.
				adjust_vmin_vmax(core_freesync->dc, streams,
				dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
							   num_streams, v_total_min,
							   v_total_max);

@@ -625,8 +613,7 @@ static bool set_freesync_on_streams(struct core_freesync *core_freesync,
						core_freesync,
						streams[stream_idx]);

					core_freesync->dc->stream_funcs.
					adjust_vmin_vmax(
					dc_stream_adjust_vmin_vmax(
						core_freesync->dc, streams,
						num_streams, v_total_nominal,
						v_total_nominal);
@@ -645,9 +632,7 @@ static bool set_freesync_on_streams(struct core_freesync *core_freesync,
					core_freesync,
					streams[stream_idx]);

				core_freesync->dc->stream_funcs.
						adjust_vmin_vmax(
						core_freesync->dc, streams,
				dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
							   num_streams, v_total_nominal,
							   v_total_nominal);

@@ -665,9 +650,7 @@ static bool set_freesync_on_streams(struct core_freesync *core_freesync,
			 * not support freesync because a former stream has
			 * be programmed
			 */
			core_freesync->dc->stream_funcs.
					adjust_vmin_vmax(
					core_freesync->dc, streams,
			dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
						   num_streams, v_total_nominal,
						   v_total_nominal);
			/* Reset the cached variables */
@@ -786,8 +769,7 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
			vmin = inserted_frame_v_total;

			/* Program V_TOTAL */
			core_freesync->dc->stream_funcs.adjust_vmin_vmax(
				core_freesync->dc, streams,
			dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
						   num_streams, vmin, vmax);
		}

@@ -822,17 +804,15 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,
		update_stream_freesync_context(core_freesync, streams[0]);

		/* Program static screen ramp values */
		core_freesync->dc->stream_funcs.adjust_vmin_vmax(
					core_freesync->dc, streams,
		dc_stream_adjust_vmin_vmax(core_freesync->dc, streams,
					   num_streams, v_total,
					   v_total);

		triggers.overlay_update = true;
		triggers.surface_update = true;

		core_freesync->dc->stream_funcs.set_static_screen_events(
					core_freesync->dc, streams,	num_streams,
					&triggers);
		dc_stream_set_static_screen_events(core_freesync->dc, streams,
						   num_streams, &triggers);
	}
}

@@ -916,9 +896,8 @@ void mod_freesync_update_state(struct mod_freesync *mod_freesync,
	triggers.overlay_update = true;
	triggers.surface_update = true;

	core_freesync->dc->stream_funcs.set_static_screen_events(
		core_freesync->dc, streams, num_streams,
		&triggers);
	dc_stream_set_static_screen_events(core_freesync->dc, streams,
					   num_streams, &triggers);

	if (freesync_program_required)
		/* Program freesync according to current state*/
@@ -1084,8 +1063,7 @@ bool mod_freesync_override_min_max(struct mod_freesync *mod_freesync,
				max_refresh);

		/* Program vtotal min/max */
		core_freesync->dc->stream_funcs.adjust_vmin_vmax(
			core_freesync->dc, &streams, 1,
		dc_stream_adjust_vmin_vmax(core_freesync->dc, &streams, 1,
					   state->freesync_range.vmin,
					   state->freesync_range.vmax);
	}
@@ -1163,9 +1141,9 @@ bool mod_freesync_get_v_position(struct mod_freesync *mod_freesync,
	core_freesync = MOD_FREESYNC_TO_CORE(mod_freesync);
	index = map_index_from_stream(core_freesync, stream);

	if (core_freesync->dc->stream_funcs.get_crtc_position(
			core_freesync->dc, &stream, 1,
			&position.vertical_count, &position.nominal_vcount)) {
	if (dc_stream_get_crtc_position(core_freesync->dc, &stream, 1,
					&position.vertical_count,
					&position.nominal_vcount)) {

		*nom_v_pos = position.nominal_vcount;
		*v_pos = position.vertical_count;
@@ -1223,8 +1201,8 @@ void mod_freesync_notify_mode_change(struct mod_freesync *mod_freesync,
			triggers.overlay_update = true;
			triggers.surface_update = true;

			core_freesync->dc->stream_funcs.set_static_screen_events(
				core_freesync->dc, streams, num_streams,
			dc_stream_set_static_screen_events(core_freesync->dc,
							   streams, num_streams,
							   &triggers);
		}
	}
@@ -1424,10 +1402,8 @@ static void apply_fixed_refresh(struct core_freesync *core_freesync,

		vmax = vmin;

		core_freesync->dc->stream_funcs.adjust_vmin_vmax(
				core_freesync->dc, &stream,
				1, vmin,
				vmax);
		dc_stream_adjust_vmin_vmax(core_freesync->dc, &stream,
					   1, vmin, vmax);
	}
}