changeset 446:bed6d393f3e0

C1xx targets: sensible handling of Compal's power key wiring
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 28 Jan 2018 19:26:10 +0000 (2018-01-28)
parents 399f3a5a5450
children 4b6acb68b851
files src/cs/drivers/drv_app/abb/board/abb_inth.c src/cs/drivers/drv_app/kpd/board/kpd_scan_functions.c src/cs/drivers/drv_app/kpd/kpd_physical_key_def.h
diffstat 3 files changed, 51 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/abb/board/abb_inth.c	Mon Jan 22 05:45:26 2018 +0000
+++ b/src/cs/drivers/drv_app/abb/board/abb_inth.c	Sun Jan 28 19:26:10 2018 +0000
@@ -37,6 +37,7 @@
 #include "chipset.cfg"
 #include "swconfig.cfg"
 #include "sys.cfg"
+#include "fc-target.cfg"
 
 
 #include "l1_macro.h"
@@ -128,7 +129,9 @@
          if (status_value == PWR_OFF_KEY_PRESSED)
          {
             /* Inform keypad that key ON/OFF has been pressed */
+          #ifndef CONFIG_TARGET_COMPAL
             kpd_power_key_pressed();
+          #endif
 
             loop_count = 0;
             /* Wait loop for Power-OFF */
--- a/src/cs/drivers/drv_app/kpd/board/kpd_scan_functions.c	Mon Jan 22 05:45:26 2018 +0000
+++ b/src/cs/drivers/drv_app/kpd/board/kpd_scan_functions.c	Sun Jan 28 19:26:10 2018 +0000
@@ -86,38 +86,41 @@
    {KPD_PKEY_7,     KPD_PKEY_8,    KPD_PKEY_9,         KPD_PKEY_NULL},
    {KPD_PKEY_STAR,  KPD_PKEY_0,    KPD_PKEY_DIESE,     KPD_PKEY_NULL},
    };
-#elif ((BOARD == 40) || (BOARD == 41) || (BOARD == 42) || (BOARD == 43))
+#elif defined(CONFIG_TARGET_COMPAL)
+   #define KP_ROWS      5
+   #define KP_COLS      4
+   const T_KPD_PHYSICAL_KEY_ID keypad_layout[KP_ROWS][KP_COLS]=
+   {                           
+   /* Mot C1xx keypad */
+   {KPD_PKEY_GREEN, KPD_PKEY_3,          KPD_PKEY_2,         KPD_PKEY_1},
+   {KPD_PKEY_UP,    KPD_PKEY_6,          KPD_PKEY_5,         KPD_PKEY_4},
+   {KPD_PKEY_DOWN,  KPD_PKEY_9,          KPD_PKEY_8,         KPD_PKEY_7},
+   {KPD_PKEY_LEFT,  KPD_PKEY_DIESE,      KPD_PKEY_0,         KPD_PKEY_STAR},
+   {KPD_PKEY_RIGHT, KPD_PKEY_SOFT_RIGHT, KPD_PKEY_NAV_CENTER,KPD_PKEY_SOFT_LEFT},
+   };
+#elif defined(CONFIG_TARGET_PIRELLI)
    #define KP_ROWS      5
    #define KP_COLS      5
    const T_KPD_PHYSICAL_KEY_ID keypad_layout[KP_ROWS][KP_COLS]=
    {                           
-#ifdef CONFIG_TARGET_COMPAL
-   /* Mot C1xx keypad */
-   {KPD_PKEY_GREEN, KPD_PKEY_3,          KPD_PKEY_2,         KPD_PKEY_1,
-	KPD_PKEY_NULL},
-   {KPD_PKEY_UP,    KPD_PKEY_6,          KPD_PKEY_5,         KPD_PKEY_4,
-	KPD_PKEY_NULL},
-   {KPD_PKEY_DOWN,  KPD_PKEY_9,          KPD_PKEY_8,         KPD_PKEY_7,
-	KPD_PKEY_NULL},
-   {KPD_PKEY_LEFT,  KPD_PKEY_DIESE,      KPD_PKEY_0,         KPD_PKEY_STAR,
-	KPD_PKEY_NULL},
-   {KPD_PKEY_RIGHT, KPD_PKEY_SOFT_RIGHT, KPD_PKEY_NAV_CENTER,KPD_PKEY_SOFT_LEFT,
-	KPD_PKEY_NULL},
-#elif defined(CONFIG_TARGET_PIRELLI)
    /* Pirelli's keypad */
    {KPD_PKEY_NAV_CENTER, KPD_PKEY_LEFT,       KPD_PKEY_RIGHT, KPD_PKEY_UP,    KPD_PKEY_NULL},
    {KPD_PKEY_SOFT_LEFT,  KPD_PKEY_SOFT_RIGHT, KPD_PKEY_GREEN, KPD_PKEY_DOWN,  KPD_PKEY_VOL_UP},
    {KPD_PKEY_3,          KPD_PKEY_6,          KPD_PKEY_9,     KPD_PKEY_DIESE, KPD_PKEY_VOL_DOWN},
    {KPD_PKEY_2,          KPD_PKEY_5,          KPD_PKEY_8,     KPD_PKEY_0,     KPD_PKEY_REC},
    {KPD_PKEY_1,          KPD_PKEY_4,          KPD_PKEY_7,     KPD_PKEY_STAR,  KPD_PKEY_NULL},
-#else
+   };
+#elif ((BOARD == 40) || (BOARD == 41) || (BOARD == 42) || (BOARD == 43))
+   #define KP_ROWS      5
+   #define KP_COLS      5
+   const T_KPD_PHYSICAL_KEY_ID keypad_layout[KP_ROWS][KP_COLS]=
+   {                           
    /* Layout of D-Sample and E-Sample */
    {KPD_PKEY_GREEN, KPD_PKEY_VOL_DOWN, KPD_PKEY_VOL_UP,KPD_PKEY_SOFT_LEFT,  KPD_PKEY_LEFT},
    {KPD_PKEY_1,     KPD_PKEY_2,        KPD_PKEY_3,     KPD_PKEY_REC,        KPD_PKEY_RIGHT},
    {KPD_PKEY_4,     KPD_PKEY_5,        KPD_PKEY_6,     KPD_PKEY_SOFT_RIGHT, KPD_PKEY_UP},
    {KPD_PKEY_7,     KPD_PKEY_8,        KPD_PKEY_9,     KPD_PKEY_NULL,       KPD_PKEY_DOWN},
    {KPD_PKEY_STAR,  KPD_PKEY_0,        KPD_PKEY_DIESE, KPD_PKEY_NULL,       KPD_PKEY_NAV_CENTER},
-#endif
    };
 #endif
 
