mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 05:05:20 -05:00
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
|
|
@ -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