⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msapi_scaler.c

📁 mstar 776 开发的车载dvd
💻 C
📖 第 1 页 / 共 4 页
字号:
// -Vertical start position
// @param u16HSize \b IN
// -Horizontal size
// @param u16VSize \b IN
// -Vertical size
/******************************************************************************/
void msAPI_Scaler_SetCustomerDisplayWindow(BOOLEAN bEnable, U16 u16HStart, U16 u16VStart, U16 u16HSize, U16 u16VSize)
{
    if(bEnable)
    {
        u16HSize = (u16HSize + 1) & ~1; // display muset be even

        g_DisplayWindowSetting.u16H_DisStart = devPanel_HSTART() + u16HStart;
        g_DisplayWindowSetting.u16V_DisStart = devPanel_DE_VSTART() + u16VStart;
        g_DisplayWindowSetting.u16H_DisSize = u16HSize;
        g_DisplayWindowSetting.u16V_DisSize = u16VSize;

        g_DisplayWindowSetting.u8DisplayStatus |= DISPLAYWINDOW_NINELATTICE;
    }
    else
    {
        g_DisplayWindowSetting.u8DisplayStatus &= ~DISPLAYWINDOW_NINELATTICE;
    }
}

//-----------------------------------------------------------------------------
// PC mode
//-----------------------------------------------------------------------------
void msAPI_Scaler_SetTimingAndWindow ( MS_INPUT_SOURCE_TYPE enInputSourceType,
                                       EN_ASPECT_RATIO_TYPE enVideoScreen)
{
    BOOLEAN bOPClkGating;

    bOPClkGating = MDrv_Scaler_GetOPClkGating();
    MDrv_Scaler_SetOPClkGating(FALSE); // It is necessary to disable OP clock gating when change output timings.

    msAPI_Scaler_ProgramWin( enInputSourceType);// kevin (To get input capture start/size, H Freq, V total & display V freq)
    msAPI_Scaler_SetModeFlag( enInputSourceType );// kevin (To set CSC, Memory, De-interlace, Delay line parameters)
    msAPI_Scaler_SetupMode2( enInputSourceType, &g_DisplayWindowSetting );// kevin (To set CSC, VOP, EODi, Memory, De-interlace, Delay line registers)

    // start to prepare the display
    APISC_DBG(puts("\r\nPrepare Display"));// kevin ZZ
    if(g_DisplayWindowSetting.u8DisplayStatus & DISPLAYWINDOW_NINELATTICE)
    {
        // use user settings from msAPI_Scaler_SetCustomerDisplayWindow()
        ;
    }
    else
    {
        // use default settings
        MDrv_Scaler_GetStdDisplayWindow();  // kevin (To get the Panel H/V start, height, width)
    }

    if(IsPCInUse())
    {
        g_DisplayWindowSetting.u8H_OverScanRatio = 0;
        g_DisplayWindowSetting.u8V_OverScanRatio = 0;
    }
    else if (IsSrcTypeVideo(enInputSourceType))
    {
        MDrv_Scaler_CalculateOverScan( enInputSourceType, &g_DisplayWindowSetting );// kevin (Calculate the new H/V capture size & start)
    }

    MDrv_Scaler_CalculateAspectRatio(enInputSourceType, &g_DisplayWindowSetting, enVideoScreen);// kevin (Calculate the H/V display start, size)

    MDrv_Scaler_SetScalingRatio(enInputSourceType, &g_DisplayWindowSetting);// kevin (Set the H/V scaling,DNR,Filter registers)

    MDrv_Scaler_SetCaptureWindow();

    MDrv_Scaler_SetDisplayWindow();

    MDrv_Scaler_SetBorder( &g_DisplayWindowSetting, enVideoScreen );

    MDrv_Scaler_SetDEWindow();

    MDrv_Scaler_SetPanelTiming(enInputSourceType, &g_DisplayWindowSetting);

    MDrv_Scaler_FineTune( enInputSourceType, &g_DisplayWindowSetting );

#if NEW_LOCK
    MDrv_Scaler_ClearLPLL();
#endif

    MDrv_Scaler_SetOPClkGating(bOPClkGating); // Restore original OP clock gating.

// seven 070823_00
/*
#if (PANEL_ATCON||PANEL_DTCON)
    MDrv_Scaler_TCON_FineTune(enInputSourceType, &g_DisplayWindowSetting);
#endif
*/
// end
}

