From cb6d9283274cc50431cc142026187e65b0c6766b Mon Sep 17 00:00:00 2001 From: Mike Hsieh Date: Thu, 19 Oct 2023 16:14:26 +0800 Subject: [PATCH] amd/vpelib: Add param check for geometric scaling and refactor [WHY] Param check for geometric scaling is required. 3dlut for geometric scaling case is too complicate. [HOW] Add Param check for geometric scaling. Refactor 3dlut for geometric scaling case. Reviewed-by: Roy Chan Acked-by: Alan Liu Signed-off-by: Mike Hsieh Part-of: --- src/amd/vpelib/inc/vpe_types.h | 3 ++- src/amd/vpelib/src/core/color.c | 7 +------ src/amd/vpelib/src/core/common.c | 9 +++------ src/amd/vpelib/src/core/inc/common.h | 2 +- src/amd/vpelib/src/core/resource.c | 1 + src/amd/vpelib/src/core/vpelib.c | 15 ++++++++++++++- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/amd/vpelib/inc/vpe_types.h b/src/amd/vpelib/inc/vpe_types.h index 559a2a87378..3b79e720279 100644 --- a/src/amd/vpelib/inc/vpe_types.h +++ b/src/amd/vpelib/inc/vpe_types.h @@ -72,7 +72,8 @@ enum vpe_status { VPE_STATUS_REPEAT_ITEM, VPE_STATUS_PATCH_OVER_MAXSIZE, VPE_STATUS_INVALID_BUFFER_SIZE, - VPE_STATUS_SCALER_NOT_SET + VPE_STATUS_SCALER_NOT_SET, + VPE_STATUS_GEOMETRICSCALING_ERROR }; /** HW IP level */ diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index 3d3fc67b712..e7fcc316218 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -778,11 +778,9 @@ enum vpe_status vpe_color_update_movable_cm( stream_ctx = &vpe_priv->stream_ctx[stream_idx]; bool enable_3dlut = stream_ctx->stream.tm_params.enable_3dlut; - bool update_3dlut = stream_ctx->stream.tm_params.update_3dlut; if (param->streams->flags.geometric_scaling) { enable_3dlut = false; - update_3dlut = true; } if (stream_ctx->update_3dlut) { @@ -850,10 +848,7 @@ enum vpe_status vpe_color_update_movable_cm( vpe_convert_to_tetrahedral(vpe_priv, param->streams[stream_idx].tm_params.lut_data, stream_ctx->lut3d_func, enable_3dlut); - if (param->streams->flags.geometric_scaling) - stream_ctx->update_3dlut = true; - else - stream_ctx->update_3dlut = false; + stream_ctx->update_3dlut = false; } } exit: diff --git a/src/amd/vpelib/src/core/common.c b/src/amd/vpelib/src/core/common.c index 5c56d0b02d5..159663e754e 100644 --- a/src/amd/vpelib/src/core/common.c +++ b/src/amd/vpelib/src/core/common.c @@ -553,14 +553,11 @@ enum vpe_status vpe_check_input_support(struct vpe *vpe, const struct vpe_stream } enum vpe_status vpe_cache_tone_map_params( - struct stream_ctx *stream_ctx, const struct vpe_build_param *param) + struct stream_ctx *stream_ctx, const struct vpe_stream *stream) { - stream_ctx->update_3dlut = stream_ctx->update_3dlut || param->streams->tm_params.update_3dlut; - - if (param->streams->flags.geometric_scaling) { - stream_ctx->update_3dlut = true; - } + stream_ctx->update_3dlut = stream_ctx->update_3dlut || stream->tm_params.update_3dlut || + (stream_ctx->stream.flags.geometric_scaling != stream->flags.geometric_scaling); return VPE_STATUS_OK; } diff --git a/src/amd/vpelib/src/core/inc/common.h b/src/amd/vpelib/src/core/inc/common.h index e9898cef8d8..f524fd494b9 100644 --- a/src/amd/vpelib/src/core/inc/common.h +++ b/src/amd/vpelib/src/core/inc/common.h @@ -81,7 +81,7 @@ enum vpe_status vpe_check_output_support(struct vpe *vpe, const struct vpe_build enum vpe_status vpe_check_input_support(struct vpe *vpe, const struct vpe_stream *stream); -enum vpe_status vpe_cache_tone_map_params(struct stream_ctx *, const struct vpe_build_param *param); +enum vpe_status vpe_cache_tone_map_params(struct stream_ctx *, const struct vpe_stream *stream); enum vpe_status vpe_check_tone_map_support( struct vpe *vpe, const struct vpe_stream *stream, const struct vpe_build_param *param); diff --git a/src/amd/vpelib/src/core/resource.c b/src/amd/vpelib/src/core/resource.c index 2b777bc3762..e110cf8e6ca 100644 --- a/src/amd/vpelib/src/core/resource.c +++ b/src/amd/vpelib/src/core/resource.c @@ -160,6 +160,7 @@ struct stream_ctx *vpe_alloc_stream_ctx(struct vpe_priv *vpe_priv, uint32_t num_ ctx->vpe_priv = vpe_priv; vpe_color_set_adjustments_to_default(&ctx->color_adjustments); ctx->tf_scaling_factor = vpe_fixpt_one; + ctx->stream.flags.geometric_scaling = 0; } return ctx_base; diff --git a/src/amd/vpelib/src/core/vpelib.c b/src/amd/vpelib/src/core/vpelib.c index d2baffe5863..fcc90ff8183 100644 --- a/src/amd/vpelib/src/core/vpelib.c +++ b/src/amd/vpelib/src/core/vpelib.c @@ -182,6 +182,15 @@ void vpe_destroy(struct vpe **vpe) *vpe = NULL; } +static enum vpe_status validate_geometric_scaling_support(const struct vpe_build_param *param) +{ + if(param->num_streams > 1 && param->streams[0].flags.geometric_scaling) + { + return VPE_STATUS_GEOMETRICSCALING_ERROR; + } + return VPE_STATUS_OK; +} + /***************************************************************************************** * handle_zero_input * handle any zero input stream but background output only @@ -344,7 +353,7 @@ enum vpe_status vpe_check_support( // Need a sticky bit to tell vpe to program the 3dlut on next jobs submission even // if 3dlut has not changed for (i = 0; i < param->num_streams; i++) { - vpe_cache_tone_map_params(&vpe_priv->stream_ctx[i], param); + vpe_cache_tone_map_params(&vpe_priv->stream_ctx[i], ¶m->streams[i]); } if (status == VPE_STATUS_OK) { @@ -450,6 +459,10 @@ enum vpe_status vpe_check_support( vpe_priv->ops_support = true; } + if (status == VPE_STATUS_OK) { + status = validate_geometric_scaling_support(param); + } + if (vpe_priv->init.debug.assert_when_not_support) VPE_ASSERT(status == VPE_STATUS_OK);