summaryrefslogtreecommitdiffstats
path: root/libcamera
diff options
context:
space:
mode:
authorPawit Pornkitprasan <p.pawit@gmail.com>2011-12-22 19:15:09 +0700
committerPawit Pornkitprasan <p.pawit@gmail.com>2011-12-23 19:34:39 +0700
commitda0068d8e9e2120069e306ec71a1544e5bff45e1 (patch)
tree2d4e14ac0ed8e2db71caaa21b542e8574b3cdef3 /libcamera
parent7ae31a772739c5b073a02abac904da182f4fe4ea (diff)
downloaddevice_samsung_aries-common-da0068d8e9e2120069e306ec71a1544e5bff45e1.zip
device_samsung_aries-common-da0068d8e9e2120069e306ec71a1544e5bff45e1.tar.gz
device_samsung_aries-common-da0068d8e9e2120069e306ec71a1544e5bff45e1.tar.bz2
libcamera: Implement user-space AF polling for CE147
Required for linux 3.0
Diffstat (limited to 'libcamera')
-rwxr-xr-xlibcamera/SecCamera.cpp23
-rw-r--r--libcamera/SecCamera.h6
2 files changed, 26 insertions, 3 deletions
diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp
index e53fbc2..3fd7081 100755
--- a/libcamera/SecCamera.cpp
+++ b/libcamera/SecCamera.cpp
@@ -1680,12 +1680,29 @@ 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);
+ 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_FINISH_AUTO_FOCUS", __func__);
+ return -1;
+ }
return af_result;
}
diff --git a/libcamera/SecCamera.h b/libcamera/SecCamera.h
index 8b9548d..6df8bcd 100644
--- a/libcamera/SecCamera.h
+++ b/libcamera/SecCamera.h
@@ -148,6 +148,12 @@ namespace android {
#define BPP 2
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX_BUFFERS 4
+
+#define FIRST_AF_SEARCH_COUNT 600
+#define AF_PROGRESS 0x05
+#define AF_SUCCESS 0x02
+#define AF_DELAY 10000
+
/*
* V 4 L 2 F I M C E X T E N S I O N S
*