/******************************************************************************/
///-Set H position for PC mode
///@param u16Position \b IN
///- H position
/******************************************************************************/
void msAPI_Scaler_SetPcHPosition ( U16 u16Position )
{
    MDrv_Scaler_SetPcHPosition( (U16)MAX_PC_H_START-u16Position+MIN_PC_H_START );
}

/******************************************************************************/
///-Set V position for PC mode
///@param u16Position \b IN
///- V position
/******************************************************************************/
void msAPI_Scaler_SetPcVPosition ( U16 u16Position )
{
    MDrv_Scaler_SetPcVPosition( u16Position );
}

/******************************************************************************/
///-Set clock for PC mode
///@param u16Clock \b IN
///- PC's Input clock value
/******************************************************************************/
void msAPI_Scaler_SetPcClock ( U16 u16Clock )
{
	u16Clock=u16Clock;
//    MDrv_ADC_SetADCClk( u16Clock );
}
/******************************************************************************/
///-Set phase for PC mode
///@param u8Phase \b IN
///- PC's Phasevalue
/******************************************************************************/
void msAPI_Scaler_SetPcPhase ( U8 u8Phase )
{
    MDrv_ADC_SetADCPhase( u8Phase );
}

#if NEW_LOCK
void msAPI_Scaler_MonitorLPLL(void)
{
    MDrv_Scaler_MonitorLPLL();
}
#endif

//-----------------------------------------------------------------------------
// brightness
//-----------------------------------------------------------------------------

/******************************************************************************/
///-This function will set up brightness for PC or VIDEO port
///@param u8PcBrightness :    brightness value
/******************************************************************************/
void msAPI_Scaler_SetBrightness ( U8 u8PC,U8 u8Brightness )
{
    if(u8PC)
    {
#if UseInverterBL
        MDrv_ADC_AdjustBacklight( u8Brightness );
        MDrv_Scaler_AdjustBrightness( MAX_VGA_BRIGHTNESS );
#else    // use digital brightness
        MDrv_ADC_AdjustBacklight( MAX_VGA_BRIGHTNESS );
        MDrv_Scaler_AdjustBrightness( u8Brightness );
#endif
    }
    else
    {
        MDrv_ADC_AdjustBacklight( MAX_VIDEO_BACKLIGHT );
        MDrv_Scaler_AdjustBrightness( u8Brightness );
    }
}

void msAPI_Scaler_SetBacklight( U8 u8Blacklight )
{
    MDrv_ADC_AdjustBacklight(u8Blacklight);
}

// For SEC Factory mode used
/******************************************************************************/
///-This function will set up brightness for PC or VIDEO port
///@param u8PcBrightness :    brightness value
/******************************************************************************/
void msAPI_Scaler_SetRGBBrightness ( U8 u8PC,MS_BRIGHTNESS_SETTING stBrightness )
{
    if(u8PC)
    {
#if UseInverterBL
        MDrv_ADC_AdjustBacklight( u8Brightness );
        MDrv_Scaler_AdjustWBBrightness( MAX_VGA_BRIGHTNESS );
#else    // use digital brightness
        MDrv_ADC_AdjustBacklight( MAX_VGA_BRIGHTNESS );
        MDrv_Scaler_AdjustWBBrightness( stBrightness );
#endif
    }
    else
    {
        MDrv_ADC_AdjustBacklight( MAX_VIDEO_BACKLIGHT );
        MDrv_Scaler_AdjustWBBrightness( stBrightness );
    }
}

//-----------------------------------------------------------------------------
// SSC
//-----------------------------------------------------------------------------

#if ENABLE_SSC
/******************************************************************************/
///-This function will set up Spread sprum  span value and the step value
///@param SSC_SPAN \b IN :span value 0 - 0xffff
///@param SSC_SETP \b IN :step value 0 - 0xffff
/******************************************************************************/
void msAPI_Scaler_SetSsc( U8 u8Periodx100Hz, U16 u16Percentx100, BOOLEAN bEnable )
{
    MDrv_Scaler_SetSsc(u8Periodx100Hz, u16Percentx100, bEnable);
}
#endif

