Hey Samsung, perhaps you should enable crop in capture so that we can avoid both...
authorPaul Kocialkowski <contact@paulk.fr>
Fri, 1 Feb 2013 18:48:16 +0000 (19:48 +0100)
committerPaul Kocialkowski <contact@paulk.fr>
Fri, 1 Feb 2013 18:48:16 +0000 (19:48 +0100)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
exynos_camera.c
exynos_camera.h

index 39282c5..cbf401c 100644 (file)
@@ -70,6 +70,10 @@ struct exynos_camera_preset exynos_camera_presets_galaxys2[] = {
                        .jpeg_thumbnail_quality = 100,
                        .jpeg_quality = 90,
 
+                       .recording_preview_size = NULL,
+                       .recording_size = "720x480",
+                       .recording_format = "yuv420sp",
+
                        .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",
@@ -106,6 +110,10 @@ struct exynos_camera_preset exynos_camera_presets_galaxys2[] = {
                        .jpeg_thumbnail_quality = 100,
                        .jpeg_quality = 90,
 
+                       .recording_preview_size = NULL,
+                       .recording_size = "640x480",
+                       .recording_format = "yuv420sp",
+
                        .zoom_supported = 0,
                },
        },
@@ -252,6 +260,10 @@ int exynos_camera_params_init(struct exynos_camera *exynos_camera, int id)
        exynos_camera->camera_picture_format = exynos_camera->config->presets[id].picture_format;
        exynos_camera->camera_focal_length = exynos_camera->config->presets[id].focal_length;
 
+       // Recording preview
+       exynos_param_string_set(exynos_camera, "preferred-preview-size-for-video",
+               exynos_camera->config->presets[id].params.recording_preview_size);
+
        // Preview
        exynos_param_string_set(exynos_camera, "preview-size-values",
                exynos_camera->config->presets[id].params.preview_size_values);
@@ -290,6 +302,12 @@ int exynos_camera_params_init(struct exynos_camera *exynos_camera, int id)
        exynos_param_int_set(exynos_camera, "jpeg-quality",
                exynos_camera->config->presets[id].params.jpeg_quality);
 
