White Balance
authorPaul Kocialkowski <contact@paulk.fr>
Sat, 2 Feb 2013 22:33:39 +0000 (23:33 +0100)
committerPaul Kocialkowski <contact@paulk.fr>
Sat, 2 Feb 2013 22:33:39 +0000 (23:33 +0100)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
exynos_camera.c
exynos_camera.h

index 04fef78..d127ffe 100644 (file)
@@ -99,6 +99,9 @@ struct exynos_camera_preset exynos_camera_presets_galaxys2[] = {
                        .exposure_compensation_step = 0.5,
                        .min_exposure_compensation = -4,
                        .max_exposure_compensation = 4,
+
+                       .whitebalance = "auto",
+                       .whitebalance_values = "auto,incandescent,fluorescent,daylight,cloudy-daylight",
                },
        },
        {
@@ -143,12 +146,17 @@ struct exynos_camera_preset exynos_camera_presets_galaxys2[] = {
                        .max_num_focus_areas = 0,
 
                        .zoom_supported = 0,
+
                        .flash_mode = NULL,
+                       .flash_mode_values = NULL,
 
                        .exposure_compensation = 0,
                        .exposure_compensation_step = 0.5,
                        .min_exposure_compensation = -4,
                        .max_exposure_compensation = 4,
+
+                       .whitebalance = NULL,
+                       .whitebalance_values = NULL,
                },
        },
 };
@@ -391,6 +399,12 @@ int exynos_camera_params_init(struct exynos_camera *exynos_camera, int id)
        exynos_param_int_set(exynos_camera, "max-exposure-compensation",
                exynos_camera->config->presets[id].params.max_exposure_compensation);
 
+       // WB
+       exynos_param_string_set(exynos_camera, "whitebalance",
+               exynos_camera->config->presets[id].params.whitebalance);
+       exynos_param_string_set(exynos_camera, "whitebalance-values",
+               exynos_camera->config->presets[id].params.whitebalance_values);
+
        // Camera
        exynos_param_float_set(exynos_camera, "focal-length",
                exynos_camera->config->presets[id].focal_length);
@@ -457,6 +471,9 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
        int min_exposure_compensation;
        int max_exposure_compensation;
 
+       char *whitebalance_string;
+       int whitebalance;
+
        char *metering_string;
        int metering;
 
@@ -753,6 +770,30 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
                        LOGE("%s: s ctrl failed!", __func__);
        }
 
+       // WB
+       whitebalance_string = exynos_param_string_get(exynos_camera, "whitebalance");
+       if (whitebalance_string != NULL) {
+               if (strcmp(whitebalance_string, "auto") == 0)
+                       whitebalance = WHITE_BALANCE_AUTO;
+               else if (strcmp(whitebalance_string, "incandescent") == 0)
+                       whitebalance = WHITE_BALANCE_TUNGSTEN;
+               else if (strcmp(whitebalance_string, "fluorescent") == 0)
+                       whitebalance = WHITE_BALANCE_FLUORESCENT;
+               else if (strcmp(whitebalance_string, "daylight") == 0)
+                       whitebalance = WHITE_BALANCE_SUNNY;
+               else if (strcmp(whitebalance_string, "cloudy-daylight") == 0)
+                       whitebalance = WHITE_BALANCE_CLOUDY;
+               else
+                       whitebalance = WHITE_BALANCE_AUTO;
+
+               if (whitebalance != exynos_camera->whitebalance || force) {
+                       exynos_camera->whitebalance = whitebalance;
+                       rc = exynos_v4l2_s_ctrl(exynos_camera, 0, V4L2_CID_CAMERA_WHITE_BALANCE, whitebalance);
+                       if (rc < 0)
+                               LOGE("%s: s ctrl failed!", __func__);
+               }
+       }
+
        // Metering
        metering_string = exynos_param_string_get(exynos_camera, "metering");
        if (metering_string != NULL) {
index c713561..e4d8ea1 100644 (file)
@@ -113,6 +113,9 @@ struct exynos_camera_params {
        float exposure_compensation_step;
        int min_exposure_compensation;
        int max_exposure_compensation;
+
+       char *whitebalance;
+       char *whitebalance_values;
 };
 
 struct exynos_camera_preset {
@@ -231,6 +234,7 @@ struct exynos_camera {
        int zoom;
        int flash_mode;
        int exposure_compensation;
+       int whitebalance;
        int metering;
 };