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

Commit 79906427 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ais: Support multi-client for req and sync mgr"

parents 423eebbb c64c020a
Loading
Loading
Loading
Loading
+30 −20
Original line number Diff line number Diff line
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2019, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -103,10 +103,6 @@ static int cam_req_mgr_open(struct file *filep)
	int rc;

	mutex_lock(&g_dev.cam_lock);
	if (g_dev.open_cnt >= 1) {
		rc = -EALREADY;
		goto end;
	}

	rc = v4l2_fh_open(filep);
	if (rc) {
@@ -114,11 +110,18 @@ static int cam_req_mgr_open(struct file *filep)
		goto end;
	}

	g_dev.open_cnt++;

	/* return if already initialized before */
	if (g_dev.open_cnt > 1) {
		CAM_ERR(CAM_CRM, "Already opened", rc);
		goto end;
	}

	spin_lock_bh(&g_dev.cam_eventq_lock);
	g_dev.cam_eventq = filep->private_data;
	spin_unlock_bh(&g_dev.cam_eventq_lock);

	g_dev.open_cnt++;
	rc = cam_mem_mgr_init();
	if (rc) {
		g_dev.open_cnt--;
@@ -165,27 +168,34 @@ static int cam_req_mgr_close(struct file *filep)
		return -EINVAL;
	}

	g_dev.open_cnt--;

	if (g_dev.open_cnt == 0) {
		cam_req_mgr_handle_core_shutdown();

		list_for_each_entry(sd, &g_dev.v4l2_dev->subdevs, list) {
			if (!(sd->flags & V4L2_SUBDEV_FL_HAS_DEVNODE))
				continue;
			if (sd->internal_ops && sd->internal_ops->close) {
			CAM_DBG(CAM_CRM, "Invoke subdev close for device %s",
				CAM_DBG(CAM_CRM,
					"Invoke subdev close for device %s",
					sd->name);
				sd->internal_ops->close(sd, subdev_fh);
			}
		}
	}

	g_dev.open_cnt--;
	v4l2_fh_release(filep);

	if (g_dev.open_cnt == 0) {
		spin_lock_bh(&g_dev.cam_eventq_lock);
		g_dev.cam_eventq = NULL;
		spin_unlock_bh(&g_dev.cam_eventq_lock);

		cam_req_mgr_util_free_hdls();
		cam_mem_mgr_deinit();
	}

	mutex_unlock(&g_dev.cam_lock);

	return 0;
+30 −16
Original line number Diff line number Diff line
@@ -439,9 +439,10 @@ static int cam_sync_handle_create(struct cam_private_ioctl_arg *k_ioctl)
		k_ioctl->size))
		return -EFAULT;

	mutex_lock(&sync_dev->table_lock);
	result = cam_sync_create(&sync_create.sync_obj,
		sync_create.name);

	mutex_unlock(&sync_dev->table_lock);
	if (!result)
		if (copy_to_user(
			u64_to_user_ptr(k_ioctl->ioctl_ptr),
@@ -560,6 +561,7 @@ static int cam_sync_handle_wait(struct cam_private_ioctl_arg *k_ioctl)
static int cam_sync_handle_destroy(struct cam_private_ioctl_arg *k_ioctl)
{
	struct cam_sync_info sync_create;
	int rc;

	if (k_ioctl->size != sizeof(struct cam_sync_info))
		return -EINVAL;
@@ -572,7 +574,11 @@ static int cam_sync_handle_destroy(struct cam_private_ioctl_arg *k_ioctl)
		k_ioctl->size))
		return -EFAULT;

	return cam_sync_destroy(sync_create.sync_obj);
	mutex_lock(&sync_dev->table_lock);
	rc = cam_sync_destroy(sync_create.sync_obj);
	mutex_unlock(&sync_dev->table_lock);

	return rc;
}

static int cam_sync_handle_register_user_payload(
@@ -789,20 +795,26 @@ static int cam_sync_open(struct file *filep)
	sync_dev->err_cnt = 0;

	mutex_lock(&sync_dev->table_lock);
	if (sync_dev->open_cnt >= 1) {
		mutex_unlock(&sync_dev->table_lock);
		return -EALREADY;
	}

	rc = v4l2_fh_open(filep);
	if (!rc) {
	if (rc) {
		CAM_ERR(CAM_SYNC, "v4l2_fh_open failed: %d", rc);
		goto end;
	}

	sync_dev->open_cnt++;

	/* return if already initialized before */
	if (sync_dev->open_cnt > 1) {
		CAM_ERR(CAM_SYNC, "Already opened", rc);
		goto end;
	}

	spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
	sync_dev->cam_sync_eventq = filep->private_data;
	spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
	} else {
		CAM_ERR(CAM_SYNC, "v4l2_fh_open failed : %d", rc);
	}

end:
	mutex_unlock(&sync_dev->table_lock);

	return rc;
@@ -864,11 +876,13 @@ static int cam_sync_close(struct file *filep)
					  i);
			}
		}
	}
	mutex_unlock(&sync_dev->table_lock);

		spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
		sync_dev->cam_sync_eventq = NULL;
		spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
	}
	mutex_unlock(&sync_dev->table_lock);

	v4l2_fh_release(filep);

	return rc;