From 14000cd9c6078ed9154ea1742ebcfd7633100e16 Mon Sep 17 00:00:00 2001 From: Zhongbo Shi Date: Thu, 12 Oct 2023 13:34:40 +0800 Subject: [PATCH] video: driver: avoid array copy for freq and bitrate table Using pointer instead of array copy for frequency and bitrate table. Change-Id: I1c4c10ed0708954a067e8b199e293a2169e68628 Signed-off-by: Zhongbo Shi --- .../platform/common/inc/perf_static_model.h | 3 ++ .../iris33/src/msm_vidc_clock_iris33.c | 31 +++++++++---------- .../iris33/src/msm_vidc_power_iris33.c | 10 ++++++ 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/driver/platform/common/inc/perf_static_model.h b/driver/platform/common/inc/perf_static_model.h index 1983609e04..23d87d8bc3 100644 --- a/driver/platform/common/inc/perf_static_model.h +++ b/driver/platform/common/inc/perf_static_model.h @@ -148,6 +148,9 @@ struct api_calculation_input { /* used in aurora for depth map decode */ u32 lumaonly_decode; + + /* used in freq and bitrate table selection*/ + u32 vpu_ver; }; struct corner_voting { diff --git a/driver/variant/iris33/src/msm_vidc_clock_iris33.c b/driver/variant/iris33/src/msm_vidc_clock_iris33.c index ac5431514f..211d49f4b6 100644 --- a/driver/variant/iris33/src/msm_vidc_clock_iris33.c +++ b/driver/variant/iris33/src/msm_vidc_clock_iris33.c @@ -5,6 +5,7 @@ #include "perf_static_model.h" #include "msm_vidc_debug.h" +#include "msm_vidc_platform.h" #define ENABLE_FINEBITRATE_SUBUHD60 0 @@ -322,8 +323,8 @@ u32 get_bitrate_entry(u32 pixle_count) static int calculate_vsp_min_freq(struct api_calculation_input codec_input, struct api_calculation_freq_output *codec_output) { - u32 frequency_table_value[2][6]; - u32 bitrate_table_2stage_value[5][10]; + u32 (*frequency_table_value)[6]; + u32 (*bitrate_table_2stage_value)[10]; /* * VSP calculation * different methodology from Lahaina @@ -345,16 +346,12 @@ static int calculate_vsp_min_freq(struct api_calculation_input codec_input, input_bitrate_fp = ((u32)(codec_input.bitrate_mbps * 100 + 99)) / 100; - if (codec_input.pipe_num == 4) { - memcpy(frequency_table_value, frequency_table_iris33, - sizeof(frequency_table_value)); - memcpy(bitrate_table_2stage_value, bitrate_table_iris33_2stage_fp, - sizeof(bitrate_table_2stage_value)); - } else if (codec_input.pipe_num == 2) { - memcpy(frequency_table_value, frequency_table_iris33_2p, - sizeof(frequency_table_value)); - memcpy(bitrate_table_2stage_value, bitrate_table_iris33_2p_2stage_fp, - sizeof(bitrate_table_2stage_value)); + if (codec_input.vpu_ver == VPU_VERSION_IRIS33) { + frequency_table_value = frequency_table_iris33; + bitrate_table_2stage_value = bitrate_table_iris33_2stage_fp; + } else if (codec_input.vpu_ver == VPU_VERSION_IRIS33_2P) { + frequency_table_value = frequency_table_iris33_2p; + bitrate_table_2stage_value = bitrate_table_iris33_2p_2stage_fp; } /* 8KUHD60fps with B frame */ @@ -438,12 +435,12 @@ static u32 calculate_pipe_penalty(struct api_calculation_input codec_input) u32 pipe_penalty_codec = 0; u8 avid_commercial_content = 0; u32 pixel_count = 0; - u32 pipe_penalty_value[3][3]; + u32 (*pipe_penalty_value)[3]; - if (codec_input.pipe_num == 4) - memcpy(pipe_penalty_value, pipe_penalty_iris33, sizeof(pipe_penalty_value)); - else if (codec_input.pipe_num == 2) - memcpy(pipe_penalty_value, pipe_penalty_iris33_2p, sizeof(pipe_penalty_value)); + if (codec_input.vpu_ver == VPU_VERSION_IRIS33) + pipe_penalty_value = pipe_penalty_iris33; + else if (codec_input.vpu_ver == VPU_VERSION_IRIS33_2P) + pipe_penalty_value = pipe_penalty_iris33_2p; /* decoder */ if (codec_input.decoder_or_encoder == CODEC_DECODER) { diff --git a/driver/variant/iris33/src/msm_vidc_power_iris33.c b/driver/variant/iris33/src/msm_vidc_power_iris33.c index 8bc389b89d..7c6597d042 100644 --- a/driver/variant/iris33/src/msm_vidc_power_iris33.c +++ b/driver/variant/iris33/src/msm_vidc_power_iris33.c @@ -8,6 +8,7 @@ #include "msm_vidc_driver.h" #include "msm_vidc_inst.h" #include "msm_vidc_core.h" +#include "msm_vidc_platform.h" #include "msm_vidc_debug.h" #include "perf_static_model.h" #include "msm_vidc_power.h" @@ -50,6 +51,7 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s { enum msm_vidc_port_type port; u32 color_fmt, tile_rows_columns = 0; + struct msm_vidc_core *core; if (is_encode_session(inst)) { codec_input->decoder_or_encoder = CODEC_ENCODER; @@ -157,6 +159,9 @@ static int msm_vidc_init_codec_input_freq(struct msm_vidc_inst *inst, u32 data_s /* set as sanity mode, this regression mode has no effect on power calculations */ codec_input->regression_mode = REGRESSION_MODE_SANITY; + core = inst->core; + codec_input->vpu_ver = core->platform->data.vpu_ver; + return 0; } @@ -165,6 +170,7 @@ static int msm_vidc_init_codec_input_bus(struct msm_vidc_inst *inst, struct vidc { u32 complexity_factor_int = 0, complexity_factor_frac = 0, tile_rows_columns = 0; bool opb_compression_enabled = false; + struct msm_vidc_core *core; if (!d) return -EINVAL; @@ -321,6 +327,9 @@ static int msm_vidc_init_codec_input_bus(struct msm_vidc_inst *inst, struct vidc codec_input->av1d_commer_tile_enable = 0; } + core = inst->core; + codec_input->vpu_ver = core->platform->data.vpu_ver; + /* Dump all the variables for easier debugging */ if (msm_vidc_debug & VIDC_BUS) { struct dump dump[] = { @@ -354,6 +363,7 @@ static int msm_vidc_init_codec_input_bus(struct msm_vidc_inst *inst, struct vidc {"lumaonly_decode", "%d", codec_input->lumaonly_decode}, {"av1d_commer_tile_enable", "%d", codec_input->av1d_commer_tile_enable}, {"regression_mode", "%d", codec_input->regression_mode}, + {"vpu_ver", "%d", codec_input->vpu_ver}, }; __dump(dump, ARRAY_SIZE(dump)); }