Commit 26ad78ff authored by Yihan Zhu's avatar Yihan Zhu Committed by Alex Deucher
Browse files

drm/amd/display: MPC basic allocation logic and TMZ



[WHY & HOW]
Adding basic logic to allocate unused RMCM block and TMZ support.

Reviewed-by: default avatarKrunoslav Kovac <krunoslav.kovac@amd.com>
Signed-off-by: default avatarYihan Zhu <Yihan.Zhu@amd.com>
Signed-off-by: default avatarIvan Lipski <ivan.lipski@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 04d57f44
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -976,6 +976,8 @@ static bool dc_construct_ctx(struct dc *dc,
	if (!dc_ctx)
		return false;

	dc_stream_init_rmcm_3dlut(dc);

	dc_ctx->cgs_device = init_params->cgs_device;
	dc_ctx->driver_context = init_params->driver;
	dc_ctx->dc = dc;
+2 −0
Original line number Diff line number Diff line
@@ -427,6 +427,8 @@ enum dc_status dc_state_remove_stream(
		return DC_ERROR_UNEXPECTED;
	}

	dc_stream_release_3dlut_for_stream(dc, stream);

	dc_stream_release(state->streams[i]);
	state->stream_count--;

+67 −0
Original line number Diff line number Diff line
@@ -856,6 +856,73 @@ void dc_stream_log(const struct dc *dc, const struct dc_stream_state *stream)
	}
}

/*
*	dc_stream_get_3dlut()
*	Requirements:
*	1. Is stream already owns an RMCM instance, return it.
*	2. If it doesn't and we don't need to allocate, return NULL.
*	3. If there's a free RMCM instance, assign to stream and return it.
*	4. If no free RMCM instances, return NULL.
*/

struct dc_rmcm_3dlut *dc_stream_get_3dlut_for_stream(
	const struct dc *dc,
	const struct dc_stream_state *stream,
	bool allocate_one)
{
	unsigned int num_rmcm = dc->caps.color.mpc.num_rmcm_3dluts;

	// see if one is allocated for this stream
	for (int i = 0; i < num_rmcm; i++) {
		if (dc->res_pool->rmcm_3dlut[i].isInUse &&
			dc->res_pool->rmcm_3dlut[i].stream == stream)
			return &dc->res_pool->rmcm_3dlut[i];
	}

	//case: not found one, and dont need to allocate
	if (!allocate_one)
		return NULL;

	//see if there is an unused 3dlut, allocate
	for (int i = 0; i < num_rmcm; i++) {
		if (!dc->res_pool->rmcm_3dlut[i].isInUse) {
			dc->res_pool->rmcm_3dlut[i].isInUse = true;
			dc->res_pool->rmcm_3dlut[i].stream = stream;
			return &dc->res_pool->rmcm_3dlut[i];
		}
	}

	//dont have a 3dlut
	return NULL;
}


void dc_stream_release_3dlut_for_stream(
	const struct dc *dc,
	const struct dc_stream_state *stream)
{
	struct dc_rmcm_3dlut *rmcm_3dlut =
		dc_stream_get_3dlut_for_stream(dc, stream, false);

	if (rmcm_3dlut) {
		rmcm_3dlut->isInUse = false;
		rmcm_3dlut->stream  = NULL;
		rmcm_3dlut->protection_bits = 0;
	}
}


void dc_stream_init_rmcm_3dlut(struct dc *dc)
{
	unsigned int num_rmcm = dc->caps.color.mpc.num_rmcm_3dluts;

	for (int i = 0; i < num_rmcm; i++) {
		dc->res_pool->rmcm_3dlut[i].isInUse = false;
		dc->res_pool->rmcm_3dlut[i].stream = NULL;
		dc->res_pool->rmcm_3dlut[i].protection_bits = 0;
	}
}

/*
 * Finds the greatest index in refresh_rate_hz that contains a value <= refresh
 */
+7 −0
Original line number Diff line number Diff line
@@ -246,6 +246,7 @@ struct mpc_color_caps {
	uint16_t ogam_ram : 1;
	uint16_t ocsc : 1;
	uint16_t num_3dluts : 3;
	uint16_t num_rmcm_3dluts : 3;
	uint16_t shared_3d_lut:1;
	struct rom_curve_caps ogam_rom_caps;
	struct lut3d_caps mcm_3d_lut_caps;
@@ -1294,6 +1295,12 @@ union dc_3dlut_state {
};


struct dc_rmcm_3dlut {
	bool isInUse;
	const struct dc_stream_state *stream;
	uint8_t protection_bits;
};

struct dc_3dlut {
	struct kref refcount;
	struct tetrahedral_params lut_3d;
+11 −0
Original line number Diff line number Diff line
@@ -579,6 +579,17 @@ bool dc_stream_set_gamut_remap(struct dc *dc,
bool dc_stream_program_csc_matrix(struct dc *dc,
				  struct dc_stream_state *stream);

struct dc_rmcm_3dlut *dc_stream_get_3dlut_for_stream(
	const struct dc *dc,
	const struct dc_stream_state *stream,
	bool allocate_one);

void dc_stream_release_3dlut_for_stream(
	const struct dc *dc,
	const struct dc_stream_state *stream);

void dc_stream_init_rmcm_3dlut(struct dc *dc);

struct pipe_ctx *dc_stream_get_pipe_ctx(struct dc_stream_state *stream);

void dc_dmub_update_dirty_rect(struct dc *dc,
Loading