GeneralDeviceInterface.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:132k
源码类别:
MTK
开发平台:
C/C++
- #endif /* defined(__MMI_SUBLCD__) */
- /* redraw main lcd */
- gdi_lcd_repaint_all();
- /* resume screensaver if it is playing before sleep-in, must after lcd sleep out */
- mmi_scrsvr_lcd_sleepout_handler();
- #if defined(__WIFI_SUPPORT__) && defined (__MTK_TARGET__)
- wndrv_LCD_isON();
- #endif /* #if defined(__WIFI_SUPPORT__) && defined (__MTK_TARGET__) */
- /* tvout sleepout */
- #ifdef __MMI_TVOUT__
- mmi_phnset_tvout_lcd_sleepout_handler();
- #endif
- #ifdef __MMI_TOUCH_SCREEN__
- /* diamond, 2006/06/09 Pen will not be blocked if keypad lock timeout after backlight is off */
- if ((g_idle_context.IsOnIdleScreen || g_idle_context.IsOnSimErrorScreen)&& g_keylock_context.gKeyPadLockFlag)
- {
- mmi_pen_block();
- }
- #endif /* __MMI_TOUCH_SCREEN__ */
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * GpioTurnOnKeypadLight
- * DESCRIPTION
- * turn on keypad backlight
- *
- * PARAMETERS:
- * void
- *****************************************************************************/
- static void GpioTurnOnKeypadLight(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- //KP Jerry add on 2007-03-26 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- if(GetCurrentActivatedProfileKeyBKStatus())
- {
- #endif
- //KP Jerry add on 2007-03-26 end
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- /* turn on keypad backlight if currently off and clam open */
- if (keypad_backlight == 0 && gMMIClamState == 1 && g_keylock_context.gKeyPadLockFlag == 0)
- {
- KeyPadBackLightOn();
- keypad_backlight = 1;
- }
- StartTimer(GPIO_KEYPAD_LIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, GpioTurnOffKeypadLight);
- //KP Jerry add on 2007-03-26 start
- #ifdef __MMI_PROFILE_POWER_SAVING__
- }
- #endif
- //KP Jerry add on 2007-03-26 end
- #endif /* MMI_ON_HARDWARE_P */
- }
- //KP Jerry add on 2007-4-25 start
- void SetkeypadBacklightStuatus(U8 value)
- {
- keypad_backlight = value;
- }
- //KP Jerry add on 2007-4-25 end
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_set_main_lcd_level_5
- * DESCRIPTION
- * Set main LCD level to 5.
- * PARAMETERS:
- * void
- *****************************************************************************/
- static void mmi_gpio_set_main_lcd_level_5(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- }
- #endif /* MMI_BK_LIGHT_DELAY_TIME */
- /*****************************************************************************
- * FUNCTION
- * IsBacklightOn
- * DESCRIPTION
- * Test whether the backlight is on (half-light or full-light)
- *
- * PARAMETERS:
- * void
- *****************************************************************************/
- MMI_BOOL IsBacklightOn(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (lcd_backlight)
- {
- return MMI_TRUE;
- }
- else
- {
- return MMI_FALSE;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * HalfModeBacklight
- * DESCRIPTION
- * Takes the Backlight to Half Mode
- * (Backlit is dimmed but not black)
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void HalfModeBacklight(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (gbacklight_mode == 1) /* for AT command */
- {
- if (sublcd_backlight == 0)
- {
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL5);
- sublcd_backlight = 1;
- }
- if (lcd_backlight == 0 && gMMIClamState == 1) /* sleep mode */
- {
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepOut();
- UI_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
- update_mainlcd_dt_display();
- update_sublcd_dt_display();
- /* resume screensaver if it is playing before sleep-in, must after lcd sleep out */
- mmi_scrsvr_lcd_sleepout_handler();
- /* tvout sleepout */
- #ifdef __MMI_TVOUT__
- mmi_phnset_tvout_lcd_sleepout_handler();
- #endif
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL1);
- lcd_backlight = 1;
- }
- if (isTimerSuspend == 1)
- {
- if (mmi_bootup_get_active_flight_mode() == 0)
- {
- evshed_resume_all_events(event_scheduler1_ptr);
- }
- isTimerSuspend = 0;
- }
- if (gBackLightTimerStatus > 1)
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_OPEN_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- }
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- #if defined(__MMI_SYNC_LCD_GPIO_MODE__)
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_turn_on_all_light
- * DESCRIPTION
- * Turn on all light to whole bright
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gpio_turn_on_all_light(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "turn_on_all_light() lcd_backlight=%d", lcd_backlight));
- GpioLCDSleepOut();
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- lcd_backlight = 2;
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_turn_off_all_light
- * DESCRIPTION
- * Turn off all light to whole dark
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gpio_turn_off_all_light(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "turn_off_all_light() lcd_backlight=%d", lcd_backlight));
- /* set lcd backlight to half mode */
- if (lcd_backlight != 0) /* backlight is on */
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL0);
- lcd_backlight = 0;
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * TurnOffBacklight
- * DESCRIPTION
- * It is typically paired with TurnOnBacklight(0) in order to resume backlight timer.
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void TurnOffBacklight(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "TurnOffBacklight(): lcd_backlight=%d, BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- /* Share the same code for target and PC simulator */
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- if (gBackLightTimerStatus == 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * BacklightTimerHdlr
- * DESCRIPTION
- * Timer handler to switch backlight state
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- static void BacklightTimerHdlr(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "BacklightTimerHdlr() lcd_backlight=%d, BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- if (gBackLightTimerStatus == 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- else if (gBackLightTimerStatus == 1)
- {
- if (lcd_backlight == 2)
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL1);
- lcd_backlight = 1;
- }
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_OPEN_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- }
- else /* gBackLightTimerStatus == 2 */
- {
- if (lcd_backlight == 1)
- {
- if(/*!backlight_check_call_present() //KP Jerry disable on 2006-12-21
- &&*/ (g_phb_cntx.processing == FALSE)
- /*&& (mdi_audio_get_state() != MDI_AUDIO_RECORD) && (mdi_audio_get_state() != MDI_AUDIO_RECORD_PAUSED)*/) //KP Jerry disable on 2006-12-21
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL0);
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) /* { */
- GpioLCDSleepIn();
- #ifdef __MMI_LCMSLEEP_BACK2IDLE__
- LCMSleepGotoIdleScreen();
- #endif
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */ /* } */
- lcd_backlight = 0;
- }
- gBackLightTimerStatus = 3;
- }
- #ifdef __MMI_CLAMSHELL__
- if (isTimerSuspend == 0
- && g_charbat_context.isChargerConnected == 0
- && !backlight_check_call_present()
- && mmi_msg_need_mem_full_ind() == 0
- && g_phb_cntx.processing == FALSE
- #if defined(__MMI_VIDEO_PLAYER__) && defined(__MMI_TVOUT__)
- && mmi_vdoply_is_in_play_and_tvout_enable() == MMI_FALSE
- #endif
- /*&& mdi_audio_get_state() != MDI_AUDIO_RECORD && mdi_audio_get_state() != MDI_AUDIO_RECORD_PAUSED*/ ) //KP Jerry disable on 2006-12-21
- #else /* __MMI_CLAMSHELL__ */
- if (isTimerSuspend == 0 && g_charbat_context.isChargerConnected == 0
- && !backlight_check_call_present()
- #if defined(__MMI_VIDEO_PLAYER__) && defined(__MMI_TVOUT__)
- && mmi_vdoply_is_in_play_and_tvout_enable() == MMI_FALSE
- #endif
- && g_phb_cntx.processing == FALSE /*&& mdi_audio_get_state() != MDI_AUDIO_RECORD && mdi_audio_get_state() != MDI_AUDIO_RECORD_PAUSED*/ ) //KP Jerry disable on 2006-12-21
- #endif /* __MMI_CLAMSHELL__ */
- {
- if (mmi_bootup_get_active_flight_mode() == 0)
- {
- evshed_suspend_all_events(event_scheduler1_ptr);
- }
- isTimerSuspend = 1;
- }
- }
- #else /* MMI_ON_HARDWARE_P */ /* For PC Simulator only */
- if (gbacklight_mode == 1)
- {
- if (gBackLightTimerStatus == 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- else if (gBackLightTimerStatus == 1)
- {
- if (lcd_backlight == 2)
- {
- simulate_lcd_bklight_turn_off();
- lcd_backlight = 1;
- }
- if (sublcd_backlight == 1)
- {
- simulate_sublcd_bklight_turn_off();
- sublcd_backlight = 0;
- }
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_OPEN_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- }
- else /* gBackLightTimerStatus == 2 */
- {
- if (sublcd_backlight == 1)
- {
- simulate_sublcd_bklight_turn_off();
- sublcd_backlight = 0;
- }
- if (lcd_backlight == 1)
- {
- simulate_lcd_bklight_turn_off();
- }
- gBackLightTimerStatus = 3;
- }
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * TurnOnBacklight
- * DESCRIPTION
- * Turns On the backlight
- * PARAMETERS
- * time_enum [IN] Time duration type
- *****************************************************************************/
- void TurnOnBacklight(gpio_backlight_time_enum time_enum)
- {
- #ifdef MMI_ON_HARDWARE_P /* { */
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "TurnOnBacklight() time_enum=%d, BLTimerStat=%d", time_enum, gBackLightTimerStatus));
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- StopMyTimer(GPIO_BACKLIGHT_DELAY_TIMER);
- #endif
- /* resume timer if suspended */
- if (isTimerSuspend == 1)
- {
- if (mmi_bootup_get_active_flight_mode() == 0)
- {
- evshed_resume_all_events(event_scheduler1_ptr);
- }
- isTimerSuspend = 0;
- }
- #ifdef LCM_MMI_TYPE_QUERY
- #ifdef __MMI_LCD_PARTIAL_ON__
- /* If LCD is transmissive, there is meanless for partial display.
- But if LCD is reflective or transflective, user can see the display when backlight is off.
- In this case, when turn on backlight, handset should leave Screen saver */
- if (get_lcm_type)
- {
- if (get_lcm_type() == LCM_TRANSFLECTIVE_TYPE)
- {
- LeavePartialOnScreenSaverIfOk();
- }
- }
- #endif
- #endif /* LCM_MMI_TYPE_QUERY */
- /* lcd backlight */
- if (lcd_backlight == 0)
- {
- lcd_backlight = 2;
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepOut();
- #endif
- #ifdef __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ /* { */
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- StartTimer(GPIO_BACKLIGHT_DELAY_TIMER, MMI_BK_LIGHT_DELAY_TIME, mmi_gpio_set_main_lcd_level_5);
- #else
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- #else /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* }{ */
- if (gMMIClamState == 1) /* clam is opened */
- {
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- StartTimer(GPIO_BACKLIGHT_DELAY_TIMER, MMI_BK_LIGHT_DELAY_TIME, mmi_gpio_set_main_lcd_level_5);
- #else
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- lcd_backlight = 2;
- }
- else /* clam is closed */
- {
- #ifndef __MMI_SLIDE__
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL1);
- lcd_backlight = 1;
- #else
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- StartTimer(GPIO_BACKLIGHT_DELAY_TIMER, MMI_BK_LIGHT_DELAY_TIME, mmi_gpio_set_main_lcd_level_5);
- #else
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- lcd_backlight = 2;
- #endif
- }
- #endif /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* } */
- }
- else if (lcd_backlight == 1)
- {
- #ifdef __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- lcd_backlight = 2;
- #else /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* }{ */
- #ifndef __MMI_SLIDE__
- if (gMMIClamState == 1 || !mmi_bootup_is_searching_or_idle_reached()) /* clam is opened */
- #endif
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- lcd_backlight = 2;
- }
- #endif /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* } */
- }
- /* turn on keypad backlight if currently off and clam open */
- GpioTurnOnKeypadLight();
- /* start/stop timer according to input parameter */
- if (time_enum == GPIO_BACKLIGHT_PERMANENT)
- {
- StopTimer(BACKLIGHT_TIMER);
- gBackLightTimerStatus = 0;
- }
- else if (gBackLightTimerStatus != 0) /* start a timer */
- {
- StopTimer(BACKLIGHT_TIMER);
- #ifdef __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- #else /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* }{ */
- #if defined (__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__)
- if (gMMIClamState == 1) /* clam is opened */
- {
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- else /* clam is closed */
- {
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_CLOSE_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- #else /* defined (__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) */
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- #endif /* defined (__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) */
- #endif /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* } */
- }
- #else /* MMI_ON_HARDWARE_P */ /* For PC Simulator only */ /* }{ */
- if (gbacklight_mode == 1)
- {
- if (sublcd_backlight == 0)
- {
- simulate_sublcd_bklight_turn_on();
- sublcd_backlight = 1;
- }
- if (lcd_backlight == 0)
- {
- simulate_lcd_bklight_turn_on();
- lcd_backlight = 2;
- }
- else if (lcd_backlight == 1)
- {
- simulate_lcd_bklight_turn_on();
- lcd_backlight = 2;
- }
- }
- if (time_enum == GPIO_BACKLIGHT_PERMANENT)
- {
- StopTimer(BACKLIGHT_TIMER);
- gBackLightTimerStatus = 0;
- }
- else
- {
- if (gBackLightTimerStatus != 0) /* start a timer */
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- }
- #endif /* MMI_ON_HARDWARE_P */ /* } */
- }
- /*****************************************************************************
- * FUNCTION
- * CloseBacklight
- * DESCRIPTION
- * Immeditae Baclight Close not going thru Half Mode
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void CloseBacklight(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "CloseBacklight() lcd_backlight=%d BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- /* stop backlight timer */
- if (gBackLightTimerStatus != 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- }
- #ifdef __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ /* { */
- if (lcd_backlight == 1) /* backlight is half light */
- {
- lcd_backlight = 2;
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- }
- else if (lcd_backlight == 0) /* backlight is off */
- {
- lcd_backlight = 2;
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepOut();
- update_mainlcd_dt_display();
- update_sublcd_dt_display();
- gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
- GpioWakeUpTimer();
- gIsInSleepMode = 0;
- /* resume screensaver if it is playing before sleep-in, must after lcd sleep out */
- mmi_scrsvr_lcd_sleepout_handler();
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL5);
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- }
- #else /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* }{ */
- /* set lcd backlight to half mode */
- if (lcd_backlight == 2) /* backlight is on */
- {
- lcd_backlight = 1;
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL1);
- }
- else if (lcd_backlight == 0) /* backlight is off */
- {
- lcd_backlight = 1;
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepOut();
- update_mainlcd_dt_display();
- update_sublcd_dt_display();
- gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
- GpioWakeUpTimer();
- gIsInSleepMode = 0;
- /* resume screensaver if it is playing before sleep-in, must after lcd sleep out */
- mmi_scrsvr_lcd_sleepout_handler();
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL5);
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- }
- #endif /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */ /* } */
- /* turn off keypad backlight */
- GpioTurnOffKeypadLight();
- #ifdef __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- #else /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_CLOSE_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- #endif /* __MMI_GPIO_3_STAGE_SUB_BACKLIGHT__ */
- #endif /* MMI_ON_HARDWARE_P */
- }
- #else /* defined(__MMI_SYNC_LCD_GPIO_MODE__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_turn_on_all_light
- * DESCRIPTION
- * Turn on all light to whole bright
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gpio_turn_on_all_light(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "turn_on_all_light() lcd_backlight=%d, BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- GpioLCDSleepOut();
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- lcd_backlight = 2;
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL5);
- sublcd_backlight = 2;
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_turn_off_all_light
- * DESCRIPTION
- * Turn off all light to whole dark
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- static void mmi_gpio_turn_off_all_light(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "turn_off_all_light() lcd_backlight=%d", lcd_backlight));
- /* set lcd backlight to half mode */
- if (lcd_backlight != 0) /* backlight is on */
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL0);
- lcd_backlight = 0;
- }
- /* turn on sub-lcd baclight */
- if (sublcd_backlight != 0)
- {
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL0);
- sublcd_backlight = 0;
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * TurnOffBacklight
- * DESCRIPTION
- * Turns Off the backlight
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void TurnOffBacklight(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "TurnOffBacklight() lcd_backlight=%d, BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- /* Share the same code for target and PC simulator */
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- if (gBackLightTimerStatus == 0) /* resume backlight mechanism */
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * BacklightTimerHdlr
- * DESCRIPTION
- * Timer handler to switch backlight state
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- static void BacklightTimerHdlr(void)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "BacklightTimerHdlr() lcd_backlight=%d, BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- if (gBackLightTimerStatus == 0) /* resume backlight mechanism */
- {
- gBackLightTimerStatus = 1;
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- }
- else if (gBackLightTimerStatus == 1)
- {
- if (lcd_backlight == 2) /* full light, switch to half light */
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL1);
- lcd_backlight = 1;
- }
- if (sublcd_backlight == 1)
- {
- sublcd_backlight = 0;
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL0);
- }
- StopTimer(BACKLIGHT_TIMER);
- #ifdef __MMI_CLAMSHELL__
- if (gMMIClamState == 0)
- {
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_CLOSE_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- }
- else
- #endif /* __MMI_CLAMSHELL__ */
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_OPEN_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- }
- else /* gBackLightTimerStatus == 2 */
- {
- if (sublcd_backlight == 1)
- {
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL0);
- sublcd_backlight = 0;
- }
- if (lcd_backlight == 1)
- {
- if(/*!backlight_check_call_present() //KP Jerry disable on 2006-12-21
- &&*/ (g_phb_cntx.processing == FALSE)
- /*&& (mdi_audio_get_state() != MDI_AUDIO_RECORD) && (mdi_audio_get_state() != MDI_AUDIO_RECORD_PAUSED)*/) //KP Jerry disable on 2006-12-21
- {
- #ifdef __MMI_LCD_PARTIAL_ON__
- /* We do not enter partial display screen saver before idle screen */
- if (((mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE) || mmi_bootup_is_sim_removed() == MMI_TRUE)
- && PhnsetIsScrSvrPartialOn())
- {
- /* 1. Turn off backlight if defined(__MMI_GPIO_DISABLE_SLEEP_MODE__), but keep
- half backlight if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__).
- (Typically __MMI_GPIO_DISABLE_SLEEP_MODE__ means that LCM can
- retain display even when backlight is turned off, and hence we
- can turn off backlight without making LCM sleep.)
- 2. __MMI_LCMSLEEP_BACK2IDLE__ is currently ignored */
- if (gBackLightTimerStatus == 2)
- {
- EnterPartialOnScreenSaverIfOk();
- }
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL0);
- lcd_backlight = 0;
- #endif /* defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- }
- else
- #endif /* __MMI_LCD_PARTIAL_ON__ */
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL0);
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepIn();
- #ifdef __MMI_LCMSLEEP_BACK2IDLE__
- LCMSleepGotoIdleScreen();
- #endif
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- lcd_backlight = 0;
- }
- }
- gBackLightTimerStatus = 3;
- }
- if (isTimerSuspend == 0 && g_charbat_context.isChargerConnected == 0
- && !backlight_check_call_present()
- #ifdef __MMI_CLAMSHELL__
- && mmi_msg_need_mem_full_ind() == 0
- #endif
- #if defined(__MMI_VIDEO_PLAYER__) && defined(__MMI_TVOUT__)
- && mmi_vdoply_is_in_play_and_tvout_enable() == MMI_FALSE
- #endif
- && g_phb_cntx.processing == FALSE
- /*&& mdi_audio_get_state() != MDI_AUDIO_RECORD && mdi_audio_get_state() != MDI_AUDIO_RECORD_PAUSED*/ ) //KP Jerry disable on 2006-12-21
- {
- if (mmi_bootup_get_active_flight_mode() == 0)
- {
- evshed_suspend_all_events(event_scheduler1_ptr);
- }
- isTimerSuspend = 1;
- }
- }
- #else /* MMI_ON_HARDWARE_P */ /* For PC Simulator only */
- if (gbacklight_mode == 1)
- {
- if (gBackLightTimerStatus == 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- else if (gBackLightTimerStatus == 1)
- {
- if (lcd_backlight == 2)
- {
- simulate_lcd_bklight_turn_off();
- lcd_backlight = 1;
- }
- if (sublcd_backlight == 1)
- {
- simulate_sublcd_bklight_turn_off();
- sublcd_backlight = 0;
- }
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, LCD_CLAM_OPEN_HALFLITE_TO_OFF_TIME, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- }
- else /* gBackLightTimerStatus == 2 */
- {
- if (sublcd_backlight == 1)
- {
- simulate_sublcd_bklight_turn_off();
- sublcd_backlight = 0;
- }
- if (lcd_backlight == 1)
- {
- simulate_lcd_bklight_turn_off();
- }
- gBackLightTimerStatus = 3;
- }
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * TurnOnBacklight
- * DESCRIPTION
- * Turns On the backlight
- * PARAMETERS
- * time_enum [IN] Time duration type
- *****************************************************************************/
- void TurnOnBacklight(gpio_backlight_time_enum time_enum)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "TurnOnBacklight() time_enum=%d, BLTimerStat=%d", time_enum, gBackLightTimerStatus));
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- StopMyTimer(GPIO_BACKLIGHT_DELAY_TIMER);
- #endif
- /* resume timer if suspended */
- if (isTimerSuspend == 1)
- {
- if (mmi_bootup_get_active_flight_mode() == 0)
- {
- evshed_resume_all_events(event_scheduler1_ptr);
- }
- isTimerSuspend = 0;
- }
- #ifdef LCM_MMI_TYPE_QUERY
- #ifdef __MMI_LCD_PARTIAL_ON__
- /* If LCD is transmissive, there is meanless for partial display.
- But if LCD is reflective or transflective, user can see the display when backlight is off.
- In this case, when turn on backlight, handset should leave Screen saver */
- if (get_lcm_type)
- {
- if (get_lcm_type() == LCM_TRANSFLECTIVE_TYPE)
- {
- LeavePartialOnScreenSaverIfOk();
- }
- }
- #endif
- #endif /* #ifdef LCM_MMI_TYPE_QUERY */
- /* turn on sub-lcd backlight if currently off */
- if (sublcd_backlight == 0)
- {
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL5);
- sublcd_backlight = 1;
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) && defined(__MMI_SUBLCD__)
- {
- S32 lcd_width;
- S32 lcd_height;
- gdi_lcd_set_active(GDI_LCD_SUB_LCD_HANDLE);
- gdi_lcd_get_dimension(&lcd_width, &lcd_height);
- UI_BLT_double_buffer(0, 0, lcd_width - 1, lcd_height - 1);
- gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);
- }
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) && defined(__MMI_SUBLCD__) */
- }
- if (lcd_backlight == 0 && gMMIClamState == 1) /* sleep mode and clam open */
- {
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepOut();
- update_mainlcd_dt_display();
- update_sublcd_dt_display();
- UI_BLT_double_buffer(0, 0, UI_device_width - 1, UI_device_height - 1);
- /* resume screensaver if it is playing before sleep-in */
- mmi_scrsvr_lcd_sleepout_handler();
- /* tvout sleepout */
- #ifdef __MMI_TVOUT__
- mmi_phnset_tvout_lcd_sleepout_handler();
- #endif
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- #ifdef MMI_BK_LIGHT_DELAY_TIME
- StartTimer(GPIO_BACKLIGHT_DELAY_TIMER, MMI_BK_LIGHT_DELAY_TIME, mmi_gpio_set_main_lcd_level_5);
- #else
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- #endif
- lcd_backlight = 2;
- }
- else if (lcd_backlight == 1 && gMMIClamState == 1) /* backlight off and clam open */
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- lcd_backlight = 2;
- }
- else if (lcd_backlight == 2 && gMMIClamState == 1) /* backlight off and clam open */
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL5);
- }
- /* turn on keypad backlight if currently off and clam open */
- GpioTurnOnKeypadLight();
- /* start/stop timer according to input parameter */
- if (time_enum == GPIO_BACKLIGHT_PERMANENT)
- {
- StopTimer(BACKLIGHT_TIMER);
- gBackLightTimerStatus = 0;
- }
- else if (gBackLightTimerStatus != 0) /* start a timer */
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- #else /* MMI_ON_HARDWARE_P */ /* For PC Simulator only */
- if (gbacklight_mode == 1)
- {
- if (sublcd_backlight == 0)
- {
- simulate_sublcd_bklight_turn_on();
- sublcd_backlight = 1;
- }
- if (lcd_backlight == 0)
- {
- simulate_lcd_bklight_turn_on();
- lcd_backlight = 2;
- }
- else if (lcd_backlight == 1)
- {
- simulate_lcd_bklight_turn_on();
- lcd_backlight = 2;
- }
- }
- if (time_enum == GPIO_BACKLIGHT_PERMANENT)
- {
- StopTimer(BACKLIGHT_TIMER);
- gBackLightTimerStatus = 0;
- }
- else
- {
- if (gBackLightTimerStatus != 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 1;
- }
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * CloseBacklight
- * DESCRIPTION
- * Immeditae Baclight Close not going thru Half Mode
- * We do not handle __MMI_LCD_PARTIAL_ON__ because CloseBacklight() is used only in clamshell
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void CloseBacklight()
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "CloseBacklight() lcd_backlight=%d, BLTimerStat=%d", lcd_backlight, gBackLightTimerStatus));
- /* AT command disables backlight mechanism */
- if (gbacklight_mode == 0)
- {
- return;
- }
- /* stop backlight timer */
- if (gBackLightTimerStatus != 0)
- {
- StopTimer(BACKLIGHT_TIMER);
- }
- /* turn off main-lcd backlight */
- if (lcd_backlight != 0)
- {
- SetGPIOLevelReq(GPIO_DEV_LED_MAINLCD, LED_LIGHT_LEVEL0);
- #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
- GpioLCDSleepIn();
- #ifdef __MMI_LCMSLEEP_BACK2IDLE__
- LCMSleepGotoIdleScreen();
- #endif
- #endif /* !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__) */
- lcd_backlight = 0;
- }
- /* turn off keypad backlight */
- GpioTurnOffKeypadLight();
- /* turn on sub-lcd baclight */
- if (sublcd_backlight == 0)
- {
- GpioWakeUpTimer();
- gIsInSleepMode = 0;
- GpioLCDSleepOut();
- SetGPIOLevelReq(GPIO_DEV_LED_SUBLCD, LED_LIGHT_LEVEL5);
- sublcd_backlight = 1;
- }
- StartTimer(BACKLIGHT_TIMER, g_phnset_gpio_cntx_p->bl_setting_hftime * 1000, BacklightTimerHdlr);
- gBackLightTimerStatus = 2;
- #endif /* MMI_ON_HARDWARE_P */
- }
- #endif /* defined(__MMI_SYNC_LCD_GPIO_MODE__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_backlight_ctrl_req_hdlr
- * DESCRIPTION
- * Handler of MSG_ID_MMIAPI_BACKLIGHT_CONTROL_REQ
- * PARAMETERS
- * msg [IN] Requested data
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_gpio_backlight_ctrl_req_hdlr(void *msg)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmiapi_backlight_control_req_struct *req = (mmiapi_backlight_control_req_struct*) msg;
- mmiapi_backlight_control_rsp_struct *rsp =
- (mmiapi_backlight_control_rsp_struct*) OslConstructDataPtr(sizeof(mmiapi_backlight_control_rsp_struct));
- MYQUEUE Message;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StopTimer(BACKLIGHT_TIMER);
- if (req->on_off)
- {
- if (req->disable_timer)
- {
- mmi_gpio_turn_on_all_light();
- }
- else
- {
- if (gBackLightTimerStatus < 2 || gbacklight_mode == 0)
- { /* resume backlight timer and turn on the backlight */
- TurnOnBacklight(1);
- }
- else
- {
- gBackLightTimerStatus = 0;
- TurnOffBacklight();
- }
- }
- }
- else
- {
- mmi_gpio_turn_off_all_light();
- }
- if (gBackLightTimerStatus == 0) /* timer disabled */
- {
- rsp->disable_timer = TRUE;
- }
- else
- {
- rsp->disable_timer = FALSE;
- }
- rsp->on_off = req->on_off;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_MED;
- Message.oslMsgId = MSG_ID_MMIAPI_BACKLIGHT_CONTROL_RSP;
- Message.oslDataPtr = (oslParaType*) rsp;
- Message.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&Message);
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_led_ctrl_req_hdlr
- * DESCRIPTION
- * Handler of MSG_ID_MMIAPI_LED_CONTROL_REQ
- * PARAMETERS
- * msg [IN] Requested data
- * RETURNS
- * void
- *****************************************************************************/
- void mmi_gpio_led_ctrl_req_hdlr(void *msg)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmiapi_led_control_req_struct *req = (mmiapi_led_control_req_struct*) msg;
- mmiapi_led_control_rsp_struct *rsp =
- (mmiapi_led_control_rsp_struct*) OslConstructDataPtr(sizeof(mmiapi_led_control_rsp_struct));
- MYQUEUE Message;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (req->on_off)
- {
- /* disable led background play pattern */
- gpioOutOfCtrl = 1;
- StopLEDPatternBackGround();
- /* turn on led */
- SetBackLightStatusRedOn();
- SetBackLightStatusGreenOn();
- SetBackLightStatusBlueOn();
- }
- else
- {
- /* turn off led */
- SetBackLightStatusRedOff();
- SetBackLightStatusGreenOff();
- SetBackLightStatusBlueOff();
- /* enable led background play pattern */
- gpioOutOfCtrl = 0;
- StartLEDPatternBackGround();
- }
- rsp->on_off = req->on_off;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_MED;
- Message.oslMsgId = MSG_ID_MMIAPI_LED_CONTROL_RSP;
- Message.oslDataPtr = (oslParaType*) rsp;
- Message.oslPeerBuffPtr = NULL;
- OslMsgSendExtQueue(&Message);
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * InitHWBacklightTest
- * DESCRIPTION
- * Initialisation function for Back Light Test
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void InitHWBacklightTest(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef MMI_ON_HARDWARE_P
- SetProtocolEventHandler(SetBacklightMode, MSG_ID_MMI_EQ_SET_SLEEP_MODE_REQ_IND);
- #endif
- }
- /*****************************************************************************
- * FUNCTION
- * SetBacklightModeExe
- * DESCRIPTION
- * Sets BackLight Mode
- *
- * PARAMETERS: void
- * mode [IN]
- *****************************************************************************/
- void SetBacklightModeExe(U8 mode)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (mode == 1) /* enable backlight mechanism. */
- {
- gbacklight_mode = mode;
- TurnOffBacklight();
- }
- else /* disable backlight mechanism. */
- {
- gbacklight_mode = 1;
- TurnOnBacklight(0);
- gbacklight_mode = mode;
- }
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * SetBacklightMode
- * DESCRIPTION
- * Protocol Handler for MSG_ID_MMI_EQ_SET_SLEEP_MODE_REQ_IND
- *
- * PARAMETERS: info: Data from L4
- * info [IN]
- *****************************************************************************/
- void SetBacklightMode(void *info)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmi_eq_set_sleep_mode_req_ind_struct *msg = (mmi_eq_set_sleep_mode_req_ind_struct*) info;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- SetBacklightModeExe((U8) msg->on_off);
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*
- * Audio volume path
- */
- /*****************************************************************************
- * FUNCTION
- * EnableHandsFree
- * DESCRIPTION
- * Enables Hands Free Mode
- *
- * PARAMETERS: mode
- * void
- *****************************************************************************/
- void EnableHandsFree(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- mdi_audio_set_audio_mode(AUD_MODE_LOUDSPK);
- SetModeSpeechVolume();
- }
- /*****************************************************************************
- * FUNCTION
- * DisbleHandsFree
- * DESCRIPTION
- * Disables Hands Free Mode
- *
- * PARAMETERS: mode
- * void
- *****************************************************************************/
- void DisbleHandsFree(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (isEarphonePlugged)
- {
- #ifdef __CTM_SUPPORT__
- if (mmi_ctm_is_tty_on() == MMI_FALSE)
- #endif
- {
- mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
- SetModeSpeechVolume();
- return;
- }
- }
- mdi_audio_set_audio_mode(AUD_MODE_NORMAL);
- SetModeSpeechVolume();
- }
- /*****************************************************************************
- * FUNCTION
- * SaveSpeechVolume
- * DESCRIPTION
- * Saves Speech Volume
- *
- * PARAMETERS:
- * level [IN]
- *****************************************************************************/
- void SaveSpeechVolume(U8 level)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- S16 error;
- U8 audio_mode = mdi_audio_get_audio_mode();
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (audio_mode)
- {
- case AUD_MODE_NORMAL:
- WriteValue(NVRAM_NORMAL_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- case AUD_MODE_HEADSET:
- WriteValue(NVRAM_HDSET_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- case AUD_MODE_LOUDSPK:
- WriteValue(NVRAM_LDSPK_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- }
- SetSpeechVolume(level);
- }
- /*****************************************************************************
- * FUNCTION
- * SetModeSpeechVolume
- * DESCRIPTION
- * Sets Speech Volume as per the mode
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- void SetModeSpeechVolume(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 audio_mode = mdi_audio_get_audio_mode();
- U8 level;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (audio_mode)
- {
- case AUD_MODE_NORMAL:
- ReadValue(NVRAM_NORMAL_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- case AUD_MODE_HEADSET:
- ReadValue(NVRAM_HDSET_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- case AUD_MODE_LOUDSPK:
- ReadValue(NVRAM_LDSPK_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- }
- if (level == 0xFF)
- {
- level = LEVEL4;
- WriteValue(NVRAM_HDSET_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- WriteValue(NVRAM_LDSPK_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- WriteValue(NVRAM_NORMAL_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- }
- SetSpeechVolume(level);
- }
- /*****************************************************************************
- * FUNCTION
- * GetModeSpeechVolume
- * DESCRIPTION
- * Gets Speech Volume as per the mode
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- U8 GetModeSpeechVolume(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 audio_mode = mdi_audio_get_audio_mode();
- U8 level;
- S16 error;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (audio_mode)
- {
- case AUD_MODE_NORMAL:
- ReadValue(NVRAM_NORMAL_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- case AUD_MODE_HEADSET:
- ReadValue(NVRAM_HDSET_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- case AUD_MODE_LOUDSPK:
- ReadValue(NVRAM_LDSPK_MODE_VOICE_LEVEL, &level, DS_BYTE, &error);
- break;
- }
- if (level == 0xFF)
- {
- level = LEVEL4;
- }
- return level;
- }
- /*
- * Device control interface for other modules
- */
- /*****************************************************************************
- * FUNCTION
- * GpioCtrlReq
- * DESCRIPTION
- * Api for other modules get gpio control
- *
- * PARAMETERS: action: MMIAPI_DEV_CTRL_GET / MMIAPI_DEV_CTRL_RELEASE
- * action [IN]
- *****************************************************************************/
- kal_uint8 GpioCtrlReq(kal_uint8 action)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 result = MMI_TRUE;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (action == MMIAPI_DEV_CTRL_GET)
- {
- if (gpioOutOfCtrl == 1)
- {
- result = MMI_FALSE;
- }
- else
- {
- gpioOutOfCtrl = 1;
- StopLEDPatternBackGround();
- }
- }
- else if (action == MMIAPI_DEV_CTRL_RELEASE)
- {
- if (gpioOutOfCtrl == 0)
- {
- result = MMI_FALSE;
- }
- else
- {
- gpioOutOfCtrl = 0;
- StartLEDPatternBackGround();
- GpioTurnOffKeypadLight();
- TurnOnBacklight(1);
- }
- }
- else
- {
- result = MMI_FALSE;
- }
- return result;
- }
- /*****************************************************************************
- * FUNCTION
- * GpioCtrlReqHdlr
- * DESCRIPTION
- * Other module get device control through MMI
- *
- * PARAMETERS: mmiapi_device_get_ctrl_req_struct *
- * inMsg [IN]
- *****************************************************************************/
- void GpioCtrlReqHdlr(void *inMsg)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmiapi_device_get_ctrl_req_struct *p = (mmiapi_device_get_ctrl_req_struct*) inMsg;
- mmiapi_device_get_ctrl_rsp_struct *p_out;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- p_out = OslConstructDataPtr(sizeof(mmiapi_device_get_ctrl_rsp_struct));
- p_out->result = GpioCtrlReq(p->action);
- GpioSendMsg(p->src_mod_id, MSG_ID_MMIAPI_DEVICE_GET_CTRL_RSP, (void*)p_out, (void*)NULL);
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * GpioPlayReq
- * DESCRIPTION
- * Other module control gpio device
- *
- * PARAMETERS: p_type, p_level
- * p_type [IN]
- * p_level [IN]
- *****************************************************************************/
- kal_uint8 GpioPlayReq(kal_uint8 p_type, kal_uint8 p_level)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- U8 result = MMI_TRUE;
- U8 device = 0, level = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- switch (p_type)
- {
- case MMIAPI_DEV_TYPE_MAINLCD_BL:
- device = GPIO_DEV_LED_MAINLCD;
- break;
- case MMIAPI_DEV_TYPE_SUBLCD_BL:
- device = GPIO_DEV_LED_SUBLCD;
- break;
- case MMIAPI_DEV_TYPE_KEYPAD_BL:
- device = GPIO_DEV_LED_KEY;
- break;
- case MMIAPI_DEV_TYPE_LED_1:
- device = GPIO_DEV_LED_STATUS_1;
- break;
- case MMIAPI_DEV_TYPE_LED_2:
- device = GPIO_DEV_LED_STATUS_2;
- break;
- case MMIAPI_DEV_TYPE_LED_3:
- device = GPIO_DEV_LED_STATUS_3;
- break;
- case MMIAPI_DEV_TYPE_VIBRATOR:
- device = GPIO_DEV_VIBRATOR;
- break;
- default:
- result = MMI_FALSE;
- break;
- }
- switch (p_level)
- {
- case MMIAPI_DEV_LEVEL_0:
- level = LED_LIGHT_LEVEL0;
- break;
- case MMIAPI_DEV_LEVEL_1:
- level = LED_LIGHT_LEVEL1;
- break;
- case MMIAPI_DEV_LEVEL_2:
- level = LED_LIGHT_LEVEL2;
- break;
- case MMIAPI_DEV_LEVEL_3:
- level = LED_LIGHT_LEVEL3;
- break;
- case MMIAPI_DEV_LEVEL_4:
- level = LED_LIGHT_LEVEL4;
- break;
- case MMIAPI_DEV_LEVEL_5:
- level = LED_LIGHT_LEVEL5;
- break;
- default:
- result = MMI_FALSE;
- break;
- }
- SetGPIOLevelReq(device, level);
- return result;
- }
- /*****************************************************************************
- * FUNCTION
- * GpioPlayReqHdlr
- * DESCRIPTION
- * Other module play device function through MMI
- *
- * PARAMETERS: mmiapi_device_play_req_struct *
- * inMsg [IN]
- *****************************************************************************/
- void GpioPlayReqHdlr(void *inMsg)
- {
- #ifdef MMI_ON_HARDWARE_P
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- mmiapi_device_play_req_struct *p = (mmiapi_device_play_req_struct*) inMsg;
- mmiapi_device_play_rsp_struct *p_out;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- p_out = OslConstructDataPtr(sizeof(mmiapi_device_play_rsp_struct));
- p_out->result = GpioPlayReq(p->type, p->level);
- GpioSendMsg(p->src_mod_id, MSG_ID_MMIAPI_DEVICE_PLAY_RSP, (void*)p_out, (void*)NULL);
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*******************************************************/
- /* */
- /* Send Message to Lower layer */
- /* */
- /*******************************************************/
- /*****************************************************************************
- * FUNCTION
- * SendPlayPatternReqToHW
- * DESCRIPTION
- * Send pattern request to H/W
- *
- * PARAMETERS: pattern: pattern to be played
- * pattern [IN]
- * action [IN] ON/OFF
- *****************************************************************************/
- void SendPlayPatternReqToHW(U8 pattern, U8 action)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYQUEUE Message;
- mmi_eq_play_pattern_req_struct *displayLedPattern;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- Message.oslMsgId = MSG_ID_MMI_EQ_PLAY_PATTERN_REQ;
- displayLedPattern = OslConstructDataPtr(sizeof(mmi_eq_play_pattern_req_struct));
- displayLedPattern->pattern = pattern;
- displayLedPattern->action = action;
- Message.oslDataPtr = (oslParaType*) displayLedPattern;
- Message.oslPeerBuffPtr = NULL;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- OslMsgSendExtQueue(&Message);
- }
- /*****************************************************************************
- * FUNCTION
- * SetGPIOLevelReq
- * DESCRIPTION
- * Set Levels of Devices like LCD, LEDs
- *
- * PARAMETERS: device: device
- * device [IN]
- * level [IN] Device Level
- *****************************************************************************/
- void SetGPIOLevelReq(gpio_device_enum device, U8 level)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYQUEUE Message;
- mmi_eq_exe_gpio_level_req_struct *setGPIOLevelReq;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- #ifdef __LCD_ESD_RECOVERY__
- if ((device == GPIO_DEV_LED_MAINLCD) || (device == GPIO_DEV_LED_SUBLCD))
- {
- if (level == LED_LIGHT_LEVEL0)
- {
- gdi_lcd_stop_esd_recovery_timer();
- }
- else
- {
- gdi_lcd_start_esd_recovery_timer();
- }
- }
- #endif /* __LCD_ESD_RECOVERY__ */
- Message.oslMsgId = MSG_ID_MMI_EQ_EXE_GPIO_LEVEL_REQ;
- setGPIOLevelReq = OslConstructDataPtr(sizeof(mmi_eq_exe_gpio_level_req_struct));
- setGPIOLevelReq->gpio_dev_type = device;
- if ((device == GPIO_DEV_LED_MAINLCD) && (level == LED_LIGHT_LEVEL5))
- {
- setGPIOLevelReq->gpio_dev_level = g_phnset_gpio_cntx_p->bl_setting_level;
- }
- else
- {
- setGPIOLevelReq->gpio_dev_level = level;
- }
- Message.oslDataPtr = (oslParaType*) setGPIOLevelReq;
- Message.oslPeerBuffPtr = NULL;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- OslMsgSendExtQueue(&Message);
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * SetMuteReq
- * DESCRIPTION
- * Mutes the device
- *
- * PARAMETERS: device: device
- * device [IN]
- * onoff [IN] TRUE/FALSE
- *****************************************************************************/
- void SetMuteReq(audio_type_enum device, MMI_BOOL onoff)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- MYQUEUE Message;
- mmi_eq_set_mute_req_struct *setMuteReq;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- Message.oslMsgId = MSG_ID_MMI_EQ_SET_MUTE_REQ;
- setMuteReq = OslConstructDataPtr(sizeof(mmi_eq_set_mute_req_struct));
- setMuteReq->audio_device = device;
- setMuteReq->mute_onoff = onoff;
- Message.oslDataPtr = (oslParaType*) setMuteReq;
- Message.oslPeerBuffPtr = NULL;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = MOD_L4C;
- OslMsgSendExtQueue(&Message);
- }
- /*****************************************************************************
- * FUNCTION
- * GpioSendMsg
- * DESCRIPTION
- * Send message to other modules
- *
- * PARAMETERS: mmiapi_device_play_req_struct *
- * src_mod_id [IN]
- * msg_id [IN]
- * local_param_ptr [IN]
- * peer_buf_ptr [IN]
- *****************************************************************************/
- void GpioSendMsg(U16 src_mod_id, U16 msg_id, void *local_param_ptr, void *peer_buf_ptr)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- #ifdef MMI_ON_HARDWARE_P
- MYQUEUE Message;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- Message.oslMsgId = (oslMsgType) msg_id; /* Type casting, to make compiler happer */
- Message.oslDataPtr = (oslParaType*) local_param_ptr;
- Message.oslPeerBuffPtr = peer_buf_ptr;
- Message.oslSrcId = MOD_MMI;
- Message.oslDestId = (oslModuleType) src_mod_id; /* Type casting, to make compiler happer */
- OslMsgSendExtQueue(&Message);
- #endif /* MMI_ON_HARDWARE_P */
- }
- /*****************************************************************************
- * FUNCTION
- * KeyPadLCDBackLightStop
- * DESCRIPTION
- * KeyPadLCDBackLightStop
- *
- * PARAMETERS: void
- * void
- * RETURNS:
- * void
- *****************************************************************************/
- void KeyPadLCDBackLightStop(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- StopTimer(TIMER_KEYPAD_BACKLIGHT);
- LCDBackLightOff();
- KeyPadBackLightOff();
- }
- /*****************************************************************************
- * FUNCTION
- * LCMSleepGotoIdleScreen
- * DESCRIPTION
- * KeyPadLCDBackLightStop
- *
- * PARAMETERS: void
- * void
- *****************************************************************************/
- #if defined(__MMI_LCMSLEEP_BACK2IDLE__)
- void LCMSleepGotoIdleScreen(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (isEarphonePlugged == 1 && backlight_check_call_present())
- {
- return;
- }
- #if defined(__MMI_FACTORY_MODE__) || defined(__MMI_ENGINEER_MODE__)
- if (gCurrentMode == FACTORY_MODE || gCurrentMode == ENGINEERING_MODE)
- {
- return;
- }
- #endif /* defined(__MMI_FACTORY_MODE__) || defined(__MMI_ENGINEER_MODE__) */
- PRINT_INFORMATION(("LCMSleepGotoIdleScreen():END Key Press, FP: %x", GetKeyHandler(KEY_END, KEY_EVENT_DOWN)));
- ExecuteCurrKeyHandler(KEY_END, KEY_EVENT_DOWN);
- }
- #endif /* defined(__MMI_LCMSLEEP_BACK2IDLE__) */
- /*****************************************************************************
- * FUNCTION
- * mmi_gpio_is_lcd_sleep
- * DESCRIPTION
- * To tell applications that lcd is sleeping or not
- * PARAMETERS
- * void
- * RETURNS
- * void
- *****************************************************************************/
- BOOL mmi_gpio_is_lcd_sleep(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return gIsInSleepMode;
- }