From 86fa139eac0493893e08769a82e3a0eb6ed7bc90 Mon Sep 17 00:00:00 2001 From: Szymon Dziok Date: Mon, 28 Jul 2014 22:02:53 +0200 Subject: Support for remote on Samsung YH920/YH925. 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 --- firmware/target/arm/samsung/adc-target.h | 8 +--- firmware/target/arm/samsung/button-target.h | 10 ++++ firmware/target/arm/samsung/button-yh82x_yh92x.c | 60 +++++++++++++++++++++++- 3 files changed, 71 insertions(+), 7 deletions(-) (limited to 'firmware/target/arm/samsung') 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 } -- cgit v1.2.3