Loading drivers/media/platform/msm/vidc/governors/fixedpoint.h +4 −4 Original line number Diff line number Diff line /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -22,14 +22,14 @@ * Also should be normally typedef'ed to intmax_t but that doesn't seem to be * available in the kernel */ #define fp_t size_t #define fp_t uint64_t /* (Arbitrarily) make the first 25% of the bits to be the fractional bits */ #define FP_FRACTIONAL_BITS ((sizeof(fp_t) * 8) / 4) #define FP(__i, __f_n, __f_d) \ ((((fp_t)(__i)) << FP_FRACTIONAL_BITS) + \ (((__f_n) << FP_FRACTIONAL_BITS) / (__f_d))) div64_u64(((__f_n) << FP_FRACTIONAL_BITS), (__f_d))) #define FP_INT(__i) FP(__i, 0, 1) #define FP_ONE FP_INT(1) Loading Loading @@ -66,7 +66,7 @@ static inline fp_t fp_mult(fp_t a, fp_t b) static inline fp_t fp_div(fp_t a, fp_t b) { return (a << FP_FRACTIONAL_BITS) / b; return div64_u64(a << FP_FRACTIONAL_BITS, b); } #endif drivers/media/platform/msm/vidc/governors/msm_vidc_dyn_gov.c +66 −42 Original line number Diff line number Diff line /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -37,7 +37,7 @@ struct governor { * bandwidth(BASELINE_DIMENSIONS.width, BASELINE_DIMENSIONS.height) */ const struct { int height, width; uint32_t height, width; } BASELINE_DIMENSIONS = { .width = 1280, .height = 720, Loading Loading @@ -76,7 +76,7 @@ const unsigned long NOMINAL_BW_MBPS = 6000 /* ideally 320 Mhz */, static struct lut { int frame_size; /* width x height */ int frame_rate; unsigned long bitrate; fp_t bitrate; struct { int bpp; fp_t ratio; Loading @@ -87,10 +87,12 @@ static struct lut { .frame_rate = 30, .bitrate = 14, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -98,10 +100,12 @@ static struct lut { .frame_rate = 60, .bitrate = 22, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -109,10 +113,12 @@ static struct lut { .frame_rate = 30, .bitrate = 40, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -120,10 +126,12 @@ static struct lut { .frame_rate = 60, .bitrate = 64, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -131,10 +139,12 @@ static struct lut { .frame_rate = 30, .bitrate = 64, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -142,10 +152,12 @@ static struct lut { .frame_rate = 60, .bitrate = 102, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -153,10 +165,12 @@ static struct lut { .frame_rate = 30, .bitrate = 84, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -164,10 +178,12 @@ static struct lut { .frame_rate = 60, .bitrate = 134, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -175,10 +191,12 @@ static struct lut { .frame_rate = 30, .bitrate = 88, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -186,10 +204,12 @@ static struct lut { .frame_rate = 60, .bitrate = 141, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -197,10 +217,12 @@ static struct lut { .frame_rate = 30, .bitrate = 96, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -208,17 +230,19 @@ static struct lut { .frame_rate = 60, .bitrate = 154, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, }; static struct lut const *__lut(int width, int height, int fps) static struct lut const *__lut(uint32_t width, uint32_t height, uint32_t fps) { int frame_size = height * width, c = 0; uint32_t frame_size = height * width, c = 0; do { if (LUT[c].frame_size >= frame_size && LUT[c].frame_rate >= fps) Loading Loading @@ -330,17 +354,17 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, * measured heuristics and hardcoded numbers taken from the firmware. */ /* Decoder parameters */ int width, height, lcu_size, dpb_bpp, opb_bpp, fps, opb_factor; uint32_t width, height, lcu_size, dpb_bpp, opb_bpp, fps; bool unified_dpb_opb, dpb_compression_enabled, opb_compression_enabled, llc_ref_read_l2_cache_enabled = false, llc_vpss_ds_line_buf_enabled = false; fp_t dpb_opb_scaling_ratio, dpb_read_compression_factor, dpb_write_compression_factor, opb_compression_factor, qsmmu_bw_overhead_factor, height_ratio; qsmmu_bw_overhead_factor, height_ratio, opb_factor; /* Derived parameters */ int lcu_per_frame, tnbr_per_lcu, colocated_bytes_per_lcu; unsigned long bitrate; fp_t lcu_per_frame, tnbr_per_lcu, colocated_bytes_per_lcu; fp_t bitrate; fp_t bins_to_bit_factor, dpb_write_factor, ten_bpc_packing_factor, ten_bpc_bpp_factor, vsp_read_factor, vsp_write_factor, Loading @@ -360,8 +384,8 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, fp_t dpb_read, opb_read, total; } llc = {0}; unsigned long ret = 0; unsigned int integer_part, frac_part; fp_t ret = 0; fp_t integer_part, frac_part; width = max(d->input_width, BASELINE_DIMENSIONS.width); height = max(d->input_height, BASELINE_DIMENSIONS.height); Loading Loading @@ -446,13 +470,13 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, ddr.vsp_write = fp_div(fp_mult(FP_INT(bitrate), vsp_write_factor), FP_INT(8)); ddr.collocated_read = FP_INT(lcu_per_frame * colocated_bytes_per_lcu * fps / bps(1)); ddr.collocated_write = FP_INT(lcu_per_frame * colocated_bytes_per_lcu * fps / bps(1)); ddr.collocated_read = FP_INT(div64_u64(lcu_per_frame * colocated_bytes_per_lcu * fps, bps(1))); ddr.collocated_write = FP_INT(div64_u64(lcu_per_frame * colocated_bytes_per_lcu * fps, bps(1))); ddr.line_buffer_read = FP_INT(tnbr_per_lcu * lcu_per_frame * fps / bps(1)); ddr.line_buffer_read = FP_INT(div64_u64(tnbr_per_lcu * lcu_per_frame * fps, bps(1))); ddr.line_buffer_write = ddr.line_buffer_read; bw_for_1x_8bpc = fp_div(FP_INT(width * height), FP_INT(32 * 8)); Loading Loading @@ -590,7 +614,7 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d, */ /* Encoder Parameters */ int width, height, fps, dpb_bpp, lcu_per_frame, lcu_size, u32 width, height, fps, dpb_bpp, lcu_per_frame, lcu_size, vertical_tile_width, colocated_bytes_per_lcu, bitrate, ref_overlap_bw_factor; enum hal_uncompressed_format dpb_color_format, original_color_format; Loading drivers/media/platform/msm/vidc/msm_vidc_clocks.c +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, } dprintk(VIDC_PROF, "Input CR = %d Recon CR = %d Complexity Factor = %d\n", "Input CR = %d Recon CR = %llu Complexity Factor = %llu\n", vote_data->input_cr, vote_data->compression_ratio, vote_data->complexity_factor); Loading drivers/media/platform/msm/vidc/vidc_hfi_api.h +5 −5 Original line number Diff line number Diff line Loading @@ -1407,11 +1407,11 @@ struct vidc_bus_vote_data { enum hal_video_codec codec; enum hal_uncompressed_format color_formats[2]; int num_formats; /* 1 = DPB-OPB unified; 2 = split */ int input_height, input_width, fps, bitrate; int output_height, output_width; int compression_ratio; int complexity_factor; int input_cr; u32 input_height, input_width, fps, bitrate; u32 output_height, output_width; uint64_t compression_ratio; uint64_t complexity_factor; u32 input_cr; bool use_dpb_read; unsigned int lcu_size; enum msm_vidc_power_mode power_mode; Loading Loading
drivers/media/platform/msm/vidc/governors/fixedpoint.h +4 −4 Original line number Diff line number Diff line /* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading @@ -22,14 +22,14 @@ * Also should be normally typedef'ed to intmax_t but that doesn't seem to be * available in the kernel */ #define fp_t size_t #define fp_t uint64_t /* (Arbitrarily) make the first 25% of the bits to be the fractional bits */ #define FP_FRACTIONAL_BITS ((sizeof(fp_t) * 8) / 4) #define FP(__i, __f_n, __f_d) \ ((((fp_t)(__i)) << FP_FRACTIONAL_BITS) + \ (((__f_n) << FP_FRACTIONAL_BITS) / (__f_d))) div64_u64(((__f_n) << FP_FRACTIONAL_BITS), (__f_d))) #define FP_INT(__i) FP(__i, 0, 1) #define FP_ONE FP_INT(1) Loading Loading @@ -66,7 +66,7 @@ static inline fp_t fp_mult(fp_t a, fp_t b) static inline fp_t fp_div(fp_t a, fp_t b) { return (a << FP_FRACTIONAL_BITS) / b; return div64_u64(a << FP_FRACTIONAL_BITS, b); } #endif
drivers/media/platform/msm/vidc/governors/msm_vidc_dyn_gov.c +66 −42 Original line number Diff line number Diff line /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved. /* Copyright (c) 2015-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and Loading Loading @@ -37,7 +37,7 @@ struct governor { * bandwidth(BASELINE_DIMENSIONS.width, BASELINE_DIMENSIONS.height) */ const struct { int height, width; uint32_t height, width; } BASELINE_DIMENSIONS = { .width = 1280, .height = 720, Loading Loading @@ -76,7 +76,7 @@ const unsigned long NOMINAL_BW_MBPS = 6000 /* ideally 320 Mhz */, static struct lut { int frame_size; /* width x height */ int frame_rate; unsigned long bitrate; fp_t bitrate; struct { int bpp; fp_t ratio; Loading @@ -87,10 +87,12 @@ static struct lut { .frame_rate = 30, .bitrate = 14, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -98,10 +100,12 @@ static struct lut { .frame_rate = 60, .bitrate = 22, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -109,10 +113,12 @@ static struct lut { .frame_rate = 30, .bitrate = 40, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -120,10 +126,12 @@ static struct lut { .frame_rate = 60, .bitrate = 64, .compression_ratio = { /* FP(1, 28, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 28, 100)), 83886), /* FP(1, 23, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 23, 100)), 80609), } }, { Loading @@ -131,10 +139,12 @@ static struct lut { .frame_rate = 30, .bitrate = 64, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -142,10 +152,12 @@ static struct lut { .frame_rate = 60, .bitrate = 102, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -153,10 +165,12 @@ static struct lut { .frame_rate = 30, .bitrate = 84, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -164,10 +178,12 @@ static struct lut { .frame_rate = 60, .bitrate = 134, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -175,10 +191,12 @@ static struct lut { .frame_rate = 30, .bitrate = 88, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -186,10 +204,12 @@ static struct lut { .frame_rate = 60, .bitrate = 141, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -197,10 +217,12 @@ static struct lut { .frame_rate = 30, .bitrate = 96, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, { Loading @@ -208,17 +230,19 @@ static struct lut { .frame_rate = 60, .bitrate = 154, .compression_ratio = { /* FP(1, 26, 100) */ GENERATE_COMPRESSION_PROFILE(8, FP(1, 26, 100)), 82575), /* FP(1, 22, 100) */ GENERATE_COMPRESSION_PROFILE(10, FP(1, 22, 100)), 79953), } }, }; static struct lut const *__lut(int width, int height, int fps) static struct lut const *__lut(uint32_t width, uint32_t height, uint32_t fps) { int frame_size = height * width, c = 0; uint32_t frame_size = height * width, c = 0; do { if (LUT[c].frame_size >= frame_size && LUT[c].frame_rate >= fps) Loading Loading @@ -330,17 +354,17 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, * measured heuristics and hardcoded numbers taken from the firmware. */ /* Decoder parameters */ int width, height, lcu_size, dpb_bpp, opb_bpp, fps, opb_factor; uint32_t width, height, lcu_size, dpb_bpp, opb_bpp, fps; bool unified_dpb_opb, dpb_compression_enabled, opb_compression_enabled, llc_ref_read_l2_cache_enabled = false, llc_vpss_ds_line_buf_enabled = false; fp_t dpb_opb_scaling_ratio, dpb_read_compression_factor, dpb_write_compression_factor, opb_compression_factor, qsmmu_bw_overhead_factor, height_ratio; qsmmu_bw_overhead_factor, height_ratio, opb_factor; /* Derived parameters */ int lcu_per_frame, tnbr_per_lcu, colocated_bytes_per_lcu; unsigned long bitrate; fp_t lcu_per_frame, tnbr_per_lcu, colocated_bytes_per_lcu; fp_t bitrate; fp_t bins_to_bit_factor, dpb_write_factor, ten_bpc_packing_factor, ten_bpc_bpp_factor, vsp_read_factor, vsp_write_factor, Loading @@ -360,8 +384,8 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, fp_t dpb_read, opb_read, total; } llc = {0}; unsigned long ret = 0; unsigned int integer_part, frac_part; fp_t ret = 0; fp_t integer_part, frac_part; width = max(d->input_width, BASELINE_DIMENSIONS.width); height = max(d->input_height, BASELINE_DIMENSIONS.height); Loading Loading @@ -446,13 +470,13 @@ static unsigned long __calculate_decoder(struct vidc_bus_vote_data *d, ddr.vsp_write = fp_div(fp_mult(FP_INT(bitrate), vsp_write_factor), FP_INT(8)); ddr.collocated_read = FP_INT(lcu_per_frame * colocated_bytes_per_lcu * fps / bps(1)); ddr.collocated_write = FP_INT(lcu_per_frame * colocated_bytes_per_lcu * fps / bps(1)); ddr.collocated_read = FP_INT(div64_u64(lcu_per_frame * colocated_bytes_per_lcu * fps, bps(1))); ddr.collocated_write = FP_INT(div64_u64(lcu_per_frame * colocated_bytes_per_lcu * fps, bps(1))); ddr.line_buffer_read = FP_INT(tnbr_per_lcu * lcu_per_frame * fps / bps(1)); ddr.line_buffer_read = FP_INT(div64_u64(tnbr_per_lcu * lcu_per_frame * fps, bps(1))); ddr.line_buffer_write = ddr.line_buffer_read; bw_for_1x_8bpc = fp_div(FP_INT(width * height), FP_INT(32 * 8)); Loading Loading @@ -590,7 +614,7 @@ static unsigned long __calculate_encoder(struct vidc_bus_vote_data *d, */ /* Encoder Parameters */ int width, height, fps, dpb_bpp, lcu_per_frame, lcu_size, u32 width, height, fps, dpb_bpp, lcu_per_frame, lcu_size, vertical_tile_width, colocated_bytes_per_lcu, bitrate, ref_overlap_bw_factor; enum hal_uncompressed_format dpb_color_format, original_color_format; Loading
drivers/media/platform/msm/vidc/msm_vidc_clocks.c +1 −1 Original line number Diff line number Diff line Loading @@ -163,7 +163,7 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst, } dprintk(VIDC_PROF, "Input CR = %d Recon CR = %d Complexity Factor = %d\n", "Input CR = %d Recon CR = %llu Complexity Factor = %llu\n", vote_data->input_cr, vote_data->compression_ratio, vote_data->complexity_factor); Loading
drivers/media/platform/msm/vidc/vidc_hfi_api.h +5 −5 Original line number Diff line number Diff line Loading @@ -1407,11 +1407,11 @@ struct vidc_bus_vote_data { enum hal_video_codec codec; enum hal_uncompressed_format color_formats[2]; int num_formats; /* 1 = DPB-OPB unified; 2 = split */ int input_height, input_width, fps, bitrate; int output_height, output_width; int compression_ratio; int complexity_factor; int input_cr; u32 input_height, input_width, fps, bitrate; u32 output_height, output_width; uint64_t compression_ratio; uint64_t complexity_factor; u32 input_cr; bool use_dpb_read; unsigned int lcu_size; enum msm_vidc_power_mode power_mode; Loading