Commit 269c1d14 authored by Yan Li's avatar Yan Li Committed by Alex Deucher
Browse files

drm/amd/display: replace fast_validate with enum dc_validate_mode



[Why]
The boolean fast_validate is used as an
input parameter in multiple functions. To
support more scenarios, we are
replacing it with enum dc_validate_mode.

[How]
The enum dc_validate_mode introduces three
possible values:
1) DC_VALIDATE_MODE_AND_PROGRAMMING:
   Apply the mode to hardware
2) DC_VALIDATE_MODE_ONLY:
   Check whether the mode can be supported
3) DC_VALIDATE_MODE_AND_STATE_INDEX:
   Check if the mode can be supported, and
   determine the optimal voltage level
   needed to support it.

Reviewed-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Signed-off-by: default avatarYan Li <yan.li@amd.com>
Signed-off-by: default avatarWayne Lin <wayne.lin@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent d42b2331
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7520,7 +7520,7 @@ static enum dc_status dm_validate_stream_and_context(struct dc *dc,
		dc_result = DC_FAIL_ATTACH_SURFACES;

	if (dc_result == DC_OK)
		dc_result = dc_validate_global_state(dc, dc_state, true);
		dc_result = dc_validate_global_state(dc, dc_state, DC_VALIDATE_MODE_ONLY);

cleanup:
	if (dc_state)
@@ -12142,7 +12142,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
			drm_dbg_atomic(dev, "MST drm_dp_mst_atomic_check() failed\n");
			goto fail;
		}
		status = dc_validate_global_state(dc, dm_state->context, true);
		status = dc_validate_global_state(dc, dm_state->context, DC_VALIDATE_MODE_ONLY);
		if (status != DC_OK) {
			drm_dbg_atomic(dev, "DC global validation failure: %s (%d)",
				       dc_status_to_str(status), status);
+7 −5
Original line number Diff line number Diff line
@@ -2377,7 +2377,7 @@ enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params

	context->power_source = params->power_source;

	res = dc_validate_with_context(dc, set, params->stream_count, context, false);
	res = dc_validate_with_context(dc, set, params->stream_count, context, DC_VALIDATE_MODE_AND_PROGRAMMING);

	/*
	 * Only update link encoder to stream assignment after bandwidth validation passed.
@@ -3300,7 +3300,8 @@ static void copy_stream_update_to_stream(struct dc *dc,
		if (dsc_validate_context) {
			stream->timing.dsc_cfg = *update->dsc_config;
			stream->timing.flags.DSC = enable_dsc;
			if (dc->res_pool->funcs->validate_bandwidth(dc, dsc_validate_context, true) != DC_OK) {
			if (dc->res_pool->funcs->validate_bandwidth(dc, dsc_validate_context,
				DC_VALIDATE_MODE_ONLY) != DC_OK) {
				stream->timing.dsc_cfg = old_dsc_cfg;
				stream->timing.flags.DSC = old_dsc_enabled;
				update->dsc_config = NULL;
@@ -3522,7 +3523,7 @@ static bool update_planes_and_stream_state(struct dc *dc,
	}

	if (update_type == UPDATE_TYPE_FULL) {
		if (dc->res_pool->funcs->validate_bandwidth(dc, context, false) != DC_OK) {
		if (dc->res_pool->funcs->validate_bandwidth(dc, context, DC_VALIDATE_MODE_AND_PROGRAMMING) != DC_OK) {
			BREAK_TO_DEBUGGER();
			goto fail;
		}
@@ -4628,7 +4629,8 @@ static struct dc_state *create_minimal_transition_state(struct dc *dc,

	backup_and_set_minimal_pipe_split_policy(dc, base_context, policy);
	/* commit minimal state */
	if (dc->res_pool->funcs->validate_bandwidth(dc, minimal_transition_context, false) == DC_OK) {
	if (dc->res_pool->funcs->validate_bandwidth(dc, minimal_transition_context,
		DC_VALIDATE_MODE_AND_PROGRAMMING) == DC_OK) {
		/* prevent underflow and corruption when reconfiguring pipes */
		force_vsync_flip_in_minimal_transition_context(minimal_transition_context);
	} else {
@@ -5151,7 +5153,7 @@ static bool update_planes_and_stream_v1(struct dc *dc,
	copy_stream_update_to_stream(dc, context, stream, stream_update);

	if (update_type >= UPDATE_TYPE_FULL) {
		if (dc->res_pool->funcs->validate_bandwidth(dc, context, false) != DC_OK) {
		if (dc->res_pool->funcs->validate_bandwidth(dc, context, DC_VALIDATE_MODE_AND_PROGRAMMING) != DC_OK) {
			DC_ERROR("Mode validation failed for stream update!\n");
			dc_state_release(context);
			return false;
+6 −6
Original line number Diff line number Diff line
@@ -4053,7 +4053,7 @@ static bool add_all_planes_for_stream(
 * @set: An array of dc_validation_set with all the current streams reference
 * @set_count: Total of streams
 * @context: New context
 * @fast_validate: Enable or disable fast validation
 * @validate_mode: identify the validation mode
 *
 * This function updates the potential new stream in the context object. It
 * creates multiple lists for the add, remove, and unchanged streams. In
@@ -4068,7 +4068,7 @@ enum dc_status dc_validate_with_context(struct dc *dc,
					const struct dc_validation_set set[],
					int set_count,
					struct dc_state *context,
					bool fast_validate)
					enum dc_validate_mode validate_mode)
{
	struct dc_stream_state *unchanged_streams[MAX_PIPES] = { 0 };
	struct dc_stream_state *del_streams[MAX_PIPES] = { 0 };
@@ -4242,7 +4242,7 @@ enum dc_status dc_validate_with_context(struct dc *dc,
		dc_state_set_stream_subvp_cursor_limit(context->streams[i], context, false);
	}

	res = dc_validate_global_state(dc, context, fast_validate);
	res = dc_validate_global_state(dc, context, validate_mode);

	/* calculate pixel rate divider after deciding pxiel clock & odm combine  */
	if ((dc->hwss.calculate_pix_rate_divider) && (res == DC_OK)) {
@@ -4299,7 +4299,7 @@ static void decide_hblank_borrow(struct pipe_ctx *pipe_ctx)
 *
 * @dc: dc struct for this driver
 * @new_ctx: state to be validated
 * @fast_validate: set to true if only yes/no to support matters
 * @validate_mode: identify the validation mode
 *
 * Checks hardware resource availability and bandwidth requirement.
 *
@@ -4309,7 +4309,7 @@ static void decide_hblank_borrow(struct pipe_ctx *pipe_ctx)
enum dc_status dc_validate_global_state(
		struct dc *dc,
		struct dc_state *new_ctx,
		bool fast_validate)
		enum dc_validate_mode validate_mode)
{
	enum dc_status result = DC_ERROR_UNEXPECTED;
	int i, j;
@@ -4368,7 +4368,7 @@ enum dc_status dc_validate_global_state(
	result = resource_build_scaling_params_for_context(dc, new_ctx);

	if (result == DC_OK)
		result = dc->res_pool->funcs->validate_bandwidth(dc, new_ctx, fast_validate);
		result = dc->res_pool->funcs->validate_bandwidth(dc, new_ctx, validate_mode);

	return result;
}
+2 −6
Original line number Diff line number Diff line
@@ -1804,19 +1804,15 @@ enum dc_status dc_validate_with_context(struct dc *dc,
					const struct dc_validation_set set[],
					int set_count,
					struct dc_state *context,
					bool fast_validate);
					enum dc_validate_mode validate_mode);

bool dc_set_generic_gpio_for_stereo(bool enable,
		struct gpio_service *gpio_service);

/*
 * fast_validate: we return after determining if we can support the new state,
 * but before we populate the programming info
 */
enum dc_status dc_validate_global_state(
		struct dc *dc,
		struct dc_state *new_ctx,
		bool fast_validate);
		enum dc_validate_mode validate_mode);

bool dc_acquire_release_mpc_3dlut(
		struct dc *dc, bool acquire,
+8 −0
Original line number Diff line number Diff line
@@ -1370,4 +1370,12 @@ struct set_backlight_level_params {
	uint8_t aux_inst;
};

enum dc_validate_mode {
	/* validate the mode and program HW */
	DC_VALIDATE_MODE_AND_PROGRAMMING = 0,
	/* only validate the mode */
	DC_VALIDATE_MODE_ONLY = 1,
	/* validate the mode and get the max state (voltage level) */
	DC_VALIDATE_MODE_AND_STATE_INDEX = 2,
};
#endif /* DC_TYPES_H_ */
Loading