Prechádzať zdrojové kódy

video: driver: tune clock and bus vote calculation

Use bitstream fps in clock and bus vote calculation, if
bitstream detected fps is higher than client set rate.

Change-Id: I58fa1a8725086c112796b3ce5172a39f322e178e
Signed-off-by: Govindaraj Rajagopal <[email protected]>
Govindaraj Rajagopal 4 rokov pred
rodič
commit
8d81cd480b

+ 11 - 7
driver/variant/iris2/src/msm_vidc_power_iris2.c

@@ -23,7 +23,7 @@ u64 msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, u32 data_size)
 	u32 base_cycles = 0;
 	u32 base_cycles = 0;
 	u32 fps;
 	u32 fps;
 	u32 prio_val;
 	u32 prio_val;
-	u32 ts_fps;
+	u32 buf_timetamps_fps, mbpf;
 
 
 	if (!inst || !inst->core || !inst->capabilities) {
 	if (!inst || !inst->core || !inst->capabilities) {
 		d_vpr_e("%s: invalid params\n", __func__);
 		d_vpr_e("%s: invalid params\n", __func__);
@@ -45,12 +45,16 @@ u64 msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, u32 data_size)
 		return core->dt->allowed_clks_tbl[prio_val-1].clock_rate;
 		return core->dt->allowed_clks_tbl[prio_val-1].clock_rate;
 	}
 	}
 
 
-	mbs_per_second = msm_vidc_get_inst_load(inst);
+	mbpf = msm_vidc_get_mbs_per_frame(inst);
 	fps = msm_vidc_get_fps(inst);
 	fps = msm_vidc_get_fps(inst);
 
 
-	ts_fps = msm_vidc_calc_framerate(inst);
-	if (ts_fps > fps)
-		i_vpr_l(inst, "%s: ts_rate %d set rate %d\n", __func__, ts_fps, fps);
+	buf_timetamps_fps = msm_vidc_calc_framerate(inst);
+
+	/* use buffer detected fps instead of client set value */
+	if (fps < buf_timetamps_fps)
+		fps = buf_timetamps_fps;
+
+	mbs_per_second = mbpf * fps;
 
 
 	/*
 	/*
 	 * Calculate vpp, vsp, fw cycles separately for encoder and decoder.
 	 * Calculate vpp, vsp, fw cycles separately for encoder and decoder.
@@ -152,8 +156,8 @@ u64 msm_vidc_calc_freq_iris2(struct msm_vidc_inst *inst, u32 data_size)
 	freq = max(vpp_cycles, vsp_cycles);
 	freq = max(vpp_cycles, vsp_cycles);
 	freq = max(freq, fw_cycles);
 	freq = max(freq, fw_cycles);
 
 
-	i_vpr_p(inst, "%s: filled len %d required freq %llu\n",
-		__func__, data_size, freq);
+	i_vpr_p(inst, "%s: filled len %d, required freq %llu, fps %u, mbpf %u\n",
+		__func__, data_size, freq, fps, mbpf);
 
 
 	return freq;
 	return freq;
 }
 }

+ 11 - 20
driver/vidc/src/msm_vidc_power.c

@@ -47,27 +47,12 @@ u64 msm_vidc_max_freq(struct msm_vidc_inst *inst)
 
 
 int msm_vidc_get_mbps(struct msm_vidc_inst *inst)
 int msm_vidc_get_mbps(struct msm_vidc_inst *inst)
 {
 {
-	u32 input_port_mbs, output_port_mbs;
-	u32 fps, operating_rate, frame_rate;
-	struct v4l2_format *f;
+	u32 mbpf, fps;
 
 
-	f = &inst->fmts[INPUT_PORT];
-	input_port_mbs = NUM_MBS_PER_FRAME(f->fmt.pix_mp.width,
-		f->fmt.pix_mp.height);
+	mbpf = msm_vidc_get_mbs_per_frame(inst);
+	fps = msm_vidc_get_fps(inst);
 
 
-	f = &inst->fmts[OUTPUT_PORT];
-	output_port_mbs = NUM_MBS_PER_FRAME(f->fmt.pix_mp.width,
-		f->fmt.pix_mp.height);
-
-	frame_rate = inst->capabilities->cap[FRAME_RATE].value;
-	operating_rate = inst->capabilities->cap[OPERATING_RATE].value;
-
-	fps = max(operating_rate, frame_rate);
-
-	/* In case of fps < 1 we assume 1 */
-	fps = max(fps >> 16, (u32)1);
-
-	return max(input_port_mbs, output_port_mbs) * fps;
+	return mbpf * fps;
 }
 }
 
 
 int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
 int msm_vidc_get_inst_load(struct msm_vidc_inst *inst)
@@ -196,7 +181,7 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 	struct vidc_bus_vote_data *vote_data;
 	struct vidc_bus_vote_data *vote_data;
 	struct v4l2_format *out_f;
 	struct v4l2_format *out_f;
 	struct v4l2_format *inp_f;
 	struct v4l2_format *inp_f;
-	int codec = 0, frame_rate;
+	int codec = 0, frame_rate, buf_ts_fps;
 
 
 	if (!inst || !inst->core || !inst->capabilities) {
 	if (!inst || !inst->core || !inst->capabilities) {
 		d_vpr_e("%s: invalid params: %pK\n", __func__, inst);
 		d_vpr_e("%s: invalid params: %pK\n", __func__, inst);
@@ -242,6 +227,12 @@ int msm_vidc_scale_buses(struct msm_vidc_inst *inst)
 	vote_data->lcu_size = (codec == V4L2_PIX_FMT_HEVC ||
 	vote_data->lcu_size = (codec == V4L2_PIX_FMT_HEVC ||
 			codec == V4L2_PIX_FMT_VP9) ? 32 : 16;
 			codec == V4L2_PIX_FMT_VP9) ? 32 : 16;
 	vote_data->fps = msm_vidc_get_fps(inst);
 	vote_data->fps = msm_vidc_get_fps(inst);
+	buf_ts_fps = msm_vidc_calc_framerate(inst);
+	if (buf_ts_fps > vote_data->fps) {
+		i_vpr_l(inst, "%s: bitstream: fps %d, client rate %u\n", __func__,
+			buf_ts_fps, vote_data->fps);
+		vote_data->fps = buf_ts_fps;
+	}
 
 
 	if (inst->domain == MSM_VIDC_ENCODER) {
 	if (inst->domain == MSM_VIDC_ENCODER) {
 		vote_data->domain = MSM_VIDC_ENCODER;
 		vote_data->domain = MSM_VIDC_ENCODER;