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[],
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;
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;
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;
}
+ if (!validate_streams(dc, set, stream_count))
+ return false;
+
context = dm_alloc(sizeof(struct validate_context));
if (context == NULL)
goto context_alloc_fail;
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 */
- if (dc_is_hdmi_signal(stream->signal))
- stream->phy_pix_clk = get_norm_pix_clk(
- &stream->public.timing);
- else
- stream->phy_pix_clk =
- stream->public.timing.pix_clk_khz;
- }
+ update_stream_signal(stream);
+
+ /* update actual pixel clock on all streams */
+ if (dc_is_hdmi_signal(stream->signal))
+ stream->phy_pix_clk = get_norm_pix_clk(
+ &stream->public.timing);
+ else
+ stream->phy_pix_clk =
+ stream->public.timing.pix_clk_khz;
}
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];
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;
+}
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.
*
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:
bool dce110_link_encoder_validate_output_with_stream(
struct link_encoder *enc,
- struct pipe_ctx *pipe_ctx);
+ const struct core_stream *stream);
/****************** HW programming ************************/
dal_irq_service_destroy(&pool->base.irqs);
}
-static enum dc_status validate_mapped_resource(
+static enum dc_status build_mapped_resource(
const struct core_dc *dc,
struct validate_context *context,
struct validate_context *old_context)
for (i = 0; i < context->stream_count; i++) {
struct core_stream *stream = context->streams[i];
- struct dc_link *link = stream->sink->link;
if (old_context && resource_is_stream_unchanged(old_context, stream))
continue;
if (context->res_ctx.pipe_ctx[j].stream != stream)
continue;
- if (!pipe_ctx->tg->funcs->validate_timing(
- pipe_ctx->tg, &stream->public.timing))
- return DC_FAIL_CONTROLLER_VALIDATE;
-
status = dce110_resource_build_pipe_hw_param(pipe_ctx);
- if (status != DC_OK)
- return status;
-
- if (!link->link_enc->funcs->validate_output_with_stream(
- link->link_enc,
- pipe_ctx))
- return DC_FAIL_ENC_VALIDATE;
-
- /* TODO: validate audio ASIC caps, encoder */
- status = dc_link_validate_mode_timing(stream,
- link,
- &stream->public.timing);
-
if (status != DC_OK)
return status;
}
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, old_context);
+ result = build_mapped_resource(dc, context, old_context);
if (result == DC_OK)
result = resource_build_scaling_params_for_context(dc, context);
result = resource_map_clock_resources(dc, context, NULL);
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, NULL);
+ result = build_mapped_resource(dc, context, NULL);
if (result == DC_OK) {
validate_guaranteed_copy_streams(
return true;
}
-static enum dc_status validate_mapped_resource(
+static enum dc_status build_mapped_resource(
const struct core_dc *dc,
struct validate_context *context,
struct validate_context *old_context)
for (i = 0; i < context->stream_count; i++) {
struct core_stream *stream = context->streams[i];
- struct dc_link *link = stream->sink->link;
if (old_context && resource_is_stream_unchanged(old_context, stream))
continue;
dc->res_pool->underlay_pipe_index))
return DC_SURFACE_PIXEL_FORMAT_UNSUPPORTED;
- if (!pipe_ctx->tg->funcs->validate_timing(
- pipe_ctx->tg, &stream->public.timing))
- return DC_FAIL_CONTROLLER_VALIDATE;
-
status = dce110_resource_build_pipe_hw_param(pipe_ctx);
if (status != DC_OK)
return status;
- if (!link->link_enc->funcs->validate_output_with_stream(
- link->link_enc,
- pipe_ctx))
- return DC_FAIL_ENC_VALIDATE;
-
/* TODO: validate audio ASIC caps, encoder */
- status = dc_link_validate_mode_timing(stream,
- link,
- &stream->public.timing);
-
- if (status != DC_OK)
- return status;
-
resource_build_info_frame(pipe_ctx);
/* do not need to validate non root pipes */
}
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, old_context);
+ result = build_mapped_resource(dc, context, old_context);
if (result == DC_OK)
result = resource_build_scaling_params_for_context(dc, context);
result = resource_map_clock_resources(dc, context, NULL);
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, NULL);
+ result = build_mapped_resource(dc, context, NULL);
if (result == DC_OK) {
validate_guaranteed_copy_streams(
return 0;
}
-static enum dc_status validate_mapped_resource(
+static enum dc_status build_mapped_resource(
const struct core_dc *dc,
struct validate_context *context,
struct validate_context *old_context)
for (i = 0; i < context->stream_count; i++) {
struct core_stream *stream = context->streams[i];
- struct dc_link *link = stream->sink->link;
if (old_context && resource_is_stream_unchanged(old_context, stream))
continue;
if (context->res_ctx.pipe_ctx[j].stream != stream)
continue;
- if (!pipe_ctx->tg->funcs->validate_timing(
- pipe_ctx->tg, &stream->public.timing))
- return DC_FAIL_CONTROLLER_VALIDATE;
-
status = dce110_resource_build_pipe_hw_param(pipe_ctx);
- if (status != DC_OK)
- return status;
-
- if (!link->link_enc->funcs->validate_output_with_stream(
- link->link_enc,
- pipe_ctx))
- return DC_FAIL_ENC_VALIDATE;
-
- /* TODO: validate audio ASIC caps, encoder */
-
- status = dc_link_validate_mode_timing(stream,
- link,
- &stream->public.timing);
-
if (status != DC_OK)
return status;
}
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, old_context);
+ result = build_mapped_resource(dc, context, old_context);
if (result == DC_OK)
result = resource_build_scaling_params_for_context(dc, context);
result = resource_map_phy_clock_resources(dc, context, NULL);
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, NULL);
+ result = build_mapped_resource(dc, context, NULL);
if (result == DC_OK) {
validate_guaranteed_copy_streams(
}
}
-static enum dc_status validate_mapped_resource(
+static enum dc_status build_mapped_resource(
const struct core_dc *dc,
struct validate_context *context,
struct validate_context *old_context)
for (i = 0; i < context->stream_count; i++) {
struct core_stream *stream = context->streams[i];
- struct dc_link *link = stream->sink->link;
if (old_context && resource_is_stream_unchanged(old_context, stream))
continue;
if (context->res_ctx.pipe_ctx[j].stream != stream)
continue;
- if (!pipe_ctx->tg->funcs->validate_timing(
- pipe_ctx->tg, &stream->public.timing))
- return DC_FAIL_CONTROLLER_VALIDATE;
-
status = dce110_resource_build_pipe_hw_param(pipe_ctx);
- if (status != DC_OK)
- return status;
-
- if (!link->link_enc->funcs->validate_output_with_stream(
- link->link_enc,
- pipe_ctx))
- return DC_FAIL_ENC_VALIDATE;
-
- /* TODO: validate audio ASIC caps, encoder */
-
- status = dc_link_validate_mode_timing(stream,
- link,
- &stream->public.timing);
-
if (status != DC_OK)
return status;
}
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, old_context);
+ result = build_mapped_resource(dc, context, old_context);
if (result == DC_OK)
result = resource_build_scaling_params_for_context(dc, context);
result = resource_map_clock_resources(dc, context, NULL);
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, NULL);
+ result = build_mapped_resource(dc, context, NULL);
if (result == DC_OK) {
validate_guaranteed_copy_streams(
return DC_OK;
}
-static enum dc_status validate_mapped_resource(
+static enum dc_status build_mapped_resource(
const struct core_dc *dc,
struct validate_context *context,
struct validate_context *old_context)
for (i = 0; i < context->stream_count; i++) {
struct core_stream *stream = context->streams[i];
- struct dc_link *link = stream->sink->link;
if (old_context && resource_is_stream_unchanged(old_context, stream)) {
if (stream != NULL && old_context->streams[i] != NULL) {
if (context->res_ctx.pipe_ctx[j].stream != stream)
continue;
-
- if (!pipe_ctx->tg->funcs->validate_timing(
- pipe_ctx->tg, &stream->public.timing))
- return DC_FAIL_CONTROLLER_VALIDATE;
-
status = build_pipe_hw_param(pipe_ctx);
if (status != DC_OK)
return status;
- if (!link->link_enc->funcs->validate_output_with_stream(
- link->link_enc, pipe_ctx))
- return DC_FAIL_ENC_VALIDATE;
-
- /* TODO: validate audio ASIC caps, encoder */
-
- status = dc_link_validate_mode_timing(
- stream, link, &stream->public.timing);
-
- if (status != DC_OK)
- return status;
-
-
/* do not need to validate non root pipes */
break;
}
if (result != DC_OK)
return result;
- result = validate_mapped_resource(dc, context, old_context);
+ result = build_mapped_resource(dc, context, old_context);
if (result != DC_OK)
return result;
result = resource_map_phy_clock_resources(dc, context, NULL);
if (result == DC_OK)
- result = validate_mapped_resource(dc, context, NULL);
+ result = build_mapped_resource(dc, context, NULL);
if (result == DC_OK) {
validate_guaranteed_copy_streams(
struct link_encoder_funcs {
bool (*validate_output_with_stream)(
- struct link_encoder *enc, struct pipe_ctx *pipe_ctx);
+ struct link_encoder *enc, const struct core_stream *stream);
void (*hw_init)(struct link_encoder *enc);
void (*setup)(struct link_encoder *enc,
enum signal_type signal);
static bool virtual_link_encoder_validate_output_with_stream(
struct link_encoder *enc,
- struct pipe_ctx *pipe_ctx) { return true; }
+ const struct core_stream *stream) { return true; }
static void virtual_link_encoder_hw_init(struct link_encoder *enc) {}