/******************************************************************************/
///-This function will Detect sync signal exist or not
///@return sync signal exist or not
///-TRUE: detect sync
///-FALSE: no sync
/******************************************************************************/
BOOLEAN msAPI_Scaler_DetectSyncActive ( void )
{
    U8 u8TempSyncStatus;
    BOOLEAN bResult = FALSE;

    u8TempSyncStatus = MDrv_Scaler_GetInputSyncStatus();
    if ( !( u8TempSyncStatus & MD_SYNC_LOSS ) ) // check no signal
    {
        bResult = TRUE;
    }

    return bResult;
}
/******************************************************************************/
///-This function will return Horizontal period value
///@return
///- U16 Horizontal Period
/******************************************************************************/
U16 msAPI_Scaler_GetHorizontalPeriod ( void )
{
    return MDrv_Scaler_GetHorizontalPeriod();
}
/******************************************************************************/
///-This function will return Vertical total value
///@return
///- U16 Vertical total
/******************************************************************************/
U16 msAPI_Scaler_GetVerticalTotal ( void )
{
    return MDrv_Scaler_GetVerticalTotal();
}

/******************************************************************************/
/// Get the horizontal period of auto postion
/// @return the horizontal period of auto postion
/******************************************************************************/
U16 msAPI_Scaler_GetHorizontalDE ( void )
{
    return MDrv_Scaler_GetHorizontalDE();
}

/******************************************************************************/
/// Get the vertical period of auto postion
/// @return the vertical period of auto postion
/******************************************************************************/
U16 msAPI_Scaler_GetVerticalDE ( void )
{
    return MDrv_Scaler_GetVerticalDE();
}
/******************************************************************************/
///-This function will calculate and return H Frequency x 10
///@param wHPeriod \b IN
///- Horizontal period
///@return
///- U16 H Frequency x 10
/******************************************************************************/

U16 msAPI_Scaler_CalculateHFreqX10 ( U16 wHPeriod )
{
    return MDrv_Scaler_CalculateHFreqX10(wHPeriod);
}
/******************************************************************************/
///-This function will calculate and return V Frequency x 10
///@param wHFreq \b IN
///- Horizontal Frequency
///@param wVTotal \b IN
///- Vertical Frequency
///@return
///- U16 V Frequency x 10
/******************************************************************************/
U16 msAPI_Scaler_CalculateVFreqX10 ( U16 wHFreq, U16 wVTotal )
{
    return MDrv_Scaler_CalculateVFreqX10(wHFreq, wVTotal);
}

/******************************************************************************/
//
/// -This function will program Field for different signal and set line buffer delay,
///  detect Field, program capture/Display (Input/output) windows information and
///  then setup output timing.(RGB and YPbPr mode)
///@param *penMsSysInfo \b IN
///-enInputSourceType
///-enInputPortType
/******************************************************************************/
void msAPI_Scaler_SetupMode2 ( MS_INPUT_SOURCE_TYPE enInputSourceType, MS_DISPLAYWINDOW_TYPE *pstDisplayWindow )
{
	// rd recommend don't use it seven&jk 070822_01
	// set field shift line
	//MDrv_Scaler_SetShiftLine(pstDisplayWindow->u8MemoryMode, pstDisplayWindow->u8DeInterlaceMode);  // set shift line between even/odd field
	// end

    // set input RGB convert to YUV or not
    if(pstDisplayWindow->u16ColorFinetuneFlag & FINETUNE_PRE_RGB2YUV)
    {
        #if ENABLE_DIGITAL_SOURCE// kevin 071213_0
        if (IsDigitalInUse())
             MDrv_Scaler_SetCSC(FALSE);
        #else
        APISC_DBG(puts("\r\nCSC Enable"));
        MDrv_Scaler_SetCSC(TRUE);
        #endif
    }
    else
    {
        APISC_DBG(puts("\r\nCSC Disbale"));
        MDrv_Scaler_SetCSC(FALSE);
    }

    // setup output sync control
    MDrv_Scaler_SetOutPutSyncControl(pstDisplayWindow->u8MemoryMode, enInputSourceType);

    // setup memory format
    MDrv_Scaler_SetMemFormat();

    // setup de-interlace
    MDrv_Scaler_SetDeInterlaceMode(pstDisplayWindow);

    // setup EODI
    MDrv_Scaler_SetEODI(pstDisplayWindow->u8EODiMode, pstDisplayWindow->u8DeInterlaceMode);

    // control film mode
    MDrv_Scaler_SetFilmMode((BIT)(pstDisplayWindow->u16ColorFinetuneFlag&FINETUNE_FILM_MODE), pstDisplayWindow->u16InputVFreq > 550);

    // Setup delay line
    MDrv_Scaler_SetDelayLine(pstDisplayWindow->u8DelayLines);           // set delay line for trigger point, for 2DDI

    // Set field detect
    MDrv_Scaler_SetFieldDetect( enInputSourceType, pstDisplayWindow );
}

