Эх сурвалжийг харах

video: driver: remove duplicate static array inclusion from header

pineapple_technology.h contains multiple static array and it is
getting included from msm_vidc_bus.c & msm_vidc_clock.c files.
So in generated build is having 2 copies of static arrays in
code segment.

So added changes to avoid duplication in generated bin.

Change-Id: Ifcfa07331e868440d033d2c7d65555810ad4d1b3
Signed-off-by: Govindaraj Rajagopal <[email protected]>
Govindaraj Rajagopal 2 жил өмнө
parent
commit
c484af4e69

+ 0 - 239
driver/platform/pineapple/inc/pineapple_technology.h

@@ -1,239 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (c) 2023, Qualcomm Innovation Center, Inc. All rights reserved.
- */
-
-#include "perf_static_model.h"
-
-#define ENABLE_FINEBITRATE_SUBUHD60 0
-
-/*
- * Chipset Generation Technology: SW/FW overhead profiling
- * need update with new numbers
- */
-static u32 frequency_table_pineapple[2][6] = {
-	/* //make lowsvs_D1 as invalid; */
-	{533, 480, 435, 380, 300, 196},
-	{840, 720, 652, 570, 450, 294},
-};
-
- /*
-  * TODO Move to pineapple.c
-  * TODO Replace hardcoded values with
-  * ENCODER_VPP_TARGET_CLK_PER_MB_PINEAPPLE in CPP file.
-  */
-
-/* Tensilica cycles profiled by FW team in lanai device Feb 2022 */
-#define DECODER_VPP_FW_OVERHEAD_PINEAPPLE_AV1D                                            ((80000*3)/2)
-#define DECODER_VPP_FW_OVERHEAD_PINEAPPLE_NONAV1D                                         ((60000*3)/2)
-
- /* Tensilica cycles */
-#define DECODER_VPP_FW_OVERHEAD_PINEAPPLE                                                  (0)
-
-/* Tensilica cycles; this is measured in Lahaina 1stage with FW profiling */
-#define DECODER_VPPVSP1STAGE_FW_OVERHEAD_PINEAPPLE                                         (93000)
-
-#define DECODER_VSP_FW_OVERHEAD_PINEAPPLE \
-	(DECODER_VPPVSP1STAGE_FW_OVERHEAD_PINEAPPLE - DECODER_VPP_FW_OVERHEAD_PINEAPPLE)
-
-/* Tensilica cycles; encoder has ARP register */
-#define ENCODER_VPP_FW_OVERHEAD_PINEAPPLE                                                  (69000*3/2)
-
-#define ENCODER_VPPVSP1STAGE_FW_OVERHEAD_PINEAPPLE \
-	(ENCODER_VPP_FW_OVERHEAD_PINEAPPLE + DECODER_VSP_FW_OVERHEAD_PINEAPPLE)
-
-#define DECODER_SW_OVERHEAD_PINEAPPLE                                                      (489583)
-#define ENCODER_SW_OVERHEAD_PINEAPPLE                                                      (489583)
-
-/* Video IP Core Technology: pipefloor and pipe penlaty */
-static u32 encoder_vpp_target_clk_per_mb_pineapple[2] = {320, 675};
-static u32 decoder_vpp_target_clk_per_mb_pineapple = 200;
-
-/*
- * These pipe penalty numbers only applies to 4 pipe
- * For 2pipe and 1pipe, these numbers need recalibrate
- */
-static u32 pipe_penalty_pineapple[3][3] = {
-	/* NON AV1 */
-	{1059, 1059, 1059},
-	/* AV1 RECOMMENDED TILE 1080P_V2XH1, UHD_V2X2, 8KUHD_V8X2 */
-	{1410, 1248, 1226},
-	/* AV1 YOUTUBE/NETFLIX TILE 1080P_V4XH2_V4X1, UHD_V8X4_V8X1, 8KUHD_V8X8_V8X1 */
-	{2039, 2464, 1191},
-};
-
-/*
- * Video IP Core Technology: bitrate constraint
- * HW limit bitrate table (these values are measured end to end fw/sw impacts are also considered)
- * TODO Can we convert to Cycles/MB? This will remove DIVISION.
- */
-static u32 bitrate_table_pineapple_2stage_fp[5][10] = {
-	/* h264 cavlc */
-	{0, 220, 220, 220, 220, 220, 220, 220, 220, 220},
-	/* h264 cabac */
-	{0, 140, 150, 160, 175, 190, 190, 190, 190, 190},
-	/* h265 */
-	{90, 140, 160, 180, 190, 200, 200, 200, 200, 200},
-	/* vp9 */
-	{90, 90, 90, 90, 90, 90, 90, 90, 90, 90},
-	/* av1 */
-	{130, 130, 120, 120, 120, 120, 120, 120, 120, 120},
-};
-
-/* HW limit bitrate table (these values are measured end to end fw/sw impacts are also considered) */
-static u32 bitrate_table_pineapple_1stage_fp[5][10] = { /* 1-stage assume IPPP */
-	/* h264 cavlc */
-	{0, 220, 220, 220, 220, 220, 220, 220, 220, 220},
-	/* h264 cabac */
-	{0, 110, 150, 150, 150, 150, 150, 150, 150, 150},
-	/* h265 */
-	{0, 140, 150, 150, 150, 150, 150, 150, 150, 150},
-	/* vp9 */
-	{0, 70, 70, 70, 70, 70, 70, 70, 70, 70},
-	/* av1 */
-	{0, 100, 100, 100, 100, 100, 100, 100, 100, 100},
-};
-
-/* rec pwc and power bitrate table */
-static u32 bitrate_table_pineapple_rec_fp[5][10] = {
-	/* rec. worst bitrate based on bitrate table */
-#if ENABLE_FINEBITRATE_SUBUHD60
-	/* h264 cavlc */
-	{0, 168, 150, 120, 100, 90, 50, 32, 20, 14},
-	/* h264 cabac 8bit */
-	{0, 134, 109, 84, 67, 56, 35, 23, 14, 10},
-	/* h265 10bit assumption */
-	{70, 140, 116, 92, 74, 62, 39, 25, 16, 11},
-	/* vp9 (profiled content from youtube and nflx) */
-	{70, 70, 65, 55, 45, 35, 20, 8, 6, 5},
-	/* av1 (profiled content from youtube and nflx) */
-	{100, 100, 85, 70, 55, 30, 15, 5, 5, 5},
-#else
-	/* h264 cavlc */
-	{0, 168, 150, 120, 100, 90, 90, 90, 90, 90},
-	/* h264 cabac 8bit */
-	{0, 134, 109, 84, 67, 56, 56, 56, 56, 56},
-	/* h265 10bit assumption */
-	{70, 140, 116, 92, 74, 62, 62, 62, 62, 62},
-	/* vp9 */
-	{70, 70, 65, 55, 45, 35, 35, 35, 35, 35},
-	/* av1 */
-	{100, 100, 85, 70, 55, 50, 50, 50, 50, 50},
-#endif
-};
-
-static u32 input_bitrate_fp;
-
-/* 8KUHD60; UHD240; 1080p960  with B */
-static u32 fp_pixel_count_bar0 = 3840 * 2160 * 240;
-/* 8KUHD60; UHD240; 1080p960  without B */
-static u32 fp_pixel_count_bar1 = 3840 * 2160 * 240;
-/* 1080p720 */
-static u32 fp_pixel_count_bar2 = 3840 * 2160 * 180;
-/* UHD120 */
-static u32 fp_pixel_count_bar3 = 3840 * 2160 * 120;
-/* UHD90 */
-static u32 fp_pixel_count_bar4 = 3840 * 2160 * 90;
-/* UHD60 */
-static u32 fp_pixel_count_bar5 = 3840 * 2160 * 60;
-/* UHD30; FHD120; HD240 */
-static u32 fp_pixel_count_bar6 = 3840 * 2160 * 30;
-/* FHD60 */
-static u32 fp_pixel_count_bar7 = 1920 * 1080 * 60;
-/* FHD30 */
-static u32 fp_pixel_count_bar8 = 1920 * 1080 * 30;
-/* HD30 */
-static u32 fp_pixel_count_bar9 = 1280 * 720 * 30;
-
-static u32 codec_encoder_gop_complexity_table_fp[8][3];
-static u32 codec_mbspersession_pineaple;
-
-static u32 cr_table_basic_pineapple[7][4] = {
-	{1920, 1080, 20, 40},
-	{3840, 2160, 42, 84},
-	{4096, 2160, 44, 88},
-	{4096, 2304, 48, 96},
-	{1280, 720, 7, 14},
-	{2560, 1440, 32, 64},
-	{7680, 4320, 84, 168},
-};
-
-/* 100x */
-static u32 dpbopb_ubwc30_cr_table_cratio_pineapple[7][12] = {
-	{237, 399, 272, 137, 225, 158, 185, 259, 203, 138, 167, 152},
-	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
-	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
-	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
-	{237, 399, 272, 137, 225, 158, 185, 259, 203, 138, 167, 152},
-	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
-	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
-};
-
-/* 100x */
-static u32 rpb_ubwc30_cr_table_cratio_pineapple[7][12] = {
-	{193, 294, 218, 135, 214, 155, 175, 241, 191, 139, 162, 149},
-	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
-	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
-	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
-	{193, 294, 218, 135, 214, 155, 175, 241, 191, 139, 162, 149},
-	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
-	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
-};
-
-/* 100x */
-static u32 ipblossy_ubwc30_cr_table_cratio_pineapple[7][12] = {
-	{215, 215, 215, 174, 174, 174, 266, 266, 266, 231, 231, 231},
-	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
-	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
-	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
-	{215, 215, 215, 174, 174, 174, 266, 266, 266, 231, 231, 231},
-	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
-	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
-};
-
-/* 100x */
-static u32 ipblossless_ubwc30_cr_table_cratio_pineapple[7][12] = {
-	{185, 215, 194, 147, 178, 159, 162, 181, 169, 138, 161, 146},
-	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
-	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
-	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
-	{185, 215, 194, 147, 178, 159, 162, 181, 169, 138, 161, 146},
-	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
-	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
-};
-
-/* 100x */
-static u32 en_original_compression_factor_rgba_pwd_pineapple = 243;
-/* 100x */
-static u32 en_original_compression_factor_rgba_avg_pineapple = 454;
-
-static u32 av1_num_tiles_pineapple[7][3] = {
-	{2, 1, 1},
-	{4, 2, 2},
-	{4, 2, 2},
-	{4, 2, 2},
-	{1, 1, 1},
-	{2, 1, 1},
-	{16, 4, 4},
-};
-
-/*                                H   I   J         K   L   M      N   O   P
- *         TotalW   Total R       Frequency         Write         Read
- * Name                           B   b   P         B   b   P      B   b   P
- * I3B4b1P    0.5    1.875        3   4   1         1   0   1      2   2   1
- * I1B2b1P    0.5    1.75         1   2   1         1   0   1      2   2   1
- * IbP        0.5    1.5          0   1   1         1   0   1      2   2   1
- * IPP        1      1            0   0   1         1   0   1      2   2   1
- * P          1      1            0   0   1         1   0   1      2   2   1
- * smallB     0      2            0   1   0         1   0   1      2   2   1
- * bigB       1      2            1   0   0         1   0   1      2   2   1
- *
- * Total W = SUMPRODUCT(H16:J16, K16 : M16) / SUM(H16:J16)
- * Total R = SUMPRODUCT(H16:J16, N16 : P16) / SUM(H16:J16)
-*/
-
-/* 1000x */
-static u32 pineapple_en_readfactor[8] = {1000, 1500, 1750, 1875, 1000, 2000, 2000, 1000};
-/* 1000x */
-static u32 pineapple_en_writefactor[8] = {1000, 500, 500, 500, 1000, 0, 1000, 1000};
-static u32 pineapple_en_frame_num_parallel = 1;