+       // Recording
+       exynos_param_string_set(exynos_camera, "video-size",
+               exynos_camera->config->presets[id].params.recording_size);
+       exynos_param_string_set(exynos_camera, "video-frame-format",
+               exynos_camera->config->presets[id].params.recording_format);
+
        // Zoom
        if (exynos_camera->config->presets[id].params.zoom_supported == 1) {
                exynos_param_string_set(exynos_camera, "zoom-supported", "true");
@@ -322,6 +340,9 @@ int exynos_camera_params_init(struct exynos_camera *exynos_camera, int id)
 
 int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
 {
+       char *recording_hint_string;
+       char *recording_preview_size_string;
+
        char *preview_size_string;
        int preview_width = 0;
        int preview_height = 0;
@@ -341,6 +362,10 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
        int jpeg_thumbnail_quality;
        int jpeg_quality;
 
+       char *video_size_string;
+       int recording_width = 0;
+       int recording_height = 0;
+
        char *metering_string;
        int metering;
 
@@ -359,8 +384,18 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
         * original state when preview restarts.
         */
 
+       // Recording hint
+       recording_hint_string = exynos_param_string_get(exynos_camera, "recording-hint");
+
        // Preview
-       preview_size_string = exynos_param_string_get(exynos_camera, "preview-size");
+       if (recording_hint_string != NULL && strcmp(recording_hint_string, "true") == 0)
+               preview_size_string = exynos_param_string_get(exynos_camera, "preferred-preview-size-for-video");
+       else
+               preview_size_string = NULL;
+
+       if (preview_size_string == NULL)
+               preview_size_string = exynos_param_string_get(exynos_camera, "preview-size");
+
        if (preview_size_string != NULL) {
                sscanf(preview_size_string, "%dx%d", &preview_width, &preview_height);
 
@@ -449,6 +484,20 @@ int exynos_camera_params_apply(struct exynos_camera *exynos_camera)
                        LOGE("%s: s ctrl failed!", __func__);
        }
 
+       // Recording
+       video_size_string = exynos_param_string_get(exynos_camera, "video-size");
+       if (video_size_string == NULL)
+               video_size_string = exynos_param_string_get(exynos_camera, "preview-size");
+
+       if (video_size_string != NULL) {
+               sscanf(video_size_string, "%dx%d", &recording_width, &recording_height);
+
+               if (recording_width != 0 && recording_width != exynos_camera->recording_width)
+                       exynos_camera->recording_width = recording_width;
+               if (recording_height != 0 && recording_height != exynos_camera->recording_height)
+                       exynos_camera->recording_height = recording_height;
+       }
+
        // Zoom
        zoom_supported_string = exynos_param_string_get(exynos_camera, "zoom-supported");
        if (zoom_supported_string != NULL && strcmp(zoom_supported_string, "true") == 0) {
@@ -576,7 +625,6 @@ int exynos_camera_picture(struct exynos_camera *exynos_camera)
                return -1;
        } else if (rc == 0) {
                LOGE("%s: poll timeout!", __func__);
-               // TODO: it's probably a good idea to restart everything
                return -1;
        }
 
@@ -1290,7 +1338,8 @@ int exynos_camera_preview(struct exynos_camera *exynos_camera)
        int rc;
        int i;
 
-       if (exynos_camera == NULL || exynos_camera->preview_memory == NULL)
+       if (exynos_camera == NULL || exynos_camera->preview_memory == NULL ||
+               exynos_camera->preview_window == NULL)
                return -EINVAL;
 
        // V4L2
@@ -1301,7 +1350,6 @@ int exynos_camera_preview(struct exynos_camera *exynos_camera)
                return -1;
        } else if (rc == 0) {
                LOGE("%s: poll timeout!", __func__);
-               // TODO: it's probably a good idea to restart everything
                return -1;
        }
 
@@ -1375,7 +1423,6 @@ void *exynos_camera_preview_thread(void *data)
                rc = exynos_camera_preview(exynos_camera);
                if (rc < 0) {
                        LOGE("%s: preview failed!", __func__);
-                       // TODO FIXME WTF REMOVE THAT ASAP
                        exynos_camera->preview_enabled = 0;
                }
 
@@ -1436,7 +1483,12 @@ int exynos_camera_preview_start(struct exynos_camera *exynos_camera)
                return -1;
        }
 
-       rc = exynos_v4l2_reqbufs_cap(exynos_camera, 0, EXYNOS_CAMERA_MAX_BUFFERS_COUNT);
+       for (i=EXYNOS_CAMERA_MAX_BUFFERS_COUNT ; i >= EXYNOS_CAMERA_MIN_BUFFERS_COUNT ; i--) {
+               rc = exynos_v4l2_reqbufs_cap(exynos_camera, 0, i);
+               if (rc >= 0)
+                       break;
+       }
+
        if (rc < 0) {
                LOGE("%s: reqbufs failed!", __func__);
                return -1;
@@ -1586,6 +1638,8 @@ void exynos_camera_preview_stop(struct exynos_camera *exynos_camera)
                exynos_camera->preview_memory = NULL;
        }
 
+       exynos_camera->preview_window = NULL;
+
        pthread_mutex_unlock(&exynos_camera->preview_mutex);
 }
 
index 07b4278..f45bdbe 100644 (file)
@@ -33,6 +33,7 @@
 
 #define EXYNOS_CAMERA_MAX_PRESETS_COUNT                2
 #define EXYNOS_CAMERA_MAX_V4L2_NODES_COUNT     4
+#define EXYNOS_CAMERA_MIN_BUFFERS_COUNT                3
 #define EXYNOS_CAMERA_MAX_BUFFERS_COUNT                8
 
 #define EXYNOS_CAMERA_MSG_ENABLED(msg) \
@@ -89,6 +90,10 @@ struct exynos_camera_params {
        int jpeg_thumbnail_quality;
        int jpeg_quality;
 
+       char *recording_preview_size;
+       char *recording_size;
+       char *recording_format;
+
        int zoom_supported;
        int smooth_zoom_supported;
        char *zoom_ratios;
@@ -191,6 +196,8 @@ struct exynos_camera {
        int jpeg_thumbnail_height;
        int jpeg_thumbnail_quality;
        int jpeg_quality;
+       int recording_width;
+       int recording_height;
        int zoom;
        int metering;
        int focus_object_x;