changeset 84:7160f0d005d2

first stage of actual FreeCalypso backlight rework
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Oct 2020 23:46:55 +0000
parents 718ede6f6f1f
children 332bff2bd3b4
files src/ui/bmi/mmiCall.c src/ui/bmi/mmiMain.c src/ui/bmi/mmiSmsIdle.c src/ui/mfw/mfw_kbd.c src/ui/mfw/mfw_mme.c src/ui/mfw/mfw_mme.h
diffstat 6 files changed, 85 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/src/ui/bmi/mmiCall.c	Mon Oct 26 21:51:55 2020 +0000
+++ b/src/ui/bmi/mmiCall.c	Mon Oct 26 23:46:55 2020 +0000
@@ -6262,7 +6262,7 @@
 #endif
 
     /* API - 10/11/2003 - SPR 2472 - Place the call to turn on the backlight here so the backlight comes on for all calls */
-    mme_backlightEvent(BL_INCOMING_CALL);
+    mme_backlightOnEvent();
     /* API - 10/11/2003 - SPR 2472 - END */
 
     /*SPR 1392, replaced local variable display_info with call_data.inc_call_data, so incoming calls dialog
@@ -6572,7 +6572,7 @@
     /*
     ** Turn on the backlight
     */
-    mme_backlightEvent(BL_INCOMING_CALL);
+    mme_backlightOnEvent();
     /*
     * Call Info Screen
     */
--- a/src/ui/bmi/mmiMain.c	Mon Oct 26 21:51:55 2020 +0000
+++ b/src/ui/bmi/mmiMain.c	Mon Oct 26 23:46:55 2020 +0000
@@ -679,29 +679,7 @@
     #endif
 #endif
 
-    /*Setup when we want the backlight to come on*/
-//  Nov 09, 2005    REF: DVT OMAPS00056873 xdeepadh
-//On Isample boards the backlight is set off, since the bright LEDS are very disturbing.
-
-    for (i=0;i<BL_LAST_OPTION;i++)
-#if (BOARD == 71)
-    mme_setBacklightEvent(i,BL_NO_LIGHT);
-#else
-    mme_setBacklightEvent(i,BL_MAX_LIGHT);
-#endif
-
-#if (BOARD == 71)
-    mme_setBacklightEvent(BL_IDLE_TIMER,BL_NO_LIGHT);
-#else
-    mme_setBacklightEvent(BL_IDLE_TIMER,BL_SET_IDLE);
-#endif
-
-    mme_setBacklightEvent(BL_KEY_PRESS,BL_MAX_LIGHT);
-    mme_setBacklightEvent(BL_INCOMING_CALL,BL_MAX_LIGHT);
-    mme_setBacklightEvent(BL_EXIT,BL_NO_LIGHT);
-
-    /*and tell the backlight that the init event has happened */
-    mme_backlightEvent(BL_INIT);
+    mme_backlightOnEvent();
 
     //x0018858 24 Mar, 2005 MMI-FIX-11321
     //Added two functions to set the indication and CMER values.
@@ -783,7 +761,7 @@
      * sigDistribute() in mfw_kbd.c, rather than at the end.
      */
     if (res_int != -1)
-	return;
+	return 0;
 
   /* terminate the ringing in all situation (it doesnt matter where the user is */
   if ( (e & KEY_HUP) && (e & KEY_MAKE) )
@@ -829,6 +807,13 @@
 
   HUPKeyOrigin = 0;
 
+  /* FreeCalypso backlight handling */
+  if (e & KEY_MAKE) {
+	if (mme_backlightKeyPress())
+		return 1;
+  } else {
+	mme_backlightOnEvent();
+  }
 
 #ifdef SIM_TOOLKIT
        /*SPR#2121 - DS - Only download event to SAT if the event has been registered
@@ -1236,8 +1221,8 @@
    if (CphsPresent() == CPHS_ERR)
         cphs_support_check();
 
-
-  mme_backlightEvent(BL_IDLE_TIMER);
+  /* removed in FreeCalypso */
+  /* mme_backlightEvent(BL_IDLE_TIMER); */
 
   timStart(times);
 
--- a/src/ui/bmi/mmiSmsIdle.c	Mon Oct 26 21:51:55 2020 +0000
+++ b/src/ui/bmi/mmiSmsIdle.c	Mon Oct 26 23:46:55 2020 +0000
@@ -770,7 +770,7 @@
 
 #endif
 #endif
