From aae09e24c5ac5dbba702cc6ae65e25a83d49a3cb Mon Sep 17 00:00:00 2001 From: Simon Wilson Date: Mon, 14 Nov 2011 16:44:23 -0800 Subject: new prebuilt kernel d789370 S5PC11X: CAMERA: Remove AF polling code Change-Id: I0b4555b17fb24aaf197b25b27ba88c2c97b8cb6f --- bcm4329.ko | Bin 276884 -> 276884 bytes kernel | Bin 3349560 -> 3349208 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bcm4329.ko b/bcm4329.ko index 8303930..b529858 100644 Binary files a/bcm4329.ko and b/bcm4329.ko differ diff --git a/kernel b/kernel index b3dff74..639af92 100644 Binary files a/kernel and b/kernel differ -- cgit v1.1 From 3b869ce2ba1cc91c0acdcc8355a8499fc443e8a3 Mon Sep 17 00:00:00 2001 From: "kyoungho.yun" Date: Thu, 10 Nov 2011 19:58:37 +0900 Subject: Camera: move AF polling code from driver into HAL Preview is paused during auto focus. To fix this, move polling code from driver to HAL. Change-Id: Id46d9ccd2aad1a269806f4fddf8ad39c3c87bae9 Signed-off-by: kyoungho.yun --- include/videodev2_samsung.h | 5 ++++- libcamera/SecCamera.cpp | 35 ++++++++++++++++++++++++++++++++--- libcamera/SecCamera.h | 7 +++++++ 3 files changed, 43 insertions(+), 4 deletions(-) mode change 100644 => 100755 libcamera/SecCamera.h diff --git a/include/videodev2_samsung.h b/include/videodev2_samsung.h index 0a7d7c3..0d4dcc9 100755 --- a/include/videodev2_samsung.h +++ b/include/videodev2_samsung.h @@ -431,7 +431,10 @@ enum v4l2_caf_start_stop { CAF_MAX, }; -#define V4L2_CID_CAMERA_AUTO_FOCUS_RESULT (V4L2_CID_PRIVATE_BASE + 103) +#define V4L2_CID_CAMERA_AUTO_FOCUS_RESULT_FIRST (V4L2_CID_PRIVATE_BASE + 103) +#define V4L2_CID_CAMERA_AUTO_FOCUS_RESULT_SECOND (V4L2_CID_PRIVATE_BASE + 120) +#define V4L2_CID_CAMERA_FINISH_AUTO_FOCUS (V4L2_CID_PRIVATE_BASE + 121) + #define V4L2_CID_CAMERA_FRAME_RATE (V4L2_CID_PRIVATE_BASE + 104) enum v4l2_frame_rate { FRAME_RATE_AUTO = 0, diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp index 48cf02e..444001c 100755 --- a/libcamera/SecCamera.cpp +++ b/libcamera/SecCamera.cpp @@ -1557,12 +1557,41 @@ int SecCamera::setAutofocus(void) int SecCamera::getAutoFocusResult(void) { - int af_result; + int af_result, count, ret; - af_result = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT); + for (count = 0; count < FIRST_AF_SEARCH_COUNT; count++) { + ret = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT_FIRST); + if (ret != AF_PROGRESS) + break; + usleep(AF_DELAY); + } + if ((count >= FIRST_AF_SEARCH_COUNT) || (ret != AF_SUCCESS)) { + LOGV("%s : 1st AF timed out, failed, or was canceled", __func__); + af_result = 0; + goto finish_auto_focus; + } - LOGV("%s : returning %d", __func__, af_result); + for (count = 0; count < SECOND_AF_SEARCH_COUNT; count++) { + ret = fimc_v4l2_g_ctrl(m_cam_fd, V4L2_CID_CAMERA_AUTO_FOCUS_RESULT_SECOND); + /* low byte is garbage. done when high byte is 0x0 */ + if (!(ret & 0xff00)) + break; + usleep(AF_DELAY); + } + if (count >= SECOND_AF_SEARCH_COUNT) { + LOGV("%s : 2nd AF timed out, failed, or was canceled", __func__); + af_result = 0; + goto finish_auto_focus; + } + + af_result = 1; + LOGV("%s : AF was successful, returning %d", __func__, af_result); +finish_auto_focus: + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_FINISH_AUTO_FOCUS, 0) < 0) { + LOGE("ERR(%s):Fail on V4L2_CID_CAMERA_SET_PRE_FLASH", __func__); + return -1; + } return af_result; } diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h old mode 100644 new mode 100755 index 551eb03..5c62782 --- a/libcamera/SecCamera.h +++ b/libcamera/SecCamera.h @@ -146,6 +146,13 @@ namespace android { #define BPP 2 #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #define MAX_BUFFERS 9 // 11 + +#define FIRST_AF_SEARCH_COUNT 80 +#define SECOND_AF_SEARCH_COUNT 80 +#define AF_PROGRESS 0x01 +#define AF_SUCCESS 0x02 +#define AF_DELAY 50000 + /* * V 4 L 2 F I M C E X T E N S I O N S * -- cgit v1.1