From 08585e417b4e545752ff9478d28c4da3e8c09844 Mon Sep 17 00:00:00 2001 From: Mark Arigo Date: Fri, 12 Dec 2008 04:56:25 +0000 Subject: FS#9591 by Anton Veretenenko for the Philips GoGear HDD1620/1630 (with a few changes by me). Fixes boot problem, pixel format, sound, and a few other things. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19395 a1c6a512-1295-4272-9138-f99709370657 --- .../target/arm/philips/hdd1630/backlight-hdd1630.c | 4 +++ .../target/arm/philips/hdd1630/button-hdd1630.c | 33 ++++++++++++++++++++-- firmware/target/arm/philips/hdd1630/lcd-hdd1630.c | 1 + .../target/arm/philips/hdd1630/power-hdd1630.c | 27 ++++++++++++++++-- .../target/arm/philips/hdd1630/powermgmt-hdd1630.c | 8 ++++-- 5 files changed, 66 insertions(+), 7 deletions(-) (limited to 'firmware/target/arm/philips') diff --git a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c index 0c49e65563..eb2c2731ac 100755 --- a/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/backlight-hdd1630.c @@ -34,10 +34,14 @@ void _backlight_set_brightness(int brightness) void _backlight_on(void) { + GPO32_VAL &= ~0x1000000; + GPO32_ENABLE &= ~0x1000000; } void _backlight_off(void) { + GPO32_VAL |= 0x1000000; + GPO32_ENABLE |= 0x1000000; } #ifdef HAVE_BUTTON_LIGHT diff --git a/firmware/target/arm/philips/hdd1630/button-hdd1630.c b/firmware/target/arm/philips/hdd1630/button-hdd1630.c index 3a8f7c5408..84cb8f0c06 100755 --- a/firmware/target/arm/philips/hdd1630/button-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/button-hdd1630.c @@ -23,6 +23,21 @@ #include "button.h" #include "backlight.h" +/* Remember last buttons, to make single buzz sound */ +int btn_old; + +/* + * Generate a click sound from the player (not in headphones yet) + * TODO: integrate this with the "key click" option + */ +void button_click(void) +{ + GPO32_ENABLE |= 0x2000; + GPIOD_OUTPUT_VAL |= 0x8; + udelay(1000); + GPO32_VAL &= ~0x2000; +} + void button_init_device(void) { /* TODO...for now, hardware initialisation is done by the bootloader */ @@ -49,19 +64,33 @@ int button_read_device(void) /* device buttons */ if (!hold_button) { + /* These are the correct button definitions if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_MENU; if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_VOL_UP; if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_VOL_DOWN; if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_VIEW; - if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_PLAYLIST; if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; + */ + + /* This is a hack until the touchpad works */ + if (!(GPIOA_INPUT_VAL & 0x01)) btn |= BUTTON_LEFT; /* BUTTON_MENU */ + if (!(GPIOA_INPUT_VAL & 0x02)) btn |= BUTTON_UP; /* BUTTON_VOL_UP */ + if (!(GPIOA_INPUT_VAL & 0x04)) btn |= BUTTON_DOWN; /* BUTTON_VOL_DOWN */ + if (!(GPIOA_INPUT_VAL & 0x08)) btn |= BUTTON_RIGHT; /* BUTTON_VIEW */ + if (!(GPIOD_INPUT_VAL & 0x20)) btn |= BUTTON_SELECT; /* BUTTON_PLAYLIST */ + if (!(GPIOD_INPUT_VAL & 0x40)) btn |= BUTTON_POWER; } + if ((btn != btn_old) && (btn != BUTTON_NONE)) + button_click(); + + btn_old = btn; + return btn; } bool headphones_inserted(void) { - return true; + return (GPIOE_INPUT_VAL & 0x80) ? true : false; } diff --git a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c index d7dee2036d..827e3ef8c4 100755 --- a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c @@ -84,6 +84,7 @@ void lcd_init_device(void) LCD2_BLOCK_CTRL = 0x10008080; LCD2_BLOCK_CONFIG = 0xF00000; + /* lcd power */ GPIOJ_ENABLE |= 0x4; GPIOJ_OUTPUT_VAL |= 0x4; GPIOJ_OUTPUT_EN |= 0x4; diff --git a/firmware/target/arm/philips/hdd1630/power-hdd1630.c b/firmware/target/arm/philips/hdd1630/power-hdd1630.c index ade2536154..03a5794791 100755 --- a/firmware/target/arm/philips/hdd1630/power-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/power-hdd1630.c @@ -35,11 +35,30 @@ bool charger_enabled; void power_init(void) { + /* power off bit */ + GPIOB_ENABLE |= 0x80; + GPIOB_OUTPUT_VAL |= 0x80; + GPIOB_OUTPUT_EN |= 0x80; + + /* charger inserted bit */ + GPIOE_ENABLE |= 0x20; + GPIOE_INPUT_VAL |= 0x20; } unsigned int power_input_status(void) -{ - return POWER_INPUT_NONE; +{ + unsigned int status = POWER_INPUT_NONE; + + /* AC charger */ + if (GPIOE_INPUT_VAL & 0x20) + status |= POWER_INPUT_MAIN_CHARGER; + + /* Do nothing with USB for now + if (GPIOE_INPUT_VAL & 0x4) + status |= POWER_INPUT_USB_CHARGER; + */ + + return status; } void ide_power_enable(bool on) @@ -57,4 +76,8 @@ bool ide_powered(void) void power_off(void) { + /* power off bit */ + GPIOB_ENABLE |= 0x80; + GPIOB_OUTPUT_VAL &= ~0x80; + GPIOB_OUTPUT_EN |= 0x80; } diff --git a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c index c8d5584305..0bb9458fe7 100644 --- a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c @@ -26,7 +26,7 @@ const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { - 3450 + 3450 }; const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = @@ -44,7 +44,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = /* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ const unsigned short percent_to_volt_charge[11] = { - 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 + 3480, 3550, 3590, 3610, 3630, 3650, 3700, 3760, 3800, 3910, 3990 }; #endif /* CONFIG_CHARGING */ @@ -60,5 +60,7 @@ const unsigned short percent_to_volt_charge[11] = /* Returns battery voltage from ADC [millivolts] */ unsigned int battery_adc_voltage(void) { - return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; + /* For now, assume as battery full (we need to calibrate) */ + /* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */ + return 3990; } -- cgit v1.2.3