summaryrefslogtreecommitdiff
path: root/firmware/target/arm/samsung/button-yh82x_yh92x.c
diff options
context:
space:
mode:
authorSzymon Dziok <b0hoon@o2.pl>2014-07-28 22:02:53 +0200
committerSzymon Dziok <b0hoon@o2.pl>2014-07-28 22:11:33 +0200
commit86fa139eac0493893e08769a82e3a0eb6ed7bc90 (patch)
tree09e559c5a51694122e4c1860cee03acfc34d24dd /firmware/target/arm/samsung/button-yh82x_yh92x.c
parent228c47be4cb2d6612f06b443597885cc431152c1 (diff)
downloadrockbox-86fa139eac0493893e08769a82e3a0eb6ed7bc90.tar.gz
rockbox-86fa139eac0493893e08769a82e3a0eb6ed7bc90.zip
Support for remote on Samsung YH920/YH925.bootloader_yh820_v1
Remote buttons are bound to the standard buttons in button-target.h, but they can have a separate buttonmap, if someone wants. Change-Id: Id8c78a3dfec0005bf588dc16416870b4c7c56836
Diffstat (limited to 'firmware/target/arm/samsung/button-yh82x_yh92x.c')
-rw-r--r--firmware/target/arm/samsung/button-yh82x_yh92x.c60
1 files changed, 59 insertions, 1 deletions
diff --git a/firmware/target/arm/samsung/button-yh82x_yh92x.c b/firmware/target/arm/samsung/button-yh82x_yh92x.c
index 1ed8089b90..2874a4a48a 100644
--- a/firmware/target/arm/samsung/button-yh82x_yh92x.c
+++ b/firmware/target/arm/samsung/button-yh82x_yh92x.c
@@ -22,11 +22,64 @@
22#include "system.h" 22#include "system.h"
23#include "button.h" 23#include "button.h"
24#include "backlight.h" 24#include "backlight.h"
25#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
26#include "adc.h"
25 27
28static int int_btn = BUTTON_NONE;
29
30void button_init_device(void)
31{
32 /* remote interrupt - low when key is pressed */
33 GPIOD_ENABLE |= 0x01;
34 GPIOD_OUTPUT_EN &= ~0x01;
35
36 /* disable/reset int */
37 GPIOD_INT_EN &= ~0x01;
38 GPIOD_INT_CLR |= 0x01;
39
40 /* enable int */
41 GPIOD_INT_LEV &= ~0x01;
42 GPIOD_INT_EN |= 0x01;
43
44 /* remote PLAY */
45 GPIOD_ENABLE |= 0x02;
46 GPIOD_OUTPUT_EN &= ~0x02;
47}
48
49/* Remote buttons */
50void remote_int(void)
51{
52 int state = 0x01 & ~GPIOD_INPUT_VAL;
53
54 GPIO_CLEAR_BITWISE(GPIOD_INT_EN, 0x01);
55 GPIO_WRITE_BITWISE(GPIOD_INT_LEV, state, 0x01);
56
57 if (state != 0)
58 {
59 /* necessary delay 1msec */
60 udelay(1000);
61 unsigned int val = adc_scan(ADC_REMOTE);
62 if (val > 750) int_btn = BUTTON_RC_MINUS;
63 else
64 if (val > 375) int_btn = BUTTON_RC_PLUS;
65 else
66 if (val > 100) int_btn = BUTTON_RC_REW;
67 else
68 int_btn = BUTTON_RC_FFWD;
69 }
70 else
71 int_btn = BUTTON_NONE;
72
73 GPIO_SET_BITWISE(GPIOD_INT_CLR, 0x01);
74 GPIO_SET_BITWISE(GPIOD_INT_EN, 0x01);
75}
76#else
26void button_init_device(void) 77void button_init_device(void)
27{ 78{
28 /* TODO...for now, hardware initialisation is done by the OF bootloader */ 79 /* nothing */
29} 80}
81#endif /* (SAMSUNG_YH920) || (SAMSUNG_YH925) */
82
30 83
31bool button_hold(void) 84bool button_hold(void)
32{ 85{
@@ -38,7 +91,11 @@ bool button_hold(void)
38 */ 91 */
39int button_read_device(void) 92int button_read_device(void)
40{ 93{
94#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
95 int btn = int_btn;
96#else
41 int btn = BUTTON_NONE; 97 int btn = BUTTON_NONE;
98#endif /* (SAMSUNG_YH920) || (SAMSUNG_YH925) */
42 static bool hold_button = false; 99 static bool hold_button = false;
43 bool hold_button_old; 100 bool hold_button_old;
44 101
@@ -65,6 +122,7 @@ int button_read_device(void)
65 if ( GPIOB_INPUT_VAL & 0x80) btn |= BUTTON_PLAY; 122 if ( GPIOB_INPUT_VAL & 0x80) btn |= BUTTON_PLAY;
66#elif defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) 123#elif defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925)
67 if ( GPIOD_INPUT_VAL & 0x04) btn |= BUTTON_PLAY; 124 if ( GPIOD_INPUT_VAL & 0x04) btn |= BUTTON_PLAY;
125 if ( GPIOD_INPUT_VAL & 0x02) btn |= BUTTON_RC_PLAY; /* Remote PLAY */
68#endif 126#endif
69 } 127 }
70 128