MVOID
IspTuningCustom::
prepare_effect<MEFFECT_NEGATIVE>(ISP_EFFECT_T& rEffect)
{
    MY_LOG("[+prepare_effect] MEFFECT_NEGATIVE");
    //--------------------------------------------------------------------------
    //  Reference.
    ISP_EFFECT_YCCGO_T& rYCCGO = rEffect.yccgo;
    ISP_EFFECT_EDGE_T&  rEdge  = rEffect.edge;
    ISP_EFFECT_CCM_T&   rCCM   = rEffect.ccm;
    //--------------------------------------------------------------------------
    //  TODO:
    //  Begin your setting.
    //
    //  EDGE
    rEdge.cpscon2.bits.OPRGM_IVT = 1;

}
MVOID
IspTuningCustom::
prepare_effect<MEFFECT_AQUA>(ISP_EFFECT_T& rEffect)
{
    MY_LOG("[+prepare_effect] MEFFECT_AQUA");
    //--------------------------------------------------------------------------
    //  Reference.
    ISP_EFFECT_YCCGO_T& rYCCGO = rEffect.yccgo;
    ISP_EFFECT_EDGE_T&  rEdge  = rEffect.edge;
    ISP_EFFECT_CCM_T&   rCCM   = rEffect.ccm;
    //--------------------------------------------------------------------------
    //  TODO:
    //  Begin your setting.
    //
    //  YCCGO
    rYCCGO.ctrl.val         = 0;
    rYCCGO.ctrl.bits.ENC1   = 1;
    rYCCGO.cfg1.bits.MU     = 216;
    rYCCGO.cfg1.bits.MV     = 98;

}
Example #3
0
CctImp::~CctImp()
{
    MY_LOG("[~CCTIF] E\n");

    if (m_pSensorHalObj) {
        m_pSensorHalObj->destroyInstance();
        m_pSensorHalObj = NULL;
    }

    if  (m_pCctCtrl )
    {
        m_pCctCtrl->destroyInstance();
        m_pCctCtrl = NULL;
    }
    
    if(m_cctctrl_prop.isp_prop.m_pispdrv)
    {
        m_cctctrl_prop.isp_prop.m_pispdrv->uninit();       
    }

}
Example #4
0
ISP_MGR_LCE_T &
ISP_MGR_LCE_T::
put(ISP_NVRAM_LCE_T const &rParam)
{    
    //MY_LOG("rParam.qua.val = x%08x", rParam.qua.val);
    
    PUT_REG_INFO(CAM_LCE_QUA, qua);

    //MY_LOG("m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val = 0x%8x", m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val);

    mLceWeakest  = m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val & 0x01F;
    mLceStrogest = (m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val & 0x3E0) >> 5;
    mLvLowBound  = (m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val & 0x1FFC00) >> 10;
    mLvUpBound   = (m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val & 0xFFE00000) >> 21;

#if (LCE_DEBUG)
    MY_LOG("[%s] QUA(0x%08x),lceIdx(%u,%u),LV(%u,%u)",__func__,m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val,mLceWeakest,mLceStrogest,mLvLowBound,mLvUpBound);
#else
    MY_LOG_IF(g_lceDebug,"[%s] QUA(0x%08x),lceIdx(%u,%u),LV(%u,%u)",__func__,m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val,mLceWeakest,mLceStrogest,mLvLowBound,mLvUpBound);
#endif

    return  (*this);
}
MVOID
IspTuningCustom::
prepare_effect<MEFFECT_WHITEBOARD>(ISP_EFFECT_T& rEffect)
{
    MY_LOG("[+prepare_effect] MEFFECT_WHITEBOARD");
    //--------------------------------------------------------------------------
    //  Reference.
    ISP_EFFECT_YCCGO_T& rYCCGO = rEffect.yccgo;
    ISP_EFFECT_EDGE_T&  rEdge  = rEffect.edge;
    ISP_EFFECT_CCM_T&   rCCM   = rEffect.ccm;
    //--------------------------------------------------------------------------
    //  TODO:
    //  Begin your setting.
    //
    //  TODO:
    //  Begin your setting.
    //
    //  CCM
    rCCM.ccm1.val = 0x00000000;
    rCCM.ccm2.val = 0x00000000;
    rCCM.ccm3.val = 0x00000000;
    rCCM.ccm4.val = 0x00000000;
    rCCM.ccm5.val = 0x00000000;

    //
    //  YCCGO
    rYCCGO.ctrl.val         = 0;
    rYCCGO.ctrl.bits.ENC2   = 1;
    rYCCGO.cfg1.bits.H12    = 0;
    rYCCGO.cfg1.bits.H11    = 0;
    //
    //  EDGE
    rEdge.ed_ctrl.val               = 0x00000122;
    rEdge.ed_inter1.val             = 0x08000810;
    rEdge.ed_inter2.val             = 0x00000414;
    rEdge.ed_inter2.bits.THRE_LEDGE = 127;

    rEdge.edgcore.bits.SPECIAL_EN   = 1;
    rEdge.edgcore.bits.EMBOSS2_EN   = 1;
    rEdge.edgcore.bits.EMBOSS1_EN   = 1;    //
    rEdge.edgcore.bits.COREH        = 0;

    rEdge.edggain1.bits.EGAINLINE   = 0;    //
    rEdge.edggain1.bits.KNEESEL     = 3;
    rEdge.edggain1.bits.OILEN       = 0;    //
    rEdge.edggain1.bits.EGAIN_VB    = 31;
    rEdge.edggain1.bits.EGAIN_H2    = 31;
    rEdge.edggain1.bits.EGAIN_H     = 0;    //
    rEdge.edggain1.bits.SPECIPONLY  = 1;    //
    rEdge.edggain1.bits.SPECIGAIN   = 0;    //

    rEdge.edggain2.bits.SPECIINV    = 0;    //
    rEdge.edggain2.bits.SPECIABS    = 0;    //

    rEdge.edgvcon.bits.E_TH1_V      = 4;    //

    rEdge.cpscon2.bits.Y_EGAIN      = 15;   //
    rEdge.cpscon2.bits.OPRGM_IVT    = 1;    //  //

    rEdge.ee_ctrl.bits.YEDGE_EN     = 1;    //
    rEdge.ee_ctrl.bits.RGBEDGE_EN   = 1;

}
MINT32 CctImp::aaaCCTFeatureControl(MUINT32 a_u4Ioctl,
                                    MUINT8 *puParaIn ,
                                    MUINT32 u4ParaInLen,
                                    MUINT8 *puParaOut,
                                    MUINT32 u4ParaOutLen,
                                    MUINT32 *pu4RealParaOutLen
)
{

    MINT32 err = CCTIF_NO_ERROR;
    MINT32 *i32In = (MINT32 *)puParaIn;
    MUINT32 *u32In = (MUINT32 *)puParaIn;

    switch (a_u4Ioctl)
    {
    // AE
    case ACDK_CCT_OP_AE_ENABLE:
        err = NS3A::AeMgr::getInstance().CCTOPAEEnable();
        break;
    case ACDK_CCT_OP_AE_DISABLE:
        err = NS3A::AeMgr::getInstance().CCTOPAEDisable();
        break;
    case ACDK_CCT_OP_AE_GET_ENABLE_INFO:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetEnableInfo((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_DEV_AE_SET_SCENE_MODE:
        err = NS3A::AeMgr::getInstance().CCTOPAESetAEMode(*i32In);
        break;
    case ACDK_CCT_OP_DEV_AE_GET_INFO:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetNVRAMParam((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AE_GET_SCENE_MODE:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetAEMode((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AE_SET_METERING_MODE:
        err = NS3A::AeMgr::getInstance().CCTOPAESetMeteringMode(*i32In);
        break;
    case ACDK_CCT_V2_OP_AE_APPLY_EXPO_INFO:
        err = NS3A::AeMgr::getInstance().CCTOPAEApplyExpParam((VOID *)puParaIn);
        break;
    case ACDK_CCT_V2_OP_AE_SELECT_BAND:
        err = NS3A::AeMgr::getInstance().CCTOPAESetFlickerMode(*i32In);
        break;
    case ACDK_CCT_V2_OP_AE_GET_AUTO_EXPO_PARA:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetExpParam((VOID *)puParaIn, (VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AE_GET_BAND:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetFlickerMode((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AE_GET_METERING_RESULT:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetMeteringMode((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_DEV_AE_APPLY_INFO:
        err = NS3A::AeMgr::getInstance().CCTOPAEApplyNVRAMParam((VOID *)puParaIn);
        break;
    case ACDK_CCT_OP_DEV_AE_SAVE_INFO_NVRAM:
        err = NS3A::AeMgr::getInstance().CCTOPAESaveNVRAMParam();
        break;
    case ACDK_CCT_OP_DEV_AE_GET_EV_CALIBRATION:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetCurrentEV((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_AE_LOCK_EXPOSURE_SETTING:
        err = NS3A::AeMgr::getInstance().CCTOPAELockExpSetting();
        break;
    case ACDK_CCT_OP_AE_UNLOCK_EXPOSURE_SETTING:
        err = NS3A::AeMgr::getInstance().CCTOPAEUnLockExpSetting();
        break;
    case ACDK_CCT_OP_AE_GET_ISP_OB:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetIspOB((MUINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_AE_SET_ISP_OB:
        err = NS3A::AeMgr::getInstance().CCTOPAESetIspOB(*u32In);
        break;
    case ACDK_CCT_OP_AE_GET_ISP_RAW_GAIN:
        err = NS3A::AeMgr::getInstance().CCTOPAEGetIspRAWGain((MUINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_AE_SET_ISP_RAW_GAIN:
        err = NS3A::AeMgr::getInstance().CCTOPAESetIspRAWGain(*u32In);
        break;
    case ACDK_CCT_OP_AE_SET_SENSOR_EXP_TIME:
        err = NS3A::AeMgr::getInstance().CCTOPAESetSensorExpTime(*u32In);
        break;
    case ACDK_CCT_OP_AE_SET_SENSOR_EXP_LINE:
        err = NS3A::AeMgr::getInstance().CCTOPAESetSensorExpLine(*u32In);
        break;
    case ACDK_CCT_OP_AE_SET_SENSOR_GAIN:
        err = NS3A::AeMgr::getInstance().CCTOPAESetSensorGain(*u32In);
        break;
    case ACDK_CCT_OP_AE_CAPTURE_MODE:
        err = NS3A::AeMgr::getInstance().CCTOPAESetCaptureMode(*u32In);
    	 break;
    case ACDK_CCT_OP_AE_GET_CAPTURE_PARA:
        err = NS3A::AeMgr::getInstance().CCTOGetCaptureParams((VOID *)puParaOut);
    	 break;
    case ACDK_CCT_OP_AE_SET_CAPTURE_PARA:
        err = NS3A::AeMgr::getInstance().CCTOSetCaptureParams((VOID *)puParaIn);
    	 break;

    // AWB
    case ACDK_CCT_V2_OP_AWB_ENABLE_AUTO_RUN:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBEnable();
        break;
    case ACDK_CCT_V2_OP_AWB_DISABLE_AUTO_RUN:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBDisable();
        break;
    case ACDK_CCT_V2_OP_AWB_GET_AUTO_RUN_INFO:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBGetEnableInfo((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AWB_GET_GAIN:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBGetAWBGain((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AWB_SET_GAIN:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBSetAWBGain((VOID *)puParaIn);
        break;
    case ACDK_CCT_V2_OP_AWB_APPLY_CAMERA_PARA2:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBApplyNVRAMParam((VOID *)puParaIn);
        break;
    case ACDK_CCT_V2_OP_AWB_GET_AWB_PARA:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBGetNVRAMParam((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AWB_SAVE_AWB_PARA:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBSaveNVRAMParam();
        break;
    case ACDK_CCT_OP_AWB_SET_AWB_MODE:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBSetAWBMode(*i32In);
        break;
    case ACDK_CCT_OP_AWB_GET_AWB_MODE:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBGetAWBMode((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_AWB_GET_LIGHT_PROB:
        err = NS3A::AwbMgr::getInstance().CCTOPAWBGetLightProb((VOID *)puParaOut, pu4RealParaOutLen);
        break;

    // AF
    case ACDK_CCT_V2_OP_AF_OPERATION:
        err = NS3A::AfMgr::getInstance().CCTOPAFOpeartion();
        break;
    case ACDK_CCT_V2_OP_MF_OPERATION:
        err = NS3A::AfMgr::getInstance().CCTOPMFOpeartion(*i32In);
        break;
    case ACDK_CCT_V2_OP_GET_AF_INFO:
        err = NS3A::AfMgr::getInstance().CCTOPAFGetAFInfo((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AF_GET_BEST_POS:
        err = NS3A::AfMgr::getInstance().CCTOPAFGetBestPos((MINT32 *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AF_CALI_OPERATION:
        err = NS3A::AfMgr::getInstance().CCTOPAFCaliOperation((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AF_SET_RANGE:
        err = NS3A::AfMgr::getInstance().CCTOPAFSetFocusRange((VOID *)puParaIn);
        break;
    case ACDK_CCT_V2_OP_AF_GET_RANGE:
        err = NS3A::AfMgr::getInstance().CCTOPAFGetFocusRange((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AF_SAVE_TO_NVRAM:
        err = NS3A::AfMgr::getInstance().CCTOPAFSaveNVRAMParam();
        break;
    case ACDK_CCT_V2_OP_AF_READ:
        err = NS3A::AfMgr::getInstance().CCTOPAFGetNVRAMParam((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_V2_OP_AF_APPLY:
        err = NS3A::AfMgr::getInstance().CCTOPAFApplyNVRAMParam((VOID *)puParaIn);
        break;
    case ACDK_CCT_V2_OP_AF_GET_FV:
        err = NS3A::AfMgr::getInstance().CCTOPAFGetFV((VOID *)puParaIn, (VOID *)puParaOut, pu4RealParaOutLen);
        break;
    case ACDK_CCT_OP_AF_ENABLE:
        err = NS3A::AfMgr::getInstance().CCTOPAFEnable();
        break;
    case ACDK_CCT_OP_AF_DISABLE:
        err = NS3A::AfMgr::getInstance().CCTOPAFDisable();
        break;
    case ACDK_CCT_OP_AF_GET_ENABLE_INFO:
        err = NS3A::AfMgr::getInstance().CCTOPAFGetEnableInfo((VOID *)puParaOut, pu4RealParaOutLen);
        break;
    //----------------------------
    // flash
    case ACDK_CCT_OP_FLASH_GET_INFO:
    	MY_LOG("ACDK_CCT_OP_FLASH_GET_INFO line=%d\n",__LINE__);
    	err = FlashMgr::getInstance()->cctGetFlashInfo(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
        break;


    case ACDK_CCT_OP_FLASH_CONTROL:
    	err = FlashMgr::getInstance()->cctFlashLightTest((VOID *)puParaIn);
        break;
   	case ACDK_CCT_OP_FLASH_ENABLE:
   		err = FlashMgr::getInstance()->cctFlashEnable(1);
        break;
    case ACDK_CCT_OP_FLASH_DISABLE:
   		err = FlashMgr::getInstance()->cctFlashEnable(0);
        break;
    case ACDK_CCT_OP_STROBE_READ_NVRAM:	//5:
    	err = FlashMgr::getInstance()->cctReadNvram(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
    	break;
    case ACDK_CCT_OP_STROBE_WRITE_NVRAM:	//6
    	err = FlashMgr::getInstance()->cctWriteNvram(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
    	break;
    case ACDK_CCT_OP_STROBE_READ_DEFAULT_NVRAM:	//7
    	err = FlashMgr::getInstance()->cctReadDefaultNvram(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
    	break;
	case ACDK_CCT_OP_STROBE_SET_PARAM:	//8
		err = FlashMgr::getInstance()->cctSetParam(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_GET_PARAM:	//9
		err = FlashMgr::getInstance()->cctGetParam(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_GET_NVDATA: //10:
		err = FlashMgr::getInstance()->cctGetNvdata(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_SET_NVDATA: //11:
		err = FlashMgr::getInstance()->cctSetNvdata(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_GET_ENG_Y:	//12:
		err = FlashMgr::getInstance()->cctGetEngY(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_SET_ENG_Y:	//13
		err = FlashMgr::getInstance()->cctSetEngY(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_GET_ENG_RG:	//14
		err = FlashMgr::getInstance()->cctGetEngRg(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_SET_ENG_RG:	//15
		err = FlashMgr::getInstance()->cctSetEngRg(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_GET_ENG_BG:	//16
		err = FlashMgr::getInstance()->cctGetEngBg(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_SET_ENG_BG:	//17
		err = FlashMgr::getInstance()->cctSetEngBg(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_NVDATA_TO_FILE:	//18:
		err = FlashMgr::getInstance()->cctNvdataToFile(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;
	case ACDK_CCT_OP_STROBE_FILE_TO_NVDATA:	//19,
		err = FlashMgr::getInstance()->cctFileToNvdata(puParaIn, u4ParaInLen, puParaOut, u4ParaOutLen, pu4RealParaOutLen);
		break;

    }

    return err;

}
Example #7
0
MBOOL ISP_MGR_LCE_T::apply(EIspProfile_T eIspProfile)
{
    addressErrorCheck("Before ISP_MGR_LCE_T::apply()");
    
    char value[PROPERTY_VALUE_MAX] = {'\0'}; 
    property_get("debug.vhdr.dump", value, "0");
    g_lceDebug = atoi(value);

    ESoftwareScenario eSwScn = static_cast<ESoftwareScenario>(m_rIspDrvScenario[eIspProfile]);
    
#if (LCE_DEBUG)    
    MY_LOG("dev(%d),TG(%d),ispProf(%d),eSwScn(%u),m_bEnable(%u)",m_eSensorDev,m_eSensorTG,eIspProfile,eSwScn,m_bEnable);
#else
    MY_LOG_IF(g_lceDebug, "dev(%d),TG(%d),ispProf(%d),eSwScn(%u),m_bEnable(%u)",m_eSensorDev,m_eSensorTG,eIspProfile,eSwScn,m_bEnable);    
#endif    
            
    //====== Update LCE Tuning Engien ======
    
    TuningMgr::getInstance().updateEngine(eSwScn, eTuningMgrFunc_Lce);

    //====== Register Setting ======    
    
    //> TOP
    
    TUNING_MGR_WRITE_ENABLE_BITS(eSwScn, CAM_CTL_EN_P2, LCE_EN, m_bEnable);

    //> prepar register value

    //CAM_LCE_SLM_SIZE

    MUINT32 lcmSlmSize = 0;

    lcmSlmSize = lcmSlmSize | (mLcsOutHeight << 8) | mLcsOutWidth;
    m_rIspRegInfo[ERegInfo_CAM_LCE_SLM_SIZE].val = lcmSlmSize;   

    //> LCE tuning   

#if 0
    m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val   = mLceQuaReg[8];
    m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_1].val = mLceDgc1Reg[8];
    m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_2].val = mLceDgc2Reg[8];
#else

    #if LCE_ADJUST_METHOD
        updateLceIdx();
        m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val   = mLceQuaReg[mLcsIdx];
        m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_1].val = mLceDgc1Reg[mLcsIdx];
        m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_2].val = mLceDgc2Reg[mLcsIdx];
    #else
        m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val   = mLceQuaReg[mLcsFinalIdx];
        m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_1].val = mLceDgc1Reg[mLcsFinalIdx];
        m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_2].val = mLceDgc2Reg[mLcsFinalIdx];
    #endif
#endif

#if (LCE_DEBUG)

    MY_LOG("(mLcsOutWidth/mLcsOutHeight)=(%u,%u),CAM_LCE_SLM_SIZE(0x%08x)",mLcsOutWidth,mLcsOutHeight,m_rIspRegInfo[ERegInfo_CAM_LCE_SLM_SIZE].val);    
    MY_LOG("CAM_LCE_QUA(0x%08x)",m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val);
    MY_LOG("CAM_LCE_DGC_1(0x%08x)",m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_1].val);
    MY_LOG("CAM_LCE_DGC_2(0x%08x)",m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_2].val);
    MY_LOG("mLcsFinalIdx(%u),mLcsIdx(%u)",mLcsFinalIdx,mLcsIdx); 

#else

    MY_LOG_IF(g_lceDebug, "(LcsOutW/LcsOutH)=(%u,%u),CAM_LCE_SLM_SIZE(0x%08x)",mLcsOutWidth,mLcsOutHeight,m_rIspRegInfo[ERegInfo_CAM_LCE_SLM_SIZE].val);    
    MY_LOG_IF(g_lceDebug, "CAM_LCE_QUA(0x%08x)",m_rIspRegInfo[ERegInfo_CAM_LCE_QUA].val);
    MY_LOG_IF(g_lceDebug, "CAM_LCE_DGC_1(0x%08x)",m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_1].val);
    MY_LOG_IF(g_lceDebug, "CAM_LCE_DGC_2(0x%08x)",m_rIspRegInfo[ERegInfo_CAM_LCE_DGC_2].val);    
    MY_LOG_IF(g_lceDebug, "mLcsFinalIdx(%u),mLcsIdx(%u)",mLcsFinalIdx,mLcsIdx);

#endif

    //> Write to TuningMgr
    TuningMgr::getInstance().tuningMgrWriteRegs(eSwScn, static_cast<TUNING_MGR_REG_IO_STRUCT*>(m_pRegInfo), m_u4RegInfoNum);    

    addressErrorCheck("After ISP_MGR_LCE_T::apply()");
    dumpRegInfo("LCE");

    return  MTRUE;
}
Example #8
0
MVOID ISP_MGR_LCE_T::setLceCurLv(MINT32 aCurLv)
{
#if LCE_ADJUST_METHOD

    if(mAeStableCnt > LCE_ADJUST_AFTER_AE_CNT)
    {
        MY_LOG("[%s] aCurLv(%d),bound(%d,%d),cnt(%u)",__func__,aCurLv,mLvLowBound,mLvUpBound,mAeStableCnt);    
        
        if(aCurLv >= mLvUpBound)
        {
            mLcsFinalIdx = mLceStrogest;
        }
        else if(aCurLv <= mLvLowBound)
        {
            mLcsFinalIdx = mLceWeakest;        
        }
        else
        {
            MFLOAT tempIdx = (((MFLOAT)aCurLv-(MFLOAT)mLvLowBound)/((MFLOAT)mLvUpBound-(MFLOAT)mLvLowBound))*((MFLOAT)mLceStrogest-(MFLOAT)mLceWeakest)+(MFLOAT)mLceWeakest;
            mLcsFinalIdx = 0.5 + tempIdx;
        }

        //> boundary check
        
        if(mLcsFinalIdx > mLceStrogest)
        {
            MY_LOG("[%s] mLcsFinalIdx(%u->%u)",__func__,mLcsFinalIdx,mLceStrogest);
            mLcsFinalIdx = mLceStrogest;
        }
        else if(mLcsFinalIdx < mLceWeakest)
        {
            MY_LOG("[%s] mLcsFinalIdx(%u->%u)",__func__,mLcsFinalIdx,mLceWeakest);
            mLcsFinalIdx = mLceWeakest;
        }
        else
        {
            MY_LOG("[%s] mLcsFinalIdx(%u)",__func__,mLcsFinalIdx);
        } 
    }   

#else

    MY_LOG("[%s] aCurLv(%d),bound(%d,%d)",__func__,aCurLv,mLvLowBound,mLvUpBound);    
        
    if(aCurLv >= mLvUpBound)
    {
        mLcsFinalIdx = mLceStrogest;
    }
    else if(aCurLv <= mLvLowBound)
    {
        mLcsFinalIdx = mLceWeakest;        
    }
    else
    {
        MFLOAT tempIdx = (((MFLOAT)aCurLv-(MFLOAT)mLvLowBound)/((MFLOAT)mLvUpBound-(MFLOAT)mLvLowBound))*((MFLOAT)mLceStrogest-(MFLOAT)mLceWeakest)+(MFLOAT)mLceWeakest;
        mLcsFinalIdx = 0.5 + tempIdx;
    }

    //> boundary check
    
    if(mLcsFinalIdx > mLceStrogest)
    {
        MY_LOG("[%s] mLcsFinalIdx(%u->%u)",__func__,mLcsFinalIdx,mLceStrogest);
        mLcsFinalIdx = mLceStrogest;
    }
    else if(mLcsFinalIdx < mLceWeakest)
    {
        MY_LOG("[%s] mLcsFinalIdx(%u->%u)",__func__,mLcsFinalIdx,mLceWeakest);
        mLcsFinalIdx = mLceWeakest;
    }
    else
    {
        MY_LOG("[%s] mLcsFinalIdx(%u)",__func__,mLcsFinalIdx);
    }
    
#endif
}
Example #9
0
MVOID ISP_MGR_LCE_T::setLceiAddr(MUINT32 addr)
{
    mLceiBaseAddr = addr;
    MY_LOG("[%s]addr(0x%08x),dev(%d),TG(%d)",__func__,mLceiBaseAddr,m_eSensorDev,m_eSensorTG);
}
Example #10
0
MVOID ISP_MGR_LCE_T::setLcsoSize(MUINT32 width, MUINT32 height)
{    
    mLcsOutWidth  = width;
    mLcsOutHeight = height;
    MY_LOG("[%s](W/H)=(%u,%u),dev(%d),TG(%d)",__func__,mLcsOutWidth,mLcsOutHeight,m_eSensorDev,m_eSensorTG);
}
Example #11
0
MVOID ISP_MGR_LCE_T::setLceEnable(MBOOL bEnable)
{
    m_bEnable = bEnable;
    MY_LOG("[%s]en(%d),dev(%d),TG(%d)",__func__,m_bEnable,m_eSensorDev,m_eSensorTG);
}
Example #12
0
MINT32 CctImp::init(MINT32 sensorType)
{
    MUINT32 sen_id;
    MINT32 err = CCTIF_NO_ERROR;
    IspDrv* pisp_drv = m_cctctrl_prop.isp_prop.m_pispdrv;
    NvramDrvBase* pnvram_drv = m_cctctrl_prop.nvram_prop.m_pnvramdrv;
    NSNvram::BufIF<NVRAM_CAMERA_ISP_PARAM_STRUCT>** pbuf_isp = &m_cctctrl_prop.nvram_prop.pbufIf_isp;
    NSNvram::BufIF<NVRAM_CAMERA_SHADING_STRUCT>** pbuf_shd = &m_cctctrl_prop.nvram_prop.pbufIf_shd;
	NSNvram::BufIF<NVRAM_CAMERA_3A_STRUCT>** pbuf_3a = &m_cctctrl_prop.nvram_prop.pbufIf_3a; //Yosen
	NSNvram::BufIF<NVRAM_LENS_PARA_STRUCT>** pbuf_ln = &m_cctctrl_prop.nvram_prop.pbufIf_ln; //Yosen
	


    /*
    *   SENSOR INIT
    */
    mSensorDev = sensorType;
    if(!m_pSensorHalObj) {
        MY_ERR("[CctImp::init] m_pSensorHalObj != NULL before init()\n");
        return -1;
    }

    m_pSensorHalObj->init();
    err = m_pSensorHalObj->sendCommand((halSensorDev_e)sensorType,
                                       SENSOR_CMD_SET_SENSOR_DEV,
                                       0,
                                       0,
                                       0);
    if (err != SENSOR_NO_ERROR) {
        MY_ERR("[CctImp::init] set sensor dev error\n");
        return -1;
    }

    err = m_pSensorHalObj->sendCommand((halSensorDev_e)sensorType, SENSOR_CMD_GET_SENSOR_ID, (MINT32)&sen_id);
	if (err != SENSOR_NO_ERROR) {
        MY_ERR("[CctImp::init] get sensor id error\n");
        return -1;
    }

    m_cctctrl_prop.sen_prop.m_sen_id = sen_id;
    m_cctctrl_prop.sen_prop.m_sen_type = (CAMERA_DUAL_CAMERA_SENSOR_ENUM)sensorType;
	MY_LOG("[CctImp::init] sen_id = %d\n", sen_id); //Yosen
	MY_LOG("[CctImp::init] sensorType = %d\n", sensorType); //Yosen

    /*
    *   ISP INIT
    */
    if(!pisp_drv) {
        MY_ERR("[CctImp::init] m_pispdrv == NULL before init()\n");
        return -1;
    }
    pisp_drv->init();


    /*
    *   NVRAM INIT
    */
    if(!pnvram_drv) {
        MY_ERR("[CctImp::init] pnvram_drv == NULL before init()\n");
        return -1;
    }
    *pbuf_isp = pnvram_drv->getBufIF<NVRAM_CAMERA_ISP_PARAM_STRUCT>();
    *pbuf_shd = pnvram_drv->getBufIF<NVRAM_CAMERA_SHADING_STRUCT>();
	*pbuf_3a = pnvram_drv->getBufIF<NVRAM_CAMERA_3A_STRUCT>(); //Yosen
	*pbuf_ln = pnvram_drv->getBufIF<NVRAM_LENS_PARA_STRUCT>(); //Yosen
	


    /*
    *   CCT CTRL INIT
    */
    m_pCctCtrl = CctCtrl::createInstance(&m_cctctrl_prop);
    if  (!m_pCctCtrl )
    {
        MY_ERR("[CctImp::init] m_pCctCtrl == NULL\n");
        return  -1;
    }

    return  0;

}
MVOID
IspTuningCustom::userSetting_EFFECT(
        RAWIspCamInfo const& rCamInfo,
        EIndex_Effect_T const& eIdx_Effect,
        IspUsrSelectLevel_T const& rIspUsrSelectLevel,
        ISP_NVRAM_G2C_T& rG2C,
        ISP_NVRAM_SE_T& rSE
)
{
	MDOUBLE H_param[] = {-40, 0, 40};				// rotate degree H of 360
	MDOUBLE S_param[] = {44.0/64, 1, 84.0/64};		// gain = S
	MDOUBLE B_param[] = {-16*4, 0, 16*4};			// add B of 256
	MDOUBLE C_param[] = { 54.0/64, 1, 74.0/64};		// gain = C
	MINT32 M00, M01, M02, M10, M11, M12, M20, M21, M22, Yoffset, Uoffset, Voffset;
	MDOUBLE H, S, B, C;
    MINT32 YR,YG, YB, UR, UG, UB, VR, VG, VB, Y_OFFSET11, U_OFFSET10, V_OFFSET10;		// ISP registers for RGB2YUV
    MUINT32 SE_EDGE, SE_Y, SE_Y_CONST, SE_OILEN, SE_KNEESEL, SE_EGAIN_HB, SE_EGAIN_HA,	     \
	        SE_SPECIPONLY, SE_SPECIGAIN, SE_EGAIN_VB, SE_EGAIN_VA, SE_SPECIABS,	SE_SPECIINV, \
	        SE_COREH, SE_E_TH1_V, SE_EMBOSS1, SE_EMBOSS2, SE_YOUT_QBIT, SE_COUT_QBIT;	// ISP registers for SEEE

	M00 = 153;
	M01 = 301;
	M02 = 58;
	M10 = -86;
	M11 = -170;
	M12 = 256;
	M20 = 256;
	M21 = -214;
	M22 = -42;
	Yoffset = 0;
	Uoffset = 0;
	Voffset = 0;

    SE_Y = SE_Y_CONST = SE_OILEN = SE_KNEESEL = SE_EGAIN_HB = SE_EGAIN_HA = \
	SE_SPECIPONLY = SE_SPECIGAIN = SE_EGAIN_VB = SE_EGAIN_VA = SE_SPECIABS = SE_SPECIINV = \
	SE_COREH = SE_E_TH1_V = SE_EMBOSS1 = SE_EMBOSS2 = SE_YOUT_QBIT = SE_COUT_QBIT = 0;

    SE_EDGE = 1;

	MY_LOG("special effect selection : %d\n",eIdx_Effect);
	MY_LOG("input user level : H:%d S:%d B:%d C:%d\n",rIspUsrSelectLevel.eIdx_Hue,
                                                      rIspUsrSelectLevel.eIdx_Sat,
                                                      rIspUsrSelectLevel.eIdx_Bright,
                                                      rIspUsrSelectLevel.eIdx_Contrast);

	switch (eIdx_Effect) {
		case MEFFECT_MONO: // Mono
			M10 = 0;
			M11 = 0;
			M12 = 0;
			M20 = 0;
			M21 = 0;
			M22 = 0;

			//SE_EDGE = 0;

            break;

		case MEFFECT_SEPIA:	// Sepia
			M10 = 0;
			M11 = 0;
			M12 = 0;
			M20 = 0;
			M21 = 0;
			M22 = 0;
			Uoffset = -120; // -72 (Recommend)
			Voffset =  120; //  88 (Recommend)

			//SE_EDGE = 0;

			break;

		case MEFFECT_AQUA: // Aqua
			M10 = 0;
			M11 = 0;
			M12 = 0;
			M20 = 0;
			M21 = 0;
			M22 = 0;
			Uoffset = 352;	//  154 (Recommend)
			Voffset = -120;	// -154 (Recommend)

			//SE_EDGE = 0;

			break;

		case MEFFECT_NEGATIVE: // Negative
			M00 = -M00;
			M01 = -M01;
			M02 = -M02;
			M10 = -M10;
			M11 = -M11;
			M12 = -M12;
			M20 = -M20;
			M21 = -M21;
			M22 = -M22;
			Yoffset = 1023;

			//SE_EDGE = 0;

			break;

		case MEFFECT_POSTERIZE: // Posterize

			M00 = M00*1.6;
			M01 = M01*1.6;
			M02 = M02*1.6;
			M10 = M10*1.6;
			M11 = M11*1.6;
			M12 = M12*1.6;
			M20 = M20*1.6;
			M21 = M21*1.6;
			M22 = M22*1.6;
			Yoffset = Round(-512.0 * 0.6);

			SE_EDGE = 2;
			SE_YOUT_QBIT = 6;
			SE_COUT_QBIT = 5;

			break;

		case MEFFECT_BLACKBOARD: // Blackboard
			M10 = 0;
			M11 = 0;
			M12 = 0;
			M20 = 0;
			M21 = 0;
			M22 = 0;

			SE_Y = 1;
			SE_Y_CONST = 0;
			SE_EDGE = 2;
			SE_OILEN = 1;
			SE_KNEESEL = 3;
			SE_EGAIN_HB = 31;
			SE_EGAIN_HA = 15;
			SE_SPECIPONLY = 1;
			SE_SPECIGAIN = 2;
			SE_EGAIN_VB = 31;
			SE_EGAIN_VA = 15;
			SE_SPECIABS = 0;
			SE_SPECIINV = 0;
			SE_COREH = 0;
			SE_E_TH1_V = 4;
			SE_EMBOSS1 = 1;
			SE_EMBOSS2 = 1;

			break;

		case MEFFECT_WHITEBOARD:		// Whiteboard
			M10 = 0;
			M11 = 0;
			M12 = 0;
			M20 = 0;
			M21 = 0;
			M22 = 0;

			SE_Y_CONST = 255;
			SE_Y = 1;
			SE_EDGE = 2;
			SE_OILEN = 1;
			SE_KNEESEL = 3;
			SE_EGAIN_HB = 31;
			SE_EGAIN_HA = 15;
			SE_SPECIPONLY = 1;
			SE_SPECIGAIN = 2;
			SE_EGAIN_VB = 31;
			SE_EGAIN_VA = 15;
			SE_SPECIABS = 0;
			SE_SPECIINV = 1;
			SE_COREH = 0;
			SE_E_TH1_V = 4;
			SE_EMBOSS1 = 1;
			SE_EMBOSS2 = 1;

			break;

    case MEFFECT_OFF:           //  Do nothing.
    case MEFFECT_SOLARIZE:      //  Unsupport.
    case MEFFECT_SEPIAGREEN:    //  Unsupport.
    case MEFFECT_SEPIABLUE:     //  Unsupport.
    default:
        break;

	}

	H = H_param[rIspUsrSelectLevel.eIdx_Hue] * PI / 180;
	S = S_param[rIspUsrSelectLevel.eIdx_Sat];
	B = B_param[rIspUsrSelectLevel.eIdx_Bright];
	C = C_param[rIspUsrSelectLevel.eIdx_Contrast];

    MY_LOG("H=%f, S=%f, B=%f, C=%f \n",H, S, B, C);

	YR = LIMIT(Round(C * M00), -1023, 1023);
	YG = LIMIT(Round(C * M01), -1023, 1023);
	YB = LIMIT(Round(C * M02), -1023, 1023);
	UR = LIMIT(Round(S * cos(H) * M10 - S * sin(H) * M20), -1023, 1023);
	UG = LIMIT(Round(S * cos(H) * M11 - S * sin(H) * M21), -1023, 1023);
	UB = LIMIT(Round(S * cos(H) * M12 - S * sin(H) * M22), -1023, 1023);
	VR = LIMIT(Round(S * sin(H) * M10 + S * cos(H) * M20), -1023, 1023);
	VG = LIMIT(Round(S * sin(H) * M11 + S * cos(H) * M21), -1023, 1023);
	VB = LIMIT(Round(S * sin(H) * M12 + S * cos(H) * M22), -1023, 1023);

	Y_OFFSET11 = LIMIT(Round(Yoffset + B - 512 * (C-1)), -1023, 1023);
	U_OFFSET10 = LIMIT(Round(Uoffset * S), -511, 511);
	V_OFFSET10 = LIMIT(Round(Voffset * S), -511, 511);

	MY_LOG("YR=%d, YG=%d, YB=%d \n",YR, YG, YB);
	MY_LOG("UR=%d, UG=%d, UB=%d \n",UR, UG, UB);
	MY_LOG("VR=%d, VG=%d, VB=%d \n",VR, VG, VB);
	MY_LOG("Y_OFFSET11=%d, U_OFFSET10=%d, V_OFFSET10=%d \n",Y_OFFSET11, U_OFFSET10, V_OFFSET10);

    // Write back: G2C
    rG2C.conv_0a.bits.G2C_CNV00 = (YR >= 0) ? static_cast<MUINT32>(YR) : static_cast<MUINT32>(2048 + YR);
    rG2C.conv_0a.bits.G2C_CNV01 = (YG >= 0) ? static_cast<MUINT32>(YG) : static_cast<MUINT32>(2048 + YG);
    rG2C.conv_0b.bits.G2C_CNV02 = (YB >= 0) ? static_cast<MUINT32>(YB) : static_cast<MUINT32>(2048 + YB);
    rG2C.conv_0b.bits.G2C_YOFFSET11 = (Y_OFFSET11 >= 0) ? static_cast<MUINT32>(Y_OFFSET11) : static_cast<MUINT32>(2048 + Y_OFFSET11);
    rG2C.conv_1a.bits.G2C_CNV10 = (UR >= 0) ? static_cast<MUINT32>(UR) : static_cast<MUINT32>(2048 + UR);
    rG2C.conv_1a.bits.G2C_CNV11 = (UG >= 0) ? static_cast<MUINT32>(UG) : static_cast<MUINT32>(2048 + UG);
    rG2C.conv_1b.bits.G2C_CNV12 = (UB >= 0) ? static_cast<MUINT32>(UB) : static_cast<MUINT32>(2048 + UB);
    rG2C.conv_1b.bits.G2C_UOFFSET10 = (U_OFFSET10 >= 0) ? static_cast<MUINT32>(U_OFFSET10) : static_cast<MUINT32>(1024 + U_OFFSET10);
    rG2C.conv_2a.bits.G2C_CNV20 = (VR >= 0) ? static_cast<MUINT32>(VR) : static_cast<MUINT32>(2048 + VR);
    rG2C.conv_2a.bits.G2C_CNV21 = (VG >= 0) ? static_cast<MUINT32>(VG) : static_cast<MUINT32>(2048 + VG);
    rG2C.conv_2b.bits.G2C_CNV22 = (VB >= 0) ? static_cast<MUINT32>(VB) : static_cast<MUINT32>(2048 + VB);
    rG2C.conv_2b.bits.G2C_VOFFSET10 = (V_OFFSET10 >= 0) ? static_cast<MUINT32>(V_OFFSET10) : static_cast<MUINT32>(1024 + V_OFFSET10);

    MY_LOG("rG2C.conv_0a.bits.G2C_CNV00=0x%8x \n", rG2C.conv_0a.bits.G2C_CNV00);
    MY_LOG("rG2C.conv_0a.bits.G2C_CNV01=0x%8x \n", rG2C.conv_0a.bits.G2C_CNV01);
    MY_LOG("rG2C.conv_0b.bits.G2C_CNV02=0x%8x \n", rG2C.conv_0b.bits.G2C_CNV02);
    MY_LOG("rG2C.conv_0b.bits.G2C_YOFFSET11=0x%8x \n", rG2C.conv_0b.bits.G2C_YOFFSET11);
    MY_LOG("rG2C.conv_1a.bits.G2C_CNV10=0x%8x \n", rG2C.conv_1a.bits.G2C_CNV10);
    MY_LOG("rG2C.conv_1a.bits.G2C_CNV11=0x%8x \n", rG2C.conv_1a.bits.G2C_CNV11);
    MY_LOG("rG2C.conv_1b.bits.G2C_CNV12=0x%8x \n", rG2C.conv_1b.bits.G2C_CNV12);
    MY_LOG("rG2C.conv_1b.bits.G2C_UOFFSET10=0x%8x \n", rG2C.conv_1b.bits.G2C_UOFFSET10);
    MY_LOG("rG2C.conv_2a.bits.G2C_CNV20=0x%8x \n", rG2C.conv_2a.bits.G2C_CNV20);
    MY_LOG("rG2C.conv_2a.bits.G2C_CNV21=0x%8x \n", rG2C.conv_2a.bits.G2C_CNV21);
    MY_LOG("rG2C.conv_2b.bits.G2C_CNV22=0x%8x \n", rG2C.conv_2b.bits.G2C_CNV22);
    MY_LOG("rG2C.conv_2b.bits.G2C_VOFFSET10=0x%8x \n", rG2C.conv_2b.bits.G2C_VOFFSET10);

    // Write back: SE
    rSE.edge_ctrl.bits.SE_EDGE = SE_EDGE;
    rSE.y_ctrl.bits.SE_YOUT_QBIT = SE_YOUT_QBIT;
    rSE.y_ctrl.bits.SE_COUT_QBIT = SE_COUT_QBIT;
    rSE.y_ctrl.bits.SE_Y = SE_Y;
    rSE.y_ctrl.bits.SE_Y_CONST = SE_Y_CONST;
    rSE.edge_ctrl3.bits.SE_OILEN = SE_OILEN;
    rSE.special_ctrl.bits.SE_KNEESEL = SE_KNEESEL;
    rSE.edge_ctrl1.bits.SE_EGAIN_HB = SE_EGAIN_HB;
    rSE.edge_ctrl1.bits.SE_EGAIN_HA = SE_EGAIN_HA;
    rSE.special_ctrl.bits.SE_SPECIPONLY = SE_SPECIPONLY;
    rSE.special_ctrl.bits.SE_SPECIGAIN = SE_SPECIGAIN;
    rSE.edge_ctrl1.bits.SE_EGAIN_VB = SE_EGAIN_VB;
    rSE.edge_ctrl1.bits.SE_EGAIN_VA = SE_EGAIN_VA;
    rSE.special_ctrl.bits.SE_SPECIABS = SE_SPECIABS;
    rSE.special_ctrl.bits.SE_SPECIINV = SE_SPECIINV;
    rSE.core_ctrl1.bits.SE_COREH = SE_COREH;
    rSE.core_ctrl2.bits.SE_E_TH1_V = SE_E_TH1_V;
    rSE.edge_ctrl2.bits.SE_EMBOSS1 = SE_EMBOSS1;
    rSE.edge_ctrl2.bits.SE_EMBOSS2 = SE_EMBOSS2;

    MY_LOG("rSE.edge_ctrl.bits.SE_EDGE=%d \n",rSE.edge_ctrl.bits.SE_EDGE);
	MY_LOG("rSE.y_ctrl.bits.SE_YOUT_QBIT=%d \n",rSE.y_ctrl.bits.SE_YOUT_QBIT);
	MY_LOG("rSE.y_ctrl.bits.SE_COUT_QBIT=%d \n",rSE.y_ctrl.bits.SE_COUT_QBIT);        
	MY_LOG("rSE.y_ctrl.bits.SE_Y=%d \n",rSE.y_ctrl.bits.SE_Y);
	MY_LOG("rSE.y_ctrl.bits.SE_Y_CONST=%d \n",rSE.y_ctrl.bits.SE_Y_CONST);
	MY_LOG("rSE.edge_ctrl3.bits.SE_OILEN=%d \n",rSE.edge_ctrl3.bits.SE_OILEN);
	MY_LOG("rSE.special_ctrl.bits.SE_KNEESEL=%d \n",rSE.special_ctrl.bits.SE_KNEESEL);
	MY_LOG("rSE.edge_ctrl1.bits.SE_EGAIN_HB=%d \n",rSE.edge_ctrl1.bits.SE_EGAIN_HB);
	MY_LOG("rSE.edge_ctrl1.bits.SE_EGAIN_HA=%d \n",rSE.edge_ctrl1.bits.SE_EGAIN_HA);
	MY_LOG("rSE.special_ctrl.bits.SE_SPECIPONLY=%d \n",rSE.special_ctrl.bits.SE_SPECIPONLY);
	MY_LOG("rSE.special_ctrl.bits.SE_SPECIGAIN=%d \n",rSE.special_ctrl.bits.SE_SPECIGAIN);
	MY_LOG("rSE.edge_ctrl1.bits.SE_EGAIN_VB=%d \n",rSE.edge_ctrl1.bits.SE_EGAIN_VB);
	MY_LOG("rSE.edge_ctrl1.bits.SE_EGAIN_VA=%d \n",rSE.edge_ctrl1.bits.SE_EGAIN_VA);
	MY_LOG("rSE.special_ctrl.bits.SE_SPECIABS=%d \n",rSE.special_ctrl.bits.SE_SPECIABS);
	MY_LOG("rSE.special_ctrl.bits.SE_SPECIINV=%d \n",rSE.special_ctrl.bits.SE_SPECIINV);
	MY_LOG("rSE.core_ctrl1.bits.SE_COREH=%d \n",rSE.core_ctrl1.bits.SE_COREH);
	MY_LOG("rSE.core_ctrl2.bits.SE_E_TH1_V=%d \n",rSE.core_ctrl2.bits.SE_E_TH1_V);
	MY_LOG("rSE.edge_ctrl2.bits.SE_EMBOSS1=%d \n",rSE.edge_ctrl2.bits.SE_EMBOSS1);
	MY_LOG("rSE.edge_ctrl2.bits.SE_EMBOSS2=%d \n",rSE.edge_ctrl2.bits.SE_EMBOSS2);

    MY_LOG("rSE.edge_ctrl.val=0x%8x \n",rSE.edge_ctrl.val);
    MY_LOG("rSE.y_ctrl.val=0x%8x \n",rSE.y_ctrl.val);
    MY_LOG("rSE.edge_ctrl1.val=0x%8x \n",rSE.edge_ctrl1.val);
    MY_LOG("rSE.edge_ctrl2.val=0x%8x \n",rSE.edge_ctrl2.val);
    MY_LOG("rSE.edge_ctrl3.val=0x%8x \n",rSE.edge_ctrl3.val);
    MY_LOG("rSE.special_ctrl.val=0x%8x \n",rSE.special_ctrl.val);
    MY_LOG("rSE.core_ctrl1.val=0x%8x \n",rSE.core_ctrl1.val);
    MY_LOG("rSE.core_ctrl2.val=0x%8x \n",rSE.core_ctrl2.val);

}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//  EE
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MVOID
IspTuningCustom::userSetting_EE(
    EIndex_Isp_Edge_T eIdx_Edge,
    ISP_NVRAM_EE_T& rEE
)
{
    MINT32 i4Slider, dX, dY;

    MY_LOG("eIdx_Edge : %d\n",eIdx_Edge);

    switch ( eIdx_Edge )
    {
    case ISP_EDGE_LOW:
        i4Slider = -4; // Soft EE
        break;
    case ISP_EDGE_HIGH:
        i4Slider = 4; //Texture EE
        break;
    case ISP_EDGE_MIDDLE: // Normal EE
    default:
        i4Slider = 0;
        break;
    }

    if (i4Slider == 0) // Normal EE: do nothing
        return;

    // Get normal EE parameter
    MINT32 LOCK_EE_Y1 = rEE.ed_ctrl1.bits.USM_ED_Y1;   // 0~1023
	MINT32 LOCK_EE_Y2 = rEE.ed_ctrl2.bits.USM_ED_Y2;   // 0~1023
	MINT32 LOCK_EE_Y3 = rEE.ed_ctrl3.bits.USM_ED_Y3;   // 0~1023
	MINT32 LOCK_EE_Y4 = rEE.ed_ctrl4.bits.USM_ED_Y4;   // 0~1023
	MINT32 LOCK_EE_CLIP = rEE.clip_ctrl.bits.USM_CLIP; // 0~255
	MINT32 LOCK_EE_TH_OV = rEE.ed_ctrl6.bits.USM_ED_TH_OVER; // 0~255
	MINT32 LOCK_EE_TH_UN = rEE.ed_ctrl6.bits.USM_ED_TH_UNDER; // 0~255

    // Determine user setting EE parameter
    if (i4Slider < 0) {  // Soft EE
        LOCK_EE_Y1 = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_Y1) * (1 + 0.5 * i4Slider) + 0.5), 0, 1023);
        LOCK_EE_Y2 = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_Y2) * (1 + 0.3 * i4Slider) + 0.5), 0, 1023);
    }
    else { // Texture EE
        LOCK_EE_Y1 = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_Y1) * (1 + 1.0 * i4Slider) + 0.5), 0, 1023);
        LOCK_EE_Y2 = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_Y2) * (1 + 1.5 * i4Slider) + 0.5), 0, 1023);
    }

	LOCK_EE_Y3 = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_Y3) * (1 + 0.2 * i4Slider) + 0.5), 0, 1023);
	LOCK_EE_Y4 = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_Y4) * (1 + 0.2 * i4Slider) + 0.5), 0, 1023);
	LOCK_EE_CLIP = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_CLIP) * (1 + 0.2 * i4Slider) + 0.5), 0, 1023);
	LOCK_EE_TH_OV = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_TH_OV) * (1 + 0.2 * i4Slider) + 0.5), 0, 1023);
	LOCK_EE_TH_UN = LIMIT(static_cast<MINT32>(static_cast<MDOUBLE>(LOCK_EE_TH_UN) * (1 + 0.2 * i4Slider) + 0.5), 0, 1023);

    // USM_ED_S1
    MINT32 USM_ED_X1 = rEE.ed_ctrl1.bits.USM_ED_X1;
    MINT32 USM_ED_S1;

    if (USM_ED_X1 == 0) USM_ED_S1 = 0;
    else USM_ED_S1 = static_cast<MINT32>(static_cast<MDOUBLE>(rEE.ed_ctrl1.bits.USM_ED_Y1) / USM_ED_X1 + 0.5);

    if (USM_ED_S1 > 127) USM_ED_S1 = 127;

    // EE_LCE_S1_1
    MINT32 EE_LCE_X1_1 = rEE.ee_link1.bits.EE_LCE_X1_1;
    MINT32 EE_LCE_S1_1;

    if (EE_LCE_X1_1 == 0) EE_LCE_S1_1 = 0;
    else EE_LCE_S1_1 = static_cast<MINT32>(static_cast<MDOUBLE>(rEE.ed_ctrl1.bits.USM_ED_Y1) / EE_LCE_X1_1 + 0.5);

    if (EE_LCE_S1_1 > 127) EE_LCE_S1_1 = 127;

    // EE_LCE_S1_2
    MINT32 EE_LCE_X1_2 = rEE.ee_link2.bits.EE_LCE_X1_2;
    MINT32 EE_LCE_S1_2;

    if (EE_LCE_X1_2 == 0) EE_LCE_S1_2 = 0;
    else EE_LCE_S1_2 = static_cast<MINT32>(static_cast<MDOUBLE>(rEE.ed_ctrl1.bits.USM_ED_Y1) / EE_LCE_X1_2 + 0.5);

    if(EE_LCE_S1_2 > 127) EE_LCE_S1_2 = 127;

    // EE_LCE_S1_3
    MINT32 EE_LCE_X1_3 = rEE.ee_link3.bits.EE_LCE_X1_3;
    MINT32 EE_LCE_S1_3;

    if (EE_LCE_X1_3 == 0) EE_LCE_S1_3 = 0;
    else EE_LCE_S1_3 = static_cast<MINT32>(static_cast<MDOUBLE>(rEE.ed_ctrl1.bits.USM_ED_Y1) / EE_LCE_X1_3 + 0.5);

    if (EE_LCE_S1_3 > 127) EE_LCE_S1_3 = 127;

    // USM_ED_S2
    MINT32 USM_ED_X2 = rEE.ed_ctrl2.bits.USM_ED_X2;
    MINT32 USM_ED_S2;
    // EE_LCE_S2_1
    MINT32 EE_LCE_S2_1;
    // EE_LCE_S2_2
    MINT32 EE_LCE_S2_2;
    // EE_LCE_S2_3
    MINT32 EE_LCE_S2_3;

    dY = rEE.ed_ctrl2.bits.USM_ED_Y2 - rEE.ed_ctrl1.bits.USM_ED_Y1;
    if (dY > 0){
        // USM_ED_S2
        dX = USM_ED_X2 - USM_ED_X1;
        if (dX == 0) USM_ED_S2 = 0;
        else USM_ED_S2 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX + 0.5);

        // EE_LCE_S2_1
        dX = USM_ED_X2 - EE_LCE_X1_1;
        if (dX == 0) EE_LCE_S2_1 = 0;
        else EE_LCE_S2_1 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX + 0.5);

        // EE_LCE_S2_2
        dX = USM_ED_X2 - EE_LCE_X1_2;
        if (dX == 0) EE_LCE_S2_2 = 0;
        else EE_LCE_S2_2 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX + 0.5);

        // EE_LCE_S2_3
        dX = USM_ED_X2 - EE_LCE_X1_3;
        if (dX == 0) EE_LCE_S2_3 = 0;
        else EE_LCE_S2_3 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX + 0.5);
    }
    else {
        // USM_ED_S2
        dX = USM_ED_X2 - USM_ED_X1;
        if (dX == 0) USM_ED_S2 = 0;
        else USM_ED_S2 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX - 0.5);

        // EE_LCE_S2_1
        dX = USM_ED_X2 - EE_LCE_X1_1;
        if (dX == 0) EE_LCE_S2_1 = 0;
        else EE_LCE_S2_1 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX  - 0.5);

        // EE_LCE_S2_2
        dX = USM_ED_X2 - EE_LCE_X1_2;
        if (dX == 0) EE_LCE_S2_2 = 0;
        else EE_LCE_S2_2 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX - 0.5);

        // EE_LCE_S2_3
        dX = USM_ED_X2 - EE_LCE_X1_3;
        if (dX == 0) EE_LCE_S2_3 = 0;
        else EE_LCE_S2_3 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX - 0.5);
    }

    USM_ED_S2 = LIMIT(USM_ED_S2, -127, 127);
    EE_LCE_S2_1 = LIMIT(EE_LCE_S2_1, -127, 127);
    EE_LCE_S2_2 = LIMIT(EE_LCE_S2_2, -127, 127);
    EE_LCE_S2_3 = LIMIT(EE_LCE_S2_3, -127, 127);

    // USM_ED_S3
    MINT32 USM_ED_X3 = rEE.ed_ctrl3.bits.USM_ED_X3;
    MINT32 USM_ED_S3;
    dX = USM_ED_X3 - USM_ED_X2;
    dY = rEE.ed_ctrl3.bits.USM_ED_Y3 - rEE.ed_ctrl2.bits.USM_ED_Y2;
    if (dY > 0) {
        if (dX == 0) USM_ED_S3 = 0;
        else USM_ED_S3 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX + 0.5);
    }
    else {
        if (dX == 0) USM_ED_S3 = 0;
        else USM_ED_S3 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX - 0.5);
    }

    USM_ED_S3 = LIMIT(USM_ED_S3, -127, 127);

    // USM_ED_S4
    MINT32 USM_ED_X4 = rEE.ed_ctrl4.bits.USM_ED_X4;
    MINT32 USM_ED_S4;
    dX = USM_ED_X4 - USM_ED_X3;
    dY = rEE.ed_ctrl4.bits.USM_ED_Y4 - rEE.ed_ctrl3.bits.USM_ED_Y3;
    if (dY > 0){
        if (dX == 0) USM_ED_S4 = 0;
        else USM_ED_S4 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX + 0.5);
    }
    else{
        if (dX == 0) USM_ED_S4 = 0;
        else USM_ED_S4 = static_cast<MINT32>(static_cast<MDOUBLE>(dY) / dX - 0.5);
    }

    USM_ED_S4 = LIMIT(USM_ED_S4, -127, 127);

    // USM_ED_S5
    MINT32 USM_ED_S5 = rEE.ed_ctrl5.bits.USM_ED_S5;

    if (USM_ED_S5 > 127) { // -
        USM_ED_S5 = static_cast<MINT32>(static_cast<MDOUBLE>(USM_ED_S5 - 256) * (1 + 0.2 * i4Slider) - 0.5);
    }
    else {
        USM_ED_S5 = static_cast<MINT32>(static_cast<MDOUBLE>(USM_ED_S5) * (1 + 0.2 * i4Slider) + 0.5);
    }

    USM_ED_S5 = LIMIT(USM_ED_S5, -127, 127);


    MY_LOG("[userSetting_EE] old (X1, Y1, S1, X2, Y2, S2, X3, Y3, S3, X4, Y4, S4, S5) = (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
                               rEE.ed_ctrl1.bits.USM_ED_X1,
                               rEE.ed_ctrl1.bits.USM_ED_Y1,
                               rEE.ed_ctrl1.bits.USM_ED_S1,
                               rEE.ed_ctrl2.bits.USM_ED_X2,
                               rEE.ed_ctrl2.bits.USM_ED_Y2,
                               rEE.ed_ctrl2.bits.USM_ED_S2,
                               rEE.ed_ctrl3.bits.USM_ED_X3,
                               rEE.ed_ctrl3.bits.USM_ED_Y3,
                               rEE.ed_ctrl3.bits.USM_ED_S3,
                               rEE.ed_ctrl4.bits.USM_ED_X4,
                               rEE.ed_ctrl4.bits.USM_ED_Y4,
                               rEE.ed_ctrl4.bits.USM_ED_S4,
                               rEE.ed_ctrl5.bits.USM_ED_S5
                               );

    MY_LOG("[userSetting_EE] old (LCE_X1_1, LCE_S1_1, LCE_S2_1, LCE_X1_2, LCE_S1_2, LCE_S2_2, LCE_X1_3, LCE_S1_3, LCE_S2_3) = (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
                               rEE.ee_link1.bits.EE_LCE_X1_1,
                               rEE.ee_link1.bits.EE_LCE_S1_1,
                               rEE.ee_link1.bits.EE_LCE_S2_1,
                               rEE.ee_link2.bits.EE_LCE_X1_2,
                               rEE.ee_link2.bits.EE_LCE_S1_2,
                               rEE.ee_link2.bits.EE_LCE_S2_2,
                               rEE.ee_link3.bits.EE_LCE_X1_3,
                               rEE.ee_link3.bits.EE_LCE_S1_3,
                               rEE.ee_link3.bits.EE_LCE_S2_3
                               );

    // Write back
    rEE.ed_ctrl1.bits.USM_ED_Y1 = static_cast<MUINT32>(LOCK_EE_Y1);
    rEE.ed_ctrl2.bits.USM_ED_Y2 = static_cast<MUINT32>(LOCK_EE_Y2);
    rEE.ed_ctrl3.bits.USM_ED_Y3 = static_cast<MUINT32>(LOCK_EE_Y3);
    rEE.ed_ctrl4.bits.USM_ED_Y4 = static_cast<MUINT32>(LOCK_EE_Y4);
    rEE.clip_ctrl.bits.USM_CLIP = static_cast<MUINT32>(LOCK_EE_CLIP);
    rEE.ed_ctrl6.bits.USM_ED_TH_OVER = static_cast<MUINT32>(LOCK_EE_TH_OV);
    rEE.ed_ctrl6.bits.USM_ED_TH_UNDER = static_cast<MUINT32>(LOCK_EE_TH_UN);

    rEE.ed_ctrl1.bits.USM_ED_S1 = (USM_ED_S1 >= 0) ? static_cast<MUINT32>(USM_ED_S1) : static_cast<MUINT32>(256 + USM_ED_S1);
    rEE.ed_ctrl2.bits.USM_ED_S2 = (USM_ED_S2 >= 0) ? static_cast<MUINT32>(USM_ED_S2) : static_cast<MUINT32>(256 + USM_ED_S2);
    rEE.ed_ctrl3.bits.USM_ED_S3 = (USM_ED_S3 >= 0) ? static_cast<MUINT32>(USM_ED_S3) : static_cast<MUINT32>(256 + USM_ED_S3);
    rEE.ed_ctrl4.bits.USM_ED_S4 = (USM_ED_S4 >= 0) ? static_cast<MUINT32>(USM_ED_S4) : static_cast<MUINT32>(256 + USM_ED_S4);
    rEE.ed_ctrl5.bits.USM_ED_S5 = (USM_ED_S5 >= 0) ? static_cast<MUINT32>(USM_ED_S5) : static_cast<MUINT32>(256 + USM_ED_S5);

    rEE.ee_link1.bits.EE_LCE_S1_1 = (EE_LCE_S1_1 >= 0) ? static_cast<MUINT32>(EE_LCE_S1_1) : static_cast<MUINT32>(256 + EE_LCE_S1_1);
    rEE.ee_link1.bits.EE_LCE_S2_1 = (EE_LCE_S2_1 >= 0) ? static_cast<MUINT32>(EE_LCE_S2_1) : static_cast<MUINT32>(256 + EE_LCE_S2_1);
    rEE.ee_link2.bits.EE_LCE_S1_2 = (EE_LCE_S1_2 >= 0) ? static_cast<MUINT32>(EE_LCE_S1_2) : static_cast<MUINT32>(256 + EE_LCE_S1_2);
    rEE.ee_link2.bits.EE_LCE_S2_2 = (EE_LCE_S2_2 >= 0) ? static_cast<MUINT32>(EE_LCE_S2_2) : static_cast<MUINT32>(256 + EE_LCE_S2_2);
    rEE.ee_link3.bits.EE_LCE_S1_3 = (EE_LCE_S1_3 >= 0) ? static_cast<MUINT32>(EE_LCE_S1_3) : static_cast<MUINT32>(256 + EE_LCE_S1_3);
    rEE.ee_link3.bits.EE_LCE_S2_3 = (EE_LCE_S2_3 >= 0) ? static_cast<MUINT32>(EE_LCE_S2_3) : static_cast<MUINT32>(256 + EE_LCE_S2_3);

    MY_LOG("[userSetting_EE] new (X1, Y1, S1, X2, Y2, S2, X3, Y3, S3, X4, Y4, S4, S5) = (%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d)",
                               rEE.ed_ctrl1.bits.USM_ED_X1,
                               rEE.ed_ctrl1.bits.USM_ED_Y1,
                               rEE.ed_ctrl1.bits.USM_ED_S1,
                               rEE.ed_ctrl2.bits.USM_ED_X2,
                               rEE.ed_ctrl2.bits.USM_ED_Y2,
                               rEE.ed_ctrl2.bits.USM_ED_S2,
                               rEE.ed_ctrl3.bits.USM_ED_X3,
                               rEE.ed_ctrl3.bits.USM_ED_Y3,
                               rEE.ed_ctrl3.bits.USM_ED_S3,
                               rEE.ed_ctrl4.bits.USM_ED_X4,
                               rEE.ed_ctrl4.bits.USM_ED_Y4,
                               rEE.ed_ctrl4.bits.USM_ED_S4,
                               rEE.ed_ctrl5.bits.USM_ED_S5
                               );

    MY_LOG("[userSetting_EE] new (LCE_X1_1, LCE_S1_1, LCE_S2_1, LCE_X1_2, LCE_S1_2, LCE_S2_2, LCE_X1_3, LCE_S1_3, LCE_S2_3) = (%d, %d, %d, %d, %d, %d, %d, %d, %d)",
                               rEE.ee_link1.bits.EE_LCE_X1_1,
                               rEE.ee_link1.bits.EE_LCE_S1_1,
                               rEE.ee_link1.bits.EE_LCE_S2_1,
                               rEE.ee_link2.bits.EE_LCE_X1_2,
                               rEE.ee_link2.bits.EE_LCE_S1_2,
                               rEE.ee_link2.bits.EE_LCE_S2_2,
                               rEE.ee_link3.bits.EE_LCE_X1_3,
                               rEE.ee_link3.bits.EE_LCE_S1_3,
                               rEE.ee_link3.bits.EE_LCE_S2_3
                               );

}
Example #15
0
// Function to detect and draw any faces that is present in an image
bool face_detect( IplImage* srcImg, std::vector<CvRect> *vectFaces, CvHaarClassifierCascade* cascade, bool detect_only)
{

    // Create memory for calculations
    static CvMemStorage* storage = 0;

    // Create two points to represent the face locations
    CvPoint pt1, pt2;
    int i;

    if( !cascade )
    {
        MY_LOG("%s: faceCascade is NULL", __FILE__);
        return false;
    }

    // Allocate the memory storage
    storage = cvCreateMemStorage(0);

    // Clear the memory storage which was used before
    cvClearMemStorage( storage );

    int max_width = 0;
    // Find whether the cascade is loaded, to find the biggest face. If yes, then:
    if( cascade )
    {

        // There can be more than one face in an image. So create a growable sequence of faces.
        // Detect the objects and store them in the sequence

        DURATION_START;
        CvSeq* faces = cvHaarDetectObjects( srcImg, cascade, storage,
                1.1, 2, CV_HAAR_DO_CANNY_PRUNING
                , cvSize(20, 20) 
                );
        DURATION_STOP("cvHaarDetectObjects()");

        // Loop the number of faces found.
        for( i = 0, max_width=0; i < faces->total; i++ )
        {
            // Create a new rectangle for the face
            CvRect* r = (CvRect*)cvGetSeqElem( faces, i );

            if(vectFaces != NULL) {
                vectFaces -> push_back(*r);
            }

            MY_LOG("%s: found face <%d,%d> with %dx%d\n", __func__, r->x, r->y, r->width, r->height);

            if(!detect_only) {
                // Draw the rectangle in the input image
                cvRectangle( srcImg, pt1, pt2, CV_RGB(255,0,0), 3, 8, 0 );
            }

            if(max_width < r->width) {

                pt1.x = r->x;
                pt2.x = (r->x + r->width);
                pt1.y = r->y;
                pt2.y = (r->y + r->height);

                max_width = r->width;

            }
        }

        if(max_width <= 4) {
            return false;
        }

        //printf("%s: (%d,%d), (%d,%d) -> (%d * %d)\n", __func__, pt1.x, pt1.y, pt2.x, pt2.y, (pt2.x - pt1.x) , (pt2.y - pt1.y));

        //cvSetImageROI(srcImg, cvRect(pt1.x, pt1.y, pt2.x - pt1.x, pt2.y - pt1.y));
        //// __android_log_print(ANDROID_LOG_DEBUG, "run to here ", "func:%s, line:%d", __func__,__LINE__);
        //// printf("%s: srcImg ROI: (%d * %d)\n",__func__, cvGetImageROI(srcImg).width, cvGetImageROI(srcImg).height );
        //IplImage *tmpImg2 = cvCreateImage( cvSize(cvGetImageROI(srcImg).width, cvGetImageROI(srcImg).height), IPL_DEPTH_8U, 1);
        //IplImage *tmpImg = srcImg;
        ////color depth
        //if(srcImg->nChannels != 1)  {
        //    cvCvtColor(srcImg, tmpImg2, CV_BGR2GRAY);
        //    tmpImg = tmpImg2;
        //}

        ////resize
        //*dstImg = cvCreateImage(cvSize(FACE_SIZE, FACE_SIZE), IPL_DEPTH_8U, 1);
        //cvResize(tmpImg, *dstImg, CV_INTER_CUBIC);

        ////__android_log_print(ANDROID_LOG_DEBUG, "run to here ", "func:%s, line:%d", __func__,__LINE__);
        //cvResetImageROI(srcImg);

        //cvReleaseImage(&tmpImg2);
        ////__android_log_print(ANDROID_LOG_DEBUG, "run to here ", "func:%s, line:%d", __func__,__LINE__);
        
        return true;
    }

    return false;
}