+ 104 - 24
driver/variant/iris33/src/msm_vidc_bus_iris33.c

@@ -3,10 +3,90 @@
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
-#include "pineapple_technology.h"
+#include "perf_static_model.h"
 #include "msm_vidc_debug.h"
 
-u32 calculate_number_lcus_pineapple(u32 width, u32 height, u32 lcu_size)
+/* 100x */
+static u32 dpbopb_ubwc30_cr_table_cratio_iris33[7][12] = {
+	{237, 399, 272, 137, 225, 158, 185, 259, 203, 138, 167, 152},
+	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
+	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
+	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
+	{237, 399, 272, 137, 225, 158, 185, 259, 203, 138, 167, 152},
+	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
+	{269, 404, 302, 202, 367, 238, 210, 299, 232, 134, 181, 149},
+};
+
+/* 100x */
+static u32 rpb_ubwc30_cr_table_cratio_iris33[7][12] = {
+	{193, 294, 218, 135, 214, 155, 175, 241, 191, 139, 162, 149},
+	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
+	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
+	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
+	{193, 294, 218, 135, 214, 155, 175, 241, 191, 139, 162, 149},
+	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
+	{285, 406, 316, 207, 373, 243, 201, 280, 221, 139, 177, 152},
+};
+
+/* 100x */
+static u32 ipblossy_ubwc30_cr_table_cratio_iris33[7][12] = {
+	{215, 215, 215, 174, 174, 174, 266, 266, 266, 231, 231, 231},
+	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
+	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
+	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
+	{215, 215, 215, 174, 174, 174, 266, 266, 266, 231, 231, 231},
+	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
+	{254, 254, 254, 219, 219, 219, 292, 292, 292, 249, 249, 249},
+};
+
+/* 100x */
+static u32 ipblossless_ubwc30_cr_table_cratio_iris33[7][12] = {
+	{185, 215, 194, 147, 178, 159, 162, 181, 169, 138, 161, 146},
+	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
+	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
+	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
+	{185, 215, 194, 147, 178, 159, 162, 181, 169, 138, 161, 146},
+	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
+	{186, 217, 195, 151, 183, 161, 164, 182, 170, 140, 168, 148},
+};
+
+/* 100x */
+static u32 en_original_compression_factor_rgba_pwd_iris33 = 243;
+/* 100x */
+static u32 en_original_compression_factor_rgba_avg_iris33 = 454;
+
+static u32 av1_num_tiles_iris33[7][3] = {
+	{2, 1, 1},
+	{4, 2, 2},
+	{4, 2, 2},
+	{4, 2, 2},
+	{1, 1, 1},
+	{2, 1, 1},
+	{16, 4, 4},
+};
+
+/*                                H   I   J         K   L   M      N   O   P
+ *         TotalW   Total R       Frequency         Write         Read
+ * Name                           B   b   P         B   b   P      B   b   P
+ * I3B4b1P    0.5    1.875        3   4   1         1   0   1      2   2   1
+ * I1B2b1P    0.5    1.75         1   2   1         1   0   1      2   2   1
+ * IbP        0.5    1.5          0   1   1         1   0   1      2   2   1
+ * IPP        1      1            0   0   1         1   0   1      2   2   1
+ * P          1      1            0   0   1         1   0   1      2   2   1
+ * smallB     0      2            0   1   0         1   0   1      2   2   1
+ * bigB       1      2            1   0   0         1   0   1      2   2   1
+ *
+ * Total W = SUMPRODUCT(H16:J16, K16 : M16) / SUM(H16:J16)
+ * Total R = SUMPRODUCT(H16:J16, N16 : P16) / SUM(H16:J16)
+ */
+
+/* 1000x */
+static u32 pineapple_en_readfactor[8] = {1000, 1500, 1750, 1875, 1000, 2000, 2000, 1000};
+/* 1000x */
+static u32 pineapple_en_writefactor[8] = {1000, 500, 500, 500, 1000, 0, 1000, 1000};
+static u32 pineapple_en_frame_num_parallel = 1;
+
+u32 calculate_number_lcus_iris33(u32 width, u32 height, u32 lcu_size)
 {
 	u32 mbs_width = (width % lcu_size) ?
 		(width / lcu_size + 1) : (width / lcu_size);
@@ -16,7 +96,7 @@ u32 calculate_number_lcus_pineapple(u32 width, u32 height, u32 lcu_size)
 	return mbs_width * mbs_height;
 }
 
