diff options
Diffstat (limited to 'firmware/target/arm/samsung/button-yh82x_yh92x.c')
-rw-r--r-- | firmware/target/arm/samsung/button-yh82x_yh92x.c | 60 |
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 | ||
28 | static int int_btn = BUTTON_NONE; | ||
29 | |||
30 | void 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 */ | ||
50 | void 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 | ||
26 | void button_init_device(void) | 77 | void 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 | ||
31 | bool button_hold(void) | 84 | bool button_hold(void) |
32 | { | 85 | { |
@@ -38,7 +91,11 @@ bool button_hold(void) | |||
38 | */ | 91 | */ |
39 | int button_read_device(void) | 92 | int 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 | ||