summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLiu Ying <Ying.Liu@freescale.com>2012-08-10 18:08:42 +0800
committerLiu Ying <Ying.Liu@freescale.com>2012-08-15 18:00:43 +0800
commit874198b89a89aa6e792754a0a51c46084ed93d1a (patch)
tree5d1377730a09c0c768cfc550e8c5b5b11c1c3da2 /drivers
parent6bf2db8e8af7c98115db989e3f7a4164c4cd448c (diff)
ENGR00219859 MXC V4L2 capture:Pwr down/on opened cam
Currently, we support 2 cameras, which are relevant to 2 video devices respectively. This patch checks if video device is opened to determine whether we need to power down/on relevant camera when doing suspend/resume. Also, this patch protects capture resources with busy lock semaphore. Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/mxc/capture/mxc_v4l2_capture.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c
index 9e9bcc314ca5..bddfee530274 100644
--- a/drivers/media/video/mxc/capture/mxc_v4l2_capture.c
+++ b/drivers/media/video/mxc/capture/mxc_v4l2_capture.c
@@ -1744,6 +1744,8 @@ static int mxc_v4l_close(struct file *file)
return -EBADF;
}
+ down(&cam->busy_lock);
+
/* for the case somebody hit the ctrl C */
if (cam->overlay_pid == current->pid && cam->overlay_on) {
err = stop_preview(cam);
@@ -1785,6 +1787,8 @@ static int mxc_v4l_close(struct file *file)
cam->enc_counter++;
}
+ up(&cam->busy_lock);
+
return err;
}
@@ -2828,6 +2832,8 @@ static int mxc_v4l2_suspend(struct platform_device *pdev, pm_message_t state)
return -1;
}
+ down(&cam->busy_lock);
+
cam->low_power = true;
if (cam->overlay_on == true)
@@ -2836,9 +2842,11 @@ static int mxc_v4l2_suspend(struct platform_device *pdev, pm_message_t state)
cam->enc_disable(cam);
}
- if (cam->sensor)
+ if (cam->sensor && cam->open_count)
vidioc_int_s_power(cam->sensor, 0);
+ up(&cam->busy_lock);
+
return 0;
}
@@ -2861,10 +2869,12 @@ static int mxc_v4l2_resume(struct platform_device *pdev)
return -1;
}
+ down(&cam->busy_lock);
+
cam->low_power = false;
wake_up_interruptible(&cam->power_queue);
- if (cam->sensor)
+ if (cam->sensor && cam->open_count)
vidioc_int_s_power(cam->sensor, 1);
if (cam->overlay_on == true)
@@ -2872,6 +2882,8 @@ static int mxc_v4l2_resume(struct platform_device *pdev)
if (cam->capture_on == true)
mxc_streamon(cam);
+ up(&cam->busy_lock);
+
return 0;
}