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

Commit 1c4191b8 authored by Sreesudhan Ramakrish Ramkumar's avatar Sreesudhan Ramakrish Ramkumar
Browse files

msm: camera: Get max vfe clk rate



Add support to query max vfe clk rate. This max rate shall be used
by mm-qcamera-daemon user space driver to populate its capabilities
and to assign vfe resources based on request.

Change-Id: Ib65b73424d725e2d3e50e2ce2030d2f1b09e7514
Signed-off-by: default avatarSreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
parent cb544cb0
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -256,6 +256,43 @@ int msm_isp_unsubscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,
	return rc;
}

static int msm_isp_get_max_clk_rate(struct vfe_device *vfe_dev, long *rate)
{
	int           clk_idx = 0;
	unsigned long max_value = ~0;
	long          round_rate = 0;

	if (!vfe_dev || !rate) {
		pr_err("%s:%d failed: vfe_dev %p rate %p\n", __func__, __LINE__,
			vfe_dev, rate);
		return -EINVAL;
	}

	*rate = 0;
	if (!vfe_dev->hw_info) {
		pr_err("%s:%d failed: vfe_dev->hw_info %p\n", __func__,
			__LINE__, vfe_dev->hw_info);
		return -EINVAL;
	}

	clk_idx = vfe_dev->hw_info->vfe_clk_idx;
	if (clk_idx >= ARRAY_SIZE(vfe_dev->vfe_clk)) {
		pr_err("%s:%d failed: clk_idx %d max array size %d\n",
			__func__, __LINE__, clk_idx,
			ARRAY_SIZE(vfe_dev->vfe_clk));
		return -EINVAL;
	}

	round_rate = clk_round_rate(vfe_dev->vfe_clk[clk_idx], max_value);
	if (round_rate < 0) {
		pr_err("%s: Invalid vfe clock rate\n", __func__);
		return -EINVAL;
	}

	*rate = round_rate;
	return 0;
}

static int msm_isp_set_clk_rate(struct vfe_device *vfe_dev, long *rate)
{
	int rc = 0;
@@ -606,6 +643,23 @@ static int msm_isp_send_hw_cmd(struct vfe_device *vfe_dev,
	case GET_SOC_HW_VER:
		*cfg_data = vfe_dev->soc_hw_version;
		break;
	case GET_MAX_CLK_RATE: {
		int rc = 0;

		if (cmd_len < sizeof(unsigned long)) {
			pr_err("%s:%d failed: invalid cmd len %d exp %d\n",
				__func__, __LINE__, cmd_len,
				sizeof(unsigned long));
			return -EINVAL;
		}
		rc = msm_isp_get_max_clk_rate(vfe_dev,
			(unsigned long *)cfg_data);
		if (rc < 0) {
			pr_err("%s:%d failed: rc %d\n", __func__, __LINE__, rc);
			return -EINVAL;
		}
		break;
	}
	}
	return 0;
}
+1 −0
Original line number Diff line number Diff line
@@ -234,6 +234,7 @@ enum msm_vfe_reg_cfg_type {
	VFE_READ_DMI_32BIT,
	VFE_READ_DMI_64BIT,
	GET_SOC_HW_VER,
	GET_MAX_CLK_RATE,
};

struct msm_vfe_cfg_cmd2 {