diff options
Diffstat (limited to 'firmware/target/arm/olympus/mrobe-100/button-mr100.c')
-rw-r--r-- | firmware/target/arm/olympus/mrobe-100/button-mr100.c | 72 |
1 files changed, 66 insertions, 6 deletions
diff --git a/firmware/target/arm/olympus/mrobe-100/button-mr100.c b/firmware/target/arm/olympus/mrobe-100/button-mr100.c index d4479278ef..e7979a4174 100644 --- a/firmware/target/arm/olympus/mrobe-100/button-mr100.c +++ b/firmware/target/arm/olympus/mrobe-100/button-mr100.c | |||
@@ -25,6 +25,12 @@ | |||
25 | #include "backlight-target.h" | 25 | #include "backlight-target.h" |
26 | #include "synaptics-mep.h" | 26 | #include "synaptics-mep.h" |
27 | 27 | ||
28 | #ifdef HAVE_REMOTE_LCD | ||
29 | #include "lcd-remote-target.h" | ||
30 | static bool remote_hold = false; | ||
31 | static bool headphones_status = true; | ||
32 | #endif | ||
33 | |||
28 | #define LOGF_ENABLE | 34 | #define LOGF_ENABLE |
29 | #include "logf.h" | 35 | #include "logf.h" |
30 | 36 | ||
@@ -56,6 +62,13 @@ void button_init_device(void) | |||
56 | { | 62 | { |
57 | logf("touchpad not ready"); | 63 | logf("touchpad not ready"); |
58 | } | 64 | } |
65 | |||
66 | /* headphone detection bit */ | ||
67 | GPIOD_OUTPUT_EN &= ~0x80; | ||
68 | GPIOD_ENABLE |= 0x80; | ||
69 | |||
70 | /* remote detection (via headphone state) */ | ||
71 | headphones_int(); | ||
59 | } | 72 | } |
60 | 73 | ||
61 | /* | 74 | /* |
@@ -102,13 +115,35 @@ void button_init_device(void){} | |||
102 | */ | 115 | */ |
103 | int button_read_device(void) | 116 | int button_read_device(void) |
104 | { | 117 | { |
105 | int btn = int_btn; | 118 | int btn = BUTTON_NONE; |
106 | 119 | ||
107 | if(button_hold()) | 120 | #ifdef HAVE_REMOTE_LCD |
108 | return BUTTON_NONE; | 121 | unsigned char data[5]; |
109 | 122 | ||
110 | if (~GPIOA_INPUT_VAL & 0x40) | 123 | if (lcd_remote_read_device(data)) |
111 | btn |= BUTTON_POWER; | 124 | { |
125 | remote_hold = (data[2] & 0x80) ? true : false; | ||
126 | if (!remote_hold) | ||
127 | { | ||
128 | if (data[1] & 0x1) btn |= BUTTON_RC_PLAY; | ||
129 | if (data[1] & 0x2) btn |= BUTTON_RC_DOWN; | ||
130 | if (data[1] & 0x4) btn |= BUTTON_RC_FF; | ||
131 | if (data[1] & 0x8) btn |= BUTTON_RC_REW; | ||
132 | if (data[1] & 0x10) btn |= BUTTON_RC_VOL_UP; | ||
133 | if (data[1] & 0x20) btn |= BUTTON_RC_VOL_DOWN; | ||
134 | if (data[1] & 0x40) btn |= BUTTON_RC_MODE; | ||
135 | if (data[1] & 0x80) btn |= BUTTON_RC_HEART; | ||
136 | } | ||
137 | } | ||
138 | #endif | ||
139 | |||
140 | if(!button_hold()) | ||
141 | { | ||
142 | btn |= int_btn; | ||
143 | |||
144 | if (~GPIOA_INPUT_VAL & 0x40) | ||
145 | btn |= BUTTON_POWER; | ||
146 | } | ||
112 | 147 | ||
113 | return btn; | 148 | return btn; |
114 | } | 149 | } |
@@ -118,7 +153,32 @@ bool button_hold(void) | |||
118 | return (GPIOD_INPUT_VAL & 0x10) ? false : true; | 153 | return (GPIOD_INPUT_VAL & 0x10) ? false : true; |
119 | } | 154 | } |
120 | 155 | ||
156 | #ifdef HAVE_REMOTE_LCD | ||
157 | bool remote_button_hold(void) | ||
158 | { | ||
159 | return remote_hold; | ||
160 | } | ||
161 | |||
162 | bool headphones_inserted(void) | ||
163 | { | ||
164 | return headphones_status; | ||
165 | } | ||
166 | |||
167 | void headphones_int(void) | ||
168 | { | ||
169 | int state = 0x80 & ~GPIOD_INPUT_VAL; | ||
170 | headphones_status = (state) ? true : false; | ||
171 | |||
172 | GPIO_CLEAR_BITWISE(GPIOD_INT_EN, 0x80); | ||
173 | GPIO_WRITE_BITWISE(GPIOD_INT_LEV, state, 0x80); | ||
174 | GPIO_WRITE_BITWISE(GPIOD_INT_CLR, 0x80, 0x80); | ||
175 | GPIO_SET_BITWISE(GPIOD_INT_EN, 0x80); | ||
176 | |||
177 | lcd_remote_on(); | ||
178 | } | ||
179 | #else | ||
121 | bool headphones_inserted(void) | 180 | bool headphones_inserted(void) |
122 | { | 181 | { |
123 | return (GPIOD_INPUT_VAL & 0x80) ? false : true; | 182 | return (GPIOD_INPUT_VAL & 0x80) ? false : true; |
124 | } | 183 | } |
184 | #endif | ||