diff --git a/apps/keymaps/keymap-mr100.c b/apps/keymaps/keymap-mr100.c index 514d38b4e6..efbbca4d1b 100644 --- a/apps/keymaps/keymap-mr100.c +++ b/apps/keymaps/keymap-mr100.c @@ -275,12 +275,12 @@ static const struct button_mapping button_context_keyboard[] = { static const struct button_mapping remote_button_context_standard[] = { { ACTION_STD_PREV, BUTTON_RC_PLAY, BUTTON_NONE }, { ACTION_STD_PREVREPEAT, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_STD_NEXT, BUTTON_RC_DISPLAY, BUTTON_NONE }, - { ACTION_STD_NEXTREPEAT, BUTTON_RC_DISPLAY|BUTTON_REPEAT,BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_RC_DOWN, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_RC_DOWN|BUTTON_REPEAT,BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_RC_REW, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF }, { ACTION_STD_CONTEXT, BUTTON_RC_FF|BUTTON_REPEAT, BUTTON_RC_FF }, - { ACTION_STD_MENU, BUTTON_RC_FAV, BUTTON_NONE }, + { ACTION_STD_MENU, BUTTON_RC_HEART, BUTTON_NONE }, LAST_ITEM_IN_LIST }; @@ -297,7 +297,7 @@ static const struct button_mapping remote_button_context_wps[] = { { ACTION_WPS_STOPSEEK, BUTTON_RC_FF|BUTTON_REL, BUTTON_RC_FF|BUTTON_REPEAT }, { ACTION_WPS_STOP, BUTTON_RC_PLAY|BUTTON_REPEAT, BUTTON_RC_PLAY }, - { ACTION_WPS_MENU, BUTTON_RC_FAV, BUTTON_NONE }, + { ACTION_WPS_MENU, BUTTON_RC_HEART, BUTTON_NONE }, { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_WPS_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, @@ -340,7 +340,7 @@ static const struct button_mapping remote_button_context_usb_hid[] = { { ACTION_USB_HID_VOLUP, BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_USB_HID_VOLDOWN, BUTTON_RC_VOL_DOWN, BUTTON_NONE }, { ACTION_USB_HID_VOLDOWN, BUTTON_RC_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_USB_HID_MENU, BUTTON_RC_FAV, BUTTON_NONE }, + { ACTION_USB_HID_MENU, BUTTON_RC_HEART, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* remote_button_context_usb_hid */ diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c index 976fd262f8..accb286369 100644 --- a/apps/plugins/stats.c +++ b/apps/plugins/stats.c @@ -75,6 +75,7 @@ static bool abort; #elif CONFIG_KEYPAD == MROBE100_PAD #define STATS_STOP BUTTON_POWER +#define STATS_STOP_REMOTE BUTTON_RC_DOWN #elif CONFIG_KEYPAD == IAUDIO_M3_PAD #define STATS_STOP BUTTON_REC diff --git a/firmware/SOURCES b/firmware/SOURCES index 3a6e49d0d2..46c1f58cb3 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -909,6 +909,7 @@ target/arm/tms320dm320/creative-zvm/usb-creativezvm.c #ifndef SIMULATOR #ifndef BOOTLOADER drivers/synaptics-mep.c +target/arm/olympus/mrobe-100/lcd-remote-mr100.c #endif /* BOOTLOADER */ drivers/sw_i2c.c target/arm/ata-as-arm.S diff --git a/firmware/export/config-mrobe100.h b/firmware/export/config-mrobe100.h index b1299a820a..3fcef555d4 100644 --- a/firmware/export/config-mrobe100.h +++ b/firmware/export/config-mrobe100.h @@ -45,7 +45,24 @@ /*#define IRAM_LCDFRAMEBUFFER IDATA_ATTR */ /* put the lcd frame buffer in IRAM */ -#define CONFIG_KEYPAD MROBE100_PAD +#ifndef BOOTLOADER +/* Define this if you have an remote lcd */ +#define HAVE_REMOTE_LCD + +#define LCD_REMOTE_WIDTH 79 +#define LCD_REMOTE_HEIGHT 16 +#define LCD_REMOTE_DEPTH 1 +#define LCD_REMOTE_PIXELFORMAT VERTICAL_PACKING + +/* Remote display colours, for screenshots and sim (0xRRGGBB) */ +#define LCD_REMOTE_DARKCOLOR 0x000000 +#define LCD_REMOTE_BRIGHTCOLOR 0x5a915a +#define LCD_REMOTE_BL_DARKCOLOR 0x000000 +#define LCD_REMOTE_BL_BRIGHTCOLOR 0x82b4fa +#endif /* BOOTLOADER */ + +#define CONFIG_KEYPAD MROBE100_PAD +#define CONFIG_REMOTE_KEYPAD MROBE_REMOTE /* Define this if you do software codec */ #define CONFIG_CODEC SWCODEC @@ -90,6 +107,11 @@ #define HAVE_BUTTONLIGHT_BRIGHTNESS +/* Remote LCD contrast range and defaults */ +#define MIN_REMOTE_CONTRAST_SETTING 0 +#define MAX_REMOTE_CONTRAST_SETTING 15 +#define DEFAULT_REMOTE_CONTRAST_SETTING 8 + /* Define this if your LCD can be enabled/disabled */ /* TODO: #define HAVE_LCD_ENABLE */ diff --git a/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c b/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c index f3891c5000..7dd80946cd 100644 --- a/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c +++ b/firmware/target/arm/olympus/mrobe-100/backlight-mr100.c @@ -22,6 +22,7 @@ #include "config.h" #include "system.h" #include "backlight-target.h" +#include "lcd-remote-target.h" #define MIN_BRIGHTNESS 0x80ff08ff @@ -62,3 +63,15 @@ void _buttonlight_off(void) /* turn off all touchpad leds */ GPIOA_OUTPUT_VAL &= ~BUTTONLIGHT_ALL; } + +#ifdef HAVE_REMOTE_LCD +void _remote_backlight_on(void) +{ + lcd_remote_backlight(true); +} + +void _remote_backlight_off(void) +{ + lcd_remote_backlight(false); +} +#endif diff --git a/firmware/target/arm/olympus/mrobe-100/backlight-target.h b/firmware/target/arm/olympus/mrobe-100/backlight-target.h index ca5c548eff..df25106d1a 100644 --- a/firmware/target/arm/olympus/mrobe-100/backlight-target.h +++ b/firmware/target/arm/olympus/mrobe-100/backlight-target.h @@ -26,6 +26,11 @@ bool _backlight_init(void); /* Returns backlight current state (true=ON). */ void _backlight_hw_on(void); void _backlight_hw_off(void); +#ifdef HAVE_REMOTE_LCD +void _remote_backlight_on(void); +void _remote_backlight_off(void); +#endif + #ifdef BOOTLOADER #define _backlight_on() _backlight_hw_on() #define _backlight_off() _backlight_hw_off() diff --git a/firmware/target/arm/olympus/mrobe-100/button-mr100.c b/firmware/target/arm/olympus/mrobe-100/button-mr100.c index d4479278ef..e7979a4174 100644 --- a/firmware/target/arm/olympus/mrobe-100/button-mr100.c +++ b/firmware/target/arm/olympus/mrobe-100/button-mr100.c @@ -25,6 +25,12 @@ #include "backlight-target.h" #include "synaptics-mep.h" +#ifdef HAVE_REMOTE_LCD +#include "lcd-remote-target.h" +static bool remote_hold = false; +static bool headphones_status = true; +#endif + #define LOGF_ENABLE #include "logf.h" @@ -56,6 +62,13 @@ void button_init_device(void) { logf("touchpad not ready"); } + + /* headphone detection bit */ + GPIOD_OUTPUT_EN &= ~0x80; + GPIOD_ENABLE |= 0x80; + + /* remote detection (via headphone state) */ + headphones_int(); } /* @@ -102,13 +115,35 @@ void button_init_device(void){} */ int button_read_device(void) { - int btn = int_btn; + int btn = BUTTON_NONE; - if(button_hold()) - return BUTTON_NONE; - - if (~GPIOA_INPUT_VAL & 0x40) - btn |= BUTTON_POWER; +#ifdef HAVE_REMOTE_LCD + unsigned char data[5]; + + if (lcd_remote_read_device(data)) + { + remote_hold = (data[2] & 0x80) ? true : false; + if (!remote_hold) + { + if (data[1] & 0x1) btn |= BUTTON_RC_PLAY; + if (data[1] & 0x2) btn |= BUTTON_RC_DOWN; + if (data[1] & 0x4) btn |= BUTTON_RC_FF; + if (data[1] & 0x8) btn |= BUTTON_RC_REW; + if (data[1] & 0x10) btn |= BUTTON_RC_VOL_UP; + if (data[1] & 0x20) btn |= BUTTON_RC_VOL_DOWN; + if (data[1] & 0x40) btn |= BUTTON_RC_MODE; + if (data[1] & 0x80) btn |= BUTTON_RC_HEART; + } + } +#endif + + if(!button_hold()) + { + btn |= int_btn; + + if (~GPIOA_INPUT_VAL & 0x40) + btn |= BUTTON_POWER; + } return btn; } @@ -118,7 +153,32 @@ bool button_hold(void) return (GPIOD_INPUT_VAL & 0x10) ? false : true; } +#ifdef HAVE_REMOTE_LCD +bool remote_button_hold(void) +{ + return remote_hold; +} + +bool headphones_inserted(void) +{ + return headphones_status; +} + +void headphones_int(void) +{ + int state = 0x80 & ~GPIOD_INPUT_VAL; + headphones_status = (state) ? true : false; + + GPIO_CLEAR_BITWISE(GPIOD_INT_EN, 0x80); + GPIO_WRITE_BITWISE(GPIOD_INT_LEV, state, 0x80); + GPIO_WRITE_BITWISE(GPIOD_INT_CLR, 0x80, 0x80); + GPIO_SET_BITWISE(GPIOD_INT_EN, 0x80); + + lcd_remote_on(); +} +#else bool headphones_inserted(void) { return (GPIOD_INPUT_VAL & 0x80) ? false : true; } +#endif diff --git a/firmware/target/arm/olympus/mrobe-100/button-target.h b/firmware/target/arm/olympus/mrobe-100/button-target.h index 900211ebe4..93d42d62fb 100644 --- a/firmware/target/arm/olympus/mrobe-100/button-target.h +++ b/firmware/target/arm/olympus/mrobe-100/button-target.h @@ -29,22 +29,14 @@ #define MEP_BUTTON_ID 0x09 #define MEP_ABSOLUTE_HEADER 0x0b -#define HAS_BUTTON_HOLD - bool button_hold(void); void button_init_device(void); -int button_read_device(void); +int button_read_device(void); #ifndef BOOTLOADER void button_int(void); #endif -#define POWEROFF_BUTTON BUTTON_POWER -#define POWEROFF_COUNT 10 - -/* FIXME: Until the buttons are figured out, we use the button definitions - for the H10 keypad & remote. THESE ARE NOT CORRECT! */ - /* Main unit's buttons */ #define BUTTON_PLAY 0x00000001 #define BUTTON_MENU 0x00000002 @@ -61,18 +53,32 @@ void button_int(void); |BUTTON_RIGHT|BUTTON_SELECT|BUTTON_UP|BUTTON_SLIDE_UP\ |BUTTON_DOWN|BUTTON_SLIDE_DOWN|BUTTON_POWER) +#define HAS_BUTTON_HOLD + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#ifdef HAVE_REMOTE_LCD +void headphones_int(void); +bool remote_button_hold(void); + /* Remote control's buttons */ #define BUTTON_RC_PLAY 0x00010000 #define BUTTON_RC_REW 0x00020000 #define BUTTON_RC_FF 0x00040000 -#define BUTTON_RC_DISPLAY 0x00080000 -#define BUTTON_RC_FAV 0x00100000 +#define BUTTON_RC_DOWN 0x00080000 +#define BUTTON_RC_HEART 0x00100000 #define BUTTON_RC_MODE 0x00200000 #define BUTTON_RC_VOL_UP 0x00400000 #define BUTTON_RC_VOL_DOWN 0x00800000 #define BUTTON_REMOTE (BUTTON_RC_PLAY|BUTTON_RC_REW|BUTTON_RC_FF\ - |BUTTON_RC_DISPLAY|BUTTON_RC_FAV|BUTTON_RC_MODE\ + |BUTTON_RC_DOWN|BUTTON_RC_HEART|BUTTON_RC_MODE\ |BUTTON_RC_VOL_UP|BUTTON_RC_VOL_DOWN) + +#define HAS_REMOTE_BUTTON_HOLD #define RC_POWEROFF_BUTTON BUTTON_RC_PLAY +#else +#define BUTTON_REMOTE 0 +#endif /* HAVE_REMOTE_LCD */ #endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/olympus/mrobe-100/lcd-remote-mr100.c b/firmware/target/arm/olympus/mrobe-100/lcd-remote-mr100.c new file mode 100644 index 0000000000..036b6ae71c --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/lcd-remote-mr100.c @@ -0,0 +1,562 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 Mark Arigo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "cpu.h" +#include "kernel.h" +#include "thread.h" +#include "system.h" +#include "lcd-remote.h" +#include "button.h" +#include "button-target.h" + +/* Temporary defines until we sort out why the gui stuff doesn't like this size + (I believe the status bar isn't doing sanity checks and is writing outside + the frame buffer size). */ +#define RC_WIDTH 79 +#define RC_HEIGHT 16 + +#define RC_CONTRAST_MASK 0x000000ff +#define RC_SCREEN_ON 0x00000100 +#define RC_BACKLIGHT_ON 0x00000200 + +#define RC_DEV_INIT 0x00001000 +#define RC_DETECTED 0x00002000 +#define RC_AWAKE 0x00004000 +#define RC_POWER_OFF 0x00008000 + +#define RC_UPDATE_LCD 0x00010000 +#define RC_UPDATE_CONTROLLER 0x00020000 +#define RC_UPDATE_ICONS 0x00040000 +#define RC_UPDATE_MASK (RC_UPDATE_LCD|RC_UPDATE_CONTROLLER|RC_UPDATE_ICONS) + +#define RC_TX_ERROR 0x00100000 +#define RC_RX_ERROR 0x00200000 +#define RC_TIMEOUT_ERROR 0x00400000 +#define RC_ERROR_MASK (RC_TX_ERROR|RC_RX_ERROR|RC_TIMEOUT_ERROR) + +#define RC_FORCE_DETECT 0x80000000 + +#define RX_READY 0x01 +#define TX_READY 0x20 + +#define POLL_TIMEOUT 50000 + +bool remote_initialized = false; +unsigned int rc_status = 0; +unsigned char rc_buf[5]; + +/* ================================================== */ +/* Remote thread functions */ +/* These functions are private to the remote thread */ +/* ================================================== */ +static struct wakeup rc_thread_wakeup; +static unsigned int remote_thread_id; +static int remote_stack[256/sizeof(int)]; +static const char * const remote_thread_name = "remote"; + +static bool remote_wait_ready(int ready_mask) +{ + unsigned long current; + unsigned long start = USEC_TIMER; + unsigned long timeout = start + POLL_TIMEOUT; + + rc_status &= ~RC_TIMEOUT_ERROR; + + if (start <= timeout) + { + do + { + if (SER1_LSR & ready_mask) + return true; + + //~ sleep(1); + + current = USEC_TIMER; + } while (current < timeout); + } + else + { + do + { + if (SER1_LSR & ready_mask) + return true; + + //~ sleep(1); + + current = USEC_TIMER - POLL_TIMEOUT; + } while (current < start); + } + + rc_status |= RC_TIMEOUT_ERROR; + return false; +} + +static bool remote_rx(void) +{ + int i; + unsigned char chksum[2]; + + rc_status &= ~RC_RX_ERROR; + + for (i = 0; i < 5; i++) + { + if (!remote_wait_ready(RX_READY)) + { + rc_status |= RC_RX_ERROR; + return false; + } + + rc_buf[i] = SER1_RBR; + } + + /* check opcode */ + if ((rc_buf[0] & 0xf0) != 0xf0) + { + rc_status |= RC_RX_ERROR; + return false; + } + + /* verify the checksums */ + chksum[0] = chksum[1] = 0; + for (i = 0; i < 3; i++) + { + chksum[0] ^= rc_buf[i]; + chksum[1] += rc_buf[i]; + } + + if ((chksum[0] != rc_buf[3]) && (chksum[1] != rc_buf[4])) + { + rc_status |= RC_RX_ERROR; + return false; + } + + /* reception error */ + if ((rc_buf[0] & 0x1) || (rc_buf[0] & 0x2) || (rc_buf[0] & 0x4)) + { + rc_status |= RC_RX_ERROR; + return false; + } + + return true; +} + +static bool remote_tx(unsigned char *data, int len) +{ + int i; + unsigned char chksum[2]; + + rc_status &= ~RC_TX_ERROR; + + chksum[0] = chksum[1] = 0; + + for (i = 0; i < len; i++) + { + if (!remote_wait_ready(TX_READY)) + { + rc_status |= RC_TX_ERROR; + return false; + } + + SER1_THR = data[i]; + chksum[0] ^= data[i]; + chksum[1] += data[i]; + } + + for (i = 0; i < 2; i++) + { + if (!remote_wait_ready(TX_READY)) + { + rc_status |= RC_TX_ERROR; + return false; + } + + SER1_THR = chksum[i]; + } + + return remote_rx(); +} + +static void remote_dev_enable(bool enable) +{ + if (enable) + { + outl(inl(0x70000018) | 0xaa000, 0x70000018); + DEV_INIT2 &= ~0x800; + + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x80); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80); + + DEV_EN |= DEV_SER1; + + SER1_RBR; + SER1_LCR = 0x80; + SER1_DLL = 0x50; + SER1_DLM = 0x00; + SER1_LCR = 0x03; + SER1_FCR = 0x07; + + rc_status |= RC_DEV_INIT; + } + else + { + outl(inl(0x70000018) & ~0xaa000, 0x70000018); + DEV_INIT2 &= ~0x800; + + GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x80); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80); + + DEV_RS |= DEV_SER1; + nop; + DEV_RS &= ~DEV_SER1; + + DEV_EN &= ~DEV_SER1; + + rc_status &= ~RC_DEV_INIT; + } +} + +void remote_update_lcd(void) +{ + int x, y, draw_now; + unsigned char data[RC_WIDTH + 7]; + + /* If the draw_now bit is set, the draw occurs directly on the LCD. + Otherwise, the data is stored in an off-screen buffer and displayed + the next time a draw operation is executed with this flag set. */ + draw_now = 0; + + for (y = 0; y < 2; y++) + { + data[0] = 0x51; + data[1] = draw_now << 7; + data[2] = RC_WIDTH; /* width */ + data[3] = 0; /* x1 */ + data[4] = y << 3; /* y1 */ + data[5] = RC_WIDTH; /* x2 */ + data[6] = (y + 1) << 3; /* y2 */ + + for (x = 0; x < RC_WIDTH; x++) + data[x + 7] = lcd_remote_framebuffer[y][x]; + + remote_tx(data, RC_WIDTH + 7); + + draw_now = 1; + } +} + +static void remote_update_controller(void) +{ + unsigned char data[3]; + + data[0] = 0x31; + data[1] = 0x00; + if (rc_status & RC_SCREEN_ON) + data[1] |= 0x80; + if (rc_status & RC_BACKLIGHT_ON) + data[1] |= 0x40; + data[2] = (unsigned char)(rc_status & RC_CONTRAST_MASK); + remote_tx(data, 3); +} + +#if 0 +static void remote_update_icons(unsigned char symbols) +{ + unsigned char data[2]; + + if (!(rc_status & RC_AWAKE) && !(rc_status & RC_SCREEN_ON)) + return; + + data[0] = 0x41; + data[1] = symbols; + remote_tx(data, 2); +} +#endif + +static bool remote_nop(void) +{ + unsigned char val[2]; + + val[0] = 0x11; + val[1] = 0x30; + return remote_tx(val, 2); +} + +static void remote_wake(void) +{ + if (remote_nop()) + { + rc_status |= RC_AWAKE; + return; + } + + rc_status &= ~RC_AWAKE; + return; +} + +static void remote_sleep(void) +{ + unsigned char data[2]; + + if (rc_status & RC_AWAKE) + { + data[0] = 0x71; + data[1] = 0x30; + remote_tx(data, 2); + + udelay(25000); + } + + rc_status &= ~RC_AWAKE; +} + +static void remote_off(void) +{ + if (rc_status & RC_AWAKE) + remote_sleep(); + + if (rc_status & RC_DEV_INIT) + remote_dev_enable(false); + + rc_status &= ~(RC_DETECTED | RC_ERROR_MASK | RC_UPDATE_MASK); + remote_initialized = false; +} + +static void remote_on(void) +{ + if (!(rc_status & RC_DEV_INIT)) + remote_dev_enable(true); + + remote_wake(); + + if (rc_status & RC_AWAKE) + { + rc_status |= RC_DETECTED; + remote_initialized = true; + + rc_status |= (RC_UPDATE_MASK | RC_SCREEN_ON | RC_BACKLIGHT_ON); + //~ remote_update_icons(0xf0); /* show battery */ + } + else + { + rc_status &= ~RC_DETECTED; + remote_initialized = false; + } +} + +static void remote_thread(void) +{ + int rc_thread_sleep_count = 10; + int rc_thread_wait_timeout = TIMEOUT_BLOCK; + + while (1) + { + wakeup_wait(&rc_thread_wakeup, rc_thread_wait_timeout); + + /* Error handling (most likely due to remote not present) */ + if (rc_status & RC_ERROR_MASK) + { + if (--rc_thread_sleep_count == 0) + rc_status |= RC_POWER_OFF; + } + + /* Power-off (thread sleeps) */ + if (rc_status & RC_POWER_OFF) + { + remote_off(); + + rc_thread_sleep_count = 10; + rc_thread_wait_timeout = TIMEOUT_BLOCK; + + continue; + } + + /* Detection */ + if (!(rc_status & RC_DETECTED)) + { + rc_thread_wait_timeout = HZ; + + if (headphones_inserted()) + { + remote_on(); + + if (rc_status & RC_AWAKE) + { + rc_thread_sleep_count = 10; + rc_thread_wait_timeout = HZ/20; /* ~50ms for updates */ + } + } + else + { + if (--rc_thread_sleep_count == 0) + rc_status &= ~RC_POWER_OFF; + } + + continue; + } + + /* Update the remote (one per wakeup cycle) */ + if (headphones_inserted() && (rc_status & RC_AWAKE)) + { + if (rc_status & RC_SCREEN_ON) + { + /* In order of importance */ + if (rc_status & RC_UPDATE_CONTROLLER) + { + remote_update_controller(); + rc_status &= ~RC_UPDATE_CONTROLLER; + } + else if (rc_status & RC_UPDATE_LCD) + { + remote_update_lcd(); + rc_status &= ~RC_UPDATE_LCD; + } + else + { + remote_nop(); + } + } + else + { + remote_nop(); + } + } + } +} + +/* ============================================= */ +/* Public functions */ +/* These should only set the update flags that */ +/* will be executed in the remote thread. */ +/* ============================================= */ +bool lcd_remote_read_device(unsigned char *data) +{ + if (!(rc_status & RC_AWAKE) || (rc_status & RC_ERROR_MASK)) + return false; + + /* Return the most recent data. While the remote is plugged, + this is updated ~50ms */ + data[0] = rc_buf[0]; + data[1] = rc_buf[1]; + data[2] = rc_buf[2]; + data[3] = rc_buf[3]; + data[4] = rc_buf[4]; + + return true; +} + +void lcd_remote_set_invert_display(bool yesno) +{ + /* dummy function...need to introduce HAVE_LCD_REMOTE_INVERT */ + (void)yesno; +} + +/* turn the display upside down (call lcd_remote_update() afterwards) */ +void lcd_remote_set_flip(bool yesno) +{ + /* dummy function...need to introduce HAVE_LCD_REMOTE_FLIP */ + (void)yesno; +} + +int lcd_remote_default_contrast(void) +{ + return DEFAULT_REMOTE_CONTRAST_SETTING; +} + +void lcd_remote_set_contrast(int val) +{ + rc_status = (rc_status & ~RC_CONTRAST_MASK) | (val & RC_CONTRAST_MASK); + rc_status |= RC_UPDATE_CONTROLLER; +} + +void lcd_remote_backlight(bool on) +{ + if (on) + rc_status |= RC_BACKLIGHT_ON; + else + rc_status &= ~RC_BACKLIGHT_ON; + + rc_status |= RC_UPDATE_CONTROLLER; +} + +void lcd_remote_off(void) +{ + /* should only be used to power off at shutdown */ + rc_status |= RC_POWER_OFF; + wakeup_signal(&rc_thread_wakeup); + + /* wait until the things are powered off */ + while (rc_status & RC_DEV_INIT) + sleep(HZ/10); +} + +void lcd_remote_on(void) +{ + /* Only wake the remote thread if it's in the blocked state. */ + struct thread_entry *rc_thread = thread_id_entry(remote_thread_id); + if (rc_thread->state == STATE_BLOCKED || (rc_status & RC_FORCE_DETECT)) + { + rc_status &= ~RC_FORCE_DETECT; + rc_status &= ~RC_POWER_OFF; + wakeup_signal(&rc_thread_wakeup); + } +} + +bool remote_detect(void) +{ + return (rc_status & RC_DETECTED); +} + +void lcd_remote_init_device(void) +{ + /* reset */ + remote_dev_enable(false); + rc_status |= RC_FORCE_DETECT; /* force detection at startup */ + + /* unknown */ + GPIO_SET_BITWISE(GPIOL_ENABLE, 0x80); + GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x80); + GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80); + + /* a thread is required to poll & update the remote */ + wakeup_init(&rc_thread_wakeup); + remote_thread_id = create_thread(remote_thread, remote_stack, + sizeof(remote_stack), 0, remote_thread_name + IF_PRIO(, PRIORITY_SYSTEM) + IF_COP(, CPU)); +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_remote_update(void) +{ + rc_status |= RC_UPDATE_LCD; +} + +/* Update a fraction of the display. */ +void lcd_remote_update_rect(int x, int y, int width, int height) +{ + (void)x; + (void)y; + (void)width; + (void)height; + + rc_status |= RC_UPDATE_LCD; +} diff --git a/firmware/target/arm/olympus/mrobe-100/lcd-remote-target.h b/firmware/target/arm/olympus/mrobe-100/lcd-remote-target.h new file mode 100644 index 0000000000..b5a501046a --- /dev/null +++ b/firmware/target/arm/olympus/mrobe-100/lcd-remote-target.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: lcd-remote-target.h 11967 2007-01-09 23:29:07Z linus $ + * + * Copyright (C) 2007 by Jens Arnold + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef LCD_REMOTE_TARGET_H +#define LCD_REMOTE_TARGET_H + +bool remote_detect(void); /* returns detection status */ + +void lcd_remote_set_invert_display(bool yesno); +void lcd_remote_set_flip(bool yesno); +void lcd_remote_backlight(bool on); + +void lcd_remote_init_device(void); +void lcd_remote_on(void); +void lcd_remote_off(void); +void lcd_remote_update(void); +void lcd_remote_update_rect(int, int, int, int); +bool lcd_remote_read_device(unsigned char *data); + +extern bool remote_initialized; +extern unsigned int rc_status; +extern unsigned char rc_buf[5]; +#endif diff --git a/firmware/target/arm/olympus/mrobe-100/power-mr100.c b/firmware/target/arm/olympus/mrobe-100/power-mr100.c index 25757f62c1..26dd4ef14f 100644 --- a/firmware/target/arm/olympus/mrobe-100/power-mr100.c +++ b/firmware/target/arm/olympus/mrobe-100/power-mr100.c @@ -27,6 +27,7 @@ #include "power.h" #include "logf.h" #include "usb.h" +#include "lcd-remote-target.h" void power_init(void) { @@ -57,6 +58,10 @@ bool ide_powered(void) void power_off(void) { +#ifdef HAVE_REMOTE_LCD + lcd_remote_off(); +#endif + /* Disable interrupts on this core */ disable_interrupt(IRQ_FIQ_STATUS); diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index 967144ad0b..6ce45a12f3 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c @@ -29,6 +29,9 @@ #include "button-target.h" #include "usb-target.h" #include "usb_drv.h" +#ifdef HAVE_REMOTE_LCD +#include "lcd-remote-target.h" +#endif #ifndef BOOTLOADER extern void TIMER1(void); @@ -121,6 +124,9 @@ void __attribute__((interrupt("IRQ"))) irq_handler(void) else if (CPU_HI_INT_STAT & GPIO0_MASK) { if (GPIOD_INT_STAT & 0x02) button_int(); + if (GPIOD_INT_STAT & 0x80) + headphones_int(); + } else if (CPU_HI_INT_STAT & GPIO2_MASK) { if (GPIOL_INT_STAT & 0x04) diff --git a/tools/configure b/tools/configure index 802173f1b6..946cbdac75 100755 --- a/tools/configure +++ b/tools/configure @@ -1569,6 +1569,8 @@ fi tool="$rootdir/tools/scramble -mi4v2 -model=m100 -type=RBOS" bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" bmp2rb_native="$rootdir/tools/bmp2rb -f 0" + bmp2rb_remotemono="$rootdir/tools/bmp2rb -f 0" + bmp2rb_remotenative="$rootdir/tools/bmp2rb -f 0" output="rockbox.mi4" appextra="recorder:gui" plugins="yes" diff --git a/uisimulator/common/README b/uisimulator/common/README index 6f920cf43e..3ee2b45f0e 100644 --- a/uisimulator/common/README +++ b/uisimulator/common/README @@ -8,6 +8,3 @@ This directory is for code that is shared between all versions of the simulator, but is not needed for the target device. -The first code is for the software mpeg audio decoder. The actual -mpeg decoding code is here and the O/S specific sound drivers should -be located in the x11 and win32 directories as appropriate. diff --git a/uisimulator/sdl/UI-mrobe100.bmp b/uisimulator/sdl/UI-mrobe100.bmp index 19e5e1f3d3..2a9df60cf1 100644 Binary files a/uisimulator/sdl/UI-mrobe100.bmp and b/uisimulator/sdl/UI-mrobe100.bmp differ diff --git a/uisimulator/sdl/UI-mrobe500.bmp b/uisimulator/sdl/UI-mrobe500.bmp index 6aebbee8fd..c7d0bec362 100755 Binary files a/uisimulator/sdl/UI-mrobe500.bmp and b/uisimulator/sdl/UI-mrobe500.bmp differ diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c index 5f92b655d1..5987584420 100644 --- a/uisimulator/sdl/button.c +++ b/uisimulator/sdl/button.c @@ -760,6 +760,30 @@ void button_event(int key, bool pressed) new_btn = BUTTON_POWER; break; #elif CONFIG_KEYPAD == MROBE100_PAD + case SDLK_F9: + new_btn = BUTTON_RC_HEART; + break; + case SDLK_F10: + new_btn = BUTTON_RC_MODE; + break; + case SDLK_F11: + new_btn = BUTTON_RC_VOL_DOWN; + break; + case SDLK_F12: + new_btn = BUTTON_RC_VOL_UP; + break; + case SDLK_LEFT: + new_btn = BUTTON_RC_FF; + break; + case SDLK_RIGHT: + new_btn = BUTTON_RC_REW; + break; + case SDLK_UP: + new_btn = BUTTON_RC_PLAY; + break; + case SDLK_DOWN: + new_btn = BUTTON_RC_DOWN; + break; case SDLK_KP1: new_btn = BUTTON_DISPLAY; break; @@ -770,19 +794,15 @@ void button_event(int key, bool pressed) new_btn = BUTTON_PLAY; break; case SDLK_KP4: - case SDLK_LEFT: new_btn = BUTTON_LEFT; break; case SDLK_KP6: - case SDLK_RIGHT: new_btn = BUTTON_RIGHT; break; case SDLK_KP8: - case SDLK_UP: new_btn = BUTTON_UP; break; case SDLK_KP2: - case SDLK_DOWN: new_btn = BUTTON_DOWN; break; case SDLK_KP5: diff --git a/uisimulator/sdl/uisdl.h b/uisimulator/sdl/uisdl.h index 0fe0463b60..1543dcec37 100644 --- a/uisimulator/sdl/uisdl.h +++ b/uisimulator/sdl/uisdl.h @@ -163,14 +163,14 @@ #define UI_LCD_POSY 90 /* y position of lcd */ #elif defined(MROBE_500) -#if LCD_WIDHT==320 +#if LCD_WIDTH==320 #define UI_TITLE "Olympus M:Robe 500" #define UI_WIDTH 450 /* width of GUI window */ #define UI_HEIGHT 350 /* height of GUI window */ #define UI_LCD_POSX 65 /* x position of lcd */ #define UI_LCD_POSY 30 /* y position of lcd */ -#define UI_REMOTE_POSX 50 /* x position of remote lcd */ -#define UI_REMOTE_POSY 325 /* y position of remote lcd */ +#define UI_REMOTE_POSX 36 /* x position of remote lcd */ +#define UI_REMOTE_POSY 318 /* y position of remote lcd */ #else #define UI_TITLE "Olympus M:Robe 500" #define UI_WIDTH 900 /* width of GUI window */ @@ -235,9 +235,11 @@ #elif defined(MROBE_100) #define UI_TITLE "Olympus M:Robe 100" #define UI_WIDTH 247 /* width of GUI window */ -#define UI_HEIGHT 416 /* height of GUI window */ +#define UI_HEIGHT 462 /* height of GUI window */ #define UI_LCD_POSX 43 /* x position of lcd */ #define UI_LCD_POSY 25 /* y position of lcd */ +#define UI_REMOTE_POSX 34 /* x position of remote lcd */ +#define UI_REMOTE_POSY 432 /* y position of remote lcd */ #elif defined(COWON_D2) #define UI_TITLE "Cowon D2"