Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75c97e20 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: VPU: Clock frequency and bus bandwidth power optimizations"

parents 61a39b5f bd0c9726
Loading
Loading
Loading
Loading
+20 −7
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ struct vpu_channel_hal {
	void *clk_handle;
	struct regulator *vdd;
	bool vdd_enabled; /* if VDD is enabled */
	bool rpm_vote; /* If VPU high power vote was sent to RPM */
	/* internally cached value for current fw logging level */
	int fw_log_level;
};
@@ -1572,6 +1573,8 @@ int vpu_hw_session_empty_buffer(u32 sid, u32 port_id, struct vpu_buffer *vb)
	return rc;
}

static void inform_rpm_vpu_state(u32 on);

int vpu_hw_session_commit(u32 sid, enum commit_type ct,
			  u32 load_kbps, u32 pwr_mode)
{
@@ -1596,10 +1599,21 @@ int vpu_hw_session_commit(u32 sid, enum commit_type ct,
	}

	mutex_lock(&hal->pw_lock);
	if (vpu_bus_scale(load_kbps))
		pr_err("bus scale failed\n");

	if (pwr_mode == VPU_POWER_SVS && hal->rpm_vote) {
		inform_rpm_vpu_state(0);
		hal->rpm_vote = false;
	} else if (pwr_mode > VPU_POWER_SVS && !hal->rpm_vote) {
		inform_rpm_vpu_state(1);
		hal->rpm_vote = true;
	}

	if (vpu_clock_scale(hal->clk_handle, pwr_mode))
		pr_err("clock scale failed\n");

	if (vpu_bus_scale(load_kbps))
		pr_err("bus scale failed\n");

	mutex_unlock(&hal->pw_lock);

	/* send the configuration commit through IPC */
@@ -1958,9 +1972,6 @@ static int vpu_hw_power_on(struct vpu_channel_hal *hal)
{
	int rc;

	/* inform RPM VPU state is ON */
	inform_rpm_vpu_state(1);

	/* enable the power */
	if (!hal->vdd_enabled) {
		rc = regulator_enable(hal->vdd);
@@ -1992,7 +2003,6 @@ err_bus:
	regulator_disable(hal->vdd);
	hal->vdd_enabled = false;
err_power:
	inform_rpm_vpu_state(0);
	return rc;
}

@@ -2009,7 +2019,10 @@ static void vpu_hw_power_off(struct vpu_channel_hal *hal)
		hal->vdd_enabled = false;
	}

	if (hal->rpm_vote) {
		inform_rpm_vpu_state(0);
		hal->rpm_vote = false;
	}
}

int vpu_hw_sys_suspend(void)
+11 −6
Original line number Diff line number Diff line
@@ -1162,7 +1162,8 @@ static u32 __calculate_session_load(struct vpu_dev_session *session)
	int i;

	/* get required info before computation */
	fps = in->framerate ? in->framerate : MAX_FPS;
	fps = max(in->framerate, out->framerate) >> 16;
	fps = fps ? fps : 30;
	nrwb_bpp = __get_bits_per_pixel(V4L2_PIX_FMT_YUYV);
	in_bpp = __get_bits_per_pixel(in->format.pixelformat);
	out_bpp = __get_bits_per_pixel(out->format.pixelformat);
@@ -1170,7 +1171,7 @@ static u32 __calculate_session_load(struct vpu_dev_session *session)
	interlaced = in->scan_mode == LINESCANINTERLACED;
	nr_ctrl = get_control(controller, VPU_CTRL_NOISE_REDUCTION);
	nr = nr_ctrl ? (nr_ctrl->enable == PROP_TRUE) : false;
	bbroi = true; /* TODO: how to calculate? */
	bbroi = false; /* TODO: how to calculate? */

	/* compute the current session's load at each stage */
	stage_load_factor[VIP_MIP] = in_bpp;
@@ -1189,6 +1190,10 @@ static u32 __calculate_session_load(struct vpu_dev_session *session)
		load_kbps += stage_load_factor[i] *
			TO_KILO(out->format.width * out->format.height * fps);

	/* approximately a 25% BW increase if dual output is enabled */
	if (session->dual_output)
		load_kbps = (load_kbps * 5) / 4;

	return load_kbps;
}

@@ -1212,8 +1217,8 @@ static u32 __get_power_mode(struct vpu_dev_session *cur_sess)
	u32 max_w = 0, max_h = 0, fps, pr[VPU_NUM_SESSIONS] = {0, };
	int i, num_sessions = 0;
	const u32 pr_threshold[VPU_POWER_MAX] = {
		[VPU_POWER_SVS]     =  63000000,
		[VPU_POWER_NOMINAL] = 125000000,
		[VPU_POWER_SVS]     =  67000000,
		[VPU_POWER_NOMINAL] = 134000000,
		[VPU_POWER_TURBO]   = 260000000,
	};

@@ -1231,8 +1236,8 @@ static u32 __get_power_mode(struct vpu_dev_session *cur_sess)
		if ((max_w * max_h) > SZ_2M)
			goto exit_and_return_mode;

		fps = max(in->framerate, out->framerate);
		fps = fps ? fps : 60;
		fps = max(in->framerate, out->framerate) >> 16;
		fps = fps ? fps : 30;

		pr[i] = max_w * max_h * fps;
		pr_debug("session %d's pixel rate is %d\n", i, pr[i]);
+3 −2
Original line number Diff line number Diff line
@@ -253,10 +253,11 @@ static int __vpu_load_bus_vector_data(struct vpu_platform_resources *res,
		res->bus_table.loads[i] = vectors[i].load;

		for (j = 0; j < num_ports; j++) {
			/* change ab and ib values from kilobits to bytes */
			bus_pdata->usecase[i].vectors[j].ab =
					(u64)vectors[i].ab * 1000;
					(u64)vectors[i].ab * 1000 / 8;
			bus_pdata->usecase[i].vectors[j].ib =
					(u64)vectors[i].ib * 1000;
					(u64)vectors[i].ib * 1000 / 8;
			bus_pdata->usecase[i].vectors[j].src =
					bus_pdata_config.masters[j];
			bus_pdata->usecase[i].vectors[j].dst =
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ struct vpu_port_info {
	struct v4l2_pix_format_mplane format;
	struct v4l2_rect roi;
	u32 scan_mode;
	u32 framerate;
	u32 framerate; /* in 16.16 format */
	u32 video_fmt;
	u32 secure_content;