Commit 285a7054 authored by Alvin Lee's avatar Alvin Lee Committed by Alex Deucher
Browse files

drm/amd/display: Remove plane and stream pointers from dc scratch



[Why&How]
Remove several plane and stream pointers from dc for code
refactoring.

Reviewed-by: default avatarWenjing Liu <wenjing.liu@amd.com>
Acked-by: default avatarTom Chung <chiahsuan.chung@amd.com>
Signed-off-by: default avatarAlvin Lee <alvin.lee2@amd.com>
Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent a9d51813
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -5700,8 +5700,8 @@ static void fill_stream_properties_from_drm_display_mode(

	timing_out->aspect_ratio = get_aspect_ratio(mode_in);

	stream->out_transfer_func->type = TF_TYPE_PREDEFINED;
	stream->out_transfer_func->tf = TRANSFER_FUNCTION_SRGB;
	stream->out_transfer_func.type = TF_TYPE_PREDEFINED;
	stream->out_transfer_func.tf = TRANSFER_FUNCTION_SRGB;
	if (stream->signal == SIGNAL_TYPE_HDMI_TYPE_A) {
		if (!adjust_colour_depth_from_display_info(timing_out, info) &&
		    drm_mode_is_420_also(info, mode_in) &&
@@ -6319,7 +6319,7 @@ create_stream_for_sink(struct drm_connector *connector,
			if (stream->link->dpcd_caps.dprx_feature.bits.VSC_SDP_COLORIMETRY_SUPPORTED)
				stream->use_vsc_sdp_for_colorimetry = true;
		}
		if (stream->out_transfer_func->tf == TRANSFER_FUNCTION_GAMMA22)
		if (stream->out_transfer_func.tf == TRANSFER_FUNCTION_GAMMA22)
			tf = TRANSFER_FUNC_GAMMA_22;
		mod_build_vsc_infopacket(stream, &stream->vsc_infopacket, stream->output_color_space, tf);
		aconnector->psr_skip_count = AMDGPU_DM_PSR_ENTRY_DELAY;
@@ -8392,13 +8392,13 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,

		bundle->surface_updates[planes_count].surface = dc_plane;
		if (new_pcrtc_state->color_mgmt_changed) {
			bundle->surface_updates[planes_count].gamma = dc_plane->gamma_correction;
			bundle->surface_updates[planes_count].in_transfer_func = dc_plane->in_transfer_func;
			bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction;
			bundle->surface_updates[planes_count].in_transfer_func = &dc_plane->in_transfer_func;
			bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix;
			bundle->surface_updates[planes_count].hdr_mult = dc_plane->hdr_mult;
			bundle->surface_updates[planes_count].func_shaper = dc_plane->in_shaper_func;
			bundle->surface_updates[planes_count].lut3d_func = dc_plane->lut3d_func;
			bundle->surface_updates[planes_count].blend_tf = dc_plane->blend_tf;
			bundle->surface_updates[planes_count].func_shaper = &dc_plane->in_shaper_func;
			bundle->surface_updates[planes_count].lut3d_func = &dc_plane->lut3d_func;
			bundle->surface_updates[planes_count].blend_tf = &dc_plane->blend_tf;
		}

		amdgpu_dm_plane_fill_dc_scaling_info(dm->adev, new_plane_state,
@@ -8611,7 +8611,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
			bundle->stream_update.output_csc_transform =
				&acrtc_state->stream->csc_color_matrix;
			bundle->stream_update.out_transfer_func =
				acrtc_state->stream->out_transfer_func;
				&acrtc_state->stream->out_transfer_func;
			bundle->stream_update.lut3d_func =
				(struct dc_3dlut *) acrtc_state->stream->lut3d_func;
			bundle->stream_update.func_shaper =
+21 −21
Original line number Diff line number Diff line
@@ -571,7 +571,7 @@ static int amdgpu_dm_set_atomic_regamma(struct dc_stream_state *stream,
					uint32_t regamma_size, bool has_rom,
					enum dc_transfer_func_predefined tf)
{
	struct dc_transfer_func *out_tf = stream->out_transfer_func;
	struct dc_transfer_func *out_tf = &stream->out_transfer_func;
	int ret = 0;

	if (regamma_size || tf != TRANSFER_FUNCTION_LINEAR) {
@@ -954,8 +954,8 @@ int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc)
		 * inverse color ramp in legacy userspace.
		 */
		crtc->cm_is_degamma_srgb = true;
		stream->out_transfer_func->type = TF_TYPE_DISTRIBUTED_POINTS;
		stream->out_transfer_func->tf = TRANSFER_FUNCTION_SRGB;
		stream->out_transfer_func.type = TF_TYPE_DISTRIBUTED_POINTS;
		stream->out_transfer_func.tf = TRANSFER_FUNCTION_SRGB;
		/*
		 * Note: although we pass has_rom as parameter here, we never
		 * actually use ROM because the color module only takes the ROM
@@ -963,7 +963,7 @@ int amdgpu_dm_update_crtc_color_mgmt(struct dm_crtc_state *crtc)
		 *
		 * See more in mod_color_calculate_regamma_params()
		 */
		r = __set_legacy_tf(stream->out_transfer_func, regamma_lut,
		r = __set_legacy_tf(&stream->out_transfer_func, regamma_lut,
				    regamma_size, has_rom);
		if (r)
			return r;
@@ -1034,7 +1034,7 @@ map_crtc_degamma_to_dc_plane(struct dm_crtc_state *crtc,
						 &degamma_size);
		ASSERT(degamma_size == MAX_COLOR_LUT_ENTRIES);

		dc_plane_state->in_transfer_func->type = TF_TYPE_DISTRIBUTED_POINTS;
		dc_plane_state->in_transfer_func.type = TF_TYPE_DISTRIBUTED_POINTS;

		/*
		 * This case isn't fully correct, but also fairly
@@ -1061,12 +1061,12 @@ map_crtc_degamma_to_dc_plane(struct dm_crtc_state *crtc,
		 * map these to the atomic one instead.
		 */
		if (crtc->cm_is_degamma_srgb)
			dc_plane_state->in_transfer_func->tf = tf;
			dc_plane_state->in_transfer_func.tf = tf;
		else
			dc_plane_state->in_transfer_func->tf =
			dc_plane_state->in_transfer_func.tf =
				TRANSFER_FUNCTION_LINEAR;

		r = __set_input_tf(caps, dc_plane_state->in_transfer_func,
		r = __set_input_tf(caps, &dc_plane_state->in_transfer_func,
				   degamma_lut, degamma_size);
		if (r)
			return r;
@@ -1075,12 +1075,12 @@ map_crtc_degamma_to_dc_plane(struct dm_crtc_state *crtc,
		 * For legacy gamma support we need the regamma input
		 * in linear space. Assume that the input is sRGB.
		 */
		dc_plane_state->in_transfer_func->type = TF_TYPE_PREDEFINED;
		dc_plane_state->in_transfer_func->tf = tf;
		dc_plane_state->in_transfer_func.type = TF_TYPE_PREDEFINED;
		dc_plane_state->in_transfer_func.tf = tf;

		if (tf != TRANSFER_FUNCTION_SRGB &&
		    !mod_color_calculate_degamma_params(caps,
							dc_plane_state->in_transfer_func,
							&dc_plane_state->in_transfer_func,
							NULL, false))
			return -ENOMEM;
	}
@@ -1114,24 +1114,24 @@ __set_dm_plane_degamma(struct drm_plane_state *plane_state,
	if (!has_degamma_lut && tf == AMDGPU_TRANSFER_FUNCTION_DEFAULT)
		return -EINVAL;

	dc_plane_state->in_transfer_func->tf = amdgpu_tf_to_dc_tf(tf);
	dc_plane_state->in_transfer_func.tf = amdgpu_tf_to_dc_tf(tf);

	if (has_degamma_lut) {
		ASSERT(degamma_size == MAX_COLOR_LUT_ENTRIES);

		dc_plane_state->in_transfer_func->type =
		dc_plane_state->in_transfer_func.type =
			TF_TYPE_DISTRIBUTED_POINTS;

		ret = __set_input_tf(color_caps, dc_plane_state->in_transfer_func,
		ret = __set_input_tf(color_caps, &dc_plane_state->in_transfer_func,
				     degamma_lut, degamma_size);
		if (ret)
			return ret;
       } else {
		dc_plane_state->in_transfer_func->type =
		dc_plane_state->in_transfer_func.type =
			TF_TYPE_PREDEFINED;

		if (!mod_color_calculate_degamma_params(color_caps,
		    dc_plane_state->in_transfer_func, NULL, false))
		    &dc_plane_state->in_transfer_func, NULL, false))
			return -ENOMEM;
	}
	return 0;
@@ -1156,11 +1156,11 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state,
	lut3d = __extract_blob_lut(dm_plane_state->lut3d, &lut3d_size);
	lut3d_size = lut3d != NULL ? lut3d_size : 0;

	amdgpu_dm_atomic_lut3d(lut3d, lut3d_size, dc_plane_state->lut3d_func);
	amdgpu_dm_atomic_lut3d(lut3d, lut3d_size, &dc_plane_state->lut3d_func);
	ret = amdgpu_dm_atomic_shaper_lut(shaper_lut, false,
					  amdgpu_tf_to_dc_tf(shaper_tf),
					  shaper_size,
					  dc_plane_state->in_shaper_func);
					  &dc_plane_state->in_shaper_func);
	if (ret) {
		drm_dbg_kms(plane_state->plane->dev,
			    "setting plane %d shaper LUT failed.\n",
@@ -1175,7 +1175,7 @@ amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state,

	ret = amdgpu_dm_atomic_blend_lut(blend_lut, false,
					 amdgpu_tf_to_dc_tf(blend_tf),
					 blend_size, dc_plane_state->blend_tf);
					 blend_size, &dc_plane_state->blend_tf);
	if (ret) {
		drm_dbg_kms(plane_state->plane->dev,
			    "setting plane %d gamma lut failed.\n",
@@ -1221,8 +1221,8 @@ int amdgpu_dm_update_plane_color_mgmt(struct dm_crtc_state *crtc,
		color_caps = &dc_plane_state->ctx->dc->caps.color;

	/* Initially, we can just bypass the DGM block. */
	dc_plane_state->in_transfer_func->type = TF_TYPE_BYPASS;
	dc_plane_state->in_transfer_func->tf = TRANSFER_FUNCTION_LINEAR;
	dc_plane_state->in_transfer_func.type = TF_TYPE_BYPASS;
	dc_plane_state->in_transfer_func.tf = TRANSFER_FUNCTION_LINEAR;

	/* After, we start to update values according to color props */
	has_crtc_cm_degamma = (crtc->cm_has_degamma || crtc->cm_is_degamma_srgb);
+29 −51
Original line number Diff line number Diff line
@@ -2851,55 +2851,45 @@ static void copy_surface_update_to_plane(
				srf_update->plane_info->layer_index;
	}

	if (srf_update->gamma &&
			(surface->gamma_correction !=
					srf_update->gamma)) {
		memcpy(&surface->gamma_correction->entries,
	if (srf_update->gamma) {
		memcpy(&surface->gamma_correction.entries,
			&srf_update->gamma->entries,
			sizeof(struct dc_gamma_entries));
		surface->gamma_correction->is_identity =
		surface->gamma_correction.is_identity =
			srf_update->gamma->is_identity;
		surface->gamma_correction->num_entries =
		surface->gamma_correction.num_entries =
			srf_update->gamma->num_entries;
		surface->gamma_correction->type =
		surface->gamma_correction.type =
			srf_update->gamma->type;
	}

	if (srf_update->in_transfer_func &&
			(surface->in_transfer_func !=
				srf_update->in_transfer_func)) {
		surface->in_transfer_func->sdr_ref_white_level =
	if (srf_update->in_transfer_func) {
		surface->in_transfer_func.sdr_ref_white_level =
			srf_update->in_transfer_func->sdr_ref_white_level;
		surface->in_transfer_func->tf =
		surface->in_transfer_func.tf =
			srf_update->in_transfer_func->tf;
		surface->in_transfer_func->type =
		surface->in_transfer_func.type =
			srf_update->in_transfer_func->type;
		memcpy(&surface->in_transfer_func->tf_pts,
		memcpy(&surface->in_transfer_func.tf_pts,
			&srf_update->in_transfer_func->tf_pts,
			sizeof(struct dc_transfer_func_distributed_points));
	}

	if (srf_update->func_shaper &&
			(surface->in_shaper_func !=
			srf_update->func_shaper))
		memcpy(surface->in_shaper_func, srf_update->func_shaper,
		sizeof(*surface->in_shaper_func));
	if (srf_update->func_shaper)
		memcpy(&surface->in_shaper_func, srf_update->func_shaper,
		sizeof(surface->in_shaper_func));

	if (srf_update->lut3d_func &&
			(surface->lut3d_func !=
			srf_update->lut3d_func))
		memcpy(surface->lut3d_func, srf_update->lut3d_func,
		sizeof(*surface->lut3d_func));
	if (srf_update->lut3d_func)
		memcpy(&surface->lut3d_func, srf_update->lut3d_func,
		sizeof(surface->lut3d_func));

	if (srf_update->hdr_mult.value)
		surface->hdr_mult =
				srf_update->hdr_mult;

	if (srf_update->blend_tf &&
			(surface->blend_tf !=
			srf_update->blend_tf))
		memcpy(surface->blend_tf, srf_update->blend_tf,
		sizeof(*surface->blend_tf));
	if (srf_update->blend_tf)
		memcpy(&surface->blend_tf, srf_update->blend_tf,
		sizeof(surface->blend_tf));

	if (srf_update->input_csc_color_matrix)
		surface->input_csc_color_matrix =
@@ -2930,14 +2920,13 @@ static void copy_stream_update_to_stream(struct dc *dc,
	if (update->dst.height && update->dst.width)
		stream->dst = update->dst;

	if (update->out_transfer_func &&
	    stream->out_transfer_func != update->out_transfer_func) {
		stream->out_transfer_func->sdr_ref_white_level =
	if (update->out_transfer_func) {
		stream->out_transfer_func.sdr_ref_white_level =
			update->out_transfer_func->sdr_ref_white_level;
		stream->out_transfer_func->tf = update->out_transfer_func->tf;
		stream->out_transfer_func->type =
		stream->out_transfer_func.tf = update->out_transfer_func->tf;
		stream->out_transfer_func.type =
			update->out_transfer_func->type;
		memcpy(&stream->out_transfer_func->tf_pts,
		memcpy(&stream->out_transfer_func.tf_pts,
		       &update->out_transfer_func->tf_pts,
		       sizeof(struct dc_transfer_func_distributed_points));
	}
@@ -3050,15 +3039,8 @@ static void backup_planes_and_stream_state(

	for (i = 0; i < status->plane_count; i++) {
		scratch->plane_states[i] = *status->plane_states[i];
		scratch->gamma_correction[i] = *status->plane_states[i]->gamma_correction;
		scratch->in_transfer_func[i] = *status->plane_states[i]->in_transfer_func;
		scratch->lut3d_func[i] = *status->plane_states[i]->lut3d_func;
		scratch->in_shaper_func[i] = *status->plane_states[i]->in_shaper_func;
		scratch->blend_tf[i] = *status->plane_states[i]->blend_tf;
	}
	scratch->stream_state = *stream;
	if (stream->out_transfer_func)
		scratch->out_transfer_func = *stream->out_transfer_func;
}

static void restore_planes_and_stream_state(
@@ -3073,15 +3055,8 @@ static void restore_planes_and_stream_state(

	for (i = 0; i < status->plane_count; i++) {
		*status->plane_states[i] = scratch->plane_states[i];
		*status->plane_states[i]->gamma_correction = scratch->gamma_correction[i];
		*status->plane_states[i]->in_transfer_func = scratch->in_transfer_func[i];
		*status->plane_states[i]->lut3d_func = scratch->lut3d_func[i];
		*status->plane_states[i]->in_shaper_func = scratch->in_shaper_func[i];
		*status->plane_states[i]->blend_tf = scratch->blend_tf[i];
	}
	*stream = scratch->stream_state;
	if (stream->out_transfer_func)
		*stream->out_transfer_func = scratch->out_transfer_func;
}

/**
@@ -5354,10 +5329,13 @@ void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable)
	}
	dc->clk_mgr->dc_mode_softmax_enabled = enable;
}
bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc, struct dc_plane_state *plane,
bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc,
		unsigned int pitch,
		unsigned int height,
		enum surface_pixel_format format,
		struct dc_cursor_attributes *cursor_attr)
{
	if (dc->hwss.does_plane_fit_in_mall && dc->hwss.does_plane_fit_in_mall(dc, plane, cursor_attr))
	if (dc->hwss.does_plane_fit_in_mall && dc->hwss.does_plane_fit_in_mall(dc, pitch, height, format, cursor_attr))
		return true;
	return false;
}
+4 −4
Original line number Diff line number Diff line
@@ -392,10 +392,10 @@ void get_hdr_visual_confirm_color(

	switch (top_pipe_ctx->plane_res.scl_data.format) {
	case PIXEL_FORMAT_ARGB2101010:
		if (top_pipe_ctx->stream->out_transfer_func->tf == TRANSFER_FUNCTION_PQ) {
		if (top_pipe_ctx->stream->out_transfer_func.tf == TRANSFER_FUNCTION_PQ) {
			/* HDR10, ARGB2101010 - set border color to red */
			color->color_r_cr = color_value;
		} else if (top_pipe_ctx->stream->out_transfer_func->tf == TRANSFER_FUNCTION_GAMMA22) {
		} else if (top_pipe_ctx->stream->out_transfer_func.tf == TRANSFER_FUNCTION_GAMMA22) {
			/* FreeSync 2 ARGB2101010 - set border color to pink */
			color->color_r_cr = color_value;
			color->color_b_cb = color_value;
@@ -403,10 +403,10 @@ void get_hdr_visual_confirm_color(
			is_sdr = true;
		break;
	case PIXEL_FORMAT_FP16:
		if (top_pipe_ctx->stream->out_transfer_func->tf == TRANSFER_FUNCTION_PQ) {
		if (top_pipe_ctx->stream->out_transfer_func.tf == TRANSFER_FUNCTION_PQ) {
			/* HDR10, FP16 - set border color to blue */
			color->color_b_cb = color_value;
		} else if (top_pipe_ctx->stream->out_transfer_func->tf == TRANSFER_FUNCTION_GAMMA22) {
		} else if (top_pipe_ctx->stream->out_transfer_func.tf == TRANSFER_FUNCTION_GAMMA22) {
			/* FreeSync 2 HDR - set border color to green */
			color->color_g_y = color_value;
		} else
+1 −1
Original line number Diff line number Diff line
@@ -4041,7 +4041,7 @@ static void set_avi_info_frame(
	}

	if (pixel_encoding && color_space == COLOR_SPACE_2020_YCBCR &&
			stream->out_transfer_func->tf == TRANSFER_FUNCTION_GAMMA22) {
			stream->out_transfer_func.tf == TRANSFER_FUNCTION_GAMMA22) {
		hdmi_info.bits.EC0_EC2 = 0;
		hdmi_info.bits.C0_C1 = COLORIMETRY_ITU709;
	}
Loading