From 8fa10461c93caff900d921f64db422925ddf0d60 Mon Sep 17 00:00:00 2001 From: Jiali Date: Mon, 17 Jun 2024 14:35:48 -0400 Subject: [PATCH] amd/vpelib: Enhance output format capabilities - Generalize the p2b programming to support chroma viewport if any - Turn vpe_get_element_size_in_bytes to a global helper function Reviewed-by: Jesse Agate Acked-by: Chih-Wei Chien Signed-off-by: Jiali Part-of: --- src/amd/vpelib/src/chip/vpe10/inc/vpe10_cdc_be.h | 3 ++- src/amd/vpelib/src/chip/vpe10/vpe10_cdc_be.c | 3 ++- src/amd/vpelib/src/chip/vpe10/vpe10_resource.c | 2 +- src/amd/vpelib/src/core/color_gamut.c | 1 + src/amd/vpelib/src/core/common.c | 2 +- src/amd/vpelib/src/core/inc/cdc.h | 6 ++++-- src/amd/vpelib/src/core/inc/common.h | 2 ++ 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/amd/vpelib/src/chip/vpe10/inc/vpe10_cdc_be.h b/src/amd/vpelib/src/chip/vpe10/inc/vpe10_cdc_be.h index 9e71a40ee38..c55a9c111d5 100644 --- a/src/amd/vpelib/src/chip/vpe10/inc/vpe10_cdc_be.h +++ b/src/amd/vpelib/src/chip/vpe10/inc/vpe10_cdc_be.h @@ -90,7 +90,8 @@ void vpe10_cdc_program_global_sync( struct cdc_be *cdc_be, uint32_t vupdate_offset, uint32_t vupdate_width, uint32_t vready_offset); void vpe10_cdc_program_p2b_config(struct cdc_be *cdc_be, enum vpe_surface_pixel_format format, - enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport); + enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport, + const struct vpe_rect *viewport_c); #ifdef __cplusplus } diff --git a/src/amd/vpelib/src/chip/vpe10/vpe10_cdc_be.c b/src/amd/vpelib/src/chip/vpe10/vpe10_cdc_be.c index 919c89c1870..4888004f2b0 100644 --- a/src/amd/vpelib/src/chip/vpe10/vpe10_cdc_be.c +++ b/src/amd/vpelib/src/chip/vpe10/vpe10_cdc_be.c @@ -69,7 +69,8 @@ void vpe10_cdc_program_global_sync( } void vpe10_cdc_program_p2b_config(struct cdc_be *cdc_be, enum vpe_surface_pixel_format format, - enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport) + enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport, + const struct vpe_rect *viewport_c) { uint32_t bar_sel0 = (uint32_t)MUX_SEL_CB_B; uint32_t bar_sel1 = (uint32_t)MUX_SEL_Y_G; diff --git a/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c b/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c index 02f814edb2d..a47e54c7ed7 100644 --- a/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c +++ b/src/amd/vpelib/src/chip/vpe10/vpe10_resource.c @@ -869,7 +869,7 @@ int32_t vpe10_program_backend( vpe_priv->be_cb_ctx.share = true; cdc_be->funcs->program_p2b_config( - cdc_be, surface_info->format, surface_info->swizzle, &output_ctx->target_rect); + cdc_be, surface_info->format, surface_info->swizzle, &output_ctx->target_rect, NULL); cdc_be->funcs->program_global_sync(cdc_be, VPE10_CDC_VUPDATE_OFFSET_DEFAULT, VPE10_CDC_VUPDATE_WIDTH_DEFAULT, VPE10_CDC_VREADY_OFFSET_DEFAULT); diff --git a/src/amd/vpelib/src/core/color_gamut.c b/src/amd/vpelib/src/core/color_gamut.c index 091a0eb7aa1..fb58035c4bb 100644 --- a/src/amd/vpelib/src/core/color_gamut.c +++ b/src/amd/vpelib/src/core/color_gamut.c @@ -150,6 +150,7 @@ static enum predefined_gamut_type color_space_to_predefined_gamut_types( case COLOR_SPACE_2020_RGB_FULLRANGE: case COLOR_SPACE_2020_RGB_LIMITEDRANGE: case COLOR_SPACE_2020_YCBCR: + case COLOR_SPACE_2020_YCBCR_LIMITED: return gamut_type_bt2020; default: VPE_ASSERT(0); diff --git a/src/amd/vpelib/src/core/common.c b/src/amd/vpelib/src/core/common.c index ae331f861d5..c955b559245 100644 --- a/src/amd/vpelib/src/core/common.c +++ b/src/amd/vpelib/src/core/common.c @@ -190,7 +190,7 @@ bool vpe_is_yuv(enum vpe_surface_pixel_format format) vpe_is_yuv444(format)); } -static uint8_t vpe_get_element_size_in_bytes(enum vpe_surface_pixel_format format, int plane_idx) +uint8_t vpe_get_element_size_in_bytes(enum vpe_surface_pixel_format format, int plane_idx) { switch (format) { // nv12/21 diff --git a/src/amd/vpelib/src/core/inc/cdc.h b/src/amd/vpelib/src/core/inc/cdc.h index c6c3bc814e9..190ebc2e40f 100644 --- a/src/amd/vpelib/src/core/inc/cdc.h +++ b/src/amd/vpelib/src/core/inc/cdc.h @@ -49,7 +49,8 @@ struct cdc_fe_funcs { uint32_t vupdate_width, uint32_t vready_offset); void (*program_p2b_config)(struct cdc_fe *cdc_fe, enum vpe_surface_pixel_format format, - enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport); + enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport, + const struct vpe_rect *viewport_c); /** segment specific */ void (*program_viewport)( @@ -63,7 +64,8 @@ struct cdc_be_funcs { uint32_t vupdate_width, uint32_t vready_offset); void (*program_p2b_config)(struct cdc_be *cdc_be, enum vpe_surface_pixel_format format, - enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport); + enum vpe_swizzle_mode_values swizzle, const struct vpe_rect *viewport, + const struct vpe_rect *viewport_c); }; struct cdc_fe { diff --git a/src/amd/vpelib/src/core/inc/common.h b/src/amd/vpelib/src/core/inc/common.h index 4b36dbcd668..3162c38ce51 100644 --- a/src/amd/vpelib/src/core/inc/common.h +++ b/src/amd/vpelib/src/core/inc/common.h @@ -88,6 +88,8 @@ enum vpe_status vpe_check_input_support(struct vpe *vpe, const struct vpe_stream enum vpe_status vpe_check_tone_map_support( struct vpe *vpe, const struct vpe_stream *stream, const struct vpe_build_param *param); +uint8_t vpe_get_element_size_in_bytes(enum vpe_surface_pixel_format format, int plane_idx); + #ifdef __cplusplus } #endif