summaryrefslogtreecommitdiffstats
path: root/camera/exynos_camera.c
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-07-31 19:25:56 +0200
committerathurh <athurh@gmail.com>2013-08-30 23:17:10 +0200
commit4831909c8fe136f5d1b56834e7b6a24d85487d65 (patch)
treedea371bb9df48363961d2f7daeb667356ef7c1a5 /camera/exynos_camera.c
parent1dbbb4c02044c62fad1c0f560e0a06ce8bbf657d (diff)
downloaddevice_samsung_galaxys2-common-4831909c8fe136f5d1b56834e7b6a24d85487d65.zip
device_samsung_galaxys2-common-4831909c8fe136f5d1b56834e7b6a24d85487d65.tar.gz
device_samsung_galaxys2-common-4831909c8fe136f5d1b56834e7b6a24d85487d65.tar.bz2
camera: Implement proper touch-focus behavior
Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Conflicts: camera/exynos_camera.c Change-Id: I46823c0b2a1668f03d952f35fe55ced9c31a2822
Diffstat (limited to 'camera/exynos_camera.c')
-rw-r--r--camera/exynos_camera.c96
1 files changed, 55 insertions, 41 deletions
diff --git a/camera/exynos_camera.c b/camera/exynos_camera.c
index 47d118d..ea82253 100644
--- a/camera/exynos_camera.c
+++ b/camera/exynos_camera.c
@@ -494,7 +494,7 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
int camera_sensor_output_size;
char *focus_mode_string;
- int focus_mode;
+ int focus_mode = 0;
char *focus_areas_string;
int focus_left, focus_top, focus_right, focus_bottom, focus_weigth;
int focus_x;
@@ -522,7 +522,7 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
char *iso_string;
int iso;
- int force ;
+ int force = 0;
int w, h;
char *k;
@@ -535,8 +535,6 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
ALOGE("%s: Setting preview params", __func__);
exynos_camera->preview_params_set = 1;
force = 1;
- } else {
- force = 0;
}
// Preview
@@ -707,60 +705,76 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
}
// Focus
- focus_mode_string = exynos_param_string_get(exynos_camera, "focus-mode");
- if (focus_mode_string != NULL) {
- if (strcmp(focus_mode_string, "auto") == 0)
- focus_mode = FOCUS_MODE_AUTO;
- else if (strcmp(focus_mode_string, "infinity") == 0)
- focus_mode = FOCUS_MODE_INFINITY;
- else if (strcmp(focus_mode_string, "macro") == 0)
- focus_mode = FOCUS_MODE_MACRO;
- else if (strcmp(focus_mode_string, "fixed") == 0)
- focus_mode = FOCUS_MODE_FIXED;
- else if (strcmp(focus_mode_string, "facedetect") == 0)
- focus_mode = FOCUS_MODE_FACEDETECT;
- else if (strcmp(focus_mode_string, "continuous-video") == 0)
- focus_mode = FOCUS_MODE_CONTINOUS;
- else if (strcmp(focus_mode_string, "continuous-picture") == 0)
- focus_mode = FOCUS_MODE_CONTINOUS;
- else
- focus_mode = FOCUS_MODE_AUTO;
-
- if (focus_mode != exynos_camera->focus_mode || force) {
- exynos_camera->focus_mode = focus_mode;
- rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_FOCUS_MODE, focus_mode);
- if (rc < 0)
- ALOGE("%s: s ctrl failed!", __func__);
- }
- }
-
focus_areas_string = exynos_param_string_get(exynos_camera, "focus-areas");
if (focus_areas_string != NULL) {
focus_left = focus_top = focus_right = focus_bottom = focus_weigth = 0;
rc = sscanf(focus_areas_string, "(%d,%d,%d,%d,%d)",
&focus_left, &focus_top, &focus_right, &focus_bottom, &focus_weigth);
- if (rc != 5)
+ if (rc != 5) {
ALOGE("%s: sscanf failed!", __func__);
+ } else if (focus_left != 0 && focus_top != 0 && focus_right != 0 && focus_bottom != 0) {
+ focus_x = (((focus_left + focus_right) / 2) + 1000) * preview_width / 2000;
+ focus_y = (((focus_top + focus_bottom) / 2) + 1000) * preview_height / 2000;
- focus_x = (((focus_left + focus_right) / 2) + 1000) * preview_width / 2000;
- focus_y = (((focus_top + focus_bottom) / 2) + 1000) * preview_height / 2000;
+ if (focus_x != exynos_camera->focus_x || force) {
+ exynos_camera->focus_x = focus_x;
- if (focus_x != exynos_camera->focus_x || force) {
- exynos_camera->focus_x = focus_x;
+ rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_OBJECT_POSITION_X, focus_x);
+ if (rc < 0)
+ ALOGE("%s: s ctrl failed!", __func__);
+ }
+
+ if (focus_y != exynos_camera->focus_y || force) {
+ exynos_camera->focus_y = focus_y;
- rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_OBJECT_POSITION_X, focus_x);
+ rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_OBJECT_POSITION_Y, focus_y);
+ if (rc < 0)
+ ALOGE("%s: s ctrl failed!", __func__);
+ }
+
+ focus_mode = FOCUS_MODE_TOUCH;
+ }
+ }
+
+ focus_mode_string = exynos_param_string_get(exynos_camera, "focus-mode");
+ if (focus_mode_string != NULL) {
+ if (focus_mode == 0) {
+ if (strcmp(focus_mode_string, "auto") == 0)
+ focus_mode = FOCUS_MODE_AUTO;
+ else if (strcmp(focus_mode_string, "infinity") == 0)
+ focus_mode = FOCUS_MODE_INFINITY;
+ else if (strcmp(focus_mode_string, "macro") == 0)
+ focus_mode = FOCUS_MODE_MACRO;
+ else if (strcmp(focus_mode_string, "fixed") == 0)
+ focus_mode = FOCUS_MODE_FIXED;
+ else if (strcmp(focus_mode_string, "facedetect") == 0)
+ focus_mode = FOCUS_MODE_FACEDETECT;
+ else if (strcmp(focus_mode_string, "continuous-video") == 0)
+ focus_mode = FOCUS_MODE_CONTINOUS;
+ else if (strcmp(focus_mode_string, "continuous-picture") == 0)
+ focus_mode = FOCUS_MODE_CONTINOUS;
+ else
+ focus_mode = FOCUS_MODE_AUTO;
+ }
+
+ if (focus_mode != exynos_camera->focus_mode || force) {
+ rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_FOCUS_MODE, focus_mode);
if (rc < 0)
ALOGE("%s: s ctrl failed!", __func__);
}
- if (focus_y != exynos_camera->focus_y || force) {
- exynos_camera->focus_y = focus_y;
-
- rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_OBJECT_POSITION_Y, focus_y);
+ if (focus_mode == FOCUS_MODE_TOUCH) {
+ rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, 1);
+ if (rc < 0)
+ ALOGE("%s: s ctrl failed!", __func__);
+ } else if (exynos_camera->focus_mode == FOCUS_MODE_TOUCH) {
+ rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, 0);
if (rc < 0)
ALOGE("%s: s ctrl failed!", __func__);
}
+
+ exynos_camera->focus_mode = focus_mode;
}
// Zoom