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

Commit 9345d987 authored by Andrey Grodzovsky's avatar Andrey Grodzovsky Committed by Alex Deucher
Browse files

drm/amd/display: Move stream validations into seperate function.



Stateless streams validations (not require resource population)
moved into hook to be called directly from DM.

Call dc_validate_stream be before validate_with_context for
non Linux APIs

Signed-off-by: default avatarAndrey Grodzovsky <Andrey.Grodzovsky@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Reviewed-by: default avatarTony Cheng <Tony.Cheng@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6be425f3
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -664,6 +664,20 @@ static bool is_validation_required(
	return false;
}

static bool validate_streams (
		const struct dc *dc,
		const struct dc_validation_set set[],
		int set_count)
{
	int i;

	for (i = 0; i < set_count; i++)
		if (!dc_validate_stream(dc, set[i].stream))
			return false;

	return true;
}

struct validate_context *dc_get_validate_context(
		const struct dc *dc,
		const struct dc_validation_set set[],
@@ -673,6 +687,7 @@ struct validate_context *dc_get_validate_context(
	enum dc_status result = DC_ERROR_UNEXPECTED;
	struct validate_context *context;


	context = dm_alloc(sizeof(struct validate_context));
	if (context == NULL)
		goto context_alloc_fail;
@@ -711,6 +726,9 @@ bool dc_validate_resources(
	enum dc_status result = DC_ERROR_UNEXPECTED;
	struct validate_context *context;

	if (!validate_streams(dc, set, set_count))
		return false;

	context = dm_alloc(sizeof(struct validate_context));
	if (context == NULL)
		goto context_alloc_fail;
@@ -742,6 +760,9 @@ bool dc_validate_guaranteed(
	enum dc_status result = DC_ERROR_UNEXPECTED;
	struct validate_context *context;

	if (!dc_validate_stream(dc, stream))
		return false;

	context = dm_alloc(sizeof(struct validate_context));
	if (context == NULL)
		goto context_alloc_fail;
@@ -1044,6 +1065,9 @@ bool dc_commit_streams(

	}

	if (!validate_streams(dc, set, stream_count))
		return false;

	context = dm_alloc(sizeof(struct validate_context));
	if (context == NULL)
		goto context_alloc_fail;
+43 −18
Original line number Diff line number Diff line
@@ -1416,13 +1416,8 @@ static int get_norm_pix_clk(const struct dc_crtc_timing *timing)
	return normalized_pix_clk;
}

static void calculate_phy_pix_clks(struct validate_context *context)
static void calculate_phy_pix_clks(struct core_stream *stream)
{
	int i;

	for (i = 0; i < context->stream_count; i++) {
		struct core_stream *stream = context->streams[i];

	update_stream_signal(stream);

	/* update actual pixel clock on all streams */
@@ -1433,7 +1428,6 @@ static void calculate_phy_pix_clks(struct validate_context *context)
		stream->phy_pix_clk =
			stream->public.timing.pix_clk_khz;
}
}

enum dc_status resource_map_pool_resources(
		const struct core_dc *dc,
@@ -1443,8 +1437,6 @@ enum dc_status resource_map_pool_resources(
	const struct resource_pool *pool = dc->res_pool;
	int i, j;

	calculate_phy_pix_clks(context);

	for (i = 0; old_context && i < context->stream_count; i++) {
		struct core_stream *stream = context->streams[i];

@@ -2516,3 +2508,36 @@ void resource_build_bit_depth_reduction_params(const struct core_stream *stream,

	fmt_bit_depth->pixel_encoding = pixel_encoding;
}

bool dc_validate_stream(const struct dc *dc, const struct dc_stream *stream)
{
	struct core_dc *core_dc = DC_TO_CORE(dc);
	struct dc_context *dc_ctx = core_dc->ctx;
	struct core_stream *core_stream = DC_STREAM_TO_CORE(stream);
	struct dc_link *link = core_stream->sink->link;
	struct timing_generator *tg = core_dc->res_pool->timing_generators[0];
	enum dc_status res = DC_OK;

	calculate_phy_pix_clks(core_stream);

	if (!tg->funcs->validate_timing(tg, &core_stream->public.timing))
		res = DC_FAIL_CONTROLLER_VALIDATE;

	if (res == DC_OK)
		if (!link->link_enc->funcs->validate_output_with_stream(
						link->link_enc, core_stream))
			res = DC_FAIL_ENC_VALIDATE;

	/* TODO: validate audio ASIC caps, encoder */

	if (res == DC_OK)
		res = dc_link_validate_mode_timing(core_stream,
		      link,
		      &core_stream->public.timing);

	if (res != DC_OK)
		DC_ERROR("Failed validation for stream %p, err:%d, !\n",
				stream, res);

	return res == DC_OK;
}
+2 −0
Original line number Diff line number Diff line
@@ -559,6 +559,8 @@ struct dc_validation_set {
	uint8_t surface_count;
};

bool dc_validate_stream(const struct dc *dc, const struct dc_stream *stream);

/*
 * This function takes a set of resources and checks that they are cofunctional.
 *
+3 −4
Original line number Diff line number Diff line
@@ -1009,19 +1009,18 @@ bool dce110_link_encoder_construct(

bool dce110_link_encoder_validate_output_with_stream(
	struct link_encoder *enc,
	struct pipe_ctx *pipe_ctx)
	const struct core_stream *stream)
{
	struct core_stream *stream = pipe_ctx->stream;
	struct dce110_link_encoder *enc110 = TO_DCE110_LINK_ENC(enc);
	bool is_valid;

	switch (pipe_ctx->stream->signal) {
	switch (stream->signal) {
	case SIGNAL_TYPE_DVI_SINGLE_LINK:
	case SIGNAL_TYPE_DVI_DUAL_LINK:
		is_valid = dce110_link_encoder_validate_dvi_output(
			enc110,
			stream->sink->link->connector_signal,
			pipe_ctx->stream->signal,
			stream->signal,
			&stream->public.timing);
	break;
	case SIGNAL_TYPE_HDMI_TYPE_A:
+1 −1
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ bool dce110_link_encoder_validate_wireless_output(

bool dce110_link_encoder_validate_output_with_stream(
	struct link_encoder *enc,
	struct pipe_ctx *pipe_ctx);
	const struct core_stream *stream);

/****************** HW programming ************************/

Loading