/*
 * This function launches the loading of the flash tuning data
 */
TuningLoaderMgrError_t CTuningLoaderManager::loadFlashTuningData(const t_flash_info* pFlashInfo)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::loadFlashTuningData", (mTraceObject));

    // Check if constructed
    if(iNmfInstance == NULL) {
        MSG0("Instance not constructed\n");
        OstTraceFiltStatic0(TRACE_ERROR, "Instance not constructed", (mTraceObject));
        OUTR(" ",TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::loadFlashTuningData (%d)", (mTraceObject), TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        return TUNING_LOADER_MGR_NOT_CONSTRUCTED;
    }

    // Aguments sanity check
    if( pFlashInfo == NULL)
    {
        MSG1("Bad argument: pFlashInfo=%p\n", pFlashInfo);
        OstTraceFiltStatic1(TRACE_ERROR, "Bad argument: pFlashInfo=0x%x", (mTraceObject), (t_uint32)pFlashInfo);
        OUTR(" ",TUNING_LOADER_MGR_BAD_ARGUMENT);
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::loadFlashTuningData (%d)", (mTraceObject), TUNING_LOADER_MGR_BAD_ARGUMENT);
        return TUNING_LOADER_MGR_BAD_ARGUMENT;
    }

    // Send command to NMF
    MSG0("Send 'loadFlashTuning' command to NMF\n");
    OstTraceFiltStatic0(TRACE_DEBUG, "Send 'loadFlashTuning' command to NMF", (mTraceObject));
    iNmfQueryIntf.loadFlashTuning(*pFlashInfo);

    OUTR(" ",TUNING_LOADER_MGR_OK);
    OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::loadFlashTuningData (%d)", (mTraceObject), TUNING_LOADER_MGR_OK);
    return TUNING_LOADER_MGR_OK;
}
SCF_STATE CAM_SM::SettingTestMode(s_scf_event const *e)
{
	switch (e->sig)
	{
		case SCF_STATE_ENTRY_SIG:
			IMG_LOG("SettingTestMode-ENTRY;\n",NULL,NULL,NULL,NULL,NULL,NULL);
			MSG0("SettingTestMode-ENTRY;\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "SettingTestMode-ENTRY;", (&mENSComponent));
			return 0;
		case SCF_STATE_EXIT_SIG:
			IMG_LOG("SettingTestMode-EXIT;\n",NULL,NULL,NULL,NULL,NULL,NULL);
			MSG0("SettingTestMode-EXIT;\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "SettingTestMode-EXIT;", (&mENSComponent));
			return 0;
		case SCF_STATE_INIT_SIG:
			IMG_LOG("SettingTestMode-INIT;\n",NULL,NULL,NULL,NULL,NULL,NULL);
			MSG0("SettingTestMode-INIT;\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "SettingTestMode-INIT;", (&mENSComponent));
			SCF_INIT(&CAM_SM::ProcessTestMode);
			return 0;
		case Q_DEFERRED_EVENT_SIG:
			IMG_LOG("SettingTestMode-DEFERRED_EVENT;\n",NULL,NULL,NULL,NULL,NULL,NULL);
			MSG0("SettingTestMode-DEFERRED_EVENT;\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "SettingTestMode-DEFERRED_EVENT;", (&mENSComponent));
			return 0;
		default:
			IMG_LOG("SettingTestMode- default : e->sig = %d;\n",e->sig,NULL,NULL,NULL,NULL,NULL);
	}

	IMG_LOG("call SCF_STATE_PTR(&CAM_SM::SetFeature)\n",NULL,NULL,NULL,NULL,NULL,NULL);
	return SCF_STATE_PTR(&CAM_SM::SetFeature);
}
TuningLoaderMgrError_t CTuningLoaderManager::saveNvmTuningData(const t_camera_info* pCamInfo,unsigned char* pNvm, t_uint32 aSize)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::saveNvmTuningData", (mTraceObject));

    // Check if constructed
    if(iNmfInstance == NULL) {
        MSG0("Instance not constructed\n");
        OstTraceFiltStatic0(TRACE_ERROR, "Instance not constructed", (mTraceObject));
        OUTR(" ",TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::loadNvmTuningData (%d)", (mTraceObject), TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        return TUNING_LOADER_MGR_NOT_CONSTRUCTED;
    }

    // Aguments sanity check
    if( (pCamInfo == NULL) || (pNvm ==NULL) || (aSize == 0))
    {
        MSG1("Bad argument: pCamInfo=%x, pNvm=0x%x, aSize=%x\n", (unsigned int)pCamInfo,(unsigned int)pNvm,(unsigned int)aSize);
        OstTraceFiltStatic3(TRACE_ERROR, "Bad argument: pCamInfo=0x%x pNvm=0x%x, aSize=%d", (mTraceObject), (t_uint32)pCamInfo,(t_uint32)pNvm,aSize);
        OUTR(" ",TUNING_LOADER_MGR_BAD_ARGUMENT);
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::loadNvmTuningData (%d)", (mTraceObject), TUNING_LOADER_MGR_BAD_ARGUMENT);
        return TUNING_LOADER_MGR_BAD_ARGUMENT;
    }

    // Send command to NMF
    MSG0("Send 'SaveNvmTuning' command to NMF\n");
    OstTraceFiltStatic0(TRACE_DEBUG, "Send 'loadNvmTuning' command to NMF", (mTraceObject));
    iNmfQueryIntf.saveNvmTuning(*pCamInfo,(t_uint32)pNvm,aSize);

    OUTR(" ",TUNING_LOADER_MGR_OK);
    OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::loadNvmTuningData (%d)", (mTraceObject), TUNING_LOADER_MGR_OK);
    return TUNING_LOADER_MGR_OK;
}
SCF_STATE CAM_SM::PowerUp_STC(s_scf_event const *e)
{
	switch (e->sig) {
		case SCF_STATE_ENTRY_SIG:
			MSG0("PowerUp_STC-SCF_STATE_ENTRY_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC-SCF_STATE_ENTRY_SIG", (&mENSComponent));
			pIspctlCom->requestPE(Sensor_Tuning_Control_e_Flag_ReadConfigBeforeBoot_Byte0);
			return 0;
		
		case EVT_ISPCTL_INFO_SIG :
			MSG0("Powerup_STC-EVT_ISPCTL_INFO_SIG;\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "Powerup_STC-EVT_ISPCTL_INFO_SIG;", (&mENSComponent));
			if (ISP_READ_DONE == e->type.ispctlInfo.info_id) /* Acknowledge to read */
			{
				Flag_te ReadCdccConfigBeforeBoot = (Flag_te)e->type.ispctlInfo.value;
				if (ReadCdccConfigBeforeBoot == Flag_e_TRUE) SCF_TRANSIT_TO(&CAM_SM::PowerUp_STC_SensorInfo);
				else SCF_TRANSIT_TO(&COM_SM::SHARED_ControlingISPState);
				return 0;
			}
			break;
		case SCF_STATE_EXIT_SIG:
			MSG0("PowerUp_STC-SCF_STATE_EXIT_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC-SCF_STATE_EXIT_SIG", (&mENSComponent));
			return 0;
		default:
			break;
	}
	return SCF_STATE_PTR(&COM_SM::SHARED_ControlingISPState_Boot);
}
/*
 * NMF callback
 */
void CTuningLoaderManager::response(t_tuningloader_error aErr)
{
    ASYNC_IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::response", (mTraceObject));
    s_scf_event event;
    if(aErr==TUNING_LOADER_OK) {
        // NMF operation done: prepare COM_SM event
        MSG0("NMF operation completed\n");
        OstTraceFiltStatic0(TRACE_DEBUG, "NMF operation completed", (mTraceObject));
        event.sig = TUNING_LOADER_OPERATION_DONE_SIG;
        event.type.tuningLoaderEvent.error = TUNING_LOADER_OK;
    }
    else {
        // NMF operation failed: prepare COM_SM event
        MSG1("NMF operation failed: err=%d\n", aErr);
        OstTraceFiltStatic1(TRACE_ERROR, "NMF operation failed: err=%d", (mTraceObject), aErr);
        // Note: here the function iNmfSyncIntf.errorCode2String() cannot be called
        // as CTuningLoaderManager::response callback is called in the context of the ENS
        // Wrapper which has no reference to iNmfErrorIntf
        event.sig = TUNING_LOADER_OPERATION_FAILED_SIG;
        event.type.tuningLoaderEvent.error = aErr;
    }
    iSM->ProcessEvent(&event);
    ASYNC_OUT0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Exit CTuningLoaderManager::response", (mTraceObject));
}
SCF_STATE CAM_SM::TimeNudge_StartCapture(s_scf_event const *e) {
    switch (e->sig) {
        case SCF_STATE_ENTRY_SIG:
        {
            ENTRY;
            MSG0("CAM_SM::TimeNudge_StartCapture-SCF_STATE_ENTRY_SIG\n");
            pResourceSharerManager->mRSPing.Ping(0);
            return 0;
        }
        case Q_PONG_SIG:
        {
            MSG0("CAM_SM::TimeNudge_StartCapture-Q_PONG_SIG\n");
            OstTraceFiltStatic0(TRACE_DEBUG, "CAM_SM::TimeNudge_StartCapture-SCF_STATE_ENTRY_SIG", (&mENSComponent));
            /* check that we have enough buffers on port (nFrameBefore + nFrameLimit needed) */
            /* NB : nFrameBefore + 1 should be enough but it is not supported right now */
            camport * vpb1 = (camport *) mENSComponent.getPort(CAMERA_PORT_OUT1);
            t_sw3A_FlashDirective flashDirective = p3AComponentManager->mFlashController.getDirective();
            if(flashDirective.flashState == SW3A_FLASH_MAINFLASH)
            {
                //clear Extradata circular buffers
                extradataCircularBuffer_init();
            }
            if ((OMX_TRUE == pOpModeMgr->IsTimeNudgeEnabled())
                && (vpb1->getParamPortDefinition().nBufferCountActual < (pOpModeMgr->GetFrameBefore()+pOpModeMgr->GetBurstFrameLimit()))) {
                MSG0("CAM_SM::TimeNudge_StartCapture-OMX_ErrorBadParameter\n");
                OstTraceFiltStatic0(TRACE_DEBUG, "CAM_SM::TimeNudge_StartCapture-OMX_ErrorBadParameter", (&mENSComponent));
                mENSComponent.eventHandler(OMX_EventError, (OMX_U32)OMX_ErrorBadParameter, 0);
                return 0;
            }

            pOpModeMgr->captureRequest[CAMERA_PORT_OUT1] ++;
            
            OMX_ERRORTYPE err = OMX_ErrorNone;
            err = pOpModeMgr->Compute_NumberOfBuffersForStill();
            if (OMX_ErrorNone != err)
            {
               DBC_ASSERT(0);
            }
            
            if (1 == pOpModeMgr->NumberOfBuffersForStill)
            {
                pGrabControl->setStartOneShotCapture(CAMERA_PORT_OUT1);
            }
            else
            {
                pGrabControl->startBurstCapture(CAMERA_PORT_OUT1, (t_uint16)pOpModeMgr->NumberOfBuffersForStill);
            }
            
            SCF_PSTATE next;
            SM_POP_STATE(next);
            SCF_TRANSIT_TO_PSTATE(next);

            return 0;
        }
        case SCF_STATE_EXIT_SIG:  EXIT;  return 0;
        default: break;
    }
    return SCF_STATE_PTR(&CAM_SM::EnteringOpMode);
}
SCF_STATE CAM_SM::PowerUp_STC_ReadId(s_scf_event const *e) {
	switch (e->sig) {
		case SCF_STATE_ENTRY_SIG:
		{
			ENTRY;
			MSG0("PowerUp_STC_ReadId-SCF_STATE_ENTRY_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC_ReadId-SCF_STATE_ENTRY_SIG", (&mENSComponent));
			pIspctlCom->queuePE(Sensor_Tuning_Status_u16_CurrentSubBlockIdValue_Byte0,0);
			pIspctlCom->readQueue();
			return 0;
		}
		case EVT_ISPCTL_LIST_INFO_SIG:
		{
			MSG0("PowerUp_STC_ReadId-EVT_ISPCTL_LIST_INFO_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC_ReadId-EVT_ISPCTL_LIST_INFO_SIG", (&mENSComponent));
			if (e->type.ispctlInfo.info_id != ISP_READLIST_DONE) break;
//#if defined (OSI_DEBUG)
			for(t_uint16 i=0; i < e->type.ispctlInfo.number_of_pe; i++) {
				MSG3("   PE[%d] %s = 0x%lX\n", i, pSensor->GetPeName(e->type.ispctlInfo.Listvalue[i].pe_addr), e->type.ispctlInfo.Listvalue[i].pe_data );
				//OstTraceFiltStatic3(TRACE_DEBUG, "PE[%d] %s = 0x%lX", (&mENSComponent), i, CXp70::GetPeName(e->type.ispctlInfo.Listvalue[i].pe_addr), e->type.ispctlInfo.Listvalue[i].pe_data );
			}
//#endif
			// Store tuning BlockId value
			pFwSubBlockId[iCurrentFwSubBlockIndex] = (t_uint16)e->type.ispctlInfo.Listvalue[0].pe_data;
			MSG2("   FwSubBlockId[%d] = ID%d\n", iCurrentFwSubBlockIndex, pFwSubBlockId[iCurrentFwSubBlockIndex]);
			OstTraceFiltStatic2(TRACE_DEBUG, "FwSubBlockId[%d] = ID%d", (&mENSComponent), iCurrentFwSubBlockIndex, pFwSubBlockId[iCurrentFwSubBlockIndex]);
			// Another block to be fetched ?
			iCurrentFwSubBlockIndex++;
			if(iCurrentFwSubBlockIndex<iFwSubBlockIdsCount) {
				// Still some tuning blocks IDs are to be fetched
				MSG0("   Some blocks ID are to be fetched\n");
				OstTraceFiltStatic0(TRACE_DEBUG, "Some blocks ID are to be fetched", (&mENSComponent));
				SCF_TRANSIT_TO(&CAM_SM::PowerUp_STC_QueryId);
			}
			else {
				// All tuning blocks IDs were fetched
				MSG1("   All block IDs were fetched: total %d\n", iFwSubBlockIdsCount);
				OstTraceFiltStatic1(TRACE_DEBUG, "All block IDs were fetched: total %d", (&mENSComponent), iFwSubBlockIdsCount);
//#if defined (OSI_DEBUG)
				for(t_uint16 i=0; i<iFwSubBlockIdsCount; i++) {
					MSG2("   FwSubBlockId[%d] = ID%d\n", i, pFwSubBlockId[i]);
					OstTraceFiltStatic2(TRACE_DEBUG, "FwSubBlockId[%d] = ID%d", (&mENSComponent), i, pFwSubBlockId[i]);
				}
//#endif
				SCF_TRANSIT_TO(&CAM_SM::PowerUp_STC_LoadData);
			}
			return 0;
		}
		case SCF_STATE_EXIT_SIG:
		{
			EXIT;
			return 0;
		}
		default: break;
	}
	return SCF_STATE_PTR(&COM_SM::SHARED_ControlingISPState_Boot);
}
SCF_STATE CAM_SM::CAMERA_LoadingIQSettings_ZoomPreRun(s_scf_event const *e) {
   switch (e->sig) {
	   case SCF_STATE_ENTRY_SIG:
	   {
			ENTRY;

			MSG0("LoadingIQSettings_ZoomPreRun : changeover allowed\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "LoadingIQSettings_ZoomPreRun : changeover allowed", (&mENSComponent));

			pIspctlCom->queuePE(HostFrameConstraints_e_Flag_AllowChangeOver_Byte0, (t_uint32)Flag_e_TRUE);

			if (OMX_TRUE == pOpModeMgr->IsTimeNudgeEnabled() ||(pOpModeMgr->CurrentOperatingMode == OpMode_Cam_VideoRecord)||(OMX_TRUE == pOpModeMgr->ConfigCapturing[CAMERA_PORT_OUT2]) )
			{
#if (IMG_CONFIG_SW_PLATFORM == 1)
				pIspctlCom->queuePE(SystemSetup_e_GrabMode_Ctrl_Byte0, (t_uint32)GrabMode_e_FORCE_OK);
#endif
			}
			else
			{
#if (IMG_CONFIG_SW_PLATFORM == 1)
				pIspctlCom->queuePE(SystemSetup_e_GrabMode_Ctrl_Byte0, (t_uint32)GrabMode_e_NORMAL);
#endif
			}
			if((pOpModeMgr->CurrentOperatingMode == OpMode_Cam_StillCaptureSingle)
					||(pOpModeMgr->CurrentOperatingMode == OpMode_Cam_StillCaptureSingleInVideo)
					||(pOpModeMgr->CurrentOperatingMode == OpMode_Cam_StillCaptureBurstLimited)
					||(pOpModeMgr->CurrentOperatingMode == OpMode_Cam_StillCaptureBurstInfinite)
					||(pOpModeMgr->CurrentOperatingMode == OpMode_Cam_StillCaptureBurstLimitedInVideo)
					||(pOpModeMgr->CurrentOperatingMode == OpMode_Cam_StillCaptureBurstInfiniteInVideo)
			)
			{
				pIspctlCom->queuePE(HostFrameConstraints_u8_MaximumPreScale_Byte0, 1);
			}
			else
			{
					pIspctlCom->queuePE(HostFrameConstraints_u8_MaximumPreScale_Byte0, 15);
			}
			pIspctlCom->processQueue();
			return 0;
	   }
	   case SCF_STATE_EXIT_SIG:   EXIT; return 0;
	   case EVT_ISPCTL_LIST_INFO_SIG:
	   {
			MSG0("LoadingIQSettings_ZoomPreRun-EVT_ISPCTL_LIST_INFO_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "LoadingIQSettings_ZoomPreRun-EVT_ISPCTL_LIST_INFO_SIG", (&mENSComponent));
			if (e->type.ispctlInfo.info_id != ISP_WRITELIST_DONE) break;
			/* TODO : Other Feature Pre-Run */
            SCF_PSTATE next;
            SM_POP_STATE(next);
            SCF_TRANSIT_TO_PSTATE(next);
			return 0;
	   }
       default: break;
   }
   return SCF_STATE_PTR(&CAM_SM::CAMERA_LoadingIQSettings);
}
SCF_STATE CAM_SM::PowerUp_STC_CheckCoin(s_scf_event const *e) {
	switch (e->sig) {
		case SCF_STATE_ENTRY_SIG:
		{
			ENTRY;
			MSG0("PowerUp_STC_CheckCoin-SCF_STATE_ENTRY_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC_CheckCoin-SCF_STATE_ENTRY_SIG", (&mENSComponent));
			// Get coin value
			pIspctlCom->queuePE(Sensor_Tuning_Status_e_Coin_SubBlock_Status_Byte0,0);
			pIspctlCom->readQueue();
			return 0;
		}
		case EVT_ISPCTL_LIST_INFO_SIG:
		{
			MSG0("PowerUp_STC_CheckCoin-EVT_ISPCTL_LIST_INFO_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC_CheckCoin-EVT_ISPCTL_LIST_INFO_SIG", (&mENSComponent));
			if (e->type.ispctlInfo.info_id != ISP_READLIST_DONE) break;
//#if defined (OSI_DEBUG)
			for(t_uint16 i=0; i < e->type.ispctlInfo.number_of_pe; i++) {
				MSG4("   PE[%d] 0x%X (%s) = 0x%lX\n", i, e->type.ispctlInfo.Listvalue[i].pe_addr, pSensor->GetPeName(e->type.ispctlInfo.Listvalue[i].pe_addr), e->type.ispctlInfo.Listvalue[i].pe_data );
				//OstTraceFiltStatic4(TRACE_DEBUG, "   PE[%d] 0x%X (%s) = 0x%lX", (&mENSComponent), i, e->type.ispctlInfo.Listvalue[i].pe_addr, CXp70::GetPeName(e->type.ispctlInfo.Listvalue[i].pe_addr), e->type.ispctlInfo.Listvalue[i].pe_data );
			}
//#endif
			if( (Coin_te)e->type.ispctlInfo.Listvalue[0].pe_data == iStatusCoin) {
				// Coin state has not changed yet
				if(iStatusCoinRetriesCount>=10) {
					MSG0("*****   Coin state unchanged, too many attempts *****\n");
					OstTraceFiltStatic0(TRACE_DEBUG, "*****   Coin state unchanged, too many attempts *****", (&mENSComponent));
					DBC_ASSERT(0);
					return 0;
				}
				MSG1("   Coin state unchanged (state=%d) => try again\n", (int)iStatusCoin);
				OstTraceFiltStatic1(TRACE_DEBUG, "Coin state unchanged (state=%d) => try again", (&mENSComponent), (int)iStatusCoin);
				iStatusCoinRetriesCount++;
				pIspctlCom->queuePE(Sensor_Tuning_Status_e_Coin_SubBlock_Status_Byte0,0);
				pIspctlCom->readQueue();
			}
			else {
				// Coin state changed => we can read the block ID value
				iStatusCoin = (Coin_te) e->type.ispctlInfo.Listvalue[0].pe_data;
				MSG1("   Coin state unchanged (state=%d) => read Block ID value\n", (int)iStatusCoin);
				OstTraceFiltStatic1(TRACE_DEBUG, "Coin state unchanged (state=%d) => read Block ID value", (&mENSComponent), (int)iStatusCoin);
				iStatusCoinRetriesCount = 0;
				SCF_TRANSIT_TO(&CAM_SM::PowerUp_STC_ReadId);
			}
			return 0;
		}
		case SCF_STATE_EXIT_SIG:
		{
			EXIT;
			return 0;
		}
		default: break;
	}
	return SCF_STATE_PTR(&COM_SM::SHARED_ControlingISPState_Boot);
}
/*
 * Constructor
 */
CTuningLoaderManager::CTuningLoaderManager(TraceObject *traceobj): mTraceObject(traceobj)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::CTuningLoaderManager", (mTraceObject));
    iSM = NULL;
    iNmfInstance = NULL;
    iOmxHandle = NULL;
    OUT0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Exit CTuningLoaderManager::CTuningLoaderManager", (mTraceObject));
}
/*
 * COM_SM Handle setter
 */
void CTuningLoaderManager::setSM(CScfStateMachine* aSM)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::setSM", (mTraceObject));
    iSM = aSM;
    MSG1("COM_SM Handle = %p\n", iSM);
    OstTraceFiltStatic1(TRACE_DEBUG, "COM_SM Handle = 0x%x", (mTraceObject), (t_uint32)iSM);
    OUT0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Exit CTuningLoaderManager::setSM", (mTraceObject));
}
/*
 * Destructor
 */
CTuningLoaderManager::~CTuningLoaderManager()
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::~CTuningLoaderManager", (mTraceObject));
    if(iNmfInstance != NULL) {
        MSG0("NMF instance not destroyed => destroying\n");
        OstTraceFiltStatic0(TRACE_DEBUG, "NMF instance not destroyed => destroying", (mTraceObject));
        if( destroy() != TUNING_LOADER_MGR_OK) {
            MSG0("TuningLoaderManager destruction failed\n");
            OstTraceFiltStatic0(TRACE_ERROR, "TuningLoaderManager destruction failed", (mTraceObject));
        }
    }
    OUT0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Exit CTuningLoaderManager::~CTuningLoaderManager", (mTraceObject));
}
/*
 * This function computes the dampers and queues the Page Elements
 */
t_damper_error_code CNoiseFilterDamper::ComputeAndQueuePEs( CIspctlCom*                 pIspctlCom,
                                                            const t_damper_base_values* pBaseValues)
{
   IN0("\n");
   OstTraceFiltStatic0(TRACE_FLOW, "Entry CNoiseFilterDamper::ComputeAndQueuePEs", (mTraceObject));
   float pDampedValues[1] = { 0.0 };
   t_damper_error_code err = DAMPER_OK;

   // Evaluate Noise Filter dampers
   err = DoEvaluate( pBaseValues, pDampedValues);
   if(err!=DAMPER_OK)
   {
      DBGT_ERROR("Failed to evaluate damper: err=%d\n", err);
      OstTraceFiltStatic1(TRACE_ERROR, "Failed to evaluate damper: err=%d", (mTraceObject), err);
      OUTR(" ",err);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CNoiseFilterDamper::ComputeAndQueuePEs (%d)", (mTraceObject), err);
      return err;
   }

   // Queue the Page Elements
   float fGaussianWeightDamped = pDampedValues[0];
   MSG2("%s = %f\n", CIspctlCom::pIspctlSensor->GetPeName(DusterControl_u8_GaussianWeight_Byte0), fGaussianWeightDamped);
   OstTraceFiltStatic1(TRACE_DEBUG, "DusterControl_u8_GaussianWeight = %f", (mTraceObject), fGaussianWeightDamped);
   pIspctlCom->queuePE( DusterControl_u8_GaussianWeight_Byte0, (t_uint32)fGaussianWeightDamped);

   // Done
   OUTR(" ",DAMPER_OK);
   OstTraceFiltStatic1(TRACE_FLOW, "Exit CNoiseFilterDamper::ComputeAndQueuePEs (%d)", (mTraceObject), DAMPER_OK);
   return DAMPER_OK;
}
Example #14
0
void CCamSharedMemory::reset()
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CCamSharedMemory::reset", (mTraceObject));
    for (int i=0; i < CAM_SHARED_MEM_CHUNK_MAX; i++) {
        aChunks[i].armLogicalAddress = 0;
        aChunks[i].armLogicalAddress = 0;
        aChunks[i].size = 0;
        abBusyChunks[i] = false;
    }
    pSharedBuffer = NULL;
    sharedBufferPoolId = NULL;
    sharedBufferSize = 0;
    OUT0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Exit CCamSharedMemory::reset", (mTraceObject));
}
Example #15
0
camSharedMemError_t CCamSharedMemory::getChunk(camSharedMemChunk_t *pChunk, camSharedMemChunkId_t chunkId)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CCamSharedMemory::getChunk", (mTraceObject));
    if (state != CCamSharedMemory::CAM_SHARED_MEM_STATE_OPEN) {
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::getChunk (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_BAD_STATE);
        return CAM_SHARED_MEM_ERR_BAD_STATE;
    }
    if (chunkId >= CAM_SHARED_MEM_CHUNK_MAX) {
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::getChunk (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_BAD_PARAMETER);
        return CAM_SHARED_MEM_ERR_BAD_PARAMETER;
    }
    if (abBusyChunks[chunkId]) {
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::getChunk (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_BAD_PRECONDITION);
        return CAM_SHARED_MEM_ERR_BAD_PRECONDITION;
    }
    abBusyChunks[chunkId] = true;
    *pChunk = aChunks[chunkId];
    OUT0("\n");
    OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::getChunk (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_NONE);
    return CAM_SHARED_MEM_ERR_NONE;
}
/*
 * This function computes the dampers and queues the Page Elements
 */
t_damper_error_code CScorpioDamper::ComputeAndQueuePEs( CIspctlCom*                 pIspctlCom,
                                                        const t_damper_base_values* pBaseValues)
{
   IN0("\n");
   OstTraceFiltStatic0(TRACE_FLOW, "Entry CScorpioDamper::ComputeAndQueuePEs", (mTraceObject));
   float pDampedValues[1] = { 0.0 };
   float fCoringLevel = 0.0;
   t_damper_error_code err = DAMPER_OK;

   // Evaluate Scorpio dampers
   err = DoEvaluate( pBaseValues, pDampedValues);
   if(err!=DAMPER_OK)
   {
      DBGT_ERROR("Evaluation failed: err=%d\n", err);
      OstTraceFiltStatic1(TRACE_ERROR, "Evaluation failed: err=%d", (mTraceObject), err);
      OUTR(" ",err);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CScorpioDamper::ComputeAndQueuePEs (%d)", (mTraceObject), err);
      return err;
   }

   // Queue the Page Elements list
   fCoringLevel = pDampedValues[0];
   MSG2("%s = %f\n", CIspctlCom::pIspctlSensor->GetPeName(Scorpio_Ctrl_u8_CoringLevel_Ctrl_Byte0), fCoringLevel);
   OstTraceFiltStatic1(TRACE_DEBUG, "Scorpio_Ctrl_u8_CoringLevel_Ctrl = %f", (mTraceObject), fCoringLevel);
   pIspctlCom->queuePE( Scorpio_Ctrl_u8_CoringLevel_Ctrl_Byte0, (t_uint32)fCoringLevel);

   // Done
   OUTR(" ",DAMPER_OK);
   OstTraceFiltStatic1(TRACE_FLOW, "Exit CScorpioDamper::ComputeAndQueuePEs (%d)", (mTraceObject), DAMPER_OK);
   return DAMPER_OK;
}
void CFlashSequencer::sigTimer() {
    IN0("\n");
    cam_flashSeq_atom_t const *pSeq = NULL;
    if (i32_remSteps > 0) { // Some flash action still to be done
        switch (curSeq) {
            default:
            case NONE_SEQ:
                DBGT_ERROR("CFlashSequencer::sigTimer - Error: NONE_SEQ cannot be ticked.\n");
                OstTraceFiltStatic0(TRACE_ERROR, "CFlashSequencer::sigTimer - Error: NONE_SEQ cannot be ticked.", (mTraceObject));
                break;
            case RED_EYE_REMOVAL_SEQ:
                pSeq = &a_RER_sequence[sizeof(a_RER_sequence) / sizeof(cam_flashSeq_atom_t) - i32_remSteps];
                break;
            case PRIVACY_SEQ:
                pSeq = &a_PI_sequence[sizeof(a_PI_sequence) / sizeof(cam_flashSeq_atom_t) - i32_remSteps];
                break; 
        }
        if (NULL != pSeq) {
            doAtom(pSeq);
        }
        i32_remSteps--;
    } else {            // End of sequence: call the user back if requested, and clean the request.
        MSG1("CFlashSequencer::sigTimer - Sequence %d completed.\n", curSeq);
        curSeq = NONE_SEQ;
        if (mpClbk != NULL) {
            mpClbk(mctxtHnd);
            mpClbk = NULL;
            mctxtHnd = NULL;
        }
    }
    OUT0("\n");
}
SCF_STATE CAM_SM::PowerUp_STC_QueryId(s_scf_event const *e) {
	switch (e->sig) {
		case SCF_STATE_ENTRY_SIG:
		{
			ENTRY;
			// Ask the next block ID and toggle the coin
			MSG2("   Query Block[%d], coin state=%d\n", iCurrentFwSubBlockIndex, (int)iStatusCoin);
			OstTraceFiltStatic2(TRACE_DEBUG, "   Query Block[%d], coin state=%d", (&mENSComponent), iCurrentFwSubBlockIndex, (int)iStatusCoin);
			pIspctlCom->queuePE(Sensor_Tuning_Control_u16_SelectedSubBlockIdIndex_Byte0,(t_uint32)iCurrentFwSubBlockIndex);
			pIspctlCom->queuePE(Sensor_Tuning_Control_e_Coin_SubBlock_Control_Byte0,(t_uint32)(iStatusCoin==Coin_e_Heads ? Coin_e_Tails : Coin_e_Heads));
			pIspctlCom->processQueue();
			return 0;
		}
		case EVT_ISPCTL_LIST_INFO_SIG:
		{
			MSG0("PowerUp_STC_QueryId-EVT_ISPCTL_LIST_INFO_SIG\n");
			OstTraceFiltStatic0(TRACE_DEBUG, "PowerUp_STC_QueryId-EVT_ISPCTL_LIST_INFO_SIG", (&mENSComponent));
			if (e->type.ispctlInfo.info_id != ISP_WRITELIST_DONE) break;
			SCF_TRANSIT_TO(&CAM_SM::PowerUp_STC_CheckCoin);
			return 0;
		}
		case SCF_STATE_EXIT_SIG:
		{
			EXIT;
			return 0;
		}
		default: break;
	}
	return SCF_STATE_PTR(&COM_SM::SHARED_ControlingISPState_Boot);
}
Example #19
0
/*
 * This function sets the sharpening damper
 */
t_damper_error_code CSharpeningDamperLR::SetDamper( const t_sharpening_damper_lr_id aDamperId,
                                                    const float*                    pValues,
                                                    const int                       aNumRows,
                                                    const int                       aNumCols)
{
   IN0("\n");
   OstTraceFiltStatic0(TRACE_FLOW, "Entry CSharpeningDamperLR::SetDamper", (mTraceObject));
   t_damper_error_code err = DAMPER_OK;
   if(aDamperId<0 || aDamperId>=SHARPENING_DAMPERS_LR_NUM)
   {
      DBGT_ERROR("Invalid damper Id: %d\n", aDamperId);
      OstTraceFiltStatic1(TRACE_ERROR, "Invalid damper Id: %d", (mTraceObject), aDamperId);
      OUTR(" ",DAMPER_INVALID_ARGUMENT);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CSharpeningDamperLR::SetDamper (%d)", (mTraceObject), DAMPER_INVALID_ARGUMENT);
      return DAMPER_INVALID_ARGUMENT;
   }
   MSG3("[%s] NumRows=%d, NumCols=%d\n", SHARPENING_DAMPER_LR_NAME(aDamperId), aNumRows, aNumCols);
   OstTraceFiltStatic3(TRACE_DEBUG, "SHARPENING_DAMPER_LR_NAME(%d) NumRows=%d, NumCols=%d", (mTraceObject), aDamperId, aNumRows, aNumCols);
   err = DoSetDamper( aDamperId, pValues, aNumRows, aNumCols);
   if(err!=DAMPER_OK)
   {
      DBGT_ERROR("[%s] failed to set damper: err=%d\n", SHARPENING_DAMPER_LR_NAME(aDamperId), err);
      OstTraceFiltStatic2(TRACE_ERROR, "SHARPENING_DAMPER_LR_NAME(%d) failed to set damper: err=%d", (mTraceObject), aDamperId, err);
      OUTR(" ",err);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CSharpeningDamperLR::SetDamper (%d)", (mTraceObject), err);
      return err;
   }
   OUTR(" ",DAMPER_OK);
   OstTraceFiltStatic1(TRACE_FLOW, "Exit CSharpeningDamperLR::SetDamper (%d)", (mTraceObject), DAMPER_OK);
   return DAMPER_OK;
}
Example #20
0
camSharedMemError_t CCamSharedMemory::cacheInvalidate(camSharedMemChunkId_t chunkId)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CCamSharedMemory::cacheInvalidate", (mTraceObject));
    if (state != CCamSharedMemory::CAM_SHARED_MEM_STATE_OPEN) {
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::cacheInvalidate (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_BAD_STATE);
        return CAM_SHARED_MEM_ERR_BAD_STATE;
    }
    if (chunkId >= CAM_SHARED_MEM_CHUNK_MAX) {
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::cacheInvalidate (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_BAD_PARAMETER);
        return CAM_SHARED_MEM_ERR_BAD_PARAMETER;
    }
    if (! abBusyChunks[chunkId]) {
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::cacheInvalidate (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_BAD_PRECONDITION);
        return CAM_SHARED_MEM_ERR_BAD_PRECONDITION;
    }
    // Flush the data that have been written by the ISP FW
    OMX_U32 aPhysAddr; // out
    OMX_ERRORTYPE e_ret = sharedBufferPoolId->CacheSync(MMHwBuffer::ESyncAfterWriteHwOperation,
            (OMX_U32) aChunks[chunkId].armLogicalAddress,
            aChunks[chunkId].size, aPhysAddr);
    if (e_ret != OMX_ErrorNone) {
        MSG1("Problem invalidating data cache (err=%d)\n", e_ret);
        OstTraceFiltStatic1(TRACE_DEBUG, "Problem invalidating data cache (err=%d)", (mTraceObject), e_ret);
        OUT0("\n");
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::cacheInvalidate (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_NO_RESOURCE);
        return CAM_SHARED_MEM_ERR_NO_RESOURCE;
    }
    OUT0("\n");
    OstTraceFiltStatic1(TRACE_FLOW, "Exit CCamSharedMemory::cacheInvalidate (%d)", (mTraceObject), CAM_SHARED_MEM_ERR_NONE);
    return CAM_SHARED_MEM_ERR_NONE;
}
/*
 * This function computes the dampers and queues the Page Elements
 */
t_damper_error_code CDefCorDamper::ComputeAndQueuePEs( CIspctlCom*                 pIspctlCom,
                                                       const t_damper_base_values* pBaseValues)
{
   IN0("\n");
   OstTraceFiltStatic0(TRACE_FLOW, "Entry CDefCorDamper::ComputeAndQueuePEs", (mTraceObject));
   float pDamperValues[DEFCOR_DAMPERS_NUM] = {0.0, 0.0};
   t_damper_error_code err = DAMPER_OK;

   // Evaluate DefCor dampers
   err = DoEvaluate( pBaseValues, pDamperValues);
   if(err!=DAMPER_OK)
   {
      DBGT_ERROR("Evaluation failed: err=%d\n", err);
      OstTraceFiltStatic1(TRACE_ERROR, "Evaluation failed: err=%d", (mTraceObject), err);
      OUTR(" ",err);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CDefCorDamper::ComputeAndQueuePEs (%d)", (mTraceObject), err);
      return err;
   }

   // Queue the Page Elements
   for(int i=0; i<DEFCOR_DAMPERS_NUM; i++)
   {
      MSG2("%s = %f\n", CIspctlCom::pIspctlSensor->GetPeName(KDefCorDamperInfo[i].addr), pDamperValues[i]);
      //OstTraceFiltStatic2(TRACE_DEBUG, "%s = %f", (mTraceObject), CXp70::GetPeName(KDefCorDamperInfo[i].addr), pDamperValues[i]);
      pIspctlCom->queuePE( KDefCorDamperInfo[i].addr, (t_uint32)pDamperValues[i]);
   }

   // Done
   OUTR(" ",DAMPER_OK);
   OstTraceFiltStatic1(TRACE_FLOW, "Exit CDefCorDamper::ComputeAndQueuePEs (%d)", (mTraceObject), DAMPER_OK);
   return DAMPER_OK;
}
/*
 * This function sets the DefCor dampers
 */
t_damper_error_code CDefCorDamper::SetDamper( const t_defcor_damper_id aDamperId,
                                              const float*             pValues,
                                              const int                aNumRows,
                                              const int                aNumCols)
{
   IN0("\n");
   OstTraceFiltStatic0(TRACE_FLOW, "Entry CDefCorDamper::SetDamper", (mTraceObject));
   t_damper_error_code err = DAMPER_OK;
   if(aDamperId<0 || aDamperId>=DEFCOR_DAMPERS_NUM)
   {
      DBGT_ERROR("Invalid damper Id: %d\n", aDamperId);
      OstTraceFiltStatic1(TRACE_ERROR, "Invalid damper Id: %d", (mTraceObject), aDamperId);
      OUTR(" ",DAMPER_INVALID_ARGUMENT);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CDefCorDamper::SetDamper (%d)", (mTraceObject), DAMPER_INVALID_ARGUMENT);
      return DAMPER_INVALID_ARGUMENT;
   }
   MSG3("[%s] NumRows=%d, NumCols=%d\n", KDefCorDamperInfo[aDamperId].name, aNumRows, aNumCols);
   OstTraceFiltStatic3(TRACE_DEBUG, "[KDefCorDamperInfo[%d].name] NumRows=%d, NumCols=%d", (mTraceObject), aDamperId, aNumRows, aNumCols);
   err = DoSetDamper( aDamperId, pValues, aNumRows, aNumCols);
   if(err!=DAMPER_OK)
   {
      DBGT_ERROR("[%s] failed to set damper: err=%d\n", KDefCorDamperInfo[aDamperId].name, err);
      OstTraceFiltStatic2(TRACE_ERROR, "[KDefCorDamperInfo[%d].name] failed to set damper: err=%d", (mTraceObject), aDamperId, err);
      OUTR(" ",err);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CDefCorDamper::SetDamper (%d)", (mTraceObject), err);
      return err;
   }
   OUTR(" ",DAMPER_OK);
   OstTraceFiltStatic1(TRACE_FLOW, "Exit CDefCorDamper::SetDamper (%d)", (mTraceObject), DAMPER_OK);
   return DAMPER_OK;
}
cam_flash_err_e CFlashController::unConfigure()
{
    IN0("\n");
   if (mFlashDriver == NULL) {
        DBGT_ERROR("unConfigure: No valid flash driver.\n");
        OstTraceFiltStatic0(TRACE_ERROR, "unConfigure: No valid flash driver.", (mTraceObject));
        DBC_ASSERT(0);
        OUT0("\n");
        return CAM_FLASH_ERR_BAD_PRECONDITION;
    }
    if (mDriverSupportedFlashModes == 0)
    {
        OUT0("\n");
        return CAM_FLASH_ERR_NONE;
    }
    TFlashReturnCode driver_err = FLASH_RET_NONE;

    // User-controlled modes: switch off
    if ((FLASH_MODE_INDICATOR    == mFlashDriverMode)
     || (FLASH_MODE_AF_ASSISTANT == mFlashDriverMode)
     || (FLASH_MODE_VIDEO_LED    == mFlashDriverMode))
    {
        driver_err = mFlashDriver->Strobe(mFlashDriverMode, false, mFlashDriverCamId);
        if (driver_err != FLASH_RET_NONE) {
            DBGT_ERROR("unConfigure: Strobe error;\n");
            OstTraceFiltStatic0(TRACE_ERROR, "unConfigure: Strobe error;", (mTraceObject));
	    OUT0("\n");
            return CAM_FLASH_ERR_DRIVER;
        }
    }

    // Any mode: un-configure
    if (FLASH_MODE_NONE != mFlashDriver)
    {
        driver_err = mFlashDriver->EnableFlashMode(FLASH_MODE_NONE, NULL, NULL, mFlashDriverCamId);
        if (driver_err != FLASH_RET_NONE)
        {
            DBGT_ERROR("unConfigure: EnableFlashMode error;\n");
            OstTraceFiltStatic0(TRACE_ERROR, "unConfigure: EnableFlashMode error;", (mTraceObject));
	    OUT0("\n");
            return CAM_FLASH_ERR_DRIVER;
        }
        mFlashDriverMode = FLASH_MODE_NONE;
    }
    OUT0("\n");
    return CAM_FLASH_ERR_NONE;
}
/*Stop low power timer */
void CAM_SM::stopLowPowerTimer()
{
    MSG0("Stop LowPower timer\n");
    OstTraceFiltStatic0(TRACE_DEBUG, "Stop LowPower timer", (&mENSComponent));
    Camera* Cam = (Camera*)&mENSComponent.getProcessingComponent();
    Cam->iCheckTimerRunning = false;
    Cam->iNbLowPowerInterval500Msec=0;
}
/*Start low power timer */
void CAM_SM::startLowPowerTimer()
{
    MSG0("Start LowPower timer\n");
    OstTraceFiltStatic0(TRACE_DEBUG, "Start LowPower timer", (&mENSComponent));
    bLowPower = FALSE;		
    Camera* Cam = (Camera*)&mENSComponent.getProcessingComponent();
    Cam->iCheckTimerRunning = true;

}
/*
 * This function stops NMF
 */
TuningLoaderMgrError_t CTuningLoaderManager::stop()
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::stop", (mTraceObject));
    if(iNmfInstance == NULL) {
        MSG0("NMF instance not constructed\n");
        OstTraceFiltStatic0(TRACE_ERROR, "NMF instance not constructed", (mTraceObject));
        OUTR(" ",TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::stop (%d)", (mTraceObject), TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        return TUNING_LOADER_MGR_NOT_CONSTRUCTED;
    }
    MSG0("Stopping NMF component\n");
    OstTraceFiltStatic0(TRACE_DEBUG, "Stopping NMF component", (mTraceObject));
    iNmfInstance->stop_flush();
    OUTR(" ",TUNING_LOADER_MGR_OK);
    OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::stop (%d)", (mTraceObject), TUNING_LOADER_MGR_OK);
    return TUNING_LOADER_MGR_OK;
}
Example #27
0
/*
 * This function computes the dampers and queues the Page Elements
 */
t_damper_error_code CSharpeningDamperLR::ComputeAndQueuePEs( CIspctlCom*                 pIspctlCom,
                                                             const t_damper_base_values* pBaseValues)
{
   IN0("\n");
   OstTraceFiltStatic0(TRACE_FLOW, "Entry CSharpeningDamperLR::ComputeAndQueuePEs", (mTraceObject));
   float pDamperValues[SHARPENING_DAMPERS_LR_NUM] = { 0.0, 0.0};
   t_damper_error_code err = DAMPER_OK;
   float fAdsocGain = 0.0;
   float fAdsocCoring = 0.0;
   float fScaleFactor = 0.0;

   // Evaluate Sharpening dampers
   err = DoEvaluate( pBaseValues, pDamperValues);
   if(err!=DAMPER_OK)
   {
      DBGT_ERROR("Evaluation failed: err=%d\n", err);
      OstTraceFiltStatic1(TRACE_ERROR, "Evaluation failed: err=%d", (mTraceObject), err);
      OUTR(" ",err);
      OstTraceFiltStatic1(TRACE_FLOW, "Exit CSharpeningDamperLR::ComputeAndQueuePEs (%d)", (mTraceObject), err);
      return err;
   }

   // Compute and queue Adsoc Gain PE (scale against omx config and clip value)
   fAdsocGain = pDamperValues[SHARPENING_ADSOC_GAIN_LR];
   fScaleFactor = (float)iOmxSharpness * iScaleFactorGain + iScaleFactorOffset;
   MSG1("Scale Factor = %f\n", fScaleFactor);
   OstTraceFiltStatic1(TRACE_DEBUG, "Scale Factor = %f", (mTraceObject), fScaleFactor);
   fAdsocGain *= fScaleFactor;
   if( fAdsocGain < 0.0) {
      fAdsocGain = 0.0;
   }
   else if ( fAdsocGain > 255.0 ) {
      fAdsocGain = 255.0;
   }
   MSG2("%s = %f\n", CIspctlCom::pIspctlSensor->GetPeName(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Gain_Byte0), fAdsocGain);
   OstTraceFiltStatic1(TRACE_DEBUG, "Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Gain = %f", (mTraceObject), fAdsocGain);
   pIspctlCom->queuePE( Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Gain_Byte0, (t_uint32)fAdsocGain);

   // Compute and queue Adsoc Coring PE
   fAdsocCoring = pDamperValues[SHARPENING_ADSOC_CORING_LR];
   if( fAdsocCoring < 0.0) {
      fAdsocCoring = 0.0;
   }
   else if ( fAdsocCoring > 31.0 ) {
      fAdsocCoring = 31.0;
   }
   MSG2("%s = %f\n", CIspctlCom::pIspctlSensor->GetPeName(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Coring_Level_Byte0), fAdsocCoring);
   OstTraceFiltStatic1(TRACE_DEBUG, "Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Coring_Level = %f", (mTraceObject), fAdsocCoring);
   pIspctlCom->queuePE( Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Coring_Level_Byte0, (t_uint32)fAdsocCoring);

   // Done
   OUTR(" ",DAMPER_OK);
   OstTraceFiltStatic1(TRACE_FLOW, "Exit CSharpeningDamperLR::ComputeAndQueuePEs (%d)", (mTraceObject), DAMPER_OK);
   return DAMPER_OK;
}
SCF_STATE CAM_SM::ExecutingToIdle(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:
        {
            MSG0("ExecutingToIdle-SCF_STATE_INIT\n");
            OstTraceFiltStatic0(TRACE_DEBUG, "ExecutingToIdle-SCF_STATE_INIT", (&mENSComponent));
            cam_flash_err_e cam_err = p3AComponentManager->mFlashController.unConfigure();
            if (cam_err != CAM_FLASH_ERR_NONE) {
                DBGT_ERROR("Error: Could not un-configure the flash driver.\n");
                OstTraceFiltStatic0(TRACE_ERROR, "Error: Could not un-configure the flash driver.", (&mENSComponent));
                DBC_ASSERT(0);
            }

            if (bLowPower){
                ControlingISP_ControlType = ControlingISP_SendWakeUp_WaitIspWorkenUp_SendIdle;
                bLowPower = FALSE;
				SM_PUSH_STATE_STATIC(&CAM_SM::ExecutingToIdle_3);	
            }
            else {
                ControlingISP_ControlType = ControlingISP_SendStop_WaitIspSensorStopStreaming_SendIdle_Stop3A;
		  		SM_PUSH_STATE_STATIC(&CAM_SM::RendezvousState);
		  		DBC_ASSERT(p3AComponentManager->whatNextAfterRendezvous== NULL); 
	        	p3AComponentManager->whatNextAfterRendezvous= SCF_STATE_PTR(&CAM_SM::ExecutingToIdle_3);	
            }

		SCF_TRANSIT_TO(&CAM_SM::SHARED_ControlingISPState);
	     
            return 0;
        }
        case Q_DEFERRED_EVENT_SIG:
        {
            MSG0("ExecutingToIdle-Q_DEFERRED_EVENT\n");
            OstTraceFiltStatic0(TRACE_DEBUG, "ExecutingToIdle-Q_DEFERRED_EVENT", (&mENSComponent));
            return 0;
        }
        default: break;
    }
    return SCF_STATE_PTR(&CAM_SM::EnteringOpMode);
}
/*
 * This function get the config file name of the flash
 */