-                mme_backlightEvent(BL_INCOMING_SMS);
+                mme_backlightOnEvent();
             }
 
 /* Set */
@@ -874,7 +874,7 @@
            }
 #endif
 
-            mme_backlightEvent(BL_INCOMING_SMS);
+            mme_backlightOnEvent();
         }
         /*NM p029*/
         /* API - Implemented NM changes from 3.3.3 mainline to show class 0 SMS on idle screen */
@@ -969,7 +969,7 @@
 
 #endif
 #endif
-                    mme_backlightEvent(BL_INCOMING_SMS);
+                    mme_backlightOnEvent();
                     /*CQ10826 - END*/
 
 /* Added Condtion(   if((!(call_data.calls.numCalls))) ) to stop the
--- a/src/ui/mfw/mfw_kbd.c	Mon Oct 26 21:51:55 2020 +0000
+++ b/src/ui/mfw/mfw_kbd.c	Mon Oct 26 23:46:55 2020 +0000
@@ -478,7 +478,8 @@
          (kbd_processKeyInput()== QUEUE_N_KEYS))
         temp = dspl_Enable(0);
 
-    mme_backlightEvent(BL_KEY_PRESS);
+    /* removed in FreeCalypso */
+    /* mme_backlightEvent(BL_KEY_PRESS); */
 
     loopNo = 0;
     keyNo = 0;
--- a/src/ui/mfw/mfw_mme.c	Mon Oct 26 21:51:55 2020 +0000
+++ b/src/ui/mfw/mfw_mme.c	Mon Oct 26 23:46:55 2020 +0000
@@ -129,6 +129,7 @@
 
 #include "mfw_mfw.h"
 #include "mfw_sys.h"
+#include "mfw_tim.h"
 #include "prim.h"
 #include "message.h"
 #include "prim.h"
@@ -181,6 +182,20 @@
 static U8 battState = 0;                /* state of power supply    */
 static U16 hdsPresence = 0;             /* headset presence         */
 
+/* backlight control internals */
+#define	LIGHT_LEVEL_OFF	0
+#define	LIGHT_LEVEL_LOW	50
+#define	LIGHT_LEVEL_MAX	255
+
+UBYTE mme_backlight_incall;
+static U8 current_backlight_level;
+
+static MfwHdr bltimIdleH;	/* backlight timer for idle state */
+static MfwTim bltimIdle;
+static MfwHdr bltimCallH;	/* backlight timer for in-call state */
+static MfwTim bltimCall;
+static int bl_timeout_idle (U32 t, void *h);
+static int bl_timeout_call (U32 t, void *h);
 
 static int mmeCommand (U32 cmd, void *h);
 
@@ -426,6 +441,15 @@
     battState = 0;
     hdsPresence = 0;
 
+    /* init FreeCalypso backlight control infrastructure */
+    bltimIdle.handler = bl_timeout_idle;
+    bltimIdle.time = 30000;
+    bltimIdleH.data = &bltimIdle;
+    bltimIdleH.type = MfwTypTim;
+    bltimCall.handler = bl_timeout_call;
+    bltimCall.time = 10000;
+    bltimCallH.data = &bltimCall;
+    bltimCallH.type = MfwTypTim;
 
     fchg_register_event_handler(pwrCb);	/* battery driver */
     rx_Init(rxCb);	//fieldstrength driver
@@ -630,56 +654,6 @@
 }
 
 
-static int mme_backlightStatus[BL_LAST_OPTION];
-/*
-+--------------------------------------------------------------------+
-| PROJECT : MMI-Framework (8417)        MODULE  : MFW_MME            |
-| STATE   : code                        ROUTINE : mme_setBacklightIdle   |
-+--------------------------------------------------------------------+
-
-  PURPOSE : called when an event may change the backlight level/status
-
-*/
-void mme_backlightEvent(int event)
-{
-    int light;
-    if ((event >=BL_INIT) && (event <BL_LAST_OPTION))
-    {
-        light  = mme_backlightStatus[event];
-        if (light == BL_SET_IDLE)
-        {
-            light_setBacklightIdle();
-        }
-        else if (light == BL_NO_CHANGE)
-        {
-            //No change
-        }
-        else if ((light >=BL_NO_LIGHT) && (light <=BL_MAX_LIGHT))
-        {
-            mmeBackLight ((U8)light);
-        }
-
-    }
-}
-
-/*
-+--------------------------------------------------------------------+
-| PROJECT : MMI-Framework (8417)        MODULE  : MFW_MME            |
-| STATE   : code                        ROUTINE : mme_setBacklightIdle   |
-+--------------------------------------------------------------------+
-
-  PURPOSE : called to initialise backlight events
-
-*/
-void mme_setBacklightEvent(int event, int lightLevel)
-{
-    if ((event >=BL_INIT) && (event <BL_LAST_OPTION))
-    {
-        mme_backlightStatus[event] = lightLevel;
-    }
-}
-
-
 /*
 +--------------------------------------------------------------------+
 | PROJECT : MMI-Framework (8417)        MODULE  : MFW_MME            |
@@ -689,9 +663,46 @@
   PURPOSE : set display backlight
 
 */
