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

📄 avsys.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 4 页
字号:
//  ********************************************************************************
//  AVSYS.C :   AYSYS module is used to control the behavior of Tune(Radio)/ AMP mode
//  -----------------------------------------------------------------------------
//              Copyright (c) 2002, Cheertek Corp. All rights reserved.
//  ********************************************************************************
#include    "winav.h"
#include    "avsys.h"
#include    "cc.h"
#include    "setup.h"
#include    "hal.h"
#include    "chips.h"
#include    "utl.h"
#include    "input.h"
#include    "panel.h"  // LLY.278a
#include    "amp.h"    //Kevin2.80

// Notice: Don't include <string.h> earier than "winav.h"
#include    <string.h>


#ifdef SUPPORT_AV_SYSTEM
/////////////////////////////////////////////////////////////////////
// ***** Debug Info. & Operation Area.
// [1] Debug mode for Tuner mode's PANEL info.
// If define it, F/W will output panel info. by OSD display
// Others, there is nothing display while PANEL is not ready
//#define TUNER_DEBUG_MODE

///////////////////////////////////////////////////////////////
// ***** Extern other module's global variable
extern  BYTE    __bProgramCurrentIndex; // the cursor for input memory entry
extern  WORD    _wPreValue;
extern  DWORD   __dwTimeAMP;
extern  DWORD   __dwPreGetTime;  // LLY2.78b, use the keep the time for search scan feature gap
//Kevin2.81 review AVSys
#ifdef SUPPORT_EQUALIZER
extern  DWORD   __dwTimeEQ;
#endif                                                  

////////////////////////////////////////////////////////
// ***** Global Variable Declared Area *****
// [1] Current AUX channel info.
// [G-1byte]
BYTE    __bAUXChannel;

// [2] Input component status, ex earphone/ micphone -- LLY.278a
// [G-1byte]
// Notice: Try to merge earphone and micphone input control
BYTE    __bPeripheralIN;

#ifndef NO_TUNER
// [3] Current station info.
// [G-3bytes]
PSTATION_INFO   __StationInfo;  // a pointer to STATION_INFO structure

// [4] Memory station info.
// [G-3bytes]
PMEMORY_STATION __MemStation;   // a pointer to MEMORY_STATION structure

// [5] Special Tuner mode info.
// [G-1byte]
BYTE    __bTunerMode;

// ***** Internal Function Prototype Area *****
// ***** Only for Tuner behavior debug mode usage Area *****
#ifdef  TUNER_DEBUG_MODE
// Otherwise, NULL meaning will be different (seems it also declare NULL within <string.h>)
void _TUNER_Output(BYTE bMessage, WORD wParam);
#define PANEL_Output    _TUNER_Output
#endif  // #ifdef TUNER_DEBUG_MODE

#endif  // #ifndef NO_TUNER

//void _TUNER_DataAccess(BYTE bAction);
void _TUNER_MemoryAction(BYTE bAction);
BYTE _TUNER_TuningFreq(BYTE bAction);
void _TUNER_AutoScan(BYTE bAction);
void _Earphone_Control(void); // LLY.278a
void _TUNER_JumpStation(WORD wNumber); // LLY2.78b
BYTE _TUNER_QuerySearchScan(void); // LLY2.78b

#endif // #ifdef SUPPORT_AV_SYSTEM



