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

📄 msapi_scaler.c

📁 mstar 776 开发的车载dvd
💻 C
📖 第 1 页 / 共 4 页
字号:
////////////////////////////////////////////////////////////////////////////////
//
// 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_Scaler.h
/// @brief API for Scaler control
/// @author MStar Semiconductor, Inc.
//
////////////////////////////////////////////////////////////////////////////////

#define MSAPI_SCALER_C

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

#include "Board.h"

#include "msGPIO.h"
#include "msAPI_Video.h"
#include "msIR.h"
#include "hwreg.h"

#include "sysinfo.h"
#include "drvsys.h"
#include "drvmiu.h"
#include "drvvop.h"
#include "drvMode.h"
#include "drvScaler.h"
#include "drvADC.h"
#include "drvAuCommon.h"
#include "drvvd.h"
#include "drvAnalog_inline.h"
#include "drvAnalog_DataType.h"
#include "drvgpio.h"

#include "Panel.h"
#include "msAPI_ACE.h"
#include "msAPI_MIU.h"
#include "msAPI_mode.h"
#include "msAPI_Scaler.h"
#include "msAPI_Timer.h"
#include "msAPI_VD.h"

#include "DrvHDMI.h"

/******************************************************************************/
/*                     Local                                                  */
/* ****************************************************************************/
#define DEBUGMSG(x) //x
#define PCMODE_MSG(x) //x
#define APISC_DBG(x)  //x

static E_SCREEN_MUTE_STATUS enBlackVideoInfo = E_SCREEN_MUTE_INIT;

/******************************************************************************/
/*                  Private Function Prototypes                               */
/******************************************************************************/

// Setup Display

/******************************************************************************/
/*                   Functions                                                */
/******************************************************************************/
extern BOOLEAN MDrv_IIC_WriteBytes(U8 u8SlaveID, U8 AddrCnt, U8* pu8addr, U16 u16size, U8* pBuf);// kevin 071027_0 for Demo

//------------------------------------------------------------------------------
// init
//------------------------------------------------------------------------------

/******************************************************************************/
///-This function will initial the scaler
/******************************************************************************/
void msAPI_Scaler_Init ( void )
{
    MDrv_Scaler_Init();

    devPanel_InitGammaTbl();
}

//-----------------------------------------------------------------------------
// blue & black screen
//-----------------------------------------------------------------------------
/******************************************************************************/
/// -This function will enable/diable free run screen
///@param enInputPortType \b IN: input port
///-INPUT_PORT_ADC_RGB
///-INPUT_PORT_ADC_YPBPR
///-INPUT_PORT_MS_CVBS0
///-INPUT_PORT_MS_SV0
///-INPUT_PORT_AV_SCART0
/// @param bEnable \b IN:enable/disable blue screen
/// - False:Disable
/// - TRUE :enable
/// @param u8Color \b IN:the color setting
/// - 0: Black
/// - 1: White
/// - 2: Blue
/******************************************************************************/
void msAPI_Scaler_SetBlueScreen( BOOLEAN bEnable, U8 u8Color)
{
    if (bEnable )
    {
        if(stSystemInfo.u8PanelPowerStatus & PANEL_POWER_BLUESCREEN)	// sws check
            return;

        SCALER_A_DBG(printf("Enable BlueScreen(%lu)\r\n", msAPI_Timer_GetTime0()));

        msAPI_Scaler_GenerateBlackVideo(E_SCREEN_MUTE_FREERUN, ENABLE, NULL);

        MDrv_Scaler_SetBlueScreen(ENABLE, u8Color);

        stSystemInfo.u8PanelPowerStatus |= PANEL_POWER_BLUESCREEN;

        MDrv_WriteByte(BK_ADC_ATOP_38_L, 0x0F); //scaler show black, VE show black via switching ADC buffer
    }
    else
    {
        if(stSystemInfo.u8PanelPowerStatus & PANEL_POWER_BLUESCREEN)
        {
            SCALER_A_DBG(printf("\r\n Disable BlueScreen(%lu)\r\n", msAPI_Timer_GetTime0()));

            //dealy to avoid garbage screen
            msAPI_Scaler_GenerateBlackVideo(E_SCREEN_MUTE_TEMPORARY, ENABLE, 200);

            MDrv_Scaler_SetBlueScreen(DISABLE, NULL);

            msAPI_Scaler_GenerateBlackVideo(E_SCREEN_MUTE_FREERUN, DISABLE, NULL);

            stSystemInfo.u8PanelPowerStatus &= ~PANEL_POWER_BLUESCREEN;
        }
    }
}

