/* -----------------------------------------------------------------------
FUNCTION : Apply flash settings.
PURPOSE  : Function to set flash settings.
------------------------------------------------------------------------ */
static void
Configure_Flash(
t_uint32    s32_DelayFromStartPoint,
t_uint32    u32_StrobeLength_us,
t_uint32    u8_FrameCount,
t_uint32    u8_MaximumNumberOfFrames,
t_uint32    e_StrobeStartPoint_Frame)
{
    char    comment[256];

    LOS_Log("\nConfigure Flash  now..\n");

    sprintf(
    comment,
    "Configuring  Flash for  s32_DelayFromStartPoint = %ld u32_StrobeLength_us = %ld u8_FrameCount = %ld u8_MaximumNumberOfFrames = %ld e_StrobeStartPoint_Frame = %ld \n",
    s32_DelayFromStartPoint,
    u32_StrobeLength_us,
    u8_FrameCount,
    u8_MaximumNumberOfFrames,
    e_StrobeStartPoint_Frame);
    MMTE_TEST_COMMENT(comment);

    ITE_writePE(FlashControl_s32_DelayFromStartPoint_lines_Byte0, s32_DelayFromStartPoint);
    ITE_writePE(FlashControl_u32_StrobeLength_us_Byte0, u32_StrobeLength_us);
    ITE_writePE(FlashControl_u8_FrameCount_Byte0, u8_FrameCount);
    ITE_writePE(FlashControl_u8_MaxFramesToWaitForFlashTrigger_Byte0, u8_MaximumNumberOfFrames);
    ITE_writePE(FlashControl_e_StrobeStartPoint_Frame_Byte0, e_StrobeStartPoint_Frame);

#if FLASH_DRIVER_INCLUDE
    // ER:408207: Flash driver integration in ITE NMF.
    ITE_FlashDriverConfigure();

#endif
}
static void
Enable_Adsoc_Radial_Peaking(
t_uint32    pipe_no,
t_bool      enableBit)
{
    LOS_Log("\n>> Enable_Adsoc_Radial_Peaking : pipe number = %d, enableBit = %d\n", pipe_no, enableBit);
    if (0 == pipe_no)
    {
        ITE_writePE(Adsoc_RP_Ctrl_0_e_Flag_Adsoc_RP_Enable_Byte0, enableBit);
    }


    if (1 == pipe_no)
    {
        ITE_writePE(Adsoc_RP_Ctrl_1_e_Flag_Adsoc_RP_Enable_Byte0, enableBit);
    }


    if (HostInterfaceHighLevelState_e_RUNNING == ITE_readPE(HostInterface_Status_e_HostInterfaceHighLevelState_Byte0))
    {
        ITE_NMF_GlaceHistoExpStatsRequestAndWait();
    }


    LOS_Log("<<Enable_Adsoc_Radial_Peaking\n");
}
void ITE_NMF_gammacopy0(t_los_logical_address addr, int hw ){
    int i;
    t_uint16 *r_gamma_table= (t_uint16 *)addr;
    t_uint16 *g_gamma_table= (t_uint16 *)addr+CE0_SHARP_MEM_LUT_RED_ELT_DIMENSION;
    t_uint16 *b_gamma_table= (t_uint16 *)addr+CE0_SHARP_MEM_LUT_RED_ELT_DIMENSION+CE0_SHARP_MEM_LUT_GREEN_ELT_DIMENSION;

    for(i=CE0_SHARP_MEM_LUT_GREEN_ELT_OFFSET; i<(CE0_SHARP_MEM_LUT_GREEN_ELT_OFFSET + CE0_SHARP_MEM_LUT_GREEN_ELT_DIMENSION*4); i=i+4){ hv_SetReg(t1_to_arm(i),(*g_gamma_table++) );} 
    for(i=CE0_SHARP_MEM_LUT_RED_ELT_OFFSET; i<(CE0_SHARP_MEM_LUT_RED_ELT_OFFSET + CE0_SHARP_MEM_LUT_RED_ELT_DIMENSION*4); i=i+4){ hv_SetReg(t1_to_arm(i),(*r_gamma_table++) );} 
    for(i=CE0_SHARP_MEM_LUT_BLUE_ELT_OFFSET; i<(CE0_SHARP_MEM_LUT_BLUE_ELT_OFFSET + CE0_SHARP_MEM_LUT_BLUE_ELT_DIMENSION*4); i=i+4){ hv_SetReg(t1_to_arm(i), (*b_gamma_table++) );} 

    r_gamma_table= (t_uint16 *)addr;
    g_gamma_table= (t_uint16 *)addr+CE0_UNSHARP_MEM_LUT_RED_ELT_DIMENSION;
    b_gamma_table= (t_uint16 *)addr+CE0_UNSHARP_MEM_LUT_RED_ELT_DIMENSION+CE0_UNSHARP_MEM_LUT_GREEN_ELT_DIMENSION;
    for(i=CE0_UNSHARP_MEM_LUT_GREEN_ELT_OFFSET; i<(CE0_UNSHARP_MEM_LUT_GREEN_ELT_OFFSET + CE0_UNSHARP_MEM_LUT_GREEN_ELT_DIMENSION*4); i=i+4){ hv_SetReg(t1_to_arm(i),(*g_gamma_table++) );} 
    for(i=CE0_UNSHARP_MEM_LUT_RED_ELT_OFFSET; i<(CE0_UNSHARP_MEM_LUT_RED_ELT_OFFSET + CE0_UNSHARP_MEM_LUT_RED_ELT_DIMENSION*4); i=i+4){ hv_SetReg(t1_to_arm(i),(*r_gamma_table++) );} 
    for(i=CE0_UNSHARP_MEM_LUT_BLUE_ELT_OFFSET; i<(CE0_UNSHARP_MEM_LUT_BLUE_ELT_OFFSET + CE0_UNSHARP_MEM_LUT_BLUE_ELT_DIMENSION*4); i=i+4){ hv_SetReg(t1_to_arm(i),(*b_gamma_table++) );} 
   if (hw){
	ISP_R_W(ISP_CE0_FLEXTF_SHARP_LAST_ELT_GREEN_GIR,0x3ff);
	ISP_R_W(ISP_CE0_FLEXTF_SHARP_LAST_ELT_RED,0x3ff);
	ISP_R_W(ISP_CE0_FLEXTF_SHARP_LAST_ELT_BLUE,0x3ff);
	ISP_R_W(ISP_CE0_FLEXTF_UNSHARP_LAST_ELT_GREEN_GIR,0x3ff);
	ISP_R_W(ISP_CE0_FLEXTF_UNSHARP_LAST_ELT_RED,0x3ff);
	ISP_R_W(ISP_CE0_FLEXTF_UNSHARP_LAST_ELT_BLUE,0x3ff);
  	ISP_R_W(ISP_CE0_FLEXTF_SHARP_PIXELIN_SHIFT,0x00);
	ISP_R_W(ISP_CE0_FLEXTF_UNSHARP_PIXELIN_SHIFT,0x00);
    } else {
    ITE_writePE(CE_GammaControl_0_u8_GammaPixelInShift_Sharp_Byte0,0x00);
    ITE_writePE(CE_GammaControl_0_u8_GammaPixelInShift_UnSharp_Byte0,0x00);
    }
}
/* -----------------------------------------------------------------------
FUNCTION :  Send_System_Params
PURPOSE  :  Function to set flash mode and then toggle system coin
------------------------------------------------------------------------ */
static void
Send_System_Params (
Flag_te toggleCoin, 
Flag_te enableFlash)
{
    Coin_te control_coin,
            status_coin;

    //1. Write Flashmode
    ITE_writePE(FlashControl_e_Flag_FlashMode_Byte0, (t_uint32) enableFlash);

    //2. Toggle System Coin
    control_coin = (Coin_te) ITE_readPE(SystemSetup_e_Coin_Ctrl_Byte0);
    status_coin = (Coin_te) ITE_readPE(SystemConfig_Status_e_Coin_Status_Byte0);

    if (control_coin == status_coin)
    {
        if (Flag_e_TRUE == toggleCoin)
        {
            LOS_Log("\nToggling Coin..\n");
            ITE_writePE(SystemSetup_e_Coin_Ctrl_Byte0, !control_coin);
        }
    }
    else
    {
        LOS_Log("\nWarning:coins in unexpected state. Could be because ite_bms_start() got called.\n");
    }
    
    
    ITE_RefreshEventCount(Event0_Count_u16_EVENT0_19_EXPOSURE_AND_WB_PARAMETERS_UDPATE_Byte0);
    ITE_RefreshEventCount(Event0_Count_u16_EVENT0_17_GLACE_STATS_READY_Byte0);
    ITE_RefreshEventCount(Event3_Count_u16_EVENT3_0_DMA_GRAB_OK_Byte0);
}
static void
Enable_Adsoc(
t_uint32    pipe_no,
t_bool      enableBit)
{
    LOS_Log("\n>> Enable_Adsoc : pipe number = %d, enableBit = %d\n", pipe_no, enableBit);
    if (0 == pipe_no)
    {
        ITE_writePE(Adsoc_PK_Ctrl_0_e_Flag_Adsoc_PK_Enable_Byte0, enableBit);
    }
    else if (1 == pipe_no)
    {
        ITE_writePE(Adsoc_PK_Ctrl_1_e_Flag_Adsoc_PK_Enable_Byte0, enableBit);
    }
    else
    {
        // HandleInvalidPipe(pipe_no);
    }


    if (HostInterfaceHighLevelState_e_RUNNING == ITE_readPE(HostInterface_Status_e_HostInterfaceHighLevelState_Byte0))
    {
        ITE_NMF_GlaceHistoExpStatsRequestAndWait();
    }


    LOS_Log("\n<< Enable_Adsoc");
}
Exemplo n.º 6
0
/*StatsBuffersStorage_t* ITE_NMF_createFocusStatsBuffer(tps_siaMetaDatabuffer pBufferMetaData)
{
    StatsBuffersStorage_t* pStatsBufferStorage = 0;
    int i;
    int size = sizeof(AFStats_Statistics_ts) ;
    if (pBufferMetaData->handle == 0) {
        pBufferMetaData->handle = LOS_Alloc(size, 1024*1024*16,LOS_MAPPING_CREATE_UNCACHED_UNBUFFERED);
        //pBufferMetaData->phyaddress = ILOS_GetPhysicalAddress(pBufferMetaData->handle);
        pBufferMetaData->logAddress = LOS_GetLogicalAddress(pBufferMetaData->handle);
        }
    else LOS_Log("WARNING BufferMetaData already exist!!!!!!\n");

    if(pBufferMetaData->handle != 0)
	{	//init buffer: mandatory for buffer fill test
	  for (i=0; i<size; i++)
	      * ((t_uint8 *) pBufferMetaData->logAddress + i) = 0xff;
	}
    else LOS_Log("!!!!!!!!!!!! Allocate buffer error !!!!!!!!!!!!\n");

    pBufferMetaData->ISPBufferBaseAddress = ITE_NMF_mapStatisticsMemArea(pBufferMetaData->phyaddress);
    pStatsBufferStorage = (StatsBuffersStorage_t *) pBufferMetaData->logAddress;

    return(pStatsBufferStorage);
}

*/
void
ITE_NMF_FocusStatsPrepare(void)
{
    //ITE_NMF_createFocusStatsBuffer(pFocusStatsBuffer);
    //pFocusStore = g_pFocusStatsBufferStorage;
    ITE_writePE(AFStats_Controls_pu32_HostAssignedAddr_Byte0, pFocusStatsBuffer->ISPBufferBaseAddress);
    ITE_writePE(FrameParamStatus_Af_pu32_HostAssignedFrameStatusAddr_Byte0, pAfFrameStatusBuffer->ISPBufferBaseAddress);    
}
/* -----------------------------------------------------------------------
FUNCTION : Apply exp, wb, analog gain settings.
PURPOSE  : Function to set system config settings.
------------------------------------------------------------------------ */
static void
ConfigureSystemConfigParams(
t_uint32    timeus,
t_uint32    AGain)
{
    LOS_Log("\nConfigure SystemConfigParams now..\n");

    ITE_writePE(Exposure_DriverControls_u32_TargetExposureTime_us_Byte0, timeus);
    ITE_writePE(Exposure_DriverControls_u16_TargetAnalogGain_x256_Byte0, AGain);
}
void //__NO_WARNING__
ITE_NMF_gammacontrol0enablepe(){
   int isp_state;

   isp_state = ITE_readPE(HostInterface_Status_e_HostInterfaceHighLevelState_Byte0);
   if (isp_state == HostInterfaceHighLevelState_e_RUNNING){ 
	STOPVPIP();
   	ITE_writePE(CE_GammaControl_0_e_GammaCurve_Byte0,GammaCurve_Custom);
   	STARTVPIP();
   }else {
	ITE_writePE(CE_GammaControl_0_e_GammaCurve_Byte0,GammaCurve_Custom);
   }
}
void
Configure_Gridiron_StaticPrarams(
t_uint32    pixel_order,
t_uint32    reference_cast_count)
{
    /// Default Value for Cast Position0
    float   f_GridIronCastPosition0 = K_REFERENCE_CAST_0;

    /// Default Value for Cast Position1
    float   f_GridIronCastPosition1 = K_REFERENCE_CAST_1;

    /// Default Value for Cast Position2
    float   f_GridIronCastPosition2 = K_REFERENCE_CAST_2;

    /// Default Value for Cast Position3
    float   f_GridIronCastPosition3 = K_REFERENCE_CAST_3;

    LOS_Log("=====================GRID IRON STATIC CONFIGURAION=====================\n");

    LOS_Log("pixel_order = %d, reference_cast_count = %d\n", pixel_order, reference_cast_count);

    // <Hem> IEEE float conversion result was wrong when rValue of below expression is put in the 2nd argument of the ITE_writePE() being done below.
    // Therefore do casting below
    t_uint32    u32_GridIronCastPosition0 = *(( t_uint32 * ) &f_GridIronCastPosition0);
    t_uint32    u32_GridIronCastPosition1 = *(( t_uint32 * ) &f_GridIronCastPosition1);
    t_uint32    u32_GridIronCastPosition2 = *(( t_uint32 * ) &f_GridIronCastPosition2);
    t_uint32    u32_GridIronCastPosition3 = *(( t_uint32 * ) &f_GridIronCastPosition3);

    // set reference casts
    ITE_writePE(GridironControl_f_CastPosition0_Byte0, u32_GridIronCastPosition0);
    ITE_writePE(GridironControl_f_CastPosition1_Byte0, u32_GridIronCastPosition1);
    ITE_writePE(GridironControl_f_CastPosition2_Byte0, u32_GridIronCastPosition2);
    ITE_writePE(GridironControl_f_CastPosition3_Byte0, u32_GridIronCastPosition3);

    // set active reference cast count to 3
    ITE_writePE(GridironControl_u8_Active_ReferenceCast_Count_Byte0, reference_cast_count);

    // set gridIron grid width and height values
    ITE_writePE(GridironControl_u16_GridWidth_Byte0, 65);
    ITE_writePE(GridironControl_u16_GridHeight_Byte0, 49);

    // set verticle and horizontal flip values
    ITE_writePE(GridironControl_e_Flag_VerFlip_Byte0, VER_FLIP_VALUE);
    ITE_writePE(GridironControl_e_Flag_HorFlip_Byte0, HOR_FLIP_VALUE);

    ITE_writePE(GridironControl_e_PixelOrder_Byte0, pixel_order);

    Enable_Gridiron(Flag_e_TRUE);
    LOS_Log("=====================================================================\n");
}
void //__NO_WARNING__
ITE_NMF_gammacontrol1disablepe(){
   int isp_state;

   isp_state = ITE_readPE(HostInterface_Status_e_HostInterfaceHighLevelState_Byte0);
   if (isp_state == HostInterfaceHighLevelState_e_RUNNING){ 
	STOPVPIP();
   	ITE_writePE(CE_GammaControl_1_e_GammaCurve_Byte0,GammaCurve_Disable);
   	STARTVPIP();
   }else {
   	ITE_writePE(CE_GammaControl_1_e_GammaCurve_Byte0,GammaCurve_Disable);
        ITE_ActivePipe(GRBPID_PIPE_LR, 1);
	STARTVPIP();
	STOPVPIP();
	ITE_ActivePipe(GRBPID_PIPE_LR,0);
   }
}
//ported on 8500 V1
void ITE_ActivePipe(enum e_grabPipeID pipe,
                    t_uint32 enable) {

//ts_OutputPipe* MyPointer = NULL;

    if(pipe == GRBPID_PIPE_HR)
    {
        //MyPointer = &OutputPipeHRInfo;
        //MyPointer->PipeControl.bPipeControl = enable;
        ITE_writePE(DataPathControl_e_Flag_Pipe0Enable_Byte0, enable);

    }
    else
    {
        //MyPointer = &OutputPipeLRInfo;
        //MyPointer->PipeControl.bPipeControl = enable;
        ITE_writePE(DataPathControl_e_Flag_Pipe1Enable_Byte0, enable);

    }


}
t_uint32 ConfigureForcedGrabMode(GrabMode_te e_Grab_Mode)
{
    LOS_Log("\n>> ConfigureForcedGrabMode \n");

    // set beginning counter for GRABOK done thus far
    g_u32_GrabOK_Count_Begin = ITE_readPE(Event3_Count_u16_EVENT3_0_DMA_GRAB_OK_Byte0); 

    // set beginning counter for GRAB NOK done thus far
    g_u32_Grab_NOK_Count_Begin = ITE_readPE(Event3_Count_u16_EVENT3_0_DMA_GRAB_NOK_Byte0);     

    // set beginning counter for total no. of bms abort done thus far
    g_u32_Grab_Abort_Count_Begin = ITE_readPE(Event3_Count_u16_EVENT3_2_DMA_GRAB_Abort_Byte0);     

    LOS_Log("g_u32_GrabOK_Count_Begin = %u, g_u32_Grab_NOK_Count_Begin = %u, g_u32_Grab_Abort_Count_Begin = %u\n", g_u32_GrabOK_Count_Begin, g_u32_Grab_NOK_Count_Begin, g_u32_Grab_Abort_Count_Begin);
    
    // now set ForceGrabOk PE to value as indicated by caller
    ITE_writePE(SystemSetup_e_GrabMode_Ctrl_Byte0, e_Grab_Mode);
    
    LOS_Log("<< ConfigureForcedGrabMode \n");

    return 0;
}
int
TestGridironLiveCast(void)
{
    //  f_GridIronLiveCast[index][0] = Value of live cast to program ; f_GridIronLiveCast[index][0] = expected value of live cast
    float       f_GridIronLiveCast[][2] =
    {
        { K_REFERENCE_CAST_0 + 10,
                K_REFERENCE_CAST_0 },
                { K_REFERENCE_CAST_0,
                K_REFERENCE_CAST_0 },
                { K_REFERENCE_CAST_0 - 10,
                K_REFERENCE_CAST_0 - 10 },
                { K_REFERENCE_CAST_1 + 10,
                K_REFERENCE_CAST_1 + 10 },
                { K_REFERENCE_CAST_1,
                K_REFERENCE_CAST_1 },
                { K_REFERENCE_CAST_1 - 10,
                K_REFERENCE_CAST_1 - 10 },
                { K_REFERENCE_CAST_2 + 10,
                K_REFERENCE_CAST_2 + 10 },
                { K_REFERENCE_CAST_2,
                K_REFERENCE_CAST_2 },
                { K_REFERENCE_CAST_2 - 10,
                K_REFERENCE_CAST_2 - 10 },
                { K_REFERENCE_CAST_3 + 10,
                K_REFERENCE_CAST_3 + 10 },
                { K_REFERENCE_CAST_3,
                K_REFERENCE_CAST_3 },
                { K_REFERENCE_CAST_3 - 10,
                K_REFERENCE_CAST_3 },
                { K_TEST_LIVE_CAST_1,
                K_REFERENCE_CAST_2 },

                // because K_TEST_LIVE_CAST_1==K_REFERENCE_CAST_2
        { K_TEST_LIVE_CAST_2,
                K_TEST_LIVE_CAST_2 },
                { K_TEST_LIVE_CAST_3,
                K_TEST_LIVE_CAST_3 },
                };

    t_uint32    u32_StatusLiveCast = 0;
    float       f_StatusLiveCast = 0;
    t_uint32    count = 0;
    t_uint32    failed_Iteration_count = 0;
    char        comment[200];
    t_uint32    status_flag_cast0 = 0;
    t_uint32    status_flag_cast1 = 0;
    t_uint32    status_flag_cast2 = 0;
    t_uint32    status_flag_cast3 = 0;
    t_uint32    status_phase = 0;
    t_uint32    status_log_grid_pitch = 0;
    t_uint32    control_reference_cast_count = 0;
    t_uint32    u32_control_live_cast = 0;
    float       f_control_live_cast = 0;
    t_uint32    expected_flag_cast0 = 0;
    t_uint32    expected_flag_cast1 = 0;
    t_uint32    expected_flag_cast2 = 0;
    t_uint32    expected_flag_cast3 = 0;
    t_uint32    expected_phase = 0;
    float       f_expected_live_cast = 0;

    for (count = 0; count < (sizeof(f_GridIronLiveCast)) / (2 * sizeof(float)); count++)
    {
        ITE_writePE(
        GridironControl_f_LiveCast_Byte0,
        *(( t_uint32 * ) &f_GridIronLiveCast[count][K_INDEX_LIVE_CAST_PROGRAMMED]));

        if
        (
            HostInterfaceHighLevelState_e_RUNNING == ITE_readPE(
                HostInterface_Status_e_HostInterfaceHighLevelState_Byte0)
        )
        {
            ITE_NMF_GlaceHistoExpStatsRequestAndWait();
        }

        while (ITE_readPE(SystemSetup_e_Coin_Ctrl_Byte0) != ITE_readPE(SystemConfig_Status_e_Coin_Status_Byte0))
            ;

        u32_StatusLiveCast = ITE_readPE(GridironStatus_f_LiveCast_Byte0);
        status_flag_cast0 = ITE_readPE(GridironStatus_e_Flag_Cast0_Byte0);
        status_flag_cast1 = ITE_readPE(GridironStatus_e_Flag_Cast1_Byte0);
        status_flag_cast2 = ITE_readPE(GridironStatus_e_Flag_Cast2_Byte0);
        status_flag_cast3 = ITE_readPE(GridironStatus_e_Flag_Cast3_Byte0);
        control_reference_cast_count = ITE_readPE(GridironControl_u8_Active_ReferenceCast_Count_Byte0);

        status_phase = ITE_readPE(GridironStatus_u16_Phase_Byte0);
        status_log_grid_pitch = ITE_readPE(GridironStatus_u8_LogGridPitch_Byte0);

        f_StatusLiveCast = *(( float * ) &u32_StatusLiveCast);

        u32_control_live_cast = ITE_readPE(GridironControl_f_LiveCast_Byte0);
        f_control_live_cast = *(( float * ) &u32_control_live_cast);

        // Stack corruptino occurrs when following function call is done.
        GetExpectedParameterValues(
        control_reference_cast_count,
        K_REFERENCE_CAST_0,
        K_REFERENCE_CAST_1,
        K_REFERENCE_CAST_2,
        K_REFERENCE_CAST_3,
        f_control_live_cast,
        &expected_flag_cast0,
        &expected_flag_cast1,
        &expected_flag_cast2,
        &expected_flag_cast3,
        &expected_phase,
        &f_expected_live_cast);

        sprintf(
        comment,
        "\n\ncount = %d\nprogrammed f_GridIronLiveCast = %f, expected liveCast value = %f, retrieved f_StatusLiveCast = %f\n",
        ( int ) count,
        f_GridIronLiveCast[count][K_INDEX_LIVE_CAST_PROGRAMMED],
        f_GridIronLiveCast[count][K_INDEX_LIVE_CAST_EXPECTED],
        f_StatusLiveCast);

        mmte_testComment(comment);
        sprintf(
        comment,
        "g_GridironStatus.e_Flag_Cast0 = %d, g_GridironStatus.e_Flag_Cast1 = %d, g_GridironStatus.e_Flag_Cast2 = %d, g_GridironStatus.e_Flag_Cast3 = %d, status_phase = %u, status_log_grid_pitch =%u\n\n",
        ( int ) status_flag_cast0,
        ( int ) status_flag_cast1,
        ( int ) status_flag_cast2,
        ( int ) status_flag_cast3,
        ( unsigned int ) status_phase,
        ( unsigned int ) status_log_grid_pitch);
        mmte_testComment(comment);

        if (expected_flag_cast0 != status_flag_cast0)
        {
            sprintf(
            comment,
            "ERR : count = %u, expected_flag_cast0 = %u, status_flag_cast0 = %u\n",
            ( unsigned int ) count,
            ( unsigned int ) expected_flag_cast0,
            ( unsigned int ) status_flag_cast0);
            MMTE_TEST_COMMENT(comment);
        }


        if (expected_flag_cast1 != status_flag_cast1)
        {
            sprintf(
            comment,
            "ERR : count = %u, expected_flag_cast1 = %u, status_flag_cast1 = %u\n",
            ( unsigned int ) count,
            ( unsigned int ) expected_flag_cast1,
            ( unsigned int ) status_flag_cast1);
            MMTE_TEST_COMMENT(comment);
        }


        if (expected_flag_cast2 != status_flag_cast2)
        {
            sprintf(
            comment,
            "ERR : count = %u, expected_flag_cast2 = %u, status_flag_cast2 = %u\n",
            ( unsigned int ) count,
            ( unsigned int ) expected_flag_cast2,
            ( unsigned int ) status_flag_cast2);
            MMTE_TEST_COMMENT(comment);
        }


        if (expected_flag_cast3 != status_flag_cast3)
        {
            sprintf(
            comment,
            "ERR : count = %u, expected_flag_cast3 = %u, status_flag_cast3 = %u\n",
            ( unsigned int ) count,
            ( unsigned int ) expected_flag_cast3,
            ( unsigned int ) status_flag_cast3);
            MMTE_TEST_COMMENT(comment);
        }


        if (expected_phase != status_phase)
        {
            sprintf(
            comment,
            "ERR : count = %u, expected_phase = %u, status_phase = %u\n",
            ( unsigned int ) count,
            ( unsigned int ) expected_phase,
            ( unsigned int ) status_phase);
            MMTE_TEST_COMMENT(comment);
        }


        if (f_expected_live_cast != f_StatusLiveCast)
        {
            sprintf(
            comment,
            "ERR : count = %u, f_expected_live_cast = %f, f_StatusLiveCast = %f\n",
            ( unsigned int ) count,
            f_expected_live_cast,
            f_StatusLiveCast);
            MMTE_TEST_COMMENT(comment);
        }
    }


    LOS_Log("failed_Iteration_count = %u\n", failed_Iteration_count);
    return (failed_Iteration_count);
}
/*
t_cmd_list  ite_cmd_list_gridiron[] =
{
    { "ConfigureGridIron", C_ite_dbg_ConfigureGridIron_cmd, "ConfigureGridIron : Configures grid iron \n" }
    { "TestGridIron", C_ite_dbg_TestGridIron_cmd, "TestGridIron : Tests GridIron \n" }
};
*/
void
Enable_Gridiron(
t_bool  enableBit)
{
    ITE_writePE(GridironControl_e_Flag_Enable_Byte0, enableBit);
}
static t_uint32
Configure_Adsoc_Radial_Peaking(
t_uint32    pipe_no)
{
    LOS_Log("\n>> Configure_Adsoc_Radial_Peaking : pipe number = %d\n", pipe_no);
    if (0 == pipe_no)
    {
        ITE_writePE(Adsoc_RP_Ctrl_0_u16_Lens_Centre_HOffset_Byte0, g_u32_RP_Lens_Centre_HOffset);
        ITE_writePE(Adsoc_RP_Ctrl_0_u16_Lens_Centre_VOffset_Byte0, g_u32_RP_Lens_Centre_VOffset);
        ITE_writePE(Adsoc_RP_Ctrl_0_e_Flag_Adsoc_RP_Enable_Byte0, g_u32_RP_Flag_Adsoc_RP_Enable);
        ITE_writePE(Adsoc_RP_Ctrl_0_u8_Radial_Adsoc_RP_Polycoef0_Byte0, g_u32_RP_Radial_Adsoc_RP_Polycoef0);
        ITE_writePE(Adsoc_RP_Ctrl_0_u8_Radial_Adsoc_RP_Polycoef1_Byte0, g_u32_RP_Radial_Adsoc_RP_Polycoef1);
        ITE_writePE(Adsoc_RP_Ctrl_0_u8_Radial_Adsoc_RP_COF_Shift_Byte0, g_u32_RP_Radial_Adsoc_RP_COF_Shift);
        ITE_writePE(Adsoc_RP_Ctrl_0_u8_Radial_Adsoc_RP_Out_COF_Shift_Byte0, g_u32_RP_Radial_Adsoc_RP_Out_COF_Shift);
        ITE_writePE(Adsoc_RP_Ctrl_0_u8_Radial_Adsoc_RP_Unity_Byte0, g_u32_RP_Radial_Adsoc_RP_Unity);
    }
    else if (1 == pipe_no)
    {
        ITE_writePE(Adsoc_RP_Ctrl_1_u16_Lens_Centre_HOffset_Byte0, g_u32_RP_Lens_Centre_HOffset);
        ITE_writePE(Adsoc_RP_Ctrl_1_u16_Lens_Centre_VOffset_Byte0, g_u32_RP_Lens_Centre_VOffset);
        ITE_writePE(Adsoc_RP_Ctrl_1_e_Flag_Adsoc_RP_Enable_Byte0, g_u32_RP_Flag_Adsoc_RP_Enable);
        ITE_writePE(Adsoc_RP_Ctrl_1_u8_Radial_Adsoc_RP_Polycoef0_Byte0, g_u32_RP_Radial_Adsoc_RP_Polycoef0);
        ITE_writePE(Adsoc_RP_Ctrl_1_u8_Radial_Adsoc_RP_Polycoef1_Byte0, g_u32_RP_Radial_Adsoc_RP_Polycoef1);
        ITE_writePE(Adsoc_RP_Ctrl_1_u8_Radial_Adsoc_RP_COF_Shift_Byte0, g_u32_RP_Radial_Adsoc_RP_COF_Shift);
        ITE_writePE(Adsoc_RP_Ctrl_1_u8_Radial_Adsoc_RP_Out_COF_Shift_Byte0, g_u32_RP_Radial_Adsoc_RP_Out_COF_Shift);
        ITE_writePE(Adsoc_RP_Ctrl_1_u8_Radial_Adsoc_RP_Unity_Byte0, g_u32_RP_Radial_Adsoc_RP_Unity);
    }
    else
    {
        // HandleInvalidPipe(pipe_no);
    }


    LOS_Log("\n<< Configure_Adsoc_Radial_Peaking\n");
    return (0);
}
void //__NO_WARNING__
ITE_NMF_linearcontroldisablepe(){
	ITE_writePE(SDL_Control_e_SDLMode_Control_Byte0, SDL_Disable);
        while (ITE_readPE(SDL_Status_e_SDLMode_Status_Byte0) != SDL_Disable){};
}
void ITE_NMF_gridironcontroldisablepe(){
	ITE_writePE(GridironControl_e_Flag_Enable_Byte0,Flag_e_FALSE);
}
//ported on 8500
void ITE_FramerateTest(char * ap_test_id, char * ap_grabvpip_options)
{
   ITE_Log_RW_pageelements_enable();

   ITE_Log_Event_disable();

   mmte_testStart("test_manual_framerate"," test Framerate", g_out_path);

   ITE_InitUseCase(ap_test_id, ap_grabvpip_options,&usecase);

   ITE_Start_Env(&usecase,ap_grabvpip_options,0,0);

   mmte_testComment("Set AntiFlickerExposureControls_fGuaranteeStaticFlickerFrameLength to FALSE to guaranty static framerate is respected");
   ITE_writePE(HostFrameConstraints_e_Flag_GuaranteeStaticFlickerFrameLength_Byte0,Flag_e_FALSE);

   ITE_LR_Prepare(&usecase, INFINITY);

   //ITE_SetFrameRateControl(FrameRateMode_Manual,framerate,5,30);

   ITE_LR_Start(INFINITY);

   //2 secs viewfinder
   LOS_Log("\n2secs stream on LR pipe\n");
   LOS_Sleep(2000);

   #if defined(__PEPS8500_SIA)
   ITE_unitaryTestStaticFramerate(1.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(2.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(3.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(4.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(5.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(6.0,GRBPID_PIPE_LR);

   #else

   ITE_unitaryTestStaticFramerate(5.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(15.0,GRBPID_PIPE_LR);
   ITE_unitaryTestStaticFramerate(30.0,GRBPID_PIPE_LR);
   //check on high framerate only on swordfish sensor

   if IS_TOSH_SENSOR_USED
   //if (SensorsInfo[ite_sensorselect].revision.identity==8510)
   {
	   ITE_unitaryTestStaticFramerate(60.0,GRBPID_PIPE_LR);
	   ITE_unitaryTestStaticFramerate(90.0,GRBPID_PIPE_LR);
	   //not achievable with this config: max is 109fps : change HostRXMaxDataRate to achieve 120fps
	   ITE_unitaryTestStaticFramerate(120.0,GRBPID_PIPE_LR);
   }

   #endif

   ITE_LR_Stop();

   ITE_LR_Free();

   ITE_Stop_Env();

   // end test
   mmte_testEnd();


}
/* -----------------------------------------------------------------------
FUNCTION : FlashTest_FlashDriver.
PURPOSE  : This function will test flash functionality with flash driver enabled and then check
                  whether flash has been lit or not by analyzing the histogram stats.
------------------------------------------------------------------------ */
CMD_COMPLETION C_ite_dbg_Flash_TestLitFrame_cmd(
int     a_nb_args,
char    **ap_args)
{
    t_uint16 i = 0;
    float f_meanRed = 0.0, f_meanBlue = 0.0, f_meanGreen = 0.0;
    float f_PreGreanMean = 0.0, f_PostGreanMean = 0.0;
    RESULT_te   result = SUCCESS;
    volatile StatsBuffersStorage_t           *pStore;
    char datapath[5];

    MMTE_TEST_START("Flash_TestLitFrame", "/ite_nmf/test_results_nreg/flash_tests", "Flash_TestLitFrame");

    if (a_nb_args != 2)
    {
        CLI_disp_error("Flash_TestLitFrame:  Performs Flash test to check lit frame \n");
        CLI_disp_error("Flash_TestLitFrame[Syntax]: Flash_TestLitFrame <LR/HR/LRHR/BMS> \n\n");

        MMTE_TEST_SKIPPED();
        return (CMD_ERR_ARGS);
    }

    if (Flag_e_FALSE == Is_Flash_Supported())
    {
        MMTE_TEST_SKIPPED();
        return (CMD_COMPLETE);
    }

    strcpy(datapath, ap_args[1]);

    //prepare the selected datapath
    if (0 == strcmp(datapath,"LR"))
    {
        ITE_LR_Prepare(&usecase, INFINITY);
    }
    else if (0 == strcmp(datapath,"HR"))
    {
        ITE_HR_Prepare(&usecase, INFINITY);
    }
    else if (0 == strcmp(datapath,"BMS"))
    {
        ITE_BMS_Prepare(&usecase, INFINITY);
    }
    else  //LRHR
    {
        ITE_LRHR_Prepare(&usecase, INFINITY);
    }


    //1. Pass
    //Set the zoom factor as x1
    ITE_writePE(Zoom_Control_f_SetFOVX_Byte0, 0);

    //Set the frame rate = 30dps
    ITE_SetFrameRateControl(30, 30);

    //Program the Glace/Histogram blocks
    ITE_NMF_SetGlaceBlockFraction(100, 100, 0, 0);
    ITE_NMF_SetHistoBlockFraction(100, 100, 0, 0);
    ITE_NMF_SetGlaceGrid(72, 54);
    ITE_NMF_SetGlaceSatLevel(255, 255, 255);

    pStore = g_pStatsBufferStorage;
    ITE_NMF_UpdateGlaceParam();
    ITE_NMF_UpdateHistoParam();

    //set stats request (witout flash) before streaming
    ITE_NMF_GlaceAndHistoReqNoWait();
    ITE_NMF_GlaceAndHistoExpReqNoWait();

    //Start streamind the datapath
    if (0 == strcmp(datapath,"LR"))
    {
        ITE_LR_Start( INFINITY);
    }
    else if (0 == strcmp(datapath,"HR"))
    {
        ITE_HR_Start( INFINITY);
    }
    else if (0 == strcmp(datapath,"BMS"))
    {
        ITE_BMS_Start( INFINITY);
    }
    else  //LRHR
    {
        ITE_LRHR_Start( INFINITY);
    }

    ITE_NMF_WaitStatReady(ISP_GLACE_STATS_READY);

    //Glace and Histo gram stats recvd without flash
    //Calculate the mean energy from R component
    for(i = 0; i < 256; i++)
    {
        f_meanRed  	+=	*((pStore->apHistR) + i) / (256 - i );
        f_meanBlue 	+=	*((pStore->apHistB) + i) / (256 - i );
        f_meanGreen +=	*((pStore->apHistG) + i) / (256 - i ) ;
    }

    f_PreGreanMean = f_meanGreen;
    LOS_Log("\n Histogram mean energy .. \n");
    LOS_Log("\n Red mean energy - %f \n",f_meanRed);
    LOS_Log("\n Blue mean energy - %f \n",f_meanBlue);
    LOS_Log("\n Green mean energy - %f \n",f_meanGreen);

    //2nd Pass.
    //Request for stats with flash this time
    f_meanRed = 0.0;
    f_meanBlue = 0.0;
    f_meanGreen = 0.0;

    memset(g_pStatsBufferStorage->apHistG, 0, 256 * 4);

    if (0 == strcmp(datapath,"LR"))
    {
        ITE_LR_Stop();
    }
    else if (0 == strcmp(datapath,"HR"))
    {
        ITE_HR_Stop();
    }
    else if (0 == strcmp(datapath,"BMS"))
    {
        ITE_BMS_Stop();
    }
    else  //LRHR
    {
        ITE_LRHR_Stop();
    }

    // Fire flash and and re-calculate the energy
     ITE_NMF_GlaceAndHistoReqNoWait();
     Send_System_Params(Flag_e_TRUE, Flag_e_TRUE);


    if (0 == strcmp(datapath,"LR"))
    {
        ITE_LR_Start( INFINITY);
    }
    else if (0 == strcmp(datapath,"HR"))
    {
        ITE_HR_Start( INFINITY);
    }
    else if (0 == strcmp(datapath,"BMS"))
    {
        ITE_BMS_Start( INFINITY);
    }
    else  //LRHR
    {
        ITE_LRHR_Start( INFINITY);
    }

     ITE_NMF_WaitStatReady(ISP_GLACE_STATS_READY);

    //Glace and Histo gram stats recvd with flash
    //Calculate the mean energy from R component
    for(i = 0; i < 256; i++)
    {
        f_meanRed  	+=	*((pStore->apHistR) + i) / (256 - i );
        f_meanBlue 	+=	*((pStore->apHistB) + i) / (256 - i );
        f_meanGreen +=	*((pStore->apHistG) + i) / (256 - i ) ;
    }

    f_PostGreanMean = f_meanGreen;
    LOS_Log("\n Histogram mean energy .. \n");
    LOS_Log("\n Red mean energy - %f \n",f_meanRed);
    LOS_Log("\n Blue mean energy - %f \n",f_meanBlue);
    LOS_Log("\n Green mean energy - %f \n",f_meanGreen);

    f_meanRed = 0.0;
    f_meanBlue = 0.0;
    f_meanGreen = 0.0;

    if((result == SUCCESS) && (f_PostGreanMean >= f_PreGreanMean))
    {
         MMTE_RESULT_PASSED();
    }
    else
    {
        MMTE_RESULT_FAILED();
    }

    //Stop/clear the test
    if (0 == strcmp(datapath,"LR"))
    {
        ITE_LR_Stop();
        ITE_LR_Free();
    }
    else if (0 == strcmp(datapath,"HR"))
    {
        ITE_HR_Stop();
        ITE_HR_Free();
    }
    else if (0 == strcmp(datapath,"BMS"))
    {
        ITE_BMS_Stop();
        ITE_BMS_Free();
    }
    else  //LRHR
    {
        ITE_LRHR_Stop();
        ITE_LRHR_Free();
    }

    MMTE_TEST_END();
    Send_System_Params(Flag_e_FALSE, Flag_e_FALSE);  //cleanup

    return (CMD_COMPLETE);
}
/* -----------------------------------------------------------------------
   FUNCTION : ITE_FLASH_BMSDatapath
   PURPOSE  : Put sensor in color bar test mode, stream on BMS pipe and check ouput frame automaticaly
   ------------------------------------------------------------------------ */
void
ITE_FLASH_BMSDatapath(
char    *ap_test_id,
char    *ap_grabvpip_options)
{
    Coin_te status_coin;

    ITE_Log_RW_pageelements_enable();

    ITE_Log_Event_enable();
    mmte_testStart("test_BMSdatapath", " test pipe BMS with sensor in test mode", g_out_path);

    ITE_InitUseCase(ap_test_id, ap_grabvpip_options, &usecase);

    ITE_Start_Env(&usecase, ap_grabvpip_options, 0, 0);

    usecase.BMS_Mode = BMSSTILL;
    usecase.BMS_output = BAYERSTORE2;
    usecase.BMS_GrbFormat = GRBFMT_RAW8;


    LOS_Log("flash mode = 1 no coin \n");
    ITE_BMS_Prepare(&usecase, INFINITY);
    ITE_writePE(FlashControl_e_Flag_FlashMode_Byte0, 1);

    //Grab one frame
    ITE_BMS_Start(1);

    LOS_Log("\nStream 1 frame on BMS\n");
    LOS_Sleep(5000);
    status_coin = (Coin_te) ITE_readPE(SystemConfig_Status_e_Coin_Status_Byte0);
    ITE_writePE(SystemSetup_e_Coin_Ctrl_Byte0, !status_coin);

    LOS_Log("\nStream 1 frame on BMS\n");
    LOS_Sleep(5000);
    ITE_BMS_Stop();

    LOS_Log("flash mode = 1  coin=0 \n");
    ITE_BMS_Prepare(&usecase, INFINITY);
    ITE_writePE(FlashControl_e_Flag_FlashMode_Byte0, 1);
    status_coin = (Coin_te) ITE_readPE(SystemConfig_Status_e_Coin_Status_Byte0);
    ITE_writePE(SystemSetup_e_Coin_Ctrl_Byte0, !status_coin);

    //Grab one frame
    ITE_BMS_Start(1);

    LOS_Log("\nStream 1 frame on BMS\n");
    LOS_Sleep(5000);
    ITE_BMS_Stop();

    LOS_Log("flash mode = 1 request 10 frames coin=1 \n");
    ITE_BMS_Prepare(&usecase, INFINITY);
    ITE_writePE(FlashControl_e_Flag_FlashMode_Byte0, 1);
    status_coin = (Coin_te) ITE_readPE(SystemConfig_Status_e_Coin_Status_Byte0);
    ITE_writePE(SystemSetup_e_Coin_Ctrl_Byte0, !status_coin);

    //Grab one frame
    ITE_BMS_Start(10);

    LOS_Log("\nStream 1 frame on BMS\n");
    LOS_Sleep(5000);

    //ITE_writePE(FlashControl_e_Flag_FlashMode_Byte0, 0);
    ITE_BMS_Abort();
    LOS_Sleep(5000);
    ITE_BMS_Stop();

    mmte_testNext("check if colorbar detected in BMS buffer");
    if (TestColorBarbuffer(&(GrabBufferBMS[0]), COLOR_BAR__DEFAULT_TESTING_POSITION) == 0)
    {
        LOS_Log("\nColor bar successfully detected on GrabBufferBMS[0] buffer\n");
        mmte_testResult(TEST_PASSED);
    }
    else
    {
        LOS_Log("\nTEST FAIL: Color bar not properly detected on GrabBufferBMS[0] buffer\n");
        mmte_testResult(TEST_FAILED);
    }


    //Temporary Patch: use of LR
    ITE_LR_Free();

    ITE_BMS_Free();

    ITE_Stop_Env();

    // end test
    mmte_testEnd();
}
static void
Configure_Adsoc_Peaking(
t_uint32    pipe_no)
{
    LOS_Log("\n>> Configure_Adsoc_Peaking : pipe number = %d\n", pipe_no);
    if (0 == pipe_no)
    {
        ITE_writePE(Adsoc_PK_Ctrl_0_e_Flag_Adsoc_PK_AdaptiveSharpening_Enable_Byte0, g_u32_PK_Sharpening_Enable);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_Coring_Level_Byte0, g_u32_PK_Coring_Level);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_OverShoot_Gain_Bright_Byte0, g_u32_PK_OverShoot_Gain_Bright);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_OverShoot_Gain_Dark_Byte0, g_u32_PK_OverShoot_Gain_Dark);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_Emboss_Effect_Ctrl_Byte0, g_u32_PK_Emboss_Effect_Ctrl);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_Flipper_Ctrl_Byte0, g_u32_PK_Flipper_Ctrl);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_GrayBack_Ctrl_Byte0, g_u32_PK_GrayBack_Ctrl);
        ITE_writePE(Adsoc_PK_Ctrl_0_u8_Adsoc_PK_Gain_Byte0, g_u32_PK_Gain);
    }
    else if (1 == pipe_no)
    {
        ITE_writePE(Adsoc_PK_Ctrl_1_e_Flag_Adsoc_PK_AdaptiveSharpening_Enable_Byte0, g_u32_PK_Sharpening_Enable);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Coring_Level_Byte0, g_u32_PK_Coring_Level);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_OverShoot_Gain_Bright_Byte0, g_u32_PK_OverShoot_Gain_Bright);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_OverShoot_Gain_Dark_Byte0, g_u32_PK_OverShoot_Gain_Dark);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Emboss_Effect_Ctrl_Byte0, g_u32_PK_Emboss_Effect_Ctrl);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Flipper_Ctrl_Byte0, g_u32_PK_Flipper_Ctrl);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_GrayBack_Ctrl_Byte0, g_u32_PK_GrayBack_Ctrl);
        ITE_writePE(Adsoc_PK_Ctrl_1_u8_Adsoc_PK_Gain_Byte0, g_u32_PK_Gain);
    }
    else
    {
        // HandleInvalidPipe(pipe_no);
    }


    LOS_Log("<< Configure_Adsoc_Peaking\n");
}