Commit 98ce7d32 authored by Wenjing Liu's avatar Wenjing Liu Committed by Alex Deucher
Browse files

drm/amd/display: convert link.h functions to function pointer style



[Why & How]
All dc subcomponents should call another dc component via function pointers
stored in a component structure. This is part of dc coding convention since
the beginning. The reason behind this is to improve encapsulation and
polymorphism. The function contract is extracted into a single link service
structure defined in link.h header file and implemented only in link_factory.c instead
of spreading across multiple files in link component file structure.

Reviewed-by: default avatarJun Lei <Jun.Lei@amd.com>
Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: default avatarWenjing Liu <wenjing.liu@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 98ef3418
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7184,13 +7184,14 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector)
	struct edid *edid = amdgpu_dm_connector->edid;
	struct dc_link_settings *verified_link_cap =
			&amdgpu_dm_connector->dc_link->verified_link_cap;
	const struct dc *dc = amdgpu_dm_connector->dc_link->dc;

	encoder = amdgpu_dm_connector_to_encoder(connector);

	if (!drm_edid_is_valid(edid)) {
		amdgpu_dm_connector->num_modes =
				drm_add_modes_noedid(connector, 640, 480);
		if (link_dp_get_encoding_format(verified_link_cap) == DP_128b_132b_ENCODING)
		if (dc->link_srv->dp_get_encoding_format(verified_link_cap) == DP_128b_132b_ENCODING)
			amdgpu_dm_connector->num_modes +=
				drm_add_modes_noedid(connector, 1920, 1080);
	} else {
+1 −1
Original line number Diff line number Diff line
@@ -2802,7 +2802,7 @@ static int psr_read_residency(void *data, u64 *val)
	struct dc_link *link = connector->dc_link;
	u32 residency;

	link_get_psr_residency(link, &residency);
	link->dc->link_srv->edp_get_psr_residency(link, &residency);

	*val = (u64)residency;

+2 −2
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@ void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_m
			if (!edp_link->psr_settings.psr_feature_enabled)
				continue;
			clk_mgr->psr_allow_active_cache = edp_link->psr_settings.psr_allow_active;
			dc_link_set_psr_allow_active(edp_link, &allow_active, false, false, NULL);
			dc->link_srv->edp_set_psr_allow_active(edp_link, &allow_active, false, false, NULL);
		}
	}

@@ -135,7 +135,7 @@ void clk_mgr_optimize_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr)
			edp_link = edp_links[panel_inst];
			if (!edp_link->psr_settings.psr_feature_enabled)
				continue;
			dc_link_set_psr_allow_active(edp_link,
			dc->link_srv->edp_set_psr_allow_active(edp_link,
					&clk_mgr->psr_allow_active_cache, false, false, NULL);
		}
	}
+20 −13
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ static void destroy_links(struct dc *dc)

	for (i = 0; i < dc->link_count; i++) {
		if (NULL != dc->links[i])
			link_destroy(&dc->links[i]);
			dc->link_srv->destroy_link(&dc->links[i]);
	}
}