/******************************************************************************/
///-This function will enable/diable output black pattern
///@param bEnable
///-  False:Disable
///-  TRUE :enable
/******************************************************************************/
void msAPI_Scaler_GenerateBlackVideo(E_SCREEN_MUTE_STATUS eScreenMute, BOOLEAN bMuteEnable, U16 u161ms)
{
    DEBUGMSG(printf("GenerateBlackVideo - 0x%02X, %bu, %d\n", (U16)eScreenMute, (U8)bMuteEnable, u161ms));

    if( bMuteEnable )
    {
        enBlackVideoInfo |= eScreenMute;

	    if(eScreenMute == E_SCREEN_MUTE_TEMPORARY)
	    {
	        DEBUGMSG(printf("E_SCREEN_MUTE_TEMPORARY Before %u\n", (U16)u161ms));
	        u161ms = MAX( u161ms, msAPI_Timer_GetDownTimer0() );
	        DEBUGMSG(printf("E_SCREEN_MUTE_TEMPORARY After %u\n", (U16)u161ms));
	        msAPI_Timer_SetDownTimer0(u161ms);
	    }

        if( msAPI_Scaler_IsBlackVideoEnable() == FALSE )
        {
            MDrv_Scaler_GenerateBlackVideo( ENABLE );
            DEBUGMSG(printf("BlackVideo Enable %bu\n", (U8)eScreenMute));
        }
    }
    else
    {
        enBlackVideoInfo &= ~eScreenMute;

        if( enBlackVideoInfo == E_SCREEN_MUTE_INIT  )
        {
            MDrv_Scaler_GenerateBlackVideo( DISABLE );
            DEBUGMSG(printf("BlackVideo Disable %bu\n", (U8)eScreenMute));
        }
    }

    DEBUGMSG(printf("enBlackVideoInfo %bu\n", (U8)enBlackVideoInfo));
}


E_SCREEN_MUTE_STATUS msAPI_Scaler_GetBlackVideoInfo( void )
{
    return enBlackVideoInfo;
}

BOOLEAN msAPI_Scaler_IsBlackVideoEnable(void)
{
    return MDrv_Scaler_IsBlackVideoEnable();
}

//-----------------------------------------------------------------------------
// source control
//-----------------------------------------------------------------------------

