From ae4340f17f6a9e7b8863600b6074a6b13c3996cf Mon Sep 17 00:00:00 2001 From: Pawit Pornkitprasan Date: Fri, 2 Aug 2013 16:39:59 +0700 Subject: libcamera: touch-to-focus fixes - Do not send command to camera unless preview is started (fix 4.3 AOSP camera crash) - Send touch AF command regardless of previous state (required to actually trigger touch AF at the new area) Change-Id: I51a8f80ce1ec38f1052e4660f708be8649478a88 --- libcamera/SecCamera.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libcamera/SecCamera.cpp b/libcamera/SecCamera.cpp index 598f732..dc7cfa1 100755 --- a/libcamera/SecCamera.cpp +++ b/libcamera/SecCamera.cpp @@ -2357,7 +2357,8 @@ int SecCamera::setTouchAFStartStop(int start_stop) { ALOGV("%s(touch_af_start_stop (%d))", __func__, start_stop); - if (m_touch_af_start_stop != start_stop) { + if (m_flag_camera_start) { + // We need to send this command regardless of previous state to trigger AF m_touch_af_start_stop = start_stop; if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_TOUCH_AF_START_STOP, start_stop) < 0) { ALOGE("ERR(%s):Fail on V4L2_CID_CAMERA_TOUCH_AF_START_STOP", __func__); @@ -2659,14 +2660,16 @@ int SecCamera::setObjectPosition(int x, int y) { ALOGV("%s(setObjectPosition(x=%d, y=%d))", __func__, x, y); - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0) { - ALOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __func__); - return -1; - } + if (m_flag_camera_start) { + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_X, x) < 0) { + ALOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_X", __func__); + return -1; + } - if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_Y, y) < 0) { - ALOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_Y", __func__); - return -1; + if (fimc_v4l2_s_ctrl(m_cam_fd, V4L2_CID_CAMERA_OBJECT_POSITION_Y, y) < 0) { + ALOGE("ERR(%s):Fail on V4L2_CID_CAMERA_OBJECT_POSITION_Y", __func__); + return -1; + } } return 0; -- cgit v1.1