@@ -217,7 +217,7 @@ static bool create_links(
		link_init_params.connector_index = i;
		link_init_params.link_index = dc->link_count;
		link_init_params.dc = dc;
		link = link_create(&link_init_params);
		link = dc->link_srv->create_link(&link_init_params);

		if (link) {
			dc->links[dc->link_count] = link;
@@ -239,7 +239,7 @@ static bool create_links(
		link_init_params.dc = dc;
		link_init_params.is_dpia_link = true;

		link = link_create(&link_init_params);
		link = dc->link_srv->create_link(&link_init_params);
		if (link) {
			dc->links[dc->link_count] = link;
			link->dc = dc;
@@ -823,6 +823,9 @@ static void dc_destruct(struct dc *dc)

	dc_destroy_resource_pool(dc);

	if (dc->link_srv)
		link_destroy_link_service(&dc->link_srv);

	if (dc->ctx->gpio_service)
		dal_gpio_service_destroy(&dc->ctx->gpio_service);

@@ -982,7 +985,7 @@ static bool dc_construct(struct dc *dc,
		goto fail;
	}

	dc->link_srv = link_get_link_service();
	dc->link_srv = link_create_link_service();

	dc->res_pool = dc_create_resource_pool(dc, init_params, dc_ctx->dce_version);
	if (!dc->res_pool)
@@ -1263,7 +1266,7 @@ static void disable_vbios_mode_if_required(
						pipe->stream_res.pix_clk_params.requested_pix_clk_100hz;

					if (pix_clk_100hz != requested_pix_clk_100hz) {
						link_set_dpms_off(pipe);
						dc->link_srv->set_dpms_off(pipe);
						pipe->stream->dpms_off = false;
					}
				}
@@ -1718,7 +1721,7 @@ bool dc_validate_boot_timing(const struct dc *dc,
		return false;
	}

	if (link_is_edp_ilr_optimization_required(link, crtc_timing)) {
	if (dc->link_srv->edp_is_ilr_optimization_required(link, crtc_timing)) {
		DC_LOG_EVENT_LINK_TRAINING("Seamless boot disabled to optimize eDP link rate\n");
		return false;
	}
@@ -3192,7 +3195,9 @@ static void commit_planes_do_stream_update(struct dc *dc,
				dc->hwss.update_info_frame(pipe_ctx);

				if (dc_is_dp_signal(pipe_ctx->stream->signal))
					link_dp_source_sequence_trace(pipe_ctx->stream->link, DPCD_SOURCE_SEQ_AFTER_UPDATE_INFO_FRAME);
					dc->link_srv->dp_trace_source_sequence(
							pipe_ctx->stream->link,
							DPCD_SOURCE_SEQ_AFTER_UPDATE_INFO_FRAME);
			}

			if (stream_update->hdr_static_metadata &&
@@ -3228,13 +3233,15 @@ static void commit_planes_do_stream_update(struct dc *dc,
				continue;

			if (stream_update->dsc_config)
				link_update_dsc_config(pipe_ctx);
				dc->link_srv->update_dsc_config(pipe_ctx);

			if (stream_update->mst_bw_update) {
				if (stream_update->mst_bw_update->is_increase)
					link_increase_mst_payload(pipe_ctx, stream_update->mst_bw_update->mst_stream_bw);
					dc->link_srv->increase_mst_payload(pipe_ctx,
							stream_update->mst_bw_update->mst_stream_bw);
 				else
					link_reduce_mst_payload(pipe_ctx, stream_update->mst_bw_update->mst_stream_bw);
					dc->link_srv->reduce_mst_payload(pipe_ctx,
							stream_update->mst_bw_update->mst_stream_bw);
 			}

			if (stream_update->pending_test_pattern) {
@@ -3248,7 +3255,7 @@ static void commit_planes_do_stream_update(struct dc *dc,

			if (stream_update->dpms_off) {
				if (*stream_update->dpms_off) {
					link_set_dpms_off(pipe_ctx);
					dc->link_srv->set_dpms_off(pipe_ctx);
					/* for dpms, keep acquired resources*/
					if (pipe_ctx->stream_res.audio && !dc->debug.az_endpoint_mute_only)
						pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
@@ -3258,7 +3265,7 @@ static void commit_planes_do_stream_update(struct dc *dc,
				} else {
					if (get_seamless_boot_stream_count(context) == 0)
						dc->hwss.prepare_bandwidth(dc, dc->current_state);
					link_set_dpms_on(dc->current_state, pipe_ctx);
					dc->link_srv->set_dpms_on(dc->current_state, pipe_ctx);
				}
			}

@@ -4322,7 +4329,7 @@ void dc_resume(struct dc *dc)
	uint32_t i;

	for (i = 0; i < dc->link_count; i++)
		link_resume(dc->links[i]);
		dc->link_srv->resume(dc->links[i]);
}

bool dc_is_dmcu_initialized(struct dc *dc)
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ static bool is_dig_link_enc_stream(struct dc_stream_state *stream)
					/* DIGs do not support DP2.0 streams with 128b/132b encoding. */
					struct dc_link_settings link_settings = {0};

					link_decide_link_settings(stream, &link_settings);
					stream->ctx->dc->link_srv->dp_decide_link_settings(stream, &link_settings);
					if ((link_settings.link_rate >= LINK_RATE_LOW) &&
							link_settings.link_rate <= LINK_RATE_HIGH3) {
						is_dig_stream = true;
Loading