@@ -361,6 +364,18 @@
    /* Deactivate all columns */
    *(volatile UINT16*) KP_COL_OUT = KP_ALL_OFF;
 
+#ifdef CONFIG_TARGET_COMPAL
+   /* Compal's power key handling */
+   delay();
+   rows = (*(volatile UINT16*) KP_ROW_IN) & 0x1F;
+   if (KP_IS_ACTIVE(rows,4))
+   {
+      /* Reactivate all columns */
+      *(volatile UINT16*) KP_COL_OUT = KP_ALL_ON;
+      return KPD_PKEY_RED;
+   }
+#endif
+
    /* Activate 1 column at a time */
    for (col = 0; col < KP_COLS; col++)
    {
--- a/src/cs/drivers/drv_app/kpd/kpd_physical_key_def.h	Mon Jan 22 05:45:26 2018 +0000
+++ b/src/cs/drivers/drv_app/kpd/kpd_physical_key_def.h	Sun Jan 28 19:26:10 2018 +0000
@@ -26,6 +26,7 @@
 
 #ifndef _WINDOWS
    #include "config/board.cfg"
+   #include "config/fc-target.cfg"
 #endif
 
 /** Definition of the physical key ID.
@@ -63,6 +64,8 @@
 
 #endif
 
+#ifndef CONFIG_TARGET_COMPAL
+
 /* The PWR key is mapped on Analog Base Band, it's the SPI which inform
    the keypad that the PWR key is pressed, so the process for this key
    is different of the others, a subscriber can be notified only by a
@@ -71,5 +74,19 @@
    #define allows to map any key with the PWR key. */
 #define KPD_SHORT_PRESS_PWR_KEY KPD_PKEY_RED
 
+#else
+
+/*
+ * On C1xx phones the red key grounds not only the PWON signal to the ABB,
+ * but also row input line 4 of the regular keypad matrix.  The latter
+ * results in the regular keypad interrupt being generated, so we have
+ * to handle it with the regular keys, not in TI's way.  We disable the
+ * KPD_SHORT_PRESS_PWR_KEY mechanism by defining it to a key that does not
+ * exist on this keypad.
+ */
+
+#define KPD_SHORT_PRESS_PWR_KEY KPD_PKEY_REC
+
+#endif
 
 #endif /* #ifndef _KPD_PHYSICAL_KEY_DEF_H_ */