From f351e4be11e2dbcfe99d0c0219ebdfd99e14b629 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Thu, 29 Feb 2024 17:04:53 +0800 Subject: [PATCH] radeonsi/vpe: support vpe 1.1 update radeonsi and vpelib to support vpe 1.1 Co-authored-by: Alan Liu Signed-off-by: Peyton Lee Signed-off-by: Yifan Zhang Part-of: --- src/amd/vpelib/inc/vpe_types.h | 3 + src/amd/vpelib/meson.build | 6 + .../src/chip/vpe11/inc/vpe11_cmd_builder.h | 38 +++ .../src/chip/vpe11/inc/vpe11_resource.h | 42 ++++ .../vpelib/src/chip/vpe11/vpe11_cmd_builder.c | 68 +++++ .../vpelib/src/chip/vpe11/vpe11_resource.c | 237 ++++++++++++++++++ src/amd/vpelib/src/core/background.c | 4 + src/amd/vpelib/src/core/inc/cmd_builder.h | 4 + src/amd/vpelib/src/core/inc/vpe_command.h | 11 + src/amd/vpelib/src/core/inc/vpe_priv.h | 6 + src/amd/vpelib/src/core/resource.c | 20 ++ src/amd/vpelib/src/core/vpelib.c | 57 +++++ src/gallium/drivers/radeonsi/si_vpe.c | 8 + 13 files changed, 504 insertions(+) create mode 100644 src/amd/vpelib/src/chip/vpe11/inc/vpe11_cmd_builder.h create mode 100644 src/amd/vpelib/src/chip/vpe11/inc/vpe11_resource.h create mode 100644 src/amd/vpelib/src/chip/vpe11/vpe11_cmd_builder.c create mode 100644 src/amd/vpelib/src/chip/vpe11/vpe11_resource.c diff --git a/src/amd/vpelib/inc/vpe_types.h b/src/amd/vpelib/inc/vpe_types.h index c8498388f88..6dcbbf64db3 100644 --- a/src/amd/vpelib/inc/vpe_types.h +++ b/src/amd/vpelib/inc/vpe_types.h @@ -80,6 +80,7 @@ enum vpe_status { enum vpe_ip_level { VPE_IP_LEVEL_UNKNOWN = (-1), VPE_IP_LEVEL_1_0, + VPE_IP_LEVEL_1_1 }; /**************************************** @@ -604,6 +605,8 @@ struct vpe_build_param { uint32_t reserved : 31; } flags; + uint16_t num_instances; + bool collaboration_mode; }; /** reported through vpe_check_support() diff --git a/src/amd/vpelib/meson.build b/src/amd/vpelib/meson.build index 642e87cbc6d..a9dc3eea471 100644 --- a/src/amd/vpelib/meson.build +++ b/src/amd/vpelib/meson.build @@ -41,6 +41,7 @@ c_args_vpe += [ '-DLITTLEENDIAN_CPU', '-DVPE_BUILD_1_0', '-DVPE_BUILD_1_X', + '-DVPE_BUILD_1_1', ] vpe_files = files( @@ -127,6 +128,10 @@ vpe_files = files( 'src/chip/vpe10/vpe10_background.c', 'src/chip/vpe10/vpe10_cdc.c', 'src/chip/vpe10/vpe10_vpec.c', + 'src/chip/vpe11/inc/vpe11_cmd_builder.h', + 'src/chip/vpe11/inc/vpe11_resource.h', + 'src/chip/vpe11/vpe11_cmd_builder.c', + 'src/chip/vpe11/vpe11_resource.c', ) inc_amd_vpe = include_directories( @@ -136,6 +141,7 @@ inc_amd_vpe = include_directories( 'src/chip', 'src/utils/inc', 'src/chip/vpe10/inc', + 'src/chip/vpe11/inc', ) libvpe = static_library( diff --git a/src/amd/vpelib/src/chip/vpe11/inc/vpe11_cmd_builder.h b/src/amd/vpelib/src/chip/vpe11/inc/vpe11_cmd_builder.h new file mode 100644 index 00000000000..5d8c3914a7e --- /dev/null +++ b/src/amd/vpelib/src/chip/vpe11/inc/vpe11_cmd_builder.h @@ -0,0 +1,38 @@ +/* Copyright 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#pragma once + +#include "cmd_builder.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void vpe11_construct_cmd_builder(struct vpe_priv *vpe_priv, struct cmd_builder *cmd_builder); + +enum vpe_status vpe11_build_collaborate_sync_cmd( + struct vpe_priv *vpe_priv, struct vpe_build_bufs *cur_bufs, bool is_end); +#ifdef __cplusplus +} +#endif diff --git a/src/amd/vpelib/src/chip/vpe11/inc/vpe11_resource.h b/src/amd/vpelib/src/chip/vpe11/inc/vpe11_resource.h new file mode 100644 index 00000000000..96d646171d4 --- /dev/null +++ b/src/amd/vpelib/src/chip/vpe11/inc/vpe11_resource.h @@ -0,0 +1,42 @@ +/* Copyright 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#pragma once + +#include "resource.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum vpe_status vpe11_construct_resource(struct vpe_priv *vpe_priv, struct resource *res); + +void vpe11_destroy_resource(struct vpe_priv *vpe_priv, struct resource *res); + +enum vpe_status vpe11_set_num_segments(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx, + struct scaler_data *scl_data, struct vpe_rect *src_rect, struct vpe_rect *dst_rect, + uint32_t *max_seg_width); + +#ifdef __cplusplus +} +#endif diff --git a/src/amd/vpelib/src/chip/vpe11/vpe11_cmd_builder.c b/src/amd/vpelib/src/chip/vpe11/vpe11_cmd_builder.c new file mode 100644 index 00000000000..6189714c391 --- /dev/null +++ b/src/amd/vpelib/src/chip/vpe11/vpe11_cmd_builder.c @@ -0,0 +1,68 @@ +/* Copyright 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#include "vpe_assert.h" +#include "common.h" +#include "vpe_priv.h" +#include "vpe_command.h" +#include "vpe10_cmd_builder.h" +#include "vpe11_cmd_builder.h" +#include "plane_desc_writer.h" +#include "reg_helper.h" + +void vpe11_construct_cmd_builder(struct vpe_priv *vpe_priv, struct cmd_builder *builder) +{ + builder->build_noops = vpe10_build_noops; + builder->build_vpe_cmd = vpe10_build_vpe_cmd; + builder->build_plane_descriptor = vpe10_build_plane_descriptor; + // build collaborate sync cmd + builder->build_collaborate_sync_cmd = vpe11_build_collaborate_sync_cmd; +} + +enum vpe_status vpe11_build_collaborate_sync_cmd( + struct vpe_priv *vpe_priv, struct vpe_build_bufs *cur_bufs, bool is_end) +{ + struct vpe_buf *buf = &cur_bufs->cmd_buf; + uint32_t *cmd_space; + uint64_t size = 2 * sizeof(uint32_t); + uint32_t collarborate_sync_data = vpe_priv->collaborate_sync_index; + enum vpe_status status = VPE_STATUS_OK; + + if (buf->size < size) + status = VPE_STATUS_BUFFER_OVERFLOW; + + if (status == VPE_STATUS_OK) { + cmd_space = (uint32_t*)(uintptr_t)buf->cpu_va; + *cmd_space++ = VPE_COLLABORATE_SYNC_CMD_HEADER; + *cmd_space++ = VPE_COLLABORATE_SYNC_DATA_MASK(collarborate_sync_data); + + if (is_end == true) { + vpe_priv->collaborate_sync_index++; + } + buf->cpu_va += size; + buf->gpu_va += size; + buf->size -= size; + } + + return status; +} diff --git a/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c b/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c new file mode 100644 index 00000000000..9fa5b49487d --- /dev/null +++ b/src/amd/vpelib/src/chip/vpe11/vpe11_resource.c @@ -0,0 +1,237 @@ +/* Copyright 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: AMD + * + */ +#include +#include "vpe_priv.h" +#include "common.h" +#include "vpe11_resource.h" +#include "vpe10_resource.h" +#include "vpe11_cmd_builder.h" +#include "vpe10_vpec.h" +#include "vpe10_cdc.h" +#include "vpe10_dpp.h" +#include "vpe10_mpc.h" +#include "vpe10_opp.h" +#include "vpe_command.h" +#include "vpe10_cm_common.h" +#include "vpe10_background.h" +#include "vpe10/inc/asic/bringup_vpe_6_1_0_offset.h" +#include "vpe10/inc/asic/bringup_vpe_6_1_0_sh_mask.h" +#include "vpe10/inc/asic/bringup_vpe_6_1_0_default.h" +#include "vpe10/inc/asic/vpe_1_0_offset.h" +#include "custom_fp16.h" +#include "custom_float.h" +#include "background.h" + +#define LUT_NUM_ENTRIES (17 * 17 * 17) +#define LUT_ENTRY_SIZE (2) +#define LUT_NUM_COMPONENT (3) +#define LUT_BUFFER_SIZE (LUT_NUM_ENTRIES * LUT_ENTRY_SIZE * LUT_NUM_COMPONENT) + +// set field/register/bitfield name +#define SFRB(field_name, reg_name, post_fix) .field_name = reg_name##__##field_name##post_fix + +#define BASE_INNER(seg_id) VPE_BASE__INST0_SEG##seg_id + +#define BASE(seg_id) BASE_INNER(seg_id) + +// set register with block id and default val, init lastWrittenVal as default while isWritten set to +// false +#define SRIDFVL(reg_name, block, id) \ + .reg_name = {BASE(reg##reg_name##_BASE_IDX) + reg##reg_name, reg##reg_name##_##DEFAULT, \ + reg##reg_name##_##DEFAULT, false} + +static struct vpe_caps caps = { + .lut_size = LUT_BUFFER_SIZE, + .rotation_support = 0, + .h_mirror_support = 1, + .v_mirror_support = 0, + .is_apu = 1, + .bg_color_check_support = 0, + .resource_caps = + { + .num_dpp = 1, + .num_opp = 1, + .num_mpc_3dlut = 1, + .num_queue = 8, + }, + .color_caps = {.dpp = + { + .pre_csc = 1, + .luma_key = 0, + .dgam_ram = 0, + .post_csc = 1, + .gamma_corr = 1, + .hw_3dlut = 1, + .ogam_ram = 1, /**< programmable gam in output -> gamma_corr */ + .ocsc = 0, + .dgam_rom_caps = + { + .srgb = 1, + .bt2020 = 1, + .gamma2_2 = 1, + .pq = 1, + .hlg = 1, + }, + }, + .mpc = + { + .gamut_remap = 1, + .ogam_ram = 1, + .ocsc = 1, + .shared_3d_lut = 1, + .global_alpha = 1, + .top_bottom_blending = 0, + }}, + .plane_caps = + { + .per_pixel_alpha = 1, + .input_pixel_format_support = + { + .argb_packed_32b = 1, + .nv12 = 1, + .fp16 = 0, + .p010 = 1, /**< planar 4:2:0 10-bit */ + .p016 = 0, /**< planar 4:2:0 16-bit */ + .ayuv = 0, /**< packed 4:4:4 */ + .yuy2 = 0 /**< packed 4:2:2 */ + }, + .output_pixel_format_support = {.argb_packed_32b = 1, + .nv12 = 0, + .fp16 = 1, + .p010 = 0, + .p016 = 0, + .ayuv = 0, + .yuy2 = 0}, + .max_upscale_factor = 64000, + + // 6:1 downscaling ratio: 1000/6 = 166.666 + .max_downscale_factor = 167, + + .pitch_alignment = 256, + .addr_alignment = 256, + .max_viewport_width = 1024, + }, +}; + +static struct vpe_cap_funcs cap_funcs = {.get_dcc_compression_cap = vpe10_get_dcc_compression_cap}; + +enum vpe_status vpe11_construct_resource(struct vpe_priv *vpe_priv, struct resource *res) +{ + struct vpe *vpe = &vpe_priv->pub; + + vpe->caps = ∩︀ + vpe->cap_funcs = &cap_funcs; + + vpe10_construct_vpec(vpe_priv, &res->vpec); + + res->cdc[0] = vpe10_cdc_create(vpe_priv, 0); + if (!res->cdc[0]) + goto err; + + res->dpp[0] = vpe10_dpp_create(vpe_priv, 0); + if (!res->dpp[0]) + goto err; + + res->mpc[0] = vpe10_mpc_create(vpe_priv, 0); + if (!res->mpc[0]) + goto err; + + res->opp[0] = vpe10_opp_create(vpe_priv, 0); + if (!res->opp[0]) + goto err; + + vpe11_construct_cmd_builder(vpe_priv, &res->cmd_builder); + vpe_priv->num_pipe = 1; + + res->internal_hdr_normalization = 1; + + res->check_input_color_space = vpe10_check_input_color_space; + res->check_output_color_space = vpe10_check_output_color_space; + res->check_h_mirror_support = vpe10_check_h_mirror_support; + res->calculate_segments = vpe10_calculate_segments; + res->set_num_segments = vpe11_set_num_segments; + res->split_bg_gap = vpe10_split_bg_gap; + res->calculate_dst_viewport_and_active = vpe10_calculate_dst_viewport_and_active; + res->find_bg_gaps = vpe_find_bg_gaps; + res->create_bg_segments = vpe_create_bg_segments; + res->populate_cmd_info = vpe10_populate_cmd_info; + res->program_frontend = vpe10_program_frontend; + res->program_backend = vpe10_program_backend; + res->get_bufs_req = vpe10_get_bufs_req; + res->get_tf_pwl_params = vpe10_cm_get_tf_pwl_params; + + return VPE_STATUS_OK; +err: + vpe11_destroy_resource(vpe_priv, res); + return VPE_STATUS_ERROR; +} + +void vpe11_destroy_resource(struct vpe_priv *vpe_priv, struct resource *res) +{ + if (res->cdc[0] != NULL) { + vpe_free(container_of(res->cdc[0], struct vpe10_cdc, base)); + res->cdc[0] = NULL; + } + + if (res->dpp[0] != NULL) { + vpe_free(container_of(res->dpp[0], struct vpe10_dpp, base)); + res->dpp[0] = NULL; + } + + if (res->mpc[0] != NULL) { + vpe_free(container_of(res->mpc[0], struct vpe10_mpc, base)); + res->mpc[0] = NULL; + } + + if (res->opp[0] != NULL) { + vpe_free(container_of(res->opp[0], struct vpe10_opp, base)); + res->opp[0] = NULL; + } +} + +enum vpe_status vpe11_set_num_segments(struct vpe_priv *vpe_priv, struct stream_ctx *stream_ctx, + struct scaler_data *scl_data, struct vpe_rect *src_rect, struct vpe_rect *dst_rect, + uint32_t *max_seg_width) +{ + + uint16_t num_segs; + struct dpp *dpp = vpe_priv->resource.dpp[0]; + const uint32_t max_lb_size = dpp->funcs->get_line_buffer_size(); + + *max_seg_width = min(*max_seg_width, max_lb_size / scl_data->taps.v_taps); + + num_segs = vpe_get_num_segments(vpe_priv, src_rect, dst_rect, *max_seg_width); + if ((src_rect->width > (uint32_t)(vpe_priv->vpe_num_instance * VPE_MIN_VIEWPORT_SIZE)) && + (num_segs % vpe_priv->vpe_num_instance != 0)) { + num_segs += (vpe_priv->vpe_num_instance - (num_segs % vpe_priv->vpe_num_instance)); + } + + stream_ctx->segment_ctx = vpe_alloc_segment_ctx(vpe_priv, num_segs); + if (!stream_ctx->segment_ctx) + return VPE_STATUS_NO_MEMORY; + + stream_ctx->num_segments = num_segs; + + return VPE_STATUS_OK; +} diff --git a/src/amd/vpelib/src/core/background.c b/src/amd/vpelib/src/core/background.c index a9dc1610a79..d0aab3d12e9 100644 --- a/src/amd/vpelib/src/core/background.c +++ b/src/amd/vpelib/src/core/background.c @@ -160,7 +160,11 @@ uint16_t vpe_find_bg_gaps(struct vpe_priv *vpe_priv, const struct vpe_rect *targ struct vpe_rect *dst_viewport_rect; bool full_bg = false; const uint32_t max_seg_width = vpe_priv->pub.caps->plane_caps.max_viewport_width; +#ifdef VPE_BUILD_1_1 + const uint16_t num_multiple = vpe_priv->vpe_num_instance ? vpe_priv->vpe_num_instance : 1; +#else const uint16_t num_multiple = 1; +#endif num_segs = vpe_priv->stream_ctx[0].num_segments; dst_viewport_rect = &(vpe_priv->stream_ctx[0].segment_ctx[0].scaler_data.dst_viewport); diff --git a/src/amd/vpelib/src/core/inc/cmd_builder.h b/src/amd/vpelib/src/core/inc/cmd_builder.h index 3d78b489b14..e4bc4a7f67b 100644 --- a/src/amd/vpelib/src/core/inc/cmd_builder.h +++ b/src/amd/vpelib/src/core/inc/cmd_builder.h @@ -43,6 +43,10 @@ struct cmd_builder { enum vpe_status (*build_plane_descriptor)( struct vpe_priv *vpe_priv, struct vpe_buf *buf, uint32_t cmd_idx); +#ifdef VPE_BUILD_1_1 + enum vpe_status (*build_collaborate_sync_cmd)( + struct vpe_priv *vpe_priv, struct vpe_build_bufs *cur_bufs, bool is_end); +#endif }; #ifdef __cplusplus diff --git a/src/amd/vpelib/src/core/inc/vpe_command.h b/src/amd/vpelib/src/core/inc/vpe_command.h index 75286f19018..06f68c8683e 100644 --- a/src/amd/vpelib/src/core/inc/vpe_command.h +++ b/src/amd/vpelib/src/core/inc/vpe_command.h @@ -41,6 +41,9 @@ enum VPE_CMD_OPCODE { VPE_CMD_OPCODE_POLL_REGMEM = 0x8, VPE_CMD_OPCODE_ATOMIC = 0xA, VPE_CMD_OPCODE_PLANE_FILL = 0xB, +#ifdef VPE_BUILD_1_1 + VPE_CMD_OPCODE_COLLABORATE_SYNC = 0xC, +#endif VPE_CMD_OPCODE_TIMESTAMP = 0xD }; @@ -193,6 +196,14 @@ enum VPE_VPEP_CFG_SUBOP { #define VPE_IND_CFG_PKT_REGISTER_OFFSET__SHIFT 2 #define VPE_IND_CFG_PKT_REGISTER_OFFSET_MASK 0x000FFFFC +#ifdef VPE_BUILD_1_1 +// Collaborate sync Command Header +#define VPE_COLLABORATE_SYNC_HEADER_MASK 0x000000FF +#define VPE_COLLABORATE_SYNC_DATA_MASK(collaborate_data) ((collaborate_data) & 0xFFFFFFFF) +#define VPE_COLLABORATE_SYNC_CMD_HEADER \ + (VPE_CMD_HEADER(VPE_CMD_OPCODE_COLLABORATE_SYNC, 0) & VPE_COLLABORATE_SYNC_HEADER_MASK) +#endif + /************************** * Poll Reg/Mem Sub-OpCode **************************/ diff --git a/src/amd/vpelib/src/core/inc/vpe_priv.h b/src/amd/vpelib/src/core/inc/vpe_priv.h index be919cc930d..0bacdd918d0 100644 --- a/src/amd/vpelib/src/core/inc/vpe_priv.h +++ b/src/amd/vpelib/src/core/inc/vpe_priv.h @@ -255,6 +255,12 @@ struct vpe_priv { bool scale_yuv_matrix; // this is a flag that forces scaling the yuv->rgb matrix // when embedding the color adjustments +#ifdef VPE_BUILD_1_1 + // collaborate sync data counter + int32_t collaborate_sync_index; + uint16_t vpe_num_instance; + bool collaboration_mode; +#endif enum vpe_expansion_mode expansion_mode; }; diff --git a/src/amd/vpelib/src/core/resource.c b/src/amd/vpelib/src/core/resource.c index d801de04d09..312c32d8933 100644 --- a/src/amd/vpelib/src/core/resource.c +++ b/src/amd/vpelib/src/core/resource.c @@ -31,6 +31,10 @@ #include "vpe10_resource.h" #endif +#ifdef VPE_BUILD_1_1 +#include "vpe11_resource.h" +#endif + static const struct vpe_debug_options debug_defaults = { .flags = {0}, .cm_in_bypass = 0, @@ -87,6 +91,12 @@ enum vpe_ip_level vpe_resource_parse_ip_version( ip_level = VPE_IP_LEVEL_1_0; break; #endif +#if VPE_BUILD_1_1 + case VPE_VERSION(6, 1, 1): + case VPE_VERSION(6, 1, 2): + ip_level = VPE_IP_LEVEL_1_1; + break; +#endif #endif default: ip_level = VPE_IP_LEVEL_UNKNOWN; @@ -104,6 +114,11 @@ enum vpe_status vpe_construct_resource( case VPE_IP_LEVEL_1_0: status = vpe10_construct_resource(vpe_priv, res); break; +#endif +#ifdef VPE_BUILD_1_1 + case VPE_IP_LEVEL_1_1: + status = vpe11_construct_resource(vpe_priv, res); + break; #endif default: status = VPE_STATUS_NOT_SUPPORTED; @@ -126,6 +141,11 @@ void vpe_destroy_resource(struct vpe_priv *vpe_priv, struct resource *res) case VPE_IP_LEVEL_1_0: vpe10_destroy_resource(vpe_priv, res); break; +#endif +#ifdef VPE_BUILD_1_1 + case VPE_IP_LEVEL_1_1: + vpe11_destroy_resource(vpe_priv, res); + break; #endif default: break; diff --git a/src/amd/vpelib/src/core/vpelib.c b/src/amd/vpelib/src/core/vpelib.c index 9d3afe8c4e0..eb04d69d56f 100644 --- a/src/amd/vpelib/src/core/vpelib.c +++ b/src/amd/vpelib/src/core/vpelib.c @@ -119,6 +119,22 @@ static void override_debug_option( debug->skip_optimal_tap_check = user_debug->skip_optimal_tap_check; } +#ifdef VPE_BUILD_1_1 +static void verify_collaboration_mode(struct vpe_priv *vpe_priv) +{ + if (vpe_priv->pub.level == VPE_IP_LEVEL_1_1) { + if (vpe_priv->collaboration_mode == true) { + vpe_priv->collaborate_sync_index = 1; + } else { + // after the f_model support collaborate sync command + // return VPE_STATUS_ERROR + } + } else if (vpe_priv->pub.level == VPE_IP_LEVEL_1_0) { + vpe_priv->collaboration_mode = false; + } +} +#endif + struct vpe *vpe_create(const struct vpe_init_data *params) { struct vpe_priv *vpe_priv; @@ -356,6 +372,12 @@ enum vpe_status vpe_check_support( if (status != VPE_STATUS_OK) status = VPE_STATUS_NUM_STREAM_NOT_SUPPORTED; +#ifdef VPE_BUILD_1_1 + vpe_priv->collaboration_mode = param->collaboration_mode; + vpe_priv->vpe_num_instance = param->num_instances; + verify_collaboration_mode(vpe_priv); +#endif + if (!vpe_priv->stream_ctx || vpe_priv->num_streams != param->num_streams) { if (vpe_priv->stream_ctx) vpe_free_stream_ctx(vpe_priv); @@ -513,6 +535,14 @@ static bool validate_cached_param(struct vpe_priv *vpe_priv, const struct vpe_bu if (vpe_priv->num_streams != param->num_streams) return false; +#ifdef VPE_BUILD_1_1 + if (vpe_priv->collaboration_mode != param->collaboration_mode) + return false; + + if (param->num_instances > 0 && vpe_priv->vpe_num_instance != param->num_instances) + return false; +#endif + for (i = 0; i < param->num_streams; i++) { struct vpe_stream stream = param->streams[i]; @@ -551,6 +581,9 @@ enum vpe_status vpe_build_commands( int64_t emb_buf_size; uint64_t cmd_buf_gpu_a, cmd_buf_cpu_a; uint64_t emb_buf_gpu_a, emb_buf_cpu_a; +#ifdef VPE_BUILD_1_1 + bool is_collaborate_sync_end = false; +#endif if (!vpe || !param || !bufs) return VPE_STATUS_ERROR; @@ -648,12 +681,36 @@ enum vpe_status vpe_build_commands( &vpe_priv->output_ctx.bg_color, vpe_priv->stream_ctx[0].enable_3dlut); for (cmd_idx = 0; cmd_idx < vpe_priv->num_vpe_cmds; cmd_idx++) { +#ifdef VPE_BUILD_1_1 + if ((vpe_priv->collaboration_mode == true) && + (vpe_priv->vpe_cmd_info[cmd_idx].is_begin == true)) { + status = builder->build_collaborate_sync_cmd( + vpe_priv, &curr_bufs, is_collaborate_sync_end); + if (status != VPE_STATUS_OK) { + vpe_log("failed in building collaborate sync cmd %d\n", (int)status); + } else { + is_collaborate_sync_end = true; + } + } +#endif status = builder->build_vpe_cmd(vpe_priv, &curr_bufs, cmd_idx); if (status != VPE_STATUS_OK) { vpe_log("failed in building vpe cmd %d\n", (int)status); } +#ifdef VPE_BUILD_1_1 + if ((vpe_priv->collaboration_mode == true) && + (vpe_priv->vpe_cmd_info[cmd_idx].is_end == true)) { + status = builder->build_collaborate_sync_cmd( + vpe_priv, &curr_bufs, is_collaborate_sync_end); + if (status != VPE_STATUS_OK) { + vpe_log("failed in building collaborate sync cmd %d\n", (int)status); + } else { + is_collaborate_sync_end = false; + } + } +#endif } } diff --git a/src/gallium/drivers/radeonsi/si_vpe.c b/src/gallium/drivers/radeonsi/si_vpe.c index 79256c33b22..b0a661d806f 100755 --- a/src/gallium/drivers/radeonsi/si_vpe.c +++ b/src/gallium/drivers/radeonsi/si_vpe.c @@ -900,6 +900,14 @@ si_vpe_processor_process_frame(struct pipe_video_codec *codec, // build_param->streams[0].tm_params.enable_3dlut); } + if(vpe_handle->level == VPE_IP_LEVEL_1_1) { + build_param->num_instances = 2; + build_param->collaboration_mode = true; + } else { + build_param->num_instances = 1; + build_param->collaboration_mode = false; + } + result = vpe_check_support(vpe_handle, build_param, &bufs_required); if (VPE_STATUS_OK != result) { SIVPE_ERR("Check support failed with result: %d\n", result);