diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-12-25 04:05:01 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-12-25 04:05:01 +0000 |
commit | 6908cc52358df90a27452ab0f085fa41674440ff (patch) | |
tree | 32c307c3164e24ad427ac98b389bad823c363034 /firmware/target/arm/philips/hdd6330/button-hdd6330.c | |
parent | 4a85eb7d9f7212bf2a0974fa42c2cb4f1790f99e (diff) | |
download | rockbox-6908cc52358df90a27452ab0f085fa41674440ff.tar.gz rockbox-6908cc52358df90a27452ab0f085fa41674440ff.zip |
Merry Christmas Gogear HDD6330 owners! This is the start of the HDD6330 port. At the moment, it's essentially a copy of the HDD1630 port with a minimal LCD driver. The touchpad doesn't work as expected, but you can still kind of navigate and listen to music/radio.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24112 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/philips/hdd6330/button-hdd6330.c')
-rw-r--r-- | firmware/target/arm/philips/hdd6330/button-hdd6330.c | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/hdd6330/button-hdd6330.c b/firmware/target/arm/philips/hdd6330/button-hdd6330.c new file mode 100644 index 0000000000..ab06c0cf1a --- /dev/null +++ b/firmware/target/arm/philips/hdd6330/button-hdd6330.c | |||
@@ -0,0 +1,125 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 by Mark Arigo | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "system.h" | ||
23 | #include "button.h" | ||
24 | #include "backlight.h" | ||
25 | #include "synaptics-mep.h" | ||
26 | |||
27 | /*#define LOGF_ENABLE*/ | ||
28 | #include "logf.h" | ||
29 | |||
30 | static int int_btn = BUTTON_NONE; | ||
31 | |||
32 | /* | ||
33 | * Generate a click sound from the player (not in headphones yet) | ||
34 | * TODO: integrate this with the "key click" option | ||
35 | */ | ||
36 | void button_click(void) | ||
37 | { | ||
38 | GPO32_ENABLE |= 0x2000; | ||
39 | GPO32_VAL |= 0x2000; | ||
40 | udelay(1000); | ||
41 | GPO32_VAL &= ~0x2000; | ||
42 | } | ||
43 | |||
44 | #ifndef BOOTLOADER | ||
45 | void button_init_device(void) | ||
46 | { | ||
47 | /* The touchpad is powered on and initialized in power-hdd1630.c | ||
48 | since it needs to be ready for both buttons and button lights. */ | ||
49 | } | ||
50 | |||
51 | /* | ||
52 | * Button interrupt handler | ||
53 | */ | ||
54 | void button_int(void) | ||
55 | { | ||
56 | char data[4]; | ||
57 | int val; | ||
58 | |||
59 | int_btn = BUTTON_NONE; | ||
60 | |||
61 | val = touchpad_read_device(data, 4); | ||
62 | |||
63 | if (val == MEP_BUTTON_HEADER) | ||
64 | { | ||
65 | /* Buttons packet */ | ||
66 | if (data[1] & 0x1) | ||
67 | int_btn |= BUTTON_LEFT; | ||
68 | if (data[1] & 0x2) | ||
69 | int_btn |= BUTTON_RIGHT; | ||
70 | } | ||
71 | else if (val == MEP_ABSOLUTE_HEADER) | ||
72 | { | ||
73 | /* Absolute packet - the finger is on the vertical strip. | ||
74 | Position ranges from 1-4095, with 1 at the bottom. */ | ||
75 | val = ((data[1] >> 4) << 8) | data[2]; /* position */ | ||
76 | |||
77 | if ((val > 0) && (val <= 1365)) | ||
78 | int_btn |= BUTTON_DOWN; | ||
79 | else if ((val > 1365) && (val <= 2730)) | ||
80 | int_btn |= BUTTON_SELECT; | ||
81 | else if ((val > 2730) && (val <= 4095)) | ||
82 | int_btn |= BUTTON_UP; | ||
83 | } | ||
84 | } | ||
85 | #else | ||
86 | void button_init_device(void){} | ||
87 | #endif /* bootloader */ | ||
88 | |||
89 | bool button_hold(void) | ||
90 | { | ||
91 | return !(GPIOJ_INPUT_VAL & 0x8); | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Get button pressed from hardware | ||
96 | */ | ||
97 | int button_read_device(void) | ||
98 | { | ||
99 | static int btn_old = BUTTON_NONE; | ||
100 | int btn = int_btn; | ||
101 | |||
102 | /* Hold */ | ||
103 | if(button_hold()) | ||
104 | return BUTTON_NONE; | ||
105 | |||
106 | /* Device buttons */ | ||
107 | if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU; | ||
108 | if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; | ||
109 | if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; | ||
110 | if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_VIEW; | ||
111 | if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_PLAYLIST; | ||
112 | if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; | ||
113 | |||
114 | if ((btn != btn_old) && (btn != BUTTON_NONE)) | ||
115 | button_click(); | ||
116 | |||
117 | btn_old = btn; | ||
118 | |||
119 | return btn; | ||
120 | } | ||
121 | |||
122 | bool headphones_inserted(void) | ||
123 | { | ||
124 | return (GPIOE_INPUT_VAL & 0x80) ? true : false; | ||
125 | } | ||