Commit 11cc0bdc authored by Meenakshikumar Somasundaram's avatar Meenakshikumar Somasundaram Committed by Alex Deucher
Browse files

drm/amd/display: update link encoder assignment



[Why]
Map a link encoder instance matching stream encoder instance
if possible.

[How]
Get the stream encoder instance and assign the same link
encoder instance if available.

Reviewed-by: default avatarPeiChen Huang <peichen.huang@amd.com>
Signed-off-by: default avatarMeenakshikumar Somasundaram <meenakshikumar.somasundaram@amd.com>
Signed-off-by: default avatarWayne Lin <wayne.lin@amd.com>
Tested-by: default avatarDan Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent dbf58a9d
Loading
Loading
Loading
Loading
+33 −10
Original line number Diff line number Diff line
@@ -2690,17 +2690,40 @@ static inline int find_fixed_dio_link_enc(const struct dc_link *link)
}

static inline int find_free_dio_link_enc(const struct resource_context *res_ctx,
		const struct dc_link *link, const struct resource_pool *pool)
		const struct dc_link *link, const struct resource_pool *pool, struct dc_stream_state *stream)
{
	int i;
	int i, j = -1;
	int stream_enc_inst = -1;
	int enc_count = pool->dig_link_enc_count;

	/* for dpia, check preferred encoder first and then the next one */
	for (i = 0; i < enc_count; i++)
		if (res_ctx->dio_link_enc_ref_cnts[(link->dpia_preferred_eng_id + i) % enc_count] == 0)
	/* Find stream encoder instance for the stream */
	if (stream) {
		for (i = 0; i < pool->pipe_count; i++) {
			if ((res_ctx->pipe_ctx[i].stream == stream) &&
				(res_ctx->pipe_ctx[i].stream_res.stream_enc != NULL)) {
				stream_enc_inst = res_ctx->pipe_ctx[i].stream_res.stream_enc->id;
				break;
			}
		}
	}

	/* Assign dpia preferred > stream enc instance > available */
	for (i = 0; i < enc_count; i++) {
		if (res_ctx->dio_link_enc_ref_cnts[i] == 0) {
			if (j == -1)
				j = i;

	return (i >= 0 && i < enc_count) ? (link->dpia_preferred_eng_id + i) % enc_count : -1;
			if (link->dpia_preferred_eng_id == i) {
				j = i;
				break;
			}

			if (stream_enc_inst == i) {
				j = stream_enc_inst;
			}
		}
	}
	return j;
}

static inline void acquire_dio_link_enc(
@@ -2781,7 +2804,7 @@ static bool add_dio_link_enc_to_ctx(const struct dc *dc,
		retain_dio_link_enc(res_ctx, enc_index);
	} else {
		if (stream->link->is_dig_mapping_flexible)
			enc_index = find_free_dio_link_enc(res_ctx, stream->link, pool);
			enc_index = find_free_dio_link_enc(res_ctx, stream->link, pool, stream);
		else {
			int link_index = 0;

@@ -2791,7 +2814,7 @@ static bool add_dio_link_enc_to_ctx(const struct dc *dc,
			 * one into the acquiring link.
			 */
			if (enc_index >= 0 && is_dio_enc_acquired_by_other_link(stream->link, enc_index, &link_index)) {
				int new_enc_index = find_free_dio_link_enc(res_ctx, dc->links[link_index], pool);
				int new_enc_index = find_free_dio_link_enc(res_ctx, dc->links[link_index], pool, stream);

				if (new_enc_index >= 0)
					swap_dio_link_enc_to_muxable_ctx(context, pool, new_enc_index, enc_index);
@@ -5201,7 +5224,7 @@ struct link_encoder *get_temp_dio_link_enc(
		enc_index = link->eng_id;

	if (enc_index < 0)
		enc_index = find_free_dio_link_enc(res_ctx, link, pool);
		enc_index = find_free_dio_link_enc(res_ctx, link, pool, NULL);

	if (enc_index >= 0)
		link_enc = pool->link_encoders[enc_index];