summaryrefslogtreecommitdiffstats
path: root/camera/OMXCameraAdapter
diff options
context:
space:
mode:
authorTyler Luu <tluu@ti.com>2012-01-31 13:36:22 -0600
committerIliyan Malchev <malchev@google.com>2012-02-01 14:47:16 -0800
commit057f4fd59ec05ded909e9eb9a3363d9ea345b0ca (patch)
tree8687455a958ce799dfb7237f11d70a3c12b28038 /camera/OMXCameraAdapter
parenta6e104aadf560de4e33291c8e85f79acc8fb46c9 (diff)
downloadhardware_ti_omap4xxx-057f4fd59ec05ded909e9eb9a3363d9ea345b0ca.zip
hardware_ti_omap4xxx-057f4fd59ec05ded909e9eb9a3363d9ea345b0ca.tar.gz
hardware_ti_omap4xxx-057f4fd59ec05ded909e9eb9a3363d9ea345b0ca.tar.bz2
CameraHal: Implementation for CAF status callbacks
1. Remove internal handling of CAMERA_MSG_FOCUS. Before we were enabling CAMERA_MSG_FOCUS only when application calls autoFocus(). No longer needed since the CAMERA_MSG_FOCUS can come just during preview now. 2. Add handling of unregistered focus callbacks. Since OMXCamera will send callbacks even when we are not waiting for one, add some handling. Signed-off-by: Tyler Luu <tluu@ti.com> Change-Id: I457e67b33b2561dd0b1ce3863ce807a8c27f79f6 Conflicts: camera/OMXCameraAdapter/OMXFocus.cpp
Diffstat (limited to 'camera/OMXCameraAdapter')
-rwxr-xr-xcamera/OMXCameraAdapter/OMXCameraAdapter.cpp20
-rw-r--r--camera/OMXCameraAdapter/OMXFocus.cpp77
2 files changed, 76 insertions, 21 deletions
diff --git a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
index e6c733d..3d07d5e 100755
--- a/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
+++ b/camera/OMXCameraAdapter/OMXCameraAdapter.cpp
@@ -2694,6 +2694,7 @@ OMX_ERRORTYPE OMXCameraAdapter::SignalEvent(OMX_IN OMX_HANDLETYPE hComponent,
{
Mutex::Autolock lock(mEventLock);
TIUTILS::Message *msg;
+ bool eventSignalled = false;
LOG_FUNCTION_NAME;
@@ -2717,6 +2718,7 @@ OMX_ERRORTYPE OMXCameraAdapter::SignalEvent(OMX_IN OMX_HANDLETYPE hComponent,
//Signal the semaphore provided
sem->Signal();
free(msg);
+ eventSignalled = true;
break;
}
}
@@ -2727,6 +2729,19 @@ OMX_ERRORTYPE OMXCameraAdapter::SignalEvent(OMX_IN OMX_HANDLETYPE hComponent,
CAMHAL_LOGDA("Event queue empty!!!");
}
+ // Special handling for any unregistered events
+ if (!eventSignalled) {
+ // Handling for focus callback
+ if ((nData2 == OMX_IndexConfigCommonFocusStatus) &&
+ (eEvent == (OMX_EVENTTYPE) OMX_EventIndexSettingChanged)) {
+ TIUTILS::Message msg;
+ msg.command = OMXCallbackHandler::CAMERA_FOCUS_STATUS;
+ msg.arg1 = NULL;
+ msg.arg2 = NULL;
+ mOMXCallbackHandler->put(&msg);
+ }
+ }
+
LOG_FUNCTION_NAME_EXIT;
return OMX_ErrorNone;
@@ -3364,6 +3379,11 @@ bool OMXCameraAdapter::OMXCallbackHandler::Handler()
( OMX_BUFFERHEADERTYPE *) msg.arg2);
break;
}
+ case OMXCallbackHandler::CAMERA_FOCUS_STATUS:
+ {
+ mCameraAdapter->handleFocusCallback();
+ break;
+ }
case CommandHandler::COMMAND_EXIT:
{
CAMHAL_LOGDA("Exiting OMX callback handler");
diff --git a/camera/OMXCameraAdapter/OMXFocus.cpp b/camera/OMXCameraAdapter/OMXFocus.cpp
index d9d4df4..c99b620 100644
--- a/camera/OMXCameraAdapter/OMXFocus.cpp
+++ b/camera/OMXCameraAdapter/OMXFocus.cpp
@@ -141,8 +141,7 @@ status_t OMXCameraAdapter::doAutoFocus()
} else if ( mParameters3A.Focus == OMX_IMAGE_FocusControlAuto ) {
// In case we have CAF running we should first check the AF status.
// If it has managed to lock, then do as usual and return status
- // immediately. If lock is not available, then switch temporarily
- // to 'autolock' and do normal AF.
+ // immediately.
ret = checkFocus(&focusStatus);
if ( NO_ERROR != ret ) {
CAMHAL_LOGEB("Focus status check failed 0x%x!", ret);
@@ -165,12 +164,6 @@ status_t OMXCameraAdapter::doAutoFocus()
(OMX_INDEXTYPE)OMX_TI_IndexConfigAutofocusEnable,
&bOMX);
- ret = RegisterForEvent(mCameraAdapterParameters.mHandleComp,
- (OMX_EVENTTYPE) OMX_EventIndexSettingChanged,
- OMX_ALL,
- OMX_IndexConfigCommonFocusStatus,
- mDoAFSem);
-
// force AF, Ducati will take care of whether CAF
// or AF will be performed, depending on light conditions
if ( focusControl.eFocusControl == OMX_IMAGE_FocusControlAuto
@@ -200,19 +193,14 @@ status_t OMXCameraAdapter::doAutoFocus()
//If somethiing bad happened while we wait
if (mComponentState == OMX_StateInvalid) {
CAMHAL_LOGEA("Invalid State after Auto Focus Exitting!!!");
- return EINVAL;
+ return -EINVAL;
}
- if( ret != NO_ERROR) {
+ if(ret != NO_ERROR) {
//Disable auto focus callback from Ducati
setFocusCallback(false);
CAMHAL_LOGEA("Autofocus callback timeout expired");
- RemoveEvent(mCameraAdapterParameters.mHandleComp,
- (OMX_EVENTTYPE) OMX_EventIndexSettingChanged,
- OMX_ALL,
- OMX_IndexConfigCommonFocusStatus,
- NULL );
- returnFocusStatus(true);
+ ret = returnFocusStatus(true);
} else {
ret = returnFocusStatus(false);
}
@@ -401,7 +389,7 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached)
{
status_t ret = NO_ERROR;
OMX_PARAM_FOCUSSTATUSTYPE eFocusStatus;
- bool focusStatus = false;
+ CameraHalEvent::FocusStatus focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL;
BaseCameraAdapter::AdapterState state, nextState;
BaseCameraAdapter::getState(state);
BaseCameraAdapter::getNextState(nextState);
@@ -436,7 +424,7 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached)
if ( timeoutReached )
{
- focusStatus = false;
+ focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL;
}
else
{
@@ -444,7 +432,7 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached)
{
case OMX_FocusStatusReached:
{
- focusStatus = true;
+ focusStatus = CameraHalEvent::FOCUS_STATUS_SUCCESS;
break;
}
case OMX_FocusStatusOff:
@@ -452,7 +440,7 @@ status_t OMXCameraAdapter::returnFocusStatus(bool timeoutReached)
case OMX_FocusStatusRequest:
default:
{
- focusStatus = false;
+ focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL;
break;
}
}
@@ -520,7 +508,6 @@ status_t OMXCameraAdapter::checkFocus(OMX_PARAM_FOCUSSTATUSTYPE *eFocusStatus)
if ( NO_ERROR == ret )
{
OMX_INIT_STRUCT_PTR (eFocusStatus, OMX_PARAM_FOCUSSTATUSTYPE);
-
eError = OMX_GetConfig(mCameraAdapterParameters.mHandleComp,
OMX_IndexConfigCommonFocusStatus,
eFocusStatus);
@@ -800,4 +787,52 @@ status_t OMXCameraAdapter::setTouchFocus()
return ret;
}
+void OMXCameraAdapter::handleFocusCallback() {
+ OMX_PARAM_FOCUSSTATUSTYPE eFocusStatus;
+ CameraHalEvent::FocusStatus focusStatus = CameraHalEvent::FOCUS_STATUS_FAIL;
+ status_t ret = NO_ERROR;
+ BaseCameraAdapter::AdapterState nextState;
+ BaseCameraAdapter::getNextState(nextState);
+
+ OMX_INIT_STRUCT(eFocusStatus, OMX_PARAM_FOCUSSTATUSTYPE);
+
+ ret = checkFocus(&eFocusStatus);
+
+ if (NO_ERROR != ret) {
+ CAMHAL_LOGEA("Focus status check failed!");
+ // signal and unblock doAutoFocus
+ if (AF_ACTIVE & nextState) {
+ mDoAFSem.Signal();
+ }
+ return;
+ } else if (AF_ACTIVE & nextState) { // Handling for AF callback
+ // signal doAutoFocus when a end of scan message comes
+ // ignore start of scan
+ if (eFocusStatus.eFocusStatus != OMX_FocusStatusRequest) {
+ mDoAFSem.Signal();
+ }
+ return;
+ }
+
+ if (mParameters3A.Focus != (OMX_IMAGE_FOCUSCONTROLTYPE) OMX_IMAGE_FocusControlAuto) {
+ CAMHAL_LOGDA("unregistered focus callback when not in CAF or doAutoFocus... not handling");
+ return;
+ }
+
+ // Handling for CAF Callbacks
+ switch (eFocusStatus.eFocusStatus) {
+ case OMX_FocusStatusRequest:
+ focusStatus = CameraHalEvent::FOCUS_STATUS_PENDING;
+ break;
+ case OMX_FocusStatusReached:
+ case OMX_FocusStatusOff:
+ case OMX_FocusStatusUnableToReach:
+ default:
+ focusStatus = CameraHalEvent::FOCUS_STATUS_DONE;
+ break;
+ }
+
+ notifyFocusSubscribers(focusStatus);
+}
+
};