summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-10-19 16:09:14 +0200
committerPaul Kocialkowski <contact@paulk.fr>2013-10-19 16:09:14 +0200
commit9484947c8935053188b4a0251b3df3fdf87f593f (patch)
tree1446c51b8165d4b3c5c13180cbf31bc735df2210
parenteebdd72a2a498f21902845ef7825a9efe42e93cf (diff)
downloaddevice_samsung_i9300-9484947c8935053188b4a0251b3df3fdf87f593f.zip
device_samsung_i9300-9484947c8935053188b4a0251b3df3fdf87f593f.tar.gz
device_samsung_i9300-9484947c8935053188b4a0251b3df3fdf87f593f.tar.bz2
camera: Wait some time for focus to happen when unfocused before picture
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--camera/exynos_camera.c29
-rw-r--r--camera/exynos_camera.h1
2 files changed, 26 insertions, 4 deletions
diff --git a/camera/exynos_camera.c b/camera/exynos_camera.c
index 5e20ab3..781271c 100644
--- a/camera/exynos_camera.c
+++ b/camera/exynos_camera.c
@@ -2575,6 +2575,7 @@ int exynos_camera_picture_callback(struct exynos_camera *exynos_camera,
struct exynos_camera_buffer *yuv_thumbnail_buffer = NULL;
int width, height;
int thumbnail_width, thumbnail_height;
+ time_t timestamp;
int rc;
int i;
@@ -2602,12 +2603,32 @@ int exynos_camera_picture_callback(struct exynos_camera *exynos_camera,
pthread_mutex_lock(&exynos_camera->picture_mutex);
if (!exynos_camera->picture_enabled && !exynos_camera->camera_fimc_is) {
- if (exynos_camera->camera_capture_format == V4L2_PIX_FMT_INTERLEAVED && exynos_camera->zoom == 0 && exynos_camera->focus_mode == FOCUS_MODE_CONTINOUS_PICTURE && exynos_camera->capture_auto_focus_result == CAMERA_AF_STATUS_IN_PROGRESS) {
- LOGD("%s: Not asking for picture until auto focus is done", __func__);
- pthread_mutex_unlock(&exynos_camera->picture_mutex);
- return 0;
+ if (exynos_camera->camera_capture_format == V4L2_PIX_FMT_INTERLEAVED && exynos_camera->zoom == 0 && exynos_camera->focus_mode == FOCUS_MODE_CONTINOUS_PICTURE) {
+ if (exynos_camera->capture_auto_focus_result == CAMERA_AF_STATUS_FAIL) {
+ // We don't want to take a picture out of focus, so wait a bit
+ timestamp = time(NULL);
+
+ if (exynos_camera->picture_focus_timestamp > 0) {
+ if ((timestamp - exynos_camera->picture_focus_timestamp) > 2) {
+ LOGE("%s: Picture will be taken out of focus", __func__);
+ } else {
+ pthread_mutex_unlock(&exynos_camera->picture_mutex);
+ return 0;
+ }
+ } else {
+ exynos_camera->picture_focus_timestamp = timestamp;
+ pthread_mutex_unlock(&exynos_camera->picture_mutex);
+ return 0;
+ }
+ } else if (exynos_camera->capture_auto_focus_result == CAMERA_AF_STATUS_IN_PROGRESS) {
+ LOGD("%s: Not asking for picture until auto focus is done", __func__);
+ pthread_mutex_unlock(&exynos_camera->picture_mutex);
+ return 0;
+ }
}
+ exynos_camera->picture_focus_timestamp = 0;
+
rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_CAPTURE, 0);
if (rc < 0) {
LOGE("%s: Unable to set capture", __func__);
diff --git a/camera/exynos_camera.h b/camera/exynos_camera.h
index 6891833..90a8fe7 100644
--- a/camera/exynos_camera.h
+++ b/camera/exynos_camera.h
@@ -355,6 +355,7 @@ struct exynos_camera {
struct exynos_camera_buffer picture_jpeg_thumbnail_buffer;
struct exynos_camera_buffer picture_yuv_buffer;
struct exynos_camera_buffer picture_yuv_thumbnail_buffer;
+ time_t picture_focus_timestamp;
// Recording