autofocus fixed with header fixes:
authorPaul Kocialkowski <contact@paulk.fr>
Sun, 27 Jan 2013 09:35:30 +0000 (10:35 +0100)
committerPaul Kocialkowski <contact@paulk.fr>
Sun, 27 Jan 2013 09:35:30 +0000 (10:35 +0100)
enum v4l2_af_status {
CAMERA_AF_STATUS_FAIL = 0,
CAMERA_AF_STATUS_IN_PROGRESS,
CAMERA_AF_STATUS_SUCCESS,
CAMERA_AF_STATUS_1ST_SUCCESS,
CAMERA_AF_STATUS_MAX
};

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
exynos_camera.c
exynos_camera.h

index ff8b7eb..d9f0445 100644 (file)
@@ -47,6 +47,13 @@ struct exynos_camera_preset exynos_camera_presets_galaxys2[] = {
                .rotation = 0,
                .hflip = 1,
                .vflip = 0,
+               .params = {
+                       .zoom_supported = 1,
+                       .smooth_zoom_supported = 0,
+                       .zoom_ratios = "100,102,104,109,111,113,119,121,124,131,134,138,146,150,155,159,165,170,182,189,200,213,222,232,243,255,283,300,319,364,400",
+                       .zoom = 0,
+                       .max_zoom = 30,
+               },
        },
        {
                .name = "S5K5BAFX",
@@ -109,34 +116,6 @@ get all the values
 struct exynox_camera_config *exynos_camera_config =
        &exynos_camera_config_galaxys2;
 
-int exynos_camera_params_init(struct exynos_camera *exynos_camera, int id)
-{
-       if (exynos_camera == NULL)
-               return -EINVAL;
-
-       exynos_param_string_set(exynos_camera, "picture-format", "jpeg");
-       exynos_param_string_set(exynos_camera, "picture-format-values", "jpeg");
-
-       exynos_param_string_set(exynos_camera, "picture-size", "2560x1920");
-       exynos_param_string_set(exynos_camera, "picture-size-values",
-               "2560x1920,2048x1536,1600x1200,1280x960,640x480");
-
-       exynos_param_string_set(exynos_camera, "preview-format", "rgb565");
-       exynos_param_string_set(exynos_camera, "preview-format-values", "rgb565");
-       exynos_param_string_set(exynos_camera, "preview-fps-range", "15000,30000");
-       exynos_param_string_set(exynos_camera, "preview-fps-range-values", "(15000,30000)");
-       exynos_param_int_set(exynos_camera, "preview-frame-rate", 15);
-       exynos_param_int_set(exynos_camera, "preview-frame-rate-values", 15);
-       exynos_param_string_set(exynos_camera, "preview-size", "640x480");
-       exynos_param_string_set(exynos_camera, "preview-size-values",
-               "720x480,640x480,352x288,176x144");
-
-       exynos_param_string_set(exynos_camera, "focus-mode", "auto");
-       exynos_param_string_set(exynos_camera, "focus-mode-values", "auto");
-
-       return 0;
-}
-
 int exynos_camera_init(struct exynos_camera *exynos_camera, int id)
 {
        char firmware_version[7] = { 0 };
@@ -235,6 +214,85 @@ void exynos_camera_deinit(struct exynos_camera *exynos_camera)
        }
 }
 