//  ***********************************************************************
//  Function    :   AVSYS_Initial
//  Description :   Do the necessary action while initialize AV system
//  Arguments   :   bMode, specify the initial mode
//                  POWERON_INITIAL, initial AV system necessary info.
//                                   by default value or current value
//                  TUNER_INITIAL, initial tuner necessary info. while AUX switch
//  Return      :   None
//  Side Effect :
//  Notice      :   Share __cBuffer, and the max value is 192
//  ***********************************************************************
void AVSYS_Initial(BYTE bMode)
{
#ifdef  SUPPORT_AV_SYSTEM

	if( bMode&TUNER_INITIAL)
	{
        // [1.1] Initialize some global variables
        __bTunerMode=TUNER_MODE_NONE;

		//Kevin2.81-2, add
        //Kevin2.79 clear the sharing variable 
        __bProgramCurrentIndex=0;       
		
        AVSYS_TunerDataAccess(DATA_READ);
    		//Step 3: Set 1st station info.
    	PANEL_Output(MSG_STATION, NULL);
    		// LLY2.78b, merge two statement into one -- assignment & programming
    	CHIPS_ProgramTuner((BYTE)(SET_BAND|__StationInfo->bBand));
	}

//Kevin2.81-2, allocate tuner buffer within AVSYS_TunerDataAccess
/*
#ifndef NO_TUNER
    // Step 1: Do tuner mode relative buffer/ variable initial action, while
    // (1) write default value to serial-EPROM while power on, or
    // (2) AUX mode switch while enter tuner mode
    if( (bMode&TUNER_INITIAL) || (bMode&DATA_DEFAULT) )
    {
        // [1.1] Initialize some global variables
        __bTunerMode=TUNER_MODE_NONE;

        // [1.2] Partition __cBuffer for necessary array
        // Allocate the space for __StationInfo from __cBuffer start point
        __StationInfo=(PSTATION_INFO)(__cBuffer);

        // Allocate the space for __MemStation from (__cBuffer+PSTATION_INFO_LENGTH)
        __MemStation=(PMEMORY_STATION)(__cBuffer + STATION_INFO_LENGTH);

        // Output warning message if tuner mode need > cBuffer size memory
        if( (STATION_INFO_LENGTH+MEMORY_STATION_LENGTH) > LENGTH_SHAREBUFFER )
        {
#ifdef  _DEBUG_INFO
            OSD_Output(MSG_VERSION, TUNER_BUFFER_OVERFLOW, 0x3);
#endif  // #ifdef _DEBUG_INFO
            return;
        }

        //Kevin2.79 clear the sharing variable 
        __bProgramCurrentIndex=0;
        
    }
#endif  // #ifndef NO_TUNER
*/
//Kevin2,81-2, comment, let SETUP_initial() write default values into EPROM and
//UTL_EnterAUXOperation(AUX_CHANNEL_TUNER) & CHIPS_Initial(CHIPS_INIT_VOL) ... read values from EPROM  
/*    
    // Step 2: Do initial action for AV system
    if(bMode & POWERON_INITIAL)
    {
        // Write the default AMP & Tuner info. into serial-EPROM
        if(bMode & DATA_DEFAULT)
        {
            //Kevin2.79 CHIPS_WriteVolumeToEPPROM is renamed as CHIPS_EPPROMReadWriteVolume
            // LLY.278, APIs description has updated.
            //CHIPS_WriteVolumeToEPPROM(WRITE_ALL_INITIAL);
            CHIPS_EPPROMReadWriteVolume(WRITE_ALL_INITIAL);     

            // Write the default info. to serial-EPROM while power on mode w/ new ones
            _TUNER_DataAccess(DATA_DEFAULT|DATA_WRITE);
        }
        // Read-back the only AMP info. from serial-EPROM
        else
        {
            //Kevin2.79 use CHIPS_EPPROMReadWriteVolume() to read __bAMPVol & __bPerVol
            // wyc.278, read the default value frim serial EPPROM when initial.
            //__bAMPVol = HAL_EEPROM_Read(AVSYS_ADDR_ALL_VOLUME);
            // wyc.278-3, use define to set the length of reading serial EPPROM.
            //HAL_EEPROM_PRead(AVSYS_ADDR_PER_CHANNEL_VOLUME, EPROM_PER_CHANNEL_VOLUME_BYTE, __bPerVol);
            CHIPS_EPPROMReadWriteVolume(READ_FROM_EPPROM);
        }

        return;
    }
    else if(bMode & TUNER_INITIAL)
    {
        // LLY.278-1, split debug or release mode
        // Release mode:
        //     [1] read-back the serial-EPROM data while 8051 mode
        //     [2] give default value while non-8051 mode
        // Debug mode: always set default value, and save into serial-EPROM
        // Notice: _TUNER_DataAccess() will do protection while non-8051 mode
        //         ie. it will not access serial-EPROM
        
        //Kevin2.79 clear the sharing variable 
        __bProgramCurrentIndex=0;
        
#ifdef  RELEASE_SETTING
#ifdef  SYSTEM_8051
        _TUNER_DataAccess(DATA_READ);
#else   // #ifdef SYSTEM_8051
        _TUNER_DataAccess(DATA_DEFAULT);
#endif  // #ifdef SYSTEM_8051
#else   // #ifdef RELEASE_SETTING
        _TUNER_DataAccess(DATA_DEFAULT|DATA_WRITE);
#endif  // #ifdef RELEASE_SETTING

#ifndef NO_TUNER
    	//Step 3: Set 1st station info.
    	PANEL_Output(MSG_STATION, NULL);
    	/ LLY2.78b, merge two statement into one -- assignment & programming
    	CHIPS_ProgramTuner((BYTE)(SET_BAND|__StationInfo->bBand));
#endif  // #ifndef NO_TUNER
    }
*/

#endif  // #ifdef SUPPORT_AV_SYSTEM
}



//  **********************************************************************
//  Function    :   AVSYS_ExitTuner
//  Description :   Do the necessary action while exit tuner mode
//  Arguments   :   None
//  Return      :   None
//  Side Effect :
//  Notice      :   Nothing will be done if non-tuner mode
//                  So, __bAUXChannel can be updated after this APIs
//  **********************************************************************
void AVSYS_ExitTuner(void)
{
#ifndef NO_TUNER
    // [1] Nothing need to do while non-tuner mode
    if(__bAUXChannel != AUX_CHANNEL_TUNER)
        return;

    // [2] Save all necessary info. into serial-EPROM
    AVSYS_TunerDataAccess(DATA_WRITE);

    // [3] Free buffer

    // [4] Clear some sharing variables -- LLY2.78b
    __bProgramCurrentIndex=0;
    _wPreValue=0xffff;

#endif  // #ifndef NO_TUER
}


