diff --git a/apps/SOURCES b/apps/SOURCES index a8a4d0c91e..04d9e76c51 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -149,6 +149,8 @@ keymaps/keymap-h10.c keymaps/keymap-ifp7xx.c #elif CONFIG_KEYPAD == SANSA_E200_PAD keymaps/keymap-e200.c +#elif CONFIG_KEYPAD == SANSA_C200_PAD +keymaps/keymap-c200.c #elif CONFIG_KEYPAD == ARCHOS_AV300_PAD keymaps/keymap-av300.c #endif diff --git a/apps/bitmaps/native/SOURCES b/apps/bitmaps/native/SOURCES index 094b2d61b1..88b60e0654 100644 --- a/apps/bitmaps/native/SOURCES +++ b/apps/bitmaps/native/SOURCES @@ -5,6 +5,8 @@ rockboxlogo.112x30x1.bmp #elif (LCD_WIDTH == 128) && (LCD_DEPTH == 16) rockboxlogo.128x40x16.bmp +#elif (LCD_WIDTH == 132) && (LCD_DEPTH == 16) +rockboxlogo.132x40x16.bmp #elif (LCD_WIDTH == 138) && (LCD_DEPTH == 2) rockboxlogo.138x46x2.bmp #elif (LCD_WIDTH == 160) && (LCD_DEPTH == 2) diff --git a/apps/bitmaps/native/rockboxlogo.132x40x16.bmp b/apps/bitmaps/native/rockboxlogo.132x40x16.bmp new file mode 100644 index 0000000000..865a8ed59d Binary files /dev/null and b/apps/bitmaps/native/rockboxlogo.132x40x16.bmp differ diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 41507708d4..f8492d34b6 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -1010,7 +1010,8 @@ static bool dbg_spdif(void) #elif CONFIG_KEYPAD == IRIVER_H10_PAD # define DEBUG_CANCEL BUTTON_REW -#elif CONFIG_KEYPAD == SANSA_E200_PAD +#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ + (CONFIG_KEYPAD == SANSA_C200_PAD) # define DEBUG_CANCEL BUTTON_LEFT #endif /* key definitios */ @@ -2007,7 +2008,7 @@ static bool dbg_save_roms(void) return false; } -#elif defined(CPU_PP) && !defined(SANSA_E200) +#elif defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200)) static bool dbg_save_roms(void) { int fd; @@ -2254,7 +2255,7 @@ static const struct the_menu_item menuitems[] = { { "LCD Power Off", dbg_lcd_power_off }, #endif #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || \ - (defined(CPU_PP) && !defined(SANSA_E200)) + (defined(CPU_PP) && !(defined(SANSA_E200) || defined(SANSA_C200))) { "Dump ROM contents", dbg_save_roms }, #endif #if CONFIG_CPU == SH7034 || defined(CPU_COLDFIRE) || defined(CPU_PP) || CONFIG_CPU == S3C2440 diff --git a/apps/keymaps/keymap-c200.c b/apps/keymaps/keymap-c200.c new file mode 100644 index 0000000000..2141c9bf33 --- /dev/null +++ b/apps/keymaps/keymap-c200.c @@ -0,0 +1,361 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2007 Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +/* Button Code Definitions for Sandisk c200 target */ + +#include "config.h" +#include "action.h" +#include "button.h" +#include "settings.h" + +/* {Action Code, Button code, Prereq button code } */ + +/* + * The format of the list is as follows + * { Action Code, Button code, Prereq button code } + * if there's no need to check the previous button's value, use BUTTON_NONE + * Insert LAST_ITEM_IN_LIST at the end of each mapping + */ +static const struct button_mapping button_context_standard[] = { + { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, + + { ACTION_STD_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + { ACTION_STD_REC, BUTTON_REC|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_QUICKSCREEN, BUTTON_REC|BUTTON_SELECT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_standard */ + + +static const struct button_mapping button_context_wps[] = { + { ACTION_WPS_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + { ACTION_WPS_STOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + + { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT }, + + { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, + + { ACTION_WPS_ABSETB_NEXTDIR,BUTTON_POWER|BUTTON_RIGHT, BUTTON_POWER }, + { ACTION_WPS_ABSETA_PREVDIR,BUTTON_POWER|BUTTON_LEFT, BUTTON_POWER }, + { ACTION_WPS_ABRESET, BUTTON_POWER|BUTTON_UP, BUTTON_POWER }, + + { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_WPS_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_WPS_PITCHSCREEN, BUTTON_SELECT|BUTTON_UP, BUTTON_SELECT }, + { ACTION_WPS_ID3SCREEN, BUTTON_SELECT|BUTTON_DOWN, BUTTON_SELECT }, + { ACTION_WPS_CONTEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN }, + { ACTION_WPS_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, + { ACTION_WPS_REC, BUTTON_REC|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_wps */ + +static const struct button_mapping button_context_settings[] = { + { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, + { ACTION_SETTINGS_RESET, BUTTON_SELECT, BUTTON_NONE }, + + { ACTION_SETTINGS_INC, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT,BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_SETTINGS_DEC, BUTTON_UP, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT,BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_PREV, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), +}; /* button_context_settings */ + +static const struct button_mapping button_context_list[] = { + { ACTION_LISTTREE_PGUP, BUTTON_REC|BUTTON_UP, BUTTON_REC }, + { ACTION_LISTTREE_PGDOWN, BUTTON_REC|BUTTON_DOWN, BUTTON_REC }, + +#ifdef HAVE_VOLUME_IN_LIST + { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, +#endif + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_list */ + +static const struct button_mapping button_context_tree[] = { + { ACTION_TREE_WPS, BUTTON_REC|BUTTON_UP, BUTTON_REC }, + { ACTION_TREE_STOP, BUTTON_REC|BUTTON_UP|BUTTON_REPEAT, BUTTON_REC|BUTTON_UP }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), +}; /* button_context_tree */ + +static const struct button_mapping button_context_listtree_scroll_without_combo[] = { + { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT }, + + { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), +}; /* button_context_listtree_scroll_without_combo */ + +static const struct button_mapping button_context_listtree_scroll_with_combo[] = { + { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_TREE_PGLEFT, BUTTON_REC|BUTTON_LEFT, BUTTON_REC }, + { ACTION_TREE_PGLEFT, BUTTON_REC|BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_TREE_PGRIGHT, BUTTON_REC|BUTTON_RIGHT, BUTTON_REC }, + { ACTION_TREE_PGRIGHT, BUTTON_REC|BUTTON_RIGHT|BUTTON_REPEAT,BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE), +}; /* button_context_listtree_scroll_with_combo */ + +static const struct button_mapping button_context_yesno[] = { + { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), +}; /* button_context_settings_yesno */ + +static const struct button_mapping button_context_quickscreen[] = { + { ACTION_NONE, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_NONE }, + + { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REL, BUTTON_NONE }, + { ACTION_QS_DOWNINV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), +}; /* button_context_quickscreen */ + +static const struct button_mapping button_context_settings_right_is_inc[] = { + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT,BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT,BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_PREV, BUTTON_UP|BUTTON_REL, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_NONE, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, + + { ACTION_NONE, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_NONE, BUTTON_POWER, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), +}; /* button_context_settings_right_is_inc */ + +static const struct button_mapping button_context_settings_time[] = { + { ACTION_STD_PREV, BUTTON_UP|BUTTON_REL, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_NEXT, BUTTON_DOWN|BUTTON_REL, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) +}; /* button_context_settings_time */ + +static const struct button_mapping button_context_pitchscreen[] = { + { ACTION_PS_INC_SMALL, BUTTON_UP, BUTTON_NONE }, + { ACTION_PS_INC_BIG, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_PS_DEC_SMALL, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_PS_DEC_BIG, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_PS_NUDGE_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_PS_NUDGE_LEFTOFF, BUTTON_LEFT|BUTTON_REL, BUTTON_NONE }, + + { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL, BUTTON_NONE }, + + { ACTION_PS_RESET, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD), +}; /* button_context_pitchscreen */ + +/** Recording Screen **/ +#ifdef HAVE_RECORDING +static const struct button_mapping button_context_recscreen[] = { + { ACTION_STD_MENU, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_REC_PAUSE, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + { ACTION_STD_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_REC_NEWFILE, BUTTON_REC|BUTTON_REL, BUTTON_REC }, + + { ACTION_SETTINGS_INC, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_SETTINGS_DEC, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_PREV, BUTTON_SCROLL_UP, BUTTON_NONE }, + { ACTION_STD_PREV, BUTTON_SCROLL_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_NEXT, BUTTON_SCROLL_DOWN, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_SCROLL_DOWN|BUTTON_REPEAT,BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_recscreen */ +#endif + +/** FM Radio Screen **/ +#if CONFIG_TUNER +static const struct button_mapping button_context_radio[] = { + { ACTION_FM_MENU, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_FM_PRESET, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_FM_STOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, + { ACTION_FM_MODE, BUTTON_REC, BUTTON_NONE }, + { ACTION_FM_EXIT, BUTTON_POWER, BUTTON_NONE }, + { ACTION_FM_PLAY, BUTTON_UP|BUTTON_REL, BUTTON_UP }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) +}; /* button_context_radio */ +#endif + +static const struct button_mapping button_context_keyboard[] = { + { ACTION_KBD_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_KBD_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_KBD_CURSOR_LEFT, BUTTON_REC|BUTTON_LEFT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_LEFT, BUTTON_REC|BUTTON_LEFT|BUTTON_REPEAT,BUTTON_NONE }, + + { ACTION_KBD_CURSOR_RIGHT, BUTTON_REC|BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_KBD_CURSOR_RIGHT, BUTTON_REC|BUTTON_RIGHT|BUTTON_REPEAT,BUTTON_NONE }, + + { ACTION_KBD_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_KBD_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_KBD_BACKSPACE, BUTTON_REC|BUTTON_DOWN, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_REC|BUTTON_DOWN|BUTTON_REPEAT,BUTTON_NONE }, + + { ACTION_KBD_PAGE_FLIP, BUTTON_REC|BUTTON_SELECT, BUTTON_REC }, + + { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_UP, BUTTON_NONE }, + { ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + +static const struct button_mapping button_context_bmark[] = { + { ACTION_BMS_DELETE, BUTTON_UP, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), +}; /* button_context_bmark */ + +/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */ +const struct button_mapping* get_context_mapping(int context) +{ + switch (context) + { + case CONTEXT_STD: + return button_context_standard; + + case CONTEXT_WPS: + return button_context_wps; + + case CONTEXT_LIST: + return button_context_list; + case CONTEXT_TREE: + case CONTEXT_MAINMENU: + if (global_settings.hold_lr_for_scroll_in_list) + return button_context_listtree_scroll_without_combo; + else + return button_context_listtree_scroll_with_combo; + case CONTEXT_CUSTOM|CONTEXT_TREE: + return button_context_tree; + + case CONTEXT_SETTINGS: + return button_context_settings; + case CONTEXT_CUSTOM|CONTEXT_SETTINGS: + case CONTEXT_SETTINGS_COLOURCHOOSER: + case CONTEXT_SETTINGS_EQ: + return button_context_settings_right_is_inc; + + case CONTEXT_SETTINGS_TIME: + return button_context_settings_time; + + case CONTEXT_YESNOSCREEN: + return button_context_yesno; +#if CONFIG_TUNER + case CONTEXT_FM: + return button_context_radio; +#endif + case CONTEXT_BOOKMARKSCREEN: + return button_context_bmark; + case CONTEXT_QUICKSCREEN: + return button_context_quickscreen; + case CONTEXT_PITCHSCREEN: + return button_context_pitchscreen; +#ifdef HAVE_RECORDING + case CONTEXT_RECSCREEN: + return button_context_recscreen; +#endif + case CONTEXT_KEYBOARD: + return button_context_keyboard; + + default: + return button_context_standard; + } + return button_context_standard; +} diff --git a/apps/lang/english.lang b/apps/lang/english.lang index cf9ce3b268..28451d0890 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -72,6 +72,7 @@ # # Sandisk # Sansa E200 e200 +# Sansa C200 c200 # @@ -319,13 +320,13 @@ *: "PLAY = Yes" h100,h120,h300: "NAVI = Yes" - ipod*,x5,m5,gigabeatf,e200,h10,h10_5gb: "SELECT = Yes" + ipod*,x5,m5,gigabeatf,e200,c200,h10,h10_5gb: "SELECT = Yes" player: "(PLAY/STOP)" *: "PLAY = Yes" h100,h120,h300: "NAVI = Yes" - ipod*,x5,m5,gigabeatf,e200,h10,h10_5gb: "SELECT = Yes" + ipod*,x5,m5,gigabeatf,e200,c200,h10,h10_5gb: "SELECT = Yes" player: "(PLAY/STOP)" @@ -2421,14 +2422,14 @@ h100,h120,h300: "Building database... %d found (STOP to return)" ipod*: "Building database... %d found (PLAY/PAUSE to return)" x5,m5: "Building database... %d found (LEFT to return)" - h10,h10_5gb,e200: "Building database... %d found (PREV to return)" + h10,h10_5gb,e200,c200: "Building database... %d found (PREV to return)" *: "Building database... %d found (OFF to return)" h100,h120,h300: "Building database... %d found (STOP to return)" ipod*: "Building database... %d found (PLAY/PAUSE to return)" x5,m5: "Building database... %d found (LEFT to return)" - h10,h10_5gb,e200: "Building database... %d found (PREV to return)" + h10,h10_5gb,e200,c200: "Building database... %d found (PREV to return)" *: "entries found for database" @@ -4179,17 +4180,17 @@ *: none rtc: "ON = Set" h100,h120,h300: "NAVI = Set" - ipod*,x5,m5,h10,h10_5gb,e200,gigabeatf: "SELECT = Set" + ipod*,x5,m5,h10,h10_5gb,e200,c200,gigabeatf: "SELECT = Set" *: none rtc: "ON = Set" h100,h120,h300: "NAVI = Set" - ipod*,x5,m5,h10,h10_5gb,e200,gigabeatf: "SELECT = Set" + ipod*,x5,m5,h10,h10_5gb,e200,c200,gigabeatf: "SELECT = Set" *: none - rtc,h100,h120,h300,h10,h10_5gb,x5,m5,ipod*,e200,gigabeatf: "" + rtc,h100,h120,h300,h10,h10_5gb,x5,m5,ipod*,e200,c200,gigabeatf: "" @@ -4200,7 +4201,7 @@ *: none rtc: "OFF = Revert" h100,h120,h300: "STOP = Revert" - ipod*,e200: "MENU = Revert" + ipod*,e200,c200: "MENU = Revert" x5,m5: "RECORD = Revert" h10,h10_5gb: "PREV = Revert" gigabeatf: "A = Revert" @@ -4209,14 +4210,14 @@ *: none rtc: "OFF = Revert" h100,h120,h300: "STOP = Revert" - ipod*,e200: "MENU = Revert" + ipod*,e200,c200: "MENU = Revert" x5,m5: "RECORD = Revert" h10,h10_5gb: "PREV = Revert" gigabeatf: "A = Revert" *: none - rtc,h100,h120,h300,ipod*,e200,x5,m5,h10,h10_gb,gigabeatf: "" + rtc,h100,h120,h300,ipod*,e200,c200,x5,m5,h10,h10_gb,gigabeatf: "" @@ -6951,17 +6952,17 @@ user: *: none - e200: "mSD:" + e200,c200: "mSD:" ondio*: "MMC:" *: none - e200: "mSD:" + e200,c200: "mSD:" ondio*: "MMC:" *: none - e200: "micro Secure Digital card:" + e200,c200: "micro Secure Digital card:" ondio*: "Multimedia card" @@ -8325,18 +8326,18 @@ recording: "The disk is full. Press OFF to continue." h100,h120,h300: "The disk is full. Press STOP to continue." m5,x5: "The disk is full. Press POWER to continue." - e200: "The disk is full. Press UP to continue." + e200,c200: "The disk is full. Press UP to continue." *: none recording: "The disk is full. Press OFF to continue." h100,h120,h300: "The disk is full. Press STOP to continue." m5,x5: "The disk is full. Press POWER to continue." - e200: "The disk is full. Press UP to continue." + e200,c200: "The disk is full. Press UP to continue." *: none - recording,h100,h120,h300,m5,x5,e200: "" + recording,h100,h120,h300,m5,x5,e200,c200: "" @@ -8427,14 +8428,14 @@ player,h100,h120,h300: "STOP to abort" ipod*: "PLAY/PAUSE to abort" x5,m5: "Long PLAY to abort" - h10,h10_5gb,e200: "PREV to abort" + h10,h10_5gb,e200,c200: "PREV to abort" *: "OFF to abort" player,h100,h120,h300: "STOP to abort" ipod*: "PLAY/PAUSE to abort" x5,m5: "Long PLAY to abort" - h10,h10_5gb,e200: "PREV to abort" + h10,h10_5gb,e200,c200: "PREV to abort" *: "" @@ -10481,17 +10482,17 @@ *: none recording: "The disk is full. Press OFF to continue." h100,h120,h300: "The disk is full. Press STOP to continue." - m5,x5,ipod4g,ipodcolor,ipodnano,ipodvideo,e200: "The disk is full. Press LEFT to continue." + m5,x5,ipod4g,ipodcolor,ipodnano,ipodvideo,e200,c200: "The disk is full. Press LEFT to continue." *: none recording: "The disk is full. Press OFF to continue." h100,h120,h300: "The disk is full. Press STOP to continue." - m5,x5,ipod4g,ipodcolor,ipodnano,ipodvideo,e200: "The disk is full. Press LEFT to continue." + m5,x5,ipod4g,ipodcolor,ipodnano,ipodvideo,e200,c200: "The disk is full. Press LEFT to continue." *: none - recording,h100,h120,h300,m5,x5,ipod4g,ipodcolor,ipodnano,ipodvideo,e200: "" + recording,h100,h120,h300,m5,x5,ipod4g,ipodcolor,ipodnano,ipodvideo,e200,c200: "" diff --git a/bootloader/SOURCES b/bootloader/SOURCES index 94196d387a..5d82e57309 100644 --- a/bootloader/SOURCES +++ b/bootloader/SOURCES @@ -4,7 +4,8 @@ common.c ipod.c #elif defined(GIGABEAT_F) gigabeat.c -#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || defined(SANSA_E200) +#elif defined(IRIVER_H10) || defined(IRIVER_H10_5GB) || \ + defined(SANSA_E200) || defined(SANSA_C200) main-pp.c #elif defined(ELIO_TPJ1022) tpj1022.c diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index 0fa276708c..462a82e6b7 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c @@ -33,7 +33,7 @@ #include "disk.h" #include "crc32-mi4.h" #include -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) #include "usb.h" #include "arcotg_udc.h" #endif @@ -46,6 +46,9 @@ #elif CONFIG_KEYPAD == SANSA_E200_PAD #define BOOTLOADER_BOOT_OF BUTTON_LEFT +#elif CONFIG_KEYPAD == SANSA_C200_PAD +#define BOOTLOADER_BOOT_OF BUTTON_LEFT + #endif /* Maximum allowed firmware image size. 10MB is more than enough */ @@ -58,7 +61,7 @@ unsigned char *loadbuffer = (unsigned char *)DRAM_START; char version[] = APPSVERSION; /* Locations and sizes in hidden partition on Sansa */ -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) #define PPMI_SECTOR_OFFSET 1024 #define PPMI_SECTORS 1 #define MI4_HEADER_SECTORS 1 @@ -335,6 +338,7 @@ int load_mi4(unsigned char* buf, char* firmware, unsigned int buffer_size) return EOK; } +#if defined(SANSA_E200) || defined(SANSA_C200) #ifdef SANSA_E200 struct OFDB_info { char *version; @@ -346,6 +350,17 @@ struct OFDB_info { { "PP5022AF-05.51-S301-00.12-S301.00.12E-D", 39, 0x3c5c, 0x2 }, { "PP5022AF-05.51-S301-00.12-S301.00.12A-D", 39, 0x3c08, 0xe1 }, }; +#else /* SANSA_C200 */ +/* TODO: need to determine these for the c200 */ +struct OFDB_info { + char *version; + int version_length; + int sector; + int offset; +} OFDatabaseOffsets[] = { + { "PP5022AF-05.51-S301-01.11-S301.01.11A-D", 39, 0x3c08, 0xe1 }, +}; +#endif /* Load mi4 firmware from a hidden disk partition */ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, @@ -432,18 +447,17 @@ int load_mi4_part(unsigned char* buf, struct partinfo* pinfo, void* main(void) { -#ifndef SANSA_E200 - char buf[256]; - unsigned short* identify_info; -#endif int i; int btn; int rc; int num_partitions; struct partinfo* pinfo; -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) int usb_retry = 0; bool usb = false; +#else + char buf[256]; + unsigned short* identify_info; #endif chksum_crc32gentab (); @@ -459,7 +473,7 @@ void* main(void) lcd_clear_display(); btn = button_read_device(); -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) usb_init(); while ((UDC_OTGSC&0x800) && usb_retry < 5 && !usb) { @@ -481,7 +495,7 @@ void* main(void) printf(MODEL_NAME); i=ata_init(); -#ifndef SANSA_E200 +#if !defined(SANSA_E200) && !defined(SANSA_C200) if (i==0) { identify_info=ata_get_identify(); /* Show model */ @@ -525,7 +539,7 @@ void* main(void) */ printf("Loading original firmware..."); -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) /* First try a (hidden) firmware partition */ printf("Trying firmware partition"); pinfo = disk_partinfo(1); @@ -576,7 +590,7 @@ void* main(void) { printf("dumping sector %d", i); } - ata_read_sectors(pinfo->start + i,1 , sector); + ata_read_sectors(0, pinfo->start + i, 1, sector); write(fd,sector,512); } close(fd); @@ -588,19 +602,21 @@ void* main(void) printf("Can't load %s:", BOOTFILE); printf(strerror(rc)); +#ifdef OLD_BOOTFILE /* Try loading rockbox from old rockbox.e200/rockbox.h10 format */ rc=load_firmware(loadbuffer, OLD_BOOTFILE, MAX_LOADSIZE); if (rc < EOK) { printf("Can't load %s:", OLD_BOOTFILE); error(EBOOTFILE, rc); } +#endif } } return (void*)loadbuffer; } -#ifndef SANSA_E200 +#if !defined(SANSA_E200) && !defined(SANSA_C200) /* These functions are present in the firmware library, but we reimplement them here because the originals do a lot more than we want */ void usb_acknowledge(void) diff --git a/firmware/SOURCES b/firmware/SOURCES index 3b0aca79fc..7a6e253a81 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -110,7 +110,7 @@ drivers/ata_mmc.c #ifdef HAVE_FLASH_DISK drivers/ata_flash.c #else /* !HAVE_FLASH_DISK */ -#ifndef SANSA_E200 +#if !defined(SANSA_E200) && !defined(SANSA_C200) drivers/ata.c #endif /* SANSA_E200 */ #endif /* HAVE_FLASH_DISK */ @@ -239,7 +239,7 @@ usbstack/drivers/device/usb_storage.c #if CONFIG_USBOTG == USBOTG_ISP1362 drivers/isp1362.c #endif -#if defined(SANSA_E200) || !defined(BOOTLOADER) +#if defined(SANSA_E200) || defined(SANSA_C200) || !defined(BOOTLOADER) #if CONFIG_USBOTG == USBOTG_M5636 drivers/m5636.c #elif CONFIG_USBOTG == USBOTG_ARC @@ -319,7 +319,7 @@ target/arm/system-pp502x.c target/arm/crt0-pp-bl.S #else target/arm/pcm-pp.c -#ifndef SANSA_E200 +#if !defined(SANSA_E200) && !defined(SANSA_C200) target/arm/audio-pp.c #endif /* SANSA_E200 */ target/arm/crt0-pp.S @@ -415,6 +415,23 @@ target/arm/sandisk/audio-c200_e200.c #endif /* SIMULATOR */ #endif /* SANSA_E200 */ +#ifdef SANSA_C200 +#ifndef SIMULATOR +target/arm/sandisk/ata-c200_e200.c +target/arm/sandisk/sansa-c200/lcd-c200.c +target/arm/sandisk/adc-c200_e200.c +target/arm/sandisk/backlight-c200_e200.c +target/arm/usb-fw-pp502x.c +target/arm/sandisk/sansa-c200/button-c200.c +target/arm/sandisk/power-c200_e200.c +target/arm/sandisk/sansa-c200/powermgmt-c200.c +target/arm/i2s-pp.c +#ifndef BOOTLOADER +target/arm/sandisk/audio-c200_e200.c +#endif /* BOOTLOADER */ +#endif /* SIMULATOR */ +#endif /* SANSA_C200 */ + #ifdef IAUDIO_X5 #ifndef SIMULATOR target/coldfire/ata-as-coldfire.S diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index c01790f082..8df228f105 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -70,7 +70,7 @@ extern void audiohw_set_monitor(int enable); #define VOLUME_MIN -735 #define VOLUME_MAX 60 -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) #define AS3514_I2C_ADDR 0x46 #endif diff --git a/firmware/export/config-c200.h b/firmware/export/config-c200.h new file mode 100644 index 0000000000..c0e8753493 --- /dev/null +++ b/firmware/export/config-c200.h @@ -0,0 +1,190 @@ +/* + * This config file is for the Sandisk Sansa e200 + */ +#define TARGET_TREE /* this target is using the target tree system */ + +/* For Rolo and boot loader */ +#define MODEL_NUMBER 20 +#define MODEL_NAME "Sandisk Sansa c200" + +#define HW_SAMPR_CAPS (SAMPR_CAP_44) + +/* define this if you have recording possibility */ +/* TODO: #define HAVE_RECORDING */ + +#define REC_SAMPR_CAPS (SAMPR_CAP_22) +#define REC_FREQ_DEFAULT REC_FREQ_22 /* Default is not 44.1kHz */ +#define REC_SAMPR_DEFAULT SAMPR_22 + +/* Define bitmask of input sources - recordable bitmask can be defined + explicitly if different */ +#define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FMRADIO) + +/* define this if you have a bitmap LCD display */ +#define HAVE_LCD_BITMAP + +/* define this if you have a colour LCD */ +#define HAVE_LCD_COLOR + +/* define this if you have a light associated with the buttons */ +/* TODO: #define HAVE_BUTTON_LIGHT */ + +/* define this if you have access to the quickscreen */ +#define HAVE_QUICKSCREEN + +/* define this if you have access to the pitchscreen */ +#define HAVE_PITCHSCREEN + +/* define this if you would like tagcache to build on this target */ +#define HAVE_TAGCACHE + +/* LCD dimensions */ +#define LCD_WIDTH 132 +#define LCD_HEIGHT 80 +#define LCD_DEPTH 16 /* 65536 colours */ +#define LCD_PIXELFORMAT RGB565 /* rgb565 */ + +/* define this if you have LCD enable function */ +/* TODO: #define HAVE_LCD_ENABLE */ + +/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE + should be defined as well. */ +/* TODO: #define HAVE_LCD_SLEEP */ + +/* define this if you can flip your LCD */ +/* TODO: #define HAVE_LCD_FLIP */ + +/* define this if you can invert the colours on your LCD */ +/* TODO: #define HAVE_LCD_INVERT */ + +/* Define this if your LCD can set contrast */ +/* #define HAVE_LCD_CONTRAST */ + +#define MIN_CONTRAST_SETTING 0 +#define MAX_CONTRAST_SETTING 30 +#define DEFAULT_CONTRAST_SETTING 14 /* Match boot contrast */ + +/* #define IRAM_LCDFRAMEBUFFER IDATA_ATTR *//* put the lcd frame buffer in IRAM */ + +#define CONFIG_KEYPAD SANSA_C200_PAD + +/* Define this if you do software codec */ +#define CONFIG_CODEC SWCODEC + +/* There is no hardware tone control */ +#define HAVE_SW_TONE_CONTROLS + +/* The PP5024 has a built-in AustriaMicrosystems AS3514 */ +#define HAVE_AS3514 + +/* define this if you have a real-time clock */ +#ifndef BOOTLOADER +#define CONFIG_RTC RTC_AS3514 +#endif + +/* Define this if you have a software controlled poweroff */ +#define HAVE_SW_POWEROFF + +/* Some Sansa E200s seem to be FAT16 formatted */ +#define HAVE_FAT16SUPPORT + +/* The number of bytes reserved for loadable codecs */ +#define CODEC_SIZE 0x80000 + +/* The number of bytes reserved for loadable plugins */ +#define PLUGIN_BUFFER_SIZE 0x80000 + +#define AB_REPEAT_ENABLE 1 + +/* FM Tuner */ +/* TODO: #define CONFIG_TUNER LV24020LP */ +/* TODO: #define HAVE_TUNER_PWR_CTRL */ + +/* Define this for LCD backlight available */ +#define HAVE_BACKLIGHT +#define HAVE_BACKLIGHT_BRIGHTNESS + +/* define this if you have a flash memory storage */ +#define HAVE_FLASH_STORAGE + +#define HAVE_MULTIVOLUME + +#define BATTERY_CAPACITY_DEFAULT 750 /* default battery capacity */ +#define BATTERY_CAPACITY_MIN 750 /* min. capacity selectable */ +#define BATTERY_CAPACITY_MAX 750 /* max. capacity selectable */ +#define BATTERY_CAPACITY_INC 0 /* capacity increment */ +#define BATTERY_TYPES_COUNT 1 /* only one type */ + +/* Hardware controlled charging? FIXME */ +#define CONFIG_CHARGING CHARGING_SIMPLE + +/* define this if the unit can be powered or charged via USB */ +#define HAVE_USB_POWER + +/** Non-simulator section **/ +#ifndef SIMULATOR + +/* Define this if you have a PortalPlayer PP5024 */ +#define CONFIG_CPU PP5022 + +/* Define this if you want to use the PP5024 i2c interface */ +#define CONFIG_I2C I2C_PP5024 + +/* define this if the hardware can be powered off while charging */ +/* Sansa can't be powered off while charging */ +/* #define HAVE_POWEROFF_WHILE_CHARGING */ + +/* The start address index for ROM builds */ +#define ROM_START 0x00000000 + +/* Define this to the CPU frequency */ +#define CPU_FREQ 75000000 + +/* Type of LCD TODO: hopefully the same as the x5 but check this*/ +#define CONFIG_LCD LCD_C200 + +#define HAVE_HOTSWAP + +/* Offset ( in the firmware file's header ) to the file CRC and data. These are + only used when loading the old format rockbox.e200 file */ +#define FIRMWARE_OFFSET_FILE_CRC 0x0 +#define FIRMWARE_OFFSET_FILE_DATA 0x8 + +/* #define USB_IPODSTYLE */ + +/* USB On-the-go */ +#define CONFIG_USBOTG USBOTG_ARC + +/* enable these for the experimental usb stack +#define HAVE_USBSTACK +#define USBSTACK_CAPS CONTROLLER_DEVICE +*/ + +/* Virtual LED (icon) */ +#define CONFIG_LED LED_VIRTUAL + +/* Define this if you have adjustable CPU frequency */ +#define HAVE_ADJUSTABLE_CPU_FREQ + +#define MI4_FORMAT +#define BOOTFILE_EXT "mi4" +#define BOOTFILE "rockbox." BOOTFILE_EXT +#define BOOTDIR "/.rockbox" + +#define ICODE_ATTR_TREMOR_NOT_MDCT + +#define INCLUDE_TIMEOUT_API + +#endif /* SIMULATOR */ + +/** Port-specific settings **/ + +/* Main LCD backlight brightness range and defaults */ +#define MIN_BRIGHTNESS_SETTING 1 +#define MAX_BRIGHTNESS_SETTING 12 +#define DEFAULT_BRIGHTNESS_SETTING 6 + +/* Default recording levels */ +#define DEFAULT_REC_MIC_GAIN 23 +#define DEFAULT_REC_LEFT_GAIN 23 +#define DEFAULT_REC_RIGHT_GAIN 23 diff --git a/firmware/export/config.h b/firmware/export/config.h index 44583183b1..a18bf14a97 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -63,8 +63,9 @@ #define GIGABEAT_PAD 11 #define IRIVER_H10_PAD 12 #define SANSA_E200_PAD 13 -#define ELIO_TPJ1022_PAD 14 -#define ARCHOS_AV300_PAD 15 +#define SANSA_C200_PAD 14 +#define ELIO_TPJ1022_PAD 15 +#define ARCHOS_AV300_PAD 16 /* CONFIG_REMOTE_KEYPAD */ #define H100_REMOTE 1 @@ -95,6 +96,7 @@ #define LCD_H10_5GB 14 /* as used by iriver H10 5Gb */ #define LCD_TPJ1022 15 /* as used by Tatung Elio TPJ-1022 */ #define LCD_DSC25 16 /* as used by Archos AV300 */ +#define LCD_C200 17 /* as used by Sandisk Sansa c200 */ /* LCD_PIXELFORMAT */ #define HORIZONTAL_PACKING 1 @@ -191,6 +193,8 @@ #include "config-h10_5gb.h" #elif defined(SANSA_E200) #include "config-e200.h" +#elif defined(SANSA_C200) +#include "config-c200.h" #elif defined(ELIO_TPJ1022) #include "config-tpj1022.h" #else @@ -249,7 +253,7 @@ /* Enable the directory cache and tagcache in RAM if we have * plenty of RAM. Both features can be enabled independently. */ #if ((defined(MEMORYSIZE) && (MEMORYSIZE > 8)) || MEM > 8) && \ - !defined(BOOTLOADER) && !defined(SANSA_E200) + !defined(BOOTLOADER) && !defined(SANSA_E200) && !defined(SANSA_C200) #define HAVE_DIRCACHE #ifdef HAVE_TAGCACHE #define HAVE_TC_RAMCACHE diff --git a/firmware/export/usb.h b/firmware/export/usb.h index 82b9d36d4a..0c4231a4e5 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h @@ -50,7 +50,8 @@ #elif CONFIG_KEYPAD == IRIVER_H10_PAD #define USBPOWER_BUTTON BUTTON_NONE #define USBPOWER_BTN_IGNORE BUTTON_POWER -#elif CONFIG_KEYPAD == SANSA_E200_PAD +#elif (CONFIG_KEYPAD == SANSA_E200_PAD) || \ + (CONFIG_KEYPAD == SANSA_C200_PAD) #define USBPOWER_BUTTON BUTTON_SELECT #define USBPOWER_BTN_IGNORE BUTTON_POWER #endif diff --git a/firmware/target/arm/crt0-pp.S b/firmware/target/arm/crt0-pp.S index 85dd7f8b24..c1ced11cec 100644 --- a/firmware/target/arm/crt0-pp.S +++ b/firmware/target/arm/crt0-pp.S @@ -60,7 +60,7 @@ start: .space 60*4 /* (more than enough) space for exception vectors and mi4 magic */ pad_skip: -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) /* On the Sansa, copying the vectors fails if the cache is initialised */ ldr r1, =CACHE_CTRL mov r2, #0x0 diff --git a/firmware/target/arm/i2c-pp.c b/firmware/target/arm/i2c-pp.c index 07fa822ab3..1cc25a1a10 100644 --- a/firmware/target/arm/i2c-pp.c +++ b/firmware/target/arm/i2c-pp.c @@ -198,10 +198,27 @@ void i2c_init(void) outl(0x0, 0x600060a4); outl(0x80 | (0 << 8), 0x600060a4); #elif CONFIG_I2C == I2C_PP5024 +#ifdef SANSA_E200 /* Sansa OF sets this to 0x20 first, communicates with the AS3514 then sets it to 0x23 - this still works fine though */ outl(0x0, 0x600060a4); outl(0x23, 0x600060a4); +#elif defined(SANSA_C200) + /* This is the init sequence from the Sansa c200 bootloader. + I'm not sure what's really necessary. */ + pp_i2c_wait_not_busy(); + + outl(0, 0x600060a4); + outl(0x64, 0x600060a4); + + outl(0x55, 0x7000c02c); + outl(0x54, 0x7000c030); + + outl(0, 0x600060a4); + outl(0x1e, 0x600060a4); + + pp_i2c_send(0x46, 0x24, 5); +#endif #endif spinlock_init(&i2c_mutex); diff --git a/firmware/target/arm/i2s-pp.c b/firmware/target/arm/i2s-pp.c index b9e32b8789..fc01e38e91 100644 --- a/firmware/target/arm/i2s-pp.c +++ b/firmware/target/arm/i2s-pp.c @@ -142,7 +142,7 @@ void i2s_reset(void) IISFIFO_CFG |= 0x1100; } -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) void i2s_scale_attn_level(long frequency) { unsigned int iisfifo_cfg = IISFIFO_CFG & ~0xff; diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c index a61e2ab610..addc490417 100644 --- a/firmware/target/arm/sandisk/ata-c200_e200.c +++ b/firmware/target/arm/sandisk/ata-c200_e200.c @@ -519,6 +519,7 @@ static int sd_select_bank(unsigned char bank) static void sd_card_mux(int card_no) { /* Set the current card mux */ +#ifdef SANSA_E200 if (card_no == 0) { outl(inl(0x70000080) | 0x4, 0x70000080); @@ -543,6 +544,32 @@ static void sd_card_mux(int card_no) outl(inl(0x70000014) & ~(0x3ffff), 0x70000014); } +#else /* SANSA_C200 */ + if (card_no == 0) + { + outl(inl(0x70000080) | 0x4, 0x70000080); + + GPIOD_ENABLE &= ~0x1f; + GPIOD_OUTPUT_EN &= ~0x1f; + GPIOA_ENABLE |= 0x7a; + GPIOA_OUTPUT_VAL |= 0x7a; + GPIOA_OUTPUT_EN |= 0x7a; + + outl(inl(0x70000014) & ~(0x3ffff), 0x70000014); + } + else + { + outl(inl(0x70000080) & ~0x4, 0x70000080); + + GPIOA_ENABLE &= ~0x7a; + GPIOA_OUTPUT_EN &= ~0x7a; + GPIOD_ENABLE |= 0x1f; + GPIOD_OUTPUT_VAL |= 0x1f; + GPIOD_OUTPUT_EN |= 0x1f; + + outl((inl(0x70000014) & ~(0x3ffff)) | 0x255aa, 0x70000014); + } +#endif } static void sd_init_device(int card_no) diff --git a/firmware/target/arm/sandisk/backlight-c200_e200.c b/firmware/target/arm/sandisk/backlight-c200_e200.c index 29c6ab4b45..411c19f7ad 100644 --- a/firmware/target/arm/sandisk/backlight-c200_e200.c +++ b/firmware/target/arm/sandisk/backlight-c200_e200.c @@ -36,17 +36,21 @@ void __backlight_set_brightness(int brightness) void __backlight_on(void) { +#ifdef HAVE_LCD_ENABLE lcd_enable(true); /* power on lcd */ +#endif pp_i2c_send( 0x46, 0x23, backlight_brightness); } void __backlight_off(void) { pp_i2c_send( 0x46, 0x23, 0x0); +#ifdef HAVE_LCD_ENABLE lcd_enable(false); /* power off lcd */ +#endif } - +#ifdef HAVE_BUTTON_LIGHT void __button_backlight_on(void) { GPIOG_OUTPUT_VAL |=0x80; @@ -56,3 +60,4 @@ void __button_backlight_off(void) { GPIOG_OUTPUT_VAL &=~ 0x80; } +#endif diff --git a/firmware/target/arm/sandisk/backlight-target.h b/firmware/target/arm/sandisk/backlight-target.h index ac256036b9..1b1a6ad4e1 100644 --- a/firmware/target/arm/sandisk/backlight-target.h +++ b/firmware/target/arm/sandisk/backlight-target.h @@ -25,6 +25,8 @@ void __backlight_off(void); void __backlight_set_brightness(int brightness); int __backlight_is_on(void); +#ifdef HAVE_BUTTON_LIGHT void __button_backlight_on(void); void __button_backlight_off(void); #endif +#endif diff --git a/firmware/target/arm/sandisk/power-c200_e200.c b/firmware/target/arm/sandisk/power-c200_e200.c index b9a77cb9e0..cb85b117c4 100644 --- a/firmware/target/arm/sandisk/power-c200_e200.c +++ b/firmware/target/arm/sandisk/power-c200_e200.c @@ -53,7 +53,11 @@ void power_off(void) bool charger_inserted(void) { +#ifdef SANSA_E200 if(GPIOB_INPUT_VAL & 0x10) +#else /* SANSA_C200 */ + if(GPIOH_INPUT_VAL & 0x2) +#endif return true; return false; } @@ -63,6 +67,7 @@ void ide_power_enable(bool on) (void)on; } +#if CONFIG_TUNER /** Tuner **/ static bool powered = false; @@ -125,3 +130,5 @@ bool tuner_power(bool status) lv24020lp_unlock(); return old_status; } + +#endif diff --git a/firmware/target/arm/sandisk/sansa-c200/button-c200.c b/firmware/target/arm/sandisk/sansa-c200/button-c200.c new file mode 100644 index 0000000000..eedd937699 --- /dev/null +++ b/firmware/target/arm/sandisk/sansa-c200/button-c200.c @@ -0,0 +1,62 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2007 by Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "system.h" +#include "button.h" +#include "backlight.h" + +void button_init_device(void) +{ + /* TODO...for now, hardware initialisation is done by the c200 bootloader */ +} + +bool button_hold(void) +{ + return !(GPIOI_INPUT_VAL & 0x80); +} + +/* + * Get button pressed from hardware + */ +int button_read_device(void) +{ + int btn = BUTTON_NONE; + static bool hold_button = false; + bool hold_button_old; + + /* Hold */ + hold_button_old = hold_button; + hold_button = button_hold(); + + /* device buttons */ + if (!hold_button) + { + if ( (GPIOB_INPUT_VAL & 0x20)) btn |= BUTTON_POWER; + if (!(GPIOG_INPUT_VAL & 0x10)) btn |= BUTTON_UP; + if (!(GPIOH_INPUT_VAL & 0x01)) btn |= BUTTON_DOWN; + if (!(GPIOI_INPUT_VAL & 0x04)) btn |= BUTTON_LEFT; + if (!(GPIOG_INPUT_VAL & 0x02)) btn |= BUTTON_RIGHT; + if (!(GPIOL_INPUT_VAL & 0x04)) btn |= BUTTON_SELECT; + if (!(GPIOG_INPUT_VAL & 0x01)) btn |= BUTTON_REC; + if (!(GPIOL_INPUT_VAL & 0x10)) btn |= BUTTON_VOL_UP; + if (!(GPIOL_INPUT_VAL & 0x20)) btn |= BUTTON_VOL_DOWN; + } + + return btn; +} diff --git a/firmware/target/arm/sandisk/sansa-c200/button-target.h b/firmware/target/arm/sandisk/sansa-c200/button-target.h new file mode 100644 index 0000000000..6f42822f7f --- /dev/null +++ b/firmware/target/arm/sandisk/sansa-c200/button-target.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2007 by Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include +#include "config.h" + +#define HAS_BUTTON_HOLD + +bool button_hold(void); +void button_init_device(void); +int button_read_device(void); + +/* Sandisk Sansa c200 button codes */ + +/* Main unit's buttons */ +#define BUTTON_REC 0x00000001 +#define BUTTON_DOWN 0x00000002 +#define BUTTON_RIGHT 0x00000004 +#define BUTTON_LEFT 0x00000008 +#define BUTTON_SELECT 0x00000010 +#define BUTTON_UP 0x00000020 +#define BUTTON_POWER 0x00000040 +#define BUTTON_VOL_UP 0x00000080 +#define BUTTON_VOL_DOWN 0x00000100 + +#define BUTTON_MAIN 0x00000fff + +/* No Remote control */ +#define BUTTON_REMOTE 0 + +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c b/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c new file mode 100644 index 0000000000..6626ea4e6d --- /dev/null +++ b/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c @@ -0,0 +1,249 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id:$ + * + * Copyright (C) 2007 by Mark Arigo + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" +#include "cpu.h" +#include "lcd.h" +#include "kernel.h" +#include "system.h" + +#define LCD_BASE (*(volatile unsigned long *)(0x70003000)) +#define LCD_CMD (*(volatile unsigned long *)(0x70003008)) +#define LCD_DATA (*(volatile unsigned long *)(0x70003010)) + +#define LCD_BUSY 0x8000 + +/* check if number of useconds has past */ +static inline bool timer_check(int clock_start, int usecs) +{ + return ((int)(USEC_TIMER - clock_start)) >= usecs; +} + +/* wait for LCD with timeout */ +static inline void lcd_wait_write(void) +{ + int start = USEC_TIMER; + + do { + if ((LCD_BASE & LCD_BUSY) == 0) + break; + } while (timer_check(start, 1000) == 0); +} + +/* send LCD data */ +static void lcd_send_data(unsigned data) +{ + lcd_wait_write(); + LCD_DATA = (data >> 8) & 0xff; + + lcd_wait_write(); + LCD_DATA = data & 0xff; +} + +/* send LCD command */ +static void lcd_send_command(unsigned cmd) +{ + lcd_wait_write(); + LCD_CMD = cmd; +} + +/* LCD init */ +void lcd_init_device(void) +{ + /* This is from the c200 of bootloader beginning at offset 0xbbf4 */ + outl(inl(0x70000010) & ~0xfc000000, 0x70000010); + outl(inl(0x70000010), 0x70000010); + + DEV_INIT &= ~0x400; + udelay(10000); + + LCD_BASE &= ~0x4; + udelay(15); + + LCD_BASE |= 0x4; + udelay(10); + + LCD_BASE = 0x4687; + udelay(10000); + + lcd_send_command(0x2c); + udelay(20000); + + lcd_send_command(0x02); + lcd_send_command(0x01); + udelay(20000); + + lcd_send_command(0x26); + lcd_send_command(0x01); + udelay(20000); + + lcd_send_command(0x26); + lcd_send_command(0x09); + udelay(20000); + + lcd_send_command(0x26); + lcd_send_command(0x0b); + udelay(20000); + + lcd_send_command(0x26); + lcd_send_command(0x0f); + udelay(20000); + + lcd_send_command(0x10); + lcd_send_command(0x07); + + lcd_send_command(0x20); + lcd_send_command(0x03); + + lcd_send_command(0x24); + lcd_send_command(0x03); + + lcd_send_command(0x28); + lcd_send_command(0x01); + + lcd_send_command(0x2a); + lcd_send_command(0x55); + + lcd_send_command(0x30); + lcd_send_command(0x10); + + lcd_send_command(0x32); + lcd_send_command(0x0e); + + lcd_send_command(0x34); + lcd_send_command(0x0d); + + lcd_send_command(0x36); + lcd_send_command(0); + + lcd_send_command(0x40); + lcd_send_command(0x82); + + lcd_send_command(0x43); /* vertical dimensions */ + lcd_send_command(0x1a); /* y1 + 0x1a */ + lcd_send_command(LCD_HEIGHT - 1 + 0x1a); /* y2 + 0x1a */ + + lcd_send_command(0x42); /* horizontal dimensions */ + lcd_send_command(0); /* x1 */ + lcd_send_command(LCD_WIDTH - 1); /* x2 */ + udelay(100000); + + lcd_send_command(0x51); +} + +/*** hardware configuration ***/ +int lcd_default_contrast(void) +{ + return DEFAULT_CONTRAST_SETTING; +} + +void lcd_set_contrast(int val) +{ + /* TODO: Implement lcd_set_contrast() */ + (void)val; +} + +void lcd_set_invert_display(bool yesno) +{ + /* TODO: Implement lcd_set_invert_display() */ + (void)yesno; +} + +/* turn the display upside down (call lcd_update() afterwards) */ +void lcd_set_flip(bool yesno) +{ + /* TODO: Implement lcd_set_flip() */ + (void)yesno; +} + +/*** update functions ***/ + +/* Performance function that works with an external buffer + note that by and bheight are in 4-pixel units! */ +void lcd_blit(const fb_data* data, int x, int by, int width, + int bheight, int stride) +{ + /* TODO: Implement lcd_blit() */ + (void)data; + (void)x; + (void)by; + (void)width; + (void)bheight; + (void)stride; +} + +/* Performance function to blit a YUV bitmap directly to the LCD */ +void lcd_yuv_blit(unsigned char * const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + (void)src; + (void)src_x; + (void)src_y; + (void)stride; + (void)x; + (void)y; + (void)width; + (void)height; +} + +/* Update the display. + This must be called after all other LCD functions that change the display. */ +void lcd_update(void) +{ + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int x0, int y0, int width, int height) +{ + unsigned short *addr; + int c, r; + int x1 = (x0 + width) - 1; + int y1 = (y0 + height) - 1; + + if ((x1 <= 0) || (y1 <= 0)) + return; + + if(y1 >= LCD_HEIGHT) + y1 = LCD_HEIGHT - 1; + + lcd_send_command(0x43); + lcd_send_command(y0 + 0x1a); + lcd_send_command(y1 + 0x1a); + + if(x1 >= LCD_WIDTH) + x1 = LCD_WIDTH - 1; + + lcd_send_command(0x42); + lcd_send_command(x0); + lcd_send_command(x1); + + addr = (unsigned short*)&lcd_framebuffer[y0][x0]; + + /* for each row */ + for (r = 0; r < height; r++) { + /* for each column */ + for (c = 0; c < width; c++) { + /* output 1 pixel */ + lcd_send_data(*(addr++)); + } + + addr += LCD_WIDTH - width; + } +} diff --git a/firmware/target/arm/sandisk/sansa-c200/powermgmt-c200.c b/firmware/target/arm/sandisk/sansa-c200/powermgmt-c200.c new file mode 100644 index 0000000000..1de57cb184 --- /dev/null +++ b/firmware/target/arm/sandisk/sansa-c200/powermgmt-c200.c @@ -0,0 +1,58 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: powermgmt-e200.c 14375 2007-08-17 06:45:18Z amiconn $ + * + * Copyright (C) 2002 by Heikki Hannikainen, Uwe Freese + * Revisions copyright (C) 2005 by Gerald Van Baren + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" +#include "adc.h" +#include "powermgmt.h" + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + 3400 +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 3300 +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + /* Sansa Li Ion 750mAH FIXME this is a first linear approach */ + { 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 }, +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = +{ + /* Sansa Li Ion 750mAH FIXME*/ + 3300, 3390, 3480, 3570, 3660, 3750, 3840, 3930, 4020, 4110, 4200 +}; + +/* ADC should read 0x3ff=5.12V */ +#define BATTERY_SCALE_FACTOR 5125 +/* full-scale ADC readout (2^10) in millivolt */ + +/* Returns battery voltage from ADC [millivolts] */ +unsigned int battery_adc_voltage(void) +{ + return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; +} + diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index a282564d19..465457d0e1 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c @@ -120,7 +120,7 @@ static void pp_set_cpu_frequency(long frequency) while (test_and_set(&boostctrl_mtx.locked, 1)) ; #endif -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) i2s_scale_attn_level(CPUFREQ_DEFAULT); #endif @@ -183,7 +183,7 @@ static void pp_set_cpu_frequency(long frequency) CLCD_CLOCK_SRC; /* dummy read (to sync the write pipeline??) */ CLCD_CLOCK_SRC = clcd_clock_src; /* restore saved value */ -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) i2s_scale_attn_level(frequency); #endif @@ -231,7 +231,7 @@ void system_init(void) GPIOK_INT_EN = 0; GPIOL_INT_EN = 0; -#ifdef SANSA_E200 +#if defined(SANSA_E200) || defined(SANSA_C200) /* outl(0x00000000, 0x6000b000); */ outl(inl(0x6000a000) | 0x80000000, 0x6000a000); /* Init DMA controller? */ #endif diff --git a/tools/configure b/tools/configure index 2549595a62..0aa3d21382 100755 --- a/tools/configure +++ b/tools/configure @@ -616,6 +616,7 @@ cat <