summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2013-07-31 19:25:56 +0200
committerDaniel Hillenbrand <codeworkx@cyanogenmod.org>2013-09-01 18:21:01 +0200
commit9665a9d214c6d26d9cde813bf2612705bbcb3285 (patch)
tree0dc20f499983339c5d35d16acd27cf31657c915a
parent71430eafc33b3b239d4171271e8959bdd63309c3 (diff)
downloaddevice_samsung_galaxys2-common-9665a9d214c6d26d9cde813bf2612705bbcb3285.zip
device_samsung_galaxys2-common-9665a9d214c6d26d9cde813bf2612705bbcb3285.tar.gz
device_samsung_galaxys2-common-9665a9d214c6d26d9cde813bf2612705bbcb3285.tar.bz2
camera: Implement proper touch-focus behavior
Change-Id: I492e45809e4f8601214406ee839cc2f04235c138
-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