GeneralDeviceInterface.c
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:132k
源码类别:

MTK

开发平台:

C/C++

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  * GeneralDeviceInterface.c
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   MAUI
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *   This file is intends for Utility functions for GPIO
  48.  *
  49.  * Author:
  50.  * -------
  51.  * -------
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * removed!
  58.  *
  59.  * removed!
  60.  * removed!
  61.  * removed!
  62.  *
  63.  * removed!
  64.  * removed!
  65.  * removed!
  66.  *
  67.  * removed!
  68.  * removed!
  69.  * removed!
  70.  *
  71.  * removed!
  72.  * removed!
  73.  * removed!
  74.  *
  75.  * removed!
  76.  * removed!
  77.  * removed!
  78.  *
  79.  * removed!
  80.  * removed!
  81.  * removed!
  82.  *
  83.  * removed!
  84.  * removed!
  85.  * removed!
  86.  *
  87.  * removed!
  88.  * removed!
  89.  * removed!
  90.  *
  91.  * removed!
  92.  * removed!
  93.  * removed!
  94.  *
  95.  * removed!
  96.  * removed!
  97.  * removed!
  98.  *
  99.  * removed!
  100.  * removed!
  101.  * removed!
  102.  *
  103.  * removed!
  104.  * removed!
  105.  * removed!
  106.  *
  107.  * removed!
  108.  * removed!
  109.  * removed!
  110.  *
  111.  * removed!
  112.  * removed!
  113.  * removed!
  114.  *
  115.  * removed!
  116.  * removed!
  117.  * removed!
  118.  *
  119.  * removed!
  120.  * removed!
  121.  * removed!
  122.  *
  123.  * removed!
  124.  * removed!
  125.  * removed!
  126.  *
  127.  * removed!
  128.  * removed!
  129.  * removed!
  130.  *
  131.  * removed!
  132.  * removed!
  133.  * removed!
  134.  *
  135.  * removed!
  136.  * removed!
  137.  * removed!
  138.  *
  139.  * removed!
  140.  * removed!
  141.  * removed!
  142.  *
  143.  * removed!
  144.  * removed!
  145.  * removed!
  146.  *
  147.  * removed!
  148.  * removed!
  149.  * removed!
  150.  *
  151.  * removed!
  152.  * removed!
  153.  * removed!
  154.  *
  155.  * removed!
  156.  * removed!
  157.  * removed!
  158.  *
  159.  * removed!
  160.  * removed!
  161.  * removed!
  162.  *
  163.  * removed!
  164.  * removed!
  165.  * removed!
  166.  *
  167.  * removed!
  168.  * removed!
  169.  * removed!
  170.  *
  171.  * removed!
  172.  * removed!
  173.  * removed!
  174.  *
  175.  * removed!
  176.  * removed!
  177.  * removed!
  178.  *
  179.  * removed!
  180.  * removed!
  181.  * removed!
  182.  *
  183.  * removed!
  184.  * removed!
  185.  * removed!
  186.  *
  187.  * removed!
  188.  * removed!
  189.  * removed!
  190.  *
  191.  * removed!
  192.  * removed!
  193.  * removed!
  194.  *
  195.  * removed!
  196.  * removed!
  197.  * removed!
  198.  *
  199.  * removed!
  200.  * removed!
  201.  * removed!
  202.  *
  203.  * removed!
  204.  * removed!
  205.  * removed!
  206.  *
  207.  * removed!
  208.  * removed!
  209.  * removed!
  210.  *
  211.  * removed!
  212.  * removed!
  213.  * removed!
  214.  *
  215.  * removed!
  216.  * removed!
  217.  * removed!
  218.  *
  219.  * removed!
  220.  * removed!
  221.  * removed!
  222.  *
  223.  * removed!
  224.  * removed!
  225.  * removed!
  226.  *
  227.  * removed!
  228.  * removed!
  229.  * removed!
  230.  *
  231.  * removed!
  232.  * removed!
  233.  * removed!
  234.  *
  235.  * removed!
  236.  * removed!
  237.  * removed!
  238.  *
  239.  * removed!
  240.  * removed!
  241.  * removed!
  242.  *
  243.  * removed!
  244.  * removed!
  245.  * removed!
  246.  *
  247.  * removed!
  248.  * removed!
  249.  * removed!
  250.  *
  251.  * removed!
  252.  * removed!
  253.  * removed!
  254.  *
  255.  * removed!
  256.  * removed!
  257.  * removed!
  258.  *
  259.  * removed!
  260.  * removed!
  261.  * removed!
  262.  *
  263.  * removed!
  264.  * removed!
  265.  * removed!
  266.  *
  267.  * removed!
  268.  * removed!
  269.  * removed!
  270.  *
  271.  * removed!
  272.  * removed!
  273.  * removed!
  274.  *
  275.  * removed!
  276.  * removed!
  277.  * removed!
  278.  *
  279.  * removed!
  280.  * removed!
  281.  * removed!
  282.  *
  283.  * removed!
  284.  * removed!
  285.  * removed!
  286.  *
  287.  * removed!
  288.  * removed!
  289.  * removed!
  290.  *
  291.  * removed!
  292.  * removed!
  293.  * removed!
  294.  *
  295.  * removed!
  296.  * removed!
  297.  * removed!
  298.  *
  299.  * removed!
  300.  * removed!
  301.  * removed!
  302.  *
  303.  * removed!
  304.  * removed!
  305.  * removed!
  306.  *
  307.  * removed!
  308.  * removed!
  309.  * removed!
  310.  *
  311.  * removed!
  312.  * removed!
  313.  * removed!
  314.  *
  315.  * removed!
  316.  * removed!
  317.  * removed!
  318.  *
  319.  * removed!
  320.  * removed!
  321.  * removed!
  322.  *
  323.  * removed!
  324.  * removed!
  325.  * removed!
  326.  *
  327.  * removed!
  328.  * removed!
  329.  * removed!
  330.  *
  331.  * removed!
  332.  * removed!
  333.  * removed!
  334.  *
  335.  * removed!
  336.  * removed!
  337.  * removed!
  338.  *
  339.  * removed!
  340.  * removed!
  341.  * removed!
  342.  *
  343.  * removed!
  344.  * removed!
  345.  * removed!
  346.  *
  347.  * removed!
  348.  * removed!
  349.  * removed!
  350.  *
  351.  * removed!
  352.  * removed!
  353.  * removed!
  354.  *
  355.  * removed!
  356.  * removed!
  357.  * removed!
  358.  *
  359.  * removed!
  360.  * removed!
  361.  * removed!
  362.  *
  363.  * removed!
  364.  * removed!
  365.  * removed!
  366.  *
  367.  * removed!
  368.  * removed!
  369.  * removed!
  370.  *
  371.  * removed!
  372.  * removed!
  373.  * removed!
  374.  *
  375.  * removed!
  376.  * removed!
  377.  * removed!
  378.  *
  379.  * removed!
  380.  * removed!
  381.  * removed!
  382.  *
  383.  * removed!
  384.  * removed!
  385.  * removed!
  386.  *
  387.  * removed!
  388.  * removed!
  389.  * removed!
  390.  *
  391.  * removed!
  392.  * removed!
  393.  * removed!
  394.  *
  395.  * removed!
  396.  * removed!
  397.  * removed!
  398.  *
  399.  * removed!
  400.  * removed!
  401.  * removed!
  402.  *
  403.  * removed!
  404.  * removed!
  405.  * removed!
  406.  *
  407.  * removed!
  408.  * removed!
  409.  * removed!
  410.  *
  411.  * removed!
  412.  * removed!
  413.  * removed!
  414.  *
  415.  * removed!
  416.  * removed!
  417.  * removed!
  418.  *
  419.  * removed!
  420.  * removed!
  421.  * removed!
  422.  *
  423.  * removed!
  424.  * removed!
  425.  * removed!
  426.  *
  427.  * removed!
  428.  * removed!
  429.  * removed!
  430.  *
  431.  * removed!
  432.  * removed!
  433.  * removed!
  434.  *
  435.  * removed!
  436.  * removed!
  437.  * removed!
  438.  *
  439.  * removed!
  440.  * removed!
  441.  * removed!
  442.  *
  443.  * removed!
  444.  * removed!
  445.  * removed!
  446.  *
  447.  * removed!
  448.  * removed!
  449.  * removed!
  450.  *
  451.  * removed!
  452.  * removed!
  453.  * removed!
  454.  *
  455.  * removed!
  456.  * removed!
  457.  * removed!
  458.  *
  459.  * removed!
  460.  * removed!
  461.  * removed!
  462.  *
  463.  * removed!
  464.  * removed!
  465.  * removed!
  466.  *
  467.  * removed!
  468.  * removed!
  469.  * removed!
  470.  *
  471.  *------------------------------------------------------------------------------
  472.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  473.  *============================================================================
  474.  ****************************************************************************/
  475. /***************************************************************************** 
  476. * Include
  477. *****************************************************************************/
  478. #include "MMI_features.h"
  479. /*  Include: MMI header file */
  480. #include "StdC.h"
  481. #include "L4Dr1.h"
  482. #include "gpioInc.h"
  483. #include "PhnsetPROT.h"
  484. #include "KeyBrd.h"
  485. #include "pixteldatatypes.h"
  486. #include "QueueGprot.h"
  487. #include "IdleAppDef.h"
  488. #include "TimerEvents.h"
  489. #include "EventsGprot.h"
  490. #include "wgui_categories.h"
  491. #include "wgui_status_icons.h"
  492. #include "SettingProfile.h"
  493. #include "ProfileGprots.h"
  494. #include "IdleAppProt.h"
  495. #include "SimDetectionGexdcl.h"
  496. #include "SimDetectionGprot.h"
  497. #include "GlobalDefs.h"
  498. #include "CallManagementIdDef.h"
  499. #include "CallManagementGprot.h"
  500. #ifdef __MMI_VOIP__
  501. #include "VoIPGProt.h"
  502. #endif
  503. #include "CommonScreens.h"
  504. #include "SubLCDHistoryGprot.h"
  505. #include "NVRAMProt.h"
  506. #include "NVRAMEnum.h"
  507. #include "NVRAMType.h"
  508. #include "DebugInitDef.h"
  509. #include "mmiapi_enum.h"
  510. #include "mmiapi_struct.h"
  511. #include "Mdi_datatype.h"
  512. #include "Mdi_audio.h"
  513. #include "mdi_video.h"
  514. #include "lcd_if.h"
  515. #include "gdi_include.h"
  516. #include "custom_equipment.h"
  517. #include "AlarmFrameworkProt.h"
  518. #include "PhoneBookTypes.h"
  519. #include "WPSSProtos.h"
  520. #include "Event_shed.h"
  521. #if defined(__MMI_BT_HP_SUPPORT__)
  522. #include "BTMMIHPGprots.h"
  523. #endif 
  524. #ifdef __CTM_SUPPORT__
  525. #include "TextPhoneProt.h"
  526. #endif 
  527. #if defined(__MMI_BT_SUPPORT__)
  528. #include "BTMMIScrGprots.h"
  529. #endif 
  530. #ifdef __MMI_SLIDE__
  531. #include "QuickAccessMenuItemProt.h"
  532. #include "StatusIconRes.h"
  533. #endif /* __MMI_SLIDE__ */ 
  534. #if defined(__MMI_VIDEO_PLAYER__) && defined(__MMI_TVOUT__)
  535. #include "VdoPlyGprot.h"
  536. #endif 
  537. #ifdef __MMI_TVOUT__
  538. #include "PhoneSetupGprots.h"
  539. #endif 
  540. #if defined(__MMI_SUBLCD__) && defined(__MMI_SUBLCD_COLOR__)
  541. #include "mmi_features_camera.h"
  542. #endif
  543. #ifdef __MMI_SUBLCD_CAMERA__
  544. #include "mdi_camera.h"
  545. #include "cameraapp.h"
  546. #endif
  547. #ifdef __PHOEDT_FEATURE_SLIDSHOW__
  548. #include "PhotoEditorGProt.h"   /* ignore slide shell effect */
  549. #endif /* __PHOEDT_FEATURE_SLIDSHOW__ */
  550. #include "SettingDefs.h"
  551. #include "MainMenuDef.h"
  552. #ifdef MMI_ON_HARDWARE_P
  553. #include "l4dr.h"
  554. #include "lcd_sw.h"
  555. #include "lcd_sw_inc.h"
  556. #endif /* MMI_ON_HARDWARE_P */ 
  557. #if defined(__WIFI_SUPPORT__) && defined (__MTK_TARGET__)
  558. #include "wndrv_api.h"
  559. #endif
  560. #ifdef __MMI_VIDEO_PLAYER__
  561. #include "VdoPlyGprot.h"
  562. #endif
  563. #ifdef __MMI_VIDEO_RECORDER__
  564. #include "VdoRecGprot.h"
  565. #endif
  566. #ifdef __MMI_GAME__
  567. #include "GameFramework.h" /* temp solution for checking if current screen is game screen */
  568. #endif /* __MMI_GAME__ */
  569. //KP Jerry add on 2007-4-17 start
  570. #ifdef __LINE_CONTROL_EARPHONE_SUPPORT__
  571. #include "AudioPlayerDef.h"
  572. extern BOOL g_mmi_audply_init_done; 
  573. extern mmi_audply_init_before_entry_main();
  574. extern mmi_audply_enable_key_button();
  575. #endif
  576. //KP Jerry add on 2007-4-17 end
  577. /***************************************************************************** 
  578. * Local variable
  579. *****************************************************************************/
  580. static U8 isTimerSuspend;   /* Is UI timer (aligned) suspended. 0 == non-suspend, 1 == suspend */
  581. static U8 gbacklight_mode = 1;
  582. static U8 gpioOutOfCtrl;
  583. static U8 sublcd_backlight; /* 0 = dark. 1 = light */
  584. static U8 keypad_backlight; /* 0 = dark. 1 = light */
  585. /* 0 = no timer, 1 = timer for half mode backlight , 2 = timer for sleep mode, 3 = in sleep mode */
  586. static U8 gBackLightTimerStatus = 1;
  587. static U8 IsCallerGroupPatternPlaying;
  588. static U8 aud_mode_to_resume;
  589. /***************************************************************************** 
  590. * Local function
  591. *****************************************************************************/
  592. static void BacklightTimerHdlr(void);
  593. #if (defined(__MMI_CLAMCLOSE_BACK2IDLE__) || defined (__MMI_SUBLCD_SHOW_ANALOG_CLOCK__) )
  594. static void ClamCloseGotoIdleScreen(void);
  595. #endif 
  596. #if defined(__MMI_CLAMSHELL__) || defined(__MMI_SLIDE__)
  597. static BOOL IsClamToneAllow(void);
  598. #endif
  599. static void EarphoneConnectHdlr(BOOL is_in);
  600. static void EarphoneDisplayPopup(BOOL is_plugin);
  601. static void GpioEarphonePlugIn(void);
  602. static void GpioEarphonePlugOut(void);
  603. static void GpioTurnOffKeypadLight(void);
  604. static void GpioLCDSleepIn(void);
  605. static void GpioLCDSleepOut(void);
  606. static void GpioTurnOnKeypadLight(void);
  607. /***************************************************************************** 
  608. * Global function
  609. *****************************************************************************/
  610. void SetBacklightMode(void *info);
  611. void GpioSendMsg(U16 src_mod_id, U16 msg_id, void *local_param_ptr, void *peer_buf_ptr);
  612. #if defined(__MMI_LCMSLEEP_BACK2IDLE__)
  613. void LCMSleepGotoIdleScreen(void);
  614. #endif 
  615. /***************************************************************************** 
  616. * Global variable
  617. *****************************************************************************/
  618. U8 lcd_backlight = 1;   /* 0 = dark, 1 = half light, 2 = full light  */
  619. #if defined(__MMI_CLAMSHELL__) && !defined(__AMNT__)     //Old:#if defined(__MMI_CLAMSHELL__) && !defined(__MMI_SLIDE__) && !defined(__AMNT__)     //KP Jerry disable "!defined(__MMI_SLIDE__)" for keep sync with drv on 2007-4-25
  620. U8 gMMIClamState = 0;   /* Sync with Drv state */
  621. #else 
  622. U8 gMMIClamState = 1;
  623. #endif 
  624. U8 isEarphonePlugged = 0;
  625. #if !defined(__MMI_GPIO_DISABLE_SLEEP_MODE__)
  626. BOOL gIsInSleepMode = KAL_FALSE;
  627. #endif 
  628. #ifdef __MMI_ENGINEER_MODE__
  629. U32 gClamOpenCnt = 0;
  630. U32 gClamCloseCnt = 0;
  631. #endif /* __MMI_ENGINEER_MODE__ */ 
  632. U32 gDeviceState = 0x0; /* Keep device state for concurrency accessing */
  633. /***************************************************************************** 
  634. * External variable
  635. *****************************************************************************/
  636. extern event_scheduler *event_scheduler1_ptr;
  637. extern pBOOL processingNow;
  638. extern U8 mmi_msg_need_mem_full_ind(void);
  639. #if ( defined(__MMI_ENGINEER_MODE__) || defined(__MMI_FACTORY_MODE__))
  640. extern U8 gCurrentMode;
  641. #endif 
  642. #ifdef MMI_ON_HARDWARE_P
  643. extern PROFILE gcurrentprofile;
  644. #endif 
  645. /***************************************************************************** 
  646. * External functitons
  647. *****************************************************************************/
  648. extern void UI_BLT_double_buffer(S32 x1, S32 y1, S32 x2, S32 y2);
  649. #ifdef MMI_ON_WIN32
  650. extern void simulate_lcd_bklight_turn_off(void);
  651. extern void simulate_sublcd_bklight_turn_off(void);
  652. extern void simulate_lcd_bklight_turn_on(void);
  653. extern void simulate_sublcd_bklight_turn_on(void);
  654. #endif /* MMI_ON_WIN32 */ 
  655. extern void SendSetHWLevelInfoReq(void);
  656. #ifdef __MMI_AUDIO_PLAYER__
  657. extern BOOL mmi_audply_is_play_activated(void);
  658. #ifdef __MMI_AUDIO_SPECTRUM_DISPLAY__
  659. void mmi_audply_turn_on_spectrum(void);
  660. void mmi_audply_turn_off_spectrum(void);
  661. #endif /* __MMI_AUDIO_SPECTRUM_DISPLAY__ */ 
  662. #endif /* __MMI_AUDIO_PLAYER__ */ 
  663. #ifdef __MMI_FM_RADIO__
  664. extern BOOL mmi_fmrdo_is_power_on(void);
  665. #endif 
  666. #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  667. extern void ShowSubLCDAnalogClockScreen(void);
  668. #endif 
  669. /*****************************************************************************
  670.  * FUNCTION
  671.  *  backlight_check_call_present
  672.  * DESCRIPTION
  673.  *  check if there is a call
  674.  * PARAMETERS
  675.  *  void
  676.  * RETURNS
  677.  *  void
  678.  *****************************************************************************/
  679. static pBOOL backlight_check_call_present(void)
  680. {
  681.     /*----------------------------------------------------------------*/
  682.     /* Local Variables                                                */
  683.     /*----------------------------------------------------------------*/
  684.     /*----------------------------------------------------------------*/
  685.     /* Code Body                                                      */
  686.     /*----------------------------------------------------------------*/
  687.     /* We should not use GetTotalCallCount() because it does not handle automatic call redial */
  688.     if (isInCall() && !IsWapCallPresent())
  689.     {
  690.         return MMI_TRUE;
  691.     }
  692.     else
  693.     {
  694.         return MMI_FALSE;
  695.     }
  696. }
  697. /*****************************************************************************
  698.  * FUNCTION
  699.  *  GpioDetectInd
  700.  * DESCRIPTION
  701.  *  Event handler of gpio detect indication
  702.  *  
  703.  *  PARAMETERS: mmi_eq_gpio_detect_ind_struct *
  704.  *  info        [IN]        
  705.  *****************************************************************************/
  706. void GpioDetectInd(void *info)
  707. {
  708.     /*----------------------------------------------------------------*/
  709.     /* Local Variables                                                */
  710.     /*----------------------------------------------------------------*/
  711.     mmi_eq_gpio_detect_ind_struct *gpioDetectInd;
  712.     /*----------------------------------------------------------------*/
  713.     /* Code Body                                                      */
  714.     /*----------------------------------------------------------------*/
  715.     gpioDetectInd = (mmi_eq_gpio_detect_ind_struct*) info;
  716.     if (mmi_bootup_is_before_power_on() == MMI_TRUE)
  717.     {
  718.         switch (gpioDetectInd->gpio_device)
  719.         {
  720.             case EXT_DEV_EARPHONE:
  721.                 if (gpioDetectInd->on_off == 1)
  722.                 {
  723.                     isEarphonePlugged = 1;
  724. //KP Jerry add on 2007-4-17 start
  725. #ifdef __LINE_CONTROL_EARPHONE_SUPPORT__
  726. uem_send_msg_to_aux(MSG_ID_AUX_LC_EARPHONE_PLUGIN);
  727. #endif
  728. //KP Jerry add on 2007-4-17 end
  729.                     {
  730.                     #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  731.                         IdleSetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  732.                     #endif 
  733.                     }
  734.                 }
  735.                 else
  736.                 {
  737. //KP Jerry add on 2007-4-17 start
  738. #ifdef __LINE_CONTROL_EARPHONE_SUPPORT__
  739. uem_send_msg_to_aux(MSG_ID_AUX_CALL_DISCONNECT_REQ_IND);
  740. #endif
  741. //KP Jerry add on 2007-4-17 end
  742.                     isEarphonePlugged = 0;
  743.                 }
  744.                 mdi_audio_set_audio_mode(isEarphonePlugged);
  745.                 break;
  746.             #ifdef __MMI_CLAMSHELL__
  747.             case EXT_DEV_CLAM_OPEN:
  748.                 gMMIClamState = 1;
  749.                 break;
  750.             case EXT_DEV_CLAM_CLOSE:
  751.                 gMMIClamState = 0;
  752.                 break;
  753.             #endif /* __MMI_CLAMSHELL__ */ 
  754.             default:
  755.                 break;
  756.         }
  757.         PRINT_INFORMATION_2((MMI_TRACE_G7_MISC, "[GPIO] GPIO indication before power on"));
  758.         return;
  759.     }
  760.     switch (gpioDetectInd->gpio_device)
  761.     {
  762.         case EXT_DEV_EARPHONE:  /* Earphone plug in/out */
  763.         {
  764.             if (gpioDetectInd->on_off == 1)
  765.             {
  766.                 EarphoneConnectHdlr(MMI_TRUE);
  767.             }
  768.             else
  769.             {
  770.                 EarphoneConnectHdlr(MMI_FALSE);
  771.             }
  772.             break;
  773.         }
  774.         case EXT_DEV_KEY_1: /* SEND(END) key press */
  775.         {
  776.             if (mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  777.             {
  778.                 if (isInCall())
  779.                 {
  780.                     PRINT_INFORMATION(("n[GpioDetectInd] In Call, Ready to Process Headset Keyn"));
  781.                 #ifdef __MMI_VOIP__
  782.                     if (GetTotalCallCount() != 0)
  783.                     {
  784.                         ProcessHeadsetKeyPress();
  785.                         PRINT_INFORMATION(("n[GpioDetectInd] Process Headset Key for GSMn"));
  786.                     }
  787.                     else if (mmi_voip_app_total_call() != 0)
  788.                     {
  789.                         mmi_voip_entry_headsetkey();
  790.                         PRINT_INFORMATION(("n[GpioDetectInd] Process Headset Key for VoIPn"));
  791.                     }
  792.                 #else
  793.                     ProcessHeadsetKeyPress();
  794.                 #endif
  795.                 }
  796.             }
  797.             break;
  798.         }
  799. //KP Jerry add on 2007-4-17 start
  800. #ifdef __LINE_CONTROL_EARPHONE_SUPPORT__
  801. case EXT_DEV_KEY_PLAY_AND_STOP: 
  802. {
  803. if(GetCurrentState()!=CM_IDLE_STATE)
  804. ProcessHeadsetKeyPress();
  805. else
  806. {
  807. if(!g_mmi_audply_init_done)
  808. mmi_audply_init_before_entry_main();
  809. mmi_audply_enable_key_button();
  810. mmi_audply_press_play_button_down();
  811. mmi_audply_press_play_button_up();
  812. }
  813.                      //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_PLAY_AND_STOP111");
  814. break;
  815. }
  816. case EXT_DEV_KEY_PREV: 
  817. {
  818. mmi_audply_press_prev_button_down();
  819. mmi_audply_press_prev_button_up();
  820. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_PREV1111");
  821. break;
  822. }
  823. case EXT_DEV_KEY_NEXT: 
  824. {
  825. mmi_audply_press_next_button_down();
  826. mmi_audply_press_next_button_up();
  827. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_NEXT1111");
  828. break;
  829. }
  830. case EXT_DEV_KEY_VOLUME_DOWN: 
  831. {
  832. mmi_audply_press_dec_volume();
  833. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_VOLUME_DOWN1111");
  834. break;
  835. }
  836. case EXT_DEV_KEY_VOLUME_UP: 
  837. {
  838. mmi_audply_press_inc_volume();
  839. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_VOLUME_UP1111");
  840. break;
  841. }
  842. case EXT_DEV_KEY_PREV_LONGPRESS: 
  843. if(GetActiveScreenId() == SCR_ID_AUDPLY_MAIN)
  844. {
  845. mmi_audply_press_prev_button_down();
  846. mmi_audply_press_prev_button_longpress();
  847. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_PREV_LONGPRESS1111");
  848. }
  849. break;
  850. }
  851. case EXT_DEV_KEY_NEXT_LONGPRESS: 
  852. {
  853. if(GetActiveScreenId() == SCR_ID_AUDPLY_MAIN)
  854. {
  855. mmi_audply_press_next_button_down();
  856. mmi_audply_press_next_button_longpress();
  857. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_NEXT_LONGPRESS1111");
  858. }
  859. break;
  860. }
  861. case EXT_DEV_KEY_PREV_LONGPRESS_STOP: 
  862. {
  863. mmi_audply_press_prev_button_up();
  864. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_PREV_LONGPRESS_STOP1111");
  865. break;
  866. }
  867. case EXT_DEV_KEY_NEXT_LONGPRESS_STOP: 
  868. {
  869. mmi_audply_press_next_button_up();
  870. //kal_prompt_trace(MOD_AUX,"EXT_DEV_KEY_NEXT_LONGPRESS_STOP1111");
  871. break;
  872. }
  873. #endif
  874. //KP Jerry add on 2007-4-17 end
  875.     #ifdef __MMI_CLAMSHELL__        /* { */
  876.         case EXT_DEV_CLAM_OPEN: /* Clam open */
  877.         {
  878.             gMMIClamState = 1;
  879.         #if defined(__MMI_SUBLCD_SHOW_ANALOG_CLOCK__) 
  880.             if (g_pwr_context.PowerOnMode == POWER_ON_KEYPAD || g_pwr_context.PowerOnMode == POWER_ON_EXCEPTION)
  881.                 ForceSubLCDScreen(ShowIdleAppSubLcd);
  882.         #endif 
  883.         #ifdef __MMI_SUBLCD_CAMERA__
  884.             if(mmi_sublcd_camera_delete_screen_if_present())
  885.                 GoBackHistory();
  886.             else if (mmi_idle_is_on_idle_screen()==TRUE)
  887.                 EntryIdleScreen();
  888.         #endif
  889.             if (!AlmIsRTCPwron())
  890.             {
  891.                 TurnOnBacklight(1);
  892.             }
  893.             NotifyCMClampOpen();
  894.             if (mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  895.             {
  896.                 if (IsClamToneAllow())
  897.                 {
  898.                     playRequestedTone(COVER_OPEN_TONE);
  899.                  //KP Jerry add on 2007-4-26 start
  900.                  #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
  901.                     gui_start_timer(3000,StopExtCoverOpenTone);
  902.                  #endif
  903.                  //KP Jerry add on 2007-4-26 end
  904.                 }
  905.             #ifdef __MMI_SLIDE__/* keypad lock for slide phone */   /* { */
  906.                 if (g_keylock_context.gKeyPadLockFlag)
  907.                 {
  908.                     if (isInCall())
  909.                     {
  910.                         /* Not display unlock message if there is an incoming call when the slide is closed */
  911.                         StopTimer(KEYPADUNLOCKEDMESSAGE_TIMER);
  912.                         g_keylock_context.gKeyPadLockFlag = 0;
  913.                     #ifndef __MMI_KEYPADLOCK_WITH_KEYTONE__
  914.                         mmi_frm_kbd_set_tone_state(MMI_KEY_TONE_ENABLED);
  915.                     #endif 
  916.                     #ifdef __MMI_TOUCH_SCREEN__
  917.                         ChangeStatusIconImage(STATUS_ICON_KEYPAD_LOCK, IMG_SI_KEYPAD_UNLOCK);
  918.                     #else 
  919.                         IdleResetStatusIcon(STATUS_ICON_KEYPAD_LOCK);
  920.                     #endif 
  921.                     }
  922.                     else
  923.                     {
  924.                         HandlePoundKeyForUnlock();
  925.                     }
  926.                 #ifdef __MMI_TOUCH_SCREEN__     /* unblock pen for touch screen phone */
  927.                     mmi_pen_unblock();
  928.                 #endif 
  929.                 }
  930.             #endif /* __MMI_SLIDE__ */ /* } */
  931.             #ifdef __MMI_CLAMOPEN_STOP_SCRSAVER__
  932.                 if (GetActiveScreenId() == IDLE_SCREEN_SCREENSAVER_ID)
  933.                 {
  934.                     GoBackHistory();    /* Screensaver is running */
  935.                 }
  936.                 else
  937.             #endif /* __MMI_CLAMOPEN_STOP_SCRSAVER__ */ 
  938.                     mmi_idle_restart_screensaver_timer();   /* diamond, 2006/01/16 Restart screensaver timer when clam is open */
  939.             }
  940.         #ifdef __MMI_ENGINEER_MODE__
  941.             gClamOpenCnt++;
  942.         #endif 
  943.             break;
  944.         }
  945.         case EXT_DEV_CLAM_CLOSE:    /* Clam close */
  946.         {
  947.             gMMIClamState = 0;
  948.             if (mmi_bootup_is_in_power_on_period() == MMI_FALSE)
  949.             {
  950.             #ifndef __MMI_SLIDE__
  951.                 CloseBacklight();
  952.             #else /* __MMI_SLIDE__ */ 
  953.                 if (AlmIsRTCPwron())
  954.                 {
  955.                     TurnOnBacklight(0);
  956.                 }
  957.                 else
  958.                 {
  959.                     TurnOnBacklight(1);
  960.                 }
  961.             #endif /* __MMI_SLIDE__ */ 
  962.                 if (IsClamToneAllow())
  963.                 {
  964.                     playRequestedTone(COVER_CLOSE_TONE);
  965.                  //KP Jerry add on 2007-4-26 start
  966.                  #ifdef __MMI_TONE_LIST_STYLE_CHANGED__
  967.                     gui_start_timer(3000,StopExtCoverCloseTone);
  968.                  #endif
  969.                  //KP Jerry add on 2007-4-26 end
  970.                 }
  971.             #if defined(__MMI_SUBLCD_CAMERA__)
  972.                 if (mmi_bootup_is_sim_valid() && !g_keylock_context.gKeyPadLockFlag)
  973.                 SetKeyHandler(mmi_sublcd_camera_entry_option_screen, CAMERA_SHORTCUT_KEY, KEY_EVENT_DOWN);        
  974.             #endif
  975.             }
  976.         #ifndef __MMI_SLIDE__
  977.             NotifyCMClampClose();
  978.         #endif 
  979.         #if (defined __MMI_CLAMCLOSE_BACK2IDLE__ || defined __MMI_SUBLCD_SHOW_ANALOG_CLOCK__)
  980.             ClamCloseGotoIdleScreen();
  981.         #endif 
  982.             //KP Jerry add on 2007-4-21 start
  983.             #ifdef __MMI_SLIDE__
  984.             if(mmi_bootup_is_searching_or_idle_reached() && (!g_keylock_context.gKeyPadLockFlag) && (!backlight_check_call_present()))
  985.             {
  986.                     if (mmi_bootup_is_sim_valid() == MMI_TRUE)
  987.                     {
  988.                         IdleSetKeyPadLockFlag();
  989.                     }
  990.                     else
  991.                     {
  992.                         InsertSimSetKeyPadLockFlag();
  993.                     }
  994.             }
  995.        #endif  
  996.             //KP Jerry add on 2007-4-21 end
  997.         #ifdef __MMI_SUBLCD_SHOW_ANALOG_CLOCK__
  998.             ForceSubLCDScreen(ShowSubLCDAnalogClockScreen);
  999.         #endif 
  1000.         #ifdef __MMI_ENGINEER_MODE__
  1001.             gClamCloseCnt++;
  1002.         #endif 
  1003.             break;
  1004.         }
  1005.     #endif /* __MMI_CLAMSHELL__ */ /* } */
  1006.         default:
  1007.             break;
  1008.     }
  1009.     /* Popup screen display permisstion flag */
  1010.     /* Shall reset this flag in the end of msg handler func */
  1011.     SetInterruptPopupDisplay(POPUP_ALL_ON);
  1012. }
  1013. /*
  1014.  *Earphone_Handling_Functions
  1015.  */
  1016. /*****************************************************************************
  1017.  * FUNCTION
  1018.  *  mmi_gpio_is_earphone_plug_in
  1019.  * DESCRIPTION
  1020.  *  tell other applications if the earphone exist
  1021.  * PARAMETERS
  1022.  *  void
  1023.  * RETURNS
  1024.  *  yse or no
  1025.  *****************************************************************************/
  1026. BOOL mmi_gpio_is_earphone_plug_in(void)
  1027. {
  1028.     /*----------------------------------------------------------------*/
  1029.     /* Local Variables                                                */
  1030.     /*----------------------------------------------------------------*/
  1031.     /*----------------------------------------------------------------*/
  1032.     /* Code Body                                                      */
  1033.     /*----------------------------------------------------------------*/
  1034.     return (isEarphonePlugged == 1);
  1035. }
  1036. /*****************************************************************************
  1037.  * FUNCTION
  1038.  *  EarphoneConnectHdlr
  1039.  * DESCRIPTION
  1040.  *  General handler for earphone plug in/out
  1041.  *  
  1042.  *  PARAMETERS: is_in
  1043.  *  is_in       [IN]        
  1044.  *****************************************************************************/
  1045. static void EarphoneConnectHdlr(BOOL is_in)
  1046. {
  1047.     /*----------------------------------------------------------------*/
  1048.     /* Local Variables                                                */
  1049.     /*----------------------------------------------------------------*/
  1050.     /*----------------------------------------------------------------*/
  1051.     /* Code Body                                                      */
  1052.     /*----------------------------------------------------------------*/
  1053.     /* Do not switch profile if not normal power on mode */
  1054.     /* 1. Charge power on --> X */
  1055.     /* 2. Alarm power on --> X  */
  1056.     /* 3. RTC power on --> X   */
  1057. #ifdef __MMI_UI_DALMATIAN_STATUSBAR__
  1058.     disable_statusbar_fill_background();
  1059. #endif 
  1060.     if (g_pwr_context.PowerOnMode == POWER_ON_KEYPAD || g_pwr_context.PowerOnMode == POWER_ON_EXCEPTION)
  1061.     {
  1062.         if (is_in)
  1063.         {
  1064.             GpioEarphonePlugIn();
  1065.         }
  1066.         else
  1067.         {
  1068.             GpioEarphonePlugOut();
  1069.         }
  1070.         EarphoneDisplayPopup(is_in);
  1071.     }
  1072.     else
  1073.     {
  1074.         if (is_in)
  1075.         {
  1076.             isEarphonePlugged = 1;  /* diamond, 2005/10/28 Fit the case of alarm power on + GPIO detection + keypad power on */
  1077.             aud_mode_to_resume = mdi_audio_get_audio_mode();
  1078.             mdi_audio_set_audio_mode(AUD_MODE_HEADSET);
  1079.         #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1080.             IdleSetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1081.         #endif 
  1082.         }
  1083.         else
  1084.         {
  1085.             isEarphonePlugged = 0;
  1086.             mdi_audio_set_audio_mode(aud_mode_to_resume);
  1087.         #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_SUPPORT__))
  1088.             IdleResetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1089.         #endif 
  1090.         }
  1091.     }
  1092. #ifdef __MMI_UI_DALMATIAN_STATUSBAR__
  1093.     enable_statusbar_fill_background();
  1094. #endif 
  1095. }
  1096. /*****************************************************************************
  1097.  * FUNCTION
  1098.  *  EarphoneDisplayPopup
  1099.  * DESCRIPTION
  1100.  *  Display earphone plug in/out popup
  1101.  *  
  1102.  *  PARAMETERS: BOOL
  1103.  *  is_plugin       [IN]        
  1104.  *****************************************************************************/
  1105. static void EarphoneDisplayPopup(BOOL is_plugin)
  1106. {
  1107.     /*----------------------------------------------------------------*/
  1108.     /* Local Variables                                                */
  1109.     /*----------------------------------------------------------------*/
  1110.     U16 str_id = 0;
  1111.     U8 pp_flag, tone_id = 0;
  1112.     /*----------------------------------------------------------------*/
  1113.     /* Code Body                                                      */
  1114.     /*----------------------------------------------------------------*/
  1115.     /* Application who wanna stop popup has to intercept related messages and set the flag */
  1116.     pp_flag = GetInterruptPopupDisplay();
  1117.     if ((pp_flag & POPUP_DSPL_ON) == 0)
  1118.     {
  1119.         return;
  1120.     }
  1121.     if (pp_flag & POPUP_TONE_ON)
  1122.     {
  1123.         tone_id = AUX_TONE;
  1124.     }
  1125.     /* Cases not allow to display popup */
  1126.     /* 1. Call manager adjusting history */
  1127.     /* 2. During power on animation */
  1128.     /* 3. Power on mode is neither Keypad nor Exception (Means, Alarm, Charger, Usb) */
  1129.     /* 4. In Engineer mode */
  1130.     /* 5. In Factory mode  */
  1131.     if ((GetTransitionToActiveFlag() == MMI_TRUE)
  1132.         || (mmi_bootup_is_in_power_on_period() == MMI_TRUE)
  1133.         || (g_pwr_context.PowerOnMode != POWER_ON_KEYPAD && g_pwr_context.PowerOnMode != POWER_ON_EXCEPTION))
  1134.     {
  1135.         return;
  1136.     }
  1137. #ifdef __MMI_ENGINEER_MODE__
  1138.     if (gCurrentMode == ENGINEERING_MODE)
  1139.     {
  1140.         return;
  1141.     }
  1142. #endif /* __MMI_ENGINEER_MODE__ */ 
  1143. #ifdef __MMI_FACTORY_MODE__
  1144.     if (gCurrentMode == FACTORY_MODE)
  1145.     {
  1146.         return;
  1147.     }
  1148. #endif /* __MMI_FACTORY_MODE__ */ 
  1149. #ifdef __CTM_SUPPORT__
  1150.     if (mmi_ctm_is_tty_on() == MMI_TRUE)
  1151.     {
  1152.         if (is_plugin == MMI_TRUE)
  1153.         {
  1154.             str_id = STR_CTM_TTY_PLUG_IN;
  1155.         }
  1156.         else
  1157.         {
  1158.             str_id = STR_CTM_TTY_PLUG_OUT;
  1159.         }
  1160.     }
  1161.     else
  1162. #endif /* __CTM_SUPPORT__ */ 
  1163.     {
  1164.         /* Display popup according plug in/out */
  1165.         if (is_plugin == MMI_TRUE)  /* Plug in */
  1166.         {
  1167.             str_id = STR_EARPHONE_POPUP;
  1168.         }
  1169.         else    /* Plug out */
  1170.         {
  1171.             str_id = STR_HEADSET_DEACTIVATE_MESSAGE;
  1172.         }
  1173.     }
  1174.     /* Should turn on backlight first to make LCD sleep out */
  1175.     TurnOnBacklight(1);
  1176.     DisplayPopup((U8*) GetString(str_id), IMG_EARPHONE_POPUP_MAINLCD, 0, UI_POPUP_NOTIFYDURATION_TIME, tone_id);
  1177. #ifdef __MMI_SUBLCD__
  1178.     if (MMI_TRUE == is_plugin)
  1179.     {
  1180.         DisplaySubLcdPopup(IMG_EARPHONE_POPUP_SUBLCD);
  1181.     }
  1182. #endif /* __MMI_SUBLCD__ */ 
  1183. }
  1184. /*****************************************************************************
  1185.  * FUNCTION
  1186.  *  GpioEarphonePlugIn
  1187.  * DESCRIPTION
  1188.  *  General action after earphone plug in
  1189.  *  
  1190.  *  PARAMETERS:
  1191.  *  void
  1192.  *****************************************************************************/
  1193. static void GpioEarphonePlugIn(void)
  1194. {
  1195.     /*----------------------------------------------------------------*/
  1196.     /* Local Variables                                                */
  1197.     /*----------------------------------------------------------------*/
  1198.     /*----------------------------------------------------------------*/
  1199.     /* Code Body                                                      */
  1200.     /*----------------------------------------------------------------*/
  1201.     isEarphonePlugged = 1;
  1202. #ifdef __CTM_SUPPORT__
  1203.     mmi_ctm_switch_tty_status(MMI_TRUE);
  1204.     if (mmi_ctm_is_tty_on())
  1205.     {
  1206.        /* take as TTY, don't switch profile */
  1207.         return;
  1208.     }
  1209. #endif /* __CTM_SUPPORT__ */ 
  1210.     mmi_profiles_earphone_plug_in_callback();
  1211. #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__))
  1212.     IdleSetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1213. #endif 
  1214. //KP Jerry add on 2007-4-17 start
  1215. #ifdef __LINE_CONTROL_EARPHONE_SUPPORT__
  1216. uem_send_msg_to_aux(MSG_ID_AUX_LC_EARPHONE_PLUGIN);
  1217. #endif
  1218. //KP Jerry add on 2007-4-17 end
  1219. }
  1220. /*****************************************************************************
  1221.  * FUNCTION
  1222.  *  GpioEarphonePlugOut
  1223.  * DESCRIPTION
  1224.  *  General action after earphone plug out
  1225.  *  
  1226.  *  PARAMETERS:
  1227.  *  void
  1228.  *****************************************************************************/
  1229. static void GpioEarphonePlugOut(void)
  1230. {
  1231.     /*----------------------------------------------------------------*/
  1232.     /* Local Variables                                                */
  1233.     /*----------------------------------------------------------------*/
  1234.     /*----------------------------------------------------------------*/
  1235.     /* Code Body                                                      */
  1236.     /*----------------------------------------------------------------*/
  1237.     isEarphonePlugged = 0;
  1238. #ifdef __CTM_SUPPORT__
  1239.     mmi_ctm_switch_tty_status(MMI_FALSE);
  1240.     if (mmi_ctm_is_tty_on())
  1241.     {
  1242.         /* take as TTY, don't switch profile */
  1243.         return;
  1244.     }
  1245. #endif /* __CTM_SUPPORT__ */ 
  1246.     mmi_profiles_earphone_plug_out_callback();
  1247. #if (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__))
  1248. #if defined(__MMI_BT_HP_SUPPORT__)
  1249.     if (!mmi_bt_is_hs_connected())
  1250. #elif defined(__MMI_BT_SUPPORT__)
  1251.     if (!mmi_bt_is_hs_connected() && !mmi_bt_is_a2dp_connected())
  1252. #endif 
  1253.     {
  1254.         IdleResetStatusIcon(STATUS_ICON_EARPHONE_INDICATOR);
  1255.     }
  1256. #endif /* (defined (__MMI_STATUS_ICON_EN_EARPHONE__) || defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)) */ 
  1257. //KP Jerry add on 2007-4-17 start
  1258. #ifdef __LINE_CONTROL_EARPHONE_SUPPORT__
  1259. uem_send_msg_to_aux(MSG_ID_AUX_CALL_DISCONNECT_REQ_IND);
  1260. #endif
  1261. //KP Jerry add on 2007-4-17 end
  1262. }
  1263. /*
  1264.  * Clam_handling_functions
  1265.  */
  1266. #ifdef __MMI_GAME__
  1267. /*****************************************************************************
  1268.  * FUNCTION
  1269.  *  IsCurrentScrGameScr
  1270.  * DESCRIPTION
  1271.  *  temp solution for checking if current screen is game screen
  1272.  *  
  1273.  *  PARAMETERS:
  1274.  *  void
  1275.  *****************************************************************************/
  1276. BOOL IsCurrentScrGameScr(void)
  1277. {
  1278.     /*----------------------------------------------------------------*/
  1279.     /* Local Variables                                                */
  1280.     /*----------------------------------------------------------------*/
  1281.     U16 scr_id = GetExitScrnID();
  1282.     /*----------------------------------------------------------------*/
  1283.     /* Code Body                                                      */
  1284.     /*----------------------------------------------------------------*/
  1285.     if (scr_id == GFX_MENU_SCREEN ||
  1286.         scr_id == GFX_GAME_SCREEN ||
  1287.         scr_id == GFX_LEVEL_SCREEN ||
  1288.         scr_id == GFX_GRADE_SCREEN ||
  1289.         scr_id == GFX_HELP_SCREEN ||
  1290.         scr_id == GFX_GAMEOVER_SCREEN)
  1291.     {
  1292.         return MMI_TRUE;
  1293.     }
  1294.     else
  1295.     {
  1296.         return MMI_FALSE;
  1297.     }
  1298. }
  1299. #endif /* __MMI_GAME__ */
  1300. #if defined(__MMI_CLAMSHELL__) || defined(__MMI_SLIDE__)
  1301. /*****************************************************************************
  1302.  * FUNCTION
  1303.  *  IsClamToneAllow
  1304.  * DESCRIPTION
  1305.  *  Query if clam tone allow to play (No other audio tone is playing, except clam tone it self
  1306.  *  
  1307.  *  PARAMETERS:
  1308.  *  void
  1309.  *****************************************************************************/
  1310. static BOOL IsClamToneAllow(void)
  1311. {
  1312.     /*----------------------------------------------------------------*/
  1313.     /* Local Variables                                                */
  1314.     /*----------------------------------------------------------------*/
  1315.     /*----------------------------------------------------------------*/
  1316.     /* Code Body                                                      */
  1317.     /*----------------------------------------------------------------*/
  1318.     if ((!g_charbat_context.PowerOnCharger) && (!AlmIsRTCPwron()) && (!isInCall())      /* Even for CSD call */
  1319.         && (!AlmIsTonePlaying())
  1320. #ifdef __MMI_AUDIO_PLAYER__
  1321.         && (!mmi_audply_is_play_activated())
  1322. #endif 
  1323. #ifdef __MMI_FM_RADIO__
  1324.         && (!mmi_fmrdo_is_power_on())
  1325. #endif 
  1326. #ifdef __PHOEDT_FEATURE_SLIDSHOW__
  1327.         && (!mmi_slidshow_aud_is_playing())
  1328. #endif
  1329. #ifdef __MMI_VIDEO_PLAYER__
  1330.         && (!mmi_vdoply_is_in_app())
  1331.         && (!mdi_video_is_playing())        
  1332. #endif
  1333. #ifdef __MMI_VIDEO_RECORDER__
  1334.         && (!mmi_vdorec_is_in_app())
  1335.         && (!mdi_video_is_recording())        
  1336. #endif
  1337. #ifdef __MMI_GAME__
  1338.         && (!IsCurrentScrGameScr())
  1339. #endif
  1340.         )
  1341.         return MMI_TRUE;
  1342.     else
  1343.     {
  1344.         return MMI_FALSE;
  1345.     }
  1346. }
  1347. #endif /* #if defined(__MMI_CLAMSHELL__) || defined(__MMI_SLIDE__) */
  1348. /*****************************************************************************
  1349.  * FUNCTION
  1350.  *  IsClamClose
  1351.  * DESCRIPTION
  1352.  *  Query clam statue
  1353.  *  
  1354.  *  PARAMETERS:
  1355.  *  void
  1356.  *****************************************************************************/
  1357. BOOL IsClamClose(void)
  1358. {
  1359. #ifdef __MMI_CLAMSHELL__
  1360.     /*----------------------------------------------------------------*/
  1361.     /* Local Variables                                                */
  1362.     /*----------------------------------------------------------------*/
  1363.     /*----------------------------------------------------------------*/
  1364.     /* Code Body                                                      */
  1365.     /*----------------------------------------------------------------*/
  1366.     if (!gMMIClamState)
  1367.     {
  1368.         return MMI_TRUE;    /* 0: Close */
  1369.     }
  1370.     else
  1371. #endif /* __MMI_CLAMSHELL__ */ 
  1372.         return MMI_FALSE;   /* 1: Open */
  1373. }
  1374. /*****************************************************************************
  1375.  * FUNCTION
  1376.  *  SetClamState
  1377.  * DESCRIPTION
  1378.  *  Set clam state
  1379.  * PARAMETERS
  1380.  *  clam_state      [IN]        Clam state
  1381.  * RETURNS
  1382.  *  void
  1383.  *****************************************************************************/
  1384. void SetClamState(U16 clam_state)
  1385. {
  1386. #ifdef __MMI_CLAMSHELL__
  1387.     /*----------------------------------------------------------------*/
  1388.     /* Local Variables                                                */
  1389.     /*----------------------------------------------------------------*/
  1390.     /*----------------------------------------------------------------*/
  1391.     /* Code Body                                                      */
  1392.     /*----------------------------------------------------------------*/
  1393.     if (clam_state == EXT_DEV_CLAM_OPEN)
  1394.     {
  1395.         gMMIClamState = 1;  /* open */
  1396.     }
  1397.     else if (clam_state == EXT_DEV_CLAM_CLOSE)
  1398.     {
  1399.         gMMIClamState = 0;  /* close */
  1400.     }
  1401.     else
  1402.     {
  1403.         MMI_ASSERT(0);  /* wrong parameter */
  1404.     }
  1405. #else /* __MMI_CLAMSHELL__ */ 
  1406.     MMI_ASSERT(0);  /* shall not call this function when no clam support */
  1407. #endif /* __MMI_CLAMSHELL__ */ 
  1408. }
  1409. /*****************************************************************************
  1410.  * FUNCTION
  1411.  *  ClamCloseGotoIdleScreen
  1412.  * DESCRIPTION
  1413.  *  Function for clam close go back to idle screen
  1414.  *  
  1415.  *  PARAMETERS:
  1416.  *  void
  1417.  *****************************************************************************/
  1418. #if (defined(__MMI_CLAMCLOSE_BACK2IDLE__) || defined (__MMI_SUBLCD_SHOW_ANALOG_CLOCK__) )
  1419. static void ClamCloseGotoIdleScreen(void)
  1420. {
  1421.     /*----------------------------------------------------------------*/
  1422.     /* Local Variables                                                */
  1423.     /*----------------------------------------------------------------*/
  1424.     /*----------------------------------------------------------------*/
  1425.     /* Code Body                                                      */
  1426.     /*----------------------------------------------------------------*/
  1427.     if (backlight_check_call_present())
  1428.     {
  1429.         if (isEarphonePlugged == 1
  1430.     #if defined(__MMI_BT_HP_SUPPORT__) || defined(__MMI_BT_SUPPORT__)
  1431.             || mmi_bt_is_incall_aud_swap2bt() == MMI_TRUE
  1432.     #endif 
  1433.             )
  1434.             return;
  1435.     }
  1436.     PRINT_INFORMATION(("ClamCloseGotoIdleScreen():END Key Press, FP: %x", GetKeyHandler(KEY_END, KEY_EVENT_DOWN)));
  1437. #ifdef __MMI_FACTORY_MODE__
  1438.     if (gCurrentMode == FACTORY_MODE)
  1439.     {
  1440.         return;
  1441.     }
  1442. #endif /* __MMI_FACTORY_MODE__ */ 
  1443.     ClearKeyEvents();
  1444.     ExecuteCurrKeyHandler(KEY_END, KEY_EVENT_DOWN);
  1445. }
  1446. #endif /* (defined(__MMI_CLAMCLOSE_BACK2IDLE__) || defined (__MMI_SUBLCD_SHOW_ANALOG_CLOCK__) ) */ 
  1447. /*
  1448.  * LED_pattern_handling_functions
  1449.  */
  1450. /*****************************************************************************
  1451.  * FUNCTION
  1452.  *  GetBackgroundPattern
  1453.  * DESCRIPTION
  1454.  *  Returns Existing Pattern
  1455.  *  
  1456.  *  PARAMETERS:
  1457.  *  void
  1458.  *****************************************************************************/
  1459. U8 GetBackgroundPattern(void)
  1460. {
  1461.     /*----------------------------------------------------------------*/
  1462.     /* Local Variables                                                */
  1463.     /*----------------------------------------------------------------*/
  1464.     U8 band_pattern = LED_NoService;
  1465.     /*----------------------------------------------------------------*/
  1466.     /* Code Body                                                      */
  1467.     /*----------------------------------------------------------------*/
  1468.     if (g_charbat_context.LowBatteryFlag && (!g_charbat_context.isChargerConnected))    /* Robin 1217, Charger connect shall not play battery low pattern */
  1469.     {
  1470.         band_pattern = LED_BATTERY_LOW;
  1471.     }
  1472. #ifdef __MMI_LED_POWERON_CHARGEFULL__
  1473.     else if (g_charbat_context.ChargingComplete == 1)
  1474.     {
  1475.         band_pattern = LED_FullCharging;
  1476.     }
  1477. #endif /* __MMI_LED_POWERON_CHARGEFULL__ */ 
  1478.     else if (mmi_bootup_is_roaming() == MMI_TRUE)
  1479.     {
  1480.         band_pattern = LED_Roaming;
  1481.     }
  1482.     else if (g_pwr_context.CurrentServiceType == FULL_SERVICE)
  1483.     {
  1484.         switch (g_pwr_context.CurrentCampOnBand)
  1485.         {
  1486.             case NW_BAND_PGSM900:
  1487.             case NW_BAND_EGSM900:
  1488.             case NW_BAND_RGSM900:
  1489.                 band_pattern = LED_Connect900;
  1490.                 break;
  1491.             case NW_BAND_DCS1800:
  1492.                 band_pattern = LED_Connect1800;
  1493.                 break;
  1494.             case NW_BAND_PCS1900:
  1495.                 band_pattern = LED_Connect1900;
  1496.                 break;
  1497.             default:
  1498.                 band_pattern = LED_Connect900;
  1499.                 break;
  1500.         }
  1501.     }
  1502.     else if (g_pwr_context.CurrentServiceType == LIMITED_SERVICE)
  1503.     {
  1504.         band_pattern = LED_LimitService;
  1505.     }
  1506.     else
  1507.     {
  1508.         band_pattern = LED_NoService;
  1509.     }
  1510.     return band_pattern;
  1511. }
  1512. /*****************************************************************************
  1513.  * FUNCTION
  1514.  *  PlayPatternReq
  1515.  * DESCRIPTION
  1516.  *  Plays a pattern on vibrator or LED
  1517.  *  
  1518.  *  PARAMETERS:
  1519.  *  pattern     [IN]        
  1520.  *  action      [IN]        ON/OFF
  1521.  *****************************************************************************/
  1522. void PlayPatternReq(U8 pattern, U8 action)
  1523. {
  1524.     /*----------------------------------------------------------------*/
  1525.     /* Local Variables                                                */
  1526.     /*----------------------------------------------------------------*/
  1527.     signed char pat = (signed char)pattern;
  1528.     /*----------------------------------------------------------------*/
  1529.     /* Code Body                                                      */
  1530.     /*----------------------------------------------------------------*/
  1531.     if (gCurrentMode == ENGINEERING_MODE || gCurrentMode == FACTORY_MODE)
  1532.     {
  1533.         return;
  1534.     }
  1535.     /* Other module might request to obtain control of LEDs from MMI */
  1536.     if (gpioOutOfCtrl == 1 && !(pat >= VIB_PATTERN_BEGIN && pat <= VIB_PATTERN_END))
  1537.     {
  1538.         return;
  1539.     }
  1540.     /* Background LED pattern (for example: Camp on LED, Low battery...etc) */
  1541.     /* play request might comes anytime, it will interrupt the on going  */
  1542.     /* caller group pattern */
  1543.     if ((IsCallerGroupPatternPlaying)
  1544.         && (((pat >= LED_PATTERN_BEGIN) && (pat < LED_Caller1)) || ((pat > LED_Caller6) && (pat <= LED_PATTERN_END))))
  1545.     {
  1546.         return;
  1547.     }
  1548.     if ((!g_phnset_gpio_cntx_p->led_setting) && pattern == GetBackgroundPattern() && action != PLAY_STOP)
  1549.     {
  1550.         return;
  1551.     }
  1552.     SendPlayPatternReqToHW(pat, action);
  1553.     /* Start play CampOn LED pattern */
  1554.     if ((pat >= LED_PATTERN_BEGIN && pat < LED_PATTERN_END)
  1555.         && (action == PLAY_STOP)
  1556.         && (g_phnset_gpio_cntx_p->led_setting) && (mmi_bootup_is_searching_or_idle_reached() == MMI_TRUE))
  1557.     {
  1558.         SendPlayPatternReqToHW(GetBackgroundPattern(), PLAY_REPEAT);
  1559.     }
  1560. }
  1561. /*****************************************************************************
  1562.  * FUNCTION
  1563.  *  PlayPatternCallerGroup
  1564.  * DESCRIPTION
  1565.  *  Plays pattern as caller group functionality
  1566.  *  
  1567.  *  PARAMETERS:
  1568.  *  pattern     [IN]        
  1569.  *****************************************************************************/
  1570. void PlayPatternCallerGroup(MMI_LEDLIGHT_STATUS_ENUM pattern)
  1571. {
  1572.     /*----------------------------------------------------------------*/
  1573.     /* Local Variables                                                */
  1574.     /*----------------------------------------------------------------*/
  1575.     /*----------------------------------------------------------------*/
  1576.     /* Code Body                                                      */
  1577.     /*----------------------------------------------------------------*/
  1578.     IsCallerGroupPatternPlaying = 1;
  1579.     switch (pattern)
  1580.     {
  1581.         case COLOR_PATTERN1:
  1582.             StartLEDPatternCaller1();
  1583.             break;
  1584.         case COLOR_PATTERN2:
  1585.             StartLEDPatternCaller2();
  1586.             break;
  1587.         case COLOR_PATTERN3:
  1588.             StartLEDPatternCaller3();
  1589.             break;
  1590.         case COLOR_PATTERN4:
  1591.             StartLEDPatternCaller4();
  1592.             break;
  1593.         case COLOR_PATTERN5:
  1594.             StartLEDPatternCaller5();
  1595.             break;
  1596.         case COLOR_PATTERN6:
  1597.             StartLEDPatternCaller6();
  1598.             break;
  1599.         default:
  1600.             IsCallerGroupPatternPlaying = 0;
  1601.             break;
  1602.     }
  1603. }
  1604. /*****************************************************************************
  1605.  * FUNCTION
  1606.  *  StopPatternCallerGroup
  1607.  * DESCRIPTION
  1608.  *  Stops pattern as caller group functionality
  1609.  *  
  1610.  *  PARAMETERS:
  1611.  *  pattern     [IN]        
  1612.  *****************************************************************************/
  1613. void StopPatternCallerGroup(MMI_LEDLIGHT_STATUS_ENUM pattern)
  1614. {
  1615.     /*----------------------------------------------------------------*/
  1616.     /* Local Variables                                                */
  1617.     /*----------------------------------------------------------------*/
  1618.     /*----------------------------------------------------------------*/
  1619.     /* Code Body                                                      */
  1620.     /*----------------------------------------------------------------*/
  1621.     IsCallerGroupPatternPlaying = 0;
  1622.     switch (pattern)
  1623.     {
  1624.         case COLOR_PATTERN1:
  1625.             StopLEDPatternCaller1();
  1626.             break;
  1627.         case COLOR_PATTERN2:
  1628.             StopLEDPatternCaller2();
  1629.             break;
  1630.         case COLOR_PATTERN3:
  1631.             StopLEDPatternCaller3();
  1632.             break;
  1633.         case COLOR_PATTERN4:
  1634.             StopLEDPatternCaller4();
  1635.             break;
  1636.         case COLOR_PATTERN5:
  1637.             StopLEDPatternCaller5();
  1638.             break;
  1639.         case COLOR_PATTERN6:
  1640.             StopLEDPatternCaller6();
  1641.             break;
  1642.     }
  1643. }
  1644. /*
  1645.  * Tone_ID_Range_Qery_functions
  1646.  */
  1647. /*****************************************************************************
  1648.  * FUNCTION
  1649.  *  GetRingToneRange
  1650.  * DESCRIPTION
  1651.  *  Gets Tone Range for Ring Tones
  1652.  *  
  1653.  *  PARAMETERS:
  1654.  *  startId     [IN]        
  1655.  *  totalId     [IN]        
  1656.  *****************************************************************************/
  1657. void GetRingToneRange(U8 *startId, U8 *totalId)
  1658. {
  1659. #ifndef MMI_ON_WIN32
  1660.     /*----------------------------------------------------------------*/
  1661.     /* Local Variables                                                */
  1662.     /*----------------------------------------------------------------*/
  1663.     U8 endId;
  1664.     /*----------------------------------------------------------------*/
  1665.     /* Code Body                                                      */
  1666.     /*----------------------------------------------------------------*/
  1667.     custom_get_fixed_imelody_range(startId, &endId);
  1668.     *totalId = endId - *startId + 1;
  1669. #else /* MMI_ON_WIN32 */ 
  1670.     *startId = 1;
  1671.     *totalId = 15;
  1672. #endif /* MMI_ON_WIN32 */ 
  1673. }
  1674. /*****************************************************************************
  1675.  * FUNCTION
  1676.  *  GetMidiRange
  1677.  * DESCRIPTION
  1678.  *  Gets Tone Range for Midi Tones
  1679.  *  
  1680.  *  PARAMETERS:
  1681.  *  startId     [IN]        
  1682.  *  totalId     [IN]        
  1683.  *****************************************************************************/
  1684. void GetMidiRange(U8 *startId, U8 *totalId)
  1685. {
  1686. #ifndef MMI_ON_WIN32
  1687.     /*----------------------------------------------------------------*/
  1688.     /* Local Variables                                                */
  1689.     /*----------------------------------------------------------------*/
  1690.     U8 endId;
  1691.     /*----------------------------------------------------------------*/
  1692.     /* Code Body                                                      */
  1693.     /*----------------------------------------------------------------*/
  1694.     custom_get_fixed_midi_range(startId, &endId);
  1695.     *totalId = endId - *startId + 1;
  1696. #else /* MMI_ON_WIN32 */ 
  1697.     *startId = 16;
  1698.     *totalId = 15;
  1699. #endif /* MMI_ON_WIN32 */ 
  1700. }
  1701. /*****************************************************************************
  1702.  * FUNCTION
  1703.  *  GetToneRange
  1704.  * DESCRIPTION
  1705.  *  Gets Tone Range for General Tones
  1706.  *  
  1707.  *  PARAMETERS: startid: Starting Range Value
  1708.  *  startId     [IN]        
  1709.  *  totalId     [IN]        
  1710.  *****************************************************************************/
  1711. void GetToneRange(U8 *startId, U8 *totalId)
  1712. {
  1713. #ifndef MMI_ON_WIN32
  1714.     /*----------------------------------------------------------------*/
  1715.     /* Local Variables                                                */
  1716.     /*----------------------------------------------------------------*/
  1717.     U8 endId;
  1718.     /*----------------------------------------------------------------*/
  1719.     /* Code Body                                                      */
  1720.     /*----------------------------------------------------------------*/
  1721.     custom_get_fixed_sound_range(startId, &endId);
  1722.     *totalId = endId - *startId + 1;
  1723. #else /* MMI_ON_WIN32 */ 
  1724.     *startId = 31;
  1725.     *totalId = 10;
  1726. #endif /* MMI_ON_WIN32 */ 
  1727. }
  1728. /*****************************************************************************
  1729.  * FUNCTION
  1730.  *  GetMiscToneRange
  1731.  * DESCRIPTION
  1732.  *  Gets Tone Range for Misc Tones
  1733.  *  
  1734.  *  PARAMETERS: startid: Starting Range Value
  1735.  *  startId     [IN]        
  1736.  *  totalId     [IN]        
  1737.  *****************************************************************************/
  1738. void GetMiscToneRange(U8 *startId, U8 *totalId)
  1739. {
  1740. #ifndef MMI_ON_WIN32
  1741.     /*----------------------------------------------------------------*/
  1742.     /* Local Variables                                                */
  1743.     /*----------------------------------------------------------------*/
  1744.     U8 endId;
  1745.     /*----------------------------------------------------------------*/
  1746.     /* Code Body                                                      */
  1747.     /*----------------------------------------------------------------*/
  1748.     custom_get_fixed_message_sound_range(startId, &endId);
  1749.     *totalId = endId - *startId + 1;
  1750. #else /* MMI_ON_WIN32 */ 
  1751.     *startId = 46;
  1752.     *totalId = 10;
  1753. #endif /* MMI_ON_WIN32 */ 
  1754. }
  1755. /* 
  1756.  * Backlight_handling_functions
  1757.  */
  1758. /*****************************************************************************
  1759.  * FUNCTION
  1760.  *  GpioWakeUpTimer
  1761.  * DESCRIPTION
  1762.  *  Wake up timer
  1763.  *  
  1764.  *  PARAMETERS: void
  1765.  *  void
  1766.  *****************************************************************************/
  1767. void GpioWakeUpTimer(void)
  1768. {
  1769.     /*----------------------------------------------------------------*/
  1770.     /* Local Variables                                                */
  1771.     /*----------------------------------------------------------------*/
  1772.     /*----------------------------------------------------------------*/
  1773.     /* Code Body                                                      */
  1774.     /*----------------------------------------------------------------*/
  1775.     /* resume timer if suspended */
  1776.     if (isTimerSuspend == 1)
  1777.     {
  1778.         if (mmi_bootup_get_active_flight_mode() == 0)
  1779.         {
  1780.             evshed_resume_all_events(event_scheduler1_ptr);
  1781.         }
  1782.         isTimerSuspend = 0;
  1783.     }
  1784. }
  1785. /*****************************************************************************
  1786.  * FUNCTION
  1787.  *  GpioTurnOffKeypadLight
  1788.  * DESCRIPTION
  1789.  *  turn off keypad backlight
  1790.  *  
  1791.  *  PARAMETERS: void
  1792.  *  void
  1793.  *****************************************************************************/
  1794. static void GpioTurnOffKeypadLight(void)
  1795. {
  1796. #ifdef MMI_ON_HARDWARE_P
  1797.     /*----------------------------------------------------------------*/
  1798.     /* Local Variables                                                */
  1799.     /*----------------------------------------------------------------*/
  1800.     /*----------------------------------------------------------------*/
  1801.     /* Code Body                                                      */
  1802.     /*----------------------------------------------------------------*/
  1803.     /* turn off keypad backlight */
  1804.     StopTimer(GPIO_KEYPAD_LIGHT_TIMER);
  1805.     if (keypad_backlight == 1)
  1806.     {
  1807.         KeyPadBackLightOff();
  1808.         keypad_backlight = 0;
  1809.     }
  1810. #endif /* MMI_ON_HARDWARE_P */ 
  1811. }
  1812. //KP Jerry add on 2007-4-10 start
  1813. #ifdef __MMI_PEN_BLOCK_WHEN_KAYPAD_LOCKED__
  1814. BOOL GetLCDSleepStatus(void)
  1815. {
  1816.     return gIsInSleepMode;
  1817. }
  1818. #endif/*__MMI_PEN_BLOCK_WHEN_KAYPAD_LOCKED__*/
  1819. //KP Jerry add on 2007-4-10 end
  1820. /*****************************************************************************
  1821.  * FUNCTION
  1822.  *  GpioLCDSleepIn
  1823.  * DESCRIPTION
  1824.  *  Wake up LCM
  1825.  *  PARAMETERS:
  1826.  *  void
  1827.  *****************************************************************************/
  1828. static void GpioLCDSleepIn(void)
  1829. {
  1830. #ifdef MMI_ON_HARDWARE_P
  1831.     /*----------------------------------------------------------------*/
  1832.     /* Local Variables                                                */
  1833.     /*----------------------------------------------------------------*/
  1834.     /*----------------------------------------------------------------*/
  1835.     /* Code Body                                                      */
  1836.     /*----------------------------------------------------------------*/
  1837.     if (gIsInSleepMode == FALSE)
  1838.     {
  1839.         /* stop screensaver if need, since it might playing video */
  1840.         mmi_scrsvr_lcd_sleepin_handler();
  1841.         /* tvout sleepin */
  1842.     #ifdef __MMI_TVOUT__
  1843.         mmi_phnset_tvout_lcd_sleepin_handler();
  1844.     #endif 
  1845.     #ifdef __MMI_AUDIO_SPECTRUM_DISPLAY__
  1846.         mmi_audply_turn_off_spectrum();
  1847.     #endif 
  1848.     #if defined(__WIFI_SUPPORT__) && defined (__MTK_TARGET__)
  1849. wndrv_LCD_isOFF();
  1850.     #endif /* #if defined(__WIFI_SUPPORT__) && defined (__MTK_TARGET__) */
  1851.         lcd_sleep_in(MAIN_LCD);
  1852.         gIsInSleepMode = TRUE;
  1853.     #ifdef __MMI_TOUCH_SCREEN__
  1854.         /* diamond, 2006/06/22 Pen will not be blocked if backlight is becoming off */
  1855. //KP Jerry modify for LCD Backlight don't open when press any key during keypad been locked on 2007-4-4 start
  1856. #ifdef __MMI_PEN_BLOCK_WHEN_KAYPAD_LOCKED__
  1857. if(g_keylock_context.gKeyPadLockFlag)
  1858. {
  1859. mmi_pen_block();
  1860. }
  1861. #else
  1862.         if ((g_idle_context.IsOnIdleScreen || g_idle_context.IsOnSimErrorScreen) && g_keylock_context.gKeyPadLockFlag)
  1863.         {
  1864. mmi_pen_unblock();     
  1865.         }
  1866. #endif
  1867. //KP Jerry modify for LCD Backlight don't open when press any key during keypad been locked on 2007-4-4 end    
  1868.     #endif /* __MMI_TOUCH_SCREEN__ */
  1869.     }
  1870. #endif /* MMI_ON_HARDWARE_P */ 
  1871. }
  1872. /*****************************************************************************
  1873.  * FUNCTION
  1874.  *  GpioLCDSleepOut
  1875.  * DESCRIPTION
  1876.  *  Sleep LCM
  1877.  *  PARAMETERS:
  1878.  *  void
  1879.  *****************************************************************************/
  1880. static void GpioLCDSleepOut(void)
  1881. {
  1882. #ifdef MMI_ON_HARDWARE_P
  1883.     /*----------------------------------------------------------------*/
  1884.     /* Local Variables                                                */
  1885.     /*----------------------------------------------------------------*/
  1886.     /*----------------------------------------------------------------*/
  1887.     /* Code Body                                                      */
  1888.     /*----------------------------------------------------------------*/
  1889.     if (gIsInSleepMode)
  1890.     {
  1891.         ClearInterruptEventHandler(MSG_ID_MMI_EQ_ALARM_IND);
  1892.         lcd_sleep_out(MAIN_LCD);
  1893.         gIsInSleepMode = FALSE;
  1894.     #ifdef __MMI_AUDIO_SPECTRUM_DISPLAY__
  1895.         mmi_audply_turn_on_spectrum();
  1896.     #endif 
  1897.         update_mainlcd_dt_display();
  1898.         update_sublcd_dt_display();
  1899.     #if defined(__MMI_SUBLCD__)
  1900.         {
  1901.             gdi_lcd_set_active(GDI_LCD_SUB_LCD_HANDLE);
  1902.             gdi_lcd_repaint_all();
  1903.             gdi_lcd_set_active(GDI_LCD_MAIN_LCD_HANDLE);
  1904.         }