Bläddra i källkod

video: driver: Enable CR/CF UBWC stats

Use firmware values of Compression Ratio (CR) and
Complexity Factor (CF) for bandwidth calculations.

Change-Id: Ia6d3c45afc834bc872ac4e0597a2ecb95eb81682
Signed-off-by: Mihir Ganu <[email protected]>
Mihir Ganu 4 år sedan
förälder
incheckning
00d9596313
2 ändrade filer med 35 tillägg och 29 borttagningar
  1. 26 27
      driver/vidc/src/msm_vidc_power.c
  2. 9 2
      driver/vidc/src/venus_hfi_response.c

+ 26 - 27
driver/vidc/src/msm_vidc_power.c

@@ -100,37 +100,36 @@ static int fill_dynamic_stats(struct msm_vidc_inst *inst,
 	struct vidc_bus_vote_data *vote_data)
 {
 	struct msm_vidc_input_cr_data *temp, *next;
-	u32 max_cr = MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO;
-	u32 max_cf = MSM_VIDC_MIN_UBWC_COMPLEXITY_FACTOR;
-	u32 max_input_cr = MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO;
-	u32 min_cf = MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR;
-	u32 min_input_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO;
-	u32 min_cr = MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO;
-
-	/* TODO: get ubwc stats from firmware */
-	min_cr = inst->power.fw_cr;
-	max_cf = inst->power.fw_cf;
-	max_cf = max_cf / ((msm_vidc_get_mbs_per_frame(inst)) / (32 * 8) * 3) / 2;
-
-	list_for_each_entry_safe(temp, next, &inst->enc_input_crs, list) {
-		min_input_cr = min(min_input_cr, temp->input_cr);
-		max_input_cr = max(max_input_cr, temp->input_cr);
+	u32 cf = MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR;
+	u32 cr = MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO;
+	u32 input_cr = MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO;
+
+	if (inst->power.fw_cr)
+		cr = inst->power.fw_cr;
+
+	if (inst->power.fw_cf) {
+		cf = inst->power.fw_cf;
+		cf = cf / ((msm_vidc_get_mbs_per_frame(inst)) / (32 * 8) * 3) / 2;
 	}
 
+	list_for_each_entry_safe(temp, next, &inst->enc_input_crs, list)
+		input_cr = min(input_cr, temp->input_cr);
+
+	vote_data->compression_ratio = cr;
+	vote_data->complexity_factor = cf;
+	vote_data->input_cr = input_cr;
 
 	/* Sanitize CF values from HW */
-	max_cf = min_t(u32, max_cf, MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR);
-	min_cf = max_t(u32, min_cf, MSM_VIDC_MIN_UBWC_COMPLEXITY_FACTOR);
-	max_cr = min_t(u32, max_cr, MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO);
-	min_cr = max_t(u32, min_cr, MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO);
-	max_input_cr = min_t(u32,
-		max_input_cr, MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO);
-	min_input_cr = max_t(u32,
-		min_input_cr, MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO);
-
-	vote_data->compression_ratio = min_cr;
-	vote_data->complexity_factor = max_cf;
-	vote_data->input_cr = min_input_cr;
+	cf = clamp_t(u32, cf, MSM_VIDC_MIN_UBWC_COMPLEXITY_FACTOR,
+			MSM_VIDC_MAX_UBWC_COMPLEXITY_FACTOR);
+	cr = clamp_t(u32, cr, MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO,
+			MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO);
+	input_cr = clamp_t(u32, input_cr, MSM_VIDC_MIN_UBWC_COMPRESSION_RATIO,
+			MSM_VIDC_MAX_UBWC_COMPRESSION_RATIO);
+
+	vote_data->compression_ratio = cr;
+	vote_data->complexity_factor = cf;
+	vote_data->input_cr = input_cr;
 
 	i_vpr_l(inst,
 		"Input CR = %d Recon CR = %d Complexity Factor = %d\n",

+ 9 - 2
driver/vidc/src/venus_hfi_response.c

@@ -744,6 +744,13 @@ static int handle_output_buffer(struct msm_vidc_inst *inst,
 	buf->flags = 0;
 	buf->flags = get_driver_buffer_flags(inst, buffer->flags);
 
+	if (is_decode_session(inst)) {
+		inst->power.fw_cr = inst->hfi_frame_info.cr;
+		inst->power.fw_cf = inst->hfi_frame_info.cf;
+	} else {
+		inst->power.fw_cr = inst->hfi_frame_info.cr;
+	}
+
 	print_vidc_buffer(VIDC_HIGH, "high", "dqbuf", inst, buf);
 	msm_vidc_debugfs_update(inst, MSM_VIDC_DEBUGFS_EVENT_FBD);
 
@@ -1248,10 +1255,10 @@ static int handle_session_property(struct msm_vidc_inst *inst,
 		inst->hfi_frame_info.no_output = 1;
 		break;
 	case HFI_PROP_WORST_COMPRESSION_RATIO:
-		inst->power.fw_cr = payload_ptr[0];
+		inst->hfi_frame_info.cr = payload_ptr[0];
 		break;
 	case HFI_PROP_WORST_COMPLEXITY_FACTOR:
-		inst->power.fw_cf = payload_ptr[0];
+		inst->hfi_frame_info.cf = payload_ptr[0];
 		break;
 	case HFI_PROP_DPB_LIST:
 		if (is_decode_session(inst) && port == OUTPUT_PORT &&