Coremain.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:103k
- /****************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: Coremain.c $
- *
- * Description: Interface for creating and manipulating a generic Array.
- * ============
- *
- *
- * Log:
- * ====
- * $Revision: $
- * Last Modified by $Author: $ at $Modtime: $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/Coremain/Coremain.c $
- *
- ****************************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef RELEASE_TRACE_MODULE
- #define _DEBUG
- #endif
- #ifdef _DEBUG
- #undef IFTRACE
- #ifdef RELEASE_TRACE_MODULE
- #define IFTRACE if (trace_flags.nav)
- #else
- #define IFTRACE if (gTraceCore)
- #include "DebugDbgMain.h"
- #endif
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Include files
- #include <embedded.h>
- #include "IncludeSysDefs.h"
- #include "Kernelker_api.h"
- #include "KernelEventDef.h"
- #include "KerneluITRONrtos.h"
- #include "CPUCPU_API.h"
- #include "Drivedrv_api.h"
- #include "DecoderAudioSetting.h"
- #include "Decoderdecoder.h"
- #include "LogoLogo.h"
- #include "PlaycoreCoremaincoregdef.h"
- #include "PlaycoreCoremaincoremain.h"
- #include "PlaycoreCoremaincust_ui.h"
- #include "PlaycoreExceptionException.h"
- #include "PlaycoreKaraokeio_kar.h"
- #include "PlaycoreMediaDetectionCDDetection.h"
- #include "PlaycoreNav_DVDHeadernav_dvd.h"
- #include "PlaycoreNav_DVDHeadernvgadefs.h"
- #include "PlaycoreNav_DVDHeadernvgaprot.h"
- #include "PlaycoreNav_ClipsNav_Clips.h"
- #include "PlaycorePlayModeplaymode.h"
- #include "PlaycorePSps.h"
- #include "PlaycoreScPadscmgr.h"
- #include "PlaycoreKaraokeKaraoke.h"
- #ifndef EXINO_FP
- #include "RemoteIR_API.h"
- #endif // EXINO_FP
- #ifdef D_USE_LCD//tecobest gxd 20051007
- #include "fplcd_api.h"
- #else
- #include "FPfp_api.h"
- #endif
- #include "Includecpu_address.h"
- #include "Includeaddress.h"
- #include "PlaycoreNav_CDDAPE_CD.h"
- #include "PlaycoreMediaDetectionDVDDetection.h"
- #include "UartUart_api.h"
- #ifdef GAME_SUPPORT
- extern int g_ui_notification_handler_id;
- #endif
- #ifdef TUNER_ENABLE
- #include "PlaycoreNav_ReceiverNav_Receiver.h"
- #endif
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- #include "PlaycoreNav_AmplifierNav_Amplifier.h"
- #endif
- #ifdef SPDIF_IN_ENABLE
- #include "Decoderlow_levelDEC_LL_Api.h"
- #endif
- #ifdef EXINO2
- #ifdef HW_POWER_ON_RESUME
- #include "PlaycoreCoremainnvm_bmk.h"
- #endif
- #endif //EXINO2
- #ifdef VIDEO_MODE_DETECTION
- #include "Decoderlow_levelDEC_LL_EnCoderAPI.h"
- #endif
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- #include "DriveFE_Manager.h" //Hansen_1105_2004B
- #include "Drivemacestrolink.h"
- static gbOpenTrayAfterChangeFE = 0;
- #endif
- #ifdef I77_COMPANION_CHIP
- #include "HDMIMonitorDetection.h"
- #include "HDMIHDCPHDCP.h"
- #endif // I77_COMPANION_CHIP
- #ifdef I76_CPU_POWER_DOWN
- #include "DecoderDec_Power.h"
- #endif //I76_CPU_POWER_DOWN
- #if D_SUPPORT_SACD
- #include "PlaycoreSAMPsamp_gen.h"
- #include "PlaycoreSAMPschedulerSAMPScheduler.h"
- #include "Decoderlow_leveladp_if.h"
- extern ADP_TASKS CurrADPDecoder;
- #include "Decoderadp_api.h"
- #include "Playcorenav_sacdnav_sacd.h"
- #endif
- #ifdef D_ENABLE_HEADPHONE_DETECT
- #include "PlaycoreHeadPhoneHeadPhone.h"
- #endif
- #ifdef TV_GUARDIAN_ENABLE
- #include "PlaycoreTVGTVGHI.h"
- #include "PlaycoreTVGTVG.h"
- #endif
- #ifdef MACEATROLINK_SUPPORT
- #include "drivemacestrolink.h"
- #endif
- #ifdef DVD_VR_SUPPORT
- #include "PlaycoreNav_VRnav_vr.h"
- #endif
- #include "Customerdevicedacaudio_dac.h"
- extern CONST WORD g_ir_eject_key_code;
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Constants and Defines
- /* Max number of core handlers allowed */
- #define MAX_CORE_HANDLER 6
- /* Max number of core handlers allowed */
- #ifdef RELEASE_TRACE_INPUT
- #define MAX_UI_HANDLER 6
- #else
- #define MAX_UI_HANDLER 5
- #endif // RELEASE_TRACE_INPUT
- #ifdef PANEL_SKIP_FAST_COMBINE
- #define NO_KEY_PRESS_CHECK_TIME 4
- #endif
- /* Convert 'a' minutes into number of tick events of 200ms */
- #define CONVERT_MIN2TICK(a) (a*5*60)
- /* IDLE time threshold to perform spin down */
- #define ONE_MINUTE_IDLE_TIME 1
- #define MAX_TICK_EVENT_QUEUED 2
- #define MAX_IR_EVENT_QUEUED 3
- #define MAX_UI_EVENT_QUEUED 5
- #define CIRCULAR_LEVEL_BYTE(w,r) ( ((w)>=(r)) ? ((w)-(r)) : ((0xFF-(r))+(w)+1) )
- #define TICK_CHECK_AND_SEND(w, r, e) { if ((CIRCULAR_LEVEL_BYTE(w,r) < MAX_TICK_EVENT_QUEUED) && k_ie_send(e)) w++; }
- #define THREE_SECOND 8
- #ifdef ENABLE_CHECK_SUM
- #define CODE_BEGIN_ADDRESS 0x4000
- #define CODE_SIZE_START_ADDRESS MK_FP(CODE_BEGIN_ADDRESS, 0xf0)
- #endif
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // External functions and variables declaration
- extern int CDDA_Navigator(HDLR_OP, EVENT, void*);
- extern int SVCD_Navigator(HDLR_OP Op, EVENT Event, void *Param);
- extern int Receiver_Navigator(HDLR_OP Op, EVENT Event, void *Param);
- extern void sc_InitFlagReg(void);
- extern int DiscReadyDownload(void);
- extern BOOL DiscDownload(void);
- #ifdef EXINO2
- extern CONST WORD g_language_code_array[]; /* defined in customer.c */
- #endif
- #ifndef NO_WATCHDOG
- extern void ResetWatchdogVars(void);
- #endif //NO_WATCHDOG
- #ifdef OLD_ADP_CODE
- extern BYTE g_audio_sid;
- #endif
- extern DEC_BYPASS_TYPE_ET bBypassDecryptionUnits;
- #ifdef EXINO_FE //HK04232004
- BYTE SACD_CD_Key_In = 0;
- #endif
- #ifdef I77_COMPANION_CHIP
- extern SETTING_SPDIF_CHNL_PARAM_VALUE AS_GetSPDIF_Chnl_Status_Setting(SETTING_SPDIF_CHNL_PARAM spdif_chnl_param);
- #endif // I77_COMPANION_CHIP
- #ifdef BATTERY_LOW_DETECTION
- extern void BatteryLowProcess(void);
- #endif
- #ifdef OPEN_CLOSE_DETECTION
- extern void DoorDetection(void);
- #endif
- #ifdef VIDEO_MODE_DETECTION
- extern void VideoModeDetection(void);
- extern BOOL SoftVideomode;
- #endif
- #ifdef AUX_IN_ENABLE
- extern UINT8 g_bIsAuxModeOn;
- #endif
- #ifdef DVD_IP_REVERSE
- extern void DEC_DVDReverseVobu(void);
- #endif
- // Full stop check for spindown
- #ifdef ZS5XX
- extern BOOL g_in_full_stop;
- #endif // ZS5XX
- /////////////////////////////////////////////////////////////////////////////////////////////////
- // Internal Core Services and Variables
- void core_init(void);
- void core_apply_settings(WORD setting, WORD value);
- int no_disc_fsm(HDLR_OP op, EVENT evt, void *param);
- int power_off_fsm(HDLR_OP op, EVENT evt, void *param);
- //SeanLiu_0902_2004
- #ifdef AUDIO_IN_SUPPORT
- //static int ain_core_event_handler(HDLR_OP op, EVENT evt, void *param);
- //static void ain_core_constructor(void);
- //static void ain_core_destructor(void);
- #endif
- //<<<SeanLiu_0902_2004
- void run_all_core_handlers(HDLR_OP op, EVENT evt, void *param);
- void run_all_ui_handlers(HDLR_OP op, EVENT evt, void *param);
- void acknowledge_event(EVENT event);
- #ifdef RELEASE_TRACE_INPUT
- int ui_trace_handler(HDLR_OP op, EVENT event, void *param);
- #endif
- #ifdef TV_GUARDIAN_ENABLE
- void Initiazlie_Line21DataBufferPool(void);
- #endif
- /* The following holds the UI and the core handlers */
- static int (*pfn_core_handler[MAX_CORE_HANDLER])(HDLR_OP op, EVENT evt, void *param) = {0};
- static int (*pfn_ui_handler[MAX_UI_HANDLER])(HDLR_OP op, EVENT evt, void *param) = {0};
- /* The following holds the Global Core State */
- CORE_STATE gcs;
- /* The following holds the Global Navigator State */
- NAV_STATE gns;
- /* The following holds the currently played content */
- DEC_DISC_TYPE g_disc_type = DEC_DISC_TYPE_NO_DISK;
- /*
- * The following is used not to send tick events before
- * the UI and the CORE tasks are engaged
- */
- BOOL g_core_20ms_tick_handler_enabled = FALSE;
- /* The following holds the navigator handler ID */
- static int g_nav_handler_id = -1;
- /* The following is used not to run the UI task before the core is ready */
- static BOOL g_core_task_ready = FALSE;
- #ifdef ENABLE_REDUCE_CPU_FREQUENCY_FOR_STANDBY
- /* The following is used to change the CPU frequency */
- BYTE g_ReduceCPUFrequency = 1;
- #endif
- /* The following are used to avoid mail box fullness by tick events */
- #ifdef TUNER_ENABLE
- static BYTE wcount_core_tick_20MS = 0;
- static BYTE rcount_core_tick_20MS = 0;
- #endif
- static BYTE wcount_ui_tick_100MS = 0;
- static BYTE wcount_ui_tick_200MS = 0;
- static BYTE wcount_ui_tick_1SEC = 0;
- static BYTE wcount_core_tick_200MS = 0;
- static BYTE wcount_core_tick_100MS = 0;
- static BYTE wcount_core_tick_1SEC = 0;
- static BYTE rcount_ui_tick_100MS = 0;
- static BYTE rcount_ui_tick_200MS = 0;
- static BYTE rcount_ui_tick_1SEC = 0;
- static BYTE rcount_core_tick_200MS = 0;
- static BYTE rcount_core_tick_100MS = 0;
- static BYTE rcount_core_tick_1SEC = 0;
- static BYTE wcount_ir_keycode = 0;
- static BYTE rcount_ir_keycode = 0;
- #ifdef PANEL_SKIP_FAST_COMBINE
- unsigned long uLastUnRepeat = 0;
- unsigned long uLastRepeat = 0;
- #endif
- #ifdef D_USE_VARIABLE_FOR_LIB
- extern void core_varible_init(void);
- #endif
- /* I77 related */
- #ifdef I77_COMPANION_CHIP
- #ifdef I77_HDCP_ENABLED
- static HDCP_STATUS HDCPStatus = HDCP_STATUS_IDLE; /* Polls for HDCP status */
- static BOOL bBlueScreenOn = FALSE; /* Indicates whether a blue screen is already engaged */
- #endif
- static SETTING_SPDIF_CHNL_PARAM_VALUE prevSpdifSR = 0xffff; /* Holds the previously detected spdif sampling rate */
- static WORD prevVideoDisplayRatio = 0xffff; /* Holds the current spdif sampling rate */
- #ifdef I77_BRAIN_STORM
- static BYTE prev_vid_mode = 0xFF;
- BYTE switch_analog_status = FALSE;
- #endif//I77_BRAIN_STORM
- #endif // I77_COMPANION_CHIP
- /* TV Guardian related */
- #ifdef TV_GUARDIAN_ENABLE
- BYTE gLine21DataBufferPool_Read = 0xFF;
- BYTE gLine21DataBufferPool_Write = 0xFF;
- BYTE gLine21DataStruc_Read = 0xFF;
- BYTE gLine21DataStruc_Write = 0xFF;
- BYTE gLine21MuteQueue_Read = 0xFF;
- BYTE gLine21MuteQueue_Write = 0xFF;
- BYTE Line21DataBuffer_Flag = 0;
- WORD Line21DataBuffer[LINE21DATABUFFERSIZE] =
- {
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
- };
- LINE21DATASTRUC Line21DataStruc[NUM_OF_LINE21DATASTRUC] =
- {
- { 0x00, 0x00 },
- { 0x00, 0x00 }
- };
- LINE21DATA_BUFFER_POOL Line21DataBufferPool[NUM_OF_LINE21DATA_BUFFER_POOL] =
- {
- { 0x00, 0x00 },
- { 0x00, 0x00 },
- { 0x00, 0x00 },
- { 0x00, 0x00 }
- };
- LINE21MUTEENTRY Line21MuteQueue[LINE21MUTEQUEUESIZE] =
- {
- { 0xFF, 0xFF, 0xFF },
- { 0xFF, 0xFF, 0xFF },
- { 0xFF, 0xFF, 0xFF },
- { 0xFF, 0xFF, 0xFF }
- };
- #ifdef _DEBUG
- BYTE datain_session_id = 0x00;
- #endif
- #endif //TV_GUARDIAN_ENABLE
- /* SACD related */
- #if D_SUPPORT_SACD
- /* The flag remains valid when playing either CD layer or HD layer of a SACD disc */
- BOOL g_disc_is_hybrid_sacd = 0;
- BOOL gbplayCDLayerOfSACD = 0;
- #endif
- /* SPDIF input related */
- #ifdef SPDIF_IN_ENABLE
- BYTE gbOutputSamplingFrequency = 0;
- BYTE gbOutputSamplingFrequencyold =0xff;
- #endif
- #ifdef PANEL_SKIP_FAST_COMBINE
- unsigned long uTickCount = 0;
- KEY_STATE gks = {0,NO_KEY_PRESS_CHECK_TIME};
- #endif
- //SeanLiu_0902_2004
- /* The following holds the auxilary input handler ID */
- #ifdef AUDIO_IN_SUPPORT
- static int g_ain_handler_id = -1;
- #endif
- //<<<SeanLiu_0902_2004
- /*
- * The following is used to enable auto drive spindown after
- * 8 min of idle time (Idle = STOP or PAUSE mode).
- */
- static WORD gwStopTickCount = 0;
- static PLAY_STATE giPreviousPstate;
- /* Trace flags for release version */
- #ifdef RELEASE_TRACE_INPUT
- TRACE_FLAGS_STRUCT trace_flags = {0};
- #endif
- #ifdef REMOTE_ISR_MONITOR
- BYTE ir_interval =0 ;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Function name : ui_dispatch
- // Purpose : The main UI task function.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- // Remarks : The UI is not dispatched prior to the core
- // task initialization.
- /////////////////////////////////////////////////////////////////////////////
- void ui_dispatch( void )
- {
- EVENT evt;
- void *param;
- _enable ();
- while (!g_core_task_ready)
- {
- usleep(5000L); /* sleep 5 ms */
- }
-
- tr_printf(("Starting UI dispatch...n"));
-
- /* Installing the default handler (defined in Customer.c file) */
- // install_ui_event_handler(ui_notification_handler);
- #ifdef GAME_SUPPORT
- g_ui_notification_handler_id = install_ui_event_handler(ui_notification_handler);
- #else
- /* Installing the default handler (defined in Customer.c file) */
- install_ui_event_handler(ui_notification_handler);
- #endif
- #ifdef RELEASE_TRACE_INPUT
- /* Enable tty input for release trace menu */
- install_ui_event_handler(ui_trace_handler);
- #endif
- /* Enable receiving core ticks */
- g_core_20ms_tick_handler_enabled = TRUE;
- /* Main loop - activate UI handlers to respond to the received message */
- while (1)
- {
- /* Wait for ui event */
- evt = ie_get_ex( EVENT_CLASS_UI, ¶m );
- /* Pass the event to the UI handlers */
- run_all_ui_handlers( HDLR_EVENT, evt, param);
- /* Do post processing after making sure the event was handled */
- acknowledge_event( evt );
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_dispatch
- // Purpose : The main core task function.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void core_dispatch( void )
- {
- EVENT evt;
- void *param;
- _enable ();
- tr_printf(("Power ON sequence...n"));
- core_init(); /* Initialize core first */
- tr_printf(("Starting core_dispatch...n"));
-
- /* Signal to the UI dispatcher that the core has been initialized */
- g_core_task_ready = TRUE;
-
-
- /* Main loop - activate Core handlers to respond to the received message */
- while (TRUE)
- {
- /* Wait for core event */
- evt = ie_get_ex( EVENT_CLASS_CORE, ¶m );
- /* Pass the event to the core handlers */
- run_all_core_handlers( HDLR_EVENT, evt, param);
- /* Do post processing after making sure the event was handled */
- acknowledge_event( evt );
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : ndf_on_loading
- // Purpose : Detecting the played content after closing the tray.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- // Remarks : Installs a callback to the drive to get notification
- // regarding the detected media.
- /////////////////////////////////////////////////////////////////////////////
- static void ndf_on_loading(void)
- {
- #ifdef MACESTROLINK_SUPPORT //Hansen_20040910
- if(IS_PLAYING_MLNK)
- return;
- #endif
- tr_printf(("entering loadingn"));
- gcs.mstate = MST_LOADING;
- gcs.pstate = PST_STOP;
- gcst.mCDDTSDetected = CDDTS_NOT_DETECTED;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- CLEAR_COP_MASK(COP_SETUP);
- drv_install_callback(CANCEL_POLLING);
- drv_install_callback (POLL_MEDIA_TYPE);
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : power_off_fsm
- // Purpose : The state machine installed in power off state.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- // Remarks : The state machine waits for power on IR request.
- // When power up is recieved, a software reset
- // is performed.
- /////////////////////////////////////////////////////////////////////////////
- #ifndef NO_POWER_SEQUENCE
- static int power_off_fsm( HDLR_OP op, EVENT evt, void *param )
- {
- if (op == HDLR_EVENT)
- {
- switch( evt )
- {
- case IE_CORE_CMD_POWER:
- g_power_state = POWER_SEQUENCE_ON_REQUESTED;
- #ifdef _DEBUG
- DisplayINT5Reg(GPCIO_STATUS, "Requested");
- #endif
- tr_printf(("ADP reset!n"));
- I49_ParameterWrite(POWER_CONFIG_ADDR, 0x8000); // disable ADP clk
- outport(ADPRESET_ADDR, 0x0001); //reset ADP
- outport(ADPRESET_ADDR, 0x0000); //reset ADP
- I49_ParameterWrite(POWER_CONFIG_ADDR, 0x0000); // disable ADP clk
- #ifdef ENABLE_REDUCE_CPU_FREQUENCY_FOR_STANDBY
- I49_ParameterWrite (CGU_CLKDHSPLLMULT_ADDR,0x19); // change CLKD_HSPLL multiplier to 25 (clk = 27*25/5 = 135Mhz).
- I49_ParameterWrite (CGU_CONFIG_ADDR,0x8); // exit CLKD_HSPLL powerdown mode.
- delay_us(1000L);//wait at least 1ms.
- #ifndef I86_USB_SUPPORT
- I49_ParameterWrite (CGU_CONFIG_ADDR,0x0); // exit CLKD_HSPLL re-reset mode, USB clock disabled.
- #else
- I49_ParameterWrite (CGU_CONFIG_ADDR,0x40); // exit CLKD_HSPLL re-reset mode, USB clock enabled.
- #endif
- g_ReduceCPUFrequency =1;
- outport(SxBDIV, (WORD)(CLK/BAUD/16));
- #endif
- cpu_soft_reset();
- break;
-
- #ifdef D_EJECT_WAKE_UP //Wesleyj032004: Add EJECT key to wake up from standby and eject
- /* EJECT key to wake up from standby and eject */
- case IE_CORE_CMD_EJECT:
- g_power_state = POWER_SEQUENCE_ON_EJECT;
- I49_ParameterWrite(POWER_CONFIG_ADDR, 0x8000); // disable ADP clk
- outport(ADPRESET_ADDR, 0x0001); //reset ADP
- outport(ADPRESET_ADDR, 0x0000); //reset ADP
- I49_ParameterWrite(POWER_CONFIG_ADDR, 0x0000); // disable ADP clk
- cpu_soft_reset();
- break;
- #endif //D_EJECT_WAKE_UP
- }
- }
- return 0;
- }
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Function name : no_disc_fsm
- // Purpose : Used to respond to non-playback messages.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static int no_disc_fsm( HDLR_OP op, EVENT evt, void *param )
- {
- UINT16 uiLoopIndex;
- BYTE data;
-
- if (op == HDLR_ENTER)
- {
- #if defined(SERVO_TEST) || defined(DRV_SAMPLER_MODE)
- gcs.mstate = MST_NO_DISC;
- #else
- #ifdef D_EJECT_WAKE_UP
- if ( POWER_SEQUENCE_ON_EJECT == g_power_state )
- evt = IE_CORE_CMD_EJECT;
- else
- #endif
- /* Start detecting the media */
- {
- ndf_on_loading();
- return 0;
- }
- #endif
- }
- /* Event handling */
- switch (evt)
- {
- #if D_SUPPORT_SACD
- case IE_CORE_SWITCH_HYBRID_SACD_LAYER:
- #endif
- #if defined(SUPPORT_FLASH_CARD )||defined(MACESTROLINK_SUPPORT)
- /* In case of from flash to optical, tray will be closed */
- case IE_CORE_SWITCH_FE:
- //fall through!
- #endif
- case IE_CORE_CMD_EJECT:
- //fall through!
- #if defined(STORE_BMK_ON_EJECT) && defined(HW_POWER_ON_RESUME)
- //#ifdef D_MEMORY_SETTING
- if (/*gps->memory_mode && */((gcs.pstate != PST_STOP) && (gcs.pstate != PST_WAIT_UI))
- // && (!(( g_disc_type == DEC_DISC_TYPE_SVCD )&&(PM_IsPBC(PM_GetPlaybackMode()))) )
- // && (!(IS_DISC_TYPE_DVD && (!IS_IN_TITLE_DOMAIN)))
- )
- {
- NVM_BMK_SET(0);
- }
- else
- NVM_BMK_FlushAll();
- //#else
- // NVM_BMK_SET(0);
- //#endif//D_MEMORY_SETTING
- #endif//STORE_BMK_ON_EJECT && HW_POWER_ON_RESUME
- if(IE_CORE_CMD_EJECT == evt)
- {
- #if D_SUPPORT_SACD
- gbplayCDLayerOfSACD = 0;
- g_disc_is_hybrid_sacd = 0;
- #endif
- }
- #ifdef EXINO2
- clear_PonRsm_info();// SEC CH.KO042704:porting for trino // SEC shKang121103 : If Ejecting the tray at the Power Off Status, Bookmark Information is not cleared
- #endif
- IFDEF(Dvd_Macro.bMACROVISION_ENABLE)
- DEC_on_set_macrovision_mode(0);
- ENDIF
- /* Clear any navigation information */
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- core_clear_bookmark_info( 0 ); /* Clear all bookmarks */
- Logo_clear();
- Logo_selectSource(eStartup);
- Logo_display();
- }
- if(IE_CORE_CMD_EJECT == evt)
- {
- gcs.mstate = MST_TRAY_OPENING;
- }
- gcs.pstate = PST_STOP;
- if(IE_CORE_CMD_EJECT == evt)
- {
- ie_send(IE_UI_OSDMEM_CHANGED);
- }
- #ifdef AUX_IN_ENABLE
- if(!g_bIsAuxModeOn)
- #endif
- DEC_SetDiskType(DEC_DISC_TYPE_DVD_VIDEO );
- #ifdef MACESTROLINK_SUPPORT
- Logo_display(); //Hansen_May11_2005
- #endif
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- PM_ClearRepeat();
- dbg_printf(("new state tray_openingn"));
- if ((IE_CORE_CMD_EJECT == evt)
- #ifdef SUPPORT_FLASH_CARD
- && (!IS_PLAYING_CARD)
- #endif
- #ifdef MACESTROLINK_SUPPORT
- &&(!IS_PLAYING_MLNK)
- #endif
- )
- {
- drv_tray_open();
- }
- #ifdef SUPPORT_FLASH_CARD
- else
- if(IE_CORE_SWITCH_FE == evt || (IE_CORE_CMD_EJECT == evt && IS_PLAYING_CARD))
- {
- enFE_TYPE eNewFE;
-
- if(!IS_PLAYING_CARD)
- {
- eNewFE = eFE_FLASHCARD;
- }
- else
- if(IS_PLAYING_CARD)
- {
- drv_abort_play();
- eNewFE = eFE_OPTICAL_DISC;
- drv_init();
- if(IE_CORE_CMD_EJECT == evt)
- {
- gbOpenTrayAfterChangeFE = 1;
- }
- else
- {
- gbOpenTrayAfterChangeFE = 0;
- }
- }
- if(1 != gbOpenTrayAfterChangeFE)
- {
- Exception_catch(EXCEPTION_ALL);
- }
- else
- {
- Exception_throw(EXCEPTION_MEDIUM_EJECTED);
- }
- FEM_SelectFE(eNewFE);
- }
- #endif
- #if D_SUPPORT_SACD
- else if(IE_CORE_SWITCH_HYBRID_SACD_LAYER == evt)
- {
- gcs.mstate = MST_LOADING;
- #ifdef EXINO_FE //HK04232004
- SACD_CD_Key_In = 1;
- drv_install_callback(POLL_SPIN_DOWN);
- drv_spindown();
- #else
- drv_spindown();
- drv_install_callback(POLL_SPIN_DOWN);
- #endif // EXINO_FE
- }
- #endif
- #ifdef MACESTROLINK_SUPPORT
- else if(IE_CORE_SWITCH_FE == evt || (IE_CORE_CMD_EJECT == evt && IS_PLAYING_MLNK))
- {
- //<<<//Hansen_feb01_2005
- #ifdef MLNK_WITHOUT_LOADER
- if(!Get_Loader_Conf())
- {
- Exception_catch(EXCEPTION_ALL);
- FEM_SelectFE(eFE_MACESTROLINK);
- }else
- #endif
- //>>>>//Hansen_feb01_2005
- {
- enFE_TYPE sel_FE;
- if(IS_PLAYING_MLNK) {
- MLNK_abort_play();
- MLNK_Disable();
- // drv_init();
- if(!(MLNK_status()&MLNK_STATUS_VOLUME)) //Hansen_1105_2004
- {
- sel_FE=eFE_OPTICAL_DISC;
- if(IE_CORE_CMD_EJECT == evt)
- gbOpenTrayAfterChangeFE = 1;
- else
- gbOpenTrayAfterChangeFE = 0;
- }
- else //Hansen_1116_2004
- sel_FE=eFE_MACESTROLINK;
- }
- else
- sel_FE=eFE_MACESTROLINK;
- if (1 != gbOpenTrayAfterChangeFE)
- {
- Exception_catch(EXCEPTION_ALL);
- }
- else
- {
- Exception_throw(EXCEPTION_MEDIUM_EJECTED);
- }
- FEM_SelectFE(sel_FE);
- }
- }
- #endif
- #ifdef TV_GUARDIAN_ENABLE
- Initiazlie_Line21DataBufferPool();
- #endif
- #ifdef AUX_IN_ENABLE
- if(!g_bIsAuxModeOn)
- #endif
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- gcs.pstate = PST_STOP;
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- if(IE_CORE_SWITCH_FE == evt)
- {
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- }
- else
- #endif
- #if D_SUPPORT_SACD
- if(IE_CORE_SWITCH_HYBRID_SACD_LAYER == evt)
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- else
- #endif
- gcs.cop_mask = COP_CLOSE|COP_POWER_OFF|COP_RESTART|COP_SETUP; //kz 07122002
- #ifdef AUX_IN_ENABLE
- if(!g_bIsAuxModeOn)
- #endif
- {
- if(IE_CORE_CMD_EJECT == evt
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- && 0 == gbOpenTrayAfterChangeFE
- #endif
- )
- drv_install_callback (POLL_TRAY_POSITION);
- }
- gcst.m3dEffect = EFFECT3D_SETTING_OFF;
- gtps.m3dEffect = EFFECT3D_SETTING_OFF;
- gcst.mDMM = gtps.mDMM = DMM_SETTING_NORMAL;
- break;
- // End of IE_CORE_CMD_EJECT/IE_CORE_SWITCH_FE events handling
- //----------------------------------------------------------------------------------
- case IE_CORE_TRAY_OPENED:
- if ((MST_TRAY_OPENING != gcs.mstate) || (PST_STOP != gcs.pstate))
- break;
- gcs.mstate = MST_TRAY_OPEN;
- #ifdef AUX_IN_ENABLE
- if(!g_bIsAuxModeOn)
- #endif
- /* Identify tray push events */
- drv_install_callback (POLL_TRAY_POSITION);
- break;
-
- // End of IE_CORE_TRAY_OPENED event handling
- //----------------------------------------------------------------------------------
-
- case IE_CORE_CMD_CLOSE_TRAY:
- dbg_printf(("entering tray_closingn"));
- drv_tray_close();
- // Fall-Through!
- case IE_CORE_CMD_PUSH_TRAY:
- // Clear all raised Exceptions
- #ifdef PATCH_FOR_IO_KEY_SCAN
- if ((( gcs.mstate == MST_DISC_READY ) || ( gcs.mstate == MST_LOADING )) && (IE_CORE_CMD_PUSH_TRAY == evt) )
- {
- tr_printf(("Wrong tray push detectionn"));
- break;
- }
- #endif
- Exception_catch(EXCEPTION_ALL);
- gcs.mstate = MST_TRAY_CLOSING;
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- #ifdef AUX_IN_ENABLE
- if(!g_bIsAuxModeOn)
- #endif
- {
- drv_install_callback (POLL_TRAY_POSITION);
- #ifdef SCREEN_SAVER
- DEC_StopScreenSaver();
- #endif
- }
- #ifdef D_QSI_LOADER
- ie_send(IE_UI_TRAY_PUSHED_IN);
- #endif
- break;
- // End of IE_CORE_CMD_CLOSE_TRAY/IE_CORE_CMD_PUSH_TRAY events handling
- //----------------------------------------------------------------------------------
- #ifdef DRV_TRAY_JAM_NOTIFY
- case IE_CORE_TRAY_JAMMED:
- gcs.mstate = MST_TRAY_OPENING;
- break;
- #endif
- // End of IE_CORE_TRAY_JAMMED event handling
- //----------------------------------------------------------------------------------
- #ifdef DRV_TRAY_OPENING_CLOSING_NOTIFY
- case IE_CORE_TRAY_OPENING:
- gcs.mstate = MST_TRAY_OPENING;
- break;
-
- // End of IE_CORE_TRAY_OPENING event handling
- //----------------------------------------------------------------------------------
-
- case IE_CORE_TRAY_CLOSING:
- gcs.mstate = MST_TRAY_CLOSING;
- break;
- // End of IE_CORE_TRAY_CLOSING event handling
- //----------------------------------------------------------------------------------
- #endif
- case IE_CORE_STOP_DRIVE_SPINING:
- if ( PST_STOP == gcs.pstate )
- {
- drv_spindown();
- }
- break;
- // End of IE_CORE_STOP_DRIVE_SPINING event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_CMD_POWER:
- #if defined(STORE_BMK_ON_POWER_OFF) && defined(HW_POWER_ON_RESUME)
- //#ifdef D_MEMORY_SETTING
- if (/*gps->memory_mode && */(gcs.pstate != PST_STOP) && (gcs.pstate != PST_WAIT_UI)
- // && (!(( g_disc_type == DEC_DISC_TYPE_SVCD )&&(PM_IsPBC(PM_GetPlaybackMode()))) )
- // && (!(IS_DISC_TYPE_DVD && (!IS_IN_TITLE_DOMAIN)))
- )
- {
- NVM_BMK_SET(0);
- }
- else
- NVM_BMK_FlushAll();
- //#else
- // NVM_BMK_SET(0);
- //#endif
- #endif//STORE_BMK_ON_POWER_OFF && HW_POWER_ON_RESUME
- #ifdef I77_COMPANION_CHIP
- /* Power down the I77 */
- #ifdef I77_HDCP_ENABLED
- /* Terminate HDCP if it working */
- MonitorDetection_TerminateHDCP(TRUE);
- HDCP_Init(TRUE);
- HDCPStatus = HDCP_STATUS_IDLE;
- bBlueScreenOn = FALSE;
- #endif
- prevSpdifSR = 0xffff;
- prevVideoDisplayRatio = 0xffff;
- I77_PowerDown(TRUE);
- #endif // I77_COMPANION_CHIP
- DAC_SetMute(TRUE); /* the pop noise caused by the power down down command below */
- dbg_printf(("entering power_offn"));
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- amplifier_mute(TRUE);
- #endif
- OSD_TurnOff();
- #ifdef D_SCART_OUTPUT
- /* SCART I/F power off */
- ScartLL_VMOD(SCART_VMOD_STANDBY);
- #endif //D_SCART_OUTPUT
- // FrankMei_1018_2004: When IR port is GPCIO0
- #ifdef IR_USE_GPCIO0
- outport(IMASK, ~(IMASK_TMR|IMASK_GPCIO0|IMASK_DSP)); // Enable only IR, DSP and timer interrupts
- #else
- outport(IMASK, ~(IMASK_TMR|IMASK_GPCIO7_1|IMASK_DSP)); // Enable only IR, DSP and timer interrupts
- #endif
- //<<<FrankMei_1018_2004
- DEC_LL_ENC_SetDacsEnable(0);//DEC_LL_ENC_output_enable(FALSE);
- // Removing all core handlers
- for (uiLoopIndex=0; uiLoopIndex<MAX_CORE_HANDLER; uiLoopIndex++)
- {
- if (NULL != pfn_core_handler[uiLoopIndex])
- {
- remove_core_event_handler(uiLoopIndex);
- }
- }
- API_ADP_Terminate(); // Terminate ADP first avoid system stuck in soft reset
- gcs.mstate = MST_POWER_OFF;
- #ifndef D_NO_VFD
- ui_fp_update_handler(); // Display "-off-" on FP VFD
- #endif
- /*
- * Power down the drive.
- * The function returns only after making sure the driver is powered down.
- */
- #ifdef MACESTROLINK_SUPPORT
- if(IS_PLAYING_MLNK)
- {
- MLNK_Disable();
- FE2disc();
- }
- else
- #endif
- drv_power_down();
- /* Set video and audio signal pins to be floating */
- I49_ParameterWrite(FLOAT_CONFIG_ADDR,0x07);
- delay_us(1000L);
- #ifdef I76_CPU_POWER_DOWN
- DEC_DSPPowerDown(TRUE);
- #endif //I76_CPU_POWER_DOWN
- I49_ParameterWrite(POWER_CONFIG_ADDR, 0xffff); // Power down
- delay_us(1000L);
- #ifndef I76_CPU_POWER_DOWN
- #ifndef BATTERY_LOW_DETECTION
- EX_Standby_Set();
- I49_ParameterWrite(POWERCONFIG2_ADDR, 0x00db); // Power down (without the MCU and BCI unit)
- #endif
- #endif //I76_CPU_POWER_DOWN
-
- /* Install the core handler in power off state */
- install_core_event_handler(power_off_fsm);
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- g_power_state = POWER_SEQUENCE_IN_OFF_STATE;
- dbg_printf(("Install power off fsm for power off state machinen"));
- #ifdef ENABLE_REDUCE_CPU_FREQUENCY_FOR_STANDBY
- I49_ParameterWrite(CGU_CONFIG_ADDR,0x8); // enter CLKD_HSPLL re-reset mode - clk is equal to gclk (27Mhz).
- asm {nop }; asm {nop }; asm {nop }; //wait at least 3 cycles.
- I49_ParameterWrite(CGU_CONFIG_ADDR,0x9); // enter CLKD_HSPLL powerdown mode.
- I49_ParameterWrite(CGU_CLKDHSPLLMULT_ADDR,0x6); // change CLKD_HSPLL multiplier to 6 (clk = 27*6/5 = 32.4Mhz).
- g_ReduceCPUFrequency = 5; // (135MHz/27MHz)
- outport(SxBDIV, (WORD)((CLK/BAUD/16)/g_ReduceCPUFrequency));
- #endif
- #ifdef I76_CPU_POWER_DOWN
- if (DEC_PowerDown() == TRUE)
- {
- ie_send_ex( IE_CORE_CMD_POWER, (void *) 1 );
- }
- #endif //I76_CPU_POWER_DOWN
- #ifdef EXINO2
- if ( gps->customer_reserved & B_CUSTOMER_PREVIOUSLY_POWERED_ON )
- {
- PS_Save(); // ZKR GL062503 : Saved current palyer setting when power-off.
- }
- else
- {
- PS_RestoreFactoryDefault();
- }
- tr_printf(("nSend power-off commands to fp micom..."));
- fp_send_power_off();
- #endif
- break;
- // End of IE_CORE_CMD_POWER event handling
- //----------------------------------------------------------------------------------
-
- #if defined(EXINO2) && defined(D_ENABLE_HDCP_FREE) //ZKR JK0429 : hdcp_free mode
- case IE_CORE_HDCP_FREE: //ZKR JK0506
- if (gps->hdcp_free == TRUE)
- {
- tr_printf(("ncoremain : bypass always for HDCP_FREEn"));
- MonitorDetection_TerminateHDCP(TRUE);
- HDCP_Init(TRUE);
- MonitorDetection_HDCPByPass();
- }
- #endif //EXINO2
-
- case IE_CORE_TICK_200:
- #ifdef PANEL_SKIP_FAST_COMBINE
- uTickCount++;
- if (gks.mKeyPressed)
- gks.mKeyPressed--;
- #endif
- #ifdef I77_COMPANION_CHIP
- if (FALSE == MonitorDetection_IsMonitorPluggedIn())
- {
-
- if (TRUE == MonitorDetection_CheckHotPlugDetect())
- {
- BOOL edid_status;
- UINT16 retrynum;
- tr_printf(("I77 Detected monitor plugging...n"));
- MonitorDetection_TerminateHDCP(TRUE);
- HDCP_Init(TRUE);
- /* Start getting the EDID */
- retrynum = 0;
- edid_status = MonitorDetection_ReadAndParseEDID();
- //+++++++++++++++++++++++++++
- // E D I D R e t r y
- //+++++++++++++++++++++++++++
- #define NUM_EDID_RETRY 8
- while(retrynum < NUM_EDID_RETRY && FALSE == edid_status)
- {
- edid_status = MonitorDetection_ReadAndParseEDID() ;
- retrynum++;
- tr_printf(("Reading and Verify EDID retries: %dn", retrynum));
- }
- //+++++++++++++++++++++++++++
- if (FALSE == edid_status)
- {
- tr_printf(("I77 - FAILED to read the EDID, set default output to 480p DVIn"));
-
- #ifdef I77_BRAIN_STORM
- if (gps->hd_lock_mode == FALSE)
- {
- #endif//I77_BRAIN_STORM
- /* Set default output to 480p/576p with DVI mode */
- I77_SetHDMIMode(FALSE);
- I77_SetDisplayColorSpace(COLOR_SPACE_RGB);
- /* Set default to 480p or 576p according to NTSC/PAL output */
- I77_SetDefaultResolution();
- #ifdef I77_BRAIN_STORM
- }
- else
- {
- dbg_printf(("I77 load previous settingn"));
-
- /* Set default output to 480p/576p with DVI mode */
- I77_SetHDMIMode(FALSE);
- I77_SetDisplayColorSpace(gps->lastest_hdmi_mode.color_space);
- /* Set default to 480p or 576p according to NTSC/PAL output */
- I77_SetResolution(gps->lastest_hdmi_mode.output_resolution);
- }
- #endif//I77_BRAIN_STORM
- }
- else
- {
- /* EDID was successfully parsed - set the I77 to the output resolution */
- INT8 resolution = MonitorDetection_GetResolution();
- #ifdef I77_BRAIN_STORM
- extern BYTE isHDMIChanged;
- if(gps->hd_lock_mode == FALSE || isHDMIChanged)
- {
- #endif//I77_BRAIN_STORM
- /* Set DVI/HDMI mode to the I77 */
- I77_SetHDMIMode(MonitorDetection_IsHDMI());
-
- /* Set the display's color space */
- I77_SetDisplayColorSpace(MonitorDetection_GetColorSpace());
-
- /* Check if the native resolution was detected */
- if (resolution != -1)
- {
- I77_SetResolution(resolution);
- }
- else
- {
- /* Could not detect native resolution.
- * Set default to 480p or 576p according to NTSC/PAL output.
- */
- I77_SetDefaultResolution();
- }
- #ifdef I77_BRAIN_STORM
- }
- else
- {
- dbg_printf(("I77 load previous settingn"));
- /* Set default output to 480p/576p with DVI mode */
- I77_SetHDMIMode(gps->lastest_hdmi_mode.hdmi_mode);
- I77_SetDisplayColorSpace(gps->lastest_hdmi_mode.color_space);
- /* Set default to 480p or 576p according to NTSC/PAL output */
- I77_SetResolution(gps->lastest_hdmi_mode.output_resolution);
- }
- #endif//I77_BRAIN_STORM
-
- #ifndef I77_HDCP_ENABLED
- MonitorDetection_HDCPByPass();
- #endif
- }
- #ifdef I77_BRAIN_STORM
- if( gps->hd_jpeg_mode_preference == SD_JPEG_MODE )
- gcst.hd_jpeg_mode_preference = SD_JPEG_MODE;
- else
- {
- switch(gps->hd_vid_out_mode)
- {
- case HD_NTSC_IN_OUT_720P:
- case HD_NTSC_IN_OUT_1080I:
- case HD_NTSC_IN_OUT_1024X768:
- case HD_NTSC_IN_OUT_1360X768:
- gcst.hd_jpeg_mode_preference = gps->hd_vid_out_mode;
- break;
- default:
- gcst.hd_jpeg_mode_preference = SD_JPEG_MODE;
- break;
- }
- }
- gps->lastest_hdmi_mode.output_resolution = I77_GetResolution();
- gps->lastest_hdmi_mode.color_space = I77_GetDisplayColorSpace();
- gps->lastest_hdmi_mode.hdmi_mode = I77_GetHDMIMode();
- if(gps->hd_lock_mode == HD_MODE_LOCKED)
- ie_send_ex(IE_CORE_UPDATE_PS, (void*)(((DWORD)PS_UPDATE_HD_LOCK_MODE<<16) | (DWORD)gps->hd_lock_mode));
- #endif//I77_BRAIN_STORM
- }
- gps->hd_vid_out_mode = I77_GetResolution();
- #if defined(EXINO2) && defined(D_ENABLE_DVI_OUTPUT) //ZKR JK0319 : default setting
- if ( gps->hd_vid_out_mode == 0xFF )
- gps->hd_vid_out_mode = HD_NTSC_IN_OUT_480P;
- #endif
- }
- else if (FALSE == MonitorDetection_CheckHotPlugDetect())
- {
- /* The monitor was plugged out - reset comminucation to HDE1 */
-
- BYTE bWorkingByte;
- tr_printf(("Monitor was un plugged...n"));
-
- #ifdef I77_HDCP_ENABLED
- /* If HDCP is running then terminate it */
- MonitorDetection_TerminateHDCP(TRUE);
- HDCP_Init(TRUE);
- HDCPStatus = HDCP_STATUS_IDLE;
- MonitorDetection_HDCPByPass();
- bBlueScreenOn = FALSE;
- #endif // I77_HDCP_ENABLED
- MonitorDetection_Init();
- prevSpdifSR = 0xffff;
- prevVideoDisplayRatio = 0xffff;
- //clear ctl0 bit andyh
- I77_ReadBytes(0x1CA, 1, &data);
- data = data & ~0x01;
- I77_WriteBytes(0x1CA, 1, &data);
-
- /* Reset to 480p/576p DVI, RGB encoding */
- //set back to OESS
-
- // Signal to I77 to use OESS
- I77_ReadBytes(I77_GLOBAL_MODE_CONTROL1_ADDRESS, 1, &bWorkingByte);
- bWorkingByte = bWorkingByte & (~HDCP_I77_ESS_BIT_MASK);
- I77_WriteBytes(I77_GLOBAL_MODE_CONTROL1_ADDRESS, 1, &bWorkingByte);
-
- tr_printf(("Resetting output to 480p/576p DVI, RGB encodingn"));
- I77_SetHDMIMode(FALSE);
- I77_SetDisplayColorSpace(COLOR_SPACE_RGB);
- /* Set default to 480p or 576p according to NTSC/PAL output */
- I77_SetDefaultResolution();
- }
- #ifdef I77_HDCP_ENABLED
- else
- {
- extern DEC_BYPASS_TYPE_ET bBypassDecryptionUnits;
- /* Check the HDCP status */
- HDCPStatus = MonitorDetection_GetHDCPStatus();
-
- /* Check if the played content needs copy protection
- * and activate/bypass HDCP accordingly.
- */
- #if defined(EXINO2) && defined(D_ENABLE_HDCP_FREE) //ZKR JK0429 : for hdcp_free moce
- if ( (!(bBypassDecryptionUnits & DEC_BYPASS_CSS1_E) ||
- !(bBypassDecryptionUnits & DEC_BYPASS_CPPM_E)) && (gps->hdcp_free == FALSE) )
- #else
- if ( !(bBypassDecryptionUnits & DEC_BYPASS_CSS1_E) ||
- !(bBypassDecryptionUnits & DEC_BYPASS_CPPM_E) )
- #endif //EXINO2
- {
- /* Activate HDCP if it is bypassed, and the display is HDCP receiver */
-
- if(HDCP_STATUS_FAILED == HDCPStatus) //added andyh to restart HDCP on failure
- {
- dbg_printf(("andyh attempt to restart threadn"));
- MonitorDetection_TerminateHDCP(FALSE);
- MonitorDetection_ActivateHDCP();
- }
- else if ( (HDCP_STATUS_BYPASSED == HDCPStatus) ||
- (HDCP_STATUS_IDLE == HDCPStatus) )
- {
- tr_printf(("Detected protected contentn"));
- MonitorDetection_ActivateHDCP();
- }
- else if ( (HDCP_STATUS_NO_RECEIVER == HDCPStatus) && (FALSE == bBlueScreenOn) )
- {
- /* Non-HDCP receiver - view a blue screen */
- // tr_printf(("Non HDCP receiver - blue screenn"));
- #ifdef EXINO2 //ZKR JK0507 : can't detect DVI TV when power on/off
- MonitorDetection_TerminateHDCP(FALSE);
- MonitorDetection_ActivateHDCP();
- #else
- MonitorDetection_TerminateHDCP(FALSE);
- HDCP_Init(FALSE); /* To view a blue screen */
- bBlueScreenOn = TRUE;
- #endif
- }
- }
- else
- {
- /* Non-protected content - bypass HDCP if it is not already bypassed */
- if (HDCP_STATUS_BYPASSED != HDCPStatus)
- {
- tr_printf(("Detected un-protected contentn"));
- MonitorDetection_TerminateHDCP(FALSE);
- MonitorDetection_HDCPByPass();
- bBlueScreenOn = FALSE;
- }
- }
- }
- #endif // I77_HDCP_ENABLED
- #ifdef _DEBUG
- {
- extern BOOL gHDMIAudioTestOn;
- if (TRUE == gHDMIAudioTestOn)
- {
- I77_HDMIAudioTest();
- }
- I77_SpdifSyncTest();
- }
- #endif
- /* Check if the spdif sampling rate has changed or the aspect ratio has changed
- * If so, update the I77 HDMI parameters.
- */
- #ifdef I77_HDCP_ENABLED
- if (HDCP_STATUS_FAILED != HDCPStatus) /* HDCP didn't fail */
- #endif
- {
- SETTING_SPDIF_CHNL_PARAM_VALUE currSpdifSR = AS_GetSPDIF_Chnl_Status_Setting(SET_AUDIO_SAMPLE_RATE);
- extern NV_SETTINGS *gps;
- extern DEC_DISC_TYPE gDiskType;
- WORD wCurrentVideoDisplayRatio = sprm_Get(P_CFG_VIDEO) & 0x0300;
- if ( (prevSpdifSR != currSpdifSR) ||
- ( (wCurrentVideoDisplayRatio != prevVideoDisplayRatio) &&
- (DEC_DISC_TYPE_DVD_VIDEO == gDiskType) ) )
- {
- I77_LoadHDMIParams(I77_GetResolution(), FALSE,FALSE);
- prevSpdifSR = currSpdifSR;
- prevVideoDisplayRatio = wCurrentVideoDisplayRatio;
- }
- }
- #endif // I77_COMPANION_CHIP
- /* Auto Drive Spindown after 8min of idle time (Idle = STOP or PAUSE mode) */
- /* Spin down only if disc is ready and the pstate is stop */
- if ((gcs.mstate == MST_DISC_READY) || (gcs.mstate == MST_UNKNOWN_DISC))
- {
- if(gcs.pstate == PST_STOP)
- {
- gwStopTickCount++;
- if ( (gwStopTickCount == CONVERT_MIN2TICK(ONE_MINUTE_IDLE_TIME)) && /* 1 min Idle Time */
- (giPreviousPstate != PST_STOP) )
- {
- dbg_printf(("Coremain: Auto Spindownn"));
- gwStopTickCount=0;
- giPreviousPstate = PST_STOP;
- drv_spindown();
- #ifdef EXINO_FE //HK04232004
- SACD_CD_Key_In = 0; // Luis
- #endif
- }
- }
- else
- {
- gwStopTickCount = 0;
- giPreviousPstate = gcs.pstate;
- }
- }
- else
- {
- giPreviousPstate = PST_PLAY;
- }
- #ifdef READ_BIT_RATE
- if (( PST_PLAY == gcs.pstate ) &&
- ((DEC_DISC_TYPE_DVD_VIDEO == g_disc_type) || IS_IN_AVTT_DOMAIN ||IS_IN_AMGM_DOMAIN
- #ifdef DVD_VR_SUPPORT
- ||( DEC_DISC_TYPE_DVD_VR == g_disc_type )
- #endif
- ) )
- {
- UINT16 uiBitRate;
- uiBitRate = drv_get_bit_rate();
- dbg_printf(("BitRate is %dn", uiBitRate));
- sc_SetBytes(SC_BITRATE_INFO_ADDR, 0, 2, (BYTE *)&(uiBitRate));
- }
- #endif
- break;
- // End of IE_CORE_TICK_200 event handling
- //----------------------------------------------------------------------------------
- #ifdef MACESTROLINK_SUPPORT
- case IE_CORE_FE_CHANGED_TO_MLNK:
- if(!IS_PLAYING_MLNK) //Hansen_20040910
- break;
- gcs.mstate = MST_LOADING;
- MLNK_init(FALSE);
- break;
- #endif
- #ifdef SUPPORT_FLASH_CARD
- case IE_CORE_FE_CHANGED_TO_CARD:
- gcs.mstate = MST_LOADING;
- break;
- #endif
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- case IE_CORE_FE_CHANGED_TO_DISC:
- gcs.mstate = MST_LOADING;
- //Hansen_2004_12_29 remove
- if(gbOpenTrayAfterChangeFE)
- {
- Exception_catch(EXCEPTION_ALL);
- gbOpenTrayAfterChangeFE = 0;
- ie_send( IE_CORE_CMD_EJECT );
- break;
- }
- // Else fall through - close the tray.
- #endif
- case IE_CORE_TRAY_CLOSED:
- dbg_printf(("tray closed!n"));
- #ifdef AUX_IN_ENABLE
- if(!g_bIsAuxModeOn)
- #endif
- #if !(defined(SERVO_TEST) || defined(DRV_SAMPLER_MODE))
- ndf_on_loading();
- #endif
-
- ie_send(IE_UI_TRAY_PUSHED_IN);
- break;
-
- // End of IE_CORE_TRAY_CLOSED event handling
- //----------------------------------------------------------------------------------
-
- #if D_SUPPORT_SACD
- // This event is subcribed only before reloading
- case IE_CORE_SPIN_DOWN_FINISHED:
- drv_install_callback (NULL);
- drv_tray_close();
- break;
- case IE_CORE_SACD_IDENTIFICATION_FAILED:
- // Remove navigator and SAMP scheduler.
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- }
- g_disc_type = DEC_DISC_TYPE_DVD_ROM;
- g_nav_handler_id = install_core_event_handler(Clips_Navigator);
- if (g_nav_handler_id >= 0)
- {
- tr_printf(("Entering Ready State 1n"));
- gcs.mstate = MST_DISC_READY;
- gcs.pstate = PST_STOP;
- SET_COP_MASK( COP_EJECT|COP_POWER_OFF );
- }
- break;
- #endif
- #ifdef EXINO2 //ZKR JK0509 : can't construct fail
- case IE_CORE_MEDIA_UNIDENTIFIED:
- gcs.mstate = MST_UNKNOWN_DISC; //set the state to unknown disc
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF|COP_SETUP;
- dbg_printf(("Media Type is unavailable discn"));
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- Logo_selectSource(eStartup);
- Logo_display();
- break;
- #endif
- #ifdef SUPPORT_FLASH_CARD
- case IE_CORE_CARD_INSERTED:
- gcs.mstate = MST_LOADING;
- break;
-
- case IE_CORE_CARD_REMOVED:
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- core_clear_bookmark_info( 0 ); // clear all bookmarks
- Logo_clear();
- Logo_selectSource(eStartup);
- Logo_display();
- }
- //fall through
- case IE_CORE_CARD_IDENTIFIED:
- if ((!IS_PLAYING_CARD) || (FALSE== FlashCard_IsFSInitDone()))
- break;
- //fall through
- #endif
- #if !(defined(SERVO_TEST) || defined(DRV_SAMPLER_MODE))
- case IE_CORE_MEDIA_IDENTIFIED:
- #ifdef SUPPORT_FLASH_CARD
- if (MEDIA_IDENTIFIED || (IS_PLAYING_CARD && IS_CD_MEDIA)) // MEDIA is DVD or CD
- #else
- if (MEDIA_IDENTIFIED) // MEDIA is DVD or CD
- #endif
- {
- //angiehe_0608_2004:Reset the all navigator exclusive static structure before install navigator.
- memset((BYTE*)&gns,0,sizeof(gns));
-
- /* bypass the decription units for the common case */
- bBypassDecryptionUnits = DEC_BYPASS_ALL_E;
- if (IS_DVD_PHYSICAL_MEDIA)
- {
- tr_printf(("DVD MEDIAn"));
- #if D_SUPPORT_SACD
- if(IS_SACD_MEDIA)
- {
- g_disc_type = DEC_DISC_TYPE_SACD;
- #if (!defined SACD_HW_EVAL) | (defined TEST_HARNASS)
- g_nav_handler_id = SAMP_SchedulerInstall();
- #endif
- #ifdef SACD_HW_EVAL
- SAMP(BE_Init)();
- #endif
- break;
- }
- #endif
- /* Determine the content located on the DVD media */
- gns.dvd.i_dvd_type = DVD_DetermineDiscType();
- //<<<<Hansen_04_09_21
- #ifdef MACESTROLINK_SUPPORT
- if((IS_PLAYING_MLNK)&&(DVD_TYPE_VMG!=gns.dvd.i_dvd_type))
- {
- if (!Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED | EXCEPTION_POWER_DOWN_REQUEST)) //Hansen_04_09_24
- ie_send(IE_CORE_SWITCH_FE);
- break;
- }
- #endif
- //>>>>Hansen_04_09_21
- // <<< SEC shKang042304 : if ejecting the tray before determining the DVD Video,SACD Installed.
- // don't have to install the SACD Navigator.
- #ifdef EXINO2
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED | EXCEPTION_POWER_DOWN_REQUEST))
- gns.dvd.i_dvd_type = DVD_TYPE_NO_DISC;
- #endif // EXINO2
- // SEC shKang042304 >>>
- switch (gns.dvd.i_dvd_type)
- {
- #ifdef DVD_AUDIO_SUPPORT
- case DVD_TYPE_AMG:
- // Start DVD-Audio Navigator
- gns.dvd.i_dvd_selected_type = DVD_TYPE_AMG;
- g_disc_type = DEC_DISC_TYPE_DVD_AUDIO;
- g_nav_handler_id = install_core_event_handler( nav_dvd );
- break;
- #endif
- case DVD_TYPE_VMG:
- // Start DVD-Video Navigator
- gns.dvd.i_dvd_selected_type = DVD_TYPE_VMG;
- g_disc_type = DEC_DISC_TYPE_DVD_VIDEO;
- g_nav_handler_id = install_core_event_handler( nav_dvd );
- #ifdef TV_GUARDIAN_ENABLE
- Initiazlie_Line21DataBufferPool();
- #endif
- break;
- case DVD_TYPE_DVD_ROM:
- #if D_SUPPORT_SACD
- #ifndef SACD_HW_EVAL
- //Check if it's a SACD disc.
- #ifdef EXINO2
- //<<ZKR ML:033104 Aviod pop sound when loading sacd
- DAC_SACD_SetMute(TRUE);
- #endif
- g_disc_type = DEC_DISC_TYPE_SACD;
- g_nav_handler_id = SAMP_SchedulerInstall();
- break;
- #endif
- #endif
- // Start Clip Navigator
- g_disc_type = DEC_DISC_TYPE_DVD_ROM;
- g_nav_handler_id = install_core_event_handler(Clips_Navigator);
- break;
- #ifdef DVD_VR_SUPPORT
- case DVD_TYPE_VR_VMG:
- g_disc_type = DEC_DISC_TYPE_DVD_VR;
- g_nav_handler_id = install_core_event_handler( nav_vr );
- break;
- #endif
- case DVD_TYPE_NO_DISC:
- default:
- tr_printf(("Warnning: Can't identify DVD Media Type, Bad Discn"));
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED | EXCEPTION_POWER_DOWN_REQUEST) )
- break;
- #endif
- // <<< SEC shKang042304 : must not display the Bad disc Menu !!!
- #ifdef EXINO2
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED | EXCEPTION_POWER_DOWN_REQUEST))
- gcs.mstate = MST_TRAY_OPENING; //set the state to unknown disc
- else
- #endif // EXINO2
- // SEC shKang042304 >>>
- gcs.mstate = MST_UNKNOWN_DISC; //set the state to unknown disc
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF|COP_SETUP;
- dbg_printf(("Media Type is not DVDn"));
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- Logo_selectSource(eStartup);
- Logo_display();
- break;
- }
- #ifdef INTERNAL_KARAOKE//tecobest gxd 20051028
- #ifdef DVD_AUTO_CHANGE_DEFAULT_CH //add by jt (temp)//tecobest gxd 20051028 for audio is 6ch off when dvd play
- switch (g_disc_type)
- {
- case DEC_DISC_TYPE_DVD_VIDEO:
- case DEC_DISC_TYPE_DVD_AUDIO:
- // case DEC_DISC_TYPE_DVD_ROM:
- #ifdef D_DEFAULT_6CH_ON
- if(gtps.mKaraoke==KARAOKE_SETTING_ON)
- gtps.mKaraoke==KARAOKE_SETTING_OFF;
- gps->SpeakersConfigIndex = SPEAKERS_LSS1_CONFIG;
- #else
- gps->SpeakersConfigIndex = SPEAKERS_DEFAULT_CONFIG;
- #endif
- break;
- default:
- break;
- }
- #endif
- #endif
- }
- else // if (IS_DVD_MEDIA)
- {
- tr_printf(("CD MEDIAn"));
- #ifdef SUPPORT_FLASH_CARD
- if (IS_PLAYING_CARD) // MEDIA is DVD or CD
- g_disc_type= DEC_DISC_TYPE_CDROM;
- else
- #endif
- /* Determine the CD content */
- g_disc_type= CD_DetermineDiscType();
- if(CdMedia_Macro.bVCD_SELECTION_ENABLE)
- {
- if ( (gps->vcd_playable_mode==VCD_OFF) &&
- ( (g_disc_type==DEC_DISC_TYPE_VCD) || (g_disc_type==DEC_DISC_TYPE_SVCD) ) )
- {
- gds.disctype = g_disc_type;
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- }
- }
- switch (g_disc_type)
- {
- case DEC_DISC_TYPE_CDDA:
- tr_printf(("CDDA Disc Detected.n"));
- #ifdef INTERNAL_KARAOKE//tecobest gxd 20051028
- #ifdef AUTO_CHANGE_6CH_2CH //add by jt (temp)
- //if(gtps.mKaraoke==KARAOKE_SETTING_ON)
- gps->BassManagement = BASS_MANAGEMENT_OFF;
- gps->SpeakersConfigIndex = SPEAKERS_DEFAULT_CONFIG; // Config with only front speakers, no center, no surround, no SW
- #endif
- #endif
- PE_CD_DisableCGMSData();
- g_nav_handler_id= install_core_event_handler(CDDA_Navigator);
- break;
- case DEC_DISC_TYPE_VCD:
- case DEC_DISC_TYPE_SVCD:
- tr_printf(("VCD/SVCD Disc deteced.n"));
- #ifdef INTERNAL_KARAOKE//tecobest gxd 20051028
- #ifdef AUTO_CHANGE_6CH_2CH //add by jt (temp)
- //if(gtps.mKaraoke==KARAOKE_SETTING_ON)
- gps->BassManagement = BASS_MANAGEMENT_OFF;
- gps->SpeakersConfigIndex =SPEAKERS_DEFAULT_CONFIG; // Config with only front speakers, no center, no surround, no SW
- #endif
- #endif
- PE_CD_DisableCGMSData();
- g_nav_handler_id= install_core_event_handler(SVCD_Navigator);
- break;
- case DEC_DISC_TYPE_CDROM:
- case DEC_DISC_TYPE_PICTURE_CD:
- tr_printf(("CD-RROM/Picture CD Deteced.n"));
- #ifdef INTERNAL_KARAOKE//tecobest gxd 20051028
- #ifdef AUTO_CHANGE_6CH_2CH //add by jt (temp)
- //if(gtps.mKaraoke==KARAOKE_SETTING_ON)
- gps->BassManagement = BASS_MANAGEMENT_OFF;
- gps->SpeakersConfigIndex = SPEAKERS_DEFAULT_CONFIG; // Config with only front speakers, no center, no surround, no SW
- #endif
- #endif
- PE_CD_DisableCGMSData();
- g_nav_handler_id = install_core_event_handler(Clips_Navigator);
- break;
- case DEC_DISC_TYPE_SW_UPDATE:
- {
- unsigned long disc_addr;
- tr_printf(("Media Type Unsupported, could be SW-Update Discn"));
- gcs.mstate = MST_UNKNOWN_DISC;
- #ifndef D_NO_CD_UPDATE_MENU
- if ((disc_addr = DiscReadyDownload()) == FALSE)
- {
- tr_printf(("no_disc_fsm(): Fatal: Failed to acquire SW-Update address.n"));
- g_disc_type = DEC_DISC_TYPE_NO_DISK; // sign for bad disc
- Logo_selectSource(eStartup);
- Logo_display();
- }
- else
- {
- tr_printf(("SW-Update Discn"));
- g_dl_state = CD_REQUEST_USR_INPUT;
- dbg_printf(("About to send event to UIn"));
- ie_send (IE_UI_FUPGRADE_REQUEST);
- dbg_printf(("About to enter while loopn"));
- while (g_dl_state == CD_REQUEST_USR_INPUT)
- {
- usleep (50000L);
- }
- dbg_printf(("Exiting while loopn"));
- if ((g_dl_state == CD_PARTIAL_DOWNLOAD) ||
- (g_dl_state == CD_TOTAL_DOWNLOAD))
- {
- if (!DiscDownload())
- {
- tr_printf(("no_disc_fsm(): Fatal: SW-Update Error.n"));
- g_dl_state = CD_FAILED_DOWNLOAD;
- }
- }
- if (g_dl_state == CD_CANCEL_DOWNLOAD)
- {
- // If pressed CANCEL
- Logo_selectSource(eStartup);
- Logo_display();
- }
- }
- #else
- if ((disc_addr = DiscReadyDownload()) == FALSE)
- {
- tr_printf(("no_disc_fsm(): Fatal: Failed to acquire SW-Update address.n"));
- g_disc_type = DEC_DISC_TYPE_NO_DISK; // sign for bad disc
- gcs.mstate = MST_UNKNOWN_DISC;
- Logo_selectSource(eStartup);
- Logo_display();
- }
- else {
- if (! DiscDownload())
- {
- tr_printf(("no_disc_fsm(): Fatal: SW-Update Error.n"));
- g_dl_state = CD_FAILED_DOWNLOAD;
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- gcs.mstate = MST_UNKNOWN_DISC;
- Logo_selectSource(eStartup);
- Logo_display();
- }
- }
- #endif // D_NO_CD_UPDATE_MENU
- //gcs.mstate = MST_NO_DISC;
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- break;
- }
- default:
- tr_printf(("no_disc_fsm(): Warning: Unsupported CD type.n"));
- gcs.mstate = MST_UNKNOWN_DISC;
-
- if(CdMedia_Macro.bVCD_SELECTION_ENABLE)
- {
- if ( (gps->vcd_playable_mode==VCD_OFF) &&
- ( (gds.disctype==DEC_DISC_TYPE_VCD) || (gds.disctype==DEC_DISC_TYPE_SVCD) ) )
- {
- gcs.mstate = MST_NO_DISC;
- }
- }
- drv_spindown();
- gcs.pstate = PST_STOP;
- PE_CD_AbortPlayback(FALSE); // DM050703 Force a complete stop
- DEC_SetDiskType(DEC_DISC_TYPE_DVD_VIDEO);
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- }
- }
- #if D_SUPPORT_SACD
- // Don't set mstate for SACD.
- if(g_disc_type == DEC_DISC_TYPE_SACD)
- break;
- #endif
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED | EXCEPTION_POWER_DOWN_REQUEST) )
- break;
- #endif
- if (g_nav_handler_id >= 0)
- {
- tr_printf(("Entering Ready State 2n"));
- gcs.mstate = MST_DISC_READY;
- gcs.pstate = PST_STOP;
- SET_COP_MASK( COP_EJECT|COP_POWER_OFF );
- }
- }
- else
- {
- // NO_DISC, UNKNOWN or ERROR
- tr_printf(("Non detected disc: No Disc or Error or Unknownn"));
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- if (Exception_catchAndRethrow(EXCEPTION_MEDIUM_EJECTED | EXCEPTION_POWER_DOWN_REQUEST) )
- break;
- #endif
- if (gds.disctype == DISCTYPE_NODISC)
- {
-
- #if defined(SUPPORT_FLASH_CARD)||defined(MACESTROLINK_SUPPORT)
- g_disc_type= DEC_DISC_TYPE_NO_DISK;
- #endif
- gcs.mstate = MST_NO_DISC;
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_SETUP|COP_EJECT|COP_POWER_OFF;
- tr_printf(("No Disc in trayn"));
- }
- else
- {
- gcs.mstate = MST_UNKNOWN_DISC;
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_SETUP|COP_EJECT|COP_POWER_OFF;
- tr_printf(("Disc Type Unknownn"));
- // Initialize the Drive
- drv_init();
- }
- }
- break;
-
- // End of IE_CORE_MEDIA_IDENTIFIED event handling
- //----------------------------------------------------------------------------------
-
- #endif // SERVO_TEST
- case IE_CORE_UPDATE_PS:
- PS_Update((DWORD)param);
- /* Apply settings to the specific command */
- /* 16 MSB store the command - 16 LSB store the value */
- core_apply_settings((WORD)((DWORD)param>>16), (WORD) ((DWORD)param&0x0FFFF));
- break;
- // End of IE_CORE_UPDATE_PS event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_DEC_CMD:
- DEC_Apply_Cmd((DWORD)param);
- break;
- // End of IE_CORE_DEC_CMD event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_ZOOM:
- DEC_SetZoomScale((int)param);
- break;
- // End of IE_CORE_ZOOM event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_PANNING:
- DEC_SetZoomPanning((int)param);
- break;
- // End of IE_CORE_PANNING event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_ZOOM_CUSTOM_PANNING:
- // on future require
- break;
- case IE_CORE_SCREEN_SAVER:
- #ifdef SCREEN_SAVER
- if (param == SCREEN_SAVER_START)
- {
- #if !(defined(SERVO_TEST) || defined(DRV_SAMPLER_MODE))
- DEC_StartScreenSaver();
- gcs.bScreenSaverOn = TRUE;
- #endif
- }
- else if (param == SCREEN_SAVER_STOP)
- {
- gcs.bScreenSaverOn = FALSE;
- DEC_StopScreenSaver();
- }
- #endif
- break;
- // End of IE_CORE_SCREEN_SAVER event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_SET_KARAOKE_MODE:
- #ifdef EXTERNAL_KARAOKE
- DEC_SET_MICROPHONE_ON_OFF((MICROPHONE_SETTING) param);
- #endif
- break;
- // End of IE_CORE_SET_KARAOKE_MODE event handling
- //----------------------------------------------------------------------------------
- case IE_CORE_PINK_NOISE:
- #if D_SUPPORT_SACD
- if( CurrADPDecoder == SACD_TASK )
- {
- DEC_DISC_TYPE disc_type = g_disc_type;
- SAMP(BE_Term)();
- //restore ADP IO setting.
- DEC_SetSID(DEC_SID_TYPE_AUDIO, MPEG_SID1);
- g_disc_type = disc_type;
- }
- #endif
- DEC_ADPPng(param);
- break;
- #ifdef AUDIO_IN_SUPPORT
- case IE_CORE_AUDIO_IN_MODE :
- {
- /*
- switch((BYTE) param)
- {
- case AUDIO_IN_MODE_ANALOG :
- if ((MP3_SID == g_audio_sid) || (WMA_SID == g_audio_sid)) //add by wl082404
- DEC_SetSID(DEC_SID_TYPE_AUDIO, CDDA_SID); //add by wl082404
- gtps.mAudioInMode = AUDIO_IN_MODE_ANALOG;
- DEC_SetSID(DEC_SID_TYPE_AUDIO, ANALOG_IN_SID);
- break;
- #ifdef D_ENABLE_SPDIF_IN_PORT
- case AUDIO_IN_MODE_COAXIAL :
- DEC_SetSID(DEC_SID_TYPE_AUDIO, NoAudio);
- gtps.mAudioInMode = AUDIO_IN_MODE_COAXIAL;
- IO_Select_SPDIFIN_Pin(TRUE);
- DEC_SetSID(DEC_SID_TYPE_AUDIO, DIGITAL_IN_SID);
- break;
- case AUDIO_IN_MODE_OPTICAL :
- DEC_SetSID(DEC_SID_TYPE_AUDIO, NoAudio);
- gtps.mAudioInMode = AUDIO_IN_MODE_OPTICAL;
- IO_Select_SPDIFIN_Pin(FALSE);
- DEC_SetSID(DEC_SID_TYPE_AUDIO, DIGITAL_IN_SID);
- break;
- #endif
- default:
- gtps.mAudioInMode = AUDIO_IN_MODE_OFF;
- DEC_SetSID(DEC_SID_TYPE_AUDIO, NoAudio);
- }
- */
- gtps.mAudioInMode = ((BYTE) param);
- if (AUDIO_IN_MODE_OFF != gtps.mAudioInMode)
- {
- g_disc_type = DEC_DISC_TYPE_AIN;
- gcs.mstate = MST_DISC_READY;
- gcs.pstate = PST_PLAY;
- }
- PE_CD_AUDIO_IN_MODE(gtps.mAudioInMode);
- if (AUDIO_IN_MODE_OFF == gtps.mAudioInMode)
- {
- gds.disctype = DISCTYPE_UNINITIALIZED;
- gcs.mstate = MST_LOADING;
- gcs.pstate = PST_STOP;
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- }
- }
- break;
- #endif
- #ifdef TV_GUARDIAN_ENABLE
- case IE_CORE_LINE21_DATA_IN:
- {
- unsigned short sc_address;
- unsigned char pool_index;
- unsigned short temp;
- BYTE bTopField;
- unsigned char length;
- unsigned short temp_buffer[LINE21DATABUFFERSIZE + 1];
- unsigned char i;
- BYTE errnum = 0x00;
- int prev_IE = InterruptDisable();
-
- if ( gLine21DataStruc_Write == gLine21DataStruc_Read ){
- dbg_printf(("Line21 Data Struc emptyn"));
- set_SR(prev_IE);
- break;
- }
- else{
- gLine21DataStruc_Read = ( gLine21DataStruc_Read + 1 ) % NUM_OF_LINE21DATASTRUC;
- }
- pool_index = ( gLine21DataBufferPool_Write + 1 ) % NUM_OF_LINE21DATA_BUFFER_POOL;
- //Check if buffer pool is full
- if ( pool_index == gLine21DataBufferPool_Read ){
- tr_printf(("no_disc_fsm(): Warning: Can't find empty buffer pool to hold Line21 Datan"));
- set_SR(prev_IE);
- break;
- }
-
- if ( Line21DataStruc[gLine21DataStruc_Read].DataLength == 0x00 ){
- dbg_printf(("Emtpy Line21DataStrucn"));
- set_SR(prev_IE);
- break;
- }
- gLine21DataBufferPool_Write = pool_index;
-
- if ( Line21DataBuffer_Flag ){
- for( temp = 0; temp < LINE21DATABUFFERSIZE; temp ++ )
- temp_buffer[temp+1] = Line21DataBuffer[temp];
- Line21DataBuffer_Flag = 0;
-
- }
- else
- {
- unsigned char toggle_flag, index=0, datalength;
- dbg_printf(("take data from DVP FIFO in coremainn"));
- datalength = (unsigned char)(Line21DataStruc[gLine21DataStruc_Read].DataLength & 0x3F);
- i = (unsigned char)param & 0x7F;
- bTopField = (BYTE)param & 0x80;
- toggle_flag = bTopField ? 1: 0;
-
- for ( temp = 0; temp < (62 - i); temp ++){
- if ( ( toggle_flag ) && ( temp < datalength ) ){
- temp_buffer[(index++)+1] = I49_ParameterRead( DS2CFIFO_DATA_ADDR);
- toggle_flag = 0;
- }else{
- toggle_flag = 1;
- }
- Line21DataStruc[gLine21DataStruc_Read].DataLength = index;
- }
- }
-
- length = Line21DataStruc[gLine21DataStruc_Read].DataLength;
- Line21DataStruc[gLine21DataStruc_Read].DataLength = 0x00;
- if ( length > 20 ){
- tr_printf(("Data too long!n"));
- length = 20;
- }
- if ( length > 0 )
- Line21DataBufferPool[pool_index].DataLength = length;
- else
- tr_printf(("Input length is zeron"));
-
- Line21DataBufferPool[pool_index].GopCounter = Line21DataStruc[gLine21DataStruc_Read].GopCounter;
- Line21DataStruc[gLine21DataStruc_Read].GopCounter = 0x00;
- #ifdef _DEBUG
- datain_session_id ++;
- #endif
- //call tvg_process here
- swab((char*)&temp_buffer[0], (char*)&temp_buffer[0], ((length+1) * sizeof(UINT16)));
- for ( i = 0; i < length; i ++ ){
- if (errnum = tvg_process_gop((BYTE *)(&temp_buffer[1+i]), (BYTE *)(&temp_buffer[i]), i, length))
- {
- tr_printf(("Encounts errors %02xn",errnum));
- }
- }
- swab((char*)&temp_buffer[0], (char*)&temp_buffer[0], ((length+1) * sizeof(UINT16)));
- dbg_printf(("Data In==>Write Index: %02x Read Index: %02x Length: %02x Gop: %02xn",
- gLine21DataStruc_Write,
- gLine21DataStruc_Read,
- Line21DataBufferPool[pool_index].DataLength,
- Line21DataBufferPool[pool_index].GopCounter));
-
- gLine21DataBufferPool_Write = pool_index;
- //Now transfers Line21 Text and Control Characters to Sc Pad Buffer Pool
- sc_address = pool_index * SC_LINE21_DATA_POOL_SIZE + SC_LINE21_DATA_BUFFER_ADDR;
- sc_Write( sc_address, SC_LINE21_DATA_POOL_SIZE/*in Dwords*/, (Sc_cont *)&temp_buffer[0]);
- #if 0
- {
- WORD status2;
- status2 = I49_ReadStatus(DEC_LL_STATUS_2);
- dbg_printf(("Status2 is: %04x Gop counter is: %02xn",
- (status2&0xE000)>>13, Line21DataBufferPool[pool_index].GopCounter));
- }
- #endif
- set_SR(prev_IE);
- }
- break;
-
- case IE_CORE_LINE21_DATA_OUT:
- {
- BYTE pool_index = (BYTE)param;
- #if 0
- if ( gLine21DataBufferPool_Read == gLine21DataBufferPool_Write ){
- tr_printf(("no_disc_fsm(): Warning: Buffer Pool is emptyn"));
- break;
- }
- pool_index = (gLine21DataBufferPool_Read + 1 ) % NUM_OF_LINE21DATA_BUFFER_POOL;
- if ( ( Line21DataBufferPool[pool_index].DataLength & 0x7F) == 0 ){
- tr_printf(("no_disc_fsm(): Fatal: Error on receiving IE_CORE_LINE21_DATA_OUT_EVENT, pool is emptyn"));
- break;
- }
- gLine21DataBufferPool_Read = pool_index;
- dbg_printf(("Data Out<==Write Index: %02x Read Index: %02xn",
- gLine21DataBufferPool_Write
- gLine21DataBufferPool_Read));
- #ifdef _DEBUG
- {
- WORD status2;
- status2 = I49_ReadStatus(I49_STATUS_2);
- dbg_printf(("Status2 is: %04x Gop counter is: %02xn",
- (status2&0xE000)>>13, Line21DataBufferPool[pool_index].GopCounter));
- }
- #endif
- #endif
- dbg_printf(("Data Out<==Read Index: %02x Length: %02x Gop: %02xn",
- pool_index,
- Line21DataBufferPool[pool_index].DataLength,
- Line21DataBufferPool[pool_index].GopCounter));
-
- DEC_WriteLine21DataToDVP (pool_index);
-
- Line21DataBufferPool[pool_index].GopCounter = 0x00;
- Line21DataBufferPool[pool_index].DataLength = 0;
- }
- break;
- case IE_CORE_CLEAN_LINE21:
- dbg_printf(("Re-Initialize all Line21 Structsn"));
- Initiazlie_Line21DataBufferPool();
- tvg_init(1);
- break;
- #endif // TV_GUARDIAN_ENABLE
- //<<<Leslie_0828_2003_B: Comment out
- #if 0
- case IE_CORE_PAUSE_DRIVE:
- drv_suspend_data_transmission();
- break;
- case IE_CORE_RESUME_DRIVE:
- drv_resume_data_transmission((DWORD)param);
- break;
- #endif
- //Leslie_0828_2003_B>>>
- case IE_CORE_EXIT_NAVIGATOR:
- gcs.pstate = PST_STOP;
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- core_clear_bookmark_info( 0 ); // Clear all bookmarks
- }
- PM_SetPlaybackMode(PM_PLAYBACK_NORMAL);
- PM_ClearRepeat();
- gcs.pstate = PST_STOP;
- break;
- #if defined(TUNER_ENABLE) && defined(AUDIO_IN_SUPPORT)
- case IE_CORE_SET_WORKMODE:
- DEC_EX_workmode_convert(gps->TunerWorkmode);
-
- if (RADIO_WORKMODE == gps->TunerWorkmode)
- usleep(100000UL);
- //Should just remove DVD/VCD/CD/Clips navigator, keep amplifier navigator
- if (DVD_WORKMODE == gps->TunerWorkmode)
- {
- #ifndef DIRECT_KEY_SCAN//teocbest gxd 20051008
- #ifdef D_USE_LCD
- LCD_InitDisplay();
- #elif !defined(D_NO_VFD)
- VFD_InitDisplay();
- #endif
- #endif
- //VFD_InitDisplay();
- DEC_EncoderPowerDown();
- OSD_TurnOff();
- cpu_soft_reset();
- }
- else if (DEC_DISC_TYPE_AIN != g_disc_type)
- {
- DEC_EncoderPowerDown();
- gcst.m3dEffect = gtps.m3dEffect = EFFECT3D_SETTING_OFF;
- gcst.mDMM = gtps.mDMM = DMM_SETTING_NORMAL;
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- }
- // DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, NULL );
- // drv_abort_play();
- ie_send_ex(IE_CORE_AUDIO_IN_MODE, (void *)AUDIO_IN_MODE_ANALOG);
- drv_spindown();
- }
- if (RADIO_WORKMODE == gps->TunerWorkmode)
- {
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- }
- g_nav_handler_id = install_core_event_handler( Receiver_Navigator );
- }
- break;
- #endif //TUNER_ENABLE
- #ifdef SPDIF_IN_CH_SELECT
- case IE_CORE_SPDIF_IN_CHANNELS_SEL:
- Digital_In_Channel_Select(gps->dig_aud_in_chan);
- break;
- #endif
- #if defined(TUNER_ENABLE)&&defined(D_CHANGE_SR_FOR_TUNER_AM_PERFORMANCE)
- case IE_CORE_SR_CHANGE:
- gcs.pstate = PST_STOP;
- PE_CD_AIN_Play(0);
- DEC_SetDiskType(DEC_DISC_TYPE_CDDA);
- PE_CD_AIN_Play(1);
- gcs.pstate = PST_PLAY;
- break;
- #endif
- #ifdef DVD_IP_REVERSE
- case IE_CORE_DVDREV_VSYNC_HANDLER:
- DEC_DVDReverseVobu();
- break;
- #endif
- #ifdef D_RESET_FUNCTION
- case IE_CORE_RESET_FACTORY_SETTING:
- /* Clear any navigation information */
- if (g_nav_handler_id >= 0)
- {
- remove_core_event_handler( g_nav_handler_id );
- g_nav_handler_id = -1;
- Logo_clear();
- Logo_selectSource(eStartup);
- Logo_display();
- }
- gcs.pstate = PST_STOP;
- ie_send(IE_UI_SHOW_RESET_OSD);
- ui_tmp_string(L"RESET");
- DEC_SetDiskType(DEC_DISC_TYPE_DVD_VIDEO );
- ie_send_ex(IE_CORE_UPDATE_PS, (void *) (((DWORD)PS_UPDATE_TO_FACTORY_SETTING)<<16));
- break;
- #endif
- }
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_init
- // Purpose : Initializes the core task.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void core_init(void)
- {
- #ifdef _DEBUG_VERILOG
- verilog_print("core_initn");
- #endif //_DEBUG_VERILOG
- #ifdef I77_COMPANION_CHIP
- #ifdef HDCP_TEST
- {
- extern unsigned char bHDCPProducKeys;
- if (!bHDCPProducKeys)
- {
- tr_printf(("HDCP test keys are loadedn"));
- I77_LoadPrivateKeys(FALSE);
- }
- else
- {
- tr_printf(("HDCP production keys are loadedn"));
- I77_LoadPrivateKeys(TRUE);
- }
- }
- #else
- /* Load the I77 HDCP private keys*/
- I77_LoadPrivateKeys(TRUE);
- #endif
- MonitorDetection_Init();
- #endif
- gcs.bScreenSaverOn = FALSE;
- #ifdef TV_GUARDIAN_ENABLE
- Initiazlie_Line21DataBufferPool();
- #endif
- #ifndef NO_WATCHDOG
- ResetWatchdogVars();
- #endif //NO_WATCHDOG
- #ifdef INTEL_C_SERIES_FLASH_TYPE
- asm{cli};
- Init_FLASH_Burner_API();
- asm{sti};
- #endif
- DEC_SDRAMPowerUp();
- // Initialize scratch pad
- sc_Init(0);
- // Restore player settings
- #ifndef _DEBUG_VERILOG
- PS_Restore();
- #else
- PS_RestoreFactoryDefault();
- #endif
-
- #ifdef D_USE_VARIABLE_FOR_LIB
- core_varible_init();
- #endif
- #ifdef I77_BRAIN_STORM
- {
- BYTE data;
- I77_ReadBytes(I77_HDE1_STATUS_ADDRESS, 1, &data);
- if( data & I77_HOT_PLUG_DETECT_MASK )
- {
- //gps->prog_inter_select = TRUE;
-
- if( gps->hd_jpeg_mode_preference == SD_JPEG_MODE )
- {
- gcst.hd_jpeg_mode_preference = SD_JPEG_MODE;
- }
- else
- {
- switch(gps->hd_vid_out_mode)
- {
- case HD_NTSC_IN_OUT_720P:
- case HD_NTSC_IN_OUT_1080I:
- case HD_NTSC_IN_OUT_1024X768:
- case HD_NTSC_IN_OUT_1360X768:
- gcst.hd_jpeg_mode_preference = gps->hd_vid_out_mode;
- break;
- default:
- gcst.hd_jpeg_mode_preference = SD_JPEG_MODE;
- break;
- }
- }
- }
- else
- {
- //gps->prog_inter_select = FALSE;
- gcst.hd_jpeg_mode_preference = SD_JPEG_MODE;
- }
- }
- #endif //I77_BRAIN_STORM
- #ifdef D_SCART_OUTPUT
- // Check g_power_state to decide if need to set 16:9 and 4:3
- if (g_power_state == POWER_SEQUENCE_IN_ON_STATE || g_power_state == POWER_SEQUENCE_ON_REQUESTED || g_power_state == POWER_SEQUENCE_ON_EJECT)
- {
- if ( PS_TV169 == gps->tv_shape )
- {
- ScartLL_VMOD(SCART_VMOD_16V9);
- }
- else
- {
- ScartLL_VMOD(SCART_VMOD_4V3);
- }
- if ( VID_OUT_RGB == gps->vid_out )
- {
- ScartLL_VFMD(SCART_VFMD_RGB);
- }
- else
- {
- ScartLL_VFMD(SCART_VFMD_CVBS);
- }
- }
- #endif //D_SCART_OUTPUT
- #ifdef AUX_IN_ENABLE
- g_ain_handler_id=-1;
- #endif
- // Call power up only in power up status
- #ifdef DEFAULT_POWER_OFF_STATE
- if (( g_power_state == POWER_SEQUENCE_ON_REQUESTED || g_power_state == POWER_SEQUENCE_ON_EJECT))
- #endif
- {
- DEC_PowerUp();
- }
- #ifdef I77_COMPANION_CHIP
- I77_SetResolution(gps->lastest_hdmi_mode.output_resolution); //add by wl070505
- #endif
- PE_CD_DisableCGMSData();
- // Initialize scratch pad
- // sc_Init(0);
- // Initialize the Front-Panel
- #ifndef DIRECT_KEY_SCAN//tecobest gxd 20051008
- #ifdef D_USE_LCD
- LCD_InitDisplay();
- #elif !defined(D_NO_VFD)
- VFD_InitDisplay();
- #endif
- #endif
- #ifdef TUNER_ENABLE
- #ifdef D_RDS_SUPPORT
- HAL_InitRDSInterrupt();
- #endif
- DEC_EX_workmode_init();
- #endif
- inport( GPCIO_STATUS ); //BT021703: read Status register 5. This will clear pending IRQs
- ir_init(); /* initialize Remote module, from now on IR events can be issued to UI task */
- #ifdef SPDIF_IN_ENABLE
- DEC_EX_Chips_Init();
- #ifdef SPDIF_IN_CH_SELECT
- Digital_In_Channel_Select(gps->dig_aud_in_chan);
- #endif
- #endif
- #ifdef TUNER_ENABLE
- if(DVD_WORKMODE != gps->TunerWorkmode)
- {
- DEC_EncoderPowerDown();
- g_power_state = POWER_SEQUENCE_IN_ON_STATE;
- // Display logo and reset loader
- Logo_selectSource(eStartup);
- Logo_display();
- drv_power_down();
- // Install the default handler
- install_core_event_handler( no_disc_fsm );
- ie_send(IE_CORE_SET_WORKMODE);
- return;
- }
- #endif
- #ifndef DEFAULT_POWER_OFF_STATE
- // Display logo and reset loader
- Logo_selectSource(eStartup);
- Logo_display();
- #else
- tr_printf(("g_power_state A: = %02xn", g_power_state));
- if ( g_power_state == POWER_SEQUENCE_ON_REQUESTED || g_power_state == POWER_SEQUENCE_ON_EJECT)
- {
- // Display logo and reset loader
- Logo_selectSource(eStartup);
- Logo_display();
- }
- #endif
- //Set Furore to bypass mode.
- #if D_SUPPORT_SACD && (!defined(AUDIO_DAC_SUPPORT_DSD))
- FuroreSetExternalInputPCMMode();
- #endif
- drv_init();
- #ifdef ENABLE_CHECK_SUM
- if(check_sum() == FALSE)
- {
- while(1)
- {
- usleep(100000L);
- }
- }
-
- #endif
- #ifndef DEFAULT_POWER_OFF_STATE
- // Install the default handler
- install_core_event_handler( no_disc_fsm );
- g_power_state = POWER_SEQUENCE_IN_ON_STATE;
- #else
- tr_printf(("g_power_state B: = %02xn", g_power_state));
- if ( g_power_state != POWER_SEQUENCE_ON_REQUESTED &&
- g_power_state != POWER_SEQUENCE_ON_EJECT )
- {
- install_core_event_handler( power_off_fsm);
- // FrankMei_1018_2004: When IR port is GPCIO0
- #ifdef IR_USE_GPCIO0
- outport(IMASK, ~(IMASK_TMR|IMASK_GPCIO0|IMASK_DSP)); // Enable only IR, DSP and timer interrupts
- #else
- outport(IMASK, ~(IMASK_TMR|IMASK_GPCIO7_1|IMASK_DSP)); // Enable only IR, DSP and timer interrupts
- #endif
- //<<<FrankMei_1018_2004
- g_power_state = POWER_SEQUENCE_IN_OFF_STATE;
- gcs.mstate = MST_POWER_OFF;
- #ifndef DIRECT_KEY_SCAN
- ui_fp_update_handler();
- #endif
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- drv_power_down(); // the function returns only after making sure the driver is powered down
- I49_ParameterWrite(POWER_CONFIG_ADDR, 0xffff); // Power down
- I49_ParameterWrite(POWERCONFIG2_ADDR, 0x00db); // Power down (without the MCU and BCI unit)
- }
- else
- {
- install_core_event_handler( no_disc_fsm );
- g_power_state = POWER_SEQUENCE_IN_ON_STATE;
- }
- #endif
- #if (defined(INTERNAL_KARAOKE) || defined(EXTERNAL_KARAOKE) )
- #ifndef D_KEYSHIFT_SINGLE_KEY
- // Initialize Karaoke
- karKaraokeInit();
- #endif
- #endif
- #ifdef D_ENABLE_HEADPHONE_DETECT
- HeadPhoneDetectionInit();
- #endif
- // Initialize bookmarks
- core_clear_bookmark_info(0); /* Clear all bookmarks */
- #ifdef DIGITAL_AMPLIFIER_ENABLE
- install_core_event_handler( Amplifier_Navigator );
- #endif
- #ifdef TV_GUARDIAN_ENABLE
- tvg_init(0);
- #endif
- #ifdef SUPPORT_KEYS_UPDATE
- _uartOpen();
- timer_service_create(Check_Uart_Rx,(WORD) 10, TIMER_ENABLED|TIMER_REPEAT);
- #endif
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_apply_settings
- // Purpose : Apply the user setup.
- // Input Parameters : setting - The setting to be applied.
- // value - The value of the setting.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void core_apply_settings(WORD setting, WORD value)
- {
- #ifdef I77_COMPANION_CHIP
- if (PS_UPDATE_HD_VID_OUT == setting)
- {
- I77_SetResolution(value);
- return;
- }
- #endif
-
- /* Audio Settings to Apply */
- if (setting <= 0xFF)
- {
- DEC_ApplyAudioSettings(setting, value);
- }
- /* Video Settings to Apply */
- if ((setting >= 0x100) && (setting <= 0x1FF))
- {
- DEC_ApplyVideoSettings(setting);
- }
- /* General Settings to Apply */
- if ((setting >= 0x200) && (setting <= 0x2FF))
- {
- dbg_printf(("WARNING: core_apply_settings(): Unsupported setting - %xn", setting));
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : run_all_core_handlers
- // Purpose : Run all of the core handlers with the given event.
- // Input Parameters : op - Handler request (ENTER/EXIST)
- // evt - Event ID.
- // param - Event parameter.
- // value - The value of the setting.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void run_all_core_handlers(HDLR_OP op, EVENT evt, void *param)
- {
- int i;
- /* Broadcast event to all active handlers */
- for (i=0; i < MAX_CORE_HANDLER; i++)
- {
- if (NULL != pfn_core_handler[i])
- {
- (*pfn_core_handler[i])(op, evt, param);
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : run_all_ui_handlers
- // Purpose : Run all of the UI handlers with the given event.
- // Input Parameters : op - Handler request (ENTER/EXIST)
- // evt - Event ID.
- // param - Event parameter.
- // value - The value of the setting.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void run_all_ui_handlers(HDLR_OP op, EVENT evt, void *param)
- {
- int i;
- /* Broadcast event to all active handlers */
- for (i=0; i<MAX_UI_HANDLER; i++)
- {
- if (pfn_ui_handler[i])
- {
- (*pfn_ui_handler[i])(op, evt, param);
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : install_core_event_handler
- // Purpose : Installs the given handler as a core one.
- // Input Parameters : new_handler - The handler function.
- // Return type : The handler ID if successful, otherwise -1.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- int install_core_event_handler( int (*new_handler)(HDLR_OP Op, EVENT Event, void *Param))
- {
- int i;
- /* Search for an empty slot */
- for (i=0; i<MAX_CORE_HANDLER; i++)
- {
- if (NULL == pfn_core_handler[i])
- {
- pfn_core_handler[i]= new_handler;
- (*new_handler)(HDLR_ENTER, 0, NULL);
- break;
- }
- }
- if (MAX_CORE_HANDLER == i)
- {
- tr_printf(("FATAL: Could not install core handlern"));
- return -1;
- }
- return i;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : remove_core_event_handler
- // Purpose : Removes the given core handler.
- // Input Parameters : handler_id - The handler ID to be removed.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void remove_core_event_handler( int handler_id )
- {
- if (NULL == pfn_core_handler[handler_id])
- {
- tr_printf(("WARNING: Attempt to remove non-existing core handlern"));
- return;
- }
- (*pfn_core_handler[handler_id])(HDLR_EXIT, 0, NULL);
- pfn_core_handler[handler_id]= NULL;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : install_ui_event_handler
- // Purpose : Installs the given handler as a UI one.
- // Input Parameters : new_handler - The handler function.
- // Return type : The handler ID if successful, otherwise -1.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- int install_ui_event_handler( int (*new_handler)(HDLR_OP Op, EVENT Event, void *Param))
- {
- int i;
- /* Search for an empty slot */
- for (i=0; i < MAX_UI_HANDLER; i++)
- {
- if (NULL == pfn_ui_handler[i])
- {
- pfn_ui_handler[i]= new_handler;
- (*new_handler)(HDLR_ENTER, 0, NULL);
- break;
- }
- }
- if (MAX_UI_HANDLER == i)
- {
- tr_printf(("FATAL: Could not install UI handlern"));
- return -1;
- }
- return i;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : remove_ui_event_handler
- // Purpose : Removes the given UI handler.
- // Input Parameters : handler_id - The handler ID to be removed.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void remove_ui_event_handler( int handler_id )
- {
- if (NULL == pfn_ui_handler[handler_id])
- {
- tr_printf(("WARNING: Attempt to remove non-existing UI handlern"));
- return;
- }
- (*pfn_ui_handler[handler_id])(HDLR_EXIT, 0, NULL );
- pfn_ui_handler[handler_id] = NULL;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : send_tick
- // Purpose : Sends the requested tick event to the UI/Core task.
- // Input Parameters : tick_event - the event to send.
- // Return type : none.
- // Output Parameters: none.
- // Remarks : The function makes sure not to overload the mail boxes
- // with too many tick events if the previously sent tick
- // events were not already handled.
- /////////////////////////////////////////////////////////////////////////////
- void send_tick( EVENT tick_event )
- {
- switch (tick_event)
- {
- #ifdef TUNER_ENABLE
- case IE_CORE_TICK_20:
- TICK_CHECK_AND_SEND( wcount_core_tick_20MS, rcount_core_tick_20MS, tick_event );
- break;
- #endif
- case IE_CORE_TICK_100:
- TICK_CHECK_AND_SEND( wcount_core_tick_100MS, rcount_core_tick_100MS, tick_event );
- break;
- case IE_CORE_TICK_200:
- TICK_CHECK_AND_SEND( wcount_core_tick_200MS, rcount_core_tick_200MS, tick_event );
- break;
-
- case IE_CORE_TICK_ONE_SEC:
- TICK_CHECK_AND_SEND( wcount_core_tick_1SEC, rcount_core_tick_1SEC, tick_event );
- #ifdef KARAOKE_SWITCH_PATCH
- {
- static BYTE counter = 0;
- if((g_switch_karaoke) && (counter++ > 10))
- {
- g_switch_karaoke = FALSE;
- counter = 0;
- }
- }
- #endif
- break;
-
- case IE_UI_TICK_100:
- TICK_CHECK_AND_SEND( wcount_ui_tick_100MS, rcount_ui_tick_100MS, tick_event );
- break;
- case IE_UI_TICK_200:
- TICK_CHECK_AND_SEND( wcount_ui_tick_200MS, rcount_ui_tick_200MS, tick_event );
- break;
-
- case IE_UI_TICK_ONE_SEC:
- TICK_CHECK_AND_SEND( wcount_ui_tick_1SEC, rcount_ui_tick_1SEC, tick_event );
- break;
- }
- }
- #ifdef PANEL_SKIP_FAST_COMBINE
- /////////////////////////////////////////////////////////////////////////////
- // Function name : UpdateKeyPressStatus
- // Purpose :
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- // Remarks :
- /////////////////////////////////////////////////////////////////////////////
- void UpdateKeyPressStatus(void)
- {
- gks.mKeyPressed = NO_KEY_PRESS_CHECK_TIME;
- }
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Function name : send_remote_event
- // Purpose : Sends an remote control event to the UI task.
- // Input Parameters : keycode - The requested IR key code.
- // Return type : none.
- // Output Parameters: none.
- // Remarks : The function is called from IR ISR.
- /////////////////////////////////////////////////////////////////////////////
- extern CONST WORD g_ir_power_key_code;
- extern CONST WORD g_ir_eject_key_code;//tecobest gxd 20051024
- void send_remote_event( WORD keycode )
- {
- #ifdef PANEL_SKIP_FAST_COMBINE
- UpdateKeyPressStatus();
- if ( !(keycode & REMOTE_KEY_REPEATED) )
- {
- uLastUnRepeat = uTickCount;
- gks.bKeyPressedLongTime = 0;
- }
- else
- {
- uLastRepeat = uTickCount;
- if ( (uLastRepeat - uLastUnRepeat) > THREE_SECOND )
- {
- gks.bKeyPressedLongTime = 1;
- }
- }
- #endif
- if ( (g_cUICoreMsgSent) > KER_UI_CORE_MSG_MAX)
- {
- /*
- here, there are many messages in Core queue waiting for process,
- if continuously send IR msg may cause queue overflow
- so dispose IR message
- */
- //dbg_printf(("WARNING: IR msg is disposed:%x.n",g_cUICoreMsgSent));
- return ;
- }
- /* Allow up to 3 IR events to be queued */
- //if (CIRCULAR_LEVEL_BYTE( wcount_ir_keycode, rcount_ir_keycode) < MAX_IR_EVENT_QUEUED)//tecobest gxd 20051024
- if ((CIRCULAR_LEVEL_BYTE( wcount_ir_keycode, rcount_ir_keycode) < MAX_IR_EVENT_QUEUED)||
- (keycode==g_ir_eject_key_code)||(keycode==g_ir_power_key_code))
- {
- tr_printf(("keycount:%2xn",rcount_ir_keycode));
- wcount_ir_keycode++;
- k_ie_send_ex(IE_UI_REMOTE_INPUT,(void *) keycode);
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : acknowledge_event
- // Purpose : Post processing after handling an event.
- // Input Parameters : event - The last handled event.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void acknowledge_event( EVENT event )
- {
- switch (event)
- {
- #ifdef TUNER_ENABLE
- case IE_CORE_TICK_20:
- rcount_core_tick_20MS++;
- break;
- #endif
- case IE_CORE_TICK_100:
- rcount_core_tick_100MS++;
- break;
- case IE_CORE_TICK_200:
- rcount_core_tick_200MS++;
- break;
- case IE_CORE_TICK_ONE_SEC:
- rcount_core_tick_1SEC++;
- break;
- case IE_UI_TICK_100:
- rcount_ui_tick_100MS++;
- break;
- case IE_UI_TICK_200:
- rcount_ui_tick_200MS++;
- break;
- case IE_UI_TICK_ONE_SEC:
- rcount_ui_tick_1SEC++;
- break;
- case IE_UI_REMOTE_INPUT:
- rcount_ir_keycode++;
- tr_printf(("ircount:%2xn",rcount_ir_keycode));
- break;
- }
-
- if ( event & EVENT_CORE_FLAG )
- {
- // msg send with limit
- //if (IE_CORE_PLAY_FILE == event)
- //{
- // if ( g_cPlayFileMsgSent )
- // {
- // g_cPlayFileMsgSent--;
- // g_cUICoreMsgSent--;
- // }
- // else
- // ASSERT(0);
- //}
- //else
- //{
- if ( g_cUICoreMsgSent )
- g_cUICoreMsgSent--;
- else
- ASSERT( g_cUICoreMsgSent > 0 );
- //}
-
- //dbg_printf(("nr ACK EVT:%x ALL: %x nr",event,g_cUICoreMsgSent));
- }
-
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : query_core
- // Purpose : Provides information regarding the core task.
- // Input Parameters : cq - The information required (query).
- // pvInput - The input parameters for the query.
- // Return type : pvOutput - The query result.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void query_core( CORE_QUERY cq, void *pvInput, void *pvOutput )
- {
- switch ( cq )
- {
- case CQ_AVAILABLE_CHANNELS:
- {
- DWORD dwMaxChannels = (DWORD) 6L;
- DWORD *pdw = (DWORD *) pvOutput;
- dbg_printf(("CQ_AVAILABLE_CHANNELS:n"));
- *pdw = dwMaxChannels;
- }
- break;
- case CQ_AVAILABLE_CHAPTERS:
- {
- DWORD dwTitle = (DWORD) pvInput;
- DWORD *pdw = (DWORD *) pvOutput;
- WORD wMaxChapters = (WORD) 99L;
- dbg_printf(("CQ_AVAILABLE_CHAPTERS: Title is %iln", dwTitle));
- if ( g_disc_type == DEC_DISC_TYPE_DVD_VIDEO )
- {
- get_total_chapters( (WORD) dwTitle, &wMaxChapters );
- }
- #ifdef DVD_VR_SUPPORT
- else if( g_disc_type == DEC_DISC_TYPE_DVD_VR )
- {
- S_RTR_PGI pgi;
- UINT16 i,startcell = 0;
-
- if(!gns.dvdvr.isPlaylist)
- {
- for(i = 1;i < dwTitle; i++)
- {
- VR_get_PGI(i,&pgi);
- startcell += pgi.C_Ns;
- }
- VR_get_PGI((UINT8)dwTitle,&pgi);
- wMaxChapters = VR_get_Title_Total_EPs(startcell+1,startcell + pgi.C_Ns);
- }
- else
- wMaxChapters = VR_get_Title_Total_EPs(1,gns.dvdvr.pgci.CI_Ns);
- }
- #endif
- #ifdef DVD_AUDIO_SUPPORT
- else if(g_disc_type == DEC_DISC_TYPE_DVD_AUDIO)
- {
- wMaxChapters=SI_DVDA_AVAILABLE_TRACKS(dwTitle);
- }
- #endif
- #if D_SUPPORT_SACD
- else if(g_disc_type == DEC_DISC_TYPE_SACD)
- {
- // Return max sacd track num in active area
- wMaxChapters=Nav_SACD_Get_Num_Of_Tracks(SACD_ACTIVE_AREA);
- }
- #endif
- else if ( (g_disc_type == DEC_DISC_TYPE_SVCD) || (g_disc_type == DEC_DISC_TYPE_VCD) )
- {
- #ifdef EXINO2
- // Handle numerical selection for PBC.
- if ( PM_IsPBC(PM_GetPlaybackMode()) )
- {
- if ( gns.svcd.m_CurrPosition.ListType == SelectionList )
- {
- wMaxChapters = (WORD) ( gns.svcd.m_CurrList.SelectionList.uSelectionBase + gns.svcd.m_CurrList.SelectionList.uSelectionsCnt - 1);
- }
- }
- else
- #endif // EXINO2
- wMaxChapters = SI_SVCD_MAX_TRACK_NUM;
- }
- else if (g_disc_type == DEC_DISC_TYPE_CDDA)
- {
- wMaxChapters = SI_CDDA_MAX_TRACK_NUM;
- }
- else if ( IS_DISC_DATA_ROM ||
- (g_disc_type == DEC_DISC_TYPE_PICTURE_CD) )
- {
- wMaxChapters = SI_CLIPS_MAX_CLIP_NUM;
- }
- *pdw = (DWORD) wMaxChapters;
- }
- break;
- case CQ_VALID_ZOOM:
- {
- BYTE* pdw = (BYTE *)pvOutput;
-
- dbg_printf(("CQ_VALID_ZOOM: %i (%il)n", (int) pvInput, *pdw));
- *pdw = DEC_CheckAvailableManualZoom((int) pvInput);
- }
- break;
-
- #ifdef EZVIEW_ENABLED
- case CQ_GET_NEXT_EZVIEW_MODE: // Get Next EZView mode.
- {
- BYTE* pdw = (BYTE *)pvOutput;
- if(gcst.mUseManualScaling)
- {
- *pdw = DEC_GetNextEZViewMode();
- }
- }
- break;
- case CQ_GET_EZVIEW_MODE: // Get current EZView mode.
- {
- BYTE* pdw = (BYTE *)pvOutput;
- if(gcst.mUseManualScaling)
- {
- *pdw = DEC_GetEZViewMode();
- }
- }
- break;
- #endif
- #ifdef S1_GUI
- case CQ_WIDESCREEN_MODE:
- #ifdef EZVIEW_ENABLED
- // In case of EZ View mode, needs to know Output config even with PST_STILL state
- if(gcs.pstate != PST_STOP)
- #endif
- {
- DWORD *pdw = (DWORD *) pvOutput;
- WORD wWidescreenMode;
- wWidescreenMode = sprm_Get( P_CFG_VIDEO ) & 0x0300;
- #if 0
- switch(wWidescreenMode)
- {
- case 0x0000:
- wWidescreenMode = PS_TV_FULL_SCREEN;
- break;
- case 0x0100:
- wWidescreenMode = PS_TV43PS;
- break;
- case 0x0200:
- wWidescreenMode = PS_TV43LB;
- break;
- default:
- dbg_printf(("query_core(): Warning: unknown video moden"));
- }
- #endif
- dbg_printf(("CQ_WIDESCREEN_MODE: %in", wWidescreenMode));
- *pdw = (DWORD) wWidescreenMode;
- }
- break;
- #ifdef EXINO2
- case CQ_CAN_SET_REPEATAB_B:
- {
- BOOL *pb = (BOOL *) pvOutput;
-
- // Check A point time with current time
- switch (g_disc_type)
- {
- case DEC_DISC_TYPE_DVD_VIDEO:
- #ifdef EXINO2
- if ( SI_DVD_ELAPSED_TIME >= (gns.dvd.dwBookMarkATime +5) )
- #else // EXINO2
- if ( SI_DVD_ELAPSED_TIME >= (BOOKMARK_TIME(4) +5) )
- #endif // EXINO2
- {
- *pb = TRUE;
- }
- else
- {
- *pb = FALSE;
- }
- break;
- #ifdef S1_GUI
- case DEC_DISC_TYPE_CDROM:
- // ML Enable mpeg repeat A-B
- if (IS_CLIPS_TYPE_MPEG4 != 1)
- {
- break;
- }
- #endif
- #if D_SUPPORT_SACD
- case DEC_DISC_TYPE_SACD:
- *pb = TRUE;
- break;
- #endif
- case DEC_DISC_TYPE_SVCD:
- case DEC_DISC_TYPE_VCD:
- case DEC_DISC_TYPE_CDDA:
- {
- WORD curr_time = PE_CD_GetCurrentLocation()/75;
- if (g_disc_type == DEC_DISC_TYPE_VCD)
- {
- curr_time -= 2;
- }
- else if (g_disc_type == DEC_DISC_TYPE_SVCD)
- {
- curr_time -= 3;
- }
- if ( curr_time >= (BOOKMARK_TIME(4) + (( g_disc_type == DEC_DISC_TYPE_SVCD ) ? 10: 5)) )
- {
- *pb = TRUE;
- }
- else
- {
- *pb = FALSE;
- }
- break;
- }
- }
- }
- break;
- case CQ_CAN_GOTO_BOOKMARK:
- {
- BOOL *pb = (BOOL *) pvOutput;
-
- // Way to avoid the player getting stuck when user presses twice the PLAY
- // button to go to a mark.
- switch (g_disc_type)
- {
- case DEC_DISC_TYPE_DVD_VIDEO:
- if ( (SI_DVD_ELAPSED_TIME >= (BOOKMARK_TIME((BYTE)pvInput) + 3)) &&
- (gcs.pstate != PST_STILL) ) // If try to go to mark while STILL state : system gets stuck
- {
- *pb = TRUE;
- }
- else
- {
- *pb = FALSE;
- }
- break;
- case DEC_DISC_TYPE_SVCD:
- case DEC_DISC_TYPE_VCD:
- case DEC_DISC_TYPE_CDDA:
- {
- WORD curr_time = PE_CD_GetCurrentLocation()/75;
- if (g_disc_type == DEC_DISC_TYPE_VCD)
- {
- curr_time -= 2;
- }
- else if (g_disc_type == DEC_DISC_TYPE_SVCD)
- {
- curr_time -= 3;
- }
- if ( curr_time >= (BOOKMARK_TIME((BYTE)pvInput) + (( g_disc_type == DEC_DISC_TYPE_SVCD ) ? 7: 5)) )
- {
- *pb = TRUE;
- }
- else
- {
- *pb = FALSE;
- }
- break;
- }
- }
- }
- break;
-
- // Prevent skipping back from beginning or forward from end
- case CQ_CAN_SKIP_PREVIOUS:
- {
- BOOL *pb = (BOOL *) pvOutput;
- *pb = TRUE;
-
- if ( ( g_disc_type == DEC_DISC_TYPE_SVCD ) || ( g_disc_type == DEC_DISC_TYPE_VCD ) )
- {
- *pb = SVCD_Nav_Check_UOP(IE_CORE_PREVIOUS_CHAPTER, (void *)NULL);
- }
-
- if (g_disc_type == DEC_DISC_TYPE_CDDA)
- {
- *pb = CDDA_Nav_Check_UOP(IE_CORE_PREVIOUS_CHAPTER,( void *)NULL);
- }
-
- #ifdef EXINO2
- if (IS_DISC_TYPE_DVD)
- #else
- if (g_disc_type == DEC_DISC_TYPE_DVD_VIDEO)
- #endif
- {
- *pb = DVD_Nav_Check_UOP(IE_CORE_PREVIOUS_CHAPTER,( void *)NULL);
- }
- }
- break;
- case CQ_CAN_SKIP_NEXT:
- {
- BOOL *pb = (BOOL *) pvOutput;
- *pb = TRUE;
-
- if ( ( g_disc_type == DEC_DISC_TYPE_SVCD ) || ( g_disc_type == DEC_DISC_TYPE_VCD ) )
- {
- *pb = SVCD_Nav_Check_UOP(IE_CORE_NEXT_CHAPTER, (void *)NULL);
- }
-
- if (g_disc_type == DEC_DISC_TYPE_CDDA)
- {
- *pb = CDDA_Nav_Check_UOP(IE_CORE_NEXT_CHAPTER,( void *)NULL);
- }
-
- if (g_disc_type == DEC_DISC_TYPE_DVD_VIDEO)
- {
- *pb = DVD_Nav_Check_UOP(IE_CORE_NEXT_CHAPTER,( void *)NULL);
- }
- }
- break;
- #endif // EXINO2
-
- #ifdef S1_GUI
- case CQ_ONE_SEQUENTIAL_PGC_TITLE:
- {
- // Check if it is one sequential pgc title or not.
- BOOL bOneSequentialPgc = FALSE;
- BOOL *pb = (BOOL *) pvOutput;
- if ( g_disc_type == DEC_DISC_TYPE_DVD_VIDEO )
- {
- WORD wTitleNum = (WORD) pvInput;
- printf("n check if it is one sequential pgc title or not!!!n ");
- get_one_sequential_pgc( wTitleNum, &bOneSequentialPgc );
- }
- *pb = bOneSequentialPgc;
- }
- break;
- #endif
- #endif // S1_GUI
-
- default:
- tr_printf(("WARNING: query_core() - Undefined query type (0x%04x)n", cq));
- break;
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_report_error
- // Purpose : Reporting an error to the UI task by the core.
- // Input Parameters : event - The error event to report.
- // pvParam - The event parameters.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void core_report_error( EVENT event, void *pvParam )
- {
- if ( event == IE_UI_REPORT_ERROR )
- {
- ie_send_ex( event, pvParam );
- }
- dbg_printf(("core_report_error(): event: %04x, pvParam: %08lxn", event, (long) pvParam));
- gcs.mLastError = (unsigned long) pvParam;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_20ms_tick_handler
- // Purpose : The handler for 20ms events recieved from io_hal.
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void core_20ms_tick_handler (void)
- {
- static int tick_counter=0;
- static int tick_100ms=0;
- /* Check if it is disabled (UI task is not initialized yet) */
- if (FALSE == g_core_20ms_tick_handler_enabled)
- {
- return;
- }
- #ifdef TUNER_ENABLE
- if (RADIO_WORKMODE == gps->TunerWorkmode)
- {
- send_tick(IE_CORE_TICK_20);
- }
- #endif
- #ifdef REMOTE_ISR_MONITOR
- if(ir_interval)
- {
- ir_interval --;
- }
- #endif
-
- tick_counter++;
- /* Check if we reached a 100ms */
- if (tick_counter >= 5)
- {
- tick_100ms++;
- tick_counter = 0;
- #ifdef SCREEN_SAVER
- if(gcs.bScreenSaverOn)
- {
- send_tick(IE_CORE_TICK_100);
- }
- #endif
- /* Notify UI tasks */
- send_tick(IE_UI_TICK_100);
-
- /* Check if we ellapsed a 200msec */
- if ( !(tick_100ms & 1) )
- {
- send_tick(IE_CORE_TICK_200);
- send_tick(IE_UI_TICK_200);
- }
- /* Check if we ellapsed a second */
- if (tick_100ms >= 10)
- {
- send_tick(IE_CORE_TICK_ONE_SEC);
- send_tick(IE_UI_TICK_ONE_SEC);
- tick_100ms = 0;
- // <<< Stephane.Hollande.032304:Fix NMI problem with fast Paradigm communication
- #if defined(__PDREMOTE__) && !defined(NO_UART_BUG)
- if (inport(SER0_CON) & SER_TMODE) // Test if serial port is enabled
- {
- static unsigned tick_1s = 0;
-
- // There is a bug in the core or the core initialization that
- // causes the UART to sleep if not used every 20 seconds. This fix
- // sends a null PDREMOTE command through the port to keep it alive.
- // Otherwise PDREMOTE software and NMI breakpoints stop working.
- if (++tick_1s == 20)
- {
- tick_1s = 0 ;
- // compare to cpuv186tserio.c#Putch
- // but explicit for PDREMOTE's COMM port 0
- while (!(inport(SER0_STS) & SER_THRE));
-
- /* Write the character to the transmit buffer */
- outport(SER0_TDATA, 0xFD) ;
- }
- }
- #endif defined(__PDREMOTE__) && !defined(NO_UART_BUG)
- // Stephane.Hollande.032304 >>>
- }
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_clear_bookmark_info
- // Purpose : Clear a bookmark.
- // Input Parameters : bookmark_num - the book mark to clear.
- // Return type : none.
- // Output Parameters: none.
- // Remarks : If the input is 0, all bookmarks are cleared.
- /////////////////////////////////////////////////////////////////////////////
- void core_clear_bookmark_info( int bookmark_num )
- {
- if (bookmark_num)
- {
- gcs.mBookmarkTime[bookmark_num-1] = EMPTY_BOOKMARK;
- }
- else
- {
- #ifdef SUPPORT_FIVE_DVD_BOOKMARKS
- gcs.mBookmarkTime[0] = gcs.mBookmarkTime[1] = gcs.mBookmarkTime[2] =
- gcs.mBookmarkTime[3] = gcs.mBookmarkTime[4] = EMPTY_BOOKMARK;
- #else
- gcs.mBookmarkTime[0] = gcs.mBookmarkTime[1] = gcs.mBookmarkTime[2] = EMPTY_BOOKMARK;
- #endif
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_set_bookmark_info
- // Purpose : Set a book mark.
- // Input Parameters : bookmark_num - the book mark to set.
- // time_in_sec - The time of the bookmark.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void core_set_bookmark_info( int bookmark_num, WORD time_in_sec )
- {
- gcs.mBookmarkTime[bookmark_num-1] = time_in_sec;
- }
- #ifdef EXINO2
- /////////////////////////////////////////////////////////////////////////////
- // Function name : get_language_index
- // Purpose : Returns language index according to PS.H LANGUAGE_SETTINGS.
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- // Remarks : purpose is to display language stream for DVD
- // subtitle and audio Function is mapping LCD to OSD
- // language index returns -1 if not known.
- /////////////////////////////////////////////////////////////////////////////
- int get_language_index( WORD lcd )
- {
- int i = 0;
- while(( g_language_code_array[i]!=lcd ) && (g_language_code_array[i]))
- i++;
- return ( g_language_code_array[i] ? i:-1 );
- }
- #endif // EXINO2
- #ifdef TV_GUARDIAN_ENABLE
- /////////////////////////////////////////////////////////////////////////////
- // Function name : Initiazlie_Line21DataBufferPool
- // Purpose :
- // Input Parameters : none.
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void Initiazlie_Line21DataBufferPool(void)
- {
- BYTE temp;
- for (temp=0; temp<NUM_OF_LINE21DATA_BUFFER_POOL; temp++)
- {
- Line21DataBufferPool[temp].GopCounter = 0xFF;
- Line21DataBufferPool[temp++].DataLength = 0;
- }
- for (temp=0; temp<NUM_OF_LINE21DATASTRUC; temp++)
- {
- Line21DataStruc[temp].DataLength = 0;
- Line21DataStruc[temp].GopCounter = 0xFF;
- }
- for (temp=0; temp<LINE21MUTEQUEUESIZE; temp++)
- {
- Line21MuteQueue[temp].mGOP = 0;
- Line21MuteQueue[temp].mCmd = 0;
- Line21MuteQueue[temp].mOffset = 0xF;
- }
- gLine21MuteQueue_Read = 0xFF;
- gLine21MuteQueue_Write = 0xFF;
- gLine21DataBufferPool_Read = 0xFF;
- gLine21DataBufferPool_Write = 0xFF;
- gLine21DataStruc_Write = 0xFF;
- gLine21DataStruc_Read = 0xFF;
- #ifdef _DEBUG
- datain_session_id = 0x00;
- #endif
- }
- #endif //TV_GUARDIAN_ENABLE
- //<<<SeanLiu_0902_2004
- #if 0//def AUDIO_IN_SUPPORT //del by wl092304
- /////////////////////////////////////////////////////////////////////////////
- // Function name : ain_core_event_handler
- // Purpose :
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static int ain_core_event_handler(HDLR_OP op, EVENT evt, void *param)
- {
- switch(op)
- {
- case HDLR_ENTER :
- ain_core_constructor();
- break;
- case HDLR_EXIT :
- ain_core_destructor();
- break;
- case HDLR_EVENT :
- switch( evt )
- {
- case IE_CORE_RESTART:
- case IE_CORE_PLAY:
- PE_CD_AUDIO_IN_MODE(gtps.mAudioInMode);
- gcs.pstate = PST_PLAY;
- break;
- case IE_CORE_STOP:
- PE_CD_AUDIO_IN_MODE(AUDIO_IN_MODE_OFF);
- gcs.pstate = PST_STOP;
- break;
- case IE_CORE_AUDIO_IN_MODE :
- if(((AUDIO_IN_MODE_SETTING) param) != gcst.mAudioInMode)
- {
- gtps.mAudioInMode = (AUDIO_IN_MODE_SETTING) param;
- PE_CD_AUDIO_IN_MODE(gtps.mAudioInMode);
- }
- if(AUDIO_IN_MODE_OFF == ((AUDIO_IN_MODE_SETTING) param))
- {
- gcs.pstate = PST_STOP;
- }
- else
- {
- gcs.pstate = PST_PLAY;
- }
- break;
- }
- break;
- }
- return 0;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : ain_core_constructor
- // Purpose :
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void ain_core_constructor(void)
- {
- /*
- AS_Set_Enhancement_Mode( gps->ain_mode );
- PE_CD_SelectAudioStream(CDDA_SID);
- PE_CD_SelectAINChannelMode();
- */
- SET_COP_MASK( 0x00000000 );
- SET_COP_MASK( COP_PLAY | COP_EJECT | COP_STOP | COP_RESTART);
- g_disc_type = DEC_DISC_TYPE_AIN;
- gcs.mstate = MST_DISC_READY;
- gcs.pstate = PST_PLAY;
- }
- /////////////////////////////////////////////////////////////////////////////
- // Function name : ain_core_destructor
- // Purpose :
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- static void ain_core_destructor(void)
- {
- /*
- AS_Set_Enhancement_Mode( M_Mode_OFF );
- gcs.mstate = MST_LOADING;
- */
- /*
- g_disc_type = DEC_DISC_TYPE_NO_DISK;
- gcs.mstate = MST_NO_DISC;
- gcs.pstate = PST_STOP;
- */
- //PE_CD_AUDIO_IN_MODE(AUDIO_IN_MODE_OFF);
- gds.disctype = DISCTYPE_UNINITIALIZED;
- gcs.mstate = MST_LOADING;
- gcs.pstate = PST_STOP;
- gcs.cop_mask = COP_EJECT|COP_POWER_OFF;
- //DEC_StopScreenSaver();
-
- }
- #endif //AUDIO_IN_SUPPORT
- //<<<SeanLiu_0902_2004
- #ifdef STORE_PS_DATA_IN_FLASH
- /////////////////////////////////////////////////////////////////////////////
- // Function name : core_save_NVM_setting_In_Flash
- // Purpose :
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- void core_save_NVM_setting_In_Flash( unsigned short far *flash_sa)
- {
- #ifdef HW_POWER_ON_RESUME
- BOOL NeedCacheBMK = (FALSE == NVM_BMK_IsCached());
- if (NeedCacheBMK)
- NVM_BMK_Cache();
- #endif
- if (!CheckAddressWritable((unsigned short far *)flash_sa))
- {
- dbg_printf(("Updating Flash ROMn"));
- //Flash Rom
- asm{cli};
- Init_FLASH_Burner_API();
- Erase_One_Sector(flash_sa);
- #ifdef STORE_PS_DATA_IN_FLASH
- PS_NVM_Save( TRUE );
- #endif
- #ifdef HW_POWER_ON_RESUME
- NVM_BMK_Save( TRUE );
- #endif
- asm{sti};
- }
- else
- {
- //SRAM in PDRemote Mode
- dbg_printf(("Updating SRAMn"));
- #ifdef STORE_PS_DATA_IN_FLASH
- PS_NVM_Save( FALSE );
- #endif
- #ifdef HW_POWER_ON_RESUME
- NVM_BMK_Save( FALSE );
- #endif
- }
-
- #ifdef HW_POWER_ON_RESUME
- if (NeedCacheBMK)
- {
- NVM_BMK_UnCache();
- }
- #endif
- }
- #endif // STORE_PS_DATA_IN_FLASH
- #ifdef ENABLE_CHECK_SUM
- /////////////////////////////////////////////////////////////////////////////
- // Function name : check_sum
- // Purpose :
- // Input Parameters :
- // Return type : none.
- // Output Parameters: none.
- /////////////////////////////////////////////////////////////////////////////
- BOOL check_sum(void)
- {
- WORD check_data_add_all = 0,check_save_data = 0,check_save_data_random;
- DWORD check_data_size,i,check_data_size_random;
- WORD *temp_check_address;
- WORD *temp_size_address = (WORD *)CODE_SIZE_START_ADDRESS;
- WORD offset = 0,offset_address = 0x00;
-
- check_data_size = (*temp_size_address) + (((DWORD)(*(temp_size_address+1)))<<16) ;
- check_data_size_random = (*(temp_size_address+5)) + (((DWORD)(*(temp_size_address+6)))<<16) ;
-
- check_save_data = *(temp_size_address+2);
- check_save_data_random = *(temp_size_address+7);
-
- check_data_size ^= check_data_size_random;
- check_data_size = check_data_size/2;
- check_save_data ^= check_save_data_random;
- temp_check_address = MK_FP(CODE_BEGIN_ADDRESS , 0);
- for(i=0x80;i<check_data_size;i++)
- {
- if(((i*2)&0x01ffff) == 0x10000)
- {
- offset ++;
- offset_address = offset*0x100;
- temp_check_address = MK_FP(CODE_BEGIN_ADDRESS + offset_address, 0);
- check_data_size -= i;
- i = 0;
- }
-
- check_data_add_all += *(temp_check_address+i);
- }
-
- tr_printf(("check sum add all data is : %xn", check_data_add_all));
- if(check_data_add_all == check_save_data)
- {
- tr_printf(("------------check sum is succeed ------------n"));
- return TRUE;
- }
- else
- {
- tr_printf(("------------check sum is failed --------------n"));
- return FALSE;
- }
- }
- #endif