forked from len0rd/rockbox
Backlight brightness and button lights for the Philips HDD1630
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20035 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
42ef5b0c88
commit
f34cd80f63
8 changed files with 156 additions and 93 deletions
|
@ -33,6 +33,9 @@
|
|||
Protocol: 3-Wire Interface Specification" documentation */
|
||||
|
||||
#if defined(MROBE_100)
|
||||
#define INT_ENABLE GPIOD_INT_LEV &= ~0x2; GPIOD_INT_EN |= 0x2
|
||||
#define INT_DISABLE GPIOD_INT_EN &= ~0x2; GPIOD_INT_CLR |= 0x2
|
||||
|
||||
#define ACK (GPIOD_INPUT_VAL & 0x1)
|
||||
#define ACK_HI GPIOD_OUTPUT_VAL |= 0x1
|
||||
#define ACK_LO GPIOD_OUTPUT_VAL &= ~0x1
|
||||
|
@ -47,6 +50,9 @@
|
|||
#define DATA_CL GPIOD_OUTPUT_EN &= ~0x4
|
||||
|
||||
#elif defined(PHILIPS_HDD1630)
|
||||
#define INT_ENABLE GPIOA_INT_LEV &= ~0x20; GPIOA_INT_EN |= 0x20
|
||||
#define INT_DISABLE GPIOA_INT_EN &= ~0x20; GPIOA_INT_CLR |= 0x20
|
||||
|
||||
#define ACK (GPIOD_INPUT_VAL & 0x80)
|
||||
#define ACK_HI GPIOD_OUTPUT_VAL |= 0x80
|
||||
#define ACK_LO GPIOD_OUTPUT_VAL &= ~0x80
|
||||
|
@ -73,6 +79,8 @@
|
|||
#define MEP_READ 0x1
|
||||
#define MEP_WRITE 0x3
|
||||
|
||||
static unsigned short syn_status = 0;
|
||||
|
||||
static int syn_wait_clk_change(unsigned int val)
|
||||
{
|
||||
int i;
|
||||
|
@ -140,12 +148,12 @@ static void syn_flush(void)
|
|||
syn_wait_guest_flush();
|
||||
}
|
||||
|
||||
static int syn_send_data(int *data, int len)
|
||||
int syn_send(int *data, int len)
|
||||
{
|
||||
int i, bit;
|
||||
int parity = 0;
|
||||
|
||||
logf("syn_send_data...");
|
||||
logf("syn_send...");
|
||||
|
||||
/* 1. Lower DATA line to issue a request-to-send to guest */
|
||||
DATA_LO;
|
||||
|
@ -380,7 +388,7 @@ static int syn_read_data(int *data, int data_len)
|
|||
return len;
|
||||
}
|
||||
|
||||
int syn_read_device(int *data, int len)
|
||||
int syn_read(int *data, int len)
|
||||
{
|
||||
int i;
|
||||
int ret = READ_ERROR;
|
||||
|
@ -406,7 +414,7 @@ int syn_read_device(int *data, int len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int syn_reset(void)
|
||||
int syn_reset(void)
|
||||
{
|
||||
int val, id;
|
||||
int data[2];
|
||||
|
@ -415,9 +423,9 @@ static int syn_reset(void)
|
|||
|
||||
/* reset module 0 */
|
||||
val = (0 << 4) | (1 << 3) | 0;
|
||||
syn_send_data(&val, 1);
|
||||
syn_send(&val, 1);
|
||||
|
||||
val = syn_read_device(data, 2);
|
||||
val = syn_read(data, 2);
|
||||
if (val == 1)
|
||||
{
|
||||
val = data[0] & 0xff; /* packet header */
|
||||
|
@ -436,7 +444,35 @@ static int syn_reset(void)
|
|||
int syn_init(void)
|
||||
{
|
||||
syn_flush();
|
||||
return syn_reset();
|
||||
syn_status = syn_reset();
|
||||
|
||||
if (syn_status)
|
||||
{
|
||||
INT_DISABLE;
|
||||
INT_ENABLE;
|
||||
|
||||
CPU_INT_EN |= HI_MASK;
|
||||
CPU_HI_INT_EN |= GPIO0_MASK;
|
||||
}
|
||||
|
||||
return syn_status;
|
||||
}
|
||||
|
||||
int syn_get_status(void)
|
||||
{
|
||||
return syn_status;
|
||||
}
|
||||
|
||||
void syn_int_enable(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
INT_ENABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
INT_DISABLE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ROCKBOX_HAS_LOGF
|
||||
|
@ -451,8 +487,8 @@ void syn_info(void)
|
|||
logf("module base info:");
|
||||
data[0] = MEP_READ;
|
||||
data[1] = 0x80;
|
||||
syn_send_data(data, 2);
|
||||
val = syn_read_device(data, 8);
|
||||
syn_send(data, 2);
|
||||
val = syn_read(data, 8);
|
||||
if (val > 0)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
|
@ -463,8 +499,8 @@ void syn_info(void)
|
|||
logf("module product info:");
|
||||
data[0] = MEP_READ;
|
||||
data[1] = 0x81;
|
||||
syn_send_data(data, 2);
|
||||
val = syn_read_device(data, 8);
|
||||
syn_send(data, 2);
|
||||
val = syn_read(data, 8);
|
||||
if (val > 0)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
|
@ -475,8 +511,8 @@ void syn_info(void)
|
|||
logf("module serialization:");
|
||||
data[0] = MEP_READ;
|
||||
data[1] = 0x82;
|
||||
syn_send_data(data, 2);
|
||||
val = syn_read_device(data, 8);
|
||||
syn_send(data, 2);
|
||||
val = syn_read(data, 8);
|
||||
if (val > 0)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
|
@ -487,8 +523,8 @@ void syn_info(void)
|
|||
logf("1-d sensor info:");
|
||||
data[0] = MEP_READ;
|
||||
data[1] = 0x80 + 0x20;
|
||||
syn_send_data(data, 2);
|
||||
val = syn_read_device(data, 8);
|
||||
syn_send(data, 2);
|
||||
val = syn_read(data, 8);
|
||||
if (val > 0)
|
||||
{
|
||||
for (i = 0; i < 8; i++)
|
||||
|
|
|
@ -108,15 +108,17 @@
|
|||
|
||||
/* Define this for LCD backlight available */
|
||||
#define HAVE_BACKLIGHT
|
||||
/* #define HAVE_BACKLIGHT_BRIGHTNESS */
|
||||
#define HAVE_BACKLIGHT_BRIGHTNESS
|
||||
/* #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING */
|
||||
|
||||
/* Main LCD backlight brightness range and defaults */
|
||||
#define MIN_BRIGHTNESS_SETTING 1
|
||||
#define MAX_BRIGHTNESS_SETTING 12
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 6
|
||||
#define MAX_BRIGHTNESS_SETTING 16
|
||||
#define DEFAULT_BRIGHTNESS_SETTING 13 /* match OF brightness */
|
||||
|
||||
/* define this if you have a light associated with the buttons */
|
||||
/* #define HAVE_BUTTON_LIGHT */
|
||||
#define HAVE_BUTTON_LIGHT
|
||||
#define HAVE_BUTTONLIGHT_BRIGHTNESS
|
||||
|
||||
#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
|
||||
#define BATTERY_CAPACITY_MIN 630 /* min. capacity selectable */
|
||||
|
|
|
@ -18,10 +18,13 @@
|
|||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef SYNAPTICS_MEP_H
|
||||
#define SYNAPTICS_MEP_H
|
||||
|
||||
int syn_init(void);
|
||||
int syn_read_device(int *data, int len);
|
||||
int syn_init(void);
|
||||
int syn_get_status(void);
|
||||
void syn_int_enable(bool enable);
|
||||
int syn_read(int *data, int len);
|
||||
int syn_send(int *data, int len);
|
||||
|
||||
#ifdef ROCKBOX_HAS_LOGF
|
||||
void syn_info(void);
|
||||
#endif
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
static int int_btn = BUTTON_NONE;
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
static int syn_status = 0;
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
/* enable touchpad leds */
|
||||
|
@ -58,21 +56,9 @@ void button_init_device(void)
|
|||
GPIOD_OUTPUT_EN |= 0x4; /* DATA */
|
||||
GPIOD_OUTPUT_VAL |= 0x4; /* high */
|
||||
|
||||
if (syn_init())
|
||||
if (!syn_init())
|
||||
{
|
||||
#ifdef ROCKBOX_HAS_LOGF
|
||||
syn_info();
|
||||
#endif
|
||||
|
||||
syn_status = 1;
|
||||
|
||||
/* enable interrupts */
|
||||
GPIOD_INT_LEV &= ~0x2;
|
||||
GPIOD_INT_CLR |= 0x2;
|
||||
GPIOD_INT_EN |= 0x2;
|
||||
|
||||
CPU_INT_EN |= HI_MASK;
|
||||
CPU_HI_INT_EN |= GPIO0_MASK;
|
||||
logf("button_init_dev: touchpad not ready");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,13 +72,12 @@ void button_int(void)
|
|||
|
||||
int_btn = BUTTON_NONE;
|
||||
|
||||
if (syn_status)
|
||||
if (syn_get_status())
|
||||
{
|
||||
/* disable interrupt while we read the touchpad */
|
||||
GPIOD_INT_EN &= ~0x2;
|
||||
GPIOD_INT_CLR |= 0x2;
|
||||
syn_int_enable(false);
|
||||
|
||||
val = syn_read_device(data, 4);
|
||||
val = syn_read(data, 4);
|
||||
if (val > 0)
|
||||
{
|
||||
val = data[0] & 0xff; /* packet header */
|
||||
|
@ -119,7 +104,7 @@ void button_int(void)
|
|||
int_btn |= BUTTON_RIGHT;
|
||||
|
||||
/* An Absolute packet should follow which we ignore */
|
||||
val = syn_read_device(data, 4);
|
||||
val = syn_read(data, 4);
|
||||
|
||||
logf(" int_btn = 0x%04x", int_btn);
|
||||
}
|
||||
|
@ -148,8 +133,7 @@ void button_int(void)
|
|||
}
|
||||
|
||||
/* re-enable interrupts */
|
||||
GPIOD_INT_LEV &= ~0x2;
|
||||
GPIOD_INT_EN |= 0x2;
|
||||
syn_int_enable(true);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -21,35 +21,84 @@
|
|||
#include "config.h"
|
||||
#include "backlight-target.h"
|
||||
#include "system.h"
|
||||
#include "lcd.h"
|
||||
#include "backlight.h"
|
||||
#include "synaptics-mep.h"
|
||||
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
|
||||
static const int brightness_vals[16] =
|
||||
{255,237,219,201,183,165,147,130,112,94,76,58,40,22,5,0};
|
||||
|
||||
void _backlight_set_brightness(int brightness)
|
||||
{
|
||||
outl(0x80000000 | (brightness_vals[brightness-1] << 16), 0x7000a000);
|
||||
}
|
||||
#endif
|
||||
|
||||
void _backlight_on(void)
|
||||
{
|
||||
GPO32_VAL &= ~0x1000000;
|
||||
GPO32_VAL &= ~0x1000000;
|
||||
GPO32_ENABLE &= ~0x1000000;
|
||||
}
|
||||
|
||||
void _backlight_off(void)
|
||||
{
|
||||
GPO32_VAL |= 0x1000000;
|
||||
GPO32_VAL |= 0x1000000;
|
||||
GPO32_ENABLE |= 0x1000000;
|
||||
}
|
||||
|
||||
#ifdef HAVE_BUTTON_LIGHT
|
||||
void _buttonlight_on(void)
|
||||
|
||||
#define BUTTONLIGHT_MASK 0x7f
|
||||
|
||||
static unsigned short buttonight_brightness = DEFAULT_BRIGHTNESS_SETTING - 1;
|
||||
static unsigned short buttonlight_status = 0;
|
||||
|
||||
static void set_buttonlight(int brightness)
|
||||
{
|
||||
int data[6];
|
||||
|
||||
if (syn_get_status())
|
||||
{
|
||||
syn_int_enable(false);
|
||||
|
||||
/* turn on all touchpad leds */
|
||||
data[0] = 0x05;
|
||||
data[1] = 0x31;
|
||||
data[2] = (brightness & 0xff) << 4;
|
||||
data[3] = 0x00;
|
||||
data[4] = 0x00;
|
||||
data[5] = BUTTONLIGHT_MASK;
|
||||
syn_send(data, 6);
|
||||
|
||||
/* device responds with a single-byte ACK packet */
|
||||
syn_read(data, 2);
|
||||
|
||||
syn_int_enable(true);
|
||||
}
|
||||
}
|
||||
|
||||
void _buttonlight_on(void)
|
||||
{
|
||||
if (!buttonlight_status)
|
||||
{
|
||||
set_buttonlight(buttonight_brightness);
|
||||
buttonlight_status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void _buttonlight_off(void)
|
||||
{
|
||||
if (buttonlight_status)
|
||||
{
|
||||
set_buttonlight(0);
|
||||
buttonlight_status = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void _buttonlight_set_brightness(int brightness)
|
||||
{
|
||||
buttonight_brightness = brightness - 1;
|
||||
set_buttonlight(buttonight_brightness);
|
||||
buttonlight_status = 1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define _backlight_init() true
|
||||
void _backlight_on(void);
|
||||
void _backlight_off(void);
|
||||
int __backlight_is_on(void);
|
||||
|
||||
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
||||
void _backlight_set_brightness(int brightness);
|
||||
|
@ -33,6 +32,7 @@ void _backlight_set_brightness(int brightness);
|
|||
#ifdef HAVE_BUTTON_LIGHT
|
||||
void _buttonlight_on(void);
|
||||
void _buttonlight_off(void);
|
||||
void _buttonlight_set_brightness(int brightness);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -46,41 +46,11 @@ void button_click(void)
|
|||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
static int syn_status = 0;
|
||||
|
||||
void button_init_device(void)
|
||||
{
|
||||
/* enable touchpad */
|
||||
GPO32_ENABLE |= 0x80;
|
||||
GPO32_VAL &= ~0x80;
|
||||
udelay(1000);
|
||||
|
||||
/* enable ACK, CLK, DATA lines */
|
||||
GPIOD_ENABLE |= 0x80;
|
||||
GPIOA_ENABLE |= (0x10 | 0x20);
|
||||
|
||||
GPIOD_OUTPUT_EN |= 0x80; /* ACK */
|
||||
GPIOD_OUTPUT_VAL |= 0x80; /* high */
|
||||
|
||||
GPIOA_OUTPUT_EN &= ~0x20; /* CLK */
|
||||
|
||||
GPIOA_OUTPUT_EN |= 0x10; /* DATA */
|
||||
GPIOA_OUTPUT_VAL |= 0x10; /* high */
|
||||
|
||||
if (syn_init())
|
||||
if (!syn_get_status())
|
||||
{
|
||||
#ifdef ROCKBOX_HAS_LOGF
|
||||
syn_info();
|
||||
#endif
|
||||
syn_status = 1;
|
||||
|
||||
/* enable interrupts */
|
||||
GPIOA_INT_LEV &= ~0x20;
|
||||
GPIOA_INT_CLR |= 0x20;
|
||||
GPIOA_INT_EN |= 0x20;
|
||||
|
||||
CPU_INT_EN |= HI_MASK;
|
||||
CPU_HI_INT_EN |= GPIO0_MASK;
|
||||
logf("button_init_dev: touchpad not ready");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,19 +64,18 @@ void button_int(void)
|
|||
|
||||
int_btn = BUTTON_NONE;
|
||||
|
||||
if (syn_status)
|
||||
if (syn_get_status())
|
||||
{
|
||||
/* disable interrupt while we read the touchpad */
|
||||
GPIOA_INT_EN &= ~0x20;
|
||||
GPIOA_INT_CLR |= 0x20;
|
||||
syn_int_enable(false);
|
||||
|
||||
val = syn_read_device(data, 4);
|
||||
val = syn_read(data, 4);
|
||||
if (val > 0)
|
||||
{
|
||||
val = data[0] & 0xff; /* packet header */
|
||||
id = (data[1] >> 4) & 0xf; /* packet id */
|
||||
|
||||
logf("button_read_device...");
|
||||
logf("syn_read:");
|
||||
logf(" data[0] = 0x%08x", data[0]);
|
||||
logf(" data[1] = 0x%08x", data[1]);
|
||||
logf(" data[2] = 0x%08x", data[2]);
|
||||
|
@ -121,7 +90,7 @@ void button_int(void)
|
|||
int_btn |= BUTTON_RIGHT;
|
||||
|
||||
/* An Absolute packet should follow which we ignore */
|
||||
val = syn_read_device(data, 4);
|
||||
val = syn_read(data, 4);
|
||||
logf(" int_btn = 0x%04x", int_btn);
|
||||
}
|
||||
else if (val == MEP_ABSOLUTE_HEADER)
|
||||
|
@ -149,8 +118,7 @@ void button_int(void)
|
|||
}
|
||||
|
||||
/* re-enable interrupts */
|
||||
GPIOA_INT_LEV &= ~0x20;
|
||||
GPIOA_INT_EN |= 0x20;
|
||||
syn_int_enable(true);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "power.h"
|
||||
#include "logf.h"
|
||||
#include "usb.h"
|
||||
#include "synaptics-mep.h"
|
||||
|
||||
void power_init(void)
|
||||
{
|
||||
|
@ -46,6 +47,27 @@ void power_init(void)
|
|||
GPIOE_OUTPUT_EN |= 0x40;
|
||||
GPIOE_OUTPUT_VAL &= ~0x40; /* off */
|
||||
#endif
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
/* enable touchpad here because we need it for
|
||||
both buttons and button lights */
|
||||
GPO32_ENABLE |= 0x80;
|
||||
GPO32_VAL &= ~0x80;
|
||||
udelay(1000);
|
||||
|
||||
GPIOD_ENABLE |= 0x80; /* enable ACK */
|
||||
GPIOA_ENABLE |= (0x10 | 0x20); /* enable DATA, CLK */
|
||||
|
||||
GPIOD_OUTPUT_EN |= 0x80; /* set ACK */
|
||||
GPIOD_OUTPUT_VAL |= 0x80; /* high */
|
||||
|
||||
GPIOA_OUTPUT_EN &= ~0x20; /* CLK */
|
||||
|
||||
GPIOA_OUTPUT_EN |= 0x10; /* set DATA */
|
||||
GPIOA_OUTPUT_VAL |= 0x10; /* high */
|
||||
|
||||
syn_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned int power_input_status(void)
|
||||
|
@ -70,7 +92,6 @@ void ide_power_enable(bool on)
|
|||
/* We do nothing */
|
||||
}
|
||||
|
||||
|
||||
bool ide_powered(void)
|
||||
{
|
||||
/* pretend we are always powered - we don't turn it off */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue