diff options
author | Szymon Dziok <b0hoon@o2.pl> | 2014-07-28 22:02:53 +0200 |
---|---|---|
committer | Szymon Dziok <b0hoon@o2.pl> | 2014-07-28 22:11:33 +0200 |
commit | 86fa139eac0493893e08769a82e3a0eb6ed7bc90 (patch) | |
tree | 09e559c5a51694122e4c1860cee03acfc34d24dd | |
parent | 228c47be4cb2d6612f06b443597885cc431152c1 (diff) | |
download | rockbox-86fa139.tar.gz rockbox-86fa139.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
-rw-r--r-- | firmware/target/arm/pp/system-pp502x.c | 4 | ||||
-rw-r--r-- | firmware/target/arm/samsung/adc-target.h | 8 | ||||
-rw-r--r-- | firmware/target/arm/samsung/button-target.h | 10 | ||||
-rw-r--r-- | firmware/target/arm/samsung/button-yh82x_yh92x.c | 60 |
4 files changed, 75 insertions, 7 deletions
diff --git a/firmware/target/arm/pp/system-pp502x.c b/firmware/target/arm/pp/system-pp502x.c index 697b52cf51..99b536e132 100644 --- a/firmware/target/arm/pp/system-pp502x.c +++ b/firmware/target/arm/pp/system-pp502x.c @@ -154,6 +154,10 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOD_INT_STAT & 0x10) usb_insert_int(); +#if !defined(SAMSUNG_YH820) + if (GPIOD_INT_STAT & 0x01) + remote_int(); +#endif } /* end SAMSUNG_YHxxx */ #elif defined(PBELL_VIBE500) diff --git a/firmware/target/arm/samsung/adc-target.h b/firmware/target/arm/samsung/adc-target.h index 1f6a9dcb17..9cca223804 100644 --- a/firmware/target/arm/samsung/adc-target.h +++ b/firmware/target/arm/samsung/adc-target.h @@ -28,14 +28,10 @@ #define ADC_CHANNEL_2 2 #define ADC_CHANNEL_3 3 +#define ADC_REMOTE ADC_CHANNEL_0 #define ADC_BATTERY ADC_CHANNEL_1 -/* -#define ADC_UNKNOWN_1 1 -#define ADC_REMOTE 2 -#define ADC_SCROLLPAD 3 -*/ -#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ +#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ /* Force a scan now */ unsigned short adc_scan(int channel); diff --git a/firmware/target/arm/samsung/button-target.h b/firmware/target/arm/samsung/button-target.h index 61561dc86d..400c4ed768 100644 --- a/firmware/target/arm/samsung/button-target.h +++ b/firmware/target/arm/samsung/button-target.h @@ -26,6 +26,10 @@ /* Button codes for Samsung YH-820, 920, 925 */ +#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) +void remote_int(void); +#endif /* (SAMSUNG_YH920) || (SAMSUNG_YH925) */ + /* Main unit's buttons */ /* Left = Menu, Right = Sel */ #define BUTTON_LEFT 0x00000001 @@ -39,6 +43,12 @@ #define BUTTON_MAIN 0x000000ff +#define BUTTON_RC_PLUS BUTTON_UP +#define BUTTON_RC_MINUS BUTTON_DOWN +#define BUTTON_RC_PLAY BUTTON_PLAY +#define BUTTON_RC_REW BUTTON_REW +#define BUTTON_RC_FFWD BUTTON_FFWD + #define POWEROFF_BUTTON BUTTON_PLAY #define POWEROFF_COUNT 15 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 @@ #include "system.h" #include "button.h" #include "backlight.h" +#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) +#include "adc.h" +static int int_btn = BUTTON_NONE; + +void button_init_device(void) +{ + /* remote interrupt - low when key is pressed */ + GPIOD_ENABLE |= 0x01; + GPIOD_OUTPUT_EN &= ~0x01; + + /* disable/reset int */ + GPIOD_INT_EN &= ~0x01; + GPIOD_INT_CLR |= 0x01; + + /* enable int */ + GPIOD_INT_LEV &= ~0x01; + GPIOD_INT_EN |= 0x01; + + /* remote PLAY */ + GPIOD_ENABLE |= 0x02; + GPIOD_OUTPUT_EN &= ~0x02; +} + +/* Remote buttons */ +void remote_int(void) +{ + int state = 0x01 & ~GPIOD_INPUT_VAL; + + GPIO_CLEAR_BITWISE(GPIOD_INT_EN, 0x01); + GPIO_WRITE_BITWISE(GPIOD_INT_LEV, state, 0x01); + + if (state != 0) + { + /* necessary delay 1msec */ + udelay(1000); + unsigned int val = adc_scan(ADC_REMOTE); + if (val > 750) int_btn = BUTTON_RC_MINUS; + else + if (val > 375) int_btn = BUTTON_RC_PLUS; + else + if (val > 100) int_btn = BUTTON_RC_REW; + else + int_btn = BUTTON_RC_FFWD; + } + else + int_btn = BUTTON_NONE; + + GPIO_SET_BITWISE(GPIOD_INT_CLR, 0x01); + GPIO_SET_BITWISE(GPIOD_INT_EN, 0x01); +} +#else void button_init_device(void) { - /* TODO...for now, hardware initialisation is done by the OF bootloader */ + /* nothing */ } +#endif /* (SAMSUNG_YH920) || (SAMSUNG_YH925) */ + bool button_hold(void) { @@ -38,7 +91,11 @@ bool button_hold(void) */ int button_read_device(void) { +#if defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) + int btn = int_btn; +#else int btn = BUTTON_NONE; +#endif /* (SAMSUNG_YH920) || (SAMSUNG_YH925) */ static bool hold_button = false; bool hold_button_old; @@ -65,6 +122,7 @@ int button_read_device(void) if ( GPIOB_INPUT_VAL & 0x80) btn |= BUTTON_PLAY; #elif defined(SAMSUNG_YH920) || defined(SAMSUNG_YH925) if ( GPIOD_INPUT_VAL & 0x04) btn |= BUTTON_PLAY; + if ( GPIOD_INPUT_VAL & 0x02) btn |= BUTTON_RC_PLAY; /* Remote PLAY */ #endif } |