void msAPI_Scaler_SetSourceType(MS_SYS_INFO *penMsSysInfo)
{
    U8 u8InputSrcMux, u8SyncSelMux, u8VDYMux, u8VDCMux;
#if (ENABLE_SCART_VIDEO)
    U8 u8ScartFBMux;
#endif

    #if (ENABLE_INPUT_PIP1 && ENABLE_INPUT_PIP2)// kevin 071031_0
    if (((penMsSysInfo->enInputSourceType) != INPUT_SOURCE_PIP1) && ((penMsSysInfo->enInputSourceType) != INPUT_SOURCE_PIP2))
    {
        MDrv_WriteByte(BK_OP2_PIP_00_H, 0x00);
        MDrv_WriteByte(BK_IP1_16_45_H, 0x80);

        /*{   // kevin 071027_0 for demo
            // disable Maria2 short-frame tune
            BYTE addr[4];
            addr[0]=0x20;
            addr[1]=0x09;
            addr[2]=0x00;
            addr[3]=~(addr[0]+addr[1]+addr[2]);
            MDrv_IIC_WriteBytes(0x6E,sizeof(addr),addr, 0,addr);
        }*/ // kevin 071123_0
    }
    #elif (ENABLE_INPUT_PIP1)// kevin 071115_1
    if (((penMsSysInfo->enInputSourceType) != INPUT_SOURCE_PIP1))
    {
        MDrv_WriteByte(BK_OP2_PIP_00_H, 0x00);
        MDrv_WriteByte(BK_IP1_16_45_H, 0x80);

        /*{   // kevin 071027_0 for demo
            // disable Maria2 short-frame tune
            BYTE addr[4];
            addr[0]=0x20;
            addr[1]=0x09;
            addr[2]=0x00;
            addr[3]=~(addr[0]+addr[1]+addr[2]);
            MDrv_IIC_WriteBytes(0x6E,sizeof(addr),addr, 0,addr);
        }*/ // kevin 071123_0
    }
    #elif ENABLE_INPUT_PIP2)// kevin 071115_1
    if (((penMsSysInfo->enInputSourceType) != INPUT_SOURCE_PIP2))
    {
        MDrv_WriteByte(BK_OP2_PIP_00_H, 0x00);
        MDrv_WriteByte(BK_IP1_16_45_H, 0x80);

        /*{   // kevin 071027_0 for demo
            // disable Maria2 short-frame tune
            BYTE addr[4];
            addr[0]=0x20;
            addr[1]=0x09;
            addr[2]=0x00;
            addr[3]=~(addr[0]+addr[1]+addr[2]);
            MDrv_IIC_WriteBytes(0x6E,sizeof(addr),addr, 0,addr);
        }*/ // kevin 071123_0
    }
    #endif

    #if (ENABLE_INPUT_PIP1 || ENABLE_INPUT_PIP2)// kevin 071122_1
    if(IsPip1InUse())
    {// Source Change Maria2 CVBS mode
    	BYTE addr[4];
    	addr[0]=0x20;
    	addr[1]=0x07;
        //addr[2]=0x06;
        addr[2]=0x03;
    	addr[3]=~(addr[0]+addr[1]+addr[2]);
        MDrv_IIC_WriteBytes(0x6E,sizeof(addr),addr, 0,addr);
        DEBUGMSG(printf("Switch Maria CVBS"));
    }
    else if(IsPip2InUse())
    {// Source Change Maria2 D-Sub mode
    	BYTE addr[4];
    	addr[0]=0x20;
    	addr[1]=0x07;
        addr[2]=0x05;
    	addr[3]=~(addr[0]+addr[1]+addr[2]);
        MDrv_IIC_WriteBytes(0x6E,sizeof(addr),addr, 0,addr);
        DEBUGMSG(printf("Switch Maria D-Sub"));
    }
    #endif

    //
    // prog input soruce
    //
    DEBUGMSG(printf("\r\nSET SRC TYPE"));

    switch (penMsSysInfo->enInputSourceType)
    {
        default:
            SCALER_A_DBG(printf("Unknow Input Type \r\n"));
            return;

        #if (ENABLE_INPUT_PIP1)// kevin 071031_0
        case INPUT_SOURCE_PIP1:
            DEBUGMSG(printf("\r\nINPUT_SOURCE_PIP1"));
		#endif

		#if (ENABLE_INPUT_PIP2)// kevin 071115_1
        case INPUT_SOURCE_PIP2:
            DEBUGMSG(printf("\r\nINPUT_SOURCE_PIP2"));
        #endif

        case INPUT_SOURCE_VGA:
            u8InputSrcMux = INPUT_VGA_MUX;
            u8SyncSelMux  = (AUTO_DETECT << 1) | CSYNC;
            break;

        #if ENABLE_DIGITAL_SOURCE// kevin 071213_0
        case INPUT_SOURCE_DIGITAL:
            #if (INPUT_DIGITAL_TYPE == DIGITAL_CCIR601)// kevin 071214
            // 601
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_CCIR601|0x08;
            #else
            // 656
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_CCIR656_A;
            #endif
            DEBUGMSG(printf("\r\nINPUT_SOURCE_DIGITAL"));
            break;
        #endif

        case INPUT_SOURCE_YPBPR:
#if (INPUT_YPBPR_VIDEO_COUNT == 2)
        case INPUT_SOURCE_YPBPR2:
#endif
            u8InputSrcMux = INPUT_YPBPR_MUX;
            u8SyncSelMux  = (SYNC_ON_GREEN << 1) | SOG;
            break;

        /*case INPUT_SOURCE_TV:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_TV_YMUX;
            u8VDCMux      = MSVD_CMUX_NONE;
            break;*/// kevin 071221

        case INPUT_SOURCE_CVBS:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_AV_YMUX;
            u8VDCMux      = MSVD_CMUX_NONE;
            break;

#if (INPUT_AV_VIDEO_COUNT == 2)
        case INPUT_SOURCE_CVBS2:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_AV2_YMUX;
            u8VDCMux      = MSVD_CMUX_NONE;
            break;
#endif
        case INPUT_SOURCE_SVIDEO:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_SV_YMUX;
            u8VDCMux      = INPUT_SV_CMUX;
            break;

#if (INPUT_SV_VIDEO_COUNT == 2)
        case INPUT_SOURCE_SVIDEO2:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_SV2_YMUX;
            u8VDCMux      = INPUT_SV2_CMUX;
            break;
#endif

#if (ENABLE_SCART_VIDEO)
        case INPUT_SOURCE_SCART:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_SCART_YMUX;
            u8VDCMux      = INPUT_SCART_CMUX;
            u8ScartFBMux  = INPUT_SCART_FB_MUX;
            break;

#if   (INPUT_SCART_VIDEO_COUNT == 2)
        case INPUT_SOURCE_SCART2:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_SCART2_YMUX;
            u8VDCMux      = INPUT_SCART2_CMUX;
            u8ScartFBMux  = INPUT_SCART2_FB_MUX;
            break;
#endif
#endif
        /*case INPUT_SOURCE_DTV:
            u8InputSrcMux = IP_VIDEO;
            u8SyncSelMux  = IP_MST_VD_A;
            u8VDYMux      = INPUT_TV_YMUX; // In ATSC system, it may either ATV signal or DTV signal
            u8VDCMux      = MSVD_CMUX_NONE;
            break;*/    // kevin 071220_2

    }

    /* select Mux and power on */
    MDrv_ADC_PowerOn(MDrv_ADC_SetMUX(penMsSysInfo->enInputPortType, u8InputSrcMux, u8VDYMux, u8VDCMux));

    //
    // set input port
    //
    APISC_DBG(printf("\r\n >>> penMsSysInfo->enInputSourceType=0x%bx", penMsSysInfo->enInputSourceType));
    APISC_DBG(printf("\r\n >>> u8InputSrcMux=0x%bx", u8InputSrcMux));
    APISC_DBG(printf("\r\n >>> u8SyncSelMux=0x%bx", u8SyncSelMux));

    MDrv_Scaler_SetInputPort(penMsSysInfo, u8InputSrcMux, u8SyncSelMux);

    //
    // set IP Mux
    //
	// seven 070823_00
    MDrv_Scaler_SetIPMux( penMsSysInfo->enInputPortType,u8InputSrcMux );

    MDrv_Timer_Delayms(50);

    //
    // Disable 3D Comb
    //
    //MDrv_VD_SetupComb( penMsSysInfo->enInputPortType );
}

/******************************************************************************/
// -This function will set customer output display window
// @param bEnable \b IN
// -Horizontal start position
// @param u16HStart \b IN
// -Horizontal start position
// @param u16VStart \b IN

⌨️ 快捷键说明

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