/*******************************************************************************
*
*   rCamInfo
*       [in]    ISP Camera Info for RAW sensor. Its members are as below:
*
*           eCamMode:
*               ECamMode_Video          = 0,
*               ECamMode_Online_Preview,
*               ECamMode_Online_Capture,
*               ECamMode_Online_Capture_ZSD,
*               ECamMode_Offline_Capture_Pass1,
*               ECamMode_Offline_Capture_Pass2,
*               ECamMode_HDR_Cap_Pass1_SF,  //  Pass1: Single Frame
*               ECamMode_HDR_Cap_Pass1_MF1, //  Pass1: Multi Frame Stage1
*               ECamMode_HDR_Cap_Pass1_MF2, //  Pass1: Multi Frame Stage2
*               ECamMode_HDR_Cap_Pass2,     //  Pass2
*
*           eIdx_Scene:
*               SCENE_MODE_OFF,             // Disable scene mode equal Auto mode
*               SCENE_MODE_NORMAL,          // Normal mode
*               SCENE_MODE_ACTION,          // Action mode
*               SCENE_MODE_PORTRAIT,        // Portrait mode
*               SCENE_MODE_LANDSCAPE,       // Landscape
*               SCENE_MODE_NIGHTSCENE,      // Night Scene
*               SCENE_MODE_NIGHTPORTRAIT,   // Night Portrait
*               SCENE_MODE_THEATRE,         // Theatre mode
*               SCENE_MODE_BEACH,           // Beach mode
*               SCENE_MODE_SNOW,            // Snow mode
*               SCENE_MODE_SUNSET,          // Sunset mode
*               SCENE_MODE_STEADYPHOTO,     // Steady photo mode
*               SCENE_MODE_FIREWORKS,       // Fireworks mode
*               SCENE_MODE_SPORTS,          // Sports mode
*               SCENE_MODE_PARTY,           // Party mode
*               SCENE_MODE_CANDLELIGHT,     // Candle light mode
*               SCENE_MODE_HDR,             // HDR mode
*
*           u4ISOValue:
*               ISO value to determine eISO.
*
*           eIdx_ISO:
*               eIDX_ISO_100,
*               eIDX_ISO_200,
*               eIDX_ISO_400,
*               eIDX_ISO_800,
*               eIDX_ISO_1600
*
*           i4CCT:
*               Correlated color temperature
*
*           eCCTIndex_CCM:
*               Correlated color temperature index for CCM
*                   eIDX_CCM_TL84
*                   eIDX_CCM_CWF
*                   eIDX_CCM_D65
*
*           u4ZoomRatio_x100:
*               zoom ratio (x100)
*
*           i4LightValue_x10:
*               light value (x10)
*
*   rIdxMgr:
*       [in]    The default ISP tuning index manager.
*       [out]   The ISP tuning index manager after customizing.
*
*
*******************************************************************************/
MVOID
IspTuningCustom::
evaluate_nvram_index(RAWIspCamInfo const& rCamInfo, IndexMgr& rIdxMgr)
{
//..............................................................................
    //  (1) Dump info. before customizing.
#if ENABLE_MY_LOG
    rCamInfo.dump();
#endif

#if 0
    LOGD("[+evaluate_nvram_index][before customizing]");
    rIdxMgr.dump();
#endif
//..............................................................................
    //  (2) Modify each index based on conditions.
    //
    //  setIdx_XXX() returns:
    //      MTURE: if successful
    //      MFALSE: if the input index is out of range.
    //
#if 0
    fgRet = rIdxMgr.setIdx_OBC(XXX);
    fgRet = rIdxMgr.setIdx_BPC(XXX);
    fgRet = rIdxMgr.setIdx_NR1(XXX);
    fgRet = rIdxMgr.setIdx_CFA(XXX);
    fgRet = rIdxMgr.setIdx_GGM(XXX);
    fgRet = rIdxMgr.setIdx_ANR(XXX);
    fgRet = rIdxMgr.setIdx_CCR(XXX);
    fgRet = rIdxMgr.setIdx_EE(XXX);
#endif
//..............................................................................
    //  (3) Finally, dump info. after modifying.
#if 0
    LOGD("[-evaluate_nvram_index][after customizing]");
    rIdxMgr.dump();
#endif
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MERROR_ENUM
Paramctrl::
do_validatePerFrameP2(MINT32 flowType, const RAWIspCamInfo& rIspCamInfo, void* pRegBuf)
{
    MERROR_ENUM err = MERR_OK;
    MBOOL prepare_rdy = MTRUE;

    MY_LOG_IF(m_bDebugEnable, "[do_validatePerFrameP2]");

    CPTLog(Event_Pipe_3A_ISP_VALIDATE_PERFRAME_DYNAMIC_TUNING, CPTFlagStart); // Profiling Start.

    //  (1) dynamic tuning
    if (isDynamicTuning())
    {
        IndexMgr idxmgr;

        //  a) Get default index setting.
        INDEX_T const*const pDefaultIndex = m_pIspTuningCustom->getDefaultIndex(
            rIspCamInfo.eIspProfile, ESensorMode_Preview/*ISP_TEMP_MARK_OUT sensor mode */, rIspCamInfo.eIdx_Scene, rIspCamInfo.eIdx_ISO
        );
        if  ( ! pDefaultIndex )
        {
            MY_ERR("[ERROR][validatePerFrame]pDefaultIndex==NULL");
            err = MERR_CUSTOM_DEFAULT_INDEX_NOT_FOUND;
            goto lbExit;
        }
        idxmgr = *pDefaultIndex;

        MY_LOG_IF(m_bDebugEnable, "[BEFORE][evaluate_nvram_index]");

        if (m_bDebugEnable) {
            idxmgr.dump();
        }

        //  b) Customize the index setting.
        m_pIspTuningCustom->evaluate_nvram_index(rIspCamInfo, idxmgr);

        MY_LOG_IF(m_bDebugEnable, "[AFTER][evaluate_nvram_index]");

        if (m_bDebugEnable) {
            idxmgr.dump();
        }

        MY_LOG_IF(m_bDebugEnable, "IndexMgr::getIdx = [OBC(%d),BPC(%d),NR1(%d),CFA(%d),GGM(%d),ANR(%d),CCR(%d),EE(%d)]\n"
                ,idxmgr.getIdx_OBC()
                ,idxmgr.getIdx_BPC()
                ,idxmgr.getIdx_NR1()
                ,idxmgr.getIdx_CFA()
                ,idxmgr.getIdx_GGM()
                ,idxmgr.getIdx_ANR()
                ,idxmgr.getIdx_CCR()
                ,idxmgr.getIdx_EE());

        //  (2) Apply Per-Frame Parameters.
        MY_LOG_IF(m_bDebugEnable, "[do_validatePerFrame()] isDynamicBypass() = %d\n", isDynamicBypass());
        (isDynamicBypass() == MTRUE) ? (prepare_rdy = prepareHw_PerFrame_Partial(rIspCamInfo, idxmgr))
                                     : (prepare_rdy = prepareHw_PerFrame_All(rIspCamInfo, idxmgr));
    }

    CPTLog(Event_Pipe_3A_ISP_VALIDATE_PERFRAME_DYNAMIC_TUNING, CPTFlagEnd); // Profiling End.

    if(!prepare_rdy || ! applyToHw_PerFrame_P2(flowType, rIspCamInfo, pRegBuf))  //  Apply the ispmgr's buffer to H/W.
    {
        err = MERR_SET_ISP_REG;
        goto lbExit;
    }

#if 0
    if  (
            ! prepareHw_PerFrame_All()          //  Prepare param members to the ispmgr's buffer.
        ||  ! applyToHw_PerFrame_All()          //  Apply the ispmgr's buffer to H/W.
        )
    {
        err = MERR_SET_ISP_REG;
        goto lbExit;
    }
#endif

    //  (3) Save Exif debug info if necessary.
    err = saveDebugInfo();
    if  ( MERR_OK != err )
    {
        goto lbExit;
    }

lbExit:
    if  ( MERR_OK != err )
    {
        MY_ERR("[-do_validatePerFrame]err(%X)", err);
    }

    return  err;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MERROR_ENUM
Paramctrl::
do_validatePerFrame(MINT32 const i4FrameID)
{
    MERROR_ENUM err = MERR_OK;
    MBOOL prepare_rdy;

    MY_LOG_IF(m_bDebugEnable, "[do_validatePerFrame]");

    CPTLog(Event_Pipe_3A_ISP_VALIDATE_PERFRAME_DYNAMIC_TUNING, CPTFlagStart); // Profiling Start.

    //  (1) dynamic tuning
    if (isDynamicTuning())
    {

        IndexMgr idxmgr;

        // CAM3 TODO: profile mapping
        if (m_i4IspProfile == EIspProfile_NormalPreview) {
            switch (m_rIspCamInfo.eSensorMode) {
            case ESensorMode_Preview:
                m_rIspCamInfo.eIspProfile = EIspProfile_NormalPreview;
                break;
            case ESensorMode_Video:
                m_rIspCamInfo.eIspProfile = EIspProfile_VideoPreview;
                break;
            case ESensorMode_Capture:
                m_rIspCamInfo.eIspProfile = EIspProfile_ZsdPreview_CC;
                break;
            default:
                m_rIspCamInfo.eIspProfile = EIspProfile_NormalPreview;
            }
        }
        else if (m_i4IspProfile == EIspProfile_NormalCapture) {
            switch (m_rIspCamInfo.eSensorMode) {
            case ESensorMode_Preview:
            case ESensorMode_Video:
                m_rIspCamInfo.eIspProfile = EIspProfile_VideoCapture;
                break;
            case ESensorMode_Capture:
                m_rIspCamInfo.eIspProfile = EIspProfile_NormalCapture;
                break;
            default:
                m_rIspCamInfo.eIspProfile = EIspProfile_NormalCapture;
            }
        }
        else {
            MY_ERR("[do_validatePerFrame]incorrect ISP profile = %d", m_i4IspProfile);
        }



        //  a) Get default index setting.
        INDEX_T const*const pDefaultIndex = m_pIspTuningCustom->getDefaultIndex(
            m_rIspCamInfo.eIspProfile, ESensorMode_Preview/*ISP_TEMP_MARK_OUT sensor mode */, m_rIspCamInfo.eIdx_Scene, m_rIspCamInfo.eIdx_ISO
        );
        if  ( ! pDefaultIndex )
        {
            MY_ERR("[ERROR][validatePerFrame]pDefaultIndex==NULL");
            err = MERR_CUSTOM_DEFAULT_INDEX_NOT_FOUND;
            goto lbExit;
        }
        idxmgr = *pDefaultIndex;

        MY_LOG_IF(m_bDebugEnable, "[BEFORE][evaluate_nvram_index]");

        if (m_bDebugEnable) {
            idxmgr.dump();
        }

        //  b) Customize the index setting.
        m_pIspTuningCustom->evaluate_nvram_index(m_rIspCamInfo, idxmgr);

        MY_LOG_IF(m_bDebugEnable, "[AFTER][evaluate_nvram_index]");

        if (m_bDebugEnable) {
            idxmgr.dump();
        }

        //  c) Restore customized index set to member.
        //m_IspNvramMgr = idxmgr; //Yosen mark out
        if (!isDynamicBypass()) m_IspNvramMgr = idxmgr; //Yosen
        MY_LOG_IF(m_bDebugEnable, "m_IspNvramMgr::getIdx = [OBC(%d),BPC(%d),NR1(%d),CFA(%d),GGM(%d),ANR(%d),CCR(%d),EE(%d)]\n"
                ,m_IspNvramMgr.getIdx_OBC()
                ,m_IspNvramMgr.getIdx_BPC()
                ,m_IspNvramMgr.getIdx_NR1()
                ,m_IspNvramMgr.getIdx_CFA()
                ,m_IspNvramMgr.getIdx_GGM()
                ,m_IspNvramMgr.getIdx_ANR()
                ,m_IspNvramMgr.getIdx_CCR()
                ,m_IspNvramMgr.getIdx_EE());

    }

    CPTLog(Event_Pipe_3A_ISP_VALIDATE_PERFRAME_DYNAMIC_TUNING, CPTFlagEnd); // Profiling End.


    //  (2) Apply Per-Frame Parameters.
    MY_LOG_IF(m_bDebugEnable, "[do_validatePerFrame()] isDynamicBypass() = %d\n", isDynamicBypass());
    (isDynamicBypass() == MTRUE) ? (prepare_rdy = prepareHw_PerFrame_Partial())
                                 : (prepare_rdy = prepareHw_PerFrame_All());

    if(!prepare_rdy || ! applyToHw_PerFrame_All(i4FrameID))  //  Apply the ispmgr's buffer to H/W.
    {
        err = MERR_SET_ISP_REG;
        goto lbExit;
    }

#if 0
    if  (
            ! prepareHw_PerFrame_All()          //  Prepare param members to the ispmgr's buffer.
        ||  ! applyToHw_PerFrame_All()          //  Apply the ispmgr's buffer to H/W.
        )
    {
        err = MERR_SET_ISP_REG;
        goto lbExit;
    }
#endif

    //  (3) Save Exif debug info if necessary.
    err = saveDebugInfo();
    if  ( MERR_OK != err )
    {
        goto lbExit;
    }

lbExit:
    if  ( MERR_OK != err )
    {
        MY_ERR("[-do_validatePerFrame]err(%X)", err);
    }

    return  err;
}
MVOID
IspTuningCustom::
evaluate_nvram_index(RAWIspCamInfo const& rCamInfo, IndexMgr& rIdxMgr)
{
    MBOOL fgRet = MFALSE;
    ECamMode_T const       eCamMode = rCamInfo.eCamMode;
    EIndex_Scene_T const eIdx_Scene = rCamInfo.eIdx_Scene;
    EIndex_ISO_T const     eIdx_ISO = rCamInfo.eIdx_ISO;
    MUINT32 const        u4ISOValue = rCamInfo.u4ISOValue;
    MUINT32 const             i4CCT = rCamInfo.i4CCT;
    MUINT32 const  u4ZoomRatio_x100 = rCamInfo.u4ZoomRatio_x100;
    MINT32 const   i4LightValue_x10 = rCamInfo.i4LightValue_x10;

    //  (0) We have:
    //      eCamMode, eScene, ......
//..............................................................................
    //  (1) Dump info. before customizing.
#if ENABLE_MY_LOG
    rCamInfo.dump();
#endif

#if 0
    LOGD("[+evaluate_nvram_index][before customizing]");
    rIdxMgr.dump();
#endif
//..............................................................................
    //  (2) Modify each index based on conditions.
    //
    //  setIdx_XXX() returns:
    //      MTURE: if successful
    //      MFALSE: if the input index is out of range.
    //
#if 0
    fgRet = rIdxMgr.setIdx_DM(XXX);
    fgRet = rIdxMgr.setIdx_DP(XXX);
    fgRet = rIdxMgr.setIdx_NR1(XXX);
    fgRet = rIdxMgr.setIdx_NR2(XXX);
    fgRet = rIdxMgr.setIdx_Saturation(XXX);
    fgRet = rIdxMgr.setIdx_Contrast(XXX);
    fgRet = rIdxMgr.setIdx_Hue(XXX);
    fgRet = rIdxMgr.setIdx_Gamma(XXX);
    fgRet = rIdxMgr.setIdx_EE(XXX);
#endif
//..............................................................................
    //  (3) Finally, dump info. after modifying.
#if 0
    LOGD("[-evaluate_nvram_index][after customizing]");
    rIdxMgr.dump();
#endif
}
Пример #5
0
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MERROR_ENUM
Paramctrl::
do_validatePerFrame(MINT32 const i4FrameID)
{
    MERROR_ENUM err = MERR_OK;
    MBOOL prepare_rdy;
    MINT32 time_ms;

    MY_LOG_IF(m_bDebugEnable, "[do_validatePerFrame]");

    //CPTLog(Event_Pipe_3A_ISP_VALIDATE_PERFRAME_DYNAMIC_TUNING, CPTFlagStart); // Profiling Start.
    if (m_bProfileEnable)
        m_pAaaTimer->start("do_validatePerFrame: nvram index", m_eSensorDev, m_bProfileEnable);

    //  (1) dynamic tuning
    if (isDynamicTuning())
    {

        IndexMgr idxmgr;

        MY_LOG_IF(m_bDebugEnable, "eIspProfile = %d, eSensorMode = %d, eIdx_Scene = %d, eIdx_ISO = %d",
                  m_rIspCamInfo.eIspProfile, m_rIspCamInfo.eSensorMode, m_rIspCamInfo.eIdx_Scene, m_rIspCamInfo.eIdx_ISO);

        // Refine camera info.
        m_pIspTuningCustom->refine_CamInfo(m_rIspCamInfo);

        //  a) Get default index setting.
        INDEX_T const*const pDefaultIndex = m_pIspTuningCustom->getDefaultIndex(
            m_rIspCamInfo.eIspProfile, m_rIspCamInfo.eSensorMode, m_rIspCamInfo.eIdx_Scene, m_rIspCamInfo.eIdx_ISO
        );
        if  ( ! pDefaultIndex )
        {
            MY_ERR("[ERROR][validatePerFrame]pDefaultIndex==NULL");
            err = MERR_CUSTOM_DEFAULT_INDEX_NOT_FOUND;
            goto lbExit;
        }
        idxmgr = *pDefaultIndex;

        MY_LOG_IF(m_bDebugEnable, "[BEFORE][evaluate_nvram_index]");

        if (m_bDebugEnable) {
            idxmgr.dump();
        }

        //  b) Customize the index setting.
        m_pIspTuningCustom->evaluate_nvram_index(m_rIspCamInfo, idxmgr);

        MY_LOG_IF(m_bDebugEnable, "[AFTER][evaluate_nvram_index]");

        if (m_bDebugEnable) {
            idxmgr.dump();
        }

        //  c) Restore customized index set to member.
        if (!isDynamicBypass()) m_IspNvramMgr = idxmgr;
        //m_IspNvramMgr = idxmgr;

    }

    if (m_bProfileEnable)
        time_ms = m_pAaaTimer->End();

    if (m_bProfileEnable)
        m_pAaaTimer->start("do_validatePerFrame: prepareHw_PerFrame_All()", m_eSensorDev, m_bProfileEnable);
    //  (2) Apply Per-Frame Parameters.
    (isDynamicBypass() == MTRUE) ? (prepare_rdy = prepareHw_PerFrame_Partial())
                                 : (prepare_rdy = prepareHw_PerFrame_All());
    if (m_bProfileEnable)
        time_ms = m_pAaaTimer->End();

    if (m_bProfileEnable)
        m_pAaaTimer->start("do_validatePerFrame: applyToHw_PerFrame_All()", m_eSensorDev, m_bProfileEnable);

    if(!prepare_rdy || ! applyToHw_PerFrame_All(i4FrameID))  //  Apply the ispmgr's buffer to H/W.
    {
        err = MERR_SET_ISP_REG;
        goto lbExit;
    }

#if 0
    if  (
            ! prepareHw_PerFrame_All()          //  Prepare param members to the ispmgr's buffer.
        ||  ! applyToHw_PerFrame_All()          //  Apply the ispmgr's buffer to H/W.
        )
    {
        err = MERR_SET_ISP_REG;
        goto lbExit;
    }
#endif

lbExit:
    if  ( MERR_OK != err )
    {
        MY_ERR("[-do_validatePerFrame]err(%X)", err);
    }

    if (m_bProfileEnable)
        time_ms = m_pAaaTimer->End();

    return  err;
}