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

Commit 53341987 authored by Sreesudhan Ramakrish Ramkumar's avatar Sreesudhan Ramakrish Ramkumar
Browse files

msm: camera: Use refcount for isp subdev



ISP subdevice can be more than once at the same time since iface
driver configures AXI, clock and ISP driver configures module
registers. Use refcount to intialize and de-initialize first time
and last time respectively.

Change-Id: Iaa1b9198fcb0153cb40a3514d0f31c1e3509408c
Signed-off-by: default avatarSreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
parent fdcb26dd
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -985,15 +985,16 @@ int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)

	mutex_lock(&vfe_dev->realtime_mutex);
	mutex_lock(&vfe_dev->core_mutex);
	if (vfe_dev->vfe_open_cnt == 1) {
		pr_err("VFE already open\n");

	if (vfe_dev->vfe_open_cnt++) {
		mutex_unlock(&vfe_dev->core_mutex);
		mutex_unlock(&vfe_dev->realtime_mutex);
		return -ENODEV;
		return 0;
	}

	if (vfe_dev->hw_info->vfe_ops.core_ops.init_hw(vfe_dev) < 0) {
		pr_err("%s: init hardware failed\n", __func__);
		vfe_dev->vfe_open_cnt--;
		mutex_unlock(&vfe_dev->core_mutex);
		mutex_unlock(&vfe_dev->realtime_mutex);
		return -EBUSY;
@@ -1002,6 +1003,7 @@ int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
	rc = vfe_dev->hw_info->vfe_ops.core_ops.reset_hw(vfe_dev);
	if (rc <= 0) {
		pr_err("%s: reset timeout\n", __func__);
		vfe_dev->vfe_open_cnt--;
		mutex_unlock(&vfe_dev->core_mutex);
		mutex_unlock(&vfe_dev->realtime_mutex);
		return -EINVAL;
@@ -1027,7 +1029,6 @@ int msm_isp_open_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
		sizeof(struct msm_vfe_stats_shared_data));
	memset(&vfe_dev->error_info, 0, sizeof(vfe_dev->error_info));
	vfe_dev->axi_data.hw_info = vfe_dev->hw_info->axi_hw_info;
	vfe_dev->vfe_open_cnt++;
	vfe_dev->taskletq_idx = 0;
	vfe_dev->vt_enable = 0;
	vfe_dev->p_avtimer_lsw = NULL;
@@ -1056,11 +1057,17 @@ int msm_isp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
	ISP_DBG("%s\n", __func__);
	mutex_lock(&vfe_dev->realtime_mutex);
	mutex_lock(&vfe_dev->core_mutex);
	if (vfe_dev->vfe_open_cnt == 0) {
		pr_err("%s: Invalid close\n", __func__);

	if (!vfe_dev->vfe_open_cnt) {
		pr_err("%s invalid state open cnt %d\n", __func__,
			vfe_dev->vfe_open_cnt);
		return -EINVAL;
	}

	if (--vfe_dev->vfe_open_cnt) {
		mutex_unlock(&vfe_dev->core_mutex);
		mutex_unlock(&vfe_dev->realtime_mutex);
		return -ENODEV;
		return 0;
	}

	rc = vfe_dev->hw_info->vfe_ops.axi_ops.halt(vfe_dev);
@@ -1069,7 +1076,6 @@ int msm_isp_close_node(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)

	vfe_dev->buf_mgr->ops->buf_mgr_deinit(vfe_dev->buf_mgr);
	vfe_dev->hw_info->vfe_ops.core_ops.release_hw(vfe_dev);
	vfe_dev->vfe_open_cnt--;
	if (vfe_dev->vt_enable) {
		iounmap(vfe_dev->p_avtimer_lsw);
		iounmap(vfe_dev->p_avtimer_msw);
+8 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
#define ISP_META_CHANNEL_BIT  0x80000
#define ISP_STATS_STREAM_BIT  0x80000000

struct msm_vfe_cfg_cmd_list;

enum ISP_START_PIXEL_PATTERN {
	ISP_BAYER_RGRGRG,
	ISP_BAYER_GRGRGR,
@@ -238,6 +240,12 @@ struct msm_vfe_cfg_cmd2 {
	void __user *cfg_cmd;
};

struct msm_vfe_cfg_cmd_list {
	struct msm_vfe_cfg_cmd2      cfg_cmd;
	struct msm_vfe_cfg_cmd_list *next;
	uint32_t                     next_size;
};

struct msm_vfe_reg_rw_info {
	uint32_t reg_offset;
	uint32_t cmd_data_offset;