diff --git a/src/amd/vpelib/inc/vpelib.h b/src/amd/vpelib/inc/vpelib.h index 3f3e8845959..714452cd352 100644 --- a/src/amd/vpelib/inc/vpelib.h +++ b/src/amd/vpelib/inc/vpelib.h @@ -158,7 +158,7 @@ enum vpe_status vpe_build_resolve_query( * @param[in] param provide the asic version. * @return vpe engine instance if valid. NULL otherwise */ -const struct vpe_engine *vpe_create_engine(struct vpe_init_data *param); +struct vpe_engine *vpe_create_engine(struct vpe_init_data *param); /** * destroy the vpe engine instance. diff --git a/src/amd/vpelib/src/chip/vpe10/inc/vpe10_resource.h b/src/amd/vpelib/src/chip/vpe10/inc/vpe10_resource.h index 268fe953658..e8388e6d0d3 100644 --- a/src/amd/vpelib/src/chip/vpe10/inc/vpe10_resource.h +++ b/src/amd/vpelib/src/chip/vpe10/inc/vpe10_resource.h @@ -106,6 +106,9 @@ bool vpe10_validate_cached_param(struct vpe_priv *vpe_priv, const struct vpe_bui void vpe10_setup_check_funcs(struct vpe_check_support_funcs *funcs); const struct vpe_caps *vpe10_get_capability(void); + +enum vpe_status vpe10_calculate_shaper(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx); + #ifdef __cplusplus } #endif diff --git a/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c b/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c index 98ac68b977e..78e0568f663 100644 --- a/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c +++ b/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c @@ -438,6 +438,7 @@ enum vpe_status vpe10_construct_resource(struct vpe_priv *vpe_priv, struct resou res->update_blnd_gamma = vpe10_update_blnd_gamma; res->update_output_gamma = vpe10_update_output_gamma; res->validate_cached_param = vpe10_validate_cached_param; + res->calculate_shaper = vpe10_calculate_shaper; return VPE_STATUS_OK; err: @@ -1535,3 +1536,8 @@ void vpe10_setup_check_funcs(struct vpe_check_support_funcs *funcs) funcs->get_dcc_compression_input_cap = vpe10_get_dcc_compression_input_cap; funcs->get_dcc_compression_output_cap = vpe10_get_dcc_compression_output_cap; } + +enum vpe_status vpe10_calculate_shaper(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx) +{ + return vpe_calculate_shaper(vpe_priv, stream_ctx); // calculate shaper data and config +} diff --git a/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c b/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c index b403b6425d4..11b6e8fa3ba 100644 --- a/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c +++ b/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c @@ -210,6 +210,7 @@ enum vpe_status vpe11_construct_resource(struct vpe_priv *vpe_priv, struct resou res->update_blnd_gamma = vpe10_update_blnd_gamma; res->update_output_gamma = vpe10_update_output_gamma; res->validate_cached_param = vpe11_validate_cached_param; + res->calculate_shaper = vpe10_calculate_shaper; return VPE_STATUS_OK; err: diff --git a/src/amd/vpelib/src/core/color.c b/src/amd/vpelib/src/core/color.c index a08ec20f7cd..98bad8811ef 100644 --- a/src/amd/vpelib/src/core/color.c +++ b/src/amd/vpelib/src/core/color.c @@ -777,6 +777,40 @@ enum vpe_status vpe_color_update_shaper(const struct vpe_priv *vpe_priv, uint16_ return ret; } +enum vpe_status vpe_calculate_shaper(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx) +{ + uint32_t shaper_norm_factor; + struct vpe_color_space cs; + enum color_space out_lut_cs; + enum color_transfer_func lut_in_tf; + bool need_update_3dlut = true; + bool enable_3dlut = + stream_ctx->stream.tm_params.UID != 0 || stream_ctx->stream.tm_params.enable_3dlut; + + // Get the normalization factor for the shaper based on tone mapping parameters. + get_shaper_norm_factor(&stream_ctx->stream.tm_params, stream_ctx, &shaper_norm_factor); + + // Update the HDR multiplier based on the shaper normalization factor and other parameters. + vpe_color_tm_update_hdr_mult(SHAPER_EXP_MAX_IN, shaper_norm_factor, + &stream_ctx->lut3d_func->hdr_multiplier, enable_3dlut, + vpe_is_fp16(stream_ctx->stream.surface_info.format)); + + if (need_update_3dlut) { + /* DirectConfig loading case */ + vpe_color_update_3dlut(vpe_priv, stream_ctx, enable_3dlut); + } + + // Build the shaper color space based on tone mapping parameters and output surface. + vpe_color_build_shaper_cs(&stream_ctx->stream.tm_params, &vpe_priv->output_ctx.surface, &cs); + + // Extract the color space and transfer function from the shaper color space. + vpe_color_get_color_space_and_tf(&cs, &out_lut_cs, &lut_in_tf); + + // Update the shaper transfer function for the current stream. + return vpe_color_update_shaper( + vpe_priv, SHAPER_EXP_MAX_IN, stream_ctx, lut_in_tf, enable_3dlut); +} + enum vpe_status vpe_color_update_movable_cm( struct vpe_priv *vpe_priv, const struct vpe_build_param *param) { @@ -793,12 +827,9 @@ enum vpe_status vpe_color_update_movable_cm( if (stream_ctx->uid_3dlut != stream_ctx->stream.tm_params.UID) { - uint32_t shaper_norm_factor; struct vpe_color_space tm_out_cs; - struct vpe_color_space cs; enum color_space out_lut_cs; - enum color_transfer_func tf, lut_in_tf; - + enum color_transfer_func tf; if (!stream_ctx->in_shaper_func) { stream_ctx->in_shaper_func = (struct transfer_func *)vpe_zalloc(sizeof(struct transfer_func)); @@ -838,17 +869,7 @@ enum vpe_status vpe_color_update_movable_cm( } } - get_shaper_norm_factor(&stream_ctx->stream.tm_params, stream_ctx, &shaper_norm_factor); - - vpe_color_tm_update_hdr_mult(SHAPER_EXP_MAX_IN, shaper_norm_factor, - &stream_ctx->lut3d_func->hdr_multiplier, enable_3dlut, - vpe_is_fp16(stream_ctx->stream.surface_info.format)); - - vpe_color_build_shaper_cs( - &stream_ctx->stream.tm_params, &vpe_priv->output_ctx.surface, &cs); - vpe_color_get_color_space_and_tf(&cs, &out_lut_cs, &lut_in_tf); - vpe_color_update_shaper( - vpe_priv, SHAPER_EXP_MAX_IN, stream_ctx, lut_in_tf, enable_3dlut); + vpe_priv->resource.calculate_shaper(vpe_priv, stream_ctx); vpe_color_build_tm_cs( &stream_ctx->stream.tm_params, &vpe_priv->output_ctx.surface, &tm_out_cs); diff --git a/src/amd/vpelib/src/core/inc/cmd_builder.h b/src/amd/vpelib/src/core/inc/cmd_builder.h index 6f704d041bf..f279ff66922 100644 --- a/src/amd/vpelib/src/core/inc/cmd_builder.h +++ b/src/amd/vpelib/src/core/inc/cmd_builder.h @@ -26,6 +26,7 @@ #include "vpe_types.h" #include "plane_desc_writer.h" +#include "hw_shared.h" #ifdef __cplusplus extern "C" { @@ -46,6 +47,7 @@ struct cmd_builder { enum vpe_status (*build_collaborate_sync_cmd)( struct vpe_priv *vpe_priv, struct vpe_build_bufs *cur_bufs); + }; #ifdef __cplusplus diff --git a/src/amd/vpelib/src/core/inc/color.h b/src/amd/vpelib/src/core/inc/color.h index 61e5f24b1ee..33ead14d767 100644 --- a/src/amd/vpelib/src/core/inc/color.h +++ b/src/amd/vpelib/src/core/inc/color.h @@ -264,6 +264,8 @@ enum vpe_status vpe_color_update_movable_cm( void vpe_color_get_color_space_and_tf( const struct vpe_color_space *vcs, enum color_space *cs, enum color_transfer_func *tf); +enum vpe_status vpe_shaper_generator(struct vpe_priv *vpe_priv); + bool vpe_use_csc_adjust(const struct vpe_color_adjust *adjustments); bool vpe_is_rgb_equal(const struct pwl_result_data *rgb, uint32_t num); @@ -302,6 +304,8 @@ bool vpe_color_update_degamma_tf(struct vpe_priv *vpe_priv, enum color_transfer_ enum color_range_type vpe_get_range_type( enum color_space color_space, enum vpe_surface_pixel_format format); +enum vpe_status vpe_calculate_shaper(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx); + #ifdef __cplusplus } #endif diff --git a/src/amd/vpelib/src/core/inc/resource.h b/src/amd/vpelib/src/core/inc/resource.h index b65d45e2ad6..9fd414fb218 100644 --- a/src/amd/vpelib/src/core/inc/resource.h +++ b/src/amd/vpelib/src/core/inc/resource.h @@ -114,6 +114,9 @@ struct resource { bool geometric_scaling); bool (*validate_cached_param)(struct vpe_priv *vpe_priv, const struct vpe_build_param *param); + + enum vpe_status (*calculate_shaper)(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx); + // Indicates the nominal range hdr input content should be in during processing. int internal_hdr_normalization; diff --git a/src/amd/vpelib/src/core/vpelib.c b/src/amd/vpelib/src/core/vpelib.c index 9e690122efc..8f6ae0e6b5b 100644 --- a/src/amd/vpelib/src/core/vpelib.c +++ b/src/amd/vpelib/src/core/vpelib.c @@ -1011,7 +1011,7 @@ enum vpe_status vpe_build_resolve_query( return result; } -const struct vpe_engine *vpe_create_engine(struct vpe_init_data *params) +struct vpe_engine *vpe_create_engine(struct vpe_init_data *params) { struct vpe_engine_priv *engine_priv; struct vpe_engine *engine_handle;