-u32 calculate_number_ubwctiles_pineapple(
+u32 calculate_number_ubwctiles_iris33(
 		u32 width, u32 height, u32 tile_w, u32 tile_h)
 {
 	u32 tiles_width = (width % tile_w) ?
@@ -76,11 +156,11 @@ u32 get_compression_factors(struct compression_factors *compression_factor,
 
 	if (codec_input.decoder_or_encoder == CODEC_DECODER) {
 		compression_factor->dpb_cf_y =
-			dpbopb_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_y];
+			dpbopb_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_y];
 		compression_factor->dpb_cf_cbcr =
-			dpbopb_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_c];
+			dpbopb_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_c];
 		compression_factor->opb_cf_ycbcr =
-			dpbopb_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_uni];
+			dpbopb_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_uni];
 
 		if ((codec_input.regression_mode == 3) &&
 			/* input cr numbers from interface */
@@ -97,21 +177,21 @@ u32 get_compression_factors(struct compression_factors *compression_factor,
 		 */
 		if (frame_width < 3840) {
 			compression_factor->ipb_cr =
-				ipblossless_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_uni];
+				ipblossless_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_uni];
 			compression_factor->ipb_cr_y =
-				ipblossless_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_y];
+				ipblossless_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_y];
 		} else {
 			compression_factor->ipb_cr =
-				ipblossy_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_uni];
+				ipblossy_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_uni];
 			compression_factor->ipb_cr_y =
