static int camera_v4l2_open(struct file *filep)
{
	int rc = 0;
	struct v4l2_event event;
	struct msm_video_device *pvdev = video_drvdata(filep);
	BUG_ON(!pvdev);

	rc = camera_v4l2_fh_open(filep);
	if (rc < 0)
		goto fh_open_fail;

	/* every stream has a vb2 queue */
	rc = camera_v4l2_vb2_q_init(filep);
	if (rc < 0)
		goto vb2_q_fail;

	if (!atomic_read(&pvdev->opened)) {

		/* create a new session when first opened */
		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
		if (rc < 0)
			goto session_fail;
		rc = msm_create_command_ack_q(pvdev->vdev->num, 0);
		if (rc < 0)
			goto command_ack_q_fail;

		camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event);
		rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		if (rc < 0)
			goto post_fail;

		rc = camera_check_event_status(&event);
		if (rc < 0)
			goto post_fail;
	} else {
		rc = msm_create_command_ack_q(pvdev->vdev->num,
			atomic_read(&pvdev->stream_cnt));
		if (rc < 0)
			goto session_fail;
	}

	atomic_add(1, &pvdev->opened);
	atomic_add(1, &pvdev->stream_cnt);
	return rc;

post_fail:
	msm_delete_command_ack_q(pvdev->vdev->num, 0);
command_ack_q_fail:
	msm_destroy_session(pvdev->vdev->num);
session_fail:
	camera_v4l2_vb2_q_release(filep);
vb2_q_fail:
	camera_v4l2_fh_release(filep);
fh_open_fail:
	return rc;
}
static int camera_v4l2_open(struct file *filep)
{
	int rc = 0;
	struct v4l2_event event;
	struct msm_video_device *pvdev = video_drvdata(filep);
	BUG_ON(!pvdev);

	rc = camera_v4l2_fh_open(filep);

	if (rc < 0) {
		pr_err("%s : camera_v4l2_fh_open failed Line %d rc %d\n",
				__func__, __LINE__, rc);
		goto fh_open_fail;
	}
	/* every stream has a vb2 queue */
	rc = camera_v4l2_vb2_q_init(filep);

	if (rc < 0) {
		pr_err("%s : vb2 queue init fails Line %d rc %d\n",
				__func__, __LINE__, rc);
		goto vb2_q_fail;
	}
	if (!atomic_read(&pvdev->opened)) {
		pm_stay_awake(&pvdev->vdev->dev);

		/* create a new session when first opened */
		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
		if (rc < 0) {
			pr_err("%s : session creation failed Line %d rc %d\n",
					__func__, __LINE__, rc);
			goto session_fail;
		}
		rc = msm_create_command_ack_q(pvdev->vdev->num, 0);

		if (rc < 0) {
			pr_err("%s : creation of command_ack queue failed\n",
					__func__);
			pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc);
			goto command_ack_q_fail;
		}
		camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event);
		rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		if (rc < 0) {
			pr_err("%s : posting of NEW_SESSION event failed\n",
					__func__);
			pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc);
			goto post_fail;
		}
		rc = camera_check_event_status(&event);
		if (rc < 0) {
			pr_err("%s : checking event status fails Line %d rc %d\n",
					__func__, __LINE__, rc);
			goto post_fail;
		}
	} else {
		rc = msm_create_command_ack_q(pvdev->vdev->num,
			atomic_read(&pvdev->stream_cnt));
		if (rc < 0) {
			pr_err("%s : creation of command_ack queue failed Line %d rc %d\n",
					__func__, __LINE__, rc);
			goto session_fail;
		}
	}

	atomic_add(1, &pvdev->opened);
	atomic_add(1, &pvdev->stream_cnt);
	return rc;

post_fail:
	msm_delete_command_ack_q(pvdev->vdev->num, 0);
command_ack_q_fail:
	msm_destroy_session(pvdev->vdev->num);
session_fail:
	pm_relax(&pvdev->vdev->dev);
	camera_v4l2_vb2_q_release(filep);
vb2_q_fail:
	camera_v4l2_fh_release(filep);
