summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/gigabeat-s
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-05-09 21:19:58 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-05-09 21:19:58 +0000
commit6df1a86e9959cdae26dc2850fa749ad18fc2a94c (patch)
tree901710269963bd5914bbfb3d2cdc65c5b6aa5a27 /firmware/target/arm/imx31/gigabeat-s
parentc85faed1ee3205d99c1ec053fc5af28d59ac0ab3 (diff)
Remove inner loop from button scanning on Gigabeat S. Requires changing the button codes but it's not a "functional port" so no plugin API version increase is done though a full update will be needed since any using the values will be incompatible.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17432 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s')
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-imx31.c29
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/button-target.h44
2 files changed, 32 insertions, 41 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
index 28b711902b..e80166bca7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/button-imx31.c
@@ -38,18 +38,18 @@ static bool hold_button_old = false;
static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
{
- static const int key_mtx[5][3] =
+ static const struct key_mask_shift
{
- { BUTTON_LEFT, BUTTON_BACK, BUTTON_VOL_UP },
- { BUTTON_UP, BUTTON_MENU, BUTTON_VOL_DOWN },
- { BUTTON_DOWN, BUTTON_NONE, BUTTON_PREV },
- { BUTTON_RIGHT, BUTTON_NONE, BUTTON_PLAY },
- { BUTTON_SELECT, BUTTON_NONE, BUTTON_NEXT },
+ uint8_t mask;
+ uint8_t shift;
+ } kms[3] =
+ {
+ { 0x1f, 0 }, /* BUTTON_LEFT...BUTTON_SELECT */
+ { 0x03, 5 }, /* BUTTON_BACK...BUTTON_MENU */
+ { 0x1f, 7 }, /* BUTTON_VOL_UP...BUTTON_NEXT */
};
- unsigned short reg_val;
- int col, row;
- int i;
+ int col;
/* Power button is handled separately on PMIC */
int button = int_btn & BUTTON_POWER;
@@ -60,6 +60,8 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
for (col = 0; col < 3; col++) /* Col */
{
+ int i;
+
/* 2. Write 1s to KPDR[10:8] setting column data to 1s */
KPP_KPDR |= (0x7 << 8);
@@ -80,7 +82,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
* 7. Repeat steps 2 - 6 for remaining columns. */
/* Col bit starts at 8th bit in KPDR */
- KPP_KPDR &= ~(1 << (8 + col));
+ KPP_KPDR &= ~(0x100 << col);
/* Delay added to avoid propagating the 0 from column to row
* when scanning. */
@@ -88,12 +90,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void)
asm volatile ("");
/* Read row input */
- reg_val = KPP_KPDR;
- for (row = 0; row < 5; row++) /* sample row */
- {
- if (!(reg_val & (1 << row)))
- button |= key_mtx[row][col];
- }
+ button |= (~KPP_KPDR & kms[col].mask) << kms[col].shift;
}
/* 8. Return all columns to 0 in preparation for standby mode. */
diff --git a/firmware/target/arm/imx31/gigabeat-s/button-target.h b/firmware/target/arm/imx31/gigabeat-s/button-target.h
index 836a4c02cd..e2f68162f7 100644
--- a/firmware/target/arm/imx31/gigabeat-s/button-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/button-target.h
@@ -31,32 +31,26 @@ void button_power_set_state(bool pressed);
void set_headphones_inserted(bool inserted);
bool headphones_inserted(void);
-/* Toshiba Gigabeat specific button codes */
+/* Toshiba Gigabeat S-specific button codes */
-#define BUTTON_BACK (1 << 0)
-#define BUTTON_MENU (1 << 1)
-
-#define BUTTON_LEFT (1 << 2)
+/* These shifts are selected to optimize scanning of the keypad port */
+#define BUTTON_LEFT (1 << 0)
+#define BUTTON_UP (1 << 1)
+#define BUTTON_DOWN (1 << 2)
#define BUTTON_RIGHT (1 << 3)
-#define BUTTON_UP (1 << 4)
-#define BUTTON_DOWN (1 << 5)
-#define BUTTON_SELECT (1 << 6)
-
-#define BUTTON_POWER (1 << 7)
-#define BUTTON_VOL_UP (1 << 8)
-#define BUTTON_VOL_DOWN (1 << 9)
-#define BUTTON_NEXT (1 << 10)
-#define BUTTON_PREV (1 << 11)
-#define BUTTON_PLAY (1 << 12)
-
-#define BUTTON_MAIN (BUTTON_BACK|BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT \
- |BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT|BUTTON_POWER \
- |BUTTON_VOL_UP|BUTTON_VOL_DOWN|BUTTON_NEXT|BUTTON_PREV \
- |BUTTON_PLAY)
-
-#define BUTTON_REMOTE 0
-
-#define POWEROFF_BUTTON BUTTON_POWER
-#define POWEROFF_COUNT 10
+#define BUTTON_SELECT (1 << 4)
+#define BUTTON_BACK (1 << 5)
+#define BUTTON_MENU (1 << 6)
+#define BUTTON_VOL_UP (1 << 7)
+#define BUTTON_VOL_DOWN (1 << 8)
+#define BUTTON_PREV (1 << 9)
+#define BUTTON_PLAY (1 << 10)
+#define BUTTON_NEXT (1 << 11)
+#define BUTTON_POWER (1 << 12) /* Read from PMIC */
+
+#define BUTTON_REMOTE 0
+
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
#endif /* _BUTTON_TARGET_H_ */