-void mmeBackLight (U8 level)
+static void mmeBackLight (U8 level)
+{
+    if (level != current_backlight_level) {
+	light_SetStatus(LIGHT_DEVICE_BACKLIGHT, level);
+	current_backlight_level = level;
+    }
+}
+
+/* new FreeCalypso backlight control functions */
+
+void mme_backlightOnEvent (void)
 {
-    light_SetStatus(LIGHT_DEVICE_BACKLIGHT,level);
+	timStop(&bltimIdleH);
+	timStop(&bltimCallH);
+	mmeBackLight(LIGHT_LEVEL_MAX);
+	if (mme_backlight_incall)
+		timStart(&bltimCallH);
+	else
+		timStart(&bltimIdleH);
+}
+
+int mme_backlightKeyPress (void)
+{
+	int ret;
+
+	ret = (current_backlight_level == LIGHT_LEVEL_OFF);
+	timStop(&bltimIdleH);
+	timStop(&bltimCallH);
+	mmeBackLight(LIGHT_LEVEL_MAX);
+	return ret;
+}
+
+static int bl_timeout_idle (U32 t, void *h)
+{
+	mmeBackLight(LIGHT_LEVEL_OFF);
+}
+
+static int bl_timeout_call (U32 t, void *h)
+{
+	mmeBackLight(LIGHT_LEVEL_LOW);
 }
 
 
--- a/src/ui/mfw/mfw_mme.h	Mon Oct 26 21:51:55 2020 +0000
+++ b/src/ui/mfw/mfw_mme.h	Mon Oct 26 23:46:55 2020 +0000
@@ -137,25 +137,6 @@
 
 #endif
 
-//Light level settings
-#define BL_NO_LIGHT 0
-#define BL_MAX_LIGHT 255
-#define BL_SET_IDLE -1
-#define BL_NO_CHANGE -2
-
-//Events that may affect the backlight
-enum {
-    BL_INIT,
-    BL_IDLE_TIMER,
-    BL_KEY_PRESS,
-    BL_INCOMING_SMS,
-    BL_INCOMING_CALL,
-    BL_EXIT,
-    BL_SPARE_OPTION_1,
-    BL_SPARE_OPTION_2,
-    BL_SPARE_OPTION_3,
-    BL_LAST_OPTION
-};
 //      xpradipg - LOCOSTO-ENH-31895 : 23 June 2005
 #ifdef FF_MMI_AUDIO_PROFILE
 #define MFW_AUD_HANDHELD        1
@@ -181,14 +162,15 @@
 MfwHnd mmeCreate (MfwHnd w, MfwEvt e, MfwCb f);
 MfwRes mmeDelete (MfwHnd h);
 void mmeSignal (U32 evt, U32 val);
-void mmeBackLight (U8 level);
-void mme_setBacklightEvent(int event, int lightLevel);
-void mme_backlightEvent(int event);
 void mmeAudioTone (U8 callTone, U8 volume, U8 toneStat);
 MfwRes mmeSetVolume (U16 audioIn, U16 audioOut);
 MfwRes mmeRtcInit (USHORT drvHandle, UBYTE *info);
 MfwRes mmeHdsInit (void (*hds_init) ());
 
+void mme_backlightOnEvent (void);
+int mme_backlightKeyPress (void);
+extern UBYTE mme_backlight_incall;
+
 void mmeRxInfo (U8 intervalls, U16 level);
 void mmeBattInfo (U8 intervalls, U16 level);
 //      xpradipg - LOCOSTO-ENH-31895 : 23 June 2005