diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-05-09 21:19:58 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-05-09 21:19:58 +0000 |
commit | 6df1a86e9959cdae26dc2850fa749ad18fc2a94c (patch) | |
tree | 901710269963bd5914bbfb3d2cdc65c5b6aa5a27 /firmware/target/arm/imx31/gigabeat-s/button-imx31.c | |
parent | c85faed1ee3205d99c1ec053fc5af28d59ac0ab3 (diff) | |
download | rockbox-6df1a86e9959cdae26dc2850fa749ad18fc2a94c.tar.gz rockbox-6df1a86e9959cdae26dc2850fa749ad18fc2a94c.zip |
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/button-imx31.c')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/button-imx31.c | 29 |
1 files changed, 13 insertions, 16 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; | |||
38 | 38 | ||
39 | static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void) | 39 | static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void) |
40 | { | 40 | { |
41 | static const int key_mtx[5][3] = | 41 | static const struct key_mask_shift |
42 | { | 42 | { |
43 | { BUTTON_LEFT, BUTTON_BACK, BUTTON_VOL_UP }, | 43 | uint8_t mask; |
44 | { BUTTON_UP, BUTTON_MENU, BUTTON_VOL_DOWN }, | 44 | uint8_t shift; |
45 | { BUTTON_DOWN, BUTTON_NONE, BUTTON_PREV }, | 45 | } kms[3] = |
46 | { BUTTON_RIGHT, BUTTON_NONE, BUTTON_PLAY }, | 46 | { |
47 | { BUTTON_SELECT, BUTTON_NONE, BUTTON_NEXT }, | 47 | { 0x1f, 0 }, /* BUTTON_LEFT...BUTTON_SELECT */ |
48 | { 0x03, 5 }, /* BUTTON_BACK...BUTTON_MENU */ | ||
49 | { 0x1f, 7 }, /* BUTTON_VOL_UP...BUTTON_NEXT */ | ||
48 | }; | 50 | }; |
49 | 51 | ||
50 | unsigned short reg_val; | 52 | int col; |
51 | int col, row; | ||
52 | int i; | ||
53 | /* Power button is handled separately on PMIC */ | 53 | /* Power button is handled separately on PMIC */ |
54 | int button = int_btn & BUTTON_POWER; | 54 | int button = int_btn & BUTTON_POWER; |
55 | 55 | ||
@@ -60,6 +60,8 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void) | |||
60 | 60 | ||
61 | for (col = 0; col < 3; col++) /* Col */ | 61 | for (col = 0; col < 3; col++) /* Col */ |
62 | { | 62 | { |
63 | int i; | ||
64 | |||
63 | /* 2. Write 1s to KPDR[10:8] setting column data to 1s */ | 65 | /* 2. Write 1s to KPDR[10:8] setting column data to 1s */ |
64 | KPP_KPDR |= (0x7 << 8); | 66 | KPP_KPDR |= (0x7 << 8); |
65 | 67 | ||
@@ -80,7 +82,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void) | |||
80 | * 7. Repeat steps 2 - 6 for remaining columns. */ | 82 | * 7. Repeat steps 2 - 6 for remaining columns. */ |
81 | 83 | ||
82 | /* Col bit starts at 8th bit in KPDR */ | 84 | /* Col bit starts at 8th bit in KPDR */ |
83 | KPP_KPDR &= ~(1 << (8 + col)); | 85 | KPP_KPDR &= ~(0x100 << col); |
84 | 86 | ||
85 | /* Delay added to avoid propagating the 0 from column to row | 87 | /* Delay added to avoid propagating the 0 from column to row |
86 | * when scanning. */ | 88 | * when scanning. */ |
@@ -88,12 +90,7 @@ static __attribute__((interrupt("IRQ"))) void KPP_HANDLER(void) | |||
88 | asm volatile (""); | 90 | asm volatile (""); |
89 | 91 | ||
90 | /* Read row input */ | 92 | /* Read row input */ |
91 | reg_val = KPP_KPDR; | 93 | button |= (~KPP_KPDR & kms[col].mask) << kms[col].shift; |
92 | for (row = 0; row < 5; row++) /* sample row */ | ||
93 | { | ||
94 | if (!(reg_val & (1 << row))) | ||
95 | button |= key_mtx[row][col]; | ||
96 | } | ||
97 | } | 94 | } |
98 | 95 | ||
99 | /* 8. Return all columns to 0 in preparation for standby mode. */ | 96 | /* 8. Return all columns to 0 in preparation for standby mode. */ |