fh_open_fail:
	return rc;
}
static int camera_v4l2_open(struct file *filep)
{
	int rc = 0;
	struct v4l2_event event;
	struct msm_video_device *pvdev = video_drvdata(filep);
	unsigned int opn_idx, idx;
	BUG_ON(!pvdev);

	rc = camera_v4l2_fh_open(filep);
	if (rc < 0) {
		pr_err("%s : camera_v4l2_fh_open failed Line %d rc %d\n",
				__func__, __LINE__, rc);
		goto fh_open_fail;
	}

	opn_idx = atomic_read(&pvdev->opened);
	idx = opn_idx;
	/* every stream has a vb2 queue */
	rc = camera_v4l2_vb2_q_init(filep);
	if (rc < 0) {
		pr_err("%s : vb2 queue init fails Line %d rc %d\n",
				__func__, __LINE__, rc);
		goto vb2_q_fail;
	}

	if (!atomic_read(&pvdev->opened)) {
		pm_stay_awake(&pvdev->vdev->dev);

		/* Disable power collapse latency */
		msm_pm_qos_update_request(CAMERA_DISABLE_PC_LATENCY);

		/* create a new session when first opened */
		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
		if (rc < 0) {
			pr_err("%s : session creation failed Line %d rc %d\n",
					__func__, __LINE__, rc);
			goto session_fail;
		}

		rc = msm_create_command_ack_q(pvdev->vdev->num,
			find_first_zero_bit((const unsigned long *)&opn_idx,
				MSM_CAMERA_STREAM_CNT_BITS));
		if (rc < 0) {
			pr_err("%s : creation of command_ack queue failed\n",
					__func__);
			pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc);
			goto command_ack_q_fail;
		}

		camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event);
		rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		if (rc < 0) {
			pr_err("%s : posting of NEW_SESSION event failed\n",
					__func__);
			pr_err("%s : Line %d rc %d\n", __func__, __LINE__, rc);
			goto post_fail;
		}

		rc = camera_check_event_status(&event);
		if (rc < 0) {
			pr_err("%s : checking event status fails Line %d rc %d\n",
					__func__, __LINE__, rc);
			goto post_fail;
		}
	} else {
		rc = msm_create_command_ack_q(pvdev->vdev->num,
			find_first_zero_bit((const unsigned long *)&opn_idx,
				MSM_CAMERA_STREAM_CNT_BITS));
		if (rc < 0) {
			pr_err("%s : creation of command_ack queue failed Line %d rc %d\n",
					__func__, __LINE__, rc);
			goto session_fail;
		}
	}
	idx |= (1 << find_first_zero_bit((const unsigned long *)&opn_idx,
				MSM_CAMERA_STREAM_CNT_BITS));
	atomic_cmpxchg(&pvdev->opened, opn_idx, idx);
	return rc;

post_fail:
	msm_delete_command_ack_q(pvdev->vdev->num, 0);
command_ack_q_fail:
	msm_destroy_session(pvdev->vdev->num);
session_fail:
	pm_relax(&pvdev->vdev->dev);
	camera_v4l2_vb2_q_release(filep);
vb2_q_fail:
	camera_v4l2_fh_release(filep);
fh_open_fail:
	return rc;
}
Beispiel #4
0
static int camera_v4l2_open(struct file *filep)
{
	int rc = 0;
	struct v4l2_event event;
	struct msm_video_device *pvdev = video_drvdata(filep);

	BUG_ON(!pvdev);

	rc = camera_v4l2_fh_open(filep);
	if (rc < 0) {
		pr_err("%s : camera_v4l2_fh_open", __func__);
		goto fh_open_fail;
	}

	/* every stream has a vb2 queue */
	rc = camera_v4l2_vb2_q_init(filep);
	if (rc < 0) {
		pr_err("%s : camera_v4l2_vb2_q_init", __func__);
		goto vb2_q_fail;
	}

	if (!atomic_read(&pvdev->opened)) {

		/* create a new session when first opened */
		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
		if (rc < 0) {
			pr_err("%s : msm_create_session", __func__);
			goto session_fail;
		}

		rc = msm_create_command_ack_q(pvdev->vdev->num, 0);
		if (rc < 0) {
			pr_err("%s : msm_create_command_ack_q", __func__);
			goto command_ack_q_fail;
		}

		camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event);
		rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		if (rc < 0) {
			pr_err("%s, __dbg: post fail \n", __func__);
			if (qdaemon_task) {
				if (!strncmp(qdaemon_task->comm, QDAEMON, strlen(QDAEMON))) {
					pr_err("%s, kill daemon", __func__);
					send_sig(SIGKILL, qdaemon_task, 0);
					pr_err("%s, kill this", __func__);
					send_sig(SIGKILL, current, 0);
				} else
					pr_err("%s, now (%s : %d)", __func__,
					   qdaemon_task->comm, task_pid_nr(qdaemon_task));
			} else
				pr_err("error!! can't look for daemon");
			goto post_fail;
		}
		rc = camera_check_event_status(&event);
		if (rc < 0) {
			pr_err("%s : camera_check_event_status", __func__);
			goto post_fail;
		}
	} else {
		rc = msm_create_command_ack_q(pvdev->vdev->num,
					      atomic_read(&pvdev->opened));
		if (rc < 0) {
			pr_err("%s : msm_create_command_ack_q", __func__);
			goto session_fail;
		}
	}

	atomic_add(1, &pvdev->opened);
	return rc;

 post_fail:
	msm_delete_command_ack_q(pvdev->vdev->num, 0);
 command_ack_q_fail:
	msm_destroy_session(pvdev->vdev->num);
 session_fail:
	camera_v4l2_vb2_q_release(filep);
 vb2_q_fail:
	camera_v4l2_fh_release(filep);
 fh_open_fail:
	return rc;
}