-				ipblossy_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_y];
+				ipblossy_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_y];
 		}
 
 		compression_factor->dpb_cf_y =
-			rpb_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_y];
+			rpb_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_y];
 
 		compression_factor->dpb_cf_cbcr =
-			rpb_ubwc30_cr_table_cratio_pineapple[cr_index_entry][cr_index_c];
+			rpb_ubwc30_cr_table_cratio_iris33[cr_index_entry][cr_index_c];
 
 		if ((codec_input.regression_mode == 3) &&
 			/* input cr from interface */
@@ -246,7 +326,7 @@ static int calculate_bandwidth_decoder_iris33(
 	}
 
 	lcu_per_frame =
-		calculate_number_lcus_pineapple(frame_width, frame_height, frame_lcu_size);
+		calculate_number_lcus_iris33(frame_width, frame_height, frame_lcu_size);
 
 	target_bitrate = (u32)(codec_input.bitrate_mbps); /* Mbps */
 
@@ -254,11 +334,11 @@ static int calculate_bandwidth_decoder_iris33(
 	ubwc_tile_h = (codec_input.bitdepth == CODEC_BITDEPTH_8) ? 8 : 4;
 
 	frame420_y_bw_linear_8bpp =
-		((calculate_number_ubwctiles_pineapple(frame_width, frame_height, 32, 8) *
+		((calculate_number_ubwctiles_iris33(frame_width, frame_height, 32, 8) *
 		256 * codec_input.frame_rate + 999) / 1000 + 999) / 1000;
 
 	frame420_y_bw_no_ubwc_tile_10bpp =
-		((calculate_number_ubwctiles_pineapple(frame_width, frame_height, 48, 4) *
+		((calculate_number_ubwctiles_iris33(frame_width, frame_height, 48, 4) *
 		256 * codec_input.frame_rate + 999) / 1000 + 999) / 1000;
 	frame420_y_bw_linear_10bpp = ((frame_width * frame_height *
 		codec_input.frame_rate * 2 + 999) / 1000 + 999) / 1000;
@@ -304,7 +384,7 @@ static int calculate_bandwidth_decoder_iris33(
 		else
 			av1tile_complexity = 0;
 
-		av1_tile_numbers = av1_num_tiles_pineapple[av1tile_index_entry][av1tile_complexity];
+		av1_tile_numbers = av1_num_tiles_iris33[av1tile_index_entry][av1tile_complexity];
 
 		/* these bw can be ignored */
 		av1_collated_seg_buffer_rd_wr =
@@ -618,7 +698,7 @@ static int calculate_bandwidth_encoder_iris33(
 	}
 
 	lcu_per_frame =
-		calculate_number_lcus_pineapple(frame_width, frame_height, frame_lcu_size);
+		calculate_number_lcus_iris33(frame_width, frame_height, frame_lcu_size);
 
 	bse_tlb_byte_per_lcu = 16; /* TODO Should be in common declaration */
 
@@ -630,16 +710,16 @@ static int calculate_bandwidth_encoder_iris33(
 	/* yuv */
 	if (codec_input.ipb_yuvrgb == 0) {
 		frame420_y_bw_linear_8bpp =
-			((calculate_number_ubwctiles_pineapple(frame_width, frame_height,
+			((calculate_number_ubwctiles_iris33(frame_width, frame_height,
 			32, 8) * 256 * codec_input.frame_rate + 999) / 1000 + 999) / 1000;
 	} else { /* RGBA */
 		frame420_y_bw_linear_8bpp =
-			((calculate_number_ubwctiles_pineapple(frame_width, frame_height,
+			((calculate_number_ubwctiles_iris33(frame_width, frame_height,
 			6, 4) * 256 * codec_input.frame_rate + 999) / 1000 + 999) / 1000;
 	}
 
 	frame420_y_bw_no_ubwc_tile_10bpp =
-		((calculate_number_ubwctiles_pineapple(frame_width, frame_height, 48, 4) *
+		((calculate_number_ubwctiles_iris33(frame_width, frame_height, 48, 4) *
 		256 * codec_input.frame_rate + 999) / 1000 + 999) / 1000;
 
 	frame420_y_bw_linear_10bpp = ((frame_width * frame_height *
@@ -854,13 +934,13 @@ static int calculate_bandwidth_encoder_iris33(
 				if (codec_input.complexity_setting == 0) /* pwc */
 					codec_output->ipb_rd_total_noc =
 						(large_bw_calculation_fp * 100 +
-						en_original_compression_factor_rgba_pwd_pineapple - 1) /
-						en_original_compression_factor_rgba_pwd_pineapple;
+						en_original_compression_factor_rgba_pwd_iris33 - 1) /
+						en_original_compression_factor_rgba_pwd_iris33;
 				else
 					codec_output->ipb_rd_total_noc =
 					(large_bw_calculation_fp * 100 +
-					en_original_compression_factor_rgba_avg_pineapple - 1) /
-					en_original_compression_factor_rgba_avg_pineapple;
+					en_original_compression_factor_rgba_avg_iris33 - 1) /
+					en_original_compression_factor_rgba_avg_iris33;
 			}
 		}
 	} else {

+ 153 - 39
driver/variant/iris33/src/msm_vidc_clock_iris33.c

@@ -3,10 +3,124 @@
  * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
-#include "pineapple_technology.h"
+#include "perf_static_model.h"
 #include "msm_vidc_debug.h"
 
-static u32 calculate_number_mbs_pineapple(u32 width, u32 height, u32 lcu_size)
+#define ENABLE_FINEBITRATE_SUBUHD60 0
+
+static u32 codec_encoder_gop_complexity_table_fp[8][3];
+static u32 codec_mbspersession_iris33;
+static u32 input_bitrate_fp;
+
+/*
+ * Chipset Generation Technology: SW/FW overhead profiling
+ * need update with new numbers
+ */
+static u32 frequency_table_iris33[2][6] = {
+	/* //make lowsvs_D1 as invalid; */
+	{533, 480, 435, 380, 300, 196},
+	{840, 720, 652, 570, 450, 294},
+};
+
+ /*
+  * TODO Move to pineapple.c
+  * TODO Replace hardcoded values with
+  * ENCODER_VPP_TARGET_CLK_PER_MB_IRIS33 in CPP file.
+  */
+
+/* Tensilica cycles profiled by FW team in lanai device Feb 2022 */
+#define DECODER_VPP_FW_OVERHEAD_IRIS33_AV1D                                            ((80000*3)/2)
+#define DECODER_VPP_FW_OVERHEAD_IRIS33_NONAV1D                                         ((60000*3)/2)
+
+ /* Tensilica cycles */
+#define DECODER_VPP_FW_OVERHEAD_IRIS33                                                  (0)
+
+/* Tensilica cycles; this is measured in Lahaina 1stage with FW profiling */
+#define DECODER_VPPVSP1STAGE_FW_OVERHEAD_IRIS33                                         (93000)
+
+#define DECODER_VSP_FW_OVERHEAD_IRIS33 \
+	(DECODER_VPPVSP1STAGE_FW_OVERHEAD_IRIS33 - DECODER_VPP_FW_OVERHEAD_IRIS33)
+
+/* Tensilica cycles; encoder has ARP register */
+#define ENCODER_VPP_FW_OVERHEAD_IRIS33                                                  (69000*3/2)
+
+#define ENCODER_VPPVSP1STAGE_FW_OVERHEAD_IRIS33 \
+	(ENCODER_VPP_FW_OVERHEAD_IRIS33 + DECODER_VSP_FW_OVERHEAD_IRIS33)
+
+#define DECODER_SW_OVERHEAD_IRIS33                                                      (489583)
+#define ENCODER_SW_OVERHEAD_IRIS33                                                      (489583)
+
+/* Video IP Core Technology: pipefloor and pipe penlaty */
+// static u32 encoder_vpp_target_clk_per_mb_iris33[2] = {320, 675};
+static u32 decoder_vpp_target_clk_per_mb_iris33 = 200;
+
+/*
+ * These pipe penalty numbers only applies to 4 pipe
+ * For 2pipe and 1pipe, these numbers need recalibrate
+ */
+static u32 pipe_penalty_iris33[3][3] = {
+	/* NON AV1 */
+	{1059, 1059, 1059},
+	/* AV1 RECOMMENDED TILE 1080P_V2XH1, UHD_V2X2, 8KUHD_V8X2 */
+	{1410, 1248, 1226},
+	/* AV1 YOUTUBE/NETFLIX TILE 1080P_V4XH2_V4X1, UHD_V8X4_V8X1, 8KUHD_V8X8_V8X1 */
+	{2039, 2464, 1191},
+};
+
+/*
+ * Video IP Core Technology: bitrate constraint
+ * HW limit bitrate table (these values are measured end to end fw/sw impacts are also considered)
+ * TODO Can we convert to Cycles/MB? This will remove DIVISION.
+ */
+static u32 bitrate_table_iris33_2stage_fp[5][10] = {
+	/* h264 cavlc */
+	{0, 220, 220, 220, 220, 220, 220, 220, 220, 220},
+	/* h264 cabac */
+	{0, 140, 150, 160, 175, 190, 190, 190, 190, 190},
+	/* h265 */
+	{90, 140, 160, 180, 190, 200, 200, 200, 200, 200},
+	/* vp9 */
+	{90, 90, 90, 90, 90, 90, 90, 90, 90, 90},
+	/* av1 */
+	{130, 130, 120, 120, 120, 120, 120, 120, 120, 120},
+};
+
+/* HW limit bitrate table (these values are measured end to end fw/sw impacts are also considered) */
+static u32 bitrate_table_iris33_1stage_fp[5][10] = { /* 1-stage assume IPPP */
+	/* h264 cavlc */
+	{0, 220, 220, 220, 220, 220, 220, 220, 220, 220},
+	/* h264 cabac */
+	{0, 110, 150, 150, 150, 150, 150, 150, 150, 150},
+	/* h265 */
+	{0, 140, 150, 150, 150, 150, 150, 150, 150, 150},
+	/* vp9 */
+	{0, 70, 70, 70, 70, 70, 70, 70, 70, 70},
+	/* av1 */
+	{0, 100, 100, 100, 100, 100, 100, 100, 100, 100},
+};
+
+/* 8KUHD60; UHD240; 1080p960  with B */
+static u32 fp_pixel_count_bar0 = 3840 * 2160 * 240;
+/* 8KUHD60; UHD240; 1080p960  without B */
+static u32 fp_pixel_count_bar1 = 3840 * 2160 * 240;
+/* 1080p720 */
+static u32 fp_pixel_count_bar2 = 3840 * 2160 * 180;
+/* UHD120 */
+static u32 fp_pixel_count_bar3 = 3840 * 2160 * 120;
+/* UHD90 */
+static u32 fp_pixel_count_bar4 = 3840 * 2160 * 90;
+/* UHD60 */
+static u32 fp_pixel_count_bar5 = 3840 * 2160 * 60;
+/* UHD30; FHD120; HD240 */
+static u32 fp_pixel_count_bar6 = 3840 * 2160 * 30;
+/* FHD60 */
+static u32 fp_pixel_count_bar7 = 1920 * 1080 * 60;
+/* FHD30 */
+static u32 fp_pixel_count_bar8 = 1920 * 1080 * 30;
+/* HD30 */
+static u32 fp_pixel_count_bar9 = 1280 * 720 * 30;
+
+static u32 calculate_number_mbs_iris33(u32 width, u32 height, u32 lcu_size)
 {
 	u32 mbs_width = (width % lcu_size) ?
 		(width / lcu_size + 1) : (width / lcu_size);
@@ -215,57 +329,57 @@ static int calculate_vsp_min_freq(struct api_calculation_input codec_input,
 		 *  TODO : Reduce these conditions by removing the zero entries from Bitrate table.
 		 */
 
-		vsp_hw_min_frequency = frequency_table_pineapple[0][2] *
+		vsp_hw_min_frequency = frequency_table_iris33[0][2] *
 			input_bitrate_fp * 1000;
 
 		if (codec_input.codec == CODEC_AV1)
-			vsp_hw_min_frequency = frequency_table_pineapple[0][1] *
+			vsp_hw_min_frequency = frequency_table_iris33[0][1] *
 				input_bitrate_fp * 1000;
 
 		if ((codec_input.codec == CODEC_H264) ||
 			(codec_input.codec == CODEC_H264_CAVLC)) {
-			vsp_hw_min_frequency = (frequency_table_pineapple[0][2] * 1000 +
+			vsp_hw_min_frequency = (frequency_table_iris33[0][2] * 1000 +
 				(fw_sw_vsp_offset - 1));
 			vsp_hw_min_frequency =
 				DIV_ROUND_UP(vsp_hw_min_frequency, fw_sw_vsp_offset);
 		} else {
 			if (codec_input.vsp_vpp_mode == CODEC_VSPVPP_MODE_2S) {
 				vsp_hw_min_frequency = vsp_hw_min_frequency +
-					(bitrate_table_pineapple_2stage_fp[codec][0] *
+					(bitrate_table_iris33_2stage_fp[codec][0] *
 					fw_sw_vsp_offset - 1);
 				vsp_hw_min_frequency = DIV_ROUND_UP(vsp_hw_min_frequency,
-					(bitrate_table_pineapple_2stage_fp[codec][0]) *
+					(bitrate_table_iris33_2stage_fp[codec][0]) *
 						fw_sw_vsp_offset);
 			} else {
 				vsp_hw_min_frequency = vsp_hw_min_frequency +
-					(bitrate_table_pineapple_1stage_fp[codec][0] *
+					(bitrate_table_iris33_1stage_fp[codec][0] *
 					fw_sw_vsp_offset - 1);
 				vsp_hw_min_frequency = DIV_ROUND_UP(vsp_hw_min_frequency,
-					(bitrate_table_pineapple_1stage_fp[codec][0]) *
+					(bitrate_table_iris33_1stage_fp[codec][0]) *
 						fw_sw_vsp_offset);
 			}
 		}
 	} else {
-		vsp_hw_min_frequency = frequency_table_pineapple[0][2] *
+		vsp_hw_min_frequency = frequency_table_iris33[0][2] *
 			input_bitrate_fp * 1000;
 
 		if (codec_input.codec == CODEC_AV1 && bitrate_entry == 1)
-			vsp_hw_min_frequency = frequency_table_pineapple[0][1] *
+			vsp_hw_min_frequency = frequency_table_iris33[0][1] *
 				input_bitrate_fp * 1000;
 
 		if (codec_input.vsp_vpp_mode == CODEC_VSPVPP_MODE_2S) {
 			vsp_hw_min_frequency = vsp_hw_min_frequency +
-				(bitrate_table_pineapple_2stage_fp[codec][bitrate_entry] *
+				(bitrate_table_iris33_2stage_fp[codec][bitrate_entry] *
 				fw_sw_vsp_offset - 1);
 			vsp_hw_min_frequency = DIV_ROUND_UP(vsp_hw_min_frequency,
-				(bitrate_table_pineapple_2stage_fp[codec][bitrate_entry]) *
+				(bitrate_table_iris33_2stage_fp[codec][bitrate_entry]) *
 					fw_sw_vsp_offset);
 		} else {
 			vsp_hw_min_frequency = vsp_hw_min_frequency +
-				(bitrate_table_pineapple_1stage_fp[codec][bitrate_entry] *
+				(bitrate_table_iris33_1stage_fp[codec][bitrate_entry] *
 				fw_sw_vsp_offset - 1);
 			vsp_hw_min_frequency = DIV_ROUND_UP(vsp_hw_min_frequency,
-				(bitrate_table_pineapple_1stage_fp[codec][bitrate_entry]) *
+				(bitrate_table_iris33_1stage_fp[codec][bitrate_entry]) *
 					fw_sw_vsp_offset);
 		}
 	}
@@ -282,27 +396,27 @@ static u32 calculate_pipe_penalty(struct api_calculation_input codec_input)
 
 	/* decoder */
 	if (codec_input.decoder_or_encoder == CODEC_DECODER) {
-		pipe_penalty_codec = pipe_penalty_pineapple[0][0];
+		pipe_penalty_codec = pipe_penalty_iris33[0][0];
 		avid_commercial_content = codec_input.av1d_commer_tile_enable;
 		if (codec_input.codec == CODEC_AV1) {
 			pixel_count = codec_input.frame_width * codec_input.frame_height;
 			if (pixel_count <= 1920 * 1080)
 				pipe_penalty_codec =
-					pipe_penalty_pineapple[avid_commercial_content + 1][0];
+					pipe_penalty_iris33[avid_commercial_content + 1][0];
 			else if (pixel_count < 3840 * 2160)
 				pipe_penalty_codec =
-					(pipe_penalty_pineapple[avid_commercial_content + 1][0] +
-					pipe_penalty_pineapple[avid_commercial_content + 1][1]) / 2;
+					(pipe_penalty_iris33[avid_commercial_content + 1][0] +
+					pipe_penalty_iris33[avid_commercial_content + 1][1]) / 2;
 			else if ((pixel_count == 3840 * 2160) ||
 				(pixel_count == 4096 * 2160) || (pixel_count == 4096 * 2304))
-				pipe_penalty_codec = pipe_penalty_pineapple[avid_commercial_content + 1][1];
+				pipe_penalty_codec = pipe_penalty_iris33[avid_commercial_content + 1][1];
 			else if (pixel_count < 7680 * 4320)
 				pipe_penalty_codec =
-					(pipe_penalty_pineapple[avid_commercial_content + 1][1] +
-					pipe_penalty_pineapple[avid_commercial_content + 1][2]) / 2;
+					(pipe_penalty_iris33[avid_commercial_content + 1][1] +
+					pipe_penalty_iris33[avid_commercial_content + 1][2]) / 2;
 			else
 				pipe_penalty_codec =
-					pipe_penalty_pineapple[avid_commercial_content + 1][2];
+					pipe_penalty_iris33[avid_commercial_content + 1][2];
 		}
 	} else {
 		pipe_penalty_codec = 101;
@@ -327,17 +441,17 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 	u32 lpmode_uhd_cycle_permb = 0;
 	u32 hqmode1080p_cycle_permb = 0;
 	u32 encoder_vpp_target_clk_per_mb = 0;
-	u32 decoder_vpp_fw_overhead = DECODER_VPP_FW_OVERHEAD_PINEAPPLE;
+	u32 decoder_vpp_fw_overhead = DECODER_VPP_FW_OVERHEAD_IRIS33;
 
-	codec_mbspersession_pineaple =
-		calculate_number_mbs_pineapple(codec_input.frame_width,
+	codec_mbspersession_iris33 =
+		calculate_number_mbs_iris33(codec_input.frame_width,
 		codec_input.frame_height, codec_input.lcu_size) *
 		codec_input.frame_rate;
 
 	/* Section 2. 0  VPP/VSP calculation */
 	if (codec_input.decoder_or_encoder == CODEC_DECODER) { /* decoder */
-		vpp_hw_min_frequency = ((decoder_vpp_target_clk_per_mb_pineapple) *
-			(codec_mbspersession_pineaple) + codec_input.pipe_num - 1) /
+		vpp_hw_min_frequency = ((decoder_vpp_target_clk_per_mb_iris33) *
+			(codec_mbspersession_iris33) + codec_input.pipe_num - 1) /
 			(codec_input.pipe_num);
 
 		vpp_hw_min_frequency = (vpp_hw_min_frequency + 99999) / 1000000;
@@ -349,9 +463,9 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 		}
 
 		if (codec_input.codec == CODEC_AV1)
-			decoder_vpp_fw_overhead = DECODER_VPP_FW_OVERHEAD_PINEAPPLE_AV1D;
+			decoder_vpp_fw_overhead = DECODER_VPP_FW_OVERHEAD_IRIS33_AV1D;
 		else
-			decoder_vpp_fw_overhead = DECODER_VPP_FW_OVERHEAD_PINEAPPLE_NONAV1D;
+			decoder_vpp_fw_overhead = DECODER_VPP_FW_OVERHEAD_IRIS33_NONAV1D;
 
 		if (codec_input.vsp_vpp_mode == CODEC_VSPVPP_MODE_2S) {
 			/* FW overhead, convert FW cycles to impact to one pipe */
@@ -362,8 +476,8 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 
 			decoder_vpp_fw_overhead =
 				DIV_ROUND_UP((decoder_vpp_fw_overhead * 1000),
-				(codec_mbspersession_pineaple *
-				decoder_vpp_target_clk_per_mb_pineapple / codec_input.pipe_num));
+				(codec_mbspersession_iris33 *
+				decoder_vpp_target_clk_per_mb_iris33 / codec_input.pipe_num));
 
 			decoder_vpp_fw_overhead += 1000;
 			decoder_vpp_fw_overhead = (decoder_vpp_fw_overhead < 1050) ?
@@ -402,7 +516,7 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 			/* FW time */
 			fmin_fwoverhead105 = (fmin * 105 + 99) / 100;
 			fmin_measured_fwoverhead = fmin +
-				(((DECODER_VPPVSP1STAGE_FW_OVERHEAD_PINEAPPLE *
+				(((DECODER_VPPVSP1STAGE_FW_OVERHEAD_IRIS33 *
 				codec_input.frame_rate * 10 + 14) / 15 + 999) / 1000 + 999) /
 				1000;
 
@@ -410,7 +524,7 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 				fmin_fwoverhead105 : fmin_measured_fwoverhead;
 		}
 
-		tensilica_min_frequency = (DECODER_SW_OVERHEAD_PINEAPPLE * 10 + 14) / 15;
+		tensilica_min_frequency = (DECODER_SW_OVERHEAD_IRIS33 * 10 + 14) / 15;
 		tensilica_min_frequency = (tensilica_min_frequency + 999) / 1000;
 		tensilica_min_frequency = tensilica_min_frequency * codec_input.frame_rate;
 		tensilica_min_frequency = (tensilica_min_frequency + 999) / 1000;
@@ -467,7 +581,7 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 			hqmode1080p_cycle_permb : lpmode_uhd_cycle_permb;
 
 		vpp_hw_min_frequency = ((encoder_vpp_target_clk_per_mb) *
-			(codec_mbspersession_pineaple) + codec_input.pipe_num - 1) /
+			(codec_mbspersession_iris33) + codec_input.pipe_num - 1) /
 			(codec_input.pipe_num);
 
 		vpp_hw_min_frequency = (vpp_hw_min_frequency + 99999) / 1000000;
@@ -483,12 +597,12 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 			u64 encoder_vpp_fw_overhead = 0;
 
 			encoder_vpp_fw_overhead =
-				DIV_ROUND_UP((ENCODER_VPP_FW_OVERHEAD_PINEAPPLE * 10 *
+				DIV_ROUND_UP((ENCODER_VPP_FW_OVERHEAD_IRIS33 * 10 *
 				codec_input.frame_rate), 15);
 
 			encoder_vpp_fw_overhead =
 				DIV_ROUND_UP((encoder_vpp_fw_overhead * 1000),
-				(codec_mbspersession_pineaple * encoder_vpp_target_clk_per_mb /
+				(codec_mbspersession_iris33 * encoder_vpp_target_clk_per_mb /
 				codec_input.pipe_num));
 
 			encoder_vpp_fw_overhead += 1000;
@@ -514,7 +628,7 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 			/* FW time */
 			fmin_fwoverhead105 = (fmin * 105 + 99) / 100;
 			fmin_measured_fwoverhead = fmin +
-				(((DECODER_VPPVSP1STAGE_FW_OVERHEAD_PINEAPPLE *
+				(((DECODER_VPPVSP1STAGE_FW_OVERHEAD_IRIS33 *
 				codec_input.frame_rate * 10 + 14) / 15 + 999) /
 				1000 + 999) / 1000;
 
@@ -523,7 +637,7 @@ static int calculate_vpp_min_freq(struct api_calculation_input codec_input,
 			/* SW time */
 		}
 
-		tensilica_min_frequency = (ENCODER_SW_OVERHEAD_PINEAPPLE * 10 + 14) / 15;
+		tensilica_min_frequency = (ENCODER_SW_OVERHEAD_IRIS33 * 10 + 14) / 15;
 		tensilica_min_frequency = (tensilica_min_frequency + 999) / 1000;
 
 		tensilica_min_frequency = tensilica_min_frequency *