OMX_ERRORTYPE EnableDataFlow::setupTunneling() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; //make tunnel between output port1 of ARMIV Proc and input port of SW JPEG Enc DBGT_PTRACE("ARM IV port: %lu SW JPEG ENcport: %lu", mParamArmIvOutput.nPortIndex, mParamSwJpegInput.nPortIndex); err = (mOmxUtils.interface()->GetpOMX_SetupTunnel())(mArmIvProc, mParamArmIvOutput.nPortIndex, mSwJpegEnc, mParamSwJpegInput.nPortIndex); if(OMX_ErrorNone != err) { DBGT_CRITICAL(" OMX_SetupTunnel failed between ARMIV Proc and SW JPEGEnc err = %d", err); DBGT_EPILOG(""); return err; } //make tunnel between Output port of SWJPEGENC with input port 0 of EXIF MIxer DBGT_PTRACE("SW JPEG ENcport: %lu EXIF Mixer POrt: %lu", mParamSwJpegOutput.nPortIndex, mParamExifInput.nPortIndex); err = (mOmxUtils.interface()->GetpOMX_SetupTunnel())(mSwJpegEnc, mParamSwJpegOutput.nPortIndex, mExifMixer, mParamExifInput.nPortIndex); if(OMX_ErrorNone != err) { DBGT_CRITICAL(" OMX_SetupTunnel failed between SWJPEGENC and EXIFMIXER err = %d", err); DBGT_EPILOG(""); return err; } DBGT_EPILOG(""); return err; }
OMX_ERRORTYPE EnableDataFlow::freeHandles() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_ASSERT(NULL != mArmIvProc, "mArmIvProc is NULL"); DBGT_ASSERT(NULL != mSwJpegEnc, "mSwJpegEnc is NULL"); DBGT_PTRACE("Sending ArmIv to unloaded State"); err = mOmxUtils.interface()->GetpOMX_FreeHandle()(mArmIvProc); if(OMX_ErrorNone != err) { DBGT_CRITICAL("GetpOMX_FreeHandle ArmIVProc failed err = %d", err); DBGT_EPILOG(""); return err; } mArmIvProc = NULL ; DBGT_PTRACE("Sending SwJpegEnc to unloaded State"); err = mOmxUtils.interface()->GetpOMX_FreeHandle()(mSwJpegEnc); if(OMX_ErrorNone != err) { DBGT_CRITICAL("GetpOMX_FreeHandle SwJpegenc failed err = %d", err); DBGT_EPILOG(""); return err; } mSwJpegEnc = NULL ; DBGT_EPILOG(""); return err; }
/** * Undo MMIO initializations. * @param slot indicates which camera to de-init * @return OMX_ErrorNone or other OMX error codes */ OMX_ERRORTYPE CSiaPlatformManager::deinit( enumExtCameraSlot slot) { OMX_ERRORTYPE error=OMX_ErrorNone; //------------------------------------------------------- // PowerOff the sensor //------------------------------------------------------- error = MMIO_Camera::powerSensor(OMX_FALSE); if (error) { DBGT_PTRACE("ERROR in MMIO_Camera::powerSensor(OFF) !"); return error; } #ifndef MMIO_ENABLE_NEW_IF //------------------------------------------------------- // Switch OFF extClk //------------------------------------------------------- error = MMIO_Camera::setExtClk(OMX_FALSE); if (error) { DBGT_PTRACE("ERROR in MMIO_Camera::setExtClk(OFF) !"); return error; } #endif //MMIO_ENABLE_NEW_IF //------------------------------------------------------- // Desinit board //------------------------------------------------------- error = MMIO_Camera::desinitBoard(); if (error) { DBGT_PTRACE("ERROR in MMIO_Camera::deinitBoard !"); return error; } //------------------------------------------------------- // Release driver //------------------------------------------------------- #ifdef MMIO_ENABLE_NEW_IF error = MMIO_Camera::releaseDriver(); if (error) { DBGT_CRITICAL("ERROR in MMIO_Camera::releaseDriver!"); } #else if(slot ==ePrimaryExtCamera) error = MMIO_Camera::releasePrimaryCameraHWInterface(); else error = MMIO_Camera::releaseSecondaryCameraHWInterface(); if (error) { DBGT_PTRACE("ERROR in MMIO_Camera::releasePrimary/SecondaryCameraHWInterface !"); } #endif return error; }
OMX_ERRORTYPE EnableDataFlow::resetComponents() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_PTRACE("Sending Command StateIdle to SwJpegEnc"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandStateSet, OMX_StateIdle, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Sending OMX_StateIdle failed for SwJpegEnc err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command StateIdle to ArmIv"); err = OMX_SendCommand(mArmIvProc, OMX_CommandStateSet, OMX_StateIdle, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Sending OMX_StateIdle failed for ArmIVProc err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); mStateSWJpegSem.wait(); DBGT_PTRACE("Sending Command StateLoaded to ArmIv"); err = OMX_SendCommand(mArmIvProc, OMX_CommandStateSet, OMX_StateLoaded, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Sending OMX_StateLoaded failed for ArmIVProc err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command StateLoaded to SwJpegEnc"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandStateSet, OMX_StateLoaded, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Sending OMX_StateLoaded failed for SwJpegEnc err = %d", err); DBGT_EPILOG(""); return err; } err = freeBuffers(); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Free buffers err = %d", err); DBGT_EPILOG(""); return err; } mStateSWJpegSem.wait(); mStateArmIvSem.wait(); DBGT_EPILOG(""); return err; }
void EnableDataFlow::handleEvent() { DBGT_PROLOG(""); DBGT_PTRACE("Waiting for ArmIv EOS"); mArmIvEosSem.wait(); DBGT_PTRACE("Waiting for SwJpegEnc EOS"); mSwJpegEosSem.wait(); DBGT_EPILOG(""); }
OMX_ERRORTYPE EnableDataFlow::sendComponentToExecuting() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_PTRACE("Sending Command StateIdle to ArmIv"); err = OMX_SendCommand(mArmIvProc, OMX_CommandStateSet, OMX_StateIdle, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_CommandStateSet IDLE failed for mArmIvProc err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command StateIdle to SWJpeg"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandStateSet, OMX_StateIdle, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_CommandStateSet IDLE failed for mSwJpegEnc err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); mStateSWJpegSem.wait(); DBGT_PTRACE("Sending Command StateExecuting to ArmIv"); err = OMX_SendCommand(mArmIvProc, OMX_CommandStateSet, OMX_StateExecuting, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_CommandStateSet EXECUTING failed for mArmIvProc err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command StateExecuting to SWJpeg"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandStateSet, OMX_StateExecuting, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_CommandStateSet EXECUTING failed for mSwJpegEnc err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); mStateSWJpegSem.wait(); DBGT_EPILOG(""); return err; }
OMX_ERRORTYPE STEOMXCodecsPlugin::getRolesOfComponent( const char *name, Vector<String8> *roles) { DBGT_PROLOG("%s", name); roles->clear(); OMX_U32 numRoles; OMX_ERRORTYPE err = (mInterface->GetpOMX_GetRolesOfComponent())( const_cast<char *>(name), &numRoles, NULL); if (err != OMX_ErrorNone) { /*DBGT_CRITICAL("GetpOMX_GetRolesOfComponent failed, err=%s", OMX_TYPE_TO_STR(OMX_ERRORTYPE, err));*/ goto error; } if (numRoles > 0) { OMX_U8 **array = new OMX_U8 *[numRoles]; for (OMX_U32 i = 0; i < numRoles; ++i) { array[i] = new OMX_U8[OMX_MAX_STRINGNAME_SIZE]; } OMX_U32 numRoles2=numRoles; err = (mInterface->GetpOMX_GetRolesOfComponent())( const_cast<char *>(name), &numRoles2, array); DBGT_ASSERT(err == OMX_ErrorNone/*, "GetpOMX_GetRolesOfComponent failed for %s, err=%s" , name, OMX_TYPE_TO_STR(OMX_ERRORTYPE, err)*/); DBGT_ASSERT(numRoles == numRoles2/*, "GetpOMX_GetRolesOfComponent failed for %s, err=%s" , name, OMX_TYPE_TO_STR(OMX_ERRORTYPE, err)*/); for (OMX_U32 i = 0; i < numRoles; ++i) { String8 s((const char *)array[i]); roles->push(s); DBGT_PTRACE("%s: role=%s", name, (const char *)array[i]); delete[] array[i]; array[i] = NULL; } delete[] array; array = NULL; } DBGT_EPILOG(); return OMX_ErrorNone; error: /*DBGT_EPILOG("err=%s", OMX_TYPE_TO_STR(OMX_ERRORTYPE, err));*/ return err; }
SCF_STATE CAM_SM::EnablePortInIdleExecutingState_SendOmxCb(s_scf_event const *e) { switch (e->sig) { case SCF_STATE_ENTRY_SIG: { ENTRY; pExtIspctlCom->requestPE(0x0000); return 0; } case SCF_STATE_EXIT_SIG: { EXIT; return 0; } case EVT_ISPCTL_INFO_SIG: { DBGT_PTRACE("EnablePortInIdleExecutingState_SendOmxCb-EVT_ISPCTL_INFO_SIG"); IFM_HostNmfProcessingComp* Cam = (IFM_HostNmfProcessingComp*)&mENSComponent.getProcessingComponent(); (Cam->getNmfSendCommandItf())->sendCommand(OMX_CommandPortEnable,enabledPort); SCF_TRANSIT_TO(&CAM_SM::ProcessPendingEvents); return 0; } default: break; } return SCF_STATE_PTR(&CAM_SM::EnablePortInIdleExecutingState); }
SCF_STATE CAM_SM::EnablePortInIdleExecutingState(s_scf_event const *e) { switch (e->sig) { case SCF_STATE_ENTRY_SIG: { ENTRY; return 0; } case SCF_STATE_EXIT_SIG: { EXIT; return 0; } case SCF_STATE_INIT_SIG: { INIT; SCF_INIT(&CAM_SM::EnablePortInIdleExecutingState_StopVpip); return 0; } case Q_DEFERRED_EVENT_SIG: { DBGT_PTRACE("EnablePortInIdleExecutingState-Q_DEFERRED_EVENT_SIG"); return 0; } default: break; } return SCF_STATE_PTR(&CAM_SM::OMX_Executing); }
SCF_STATE CAM_SM::EnablePortInIdleExecutingState_StopVpip(s_scf_event const *e) { switch (e->sig) { case SCF_STATE_ENTRY_SIG: { ENTRY; pExtIspctlCom->requestPE(0x0000); return 0; } case SCF_STATE_EXIT_SIG: { EXIT; return 0; } case EVT_ISPCTL_INFO_SIG: { DBGT_PTRACE("EnablePortInIdleExecutingState_StopVpip-EVT_ISPCTL_INFO_SIG"); OMX_STATETYPE currentState; mENSComponent.GetState(&mENSComponent, ¤tState); SCF_TRANSIT_TO(&CAM_SM::EnablePortInIdleExecutingState_ConfigurePipe); return 0; } default: break; } return SCF_STATE_PTR(&CAM_SM::EnablePortInIdleExecutingState); }
OMX_ERRORTYPE FixedFocusHandler::setUpFocus(const char* const aFocus) { DBGT_PROLOG("Focus: %s", aFocus); DBGT_ASSERT(NULL != aFocus, "Focus is NULL"); OMX_ERRORTYPE err = OMX_ErrorNone; //Setting Focus Control OmxUtils::StructContainer<OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE> focusControl; focusControl.ptr()->nPortIndex = OMX_ALL; err = OMX_GetConfig(mSTECamera->mCam, (OMX_INDEXTYPE)(OMX_IndexConfigFocusControl), focusControl.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_GetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } focusControl.ptr()->eFocusControl = OMX_IMAGE_FocusControlOff; focusControl.ptr()->nFocusStepIndex = 0; focusControl.ptr()->nFocusSteps = 100; DBGT_PTRACE("Setting Control %u", focusControl.ptr()->eFocusControl); err = OMX_SetConfig(mSTECamera->mCam, (OMX_INDEXTYPE)(OMX_IndexConfigFocusControl), focusControl.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_SetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_EPILOG(""); return err; }
OMX_ERRORTYPE EnableDataFlow::useBuffer() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_PTRACE("\n Calling OMX_SetConfig before OMX_UseBuffer ArmIV Chunk\n"); err = OMX_SetConfig(mArmIvProc, (OMX_INDEXTYPE)OMX_OsiIndexConfigSharedChunkMetadata, &mChunkData_ArmIvProc); if (err != OMX_ErrorNone) { DBGT_PTRACE("OMX_SetConfig Failed \n"); } mArmIvInBuffer = NULL; DBGT_PTRACE("usebuffer mArmIvProc "); err = OMX_UseBuffer(mArmIvProc, // hComponent &mArmIvInBuffer, // address where ptr to buffer header will be stored 0, // port index (for port for which buffer is provided) (void *)(&mArmIvOmxBuffInfo), // App. private data = pointer to beginning of allocated data // to have a context when component returns with a callback (i.e. to know // what to free etc. (OMX_U32)(mParamArmIvInput.nBufferSize), // buffer size (OMX_U8 *)(mArmIvOmxBuffInfo.mMMHwBufferInfo.iLogAddr) // buffer data ptr ); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_UseBuffer failed for mArmIvProc port 0 failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_ASSERT(NULL != mArmIvInBuffer->pBuffer, "Buffer is NULL"); mArmIvOmxBuffInfo.mCamMemoryBase.get()->setOmxBufferHeaderType(mArmIvInBuffer); DBGT_EPILOG(""); return err; }
MPerfTimer::Time SystemTimePerfTimer::elapsedTime() { DBGT_PROLOG(""); //get current time nsecs_t currentTick = systemTime(SYSTEM_TIME_REALTIME); DBGT_PTRACE("Current tick: %lld", currentTick); Time time = (currentTick-mInitTime)/1000; DBGT_EPILOG(""); return time; }
SCF_STATE CAM_SM::EnablePortInIdleExecutingState_CfgGrabStartVpip(s_scf_event const *e) { camport * portVF = (camport *) mENSComponent.getPort(CAMERA_PORT_OUT0); camport * portSS = (camport *) mENSComponent.getPort(CAMERA_PORT_OUT1); switch (e->sig) { case SCF_STATE_ENTRY_SIG: { ENTRY; DBGT_PTRACE("EnablePortInIdleExecutingState_CfgGrabStartVpip-ENTRY"); pGrabControl->configureGrabResolutionFormat(portVF); pExtIspctlCom->requestPE(0x0000); return 0; } case SCF_STATE_EXIT_SIG: { EXIT; return 0; } case EVT_ISPCTL_INFO_SIG: { DBGT_PTRACE("EnablePortInIdleExecutingState_CfgGrabStartVpip-EVT_ISPCTL_INFO_SIG"); OMX_STATETYPE currentState; mENSComponent.GetState(&mENSComponent, ¤tState); mENSComponent.eventHandler(OMX_EventPortSettingsChanged, (OMX_U32)0, portVF->getPortIndex()); mENSComponent.eventHandler(OMX_EventPortSettingsChanged, (OMX_U32)0, portSS->getPortIndex()); SCF_TRANSIT_TO(&CAM_SM::EnablePortInIdleExecutingState_SendOmxCb); return 0; } default: break; } return SCF_STATE_PTR(&CAM_SM::EnablePortInIdleExecutingState); }
OMX_ERRORTYPE ArmIVEmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) { DBGT_PROLOG("Handle: %p, AppData: %p, BuffHeader: %p", hComponent, pAppData, pBuffer); //NULL checking DBGT_ASSERT(NULL != hComponent, "Invalid handle"); DBGT_ASSERT(NULL != pBuffer, "Invalid buffer"); DBGT_PTRACE("ArmIVEmptyBufferDone empty buffer done \n"); DBGT_EPILOG(""); return OMX_ErrorNone; }
MPerfTimer::Time DurationTimerPerfTimer::elapsedTime() { DBGT_PROLOG(""); //stop timer mTimer.stop(); //get elapsed time int64_t time = mTimer.durationUsecs(); //add elapsed time mTotalTimeFromInit += static_cast<Time>(time); DBGT_PTRACE("Duration: %lld", mTotalTimeFromInit); //start timer mTimer.start(); DBGT_EPILOG(""); return mTotalTimeFromInit; }
SCF_STATE CAM_SM::EnablePortInIdleExecutingState_ConfigurePipe(s_scf_event const *e) { switch (e->sig) { case SCF_STATE_ENTRY_SIG: { ENTRY; pExtIspctlCom->requestPE(0x0000); return 0; } case SCF_STATE_EXIT_SIG: { EXIT; return 0; } case EVT_ISPCTL_INFO_SIG: { DBGT_PTRACE("EnablePortInIdleExecutingState_ConfigurePipe-EVT_ISPCTL_INFO_SIG"); SCF_TRANSIT_TO(&CAM_SM::EnablePortInIdleExecutingState_CfgGrabStartVpip); return 0; } default: break; } return SCF_STATE_PTR(&CAM_SM::EnablePortInIdleExecutingState); }
OMX_ERRORTYPE EnableDataFlow::disablePorts() { DBGT_PROLOG(""); if (!mPortsEnabled) { return OMX_ErrorNone; } OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_PTRACE("Sending Command OMX_CommandPortDisable for mArmIvProc Port 0"); err = OMX_SendCommand(mArmIvProc, OMX_CommandPortDisable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Disable 0 mArmIvProc failed err = %d", err); DBGT_EPILOG(""); return err; } err = freeBuffers(); if(OMX_ErrorNone != err) { DBGT_CRITICAL("freeBuffers failed err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); DBGT_PTRACE("Sending Command OMX_CommandPortDisable for mSwJpegEnc Port 0"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandPortDisable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Disable 0 mSwJpegEnc failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command OMX_CommandPortDisable for mArmIvProc Port 1"); err = OMX_SendCommand(mArmIvProc, OMX_CommandPortDisable, 1, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Disable 1 mArmIvProc failed err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); mStateSWJpegSem.wait(); DBGT_PTRACE("Sending Command OMX_CommandPortDisable for mSwJpegEnc Port 1"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandPortDisable, 1, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Disable 1 mSwJpegEnc failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command OMX_CommandPortDisable for mExifMixer Port 0"); err = OMX_SendCommand(mExifMixer, OMX_CommandPortDisable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Disable 1 mExifMixer failed err = %d", err); DBGT_EPILOG(""); return err; } camera_sem_wait(&mStateExifSem, SEM_WAIT_TIMEOUT); mStateSWJpegSem.wait(); mPortsEnabled = false; DBGT_EPILOG(""); return err; }
OMX_ERRORTYPE EnableDataFlow::configPorts(const ImageInfo &aThumbnailInfo, const ImageInfo &aPreviewInfo) { DBGT_PROLOG("Thumbnail Width: %d Height: %d \nPreview Width: %d Heidht: %d\n", aThumbnailInfo.getWidth(), aThumbnailInfo.getHeight(), aPreviewInfo.getAlignedWidth(), aPreviewInfo.getAlignedHeight()); DBGT_ASSERT(0 != aThumbnailInfo.getWidth(), "invalid width"); DBGT_ASSERT(0 != aThumbnailInfo.getHeight(), "invalid height"); DBGT_ASSERT(0 != aPreviewInfo.getAlignedWidth(), "invalid Preview Width"); DBGT_ASSERT(0 != aPreviewInfo.getAlignedHeight(), "invalid Preview Height"); OMX_ERRORTYPE err = OMX_ErrorNone; /****************************************************************************/ // Initialize ARM IV input /****************************************************************************/ err = OMX_GetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mArmIvProc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } mParamArmIvInput.nBufferCountActual = 1; // the index of the input port. Should be modified. //Here, the min number of buffers to be used is retrieved OMX_VIDEO_PORTDEFINITIONTYPE *pt_armivinput = &(mParamArmIvInput.format.video); pt_armivinput->cMIMEType = (OMX_STRING)""; pt_armivinput->pNativeRender = (OMX_NATIVE_DEVICETYPE)NULL; pt_armivinput->nFrameWidth = (OMX_U32)aPreviewInfo.getAlignedWidth(); pt_armivinput->nFrameHeight = (OMX_U32)aPreviewInfo.getAlignedHeight(); pt_armivinput->nStride = (OMX_U32)(2 * aPreviewInfo.getAlignedWidth()); pt_armivinput->nSliceHeight = (OMX_U32)aPreviewInfo.getAlignedHeight(); pt_armivinput->bFlagErrorConcealment = (OMX_BOOL)OMX_FALSE; pt_armivinput->eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_IMAGE_CodingUnused; pt_armivinput->eColorFormat = mPreviewOmxColorFormat; pt_armivinput->pNativeWindow = (OMX_NATIVE_DEVICETYPE)NULL; err = OMX_SetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Setparameter OMX_IndexParamPortDefinition for mArmIvProc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } err = OMX_GetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mArmIvProc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } //dump DBGT_PTRACE("Dumping params for ARM IV input"); OmxUtils::dump(mParamArmIvInput); //***********Set Rotation value in ARMIVPRoc if((aThumbnailInfo.getRotation() == 90)||(aThumbnailInfo.getRotation() == 270)){ OmxUtils::StructContainer<OMX_CONFIG_ROTATIONTYPE> rfactor; rfactor.ptr()->nPortIndex = 1; rfactor.ptr()->nRotation = (aThumbnailInfo.getRotation()+180)%360; err = OMX_SetConfig(mArmIvProc, OMX_IndexConfigCommonRotate, rfactor.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("SetConfig for mArmIvProc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } } //*********** /****************************************************************************/ // Initialize ARM IV output /****************************************************************************/ err = OMX_GetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvOutput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mArmIvProc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } mParamArmIvOutput.nBufferCountActual = 1; OMX_VIDEO_PORTDEFINITIONTYPE *pt_armivoutput = &(mParamArmIvOutput.format.video); pt_armivoutput->cMIMEType = (OMX_STRING)""; pt_armivoutput->pNativeRender = (OMX_NATIVE_DEVICETYPE)NULL; pt_armivoutput->nFrameWidth = (OMX_U32) aThumbnailInfo.getAlignedWidth(); pt_armivoutput->nFrameHeight = (OMX_U32)aThumbnailInfo.getAlignedHeight(); pt_armivoutput->nSliceHeight = (OMX_U32)aThumbnailInfo.getAlignedHeight(); pt_armivoutput->nStride = 0; pt_armivoutput->bFlagErrorConcealment = (OMX_BOOL)OMX_FALSE; pt_armivoutput->eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_IMAGE_CodingUnused; pt_armivoutput->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_COLOR_FormatCbYCrY; pt_armivoutput->pNativeWindow = (OMX_NATIVE_DEVICETYPE)NULL; err = OMX_SetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvOutput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Setparameter OMX_IndexParamPortDefinition for mArmIvProc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } err = OMX_GetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvOutput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mArmIvProc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } //dump DBGT_PTRACE("Dumping params for ARM IV output"); OmxUtils::dump(mParamArmIvOutput); /****************************************************************************/ // Initialize SW JPEG Encoder Input for DCF thumbnail /****************************************************************************/ err = OMX_GetParameter(mSwJpegEnc, OMX_IndexParamPortDefinition, &mParamSwJpegInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mSwJpegEnc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } mParamSwJpegInput.nBufferCountActual = 1; // the index of the input port. Should be modified. OMX_IMAGE_PORTDEFINITIONTYPE *pt_swjpeginput = &(mParamSwJpegInput.format.image); pt_swjpeginput->cMIMEType = (OMX_STRING)""; pt_swjpeginput->pNativeRender = (OMX_NATIVE_DEVICETYPE)NULL; pt_swjpeginput->nFrameWidth = (OMX_U32) aThumbnailInfo.getAlignedWidth(); pt_swjpeginput->nFrameHeight = (OMX_U32)aThumbnailInfo.getAlignedHeight(); pt_swjpeginput->nStride = (OMX_U32) (aThumbnailInfo.getAlignedWidth() * 3 / 2); pt_swjpeginput->nSliceHeight = (OMX_U32)aThumbnailInfo.getAlignedHeight(); pt_swjpeginput->bFlagErrorConcealment = (OMX_BOOL)OMX_FALSE; pt_swjpeginput->eCompressionFormat = (OMX_IMAGE_CODINGTYPE)OMX_IMAGE_CodingUnused; pt_swjpeginput->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_COLOR_FormatCbYCrY; pt_swjpeginput->pNativeWindow = (OMX_NATIVE_DEVICETYPE)NULL; err = OMX_SetParameter(mSwJpegEnc, OMX_IndexParamPortDefinition, &mParamSwJpegInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Setparameter OMX_IndexParamPortDefinition for mSwJpegEnc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } err = OMX_GetParameter(mSwJpegEnc, OMX_IndexParamPortDefinition, &mParamSwJpegInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mSwJpegEnc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } //dump DBGT_PTRACE("Dumping params for mParamSwJpegInput"); OmxUtils::dump(mParamSwJpegInput); /****************************************************************************/ // Initialize SW JPEG Encoder Ouput for DCF thumbnail /****************************************************************************/ if (aThumbnailInfo.invalidQuality() != aThumbnailInfo.getQuality()) { //setup thumbnail quality OmxUtils::StructContainer<OMX_IMAGE_PARAM_QFACTORTYPE> qfactor; qfactor.ptr()->nPortIndex = 1; qfactor.ptr()->nQFactor = aThumbnailInfo.getQuality(); DBGT_PTRACE("Setting JPEG Thumbnail Quality: %lu ", qfactor.ptr()->nQFactor); err = OMX_SetConfig(mSwJpegEnc, OMX_IndexParamQFactor, qfactor.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("SetConfig mSwJpegEnc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } } err = OMX_GetParameter(mSwJpegEnc, OMX_IndexParamPortDefinition, &mParamSwJpegOutput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mSwJpegEnc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } mParamSwJpegOutput.nBufferCountActual = 1; // the index of the input port. Should be modified. OMX_IMAGE_PORTDEFINITIONTYPE *pt_swjpegoutput = &(mParamSwJpegOutput.format.image); pt_swjpegoutput->cMIMEType = (OMX_STRING)""; pt_swjpegoutput->pNativeRender = (OMX_NATIVE_DEVICETYPE)NULL; pt_swjpegoutput->nFrameWidth = (OMX_U32)aThumbnailInfo.getWidth(); pt_swjpegoutput->nFrameHeight = (OMX_U32)aThumbnailInfo.getHeight(); pt_swjpegoutput->nStride = (OMX_U32)(aThumbnailInfo.getWidth() * 3 / 2); pt_swjpegoutput->nSliceHeight = (OMX_U32)aThumbnailInfo.getHeight(); pt_swjpegoutput->bFlagErrorConcealment = (OMX_BOOL)OMX_FALSE; pt_swjpegoutput->eCompressionFormat = (OMX_IMAGE_CODINGTYPE)OMX_IMAGE_CodingJPEG; pt_swjpegoutput->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_COLOR_FormatUnused; pt_swjpegoutput->pNativeWindow = (OMX_NATIVE_DEVICETYPE)NULL; err = OMX_SetParameter(mSwJpegEnc, OMX_IndexParamPortDefinition, &mParamSwJpegOutput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Setparameter OMX_IndexParamPortDefinition for mSwJpegEnc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } err = STECamera::cropOutputSize(mSwJpegEnc, aThumbnailInfo.getWidth(), aThumbnailInfo.getHeight()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("cropOutputSize for mSwJpegEnc failed err = %d", err); DBGT_EPILOG(""); return err; } err = OMX_GetParameter(mSwJpegEnc, OMX_IndexParamPortDefinition, &mParamSwJpegOutput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mSwJpegEnc port1 failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Dumping params for mParamSwJpegOutput"); OmxUtils::dump(mParamSwJpegOutput); /****************************************************************************/ // Reconfigure ExifMixer port 0 /****************************************************************************/ err = OMX_GetParameter(mExifMixer, OMX_IndexParamPortDefinition, &mParamExifInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter mExifMixer port 0 failed err = %d", err); DBGT_EPILOG(""); return err; } mParamExifInput.nBufferCountActual = 1; // the index of the input port. Should be modified. OMX_IMAGE_PORTDEFINITIONTYPE *pt_exifinput1 = &(mParamExifInput.format.image); pt_exifinput1->cMIMEType = (OMX_STRING)""; pt_exifinput1->pNativeRender = (OMX_NATIVE_DEVICETYPE)NULL; pt_exifinput1->nFrameWidth = (OMX_U32)aThumbnailInfo.getWidth(); pt_exifinput1->nFrameHeight = (OMX_U32)aThumbnailInfo.getHeight(); pt_exifinput1->nStride = (OMX_U32)(aThumbnailInfo.getWidth() * 3 / 2); pt_exifinput1->bFlagErrorConcealment = (OMX_BOOL)OMX_FALSE; pt_exifinput1->eCompressionFormat = (OMX_IMAGE_CODINGTYPE)OMX_IMAGE_CodingJPEG; pt_exifinput1->eColorFormat = (OMX_COLOR_FORMATTYPE)OMX_COLOR_FormatUnused; pt_exifinput1->pNativeWindow = (OMX_NATIVE_DEVICETYPE)NULL; err = OMX_SetParameter(mExifMixer, OMX_IndexParamPortDefinition, &mParamExifInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Setparameter mExifMixer port 0 failed err = %d", err); DBGT_EPILOG(""); return err; } //dump err = OMX_GetParameter(mExifMixer, OMX_IndexParamPortDefinition, &mParamExifInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter mExifMixer port 0 failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Dumping params for mParamExifInput"); OmxUtils::dump(mParamExifInput); DBGT_EPILOG(""); return err; }
OMX_ERRORTYPE EnableDataFlow::updateSnapShot(const ImageInfo &aPreviewInfo) { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_PTRACE("Sending Command OMX_CommandPortDisable for mArmIvProc Port 0"); err = OMX_SendCommand(mArmIvProc, OMX_CommandPortDisable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Disable 0 mArmIvProc failed err = %d", err); DBGT_EPILOG(""); return err; } err = freeBuffers(); if(OMX_ErrorNone != err) { DBGT_CRITICAL("freeBuffers failed err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); /****************************************************************************/ // Initialize ARM IV input /****************************************************************************/ err = OMX_GetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mArmIvProc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } mParamArmIvInput.nBufferCountActual = 1; // the index of the input port. Should be modified. //Here, the min number of buffers to be used is retrieved OMX_VIDEO_PORTDEFINITIONTYPE *pt_armivinput = &(mParamArmIvInput.format.video); pt_armivinput->cMIMEType = (OMX_STRING)""; pt_armivinput->pNativeRender = (OMX_NATIVE_DEVICETYPE)NULL; pt_armivinput->nFrameWidth = (OMX_U32)aPreviewInfo.getAlignedWidth(); pt_armivinput->nFrameHeight = (OMX_U32)aPreviewInfo.getAlignedHeight(); pt_armivinput->nStride = (OMX_U32)(2 * aPreviewInfo.getAlignedWidth()); pt_armivinput->nSliceHeight = (OMX_U32)aPreviewInfo.getAlignedHeight(); pt_armivinput->bFlagErrorConcealment = (OMX_BOOL)OMX_FALSE; pt_armivinput->eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_IMAGE_CodingUnused; pt_armivinput->eColorFormat = mPreviewOmxColorFormat; pt_armivinput->pNativeWindow = (OMX_NATIVE_DEVICETYPE)NULL; err = OMX_SetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Setparameter OMX_IndexParamPortDefinition for mArmIvProc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } err = OMX_GetParameter(mArmIvProc, OMX_IndexParamPortDefinition, &mParamArmIvInput); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Getparameter OMX_IndexParamPortDefinition for mArmIvProc port0 failed err = %d", err); DBGT_EPILOG(""); return err; } //dump DBGT_PTRACE("Dumping params for ARM IV input"); OmxUtils::dump(mParamArmIvInput); DBGT_PTRACE("Sending Command OMX_CommandPortEnable for mArmIvProc Port 0"); err = OMX_SendCommand(mArmIvProc, OMX_CommandPortEnable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Enable 0 mArmIvProc failed err = %d", err); DBGT_EPILOG(""); return err; } err = useBuffer(); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Use buffers failed err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); DBGT_EPILOG(""); return err; }
OMX_ERRORTYPE SWJpegEventHandler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_EVENTTYPE eEvent, OMX_U32 nData1, OMX_U32 nData2, OMX_PTR pEventData) { DBGT_PROLOG("Handle: %p AppData: %p", hComponent, pAppData); DBGT_PTRACE("Event: %s(%d) Data1: %lu Data2: %lu EventData: %p", OmxUtils::name(eEvent), eEvent, nData1, nData2, pEventData); //NULL checking DBGT_ASSERT(NULL != hComponent, "Invalid handle" ); EnableDataFlow *parent = static_cast<EnableDataFlow *>(pAppData); switch (eEvent) { case OMX_EventCmdComplete: { OMX_COMMANDTYPE cmd = (OMX_COMMANDTYPE) nData1; DBGT_PTRACE("Cmd: %s(%d)", OmxUtils::name(cmd), cmd); if (cmd == OMX_CommandStateSet) { OMX_STATETYPE newState = (OMX_STATETYPE) nData2; DBGT_PTRACE("State: %s(%d)", OmxUtils::name(newState), newState); switch (newState) { case OMX_StateLoaded: parent->mStateSWJpegSem.signal(); break; case OMX_StateIdle: parent->mStateSWJpegSem.signal(); break; case OMX_StateExecuting: parent->mStateSWJpegSem.signal(); break; case OMX_StatePause: DBGT_PTRACE("OMX_StatePause"); break; case OMX_StateInvalid: DBGT_CRITICAL("OMX_StateInvalid"); break; default: break; } } else if (OMX_CommandPortDisable == cmd) parent->mStateSWJpegSem.signal(); else if (OMX_CommandPortEnable == cmd) parent->mStateSWJpegSem.signal(); break; } case OMX_EventError: DBGT_CRITICAL("Error detected by OMX event handler : %d (0x%x) - %d (0x%x) ", (OMX_ERRORTYPE) nData1, (OMX_ERRORTYPE) nData1, (OMX_ERRORTYPE) nData2, (OMX_ERRORTYPE) nData2); break; case OMX_EventBufferFlag: { if ((nData1 == 1 ) ) { parent->mSwJpegEosSem.signal(); parent->mPerfManager.logAndDump(PerfManager::ESwJpegEOS); } break; } default: DBGT_PTRACE("Unknown event: %d", eEvent); } DBGT_EPILOG(""); return OMX_ErrorNone; }
OMX_ERRORTYPE EnableDataFlow::enablePorts() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; DBGT_PTRACE("Sending Command Port Enable for mExifMixer Port 0"); err = OMX_SendCommand(mExifMixer, OMX_CommandPortEnable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Enable 1 mExifMixer failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command Port Enable for SwJpegEnc Port 1"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandPortEnable, 1, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Enable 1 SwJpegEnc failed err = %d", err); DBGT_EPILOG(""); return err; } mStateSWJpegSem.wait(); camera_sem_wait(&mStateExifSem, SEM_WAIT_TIMEOUT); DBGT_PTRACE("Sending Command Port Enable for ArmIvProc Port 1"); err = OMX_SendCommand(mArmIvProc, OMX_CommandPortEnable, 1, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Enable 1 ArmIvProc failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_PTRACE("Sending Command Port Enabled for SwJpegEnc Port 0"); err = OMX_SendCommand(mSwJpegEnc, OMX_CommandPortEnable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Enable 0 SwJpegEnc failed err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); mStateSWJpegSem.wait(); DBGT_PTRACE("Sending Command OMX_CommandPortEnable for mArmIvProc Port 0"); err = OMX_SendCommand(mArmIvProc, OMX_CommandPortEnable, 0, NULL); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Port Enable 0 mArmIvProc failed err = %d", err); DBGT_EPILOG(""); return err; } err = useBuffer(); if(OMX_ErrorNone != err) { DBGT_CRITICAL("Use buffers failed err = %d", err); DBGT_EPILOG(""); return err; } mStateArmIvSem.wait(); mPortsEnabled = true; DBGT_EPILOG(""); return err; }
/** * Do MMIO initializations. * @param slot indicates which camera to de-init * @return OMX_ErrorNone or other OMX error codes */ OMX_ERRORTYPE CSiaPlatformManager::init( enumExtCameraSlot slot) { OMX_ERRORTYPE error=OMX_ErrorNone; #ifdef MMIO_ENABLE_NEW_IF //------------------------------------------------------- // Select camera //------------------------------------------------------- if(slot == ePrimaryExtCamera) MMIO_Camera::selectCamera(1, MMIO_Camera::eYUV); else MMIO_Camera::selectCamera(2, MMIO_Camera::eYUV); //------------------------------------------------------- // Init driver //------------------------------------------------------- error = MMIO_Camera::initDriver(); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::initDriver!"); return error; } //------------------------------------------------------- // Init board //------------------------------------------------------- error = MMIO_Camera::initHardware(); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::initHardware!"); return error; } //------------------------------------------------------- // PowerOn the sensor //------------------------------------------------------- error = MMIO_Camera::powerSensor(OMX_TRUE); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::powerSensor(ON)!"); return error; } #else if(slot == ePrimaryExtCamera) { error = MMIO_Camera::initBoard(MMIO_Camera::ePrimaryXSD); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::initBoard for primary camera!"); return error; } } else { error = MMIO_Camera::initBoard(MMIO_Camera::eSecondaryXSD); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::initBoard for secondary camera!"); return error; } } //------------------------------------------------------- // Trigger xShutdown //------------------------------------------------------- if(slot == ePrimaryExtCamera) { error = enable_xshutdown_from_host(OMX_TRUE, OMX_TRUE); if (error) { DBGT_PTRACE( "ERROR in enable_xshutdown_from_host(ON) !"); return error; } } else { error = enable_xshutdown_from_host(OMX_TRUE, OMX_FALSE); if (error) { DBGT_PTRACE( "ERROR in enable_xshutdown_from_host(ON) !"); return error; } } //------------------------------------------------------- // PowerOn the sensor //------------------------------------------------------- error = MMIO_Camera::powerSensor(OMX_TRUE); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::powerSensor(ON) !"); return error; } // Select Primary/Secondary Camera //------------------------------------------------------- if(slot ==ePrimaryExtCamera){ error = MMIO_Camera::setPrimaryCameraHWInterface(); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::setPrimaryCameraHWInterface !"); return error; } } else { error = MMIO_Camera::setSecondaryCameraHWInterface(); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::setSecondaryCameraHWInterface !"); return error; } } //------------------------------------------------------- // Switch ON extClk //------------------------------------------------------- error = MMIO_Camera::setExtClk(OMX_TRUE); if (error) { DBGT_PTRACE( "ERROR in MMIO_Camera::setExtClk(ON) !"); return error; } #endif //MMIO_ENABLE_NEW_IF return error; }
OMX_ERRORTYPE FocusHandler::handleAFEvent() { DBGT_PROLOG(""); OMX_ERRORTYPE err = OMX_ErrorNone; bool focusReached = false; //get status #ifdef ENABLE_AUTOFOCUS err = getFocusStatus(); if(OMX_ErrorNone != err) { DBGT_CRITICAL("getFocusStatus failed err = %d", err); DBGT_EPILOG(""); return err; } if(OMX_TRUE == mExtFocusStatus.mFocusStatus.bFocused) { mSTECamera->mPerfManager.logAndDump(PerfManager::EAutoFocusReached); focusReached = true; } DBGT_PTRACE("Focus reached: %d", focusReached); #endif #ifdef ENABLE_CONTINUOUS_AUTOFOCUS if (mSTECamera->mMsgEnabled & CAMERA_MSG_FOCUS_MOVE) { int lensState; int focusStatus = (OMX_FOCUSSTATUSTYPE)mExtFocusStatus.mFocusStatus.sAFROIs[0].eFocusStatus; switch (focusStatus) { case OMX_FocusStatusRequest: lensState = ETrackingState; break; case OMX_FocusStatusUnableToReach: lensState = EFocusUnableToReach; break; case OMX_FocusStatusReached: lensState = EFocusReached; break; default: DBGT_PTRACE("Invalid focus status"); break; } //If autofocus msg is enable, that means capture is in progress //no need to send callback //If lensState is same as previous then no need to send callback if (!(mSTECamera->mAutoFocusThreadData->mEnabled) && !(lensState == mSTECamera->mAutoFocusThreadData->mContinuousFocusState)) { mSTECamera->mLock.unlock(); mSTECamera->mNotifyCb(CAMERA_MSG_FOCUS_MOVE, !(focusReached), 0, mSTECamera->mCallbackCookie); mSTECamera->mLock.lock(); //Assign new state mSTECamera->mAutoFocusThreadData->mContinuousFocusState = lensState; } } #endif #ifdef ENABLE_AUTOFOCUS if (mSTECamera->mMsgEnabled & CAMERA_MSG_FOCUS) { mSTECamera->mLock.unlock(); if (mSTECamera->mAutoFocusThreadData->mEnabled) { mSTECamera->mNotifyCb(CAMERA_MSG_FOCUS, focusReached, 0, mSTECamera->mCallbackCookie); mSTECamera->mAutoFocusThreadData->mEnabled = OMX_FALSE; mSTECamera->mMsgEnabled &= ~CAMERA_MSG_FOCUS; } mSTECamera->mLock.lock(); } #else //!ENABLE_AUTOFOCUS mSTECamera->mPerfManager.logAndDump(PerfManager::EAutoFocusReached); #endif //ENABLE_AUTOFOCUS #ifdef PRINT_ALL_ROI if(focusReached == true) { for (int i=0; i< (int)mExtFocusStatus.mFocusStatus.nAFAreas; i++){ DBGT_PINFO("For RoI %d: Status is",i); DBGT_PINFO("Focus Status for ROI %s",OmxUtils::name((OMX_FOCUSSTATUSTYPE)mExtFocusStatus.mFocusStatus.sAFROIs[i].eFocusStatus ) ); DBGT_PINFO("Ref-W%d Ref-H%d",(int)(mExtFocusStatus.mFocusStatus.sAFROIs[i].nReferenceWindow.nWidth), (int) (mExtFocusStatus.mFocusStatus.sAFROIs[i].nReferenceWindow.nHeight) ); DBGT_PINFO("Rectangle X%d,Y%d,W%d,H%d ", (int)(mExtFocusStatus.mFocusStatus.sAFROIs[i].nRect.sTopLeft.nX), (int)(mExtFocusStatus.mFocusStatus.sAFROIs[i].nRect.sTopLeft.nY) , (int)(mExtFocusStatus.mFocusStatus.sAFROIs[i].nRect.sSize.nWidth), (int)(mExtFocusStatus.mFocusStatus.sAFROIs[i].nRect.sSize.nHeight) ); } } #endif //PRINT_ALL_ROI DBGT_EPILOG(""); return err; }
/** Configures a given focus mode. While configuring a focus mode, it configures * 1. Range Control * 2. Focus Control * 3. Optionally, Focus Lock, if ENABLE_LOCK is enabled. */ OMX_ERRORTYPE FocusHandler::setUpFocus(const char* const aFocus) { DBGT_PROLOG("Focus: %s", aFocus); DBGT_ASSERT(NULL != aFocus, "Focus is NULL"); OMX_ERRORTYPE err = OMX_ErrorNone; mFocusModeIndex = getFocusModeIndex(aFocus); if (kInvalidIndex == mFocusModeIndex) { DBGT_EPILOG("OMX_ErrorBadParameter"); return OMX_ErrorBadParameter; } //Setting Focus Range OmxUtils::StructContainer<OMX_SYMBIAN_CONFIG_FOCUSRANGETYPE> rangeControl; rangeControl.ptr()->nPortIndex = OMX_ALL; err = OMX_GetConfig(mSTECamera->mCam, mSTECamera->mOmxILExtIndex->getIndex(OmxILExtIndex::EFocusRange), rangeControl.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_GetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } rangeControl.ptr()->eFocusRange = g_STECamFocusProp[mFocusModeIndex].eRangeType; DBGT_PTRACE("Setting Range %s",OmxUtils::name ((OMX_SYMBIAN_FOCUSRANGETYPE)rangeControl.ptr()->eFocusRange)); err = OMX_SetConfig(mSTECamera->mCam, mSTECamera->mOmxILExtIndex->getIndex(OmxILExtIndex::EFocusRange), rangeControl.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_SetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } //Setting Focus lock #ifdef ENABLE_LOCK OmxUtils::StructContainer<OMX_SYMBIAN_CONFIG_LOCKTYPE> focuslock; focuslock.ptr()->nPortIndex=OMX_ALL; #ifndef DISABLE_GET_CONFIG_LOCK //Remove this workaround when ER 351601 is resolved err = OMX_GetConfig(mSTECamera->mCam, mSTECamera->mOmxILExtIndex->getIndex(OmxILExtIndex::EFocusLock), focuslock.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_GetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } #endif //DISABLE_GET_CONFIG_LOCK focuslock.ptr()->eImageLock = getLockType(); DBGT_PTRACE("Setting Lock %s",OmxUtils::name((OMX_SYMBIAN_LOCKTYPE) focuslock.ptr()->eImageLock)); err = OMX_SetConfig(mSTECamera->mCam, mSTECamera->mOmxILExtIndex->getIndex(OmxILExtIndex::EFocusLock), focuslock.ptr() ); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_SetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } #endif //ENABLE_LOCK //Setting Focus Control OmxUtils::StructContainer<OMX_IMAGE_CONFIG_FOCUSCONTROLTYPE> focusControl; focusControl.ptr()->nPortIndex = OMX_ALL; err = OMX_GetConfig(mSTECamera->mCam, (OMX_INDEXTYPE)(OMX_IndexConfigFocusControl), focusControl.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_GetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } focusControl.ptr()->eFocusControl = g_STECamFocusProp[mFocusModeIndex].eFocusType; DBGT_PTRACE("Setting Control %u", focusControl.ptr()->eFocusControl); err = OMX_SetConfig(mSTECamera->mCam, (OMX_INDEXTYPE)(OMX_IndexConfigFocusControl), focusControl.ptr()); if(OMX_ErrorNone != err) { DBGT_CRITICAL("OMX_SetConfig failed err = %d", err); DBGT_EPILOG(""); return err; } DBGT_EPILOG(""); return err; }