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

Commit 285756a2 authored by Camera Software Integration's avatar Camera Software Integration Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camera: common: add reference count for all video subdevs" into camera-kernel.lnx.1.0

parents bbb318fe 6b3b21c0
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved.
 */

#include <linux/device.h>
@@ -68,16 +68,22 @@ static int cam_fd_dev_close(struct v4l2_subdev *sd,
	}

	mutex_lock(&fd_dev->lock);
	if (fd_dev->open_cnt <= 0) {
		mutex_unlock(&fd_dev->lock);
		return -EINVAL;
	}
	fd_dev->open_cnt--;
	CAM_DBG(CAM_FD, "FD Subdev open count %d", fd_dev->open_cnt);
	mutex_unlock(&fd_dev->lock);

	if (!node) {
		CAM_ERR(CAM_FD, "Node ptr is NULL");
		mutex_unlock(&fd_dev->lock);
		return -EINVAL;
	}

	if (fd_dev->open_cnt == 0)
		cam_node_shutdown(node);
	mutex_unlock(&fd_dev->lock);

	return 0;
}
@@ -131,6 +137,7 @@ static int cam_fd_dev_probe(struct platform_device *pdev)

	mutex_init(&g_fd_dev.lock);
	g_fd_dev.probe_done = true;
	g_fd_dev.open_cnt = 0;

	CAM_DBG(CAM_FD, "Camera FD probe complete");

+31 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2018, 2020, The Linux Foundation. All rights reserved.
 */

#include "cam_actuator_dev.h"
@@ -72,6 +72,25 @@ static long cam_actuator_init_subdev_do_ioctl(struct v4l2_subdev *sd,
}
#endif

static int cam_actuator_subdev_open(struct v4l2_subdev *sd,
	struct v4l2_subdev_fh *fh)
{
	struct cam_actuator_ctrl_t *a_ctrl =
		v4l2_get_subdevdata(sd);

	if (!a_ctrl) {
		CAM_ERR(CAM_ACTUATOR, "a_ctrl ptr is NULL");
		return -EINVAL;
	}

	mutex_lock(&(a_ctrl->actuator_mutex));
	a_ctrl->open_cnt++;
	CAM_DBG(CAM_ACTUATOR, "actuator_dev open count %d", a_ctrl->open_cnt);
	mutex_unlock(&(a_ctrl->actuator_mutex));

	return 0;
}

static int cam_actuator_subdev_close(struct v4l2_subdev *sd,
	struct v4l2_subdev_fh *fh)
{
@@ -84,6 +103,13 @@ static int cam_actuator_subdev_close(struct v4l2_subdev *sd,
	}

	mutex_lock(&(a_ctrl->actuator_mutex));
	if (a_ctrl->open_cnt <= 0) {
		mutex_unlock(&(a_ctrl->actuator_mutex));
		return -EINVAL;
	}
	a_ctrl->open_cnt--;
	CAM_DBG(CAM_ACTUATOR, "actuator_dev open count %d", a_ctrl->open_cnt);
	if (a_ctrl->open_cnt == 0)
		cam_actuator_shutdown(a_ctrl);
	mutex_unlock(&(a_ctrl->actuator_mutex));

@@ -102,6 +128,7 @@ static struct v4l2_subdev_ops cam_actuator_subdev_ops = {
};

static const struct v4l2_subdev_internal_ops cam_actuator_internal_ops = {
	.open  = cam_actuator_subdev_open,
	.close = cam_actuator_subdev_close,
};

@@ -210,6 +237,7 @@ static int32_t cam_actuator_driver_i2c_probe(struct i2c_client *client,
		cam_actuator_apply_request;
	a_ctrl->last_flush_req = 0;
	a_ctrl->cam_act_state = CAM_ACTUATOR_INIT;
	a_ctrl->open_cnt = 0;

	return rc;

@@ -372,6 +400,7 @@ static int32_t cam_actuator_driver_platform_probe(

	platform_set_drvdata(pdev, a_ctrl);
	a_ctrl->cam_act_state = CAM_ACTUATOR_INIT;
	a_ctrl->open_cnt = 0;

	return rc;

+2 −1
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 */


@@ -115,6 +115,7 @@ struct cam_actuator_ctrl_t {
	struct cam_actuator_query_cap act_info;
	struct intf_params bridge_intf;
	uint32_t last_flush_req;
	uint32_t open_cnt;
};

#endif /* _CAM_ACTUATOR_DEV_H_ */
+30 −1
Original line number Diff line number Diff line
@@ -50,6 +50,26 @@ static long cam_csiphy_subdev_ioctl(struct v4l2_subdev *sd,
	return rc;
}


static int cam_csiphy_subdev_open(struct v4l2_subdev *sd,
	struct v4l2_subdev_fh *fh)
{
	struct csiphy_device *csiphy_dev =
		v4l2_get_subdevdata(sd);

	if (!csiphy_dev) {
		CAM_ERR(CAM_CSIPHY, "csiphy_dev ptr is NULL");
		return -EINVAL;
	}

	mutex_lock(&csiphy_dev->mutex);
	csiphy_dev->open_cnt++;
	CAM_DBG(CAM_CSIPHY, "csiphy_dev open count %d", csiphy_dev->open_cnt);
	mutex_unlock(&csiphy_dev->mutex);

	return 0;
}

static int cam_csiphy_subdev_close(struct v4l2_subdev *sd,
	struct v4l2_subdev_fh *fh)
{
@@ -62,6 +82,13 @@ static int cam_csiphy_subdev_close(struct v4l2_subdev *sd,
	}

	mutex_lock(&csiphy_dev->mutex);
	if (csiphy_dev->open_cnt <= 0) {
		mutex_unlock(&csiphy_dev->mutex);
		return -EINVAL;
	}
	csiphy_dev->open_cnt--;
	CAM_DBG(CAM_CSIPHY, "csiphy_dev open count %d", csiphy_dev->open_cnt);
	if (csiphy_dev->open_cnt == 0)
		cam_csiphy_shutdown(csiphy_dev);
	mutex_unlock(&csiphy_dev->mutex);

@@ -120,6 +147,7 @@ static const struct v4l2_subdev_ops csiphy_subdev_ops = {
};

static const struct v4l2_subdev_internal_ops csiphy_subdev_intern_ops = {
	.open  = cam_csiphy_subdev_open,
	.close = cam_csiphy_subdev_close,
};

@@ -192,6 +220,7 @@ static int32_t cam_csiphy_platform_probe(struct platform_device *pdev)
	new_csiphy_dev->acquire_count = 0;
	new_csiphy_dev->start_dev_count = 0;
	new_csiphy_dev->is_acquired_dev_combo_mode = 0;
	new_csiphy_dev->open_cnt = 0;

	cpas_parms.cam_cpas_client_cb = NULL;
	cpas_parms.cell_index = new_csiphy_dev->soc_info.index;
+1 −0
Original line number Diff line number Diff line
@@ -293,6 +293,7 @@ struct csiphy_device {
	struct cam_hw_soc_info   soc_info;
	uint32_t cpas_handle;
	uint32_t config_count;
	uint32_t open_cnt;
	uint64_t csiphy_cpas_cp_reg_mask[CSIPHY_MAX_INSTANCES];
};

Loading