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
This commit is contained in:
Szymon Dziok 2014-07-28 22:02:53 +02:00
parent 228c47be4c
commit 86fa139eac
4 changed files with 75 additions and 7 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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

View file

@ -22,12 +22,65 @@
#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)
{
/* TODO...for now, hardware initialisation is done by the OF bootloader */
/* 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)
{
/* nothing */
}
#endif /* (SAMSUNG_YH920) || (SAMSUNG_YH925) */
bool button_hold(void)
{
return (~GPIOA_INPUT_VAL & 0x1);
@ -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
}