TuningLoaderMgrError_t CTuningLoaderManager::getFlashConfigFileName(const char** pFlashCfgFileName)
{
    IN0("\n");
    OstTraceFiltStatic0(TRACE_FLOW, "Entry CTuningLoaderManager::getFlashConfigFileName", (mTraceObject));

    // Check if constructed
    if(iNmfInstance == NULL) {
        MSG0("Instance not constructed\n");
        OstTraceFiltStatic0(TRACE_ERROR, "Instance not constructed", (mTraceObject));
        OUTR(" ",TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::getFlashConfigFileName (%d)", (mTraceObject), TUNING_LOADER_MGR_NOT_CONSTRUCTED);
        return TUNING_LOADER_MGR_NOT_CONSTRUCTED;
    }

    // Ask file name to NMF component
    *pFlashCfgFileName = iNmfSyncIntf.flashConfigFileName();

    OUTR(" ",TUNING_LOADER_MGR_OK);
    OstTraceFiltStatic1(TRACE_FLOW, "Exit CTuningLoaderManager::getFlashConfigFileName (%d)", (mTraceObject), TUNING_LOADER_MGR_OK);
    return TUNING_LOADER_MGR_OK;
}
void main(void)
{
    // Test All GROUPS
    OstTraceInt0 (TRACE_ERROR,  			"ST_OSTTC_TEST2 TRACE_ERROR: 				OstTraceInt0");
    OstTraceInt0 (TRACE_WARNING,  		"ST_OSTTC_TEST2 TRACE_WARNING: 			OstTraceInt0");
    OstTraceInt0 (TRACE_FLOW,  				"ST_OSTTC_TEST2 TRACE_FLOW:  				OstTraceInt0");
    OstTraceInt0 (TRACE_DEBUG,  			"ST_OSTTC_TEST2 TRACE_DEBUG:  				OstTraceInt0");
    OstTraceInt0 (TRACE_API,  				"ST_OSTTC_TEST2 TRACE_API:  					OstTraceInt0");
    OstTraceInt0 (TRACE_OMX_API,  		"ST_OSTTC_TEST2 TRACE_OMX_API: 			OstTraceInt0");
    OstTraceInt0 (TRACE_OMX_BUFFER, 	"ST_OSTTC_TEST2 TRACE_OMX_BUFFER: 		OstTraceInt0");
    OstTraceInt0 (TRACE_RESERVED, 		"ST_OSTTC_TEST2 TRACE_OMX_RESERVED: 	OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_0, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_0: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_1, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_1: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_2, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_2: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_3, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_3: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_4, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_4: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_5, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_5: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_6, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_6: 		OstTraceInt0");
    OstTraceInt0 (TRACE_MY_GROUP_7, 	"ST_OSTTC_TEST2 TRACE_MY_GROUP_7: 		OstTraceInt0");

    // Test OstTraceIntx API
    OstTraceInt1 (TRACE_ERROR,  			"ST_OSTTC_TEST2 TRACE_ERROR: 				OstTraceInt1: %d", test);
    OstTraceInt2 (TRACE_WARNING,  		"ST_OSTTC_TEST2 TRACE_WARNING: 			OstTraceInt2: %d %d", test, test);
    OstTraceInt3 (TRACE_MY_GROUP_6,  	"ST_OSTTC_TEST2 TRACE_MY_GROUP_6: 		OstTraceInt3: %d %d %d", test, test, test);
    OstTraceInt4 (TRACE_MY_GROUP_7,  	"ST_OSTTC_TEST2 TRACE_MY_GROUP_7: 		OstTraceInt4: %d %d %d %d", test, test, test, test);

    // Test OstTraceFiltStaticx API
    OstTraceFiltInst0 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic0:");
    OstTraceFiltInst1 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic1	: %d", test);
    OstTraceFiltInst2 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic2	: %d %d", test, test);
    OstTraceFiltInst3 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic3	: %d %d %d", test, test, test);
    OstTraceFiltInst4 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic4	: %d %d %d %d", test, test, test, test);

    // Test OstTraceFiltStaticx API
    OstTraceFiltStatic0 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic0:");
    OstTraceFiltStatic1 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic1	: %d", test);
    OstTraceFiltStatic2 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic2	: %d %d", test, test);
    OstTraceFiltStatic3 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic3	: %d %d %d", test, test, test);
    OstTraceFiltStatic4 (TRACE_OMX_API,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltStatic4	: %d %d %d %d", test, test, test, test);

    // Test trace Buffer API
    OstTraceArray (TRACE_RESERVED,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceArray %{int8[]}", ptr, size);
    OstTraceFiltInstData(TRACE_RESERVED,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltInstData %{int8[]}", ptr, size);
    OstTraceFiltStaticData(TRACE_RESERVED,  "ST_OSTTC_TEST2 TRACE_OMX_API: 	OstTraceFiltInstData %{int8[]}",aInstPtr, ptr, size);

    // Check Syntax ALL below syntax shall be parsed
    OstTraceInt0 (TRACE_ERROR,  			"ST_OSTTC_TEST2 TRACE_ERROR: 				OstTraceInt0");
    OstTraceInt0 ( TRACE_ERROR ,  		"ST_OSTTC_TEST2 TRACE_ERROR: 				OstTraceInt0");


}