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

Commit 0da470ac authored by Ramesh V's avatar Ramesh V Committed by Gerrit - the friendly Code Review server
Browse files

Power: Enable/Disable power collapse after camera open



Disabling power collapse during camera open. We send
disable request before opening camera and enable it
back after opening camera

Change-Id: Idd55021063eace18fa20f00183a41a502f5c88a1
Signed-off-by: default avatarRamesh V <ramev@codeaurora.org>
parent 7b262653
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -576,6 +576,9 @@ static int camera_v4l2_open(struct file *filep)
	if (!atomic_read(&pvdev->opened)) {
	if (!atomic_read(&pvdev->opened)) {
		pm_stay_awake(&pvdev->vdev->dev);
		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 */
		/* create a new session when first opened */
		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
		rc = msm_create_session(pvdev->vdev->num, pvdev->vdev);
		if (rc < 0) {
		if (rc < 0) {
@@ -609,6 +612,8 @@ static int camera_v4l2_open(struct file *filep)
					__func__, __LINE__, rc);
					__func__, __LINE__, rc);
			goto post_fail;
			goto post_fail;
		}
		}
		/* Enable power collapse latency */
		msm_pm_qos_update_request(CAMERA_ENABLE_PC_LATENCY);
	} else {
	} else {
		rc = msm_create_command_ack_q(pvdev->vdev->num,
		rc = msm_create_command_ack_q(pvdev->vdev->num,
			find_first_zero_bit((const unsigned long *)&opn_idx,
			find_first_zero_bit((const unsigned long *)&opn_idx,
@@ -622,6 +627,7 @@ static int camera_v4l2_open(struct file *filep)
	idx |= (1 << find_first_zero_bit((const unsigned long *)&opn_idx,
	idx |= (1 << find_first_zero_bit((const unsigned long *)&opn_idx,
				MSM_CAMERA_STREAM_CNT_BITS));
				MSM_CAMERA_STREAM_CNT_BITS));
	atomic_cmpxchg(&pvdev->opened, opn_idx, idx);
	atomic_cmpxchg(&pvdev->opened, opn_idx, idx);

	return rc;
	return rc;


post_fail:
post_fail:
@@ -691,6 +697,7 @@ static int camera_v4l2_close(struct file *filep)
		 * and application crashes */
		 * and application crashes */
		camera_v4l2_vb2_q_release(filep);
		camera_v4l2_vb2_q_release(filep);
		msm_destroy_session(pvdev->vdev->num);
		msm_destroy_session(pvdev->vdev->num);

		pm_relax(&pvdev->vdev->dev);
		pm_relax(&pvdev->vdev->dev);
	} else {
	} else {
		msm_delete_command_ack_q(pvdev->vdev->num,
		msm_delete_command_ack_q(pvdev->vdev->num,
+26 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@
static struct v4l2_device *msm_v4l2_dev;
static struct v4l2_device *msm_v4l2_dev;
static struct list_head    ordered_sd_list;
static struct list_head    ordered_sd_list;


static struct pm_qos_request msm_v4l2_pm_qos_request;

static struct msm_queue_head *msm_session_q;
static struct msm_queue_head *msm_session_q;


/* config node envent queue */
/* config node envent queue */
@@ -207,6 +209,24 @@ static inline int __msm_queue_find_command_ack_q(void *d1, void *d2)
	return (ack->stream_id == *(unsigned int *)d2) ? 1 : 0;
	return (ack->stream_id == *(unsigned int *)d2) ? 1 : 0;
}
}


static void msm_pm_qos_add_request(void)
{
	pr_info("%s: add request", __func__);
	pm_qos_add_request(&msm_v4l2_pm_qos_request, PM_QOS_CPU_DMA_LATENCY,
	PM_QOS_DEFAULT_VALUE);
}

static void msm_pm_qos_remove_request(void)
{
	pr_info("%s: remove request", __func__);
	pm_qos_remove_request(&msm_v4l2_pm_qos_request);
}

void msm_pm_qos_update_request(int val)
{
	pr_info("%s: update request %d", __func__, val);
	pm_qos_update_request(&msm_v4l2_pm_qos_request, val);
}


struct msm_session *msm_session_find(unsigned int session_id)
struct msm_session *msm_session_find(unsigned int session_id)
{
{
@@ -921,6 +941,9 @@ static int msm_close(struct file *filep)
		list_for_each_entry(msm_sd, &ordered_sd_list, list)
		list_for_each_entry(msm_sd, &ordered_sd_list, list)
			__msm_sd_close_subdevs(msm_sd, &sd_close);
			__msm_sd_close_subdevs(msm_sd, &sd_close);


	/* remove msm_v4l2_pm_qos_request */
	msm_pm_qos_remove_request();

	/* send v4l2_event to HAL next*/
	/* send v4l2_event to HAL next*/
	msm_queue_traverse_action(msm_session_q, struct msm_session, list,
	msm_queue_traverse_action(msm_session_q, struct msm_session, list,
		__msm_close_destry_session_notify_apps, NULL);
		__msm_close_destry_session_notify_apps, NULL);
@@ -980,6 +1003,9 @@ static int msm_open(struct file *filep)
	msm_eventq = filep->private_data;
	msm_eventq = filep->private_data;
	spin_unlock_irqrestore(&msm_eventq_lock, flags);
	spin_unlock_irqrestore(&msm_eventq_lock, flags);


	/* register msm_v4l2_pm_qos_request */
	msm_pm_qos_add_request();

	return rc;
	return rc;
}
}


+5 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,9 @@
#define MSM_POST_EVT_NOTIMEOUT 0xFFFFFFFF
#define MSM_POST_EVT_NOTIMEOUT 0xFFFFFFFF
#define MSM_CAMERA_STREAM_CNT_BITS  32
#define MSM_CAMERA_STREAM_CNT_BITS  32


#define CAMERA_DISABLE_PC_LATENCY 100
#define CAMERA_ENABLE_PC_LATENCY PM_QOS_DEFAULT_VALUE

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


void msm_pm_qos_update_request(int val);

int msm_post_event(struct v4l2_event *event, int timeout);
int msm_post_event(struct v4l2_event *event, int timeout);
int  msm_create_session(unsigned int session, struct video_device *vdev);
int  msm_create_session(unsigned int session, struct video_device *vdev);
int msm_destroy_session(unsigned int session_id);
int msm_destroy_session(unsigned int session_id);