Commit 90e508ba authored by Anthony Koo's avatar Anthony Koo Committed by Alex Deucher
Browse files

drm/amd/display: Refactor output transfer function to stream



Refactor part 3 - Moving output transfer function from surface to stream

Split HWSS to program degamma and regamma separately.
Degamma should be dependent on input transfer function.
And Regamma should depend on the desired output transfer function.

Signed-off-by: default avatarAnthony Koo <anthony.koo@amd.com>
Reviewed-by: default avatarAric Cyr <Aric.Cyr@amd.com>
Acked-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 9cdc4e7c
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -513,6 +513,7 @@ static void fill_gamma_from_crtc(
	struct dc_gamma *gamma;
	struct drm_crtc_state *state = crtc->state;
	struct drm_color_lut *lut = (struct drm_color_lut *) state->gamma_lut->data;
	struct dc_transfer_func *input_tf;

	gamma = dc_create_gamma();

@@ -529,6 +530,16 @@ static void fill_gamma_from_crtc(
	gamma->size = sizeof(gamma->gamma_ramp_rgb256x3x16);

	dc_surface->gamma_correction = gamma;

	input_tf = dc_create_transfer_func();

	if (input_tf == NULL)
		return;

	input_tf->type = TF_TYPE_PREDEFINED;
	input_tf->tf = TRANSFER_FUNCTION_SRGB;

	dc_surface->in_transfer_func = input_tf;
}

static void fill_plane_attributes(
+15 −8
Original line number Diff line number Diff line
@@ -1394,6 +1394,7 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda

		for (j = 0; j < context->res_ctx.pool->pipe_count; j++) {
			struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
			struct core_stream *stream = pipe_ctx->stream;

			if (pipe_ctx->surface != surface)
				continue;
@@ -1472,15 +1473,14 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda

			if (updates[i].out_transfer_func &&
					updates[i].out_transfer_func !=
					surface->public.out_transfer_func) {
				if (surface->public.out_transfer_func != NULL)
					stream->public.out_transfer_func) {
				if (stream->public.out_transfer_func != NULL)
					dc_transfer_func_release(
							surface->public.
							stream->public.
							out_transfer_func);

				dc_transfer_func_retain(
						updates[i].out_transfer_func);
				surface->public.out_transfer_func =
				stream->public.out_transfer_func =
						updates[i].out_transfer_func;
			}
		}
@@ -1516,12 +1516,19 @@ void dc_update_surfaces_for_target(struct dc *dc, struct dc_surface_update *upda
				}
			}

			if (is_new_pipe_surface[j] ||
					updates[i].in_transfer_func)
				core_dc->hwss.set_input_transfer_func(
						pipe_ctx, pipe_ctx->surface);

			if (is_new_pipe_surface[j] ||
					updates[i].gamma ||
					updates[i].in_transfer_func ||
					updates[i].out_transfer_func)
				core_dc->hwss.set_gamma_correction(
						pipe_ctx, pipe_ctx->surface);
				core_dc->hwss.set_output_transfer_func(
						pipe_ctx,
						pipe_ctx->surface,
						pipe_ctx->stream);

		}
		if (apply_ctx) {
			core_dc->hwss.apply_ctx_for_surface(core_dc, surface, context);
+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ static bool construct(struct core_stream *stream,
static void destruct(struct core_stream *stream)
{
	dc_sink_release(&stream->sink->public);
	if (stream->public.out_transfer_func != NULL)
		dc_transfer_func_release(
				stream->public.out_transfer_func);
}

void dc_stream_retain(const struct dc_stream *dc_stream)
+1 −5
Original line number Diff line number Diff line
@@ -76,9 +76,6 @@ static void destruct(struct surface *surface)
	if (surface->protected.public.in_transfer_func != NULL)
		dc_transfer_func_release(
				surface->protected.public.in_transfer_func);
	if (surface->protected.public.out_transfer_func != NULL)
		dc_transfer_func_release(
				surface->protected.public.out_transfer_func);
}

/*******************************************************************************
@@ -223,9 +220,8 @@ void dc_transfer_func_release(const struct dc_transfer_func *dc_tf)
		dm_free(tf);
}

struct dc_transfer_func *dc_create_transfer_func(const struct dc *dc)
struct dc_transfer_func *dc_create_transfer_func()
{
	struct core_dc *core_dc = DC_TO_CORE(dc);
	struct transfer_func *tf = dm_alloc(sizeof(*tf));

	if (tf == NULL)
+5 −4
Original line number Diff line number Diff line
@@ -254,6 +254,7 @@ struct dc_transfer_func_distributed_points {
enum dc_transfer_func_predefined {
	TRANSFER_FUNCTION_SRGB,
	TRANSFER_FUNCTION_BT709,
	TRANSFER_FUNCTION_PQ,
	TRANSFER_FUNCTION_LINEAR,
};

@@ -287,7 +288,6 @@ struct dc_surface {
	const struct dc_gamma *gamma_correction;

	const struct dc_transfer_func *in_transfer_func;
	const struct dc_transfer_func *out_transfer_func;
};

struct dc_plane_info {
@@ -353,7 +353,7 @@ struct dc_gamma *dc_create_gamma(void);

void dc_transfer_func_retain(const struct dc_transfer_func *dc_tf);
void dc_transfer_func_release(const struct dc_transfer_func *dc_tf);
struct dc_transfer_func *dc_create_transfer_func(const struct dc *dc);
struct dc_transfer_func *dc_create_transfer_func(void);

/*
 * This structure holds a surface address.  There could be multiple addresses
@@ -527,10 +527,11 @@ struct dc_stream {

	struct freesync_context freesync_ctx;

	/* TODO: dithering */
	/* TODO: transfer function (CSC/regamma/gamut remap) */
	const struct dc_transfer_func *out_transfer_func;
	struct colorspace_transform gamut_remap_matrix;
	struct csc_transform csc_color_matrix;

	/* TODO: dithering */
	/* TODO: custom INFO packets */
	/* TODO: ABM info (DMCU) */
	/* TODO: PSR info */
Loading