summaryrefslogtreecommitdiff
path: root/firmware/drivers/button.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/button.c')
-rw-r--r--firmware/drivers/button.c118
1 files changed, 15 insertions, 103 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 216c51ea15..d9f9ae2a6d 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -44,6 +44,10 @@
44#include "lcd-remote.h" 44#include "lcd-remote.h"
45#endif 45#endif
46 46
47#ifdef TARGET_TREE
48#include "button-target.h"
49#endif
50
47struct event_queue button_queue; 51struct event_queue button_queue;
48 52
49static long lastbtn; /* Last valid button status */ 53static long lastbtn; /* Last valid button status */
@@ -72,10 +76,7 @@ static bool remote_filter_first_keypress;
72 (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD) 76 (CONFIG_KEYPAD == IRIVER_IFP7XX_PAD)
73#define POWEROFF_BUTTON BUTTON_PLAY 77#define POWEROFF_BUTTON BUTTON_PLAY
74#define POWEROFF_COUNT 40 78#define POWEROFF_COUNT 40
75#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD) 79#elif !defined(TARGET_TREE)
76#define POWEROFF_BUTTON BUTTON_POWER
77#define POWEROFF_COUNT 10
78#else
79#define POWEROFF_BUTTON BUTTON_OFF 80#define POWEROFF_BUTTON BUTTON_OFF
80#define POWEROFF_COUNT 10 81#define POWEROFF_COUNT 10
81#endif 82#endif
@@ -603,7 +604,10 @@ long button_get_w_tmo(int ticks)
603void button_init(void) 604void button_init(void)
604{ 605{
605 /* hardware inits */ 606 /* hardware inits */
606#if CONFIG_KEYPAD == IRIVER_H100_PAD 607#ifdef TARGET_TREE
608 button_init_device();
609
610#elif CONFIG_KEYPAD == IRIVER_H100_PAD
607 /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ 611 /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */
608 GPIO1_FUNCTION |= 0x00100062; 612 GPIO1_FUNCTION |= 0x00100062;
609 GPIO1_ENABLE &= ~0x00100060; 613 GPIO1_ENABLE &= ~0x00100060;
@@ -614,11 +618,6 @@ void button_init(void)
614 /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */ 618 /* Set GPIO33, GPIO37, GPIO38 and GPIO52 as general purpose inputs */
615 GPIO1_ENABLE &= ~0x00100060; 619 GPIO1_ENABLE &= ~0x00100060;
616 GPIO1_FUNCTION |= 0x00100062; 620 GPIO1_FUNCTION |= 0x00100062;
617#elif CONFIG_KEYPAD == IAUDIO_X5_PAD
618 /* Power, Remote Play & Hold switch */
619 GPIO_FUNCTION |= 0x0e000000;
620 GPIO_ENABLE &= ~0x0e000000;
621
622#elif CONFIG_KEYPAD == RECORDER_PAD 621#elif CONFIG_KEYPAD == RECORDER_PAD
623 /* Set PB4 and PB8 as input pins */ 622 /* Set PB4 and PB8 as input pins */
624 PBCR1 &= 0xfffc; /* PB8MD = 00 */ 623 PBCR1 &= 0xfffc; /* PB8MD = 00 */
@@ -833,9 +832,14 @@ static int button_read(void)
833{ 832{
834 int btn = BUTTON_NONE; 833 int btn = BUTTON_NONE;
835 int retval; 834 int retval;
835#ifndef TARGET_TREE
836 int data; 836 int data;
837#endif
837 838
838#if (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD) 839#ifdef TARGET_TREE
840 btn = button_read_device();
841
842#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
839 static bool hold_button = false; 843 static bool hold_button = false;
840 static bool remote_hold_button = false; 844 static bool remote_hold_button = false;
841 static int prev_data = 0xff; 845 static int prev_data = 0xff;
@@ -1238,86 +1242,6 @@ static int button_read(void)
1238 (void)data; 1242 (void)data;
1239 btn = ipod_3g_button_read(); 1243 btn = ipod_3g_button_read();
1240 1244
1241#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)
1242 static bool hold_button = false;
1243 static bool remote_hold_button = false;
1244
1245 /* light handling */
1246 if (hold_button && !button_hold())
1247 {
1248 backlight_on();
1249 }
1250 /* TODO: add light handling for the remote */
1251
1252 hold_button = button_hold();
1253 remote_hold_button = remote_button_hold();
1254
1255 /* normal buttons */
1256 if (!hold_button)
1257 {
1258 data = adc_scan(ADC_BUTTONS);
1259 if (data < 0xf0)
1260 {
1261 if(data < 0x7c)
1262 if(data < 0x42)
1263 btn = BUTTON_LEFT;
1264 else
1265 if(data < 0x62)
1266 btn = BUTTON_RIGHT;
1267 else
1268 btn = BUTTON_SELECT;
1269 else
1270 if(data < 0xb6)
1271 if(data < 0x98)
1272 btn = BUTTON_REC;
1273 else
1274 btn = BUTTON_PLAY;
1275 else
1276 if(data < 0xd3)
1277 btn = BUTTON_DOWN;
1278 else
1279 btn = BUTTON_UP;
1280 }
1281 }
1282
1283 /* remote buttons */
1284 data = adc_scan(ADC_REMOTE);
1285 if(data < 0x17)
1286 remote_hold_button = true;
1287
1288 if(!remote_hold_button)
1289 {
1290 if (data < 0xee)
1291 {
1292 if(data < 0x7a)
1293 if(data < 0x41)
1294 btn |= BUTTON_RC_REW;
1295 else
1296 if(data < 0x61)
1297 btn |= BUTTON_RC_FF;
1298 else
1299 btn |= BUTTON_RC_MODE;
1300 else
1301 if(data < 0xb4)
1302 if(data < 0x96)
1303 btn |= BUTTON_RC_REC;
1304 else
1305 btn |= BUTTON_RC_MENU;
1306 else
1307 if(data < 0xd1)
1308 btn |= BUTTON_RC_VOL_UP;
1309 else
1310 btn |= BUTTON_RC_VOL_DOWN;
1311 }
1312 }
1313
1314 data = GPIO_READ;
1315 if (!(data & 0x04000000))
1316 btn |= BUTTON_POWER;
1317
1318 if (!(data & 0x02000000))
1319 btn |= BUTTON_RC_PLAY;
1320
1321#endif /* CONFIG_KEYPAD */ 1245#endif /* CONFIG_KEYPAD */
1322 1246
1323#ifdef HAVE_LCD_BITMAP 1247#ifdef HAVE_LCD_BITMAP
@@ -1375,18 +1299,6 @@ bool button_hold(void)
1375} 1299}
1376#endif 1300#endif
1377 1301
1378#if (CONFIG_KEYPAD == IAUDIO_X5_PAD)
1379bool button_hold(void)
1380{
1381 return (GPIO_READ & 0x08000000)?false:true;
1382}
1383
1384bool remote_button_hold(void)
1385{
1386 return false; /* TODO X5 */
1387}
1388#endif
1389
1390int button_status(void) 1302int button_status(void)
1391{ 1303{
1392 return lastbtn; 1304 return lastbtn;