/******************************************************************************/
/// -This function will return input video source status
/// @return Video status
/// - BIT0:VSnc polarity bit(0/1 = positive/negative)
/// - BIT1:HSync polarity bit(0/1 = positive/negative)
/// - BIT2:HSync loss bit
/// - BIT3:VSync loss bit
/// - BIT4:Interlace mode
/// - BIT7:User new mode (Not found in mode table)
/******************************************************************************/
U8 msAPI_Scaler_GetInputStatus ( void )
{
    return MDrv_Scaler_GetInputSyncStatus();
}

/******************************************************************************/
/// -Setup the different modes between each input sources
/// @param enInputSourceType \b IN: the input video source type
/// - INPUT_SOURCE_VGA
/// - INPUT_SOURCE_TV
/// - INPUT_SOURCE_CVBS
/// - INPUT_SOURCE_SVIDEO
/// - INPUT_SOURCE_YPBPR
/// - INPUT_SOURCE_SCART
/******************************************************************************/
void msAPI_Scaler_SetModeFlag( MS_INPUT_SOURCE_TYPE enInputSourceType )
{
    U8 u8ModeIndex = g_PcadcModeSetting.u8ModeIndex;

    //----------------------------------------------------
    // Setup Input CSC and color space
    //----------------------------------------------------
    if(IsSrcTypeVga(enInputSourceType))
    {
        // only VGA, DVI, HDMI but RGB in need to do CSC
  #if ENABLE_PC_CSC
        // do CSC and color space is YUV
        g_DisplayWindowSetting.u16ColorFinetuneFlag |= FINETUNE_PRE_RGB2YUV;
        g_DisplayWindowSetting.u16ColorFinetuneFlag |= (FINETUNE_USE_YUV_SPACE|FINETUNE_MATRIX_YUV2RGB);
  #else
        // don't do CSC and color space is RGB
        g_DisplayWindowSetting.u16ColorFinetuneFlag &= ~FINETUNE_PRE_RGB2YUV;    // Pure RGB mode, for check quality only
        g_DisplayWindowSetting.u16ColorFinetuneFlag &= ~(FINETUNE_USE_YUV_SPACE|FINETUNE_MATRIX_YUV2RGB);
  #endif
    }
    else
    {
        // for other YPbPr input source, no need to set CSC but color space is YUV
        g_DisplayWindowSetting.u16ColorFinetuneFlag &= ~FINETUNE_PRE_RGB2YUV;
        g_DisplayWindowSetting.u16ColorFinetuneFlag |= (FINETUNE_USE_YUV_SPACE|FINETUNE_MATRIX_YUV2RGB);
    }

    APISC_DBG(printf("\r\nu16ColorFinetuneFlag=%d",g_DisplayWindowSetting.u16ColorFinetuneFlag));// kevin ZZ

    //----------------------------------
    // Set Memory Mode
    //----------------------------------
  #if (MAIN_FRAME_BUF_SEL == MAIN_FRAME_BUFLESS)
    // Frame buffer less
    g_DisplayWindowSetting.u8MemoryMode = MS_MEM_FMT_NO_USE;
  #else
    // Frame buffer
    g_DisplayWindowSetting.u8MemoryMode =
        (g_DisplayWindowSetting.u16ColorFinetuneFlag & FINETUNE_USE_YUV_SPACE) ? MS_MEM_FMT_422 : MS_MEM_FMT_444;
  #endif

#ifdef DDRAM_16Mx16
    if (IsSrcHDTVMode()/* && IsDTVInUse()//kevin 071220_2*/)
    {
        g_DisplayWindowSetting.u8MemoryMode = MS_MEM_FMT_NO_USE;
    }
#endif

    APISC_DBG(printf("\r\nu8MemoryMode=%bu",g_DisplayWindowSetting.u8MemoryMode));

    //----------------------------------
    // Set De-interlaced mode
    //----------------------------------
    if(g_DisplayWindowSetting.u8DisplayStatus & DISPLAYWINDOW_INTERLACE)
    {
        // different source may have different de-interlaced mode
        // if needed, seperate the settings for difference sources
        if(IsSrcTypeDigitalVD(enInputSourceType)/* || IsSrcTypeDTV(enInputSourceType)// kevin 071220_2*/)
        {
            if (g_DisplayWindowSetting.u8MemoryMode == MS_MEM_FMT_NO_USE)
            {
                // FBL
                g_DisplayWindowSetting.u8DeInterlaceMode = MS_DEINT_OFF;
                g_DisplayWindowSetting.u8EODiMode = MS_EODI_OFF;//MS_EODI_2D;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -