summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-07-01 18:40:54 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-07-01 18:40:54 +0200
commit6ae9fdf827e93f1843c846f7daa5e23831d6fc19 (patch)
tree4152c1fe97496c8bf4deca2a608b27495594db8c
parent0e028ac00134ad05bfca03d277dc3b3fee325e87 (diff)
downloaddevice_samsung_smdk4412-common-6ae9fdf827e93f1843c846f7daa5e23831d6fc19.zip
device_samsung_smdk4412-common-6ae9fdf827e93f1843c846f7daa5e23831d6fc19.tar.gz
device_samsung_smdk4412-common-6ae9fdf827e93f1843c846f7daa5e23831d6fc19.tar.bz2
camera: Handle preview size or format change
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--camera/smdk4x12_camera.c53
-rw-r--r--camera/smdk4x12_camera.h1
-rw-r--r--camera/smdk4x12_utils.c16
3 files changed, 53 insertions, 17 deletions
diff --git a/camera/smdk4x12_camera.c b/camera/smdk4x12_camera.c
index 19aacdf..8cb5cea 100644
--- a/camera/smdk4x12_camera.c
+++ b/camera/smdk4x12_camera.c
@@ -2278,6 +2278,12 @@ int smdk4x12_camera_preview_callback(struct smdk4x12_camera *smdk4x12_camera,
return 0;
}
+ if (smdk4x12_camera->preview_listener->width != smdk4x12_camera->preview_width || smdk4x12_camera->preview_listener->height != smdk4x12_camera->preview_height || smdk4x12_camera->preview_listener->format != smdk4x12_camera->preview_format) {
+ ALOGD("%s: Waiting for preview listener update", __func__);
+ pthread_mutex_unlock(&smdk4x12_camera->preview_lock_mutex);
+ return 0;
+ }
+
smdk4x12_camera->preview_listener->busy = 1;
width = smdk4x12_camera->preview_width;
@@ -2450,6 +2456,8 @@ complete:
void *smdk4x12_camera_preview_thread(void *data)
{
struct smdk4x12_camera *smdk4x12_camera;
+ struct smdk4x12_camera_capture_listener *listener;
+ int gralloc_format;
int rc;
if (data == NULL)
@@ -2479,6 +2487,33 @@ void *smdk4x12_camera_preview_thread(void *data)
}
}
+ if (smdk4x12_camera->preview_listener->width != smdk4x12_camera->preview_width || smdk4x12_camera->preview_listener->height != smdk4x12_camera->preview_height || smdk4x12_camera->preview_listener->format != smdk4x12_camera->preview_format) {
+ if (smdk4x12_camera->preview_output_enabled)
+ smdk4x12_camera_preview_output_stop(smdk4x12_camera);
+
+ smdk4x12_camera_capture_listener_unregister(smdk4x12_camera, smdk4x12_camera->preview_listener);
+
+ smdk4x12_camera->preview_listener = NULL;
+
+ listener = smdk4x12_camera_capture_listener_register(smdk4x12_camera, smdk4x12_camera->preview_width, smdk4x12_camera->preview_height, smdk4x12_camera->preview_format, smdk4x12_camera_preview_callback);
+ if (listener == NULL) {
+ ALOGE("%s: Unable to register preview capture listener", __func__);
+ pthread_mutex_unlock(&smdk4x12_camera->preview_mutex);
+ break;
+ }
+
+ smdk4x12_camera->preview_listener = listener;
+
+ gralloc_format = smdk4x12_gralloc_format(smdk4x12_camera->preview_format);
+
+ rc = smdk4x12_camera->preview_window->set_buffers_geometry(smdk4x12_camera->preview_window, smdk4x12_camera->preview_width, smdk4x12_camera->preview_height, gralloc_format);
+ if (rc) {
+ ALOGE("%s: Unable to set buffers geometry", __func__);
+ pthread_mutex_unlock(&smdk4x12_camera->preview_mutex);
+ break;
+ }
+ }
+
pthread_mutex_unlock(&smdk4x12_camera->preview_mutex);
}
@@ -3933,23 +3968,7 @@ int smdk4x12_camera_set_preview_window(struct camera_device *device,
height = smdk4x12_camera->preview_height;
format = smdk4x12_camera->preview_format;
- switch (format) {
- case V4L2_PIX_FMT_NV21:
- gralloc_format = HAL_PIXEL_FORMAT_YCrCb_420_SP;
- break;
- case V4L2_PIX_FMT_YUV420:
- gralloc_format = HAL_PIXEL_FORMAT_YV12;
- break;
- case V4L2_PIX_FMT_RGB565:
- gralloc_format = HAL_PIXEL_FORMAT_RGB_565;
- break;
- case V4L2_PIX_FMT_RGB32:
- gralloc_format = HAL_PIXEL_FORMAT_RGBX_8888;
- break;
- default:
- gralloc_format = HAL_PIXEL_FORMAT_YCrCb_420_SP;
- break;
- }
+ gralloc_format = smdk4x12_gralloc_format(format);
rc = w->set_buffers_geometry(w, width, height, gralloc_format);
if (rc) {
diff --git a/camera/smdk4x12_camera.h b/camera/smdk4x12_camera.h
index b264f39..d1a3924 100644
--- a/camera/smdk4x12_camera.h
+++ b/camera/smdk4x12_camera.h
@@ -574,6 +574,7 @@ void list_head_remove(struct list_head *list);
int smdk4x12_camera_buffer_length(int width, int height, int format);
void smdk4x12_camera_yuv_planes(int width, int height, int format, int address, int *address_y, int *address_cb, int *address_cr);
+int smdk4x12_gralloc_format(int format);
/*
* V4L2
diff --git a/camera/smdk4x12_utils.c b/camera/smdk4x12_utils.c
index 7f8fc40..90d2167 100644
--- a/camera/smdk4x12_utils.c
+++ b/camera/smdk4x12_utils.c
@@ -156,3 +156,19 @@ void smdk4x12_camera_yuv_planes(int width, int height, int format, int address,
break;
}
}
+
+int smdk4x12_gralloc_format(int format)
+{
+ switch (format) {
+ case V4L2_PIX_FMT_NV21:
+ return HAL_PIXEL_FORMAT_YCrCb_420_SP;
+ case V4L2_PIX_FMT_YUV420:
+ return HAL_PIXEL_FORMAT_YV12;
+ case V4L2_PIX_FMT_RGB565:
+ return HAL_PIXEL_FORMAT_RGB_565;
+ case V4L2_PIX_FMT_RGB32:
+ return HAL_PIXEL_FORMAT_RGBX_8888;
+ default:
+ return HAL_PIXEL_FORMAT_YCrCb_420_SP;
+ }
+}