/* TODO: Unhardcode stream count */
struct dc_stream *stream;
struct amdgpu_connector *aconnector = to_amdgpu_connector(connector);
+ struct validate_context *context;
if ((mode->flags & DRM_MODE_FLAG_INTERLACE) ||
(mode->flags & DRM_MODE_FLAG_DBLSCAN))
stream->src.height = mode->vdisplay;
stream->dst = stream->src;
- if (dc_validate_resources(adev->dm.dc, &val_set, 1))
+ context = dc_get_validate_context(adev->dm.dc, &val_set, 1);
+
+ if (context) {
result = MODE_OK;
+ dc_resource_validate_ctx_destruct(context);
+ dm_free(context);
+ }
dc_stream_release(stream);
struct amdgpu_device *adev = dev->dev_private;
struct dc *dc = adev->dm.dc;
bool need_to_validate = false;
+ struct validate_context *context;
ret = drm_atomic_helper_check(dev, state);
}
}
- if (need_to_validate == false || set_count == 0 ||
- dc_validate_resources(dc, set, set_count))
+ context = dc_get_validate_context(dc, set, set_count);
+
+ if (need_to_validate == false || set_count == 0 || context)
ret = 0;
- for (i = 0; i < set_count; i++) {
- for (j = 0; j < set[i].surface_count; j++) {
- dc_surface_release(set[i].surfaces[j]);
- }
+ if (context) {
+ dc_resource_validate_ctx_destruct(context);
+ dm_free(context);
}
+
+ for (i = 0; i < set_count; i++)
+ for (j = 0; j < set[i].surface_count; j++)
+ dc_surface_release(set[i].surfaces[j]);
+
for (i = 0; i < new_stream_count; i++)
dc_stream_release(new_streams[i]);
return false;
}
-bool dc_validate_resources(
+struct validate_context *dc_get_validate_context(
const struct dc *dc,
const struct dc_validation_set set[],
uint8_t set_count)
enum dc_status result = DC_ERROR_UNEXPECTED;
struct validate_context *context;
- if (!is_validation_required(core_dc, set, set_count))
- return true;
-
context = dm_alloc(sizeof(struct validate_context));
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);
- dc_resource_validate_ctx_destruct(context);
- dm_free(context);
-
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);
+
+ dc_resource_validate_ctx_destruct(context);
+ dm_free(context);
+ context = NULL;
}
- return (result == DC_OK);
+ return context;
}
+bool dc_validate_resources(
+ const struct dc *dc,
+ const struct dc_validation_set set[],
+ uint8_t set_count)
+{
+ struct validate_context *ctx;
+
+ ctx = dc_get_validate_context(dc, set, set_count);
+ if (ctx) {
+ dc_resource_validate_ctx_destruct(ctx);
+ dm_free(ctx);
+ return true;
+ }
+
+ return false;
+}
+
bool dc_validate_guaranteed(
const struct dc *dc,
const struct dc_stream *stream)
* After this call:
* No hardware is programmed for call. Only validation is done.
*/
+struct validate_context *dc_get_validate_context(
+ const struct dc *dc,
+ const struct dc_validation_set set[],
+ uint8_t set_count);
+
bool dc_validate_resources(
const struct dc *dc,
const struct dc_validation_set set[],