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

📄 msapi_mode.c

📁 mstar 776 开发的车载dvd
💻 C
字号:
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006-2007 MStar Semiconductor, Inc.
// All rights reserved.
//
// Unless otherwise stipulated in writing, any and all information contained
// herein regardless in any format shall remain the sole proprietary of
// MStar Semiconductor Inc. and be kept in strict confidence
// (¨MStar Confidential Information〃) by the recipient.
// Any unauthorized act including without limitation unauthorized disclosure,
// copying, use, reproduction, sale, distribution, modification, disassembling,
// reverse engineering and compiling of the contents of MStar Confidential
// Information is unlawful and strictly prohibited. MStar hereby reserves the
// rights to any and all damages, losses, costs and expenses resulting therefrom.
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
/// @file msAPI_Mode.h
/// @brief API for different modes
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////

#define MSAPI_MODE_C

/******************************************************************************/
/*                    Header Files                                            */
/* ****************************************************************************/
#include <stdio.h>
#include <stdlib.h>

#include "drvGlobal.h"
#include "Panel.h"
#include "drvMode.h"
#include "drvScaler.h"
#include "drvAnalog_inline.h"
#include "color.h"

#include "msAPI_Mode.h"
#include "msAPI_Scaler.h"

#if (HDMI_CHIP_SEL == HDMI_CHIP_MST3383M)
#include "DrvHDMI_Mst3383M.h"
#endif

#define API_MODE(x)	x


/******************************************************************************/
/*                     Local                                                  */
/* ****************************************************************************/
// Set different color setting according to each input


/********************************************************************************/
/*                   Local Function Prototypes                  */
/********************************************************************************/
/********************************************************************************/
/*                   Functions                      */
/********************************************************************************/
EN_RESOLUTION_TYPE msAPI_Mode_GetStdModeResolutionIndex( U8 u8ModeIndex ) //mengfu@SEC: 20040415
{
    return( MDrv_Mode_GetStdModeResolutionIndex(u8ModeIndex) );
}

/******************************************************************************/
///-This function will get standard H resolution
///@param  u8ModeIndex: the current mode
///@return H resolution
/******************************************************************************/
U16 msAPI_Mode_GetStdModeResH ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeResH(u8ModeIndex);
}

/******************************************************************************/
///-This function will get standard V resolution
///@param u8ModeIndex: the current mode
///@return V resolution
/******************************************************************************/
U16 msAPI_Mode_GetStdModeResV ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeResV(u8ModeIndex);
}

U16 msAPI_Mode_GetStdModeVFreq(U8 u8ModeIndex)
{
    return MDrv_Mode_GetStdModeVFreq( u8ModeIndex );
}

/******************************************************************************/
///-This function will get standard H total
///@param u8ModeIndex: the current mode
///@return H total
/******************************************************************************/
U16 msAPI_Mode_GetStdModeHTotal ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeHTotal(u8ModeIndex);
}

/******************************************************************************/
///-This function will get standard V total
///@param u8ModeIndex: the current mode
///@return V total
/******************************************************************************/
U16 msAPI_Mode_GetStdModeVTotal ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeVTotal(u8ModeIndex);
}

/******************************************************************************/
///-This function will get standard H start
///@param u8ModeIndex: the current mode
///@return H start
/******************************************************************************/
U16 msAPI_Mode_GetStdModeHStart ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeHStart(u8ModeIndex);
}

/******************************************************************************/
///-This function will get standard V start
///@param u8ModeIndex: the current mode
///@return V start
/******************************************************************************/
U16 msAPI_Mode_GetStdModeVStart ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeVStart(u8ModeIndex);
}

/******************************************************************************/
///-This function will get standard of ADC phase
///@param u8ModeIndex: the current mode
///@return ADC  phase
/******************************************************************************/
U8 msAPI_Mode_GetStdModeADCPhase ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeADCPhase(u8ModeIndex);
}