//  *********************************************************************************
//  Function    :   AVSYS_ProcessKey
//  Description :   Process the input key while support A/V system
//  Arguments   :   bKey, the input key
//  Return      :   KEY_NO_KEY  , the input key is processed
//              :   INVALID_KEY , the input key is not allowed under this mode
//              :   KEY_xxx     , the main program need do more process for the key.
//  Side Effect :
//  *********************************************************************************
//Kevin2.81 modified
//BYTE AVSYS_ProcessKey(BYTE bKey, WORD wParam)
BYTE AVSYS_ProcessKey(BYTE bKey)
{
#ifdef  SUPPORT_AV_SYSTEM

    // [1] Process the key for all AUX channel
    switch(bKey)
    {
    // [1.1] Main flow will handle the procedure
    case    KEY_POWER:
    	//Kevin2.81, save Per-Ch/All-Ch volume values into serial EPPROM also when IR power down
		if (!__btPowerDown)    	
	    {
    		if (__bAMPActive & AMP_TUNE_PER_CHANNEL)
        		CHIPS_EPPROMReadWriteVolume(WRITE_PER_CHANNEL_NOT_INITIAL); 
	    	else if (__bAMPActive & AMP_TUNE_ALL_CHANNEL)
            	CHIPS_EPPROMReadWriteVolume(WRITE_ALL_CHANNEL_NOT_INITIAL);
	    }      	    
    case    KEY_VOL_UP:
    case    KEY_VOL_DOWN:
    case    KEY_MUTE:
        return  bKey;

    // [1.2] Do the correspond action for desired input key
    case    KEY_FUNCTION:
        // wyc.277a-2-AVSys, use new functions to switch AUX channel.
        // Do necessary action while AUX switching
        UTL_ExitAUXOperation(__bAUXChannel);
        __bAUXChannel++;
        if (__bAUXChannel> AUX_CHANNEL_END)
            __bAUXChannel = AUX_CHANNEL_BEGIN;

        // Light AUX channel info.
        PANEL_Output(MSG_AUX, __bAUXChannel);

        UTL_EnterAUXOperation(__bAUXChannel);
        return KEY_NO_KEY;

    case    KEY_EQUALIZER:
        //Kevin2.81 review AVSys
        if (__bAMPActive & AMP_TUNE_PER_CHANNEL)    
            CHIPS_AMPAction(AMP_MODE_ENTER_EXIT);   //exit AMP mode     
        
        if(CHIPS_SoundEffect(EQ_MODE_ENTER_EXIT))   //enter EQ mode
            return KEY_NO_KEY;
        else
            return INVALID_KEY;

    case    KEY_AMP:
        //Kevin2.81 review AVSys
        if ( (__bSoundEffect&EQ_ADJUST_USER_DEFINED_EQ) || (__bSoundEffect&EQ_ADJUST_MAIN_EQ) )
            CHIPS_SoundEffect(EQ_MODE_ENTER_EXIT);  //exit EQ mode 
      
        CHIPS_AMPAction(AMP_MODE_ENTER_EXIT);       //enter AMP mode
        return KEY_NO_KEY;

    case    KEY_UP:
    case    KEY_DOWN:
    case    KEY_LEFT:
    case    KEY_RIGHT:
		//Kevin2.81 review AVSys
        if ( (__bSoundEffect&EQ_ADJUST_USER_DEFINED_EQ) || (__bSoundEffect&EQ_ADJUST_MAIN_EQ) )
        {
            CHIPS_SoundEffect(bKey);
            return KEY_NO_KEY;                            
        }                        
        else if (__bAMPActive & AMP_TUNE_PER_CHANNEL)   //in AMP mode
        {
            CHIPS_AMPAction(bKey);
            return KEY_NO_KEY;
        }
        break;  

    //Kevin2.81 review AVSys, move here to process the key for all AUX channel
    // Notice: must check if can remove those control flow  
    // because it will be done within _CC_TransferProcessingKey()
    // Current problem: _CC_TransferProcessingKey() will return KEY_ACCEPT directly while non-DVD player mode
    //                  So, there is no chance to do following action within it          cc.c ???                    
    case    KEY_PLAY:
    case    KEY_ENTER:
    case    KEY_PLAY_PAUSE:
/*
#ifdef  SUPPORT_NUMBER_CONFIRM_KEY
        if(__bAUXChannel == AUX_CHANNEL_TUNER)
        {
            // When has number input, KEY_PLAY/KEY_PLAY_PAUSE/KEY_ENTER will act as confirm key.
            if (_wPreValue != 0xffff)   // means has number input.
            {
                return KEY_ACTIVE; // confirm the input key
            }
        }
#endif //#ifdef SUPPORT_NUMBER_CONFIRM_KEY        
*/

//Kevin2.81 review AVSys
#ifdef SUPPORT_USER_DEFINED_EQ 
        if ( (__bSoundEffect&EQ_ADJUST_MAIN_EQ) && ((__bSoundEffect&0x0F) == SOUND_EFFECT_USER_DEFINED) )
        {
            CHIPS_SoundEffect(bKey);
            return KEY_NO_KEY;                            
        }  
#endif
        break;                       


      // [1.3] Others which is only for DVD or TUNER mode
    default:

⌨️ 快捷键说明

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