changeset 213:0947a816580c

first stage of FreeCalypso handset switch-on logic rework
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 22 Apr 2021 21:23:16 +0000
parents 782c6ae77467
children adfdbcd360fd
files src/cs/drivers/drv_app/abb/board/abb_inth.c src/cs/drivers/drv_app/power/board/power.c src/ui/bmi/mmiMmi.c src/ui/mfw/ti1_key.c
diffstat 4 files changed, 76 insertions(+), 479 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/abb/board/abb_inth.c	Thu Apr 22 20:41:41 2021 +0000
+++ b/src/cs/drivers/drv_app/abb/board/abb_inth.c	Thu Apr 22 21:23:16 2021 +0000
@@ -106,7 +106,8 @@
    if (*read_value & PUSHOFF_IT_STS)
    {
       /* Push Button from ON to OFF */
-      if (SPI_GBL_INFO_PTR->is_gsm_on == TRUE)
+      /* condition below removed in FreeCalypso */
+      /* if (SPI_GBL_INFO_PTR->is_gsm_on == TRUE) */
       {
          NU_Sleep(SHORT_OFF_KEY_PRESSED);
 
@@ -156,12 +157,6 @@
          }
        #endif //WCP
       }
-      else  /* GSM OFF */
-      {
-         rvf_send_trace("IQ EXT: Power On request",24, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, SPI_USE_ID);
-
-         Power_ON_Button();
-      }
    }
 
    else if (*read_value & REMOT_IT_STS)
--- a/src/cs/drivers/drv_app/power/board/power.c	Thu Apr 22 20:41:41 2021 +0000
+++ b/src/cs/drivers/drv_app/power/board/power.c	Thu Apr 22 21:23:16 2021 +0000
@@ -10,8 +10,8 @@
 *
 * Author:  Candice Bazanegue (c-brille@ti.com)
 *
-*
-* (C) Texas Instruments 2001
+* The present FreeCalypso version is heavily modified from TI's original,
+* for the new FreeCalypso way of managing handset on/off state.
 *
 ******************************************************************************/
 
@@ -30,19 +30,6 @@
   #include "ffs/ffs.h"
 #endif  // _WINDOWS
 
-#ifdef RVM_PWR_SWE
-  #include "spi/spi_task.h"
-  #ifndef _WINDOWS
-    #include "l1sw.cfg"
-    #include "chipset.cfg"
-  #endif  // _WINDOWS
-  #include "pwr/pwr_messages.h"
-  #include "pwr/pwr_liion_cha.h"
-  #include "pwr/pwr_disch.h"
-#endif /* #ifdef RVM_PWR_SWE */
-
-
-
 #ifndef _WINDOWS
   /* Declare the variable containing pressed and released callback.  */
   extern T_KPD_KEYPAD Kp;
@@ -50,7 +37,6 @@
   extern effs_t ffs_exit(void);
 #endif  // _WINDOWS
 
-
 /// The ABB status used to know the cause of the Switch ON event.
 static SYS_UWORD16 Power_abb_status = 0;
 
@@ -60,70 +46,42 @@
 ** Function      Power_ON_Button
 **
 ** Description:  Informs the Protocol Stack that the Power ON key has been
-**				 pressed, and thus allows it to start.
+**		 pressed, and thus allows it to start.
 **
 *******************************************************************************/
 void Power_ON_Button(void)
 {
-#ifndef _WINDOWS
-   SPI_GBL_INFO_PTR->is_gsm_on = TRUE;
-
-   /*
-     When we build for ACI, we have no MMI, so there's no point waiting
-      for a keypress.  See CR 17958.
-   */
-
-#if (OP_WCP == 0) && (MMI != 0)
-
-   /* Wait until the pointers initialization by the SMI */
-   while(!(Kp.pressed && Kp.released))
-     rvf_delay(1);
+#if (MMI != 0)
+    extern void fchs_pwon_button_boot(void);
 
-#if (TEST==0)
-   (Kp.pressed)(KPD_PWR);  /* tell key is pressed */
-   rvf_delay(5);
-   (Kp.released)();        /* allow protocol stack to start */
+    fchs_pwon_button_boot();
 #endif
-
-#endif // OP_WCP == 0
-
-#else
-  rvf_send_trace("Start from button", 17, NULL_PARAM, RV_TRACE_LEVEL_WARNING, LCC_USE_ID);
-  SPI_GBL_INFO_PTR->is_gsm_on = TRUE;
-#endif  // _WINDOWS
 }
 
 
