summaryrefslogtreecommitdiff
path: root/firmware/target/arm
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm')
-rw-r--r--firmware/target/arm/philips/sa9200/backlight-sa9200.c23
-rw-r--r--firmware/target/arm/philips/sa9200/backlight-target.h3
-rwxr-xr-xfirmware/target/arm/philips/sa9200/button-sa9200.c79
-rwxr-xr-xfirmware/target/arm/philips/sa9200/button-target.h10
-rw-r--r--firmware/target/arm/philips/sa9200/power-sa9200.c40
5 files changed, 124 insertions, 31 deletions
diff --git a/firmware/target/arm/philips/sa9200/backlight-sa9200.c b/firmware/target/arm/philips/sa9200/backlight-sa9200.c
index a0acaa0abd..22aae1ae6b 100644
--- a/firmware/target/arm/philips/sa9200/backlight-sa9200.c
+++ b/firmware/target/arm/philips/sa9200/backlight-sa9200.c
@@ -21,10 +21,10 @@
21#include "config.h" 21#include "config.h"
22#include "backlight-target.h" 22#include "backlight-target.h"
23#include "system.h" 23#include "system.h"
24#include "lcd.h"
25#include "backlight.h" 24#include "backlight.h"
26#include "ascodec.h" 25#include "ascodec.h"
27#include "as3514.h" 26#include "as3514.h"
27#include "synaptics-mep.h"
28 28
29void _backlight_set_brightness(int brightness) 29void _backlight_set_brightness(int brightness)
30{ 30{
@@ -51,12 +51,29 @@ void _backlight_off(void)
51#endif 51#endif
52} 52}
53 53
54#ifdef HAVE_BUTTON_LIGHT
55
56#define BUTTONLIGHT_MASK 0x7f
57#define BUTTONLIGHT_MAX 0x0f
58static unsigned short buttonlight_status = 0;
59
54void _buttonlight_on(void) 60void _buttonlight_on(void)
55{ 61{
56 /* TODO */ 62 if (!buttonlight_status)
63 {
64 touchpad_set_buttonlights(BUTTONLIGHT_MASK, BUTTONLIGHT_MAX);
65 GPIOD_OUTPUT_VAL &= ~(0x40 | 0x20 | 0x04); /* REW/FFWD/MENU */
66 buttonlight_status = 1;
67 }
57} 68}
58 69
59void _buttonlight_off(void) 70void _buttonlight_off(void)
60{ 71{
61 /* TODO */ 72 if (buttonlight_status)
73 {
74 touchpad_set_buttonlights(BUTTONLIGHT_MASK, 0);
75 GPIOD_OUTPUT_VAL |= (0x40 | 0x20 | 0x04); /* REW/FFWD/MENU */
76 buttonlight_status = 0;
77 }
62} 78}
79#endif
diff --git a/firmware/target/arm/philips/sa9200/backlight-target.h b/firmware/target/arm/philips/sa9200/backlight-target.h
index 21fad6d22e..9d695e5a22 100644
--- a/firmware/target/arm/philips/sa9200/backlight-target.h
+++ b/firmware/target/arm/philips/sa9200/backlight-target.h
@@ -27,6 +27,9 @@ void _backlight_off(void);
27void _backlight_set_brightness(int brightness); 27void _backlight_set_brightness(int brightness);
28int __backlight_is_on(void); 28int __backlight_is_on(void);
29 29
30#ifdef HAVE_BUTTON_LIGHT
30void _buttonlight_on(void); 31void _buttonlight_on(void);
31void _buttonlight_off(void); 32void _buttonlight_off(void);
32#endif 33#endif
34
35#endif
diff --git a/firmware/target/arm/philips/sa9200/button-sa9200.c b/firmware/target/arm/philips/sa9200/button-sa9200.c
index d965966075..be37111ecb 100755
--- a/firmware/target/arm/philips/sa9200/button-sa9200.c
+++ b/firmware/target/arm/philips/sa9200/button-sa9200.c
@@ -22,11 +22,58 @@
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#include "synaptics-mep.h"
25 26
27#define LOGF_ENABLE
28#include "logf.h"
29
30static int int_btn = BUTTON_NONE;
31
32#ifndef BOOTLOADER
26void button_init_device(void) 33void button_init_device(void)
27{ 34{
28 /* TODO...for now, hardware initialisation is done by the c200 bootloader */ 35 /* The touchpad is powered on and initialized in power-sa9200.c
36 since it needs to be ready for both buttons and button lights. */
37}
38
39/*
40 * Button interrupt handler
41 */
42void button_int(void)
43{
44 char data[4];
45 int val;
46
47 int_btn = BUTTON_NONE;
48
49 val = touchpad_read_device(data, 4);
50
51 if (val == MEP_BUTTON_HEADER)
52 {
53 /* Buttons packet */
54 if (data[1] & 0x1) int_btn |= BUTTON_FFWD;
55 if (data[1] & 0x2) int_btn |= BUTTON_RIGHT;
56 if (data[1] & 0x4) int_btn |= BUTTON_LEFT;
57 if (data[1] & 0x8) int_btn |= BUTTON_REW;
58 if (data[2] & 0x1) int_btn |= BUTTON_MENU;
59 }
60 else if (val == MEP_ABSOLUTE_HEADER)
61 {
62 /* Absolute packet - the finger is on the vertical strip.
63 Position ranges from 1-4095, with 1 at the bottom. */
64 val = ((data[1] >> 4) << 8) | data[2]; /* position */
65
66 if ((val > 0) && (val <= 1365))
67 int_btn |= BUTTON_DOWN;
68 else if ((val > 1365) && (val <= 2730))
69 int_btn |= BUTTON_PLAY;
70 else if ((val > 2730) && (val <= 4095))
71 int_btn |= BUTTON_UP;
72 }
29} 73}
74#else
75void button_init_device(void){}
76#endif /* bootloader */
30 77
31bool button_hold(void) 78bool button_hold(void)
32{ 79{
@@ -38,32 +85,14 @@ bool button_hold(void)
38 */ 85 */
39int button_read_device(void) 86int button_read_device(void)
40{ 87{
41 int btn = BUTTON_NONE; 88 int btn = int_btn;
42 static bool hold_button = false;
43 bool hold_button_old;
44
45 /* Hold */
46 hold_button_old = hold_button;
47 hold_button = button_hold();
48 89
49#ifndef BOOTLOADER 90 if (button_hold())
50 if (hold_button != hold_button_old) 91 return BUTTON_NONE;
51 backlight_hold_changed(hold_button);
52#endif
53 92
54 /* device buttons */ 93 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER;
55 if (!hold_button) 94 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP;
56 { 95 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN;
57#if 0
58 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER;
59 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP;
60 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN;
61#endif
62 /* A hack until the touchpad works */
63 if (!(GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT;
64 if (!(GPIOF_INPUT_VAL & 0x10)) btn |= BUTTON_UP;
65 if (!(GPIOF_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN;
66 }
67 96
68 return btn; 97 return btn;
69} 98}
diff --git a/firmware/target/arm/philips/sa9200/button-target.h b/firmware/target/arm/philips/sa9200/button-target.h
index 0d691506d2..6259aa0737 100755
--- a/firmware/target/arm/philips/sa9200/button-target.h
+++ b/firmware/target/arm/philips/sa9200/button-target.h
@@ -25,15 +25,23 @@
25#include <stdbool.h> 25#include <stdbool.h>
26#include "config.h" 26#include "config.h"
27 27
28#define MEP_BUTTON_HEADER 0x1a
29#define MEP_BUTTON_ID 0x09
30#define MEP_ABSOLUTE_HEADER 0x0b
31
28#define HAS_BUTTON_HOLD 32#define HAS_BUTTON_HOLD
29 33
30bool button_hold(void); 34bool button_hold(void);
31void button_init_device(void); 35void button_init_device(void);
32int button_read_device(void); 36int button_read_device(void);
33 37
38#ifndef BOOTLOADER
39void button_int(void);
40#endif
41
34/* Main unit's buttons */ 42/* Main unit's buttons */
35#define BUTTON_POWER 0x00000001 43#define BUTTON_POWER 0x00000001
36#define BUTTON_SELECT 0x00000002 44#define BUTTON_PLAY 0x00000002
37#define BUTTON_MENU 0x00000004 45#define BUTTON_MENU 0x00000004
38#define BUTTON_LEFT 0x00000008 46#define BUTTON_LEFT 0x00000008
39#define BUTTON_RIGHT 0x00000010 47#define BUTTON_RIGHT 0x00000010
diff --git a/firmware/target/arm/philips/sa9200/power-sa9200.c b/firmware/target/arm/philips/sa9200/power-sa9200.c
index cf9468cb1d..5da1fc5fc4 100644
--- a/firmware/target/arm/philips/sa9200/power-sa9200.c
+++ b/firmware/target/arm/philips/sa9200/power-sa9200.c
@@ -22,14 +22,50 @@
22#include <stdbool.h> 22#include <stdbool.h>
23#include "system.h" 23#include "system.h"
24#include "cpu.h" 24#include "cpu.h"
25#include "i2c-pp.h"
26#include "tuner.h"
27#include "ascodec.h" 25#include "ascodec.h"
28#include "as3514.h" 26#include "as3514.h"
29#include "power.h" 27#include "power.h"
28#include "synaptics-mep.h"
29#include "logf.h"
30 30
31void power_init(void) 31void power_init(void)
32{ 32{
33#ifndef BOOTLOADER
34 /* Power on and initialize the touchpad here because we need it for
35 both buttons and button lights */
36 DEV_INIT2 &= ~0x800;
37
38 char byte = ascodec_read(AS3514_CVDD_DCDC3);
39 byte = (byte & ~0x18) | 0x08;
40 ascodec_write(AS3514_CVDD_DCDC3, byte);
41
42 /* LEDs for REW, FFWD, MENU */
43 GPIOD_ENABLE |= (0x40 | 0x20 | 0x04);
44 GPIOD_OUTPUT_VAL |= (0x40 | 0x20 | 0x04);
45 GPIOD_OUTPUT_EN |= (0x40 | 0x20 | 0x04);
46 udelay(20000);
47
48 GPIOL_ENABLE |= 0x10;
49 GPIOL_OUTPUT_VAL &= ~0x10;
50 GPIOL_OUTPUT_EN |= 0x10;
51 udelay(100000);
52
53 /* enable DATA, ACK, CLK lines */
54 GPIOD_ENABLE |= (0x10 | 0x08 | 0x02);
55
56 GPIOD_OUTPUT_EN |= 0x08; /* ACK */
57 GPIOD_OUTPUT_VAL |= 0x08; /* high */
58
59 GPIOD_OUTPUT_EN &= ~0x02; /* CLK */
60
61 GPIOD_OUTPUT_EN |= 0x10; /* DATA */
62 GPIOD_OUTPUT_VAL |= 0x10; /* high */
63
64 if (!touchpad_init())
65 {
66 logf("touchpad not ready");
67 }
68#endif
33} 69}
34 70
35void power_off(void) 71void power_off(void)