+// Params
+
+int exynos_camera_params_init(struct exynos_camera *exynos_camera, int id)
+{
+       int rc;
+
+       if (exynos_camera == NULL || id >= exynos_camera->config->presets_count)
+               return -EINVAL;
+
+       exynos_param_string_set(exynos_camera, "picture-format", "jpeg");
+       exynos_param_string_set(exynos_camera, "picture-format-values", "jpeg");
+
+       exynos_param_string_set(exynos_camera, "picture-size", "2560x1920");
+       exynos_param_string_set(exynos_camera, "picture-size-values",
+               "2560x1920,2048x1536,1600x1200,1280x960,640x480");
+
+       exynos_param_string_set(exynos_camera, "preview-format", "rgb565");
+       exynos_param_string_set(exynos_camera, "preview-format-values", "rgb565");
+       exynos_param_string_set(exynos_camera, "preview-fps-range", "15000,30000");
+       exynos_param_string_set(exynos_camera, "preview-fps-range-values", "(15000,30000)");
+       exynos_param_int_set(exynos_camera, "preview-frame-rate", 15);
+       exynos_param_int_set(exynos_camera, "preview-frame-rate-values", 15);
+       exynos_param_string_set(exynos_camera, "preview-size", "640x480");
+       exynos_param_string_set(exynos_camera, "preview-size-values",
+               "720x480,640x480,352x288,176x144");
+
+       exynos_param_string_set(exynos_camera, "focus-mode", "auto");
+       exynos_param_string_set(exynos_camera, "focus-mode-values", "auto");
+
+       // Zoom
+       if (exynos_camera->config->presets[id].params.zoom_supported == 1) {
+               exynos_param_string_set(exynos_camera, "zoom-supported", "true");
+
+               if (exynos_camera->config->presets[id].params.smooth_zoom_supported == 1)
+                       exynos_param_string_set(exynos_camera, "smooth-zoom-supported", "true");
+
+               if (exynos_camera->config->presets[id].params.zoom_ratios != NULL)
+                       exynos_param_string_set(exynos_camera, "zoom-ratios", exynos_camera->config->presets[id].params.zoom_ratios);
+
+               exynos_param_int_set(exynos_camera, "zoom", exynos_camera->config->presets[id].params.zoom);
+               exynos_param_int_set(exynos_camera, "max-zoom", exynos_camera->config->presets[id].params.max_zoom);
+
+       } else {
+               exynos_param_string_set(exynos_camera, "zoom-supported", "false");
+       }
+
+       rc = exynos_camera_params_apply(exynos_camera);
+       if (rc < 0) {
+               LOGE("%s: Unable to apply params", __func__);
+               return -1;
+       }
+
+       return 0;
+}
+
+int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
+{
+       char *zoom_supported;
+       int zoom, max_zoom;
+       int rc;
+
+       if (exynos_camera == NULL)
+               return -EINVAL;
+
+       zoom_supported = exynos_param_string_get(exynos_camera, "zoom-supported");
+       if (zoom_supported != NULL && strcmp(zoom_supported, "true") == 0) {
+               zoom = exynos_param_int_get(exynos_camera, "zoom");
+               max_zoom = exynos_param_int_get(exynos_camera, "max-zoom");
+               if (zoom <= max_zoom && zoom >= 0) {
+                       rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_ZOOM, zoom);
+                       if (rc < 0)
+                               LOGE("%s: s ctrl failed!", __func__);
+               }
+
+       }
+
+       return 0;
+}
+
 // Preview
 
 int exynos_camera_preview(struct exynos_camera *exynos_camera)
@@ -579,9 +637,9 @@ void *exynos_camera_auto_focus_thread(void *data)
 
                switch (auto_focus_status) {
                        case CAMERA_AF_STATUS_IN_PROGRESS:
-                       case CAMERA_AF_STATUS_SUCCESS:
                                usleep(500);
                                break;
+                       case CAMERA_AF_STATUS_SUCCESS:
                        case CAMERA_AF_STATUS_1ST_SUCCESS:
                                auto_focus_result = 1;
                                pthread_mutex_unlock(&exynos_camera->auto_focus_mutex);
@@ -1266,6 +1324,12 @@ int exynos_camera_set_parameters(struct camera_device *dev,
                return -1;
        }
 
+       rc = exynos_camera_params_apply(exynos_camera);
+       if (rc < 0) {
+               LOGE("%s: Unable to apply params", __func__);
+               return -1;
+       }
+
        return 0;
 }
 
index 165cbec..d1e5106 100644 (file)
@@ -63,16 +63,27 @@ struct exynos_param {
        enum exynos_param_type type;
 };
 
+struct exynos_camera_params {
+       char *preview_sizes;
+       char *picture_sizes;
+
+       int zoom_supported;
+       int smooth_zoom_supported;
+       char *zoom_ratios;
+       int zoom;
+       int max_zoom;
+};
+
 struct exynos_camera_preset {
        char *name;
        int facing;
        int orientation;
-       char *preview_sizes;
-       char *picture_sizes;
 
        int rotation;
        int hflip;
        int vflip;
+
+       struct exynos_camera_params params;
 };
 
 struct exynos_v4l2_node {