-
 /*******************************************************************************
 **
 ** Function      Power_OFF_Button
 **
 ** Description:  Informs the Protocol Stack that the Power OFF key has been
-**				 pressed, and thus allows it to stop.
+**		 pressed, and thus allows it to stop.
 **
 *******************************************************************************/
 void Power_OFF_Button(void)
 {
-#ifndef _WINDOWS
-   ffs_exit ();
-#endif  // _WINDOWS
-   rvf_send_trace("Power off button", 16, NULL_PARAM, RV_TRACE_LEVEL_WARNING, LCC_USE_ID);
-   SPI_GBL_INFO_PTR->is_gsm_on = FALSE;
-#ifndef _WINDOWS
-  #if (OP_WCP == 0) && (MMI != 0)
-   (Kp.pressed)(KPD_PWR);  /* tell key is pressed */
-   rvf_delay(5);
-   (Kp.released)();        /* tell key is released */
-  #else
-   ABB_Power_Off();
-  #endif
-#endif  // _WINDOWS
+    rvf_send_trace("Power off button", 16, NULL_PARAM, RV_TRACE_LEVEL_WARNING,
+		   LCC_USE_ID);
+    if (Kp.pressed && Kp.released) {
+	(Kp.pressed)(KPD_PWR);  /* tell key is pressed */
+	rvf_delay(5);
+	(Kp.released)();        /* tell key is released */
+    } else
+	ABB_Power_Off();
 }
 
 
 /**
- * @brief Sets the cause of the swith ON event.
+ * @brief Sets the cause of the switch ON event.
  *
  * This function get the ABB status register and stores it into the
  * global variable Power_abb_status.
@@ -151,60 +109,38 @@
 *******************************************************************************/
 void Switch_ON(void)
 {
-#if ((ANLG_FAM == 1) || (ANLG_FAM == 2))
    if (Power_abb_status & ONBSTS)
-#elif (ANLG_FAM == 3)
-   if (Power_abb_status & PWONBSTS)
-#endif
    {
       /* Switch on Condition on ON BUTTON Push */
-      rvf_send_trace("Push Button from OFF to ON",26, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
+      rvf_send_trace("Push Button from OFF to ON",26, NULL_PARAM,
+		     RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
       Power_ON_Button();
-      #ifdef RVM_PWR_SWE
-      pwr_handle_discharge();
-      #endif
    }
 
-#if ((ANLG_FAM == 1) || (ANLG_FAM == 2))
    else if (Power_abb_status & ONRSTS)
-#elif (ANLG_FAM == 3)
-   else if (Power_abb_status & RPSTS)
-#endif
    {
       /* Switch on Condition on ON REM transition 0->1 */
-      rvf_send_trace("ON Remote",9, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
+      rvf_send_trace("ON Remote",9, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW,
+		     LCC_USE_ID);
       Power_ON_Remote();
-      #ifdef RVM_PWR_SWE
-      pwr_handle_discharge();
-      #endif
    }
 
-#ifdef RVM_PWR_SWE
    else if (Power_abb_status & CHGSTS)
    {
       /* Switch on Condition on CHARGER IC PLUG */
-      rvf_send_trace("PWR: Charger Plug",17, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
-      if (Power_abb_status & CHGPRES)
-      {
-         /* charger still present */
-         PWR_Charger_Plug();
-      }
+      rvf_send_trace("Boot: Charger Plug",18, NULL_PARAM,
+		     RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
    }
-#endif /* #ifdef RVM_PWR_SWE */
 
    else
    {
-      // The reset should run the SW in the same way than a Power ON
-      rvf_send_trace("Start from reset",16, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
-      Power_ON_Button();
-      #ifdef RVM_PWR_SWE
-      pwr_handle_discharge();
-      #endif
+      /* In FreeCalypso start from reset is NOT the same as PWON! */
+      rvf_send_trace("Start from reset",16, NULL_PARAM,
+		     RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
    }
 }
 
 
-
 /*******************************************************************************
 **
 ** Function         Power_ON_Remote
@@ -218,7 +154,6 @@
 }
 
 
-
 /*******************************************************************************
 **
 ** Function         Power_OFF_Remote
@@ -232,7 +167,6 @@
 }
 
 
-
 /*******************************************************************************
 **
 ** Function         Power_IT_WakeUp
@@ -244,78 +178,3 @@
 void Power_IT_WakeUp(void)
 {
 }
-
-
-
-#ifdef RVM_PWR_SWE
-/*******************************************************************************
-**
-** Function         PWR_Charger_Plug
-**
-** Description
-**
-**
-*******************************************************************************/
-void PWR_Charger_Plug(void)
-{
-
-  /* Start the fast charging cycle */
-
-  /* Since this function is called from the SPI task
-   it can't be interrupt by another task
-   so we can directly access the SPI through the low-level driver */
-
-   if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
-   {
-      rvf_delay(RVF_MS_TO_TICKS(2000));
-   }
-
-   rvf_stop_timer(SPI_TIMER3);
-
-   /* informs the upper layer that the charger has been plugged */
-   pwr_send_charger_plug_event();
-
-   /* get the type of the battery */
-   pwr_get_battery_type();
-}
-
-
-
-/*******************************************************************************
-**
-** Function         PWR_Charger_Unplug
-**
-** Description
-**
-**
-*******************************************************************************/
-void PWR_Charger_Unplug(void)
-{
-   /* informs the upper layer that the charger has been unplugged */
-   pwr_send_charger_unplug_event();
-
-   rvf_send_trace("Charger unplug", 14, NULL_PARAM, RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID );
-   pwr_stop_charging();
-   if (SPI_GBL_INFO_PTR->is_gsm_on == FALSE) /* GSM OFF */
-   {
-    #ifndef _WINDOWS
-      #if (ANLG_FAM == 1)
-      ABB_Write_Register_on_page(PAGE0, VRPCCTL2, 0x00EE);
-      #elif ((ANLG_FAM == 2) || (ANLG_FAM == 3))
-      ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
-      #endif
-    #else
-      ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x00EE);
-    #endif  // _WINDOWS
-   }
-   else
-   {
-      pwr_handle_discharge();
-   }
-}
-#endif /* #ifdef RVM_PWR_SWE */
-
-
-
-
-
--- a/src/ui/bmi/mmiMmi.c	Thu Apr 22 20:41:41 2021 +0000
+++ b/src/ui/bmi/mmiMmi.c	Thu Apr 22 21:23:16 2021 +0000
@@ -130,29 +130,9 @@
 #include "MmiDialogs.h"
 #include "MmiLists.h"
 
-/* Retrieve PM duration from FlashData structure */
-#ifdef NEPTUNE_BOARD
-#ifdef MMI_POWER_MANAGEMENT_TEST
-#include "mfw_ffs.h"
-#endif
-#endif
-
 #include "dspl.h"
 #include "drv_key.h"
 
-#ifdef FF_MMI_MULTIMEDIA
-/* To Assign the MSL_Init Return Value */
-#include "MSL.h"
-#include "mmiMultimediaApp.h"
-#include "omxutil.h"
-/* Bug Fix - OMAPS00084167 */
-/* Added - To access the funtion dev_Mbox_isDspMboxReady () */
-#include "typedefs.h"
-#include "main_system.h"
-#include "dev_Mbox.h"  /* 04-07-2006 */
-#include "mfw_acie.h"   /* prototypes of aci_delete and aci_create */
-#endif
-
 #ifdef MMI_LITE
 	#define MFW_MEMORY_POOL_SIZE 22000 /*SPR 2686*/
 #else
@@ -184,37 +164,6 @@
 /* x0039928 - Lint warning fix
 static int initialized = 0;              */
 
-/* Begin Bug Fix - OMAPS00084167 */
-/* Added for Primitive exchange */
-#ifdef ENABLE_KEY_ON_BOOTING
-#define hCommACI _ENTITY_PREFIXED(hCommACI)
-
-#if defined (NEW_FRAME)
-EXTERN T_HANDLE hCommACI;
-#else
-EXTERN T_VSI_CHANDLE hCommACI;
-#endif
-
-#define BOOTUP_WAIT_TIME    20
-#define BOOTUP_SUCCESS_IND  1
-#define MFW_BOOTUP_IND      0x910
-
-static int iPrimitiveSlot = 0;
-
-/* ====================================================== */
-/**
-* Structure which holds the Status details
-**/
-/* ====================================================== */
-typedef struct
-{
-      int  iStatus;
-}T_MFW_BOOTUP_IND;
-
-GLOBAL BOOL bootup_response_cb (ULONG opc, void * data);
-#endif
-/* End - OMAPS00084167 */
-
 
 /*******************************************************************************
 
@@ -236,88 +185,13 @@
 
 void mmi_main( void )
 {
-    /* JVJ #1874 - mmi_main doesnt start the MMI. It only initilizes the Keyboard handler*/
-    /* The keyboard handler will call mmiInit() when the Power Key is pressed */
-//    	Jun 13 2005,	REF:LOCOSTO-OTH-32113	-	xpradipg
-#if (BOARD == 61)
-/* BUG FIX - OMAPS00084167 */
-/* For multimedia alone generate the primitive */
-#ifdef ENABLE_KEY_ON_BOOTING
-      /* Send the primitive to MMI */
-     PALLOC (bootup_indication, MFW_BOOTUP_IND);
-#endif
-/* END - OMAPS00084167 */
-
-#if FF_MMI_SERVICES_MIGRATION
-	   drvKeyUpDown(0,0);
-#else
-	 key_power_init();
-#endif
-
-
-#ifndef ENABLE_KEY_ON_BOOTING
-	vsi_t_sleep(VSI_CALLER 50);
-	mmiInit();
-#else
-      /* Begin - Bug fix - OMAPS00084167 */
-      iPrimitiveSlot = aci_create (bootup_response_cb, NULL);
-
-     bootup_indication->iStatus  = BOOTUP_SUCCESS_IND;
-     PSENDX (ACI, bootup_indication);
-     /* End - OMAPS00084167 */
-#endif
-
-
-#else  /* Other Builds */
-     key_power_init();
-#endif
-
+/*
+ * In FreeCalypso this function is now empty: Switch_ON() will call
+ * fchs_pwon_button_boot() which will cause mmiInit() to be called
+ * in MMI task context, and the setup of key_power_init (for subsequent
+ * power-off, not for power-on!) now happens inside mmiInit().
+ */
 }
-/* Begin - Bugfix - OMAPS00084167 */
-#ifdef ENABLE_KEY_ON_BOOTING
-/* ===========================================================*/
-/**
-* bootup_response_cb () -  response function.
-*
-* @param ULONG opc  - Operation Code.
-*
-* @param void * data - structure data.
-*
-*  @return BOOL  - TRUE / FALSE
-*
-*  @see
-*/
-/* =========================================================== */
-GLOBAL BOOL bootup_response_cb (ULONG opc, void * data)
-{
-       T_MFW_BOOTUP_IND *bootup_indication;
-
-        if (opc == MFW_BOOTUP_IND) {
-              bootup_indication = (T_MFW_BOOTUP_IND *)data;
-
-              /* Status is 1 then bootup sequence has enabled */
-              if (bootup_indication->iStatus == BOOTUP_SUCCESS_IND) {
-                   /* Contineous Pooling */
-                   while (dev_Mbox_isDspMboxReady() == FALSE)
-                    {
-                         vsi_t_sleep (VSI_CALLER BOOTUP_WAIT_TIME); /* Small Delay after each check */
-                    }
-
-                   aci_delete (iPrimitiveSlot);
-
-                   /* Once DSP initialization is done */
-                   mmiInit ();
-
-                   return TRUE;
-
-              }
-
-        }
-
-	return FALSE;
-
-}
-#endif /* End - OMAPS00084167 */
 
 
 /*******************************************************************************
@@ -335,10 +209,6 @@
 
 void mmiInit( void )
 {
-#ifdef FF_MMI_MULTIMEDIA
-   unsigned int uiResult = 0;
-#endif
-
   /* get the resources running
   */
 
@@ -347,11 +217,11 @@
   mfwInit( mfwMem,   sizeof( mfwMem ) );
   winInit( &mmiScrX, &mmiScrY );
 
-
   timInit();                          /* init timer handler       */
   kbdInit();                          /* init keyboard handler    */
+  key_power_init();		      /* init power-off handler   */
   lngInit();                          /* init language handler    */
-  #ifndef NEW_EDITOR			/* SPR#1428 - SH - New Editor changes */
+  #ifndef NEW_EDITOR		      /* SPR#1428 - SH - New Editor changes */
   edtInit();                          /* init editor handler      */
   #endif /* NEW_EDITOR */
 
@@ -360,25 +230,6 @@
   //Oct 05, 2006    ER: OMAPS00094496 x0061088(Prachi)
   sAT_PercentCSQ ( CMD_SRC_LCL, CSQ_Enable );
   mainInit(0);
-#ifdef FF_MMI_MULTIMEDIA
-    /* MSL Init Call */
-   uiResult = MSL_Init();
-   vsi_t_sleep(0, 100);
-   mmi_setInitResult(uiResult);
-
-/* Power management. Enable/Disable on boot up based on value stored*/
-#ifdef NEPTUNE_BOARD
-#ifdef MMI_POWER_MANAGEMENT_TEST
-    if(FFS_flashData.pm_duration)
-    {
-        SVC_SCN_EnablePM( 1, FFS_flashData.pm_duration);
-    }
-#endif
-#endif
-   /* PCM Setup Done */
-/*  MSLRM_Start ();  */
-#endif
-
 }
 
 
@@ -397,11 +248,11 @@
 
 void mmiExit( void )
 {
-    TRACE_EVENT("mmiExit");
+  TRACE_EVENT("mmiExit");
 
   icnExit();                          /* finit icon handler       */
   mnuExit();                          /* finit menu handler       */
-  #ifndef NEW_EDITOR			/* SPR#1428 - SH - New Editor changes */
+  #ifndef NEW_EDITOR		      /* SPR#1428 - SH - New Editor changes */
   edtExit();                          /* finit edit handler       */
   #endif /* NEW_EDITOR */
   lngExit();                          /* finit language handler   */
@@ -425,7 +276,6 @@
 #ifndef _SIMULATION_
   AI_Power(0);
 #endif   //_SIMULATION_
-
 }
 
 
--- a/src/ui/mfw/ti1_key.c	Thu Apr 22 20:41:41 2021 +0000
+++ b/src/ui/mfw/ti1_key.c	Thu Apr 22 21:23:16 2021 +0000
@@ -44,35 +44,12 @@
 #include "drv_key.h"
 #include "ti1_key.h"
 
-#ifndef NEPTUNE_BOARD
 #include "kpd/kpd_api.h"
-#else
-#define PLATFORM_ARCH_ARM
-#define PLATFORM_ENDIAN_LITTLE
-#define PLATFORM tcs3100Evm
-#include "bspSystem.h"
-#include "bspKeypad_Gsp.h"
-#endif
-
-/* BUG FIX - OMAPS00084167 */
-#ifdef FF_MMI_MULTIMEDIA
-#include "typedefs.h"
-#include "main_system.h"
-/*#include "dev_Mbox.h" */ /* 04-07-2006 */
-#endif
-/* END - OMAPS00084167 */
-
-BOOL powered_on=FALSE;
 
 #define POWER_KEY 25
 
 extern void mmiInit(void);
 
-//TISH modified for MSIM
-#ifdef WIN32
-#define _SIMULATION_
-#endif
-
 /*
  * Marcus: Issue 811: 05:09/2002:
  * Moved kbd_map, simkbd_map and config_map to \g23m\Condat\COM\SRC\DRIVER\keypad.c
@@ -91,24 +68,30 @@
 
 T_KPD_SUBSCRIBER      subscriber_p; /* keep the subscription indentification value */
 
-//   Sep 18, 2006 REF: OMAPS00094426 - x0039928
-#if (BOARD == 71)
-extern UBYTE kpd_key;
-#endif
-
 typedef struct
 {
     U32     msg_id;
-  void    (*callback_func)(void *);
-    U16 src_addr_id;
-  U16 dest_addr_id;
+    void    (*callback_func)(void *);
+    U16     src_addr_id;
+    U16     dest_addr_id;
 } T_RV_CHECK;
 
+/*
+ * New FreeCalypso way of launching "full on" operation: Switch_ON()
+ * will call fchs_pwon_button_boot() when the switch-on cause is the
+ * PWON button (as opposed to charging or test reset), the latter
+ * function will post a different version of the MMI_KEYPAD_IND
+ * primitive to MMI task, drvKeyUpDown() will get called as a result
+ * of this special MMI_KEYPAD_IND, and the latter function calls
+ * mmiInit().  Here we define the special "key code" used in the
+ * MMI_KEYPAD_IND primitive to pass this event to the MMI task.
+ */
+
+#define	SPECIAL_KEYCODE_PWON	0x81
 
 
 /* JVJ #1874 - new function to initialize the power key*/
 
-
 /*
 +--------------------------------------------------------------------+
 | PROJECT : MMI-Framework (8417)        MODULE  : key_power_init       |
@@ -119,15 +102,12 @@
 
 */
 
-
-
 void key_power_init()
 {
     kbd_Init(kbdCb);
 }
 
 
-
 /*
 +--------------------------------------------------------------------+
 | PROJECT : MMI-Framework (8417)        MODULE  : ti1_key            |
@@ -149,16 +129,7 @@
     */
     keyMap = (char *) kbd_map;
 
-
-//new keypad driver
-#ifdef NEPTUNE_BOARD
-// Commented by Nitin for Neptune Platfrom. 05/04/2005
-//keypad_initialize ();
-#else
     keypad_initialize ();
-#endif
-
-
 }
 
 
@@ -176,17 +147,8 @@
 {
     sig = 0;
 
-    // by Nitin 05/04/2004
-#ifndef NEPTUNE_BOARD
-  //unsubscribe the client from the keypad driver
-#ifndef _SIMULATION_
+    //unsubscribe the client from the keypad driver
     kpd_unsubscribe (&subscriber_p);
-#endif
-// Added by Nitin 05/04/2004
-#else /* NOT defined NEPTUNE_BOARD  */
-    kpdMgr_unsubscribe(); // Sumit; commented for time being
-#endif
-
 }
 
 /*
@@ -202,7 +164,6 @@
 {
     int i;
 
-#ifndef _SIMULATION_
     for (i = 0; i < 32; i++)
     {
         if (keyMap[i] == key)
@@ -211,20 +172,7 @@
         }
     }
 
-#else
-                                        /* TEST only ES!!           */
-    for (i = 0; i < NUM_KPD_KEYS; i++)
-    {
-        if (simkbd_map[i] == key)
-        {
-            return (i);
-        }
-    }
-#endif
-
     return (char)(0xFE); //No match./*a0393213 warnings removal - -1 changed to 0xFE*/
-
-
 }
 
 
@@ -241,24 +189,10 @@
 void drvKeyUpDown (char upDown, char key)
 {
     TRACE_EVENT_P2("drvKeyUpDown : key = %d : state = %x", key, upDown);
-/* JVJ #1705 The first KEY event can only be the Power Key*/
-/* This will start MMI                                    */
-    if ((!powered_on))
-    {
-        powered_on =TRUE;
-
-        /* ADDED BY RAVI - 22-11-2005 - OMAPS00056702 FIX */
-#if (BOARD!=61)
-        /* JVJ #1705 MMI will be started here */
-        mmiInit();
-        return;
-#endif
-      /* END RAVI - 22-11-2005 */
-    }
 
     if (key != (char)0)
     {
-        if ((key >= 48) && (key <=57))
+        if ((key >= 48) && (key <= 57))
         {
             key -= 47;
         }
@@ -302,6 +236,11 @@
                     key = (char)12;
                     break;
 
+		/* FreeCalypso new way */
+		case SPECIAL_KEYCODE_PWON:
+		    mmiInit();
+		    return;
+
                 default:
                     key = (char)0;
                     break;
@@ -316,7 +255,6 @@
     sig((char)(!upDown),0);
 
     return;
-
 }
 
 
@@ -429,11 +367,7 @@
 
 static void kbdCb (drv_SignalID_Type *signal_params)
 {
-#if defined (NEW_FRAME)
-ULONG signal_raw;
-
-#endif
-
+    ULONG signal_raw;
     U16 signal_high;
     U16 signal_low;
     U8   key_code;
@@ -441,15 +375,9 @@
 
     int nPresses; //Number of key presses still in the queue
 
-
-#if defined (NEW_FRAME)
     signal_raw = (ULONG)signal_params->UserData;
     signal_high = (U16) (signal_raw >> 16);
     signal_low = (U16) (signal_raw & 0xFFFF);
-#else
-    signal_high = (U16) (signal_params->UserData >> 16);
-    signal_low = (U16) (signal_params->UserData & 0xFFFF);
-#endif
 
     key_code = (U8) (signal_low & 0xFF);
     if (signal_high == 1)
@@ -457,19 +385,9 @@
     else
         key_state = KEY_STAT_REL;
 
-/*JVJ #1705 When the first POWER KEY event arrives, an event is sent to MMI */
-/*to start it */
-if ((!powered_on)&&(key_code==POWER_KEY))
-{
-        sendKeyInd(key_code, key_state, 0);
-        return;
-}
-
-
     //Add keypress to queue of key presses
     nPresses = kbd_getNumElements();
 
-
     kbd_putMakeAndKey( (char)key_state, (char)key_code);
 
     if ((!kbd_stillProcessingKeys()) && (nPresses == 0))
@@ -477,13 +395,12 @@
         sendKeyInd(key_code, key_state, 0);
 
     }
-
 }
 
 /*
 +--------------------------------------------------------------------+
 | PROJECT : MMI-Framework (8417)        MODULE  : ti1_key            |
-| STATE   : code                        ROUTINE :  keypad_cb          |
+| STATE   : code                        ROUTINE :  keypad_cb         |
 +--------------------------------------------------------------------+
 
   PURPOSE : This CB function is called by the driver when a key is pressed/released
@@ -493,13 +410,10 @@
 
 void keypad_cb (void* parameter)
 {
-// NITIN
-#ifndef NEPTUNE_BOARD
     T_KPD_KEY_EVENT_MSG* event;
     T_KPD_STATUS_MSG*    status;
     T_RV_CHECK*  check;
 
-
     check = (T_RV_CHECK*)parameter;
 
     if (check->msg_id EQ KPD_STATUS_MSG)
@@ -523,7 +437,6 @@
         //event message is used
         event = (T_KPD_KEY_EVENT_MSG*) parameter;
 
-
         //Add keypress to queue of key presses
         nPresses = kbd_getNumElements();
 
@@ -542,11 +455,6 @@
             //        0010 00xx = KPD_REPEAT_PRESS
             //
             //    x = anystate
-//   Sep 18, 2006 REF: OMAPS00094426 - x0039928
-// Fix : Store the virtual key info in the global variable kpd_key for later use
-#if (BOARD == 71)
-            kpd_key = (char)event->key_info.virtual_key_id;
-#endif
             kbd_putMakeAndKey( (char)(event->key_info.state | (event->key_info.press_state << 4)),
                                   (char)event->key_info.virtual_key_id );
         }
@@ -560,24 +468,20 @@
         }
 
     }
-#endif // NEPTUNE_BOARD
     return;
-
 }
 
 
 /*
 +--------------------------------------------------------------------+
 | PROJECT : MMI-Framework (8417)        MODULE  : ti1_key            |
-| STATE   : code                        ROUTINE :  keypad_initialize    |
+| STATE   : code                        ROUTINE :  keypad_initialize |
 +--------------------------------------------------------------------+
 
   PURPOSE : initialize keyboard driver
 
 */
-// Commented by Nitin for Neptune Platfrom. 05/04/2005
 
-#ifndef NEPTUNE_BOARD
 UBYTE keypad_initialize (void)
 {
     T_KPD_MODE          mode;
@@ -624,11 +528,7 @@
     notified_keys.notified_keys [23] = KPD_KEY_RECORD;
   #endif
 
-#ifndef _SIMULATION_
   return_value = kpd_subscribe (&subscriber_p, mode, &notified_keys, return_path);
-#else
-  return_value = RV_OK; /* do some faking here, to get it compileable */
-#endif
 
   if (return_value EQ RV_INTERNAL_ERR ||
      return_value EQ RV_INVALID_PARAMETER ||
@@ -650,12 +550,8 @@
   //subscribe to KPD_LONG_KEY_PRESS_NOTIF once implemented.
   notif_level = KPD_FIRST_PRESS_NOTIF | KPD_RELEASE_NOTIF;
 
-#ifndef _SIMULATION_
   return_value = kpd_define_key_notification( subscriber_p, &notified_keys, notif_level,
               long_press_time, repeat_time );
-#else
-  return_value = RV_OK;
-#endif
 
   if (return_value EQ RV_INVALID_PARAMETER ||
      return_value EQ RV_MEMORY_ERR)
@@ -664,8 +560,6 @@
   }
   return 0;
 }
-// Commented by Nitin for Neptune Platfrom. 05/04/2005
-#endif /* NEPTUNE_BOARD*/
 
 
 /*
@@ -680,31 +574,30 @@
                     T_KPD_KEY_STATE key_state,
                     T_KPD_PRESS_STATE press_state)
 {
-#if defined (NEW_FRAME)
     EXTERN T_HANDLE hCommACI;
 
-//  ULONG signal_raw;   // RAVI
-#else
-    EXTERN T_VSI_CHANDLE hCommACI;
-#endif
-
     PALLOC(key_ind,MMI_KEYPAD_IND);
 
     key_ind->key_code = (U8)0;
 
     key_ind->key_stat = 0;
 
-#if defined (NEW_FRAME)
     PSENDX(ACI,key_ind);
-#else
-#if defined (_TMS470)
-    vsi_c_send("",hCommACI,D2P(key_ind),
-            sizeof(T_PRIM_HEADER)+sizeof(T_MMI_KEYPAD_IND));
-#else
-    PSEND(ACI,key_ind);
-#endif
-#endif
 
     return;
+}
 
+/* new FreeCalypso functions for switch-on causes */
+
+void fchs_pwon_button_boot(void)
+{
+    EXTERN T_HANDLE hCommACI;
+
+    PALLOC(key_ind,MMI_KEYPAD_IND);
+
+    key_ind->key_code = SPECIAL_KEYCODE_PWON;
+
+    key_ind->key_stat = 0;
+
+    PSENDX(ACI,key_ind);
 }