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

Commit 0c09c333 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm:camera: Enable/Disable camera daemon"

parents 979aef8f 30c760f9
Loading
Loading
Loading
Loading
+68 −45
Original line number Diff line number Diff line
@@ -92,6 +92,9 @@ static int camera_v4l2_querycap(struct file *filep, void *fh,
	int rc;
	struct v4l2_event event;

	if (msm_is_daemon_present() == false)
		return 0;

	/* can use cap->driver to make differentiation */
	camera_pack_event(filep, MSM_CAMERA_GET_PARM,
		MSM_CAMERA_PRIV_QUERY_CAP, -1, &event);
@@ -111,6 +114,9 @@ static int camera_v4l2_s_crop(struct file *filep, void *fh,
	int rc = 0;
	struct v4l2_event event;

	if (msm_is_daemon_present() == false)
		return 0;

	if (crop->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {

		camera_pack_event(filep, MSM_CAMERA_SET_PARM,
@@ -132,6 +138,9 @@ static int camera_v4l2_g_crop(struct file *filep, void *fh,
	int rc = 0;
	struct v4l2_event event;

	if (msm_is_daemon_present() == false)
		return 0;

	if (crop->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
		camera_pack_event(filep, MSM_CAMERA_GET_PARM,
			MSM_CAMERA_PRIV_G_CROP, -1, &event);
@@ -152,6 +161,9 @@ static int camera_v4l2_queryctrl(struct file *filep, void *fh,
	int rc = 0;
	struct v4l2_event event;

	if (msm_is_daemon_present() == false)
		return 0;

	if (ctrl->type == V4L2_CTRL_TYPE_MENU) {

		camera_pack_event(filep, MSM_CAMERA_GET_PARM,
@@ -281,6 +293,10 @@ static int camera_v4l2_streamon(struct file *filep, void *fh,
	mutex_lock(&sp->lock);
	rc = vb2_streamon(&sp->vb2_q, buf_type);
	mutex_unlock(&sp->lock);

	if (msm_is_daemon_present() == false)
		return 0;

	camera_pack_event(filep, MSM_CAMERA_SET_PARM,
		MSM_CAMERA_PRIV_STREAM_ON, -1, &event);

@@ -296,17 +312,18 @@ static int camera_v4l2_streamoff(struct file *filep, void *fh,
		enum v4l2_buf_type buf_type)
{
	struct v4l2_event event;
	int rc;
	int rc = 0;
	struct camera_v4l2_private *sp = fh_to_private(fh);

	if (msm_is_daemon_present() != false) {
		camera_pack_event(filep, MSM_CAMERA_SET_PARM,
			MSM_CAMERA_PRIV_STREAM_OFF, -1, &event);

		rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		if (rc < 0)
			return rc;

		rc = camera_check_event_status(&event);
	}
	mutex_lock(&sp->lock);
	vb2_streamoff(&sp->vb2_q, buf_type);
	mutex_unlock(&sp->lock);
@@ -318,6 +335,9 @@ static int camera_v4l2_g_fmt_vid_cap_mplane(struct file *filep, void *fh,
{
	int rc = -EINVAL;

	if (msm_is_daemon_present() == false)
		return 0;

	if (pfmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
		struct v4l2_event event;

@@ -362,6 +382,7 @@ static int camera_v4l2_s_fmt_vid_cap_mplane(struct file *filep, void *fh,
			pr_debug("%s: plane size[%d]\n", __func__,
					user_fmt->plane_sizes[i]);

		if (msm_is_daemon_present() != false) {
			camera_pack_event(filep, MSM_CAMERA_SET_PARM,
				MSM_CAMERA_PRIV_S_FMT, -1, &event);

@@ -372,12 +393,11 @@ static int camera_v4l2_s_fmt_vid_cap_mplane(struct file *filep, void *fh,
			rc = camera_check_event_status(&event);
			if (rc < 0)
				return rc;

		}
		sp->is_vb2_valid = 1;
	}

	return rc;

}

static int camera_v4l2_try_fmt_vid_cap_mplane(struct file *filep, void *fh,
@@ -411,6 +431,7 @@ static int camera_v4l2_s_parm(struct file *filep, void *fh,
	if (rc < 0)
		return rc;

	if (msm_is_daemon_present() != false) {
		rc = msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		if (rc < 0)
			goto error;
@@ -418,7 +439,7 @@ static int camera_v4l2_s_parm(struct file *filep, void *fh,
		rc = camera_check_event_status(&event);
		if (rc < 0)
			goto error;

	}
	/* use stream_id as stream index */
	parm->parm.capture.extendedmode = sp->stream_id;
	sp->stream_created = true;
@@ -640,19 +661,18 @@ static int camera_v4l2_open(struct file *filep)
			goto command_ack_q_fail;
		}

		camera_pack_event(filep, MSM_CAMERA_NEW_SESSION, 0, -1, &event);
		if (msm_is_daemon_present() != false) {
			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);
				pr_err("%s : NEW_SESSION event failed,rc %d\n",
					__func__, 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);
			if (rc < 0)
				goto post_fail;
		}
		/* Enable power collapse latency */
@@ -704,7 +724,6 @@ static unsigned int camera_v4l2_poll(struct file *filep,

static int camera_v4l2_close(struct file *filep)
{
	int rc = 0;
	struct v4l2_event event;
	struct msm_video_device *pvdev = video_drvdata(filep);
	struct camera_v4l2_private *sp = fh_to_private(filep->private_data);
@@ -721,18 +740,22 @@ static int camera_v4l2_close(struct file *filep)
	opn_idx &= ~mask;
	atomic_set(&pvdev->opened, opn_idx);

	if (sp->stream_created == true) {
	if (msm_is_daemon_present() != false && sp->stream_created == true) {
		pr_debug("%s: close stream_id=%d\n", __func__, sp->stream_id);
		camera_pack_event(filep, MSM_CAMERA_SET_PARM,
			MSM_CAMERA_PRIV_DEL_STREAM, -1, &event);
		msm_post_event(&event, MSM_POST_EVT_TIMEOUT);
		sp->stream_created = false;
	}

	if (sp->stream_created == true)
		sp->stream_created = false;

	if (atomic_read(&pvdev->opened) == 0) {
		camera_pack_event(filep, MSM_CAMERA_DEL_SESSION, 0, -1, &event);
		if (msm_is_daemon_present() != false) {
			camera_pack_event(filep, MSM_CAMERA_DEL_SESSION,
				0, -1, &event);
			msm_post_event(&event, MSM_POST_EVT_TIMEOUT);

		}
		msm_delete_command_ack_q(pvdev->vdev->num, 0);
		msm_delete_stream(pvdev->vdev->num, sp->stream_id);
		mutex_unlock(&session->close_lock);
@@ -753,7 +776,7 @@ static int camera_v4l2_close(struct file *filep)

	camera_v4l2_fh_release(filep);

	return rc;
	return 0;
}

#ifdef CONFIG_COMPAT
+11 −0
Original line number Diff line number Diff line
@@ -40,6 +40,12 @@ static struct pm_qos_request msm_v4l2_pm_qos_request;

static struct msm_queue_head *msm_session_q;

/* This variable represent daemon status
 * true = daemon present (default state)
 * false = daemon is NOT present
 */
bool is_daemon_status = true;

/* config node envent queue */
static struct v4l2_fh  *msm_eventq;
spinlock_t msm_eventq_lock;
@@ -681,6 +687,11 @@ static long msm_private_ioctl(struct file *file, void *fh,
	unsigned long spin_flags = 0;
	struct msm_sd_subdev *msm_sd;

	if (cmd == MSM_CAM_V4L2_IOCTL_DAEMON_DISABLED) {
		is_daemon_status = false;
		return 0;
	}

	memset(&event, 0, sizeof(struct v4l2_event));
	session_id = event_data->session_id;
	stream_id = event_data->stream_id;
+7 −1
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@
#define CAMERA_DISABLE_PC_LATENCY 100
#define CAMERA_ENABLE_PC_LATENCY PM_QOS_DEFAULT_VALUE

extern bool is_daemon_status;

struct msm_video_device {
	struct video_device *vdev;
	atomic_t opened;
@@ -110,8 +112,12 @@ struct msm_session {
	struct mutex close_lock;
};

void msm_pm_qos_update_request(int val);
static inline bool msm_is_daemon_present(void)
{
	return is_daemon_status;
}

void msm_pm_qos_update_request(int val);
int msm_post_event(struct v4l2_event *event, int timeout);
int  msm_create_session(unsigned int session, struct video_device *vdev);
int msm_destroy_session(unsigned int session_id);
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
#define MSM_CAM_V4L2_IOCTL_NOTIFY_DEBUG \
	_IOW('V', BASE_VIDIOC_PRIVATE + 34, struct msm_v4l2_event_data)

#define MSM_CAM_V4L2_IOCTL_DAEMON_DISABLED \
	_IOW('V', BASE_VIDIOC_PRIVATE + 35, struct msm_v4l2_event_data)

#define QCAMERA_DEVICE_GROUP_ID	1
#define QCAMERA_VNODE_GROUP_ID	2
#define MSM_CAMERA_NAME			"msm_camera"