drm/amd/display: refactor the cursor programing codes
Acked-by: Anson Jacob <Anson.Jacob@amd.com> Signed-off-by: Roy Chan <roy.chan@amd.com> Tested-by: Daniel Wheeler <daniel.wheeler@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
f9ccaf6da0
commit
4fd771ea44
1 changed files with 73 additions and 49 deletions
|
|
@ -246,6 +246,40 @@ struct dc_stream_status *dc_stream_get_status(
|
|||
return dc_stream_get_status_from_state(dc->current_state, stream);
|
||||
}
|
||||
|
||||
static void program_cursor_attributes(
|
||||
struct dc *dc,
|
||||
struct dc_stream_state *stream,
|
||||
const struct dc_cursor_attributes *attributes)
|
||||
{
|
||||
int i;
|
||||
struct resource_context *res_ctx;
|
||||
struct pipe_ctx *pipe_to_program = NULL;
|
||||
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
res_ctx = &dc->current_state->res_ctx;
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
|
||||
|
||||
if (pipe_ctx->stream != stream)
|
||||
continue;
|
||||
|
||||
if (!pipe_to_program) {
|
||||
pipe_to_program = pipe_ctx;
|
||||
dc->hwss.cursor_lock(dc, pipe_to_program, true);
|
||||
}
|
||||
|
||||
dc->hwss.set_cursor_attribute(pipe_ctx);
|
||||
if (dc->hwss.set_cursor_sdr_white_level)
|
||||
dc->hwss.set_cursor_sdr_white_level(pipe_ctx);
|
||||
}
|
||||
|
||||
if (pipe_to_program)
|
||||
dc->hwss.cursor_lock(dc, pipe_to_program, false);
|
||||
}
|
||||
|
||||
#ifndef TRIM_FSFT
|
||||
/*
|
||||
* dc_optimize_timing_for_fsft() - dc to optimize timing
|
||||
|
|
@ -270,10 +304,7 @@ bool dc_stream_set_cursor_attributes(
|
|||
struct dc_stream_state *stream,
|
||||
const struct dc_cursor_attributes *attributes)
|
||||
{
|
||||
int i;
|
||||
struct dc *dc;
|
||||
struct resource_context *res_ctx;
|
||||
struct pipe_ctx *pipe_to_program = NULL;
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
bool reset_idle_optimizations = false;
|
||||
#endif
|
||||
|
|
@ -293,7 +324,6 @@ bool dc_stream_set_cursor_attributes(
|
|||
}
|
||||
|
||||
dc = stream->ctx->dc;
|
||||
res_ctx = &dc->current_state->res_ctx;
|
||||
stream->cursor_attributes = *attributes;
|
||||
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
|
|
@ -305,25 +335,7 @@ bool dc_stream_set_cursor_attributes(
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
|
||||
|
||||
if (pipe_ctx->stream != stream)
|
||||
continue;
|
||||
|
||||
if (!pipe_to_program) {
|
||||
pipe_to_program = pipe_ctx;
|
||||
dc->hwss.cursor_lock(dc, pipe_to_program, true);
|
||||
}
|
||||
|
||||
dc->hwss.set_cursor_attribute(pipe_ctx);
|
||||
if (dc->hwss.set_cursor_sdr_white_level)
|
||||
dc->hwss.set_cursor_sdr_white_level(pipe_ctx);
|
||||
}
|
||||
|
||||
if (pipe_to_program)
|
||||
dc->hwss.cursor_lock(dc, pipe_to_program, false);
|
||||
program_cursor_attributes(dc, stream, attributes);
|
||||
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
/* re-enable idle optimizations if necessary */
|
||||
|
|
@ -334,41 +346,19 @@ bool dc_stream_set_cursor_attributes(
|
|||
return true;
|
||||
}
|
||||
|
||||
bool dc_stream_set_cursor_position(
|
||||
static void program_cursor_position(
|
||||
struct dc *dc,
|
||||
struct dc_stream_state *stream,
|
||||
const struct dc_cursor_position *position)
|
||||
{
|
||||
int i;
|
||||
struct dc *dc;
|
||||
struct resource_context *res_ctx;
|
||||
struct pipe_ctx *pipe_to_program = NULL;
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
bool reset_idle_optimizations = false;
|
||||
#endif
|
||||
|
||||
if (NULL == stream) {
|
||||
dm_error("DC: dc_stream is NULL!\n");
|
||||
return false;
|
||||
}
|
||||
if (!stream)
|
||||
return;
|
||||
|
||||
if (NULL == position) {
|
||||
dm_error("DC: cursor position is NULL!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
dc = stream->ctx->dc;
|
||||
res_ctx = &dc->current_state->res_ctx;
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
dc_z10_restore(dc);
|
||||
|
||||
/* disable idle optimizations if enabling cursor */
|
||||
if (dc->idle_optimizations_allowed && !stream->cursor_position.enable && position->enable) {
|
||||
dc_allow_idle_optimizations(dc, false);
|
||||
reset_idle_optimizations = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
stream->cursor_position = *position;
|
||||
|
||||
for (i = 0; i < MAX_PIPES; i++) {
|
||||
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
|
||||
|
|
@ -390,7 +380,41 @@ bool dc_stream_set_cursor_position(
|
|||
|
||||
if (pipe_to_program)
|
||||
dc->hwss.cursor_lock(dc, pipe_to_program, false);
|
||||
}
|
||||
|
||||
bool dc_stream_set_cursor_position(
|
||||
struct dc_stream_state *stream,
|
||||
const struct dc_cursor_position *position)
|
||||
{
|
||||
struct dc *dc;
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
bool reset_idle_optimizations = false;
|
||||
#endif
|
||||
|
||||
if (NULL == stream) {
|
||||
dm_error("DC: dc_stream is NULL!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NULL == position) {
|
||||
dm_error("DC: cursor position is NULL!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
dc = stream->ctx->dc;
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
dc_z10_restore(dc);
|
||||
|
||||
/* disable idle optimizations if enabling cursor */
|
||||
if (dc->idle_optimizations_allowed && !stream->cursor_position.enable && position->enable) {
|
||||
dc_allow_idle_optimizations(dc, false);
|
||||
reset_idle_optimizations = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
stream->cursor_position = *position;
|
||||
|
||||
program_cursor_position(dc, stream, position);
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
/* re-enable idle optimizations if necessary */
|
||||
if (reset_idle_optimizations)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue