*dc = NULL;
}
+static bool is_validation_required(
+ const struct core_dc *dc,
+ const struct dc_validation_set set[],
+ int set_count)
+{
+ const struct validate_context *context = dc->current_context;
+ int i, j;
+
+ if (context->stream_count != set_count)
+ return true;
+
+ for (i = 0; i < set_count; i++) {
+
+ if (set[i].surface_count != context->stream_status[i].surface_count)
+ return true;
+ if (!is_stream_unchanged(DC_STREAM_TO_CORE(set[i].stream), context->streams[i]))
+ return true;
+
+ for (j = 0; j < set[i].surface_count; j++) {
+ struct dc_surface temp_surf = { 0 };
+
+ temp_surf = *context->stream_status[i].surfaces[j];
+ temp_surf.clip_rect = set[i].surfaces[j]->clip_rect;
+ temp_surf.dst_rect.x = set[i].surfaces[j]->dst_rect.x;
+ temp_surf.dst_rect.y = set[i].surfaces[j]->dst_rect.y;
+
+ if (memcmp(&temp_surf, set[i].surfaces[j], sizeof(temp_surf)) != 0)
+ return true;
+ }
+ }
+
+ return false;
+}
+
struct validate_context *dc_get_validate_context(
const struct dc *dc,
const struct dc_validation_set set[],
struct validate_context *context;
context = dm_alloc(sizeof(struct validate_context));
- if(context == NULL)
+ if (context == NULL)
goto context_alloc_fail;
+ if (!is_validation_required(core_dc, set, set_count)) {
+ dc_resource_validate_ctx_copy_construct(core_dc->current_context, context);
+ return context;
+ }
+
result = core_dc->res_pool->funcs->validate_with_context(
- core_dc, set, set_count, context, NULL);
+ core_dc, set, set_count, context, core_dc->current_context);
context_alloc_fail:
if (result != DC_OK) {
const struct dc_validation_set set[],
uint8_t set_count)
{
- struct validate_context *ctx;
+ struct core_dc *core_dc = DC_TO_CORE(dc);
+ enum dc_status result = DC_ERROR_UNEXPECTED;
+ struct validate_context *context;
- ctx = dc_get_validate_context(dc, set, set_count);
- if (ctx) {
- dc_resource_validate_ctx_destruct(ctx);
- dm_free(ctx);
- return true;
+ context = dm_alloc(sizeof(struct validate_context));
+ if (context == NULL)
+ goto context_alloc_fail;
+
+ result = core_dc->res_pool->funcs->validate_with_context(
+ core_dc, set, set_count, context, NULL);
+
+context_alloc_fail:
+ if (result != DC_OK) {
+ dm_logger_write(core_dc->ctx->logger, LOG_WARNING,
+ "%s:resource validation failed, dc_status:%d\n",
+ __func__,
+ result);
}
- return false;
+ dc_resource_validate_ctx_destruct(context);
+ dm_free(context);
+ context = NULL;
+
+ return result == DC_OK;
}
bool dc_validate_guaranteed(