/******************************************************************************/
///-This function will get standard of mode status
///@param u8ModeIndex: the current mode
///@return mode status flag
/******************************************************************************/
U8 msAPI_Mode_GetStdModeStatusFlag ( U8 u8ModeIndex )
{
    return MDrv_Mode_GetStdModeStatusFlag(u8ModeIndex);
}

U8 msAPI_Mode_GetStdMaxTableIndex(void)
{
    return MDrv_Mode_GetStdMaxTableIndex();
}

BOOLEAN msAPI_Mode_CompareModePolarity(U8 u8InputStatusFlag, U8 u8StdModeIndex)
{
    return MDrv_Mode_CompareModePolarity(u8InputStatusFlag, u8StdModeIndex);
}

/******************************************************************************/
///-This function will search matched standard mode index
///@param *pstInputType \b IN: current mode parameters
///-enResolutionIndex
///-u16HorizontalFrequency
///-u16VerticalFrequency
///-u16HorizontalStart
///-u16VerticalStart
///-u16HorizontalTotal
///-u16VerticalTotal
///-u8AdcPhase
///-u8StatusFlag
///@param enInputSourceType \b IN:current input source type
///-INPUT_SOURCE_VGA
///-INPUT_SOURCE_TV
///-INPUT_SOURCE_CVBS
///-INPUT_SOURCE_SVIDEO
///-INPUT_SOURCE_YPBPR
///-INPUT_SOURCE_SCART
///@return true value of sharpness
//*************************************************************************
U8 msAPI_Mode_MatchMode ( MS_PCADC_MODETABLE_TYPE * pstInputType, MS_INPUT_SOURCE_TYPE enInputSourceType )
{
    U16 u16HSyncBff, u16VSyncBff; // sync buffer
    U8  u8ModeIndex; // mode index

    U16 u16MinHfreq, u16MaxHfreq;
    U16 u16MinVfreq, u16MaxVfreq;
    U16 u16MinVtotal, u16MaxVtotal;

    u8ModeIndex = 0xFF;

    // clear mode flag
    g_bUnsupportMode = FALSE;
    g_u8PcUserModeRamIndex = 0xFF;

    // refresh H/V counter
    g_wHorizontalPeriod = msAPI_Scaler_GetHorizontalPeriod();
    g_wVerticalTotal    = msAPI_Scaler_GetVerticalTotal();

    // calculate H/V frequency
    u16HSyncBff = msAPI_Scaler_CalculateHFreqX10( g_wHorizontalPeriod );
    u16VSyncBff = msAPI_Scaler_CalculateVFreqX10( u16HSyncBff, g_wVerticalTotal );

    // interlace mode
    if ( g_u8CurrentSyncStatus & MD_INTERLACE_BIT )
    {
        u16VSyncBff *= 2; // vsync x 2
    }

    msAPI_Scaler_SetDisplayWindowInputFrenquency( E_ORIENTATIOM_HORIZONTAL, u16HSyncBff);
    msAPI_Scaler_SetDisplayWindowInputFrenquency( E_ORIENTATIOM_VERTICAL, u16VSyncBff);

    if( IsPCInUse())
    {
        u16MinHfreq    = MIN_HFREQ_OF_RGB;
        u16MaxHfreq    = MAX_HFREQ_OF_RGB;
        u16MinVfreq    = MIN_VFREQ_OF_RGB;
        u16MaxVfreq    = MAX_VFREQ_OF_RGB;
        u16MinVtotal   = MIN_VTOTAL_OF_RGB;
        u16MaxVtotal   = MAX_VTOTAL_OF_RGB;
    }
    else
    {
        u16MinHfreq    = MIN_HFREQ_OF_YPBPR;
        u16MaxHfreq    = MAX_HFREQ_OF_YPBPR;
        u16MinVfreq    = MIN_VFREQ_OF_YPBPR;
        u16MaxVfreq    = MAX_VFREQ_OF_YPBPR;
        u16MinVtotal   = MIN_VTOTAL_OF_YPBPR;
        u16MaxVtotal   = MAX_VTOTAL_OF_YPBPR;
    }

	API_MODE(printf("\r\n g_wHorizontalPeriod=%04d",g_wHorizontalPeriod));
	API_MODE(printf("\r\n g_wVerticalTotal=%04d, u16MaxVtotal=%04d, u16MinVtotal=%04d",g_wVerticalTotal,u16MaxVtotal,u16MinVtotal));
	API_MODE(printf("\r\n u16HSyncBff=%d, u16MaxHfreq=%d, u16MinHfreq=%d",u16HSyncBff,u16MaxHfreq,u16MinHfreq));
	API_MODE(printf("\r\n u16VSyncBff=%d, u16MaxVfreq=%d, u16MinVfreq=%d",u16VSyncBff,u16MaxVfreq,u16MinVfreq));

    // check sync over range
     if( (u16HSyncBff > u16MaxHfreq) || (u16HSyncBff < u16MinHfreq) ||
        (u16VSyncBff > u16MaxVfreq) || (u16VSyncBff < u16MinVfreq) ||
        (g_wVerticalTotal > u16MaxVtotal) || (g_wVerticalTotal < u16MinVtotal)
        )
    {
        g_bUnsupportMode = TRUE;
		API_MODE(printf("\r\n Sync Over Range"));
    }
	else
	{
		if( IsUseAnalogPort(enInputSourceType) )
		{
			// search standard mode, fill related parameter
			pstInputType->u16HorizontalFrequency = u16HSyncBff;
			pstInputType->u16VerticalFrequency = u16VSyncBff;
			pstInputType->u16VerticalTotal = g_wVerticalTotal;
			pstInputType->u8StatusFlag = g_u8CurrentSyncStatus;

			u8ModeIndex = MDrv_Mode_MatchMode( pstInputType, SYS_INPUT_SOURCE_TYPE );
			if(u8ModeIndex == _END_OF_TBL_)
				g_bUnsupportMode = TRUE;
			API_MODE(printf("\r\n Match u8ModeIndex=%bu",u8ModeIndex));
		}
    }


#if ENABLE_DIGITAL_SOURCE// kevin 071218_0
    #if (HDMI_CHIP_SEL == HDMI_CHIP_MST3383M)
    if (IsDigitalInUse())
    {
        WORD i;

        API_MODE(printf("\r\n Match1 u8ModeIndex=%bu",u8ModeIndex));

        if (u8ModeIndex == MD_640x480_60 || u8ModeIndex == MD_800x480_60)
        {
            i = Read_MST3xxx_Byte(0x5D) << 8;
            i += Read_MST3xxx_Byte(0x5E);

            API_MODE(printf("\r\n i=0x%x",i));

            if (i > 0x1500)
            {
                u8ModeIndex = MD_720x480_60P;
            }
        }
    }
    #endif
#endif

    return u8ModeIndex;
}

/******************************************************************************/
///-This function will calculate the current scale value
//////@param wValue: the current scale value in the range 0-100
///@param wMinValue: the min scale value
///@param wMaxValue: the max scale value
///@return :the current scale value
/******************************************************************************/
U16 N100toReallyValue ( U16 wValue, U16 wMinValue, U16 wMaxValue )
{
    double dfTemp;
    wMaxValue = wMaxValue - wMinValue;
    if(!wValue)
        wValue=wMinValue;
    else
    {
        dfTemp=(double)(((wValue)*wMaxValue)/100.0+wMinValue);
        wValue=((wValue)*wMaxValue)/100+wMinValue;

        if((double)(dfTemp-wValue)>0.4)
            wValue=wValue+1;
    }
    return(U16) wValue;
}

MS_INPUT_SOURCE_TYPE msAPI_Mode_GetSystemInputSourceType()
{
    return stSystemInfo.enInputSourceType;
}




#undef MSAPI_MODE_C

⌨️ 快捷键说明

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