From d3bc64833c76adca4d6300e5b5880ee8ea63de02 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 22 Oct 2013 00:28:09 +0200 Subject: [PATCH] Initial commit for the Creative ZEN Mozaic Change-Id: Ib65aad9f5de37e514047955cad7ca40dc0af4f74 --- apps/SOURCES | 2 + apps/keymaps/keymap-zen.c | 448 ++++++++++++++++++ firmware/SOURCES | 12 + firmware/export/config.h | 4 + .../imx233/creative-zenmozaic/adc-target.h | 29 ++ .../imx233/creative-zenmozaic/adc-zenmozaic.c | 34 ++ .../imx233/creative-zenmozaic/audio-target.h | 25 + .../creative-zenmozaic/backlight-target.h | 29 ++ .../creative-zenmozaic/backlight-zenmozaic.c | 69 +++ .../imx233/creative-zenmozaic/button-target.h | 55 +++ .../creative-zenmozaic/button-zenmozaic.c | 69 +++ .../creative-zenmozaic/debug-zenmozaic.c | 29 ++ .../fmradio-i2c-zenmozaic.c | 40 ++ .../imx233/creative-zenmozaic/lcd-target.h | 27 ++ .../imx233/creative-zenmozaic/lcd-zenmozaic.c | 152 ++++++ .../creative-zenmozaic/power-zenmozaic.c | 57 +++ .../creative-zenmozaic/powermgmt-target.h | 55 +++ .../creative-zenmozaic/powermgmt-zenmozaic.c | 49 ++ firmware/target/arm/imx233/sdmmc-imx233.c | 7 + tools/configure | 20 + tools/scramble.c | 2 + 21 files changed, 1214 insertions(+) create mode 100644 apps/keymaps/keymap-zen.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/adc-target.h create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/adc-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/audio-target.h create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/backlight-target.h create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/button-target.h create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/lcd-target.h create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/powermgmt-target.h create mode 100644 firmware/target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.c diff --git a/apps/SOURCES b/apps/SOURCES index f050fd1e83..8fa1a7ed40 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -287,6 +287,8 @@ keymaps/keymap-hm801.c keymaps/keymap-sansa-connect.c #elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD keymaps/keymap-ypr0.c +#elif CONFIG_KEYPAD == CREATIVE_ZEN_PAD +keymaps/keymap-zen.c #elif CONFIG_KEYPAD == MA_PAD keymaps/keymap-ma.c #elif CONFIG_KEYPAD == SONY_NWZ_PAD diff --git a/apps/keymaps/keymap-zen.c b/apps/keymaps/keymap-zen.c new file mode 100644 index 0000000000..dda12959d8 --- /dev/null +++ b/apps/keymaps/keymap-zen.c @@ -0,0 +1,448 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © Amaury Pouly 2013 + * + * 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 "config.h" +#include "action.h" +#include "button.h" +#include "settings.h" + +/** This keymap is shared by the ZEN targets with some variants. All ZEN targets + * shared a core set of buttons: left, right, up, down, select, back, play/pause + * and they all have a hold button. Two extra groups of button may exist: + * (ctl) menu, shortcut + * (dir) top left, top right, bottom left, bottom left + * (vol) vol up, vol down + * Here is the list of ZEN targets are the groups: + * target core ctl dir vol + * V (Plus) 1 0 0 1 + * Mozaic 1 1 0 0 + * ZEN 1 1 0 0 + * X-Fi 1 1 1 0 */ + +/* {Action Code, Button code, Prereq button code } */ + +#ifdef BUTTON_VOL_UP +#define ZEN_HAS_VOL +#endif + +#ifdef BUTTON_BOTTOMLEFT +#define ZEN_HAS_DIRECTIONAL +#endif + +#ifdef BUTTON_MENU +#define ZEN_HAS_CONTROL +#endif + +/* + * 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_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + { ACTION_STD_CONTEXT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + + { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_BACK|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + + LAST_ITEM_IN_LIST +}; /* button_context_standard */ + +static const struct button_mapping button_context_wps[] = { + { ACTION_WPS_PLAY, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + { ACTION_WPS_STOP, BUTTON_PLAYPAUSE|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { 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_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, + +#ifdef ZEN_HAS_VOL + { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, +#endif + { ACTION_WPS_VOLUP, BUTTON_UP, BUTTON_NONE }, + { ACTION_WPS_VOLUP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + +#ifdef ZEN_HAS_VOL + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, +#endif + { ACTION_WPS_VOLDOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_WPS_VOLDOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_WPS_MENU, BUTTON_BACK, BUTTON_NONE }, + { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_wps */ + +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_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_BACK, BUTTON_NONE }, + { ACTION_KBD_BACKSPACE, BUTTON_BACK|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_KBD_SELECT, BUTTON_PLAYPAUSE, BUTTON_NONE }, + { ACTION_KBD_DONE, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + { ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE }, + +#ifdef ZEN_HAS_VOL + { ACTION_KBD_MORSE_INPUT, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_KBD_MORSE_SELECT, BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_NONE }, +#endif + + LAST_ITEM_IN_LIST +}; /* button_context_keyboard */ + +static const struct button_mapping button_context_quickscreen[] = { + { ACTION_STD_CANCEL, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_PLAYPAUSE, BUTTON_NONE }, + { ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE }, + { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_quickscreen */ + +static const struct button_mapping button_context_tree[] = { + { ACTION_TREE_WPS, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + { ACTION_TREE_STOP, BUTTON_PLAYPAUSE|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST) +}; /* button_context_tree */ + +static const struct button_mapping button_context_list[] = { +#ifdef HAVE_VOLUME_IN_LIST +#ifdef ZEN_HAS_VOL + { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, +#endif +#endif +/*#ifdef HAVE_HOTKEY on some gesture later? + { ACTION_TREE_HOTKEY, BUTTON_BACK|BUTTON_REL, BUTTON_BACK|BUTTON_REPEAT }, +#endif*/ + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_list */ + +#ifdef CONFIG_TUNER +static const struct button_mapping button_context_radio[] = { + { ACTION_FM_MENU, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_FM_PLAY, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + { ACTION_FM_STOP, BUTTON_PLAYPAUSE|BUTTON_REPEAT, BUTTON_NONE }, +#ifdef ZEN_HAS_VOL + { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, +#endif + + { ACTION_FM_EXIT, BUTTON_BACK, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) +}; /* button_context_radio */ +#endif + +#ifdef HAVE_RECORDING +static const struct button_mapping button_context_recscreen[] = { + { ACTION_REC_PAUSE, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + { 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 }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_recscreen */ +#endif + +static const struct button_mapping button_context_settings[] = { + /* we overwrite this to avoid select from std */ + { ACTION_NONE, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + + { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|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 }, + + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_SETTINGS_RESET, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_settings */ + +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_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 }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) +}; /* button_context_settingsgraphical */ + +static const struct button_mapping button_context_time[] = { + + { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_PLAYPAUSE, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS) +}; /* button_context_time */ + +static const struct button_mapping button_context_colorchooser[] = { + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS), +}; /* button_context_colorchooser */ + +static const struct button_mapping button_context_eq[] = { + { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS), +}; /* button_context_eq */ + +/* Bookmark Screen */ +static const struct button_mapping button_context_bmark[] = { + { ACTION_BMS_DELETE, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST), +}; /* button_context_bmark */ + +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_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_PS_NUDGE_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_PS_RESET, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_PS_EXIT, BUTTON_BACK, BUTTON_NONE }, + { ACTION_PS_EXIT, BUTTON_PLAYPAUSE, BUTTON_NONE }, + + LAST_ITEM_IN_LIST +}; /* button_context_pitchcreen */ + +static const struct button_mapping button_context_yesno[] = { + { ACTION_YESNO_ACCEPT, BUTTON_SELECT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD) +}; /* button_context_yesno */ + +#ifdef USB_ENABLE_HID +static const struct button_mapping button_context_usb_hid[] = { + { ACTION_USB_HID_MODE_SWITCH_NEXT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER }, + { ACTION_USB_HID_MODE_SWITCH_PREV, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER }, + + LAST_ITEM_IN_LIST +}; /* button_context_usb_hid */ + +static const struct button_mapping button_context_usb_hid_mode_multimedia[] = { + + { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, +#ifdef ZEN_HAS_VOL + { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, +#endif + { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, + { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE, BUTTON_BACK|BUTTON_REL, BUTTON_BACK }, + { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP, BUTTON_PLAYPAUSE|BUTTON_REPEAT, BUTTON_PLAYPAUSE }, + { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_PREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_NEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) +}; /* button_context_usb_hid_mode_multimedia */ + + +static const struct button_mapping button_context_usb_hid_mode_presentation[] = { + { ACTION_USB_HID_PRESENTATION_SLIDESHOW_START, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + { ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE, BUTTON_PLAYPAUSE|BUTTON_REPEAT, BUTTON_PLAYPAUSE }, + { ACTION_USB_HID_PRESENTATION_SLIDE_PREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_USB_HID_PRESENTATION_SLIDE_NEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_USB_HID_PRESENTATION_SLIDE_FIRST, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_PRESENTATION_SLIDE_LAST, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_PRESENTATION_LINK_PREV, BUTTON_UP, BUTTON_NONE }, + { ACTION_USB_HID_PRESENTATION_LINK_PREV, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_PRESENTATION_LINK_NEXT, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_USB_HID_PRESENTATION_LINK_NEXT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_PRESENTATION_MOUSE_CLICK, BUTTON_SELECT, BUTTON_SELECT }, + { ACTION_USB_HID_PRESENTATION_MOUSE_OVER, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) +}; /* button_context_usb_hid_mode_presentation */ + +static const struct button_mapping button_context_usb_hid_mode_browser[] = { + { ACTION_USB_HID_BROWSER_SCROLL_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_SCROLL_UP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_SCROLL_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_SCROLL_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, +#ifdef ZEN_HAS_VOL + { ACTION_USB_HID_BROWSER_ZOOM_IN, BUTTON_VOL_UP, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_ZOOM_IN, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_ZOOM_OUT, BUTTON_VOL_DOWN, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_ZOOM_OUT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE }, +#endif + { ACTION_USB_HID_BROWSER_ZOOM_RESET, BUTTON_PLAYPAUSE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_BROWSER_TAB_PREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, + { ACTION_USB_HID_BROWSER_TAB_NEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, + { ACTION_USB_HID_BROWSER_TAB_CLOSE, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK }, + { ACTION_USB_HID_BROWSER_HISTORY_BACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT }, + { ACTION_USB_HID_BROWSER_HISTORY_FORWARD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT }, + { ACTION_USB_HID_BROWSER_VIEW_FULL_SCREEN, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) +}; /* button_context_usb_hid_mode_browser */ + +#ifdef HAVE_USB_HID_MOUSE +static const struct button_mapping button_context_usb_hid_mode_mouse[] = { + { ACTION_USB_HID_MOUSE_UP, BUTTON_UP, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_UP_REP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_DOWN, BUTTON_DOWN, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_DOWN_REP, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_LEFT, BUTTON_LEFT, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_LEFT_REP, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_RIGHT, BUTTON_RIGHT, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_RIGHT_REP, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_USB_HID_MOUSE_BUTTON_LEFT, BUTTON_SELECT, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_BUTTON_LEFT_REL, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE }, + + { ACTION_USB_HID_MOUSE_BUTTON_RIGHT, BUTTON_PLAYPAUSE, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_BUTTON_RIGHT_REL, BUTTON_PLAYPAUSE|BUTTON_REL, BUTTON_PLAYPAUSE }, + + { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP, BUTTON_BACK, BUTTON_NONE }, + { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP, BUTTON_BACK|BUTTON_REPEAT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID) +}; /* button_context_usb_hid_mode_mouse */ +#endif +#endif + +/* 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_MAINMENU: + return button_context_tree; + case CONTEXT_SETTINGS: + return button_context_settings; + case CONTEXT_WPS: + return button_context_wps; + case CONTEXT_YESNOSCREEN: + return button_context_yesno; + case CONTEXT_SETTINGS_TIME: + return button_context_time; + case CONTEXT_KEYBOARD: + case CONTEXT_MORSE_INPUT: + return button_context_keyboard; +#ifdef CONFIG_TUNER + case CONTEXT_FM: + return button_context_radio; +#endif + case CONTEXT_LIST: + return button_context_list; + case CONTEXT_TREE: + return button_context_tree; + case CONTEXT_SETTINGS_EQ: + return button_context_eq; +#ifdef HAVE_RECORDING + case CONTEXT_RECSCREEN: + return button_context_recscreen; +#endif + case CONTEXT_QUICKSCREEN: + return button_context_quickscreen; + case CONTEXT_BOOKMARKSCREEN: + return button_context_bmark; + case CONTEXT_PITCHSCREEN: + return button_context_pitchscreen; + case CONTEXT_SETTINGS_COLOURCHOOSER: + return button_context_colorchooser; + case CONTEXT_SETTINGS_RECTRIGGER: + return button_context_settings_right_is_inc; + case CONTEXT_CUSTOM|CONTEXT_SETTINGS: + return button_context_settings_right_is_inc; +#ifdef USB_ENABLE_HID + case CONTEXT_USB_HID: + return button_context_usb_hid; + case CONTEXT_USB_HID_MODE_MULTIMEDIA: + return button_context_usb_hid_mode_multimedia; + case CONTEXT_USB_HID_MODE_PRESENTATION: + return button_context_usb_hid_mode_presentation; + case CONTEXT_USB_HID_MODE_BROWSER: + return button_context_usb_hid_mode_browser; +#ifdef HAVE_USB_HID_MOUSE + case CONTEXT_USB_HID_MODE_MOUSE: + return button_context_usb_hid_mode_mouse; +#endif +#endif + default: + return button_context_standard; + } + return button_context_standard; +} + diff --git a/firmware/SOURCES b/firmware/SOURCES index 884e1102e2..f6df418049 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES @@ -1184,6 +1184,18 @@ target/arm/imx233/creative-zenxfi3/adc-zenxfi3.c target/arm/imx233/creative-zenxfi3/powermgmt-zenxfi3.c #endif +#ifdef CREATIVE_ZENMOZAIC +target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c +target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.c +target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c +target/arm/imx233/creative-zenmozaic/button-zenmozaic.c +target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c +target/arm/imx233/creative-zenmozaic/power-zenmozaic.c +target/arm/imx233/creative-zenmozaic/adc-zenmozaic.c +target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.c +target/arm/imx233/button-lradc-imx233.c +#endif + #if defined(SONY_NWZE360) || defined(SONY_NWZE370) target/arm/imx233/button-lradc-imx233.c target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c diff --git a/firmware/export/config.h b/firmware/export/config.h index 3ee2330879..37146b649d 100644 --- a/firmware/export/config.h +++ b/firmware/export/config.h @@ -149,6 +149,7 @@ #define CREATIVE_ZENXFI3_PAD 55 #define MA_PAD 56 #define SONY_NWZ_PAD 57 +#define CREATIVE_ZEN_PAD 58 /* CONFIG_REMOTE_KEYPAD */ #define H100_REMOTE 1 @@ -253,6 +254,7 @@ #define LCD_ILI9342 50 /* as used by HiFi E.T MA9/MA8 */ #define LCD_NWZE370 51 /* as used by Sony NWZ-E370 series */ #define LCD_NWZE360 52 /* as used by Sony NWZ-E360 series */ +#define LCD_CREATIVEZENMOZAIC 56 /* as used by the Creative ZEN Mozaic (FGD0801) */ /* LCD_PIXELFORMAT */ #define HORIZONTAL_PACKING 1 @@ -521,6 +523,8 @@ Lyre prototype 1 */ #include "config/pandora.h" #elif defined(SAMSUNG_YPR0) #include "config/samsungypr0.h" +#elif defined(CREATIVE_ZENMOZAIC) +#include "config/creativezenmozaic.h" #elif defined(MA9) #include "config/hifietma9.h" #elif defined(SONY_NWZE370) diff --git a/firmware/target/arm/imx233/creative-zenmozaic/adc-target.h b/firmware/target/arm/imx233/creative-zenmozaic/adc-target.h new file mode 100644 index 0000000000..5a525152f6 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/adc-target.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +#define NUM_ADC_CHANNELS 2 + +#define ADC_BATTERY 0 +#define ADC_DIE_TEMP 1 + +#endif diff --git a/firmware/target/arm/imx233/creative-zenmozaic/adc-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/adc-zenmozaic.c new file mode 100644 index 0000000000..92c1063c24 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/adc-zenmozaic.c @@ -0,0 +1,34 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "adc-target.h" +#include "adc-imx233.h" + +int imx233_adc_mapping[] = +{ + [ADC_DIE_TEMP] = IMX233_ADC_DIE_TEMP, + [ADC_BATTERY] = IMX233_ADC_BATTERY, +}; + +const char *imx233_adc_channel_name[] = +{ + "Die temperature(°C)", + "Battery(raw)", +}; diff --git a/firmware/target/arm/imx233/creative-zenmozaic/audio-target.h b/firmware/target/arm/imx233/creative-zenmozaic/audio-target.h new file mode 100644 index 0000000000..4ee2e2f402 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/audio-target.h @@ -0,0 +1,25 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 __audio_target__ +#define __audio_target__ + +#endif /* __audio_target__ */ + diff --git a/firmware/target/arm/imx233/creative-zenmozaic/backlight-target.h b/firmware/target/arm/imx233/creative-zenmozaic/backlight-target.h new file mode 100644 index 0000000000..78a0a72d85 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/backlight-target.h @@ -0,0 +1,29 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +bool _backlight_init(void); +void _backlight_on(void); +void _backlight_off(void); +void _backlight_set_brightness(int brightness); + +#endif /* BACKLIGHT_TARGET_H */ diff --git a/firmware/target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.c new file mode 100644 index 0000000000..0d223b52e9 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/backlight-zenmozaic.c @@ -0,0 +1,69 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "config.h" +#include "system.h" +#include "backlight.h" +#include "lcd.h" +#include "backlight-target.h" +#include "uartdbg-imx233.h" +#include "pinctrl-imx233.h" + +void _backlight_set_brightness(int level) +{ + unsigned val = (level + 200) * level / 1000; + if(level != 0) + { + for(unsigned mask = 0x10; mask; mask >>= 1) + imx233_uartdbg_send((val & mask) ? 0xff : 0xf8); + imx233_uartdbg_send(0); + imx233_pinctrl_set_gpio(1, 12, true); + } + else + imx233_pinctrl_set_gpio(1, 12, false); +} + +bool _backlight_init(void) +{ + imx233_pinctrl_acquire(1, 12, "backlight_enable"); + imx233_pinctrl_set_function(1, 12, PINCTRL_FUNCTION_GPIO); + imx233_pinctrl_enable_gpio(1, 12, true); + imx233_uartdbg_init(BAUD_38400); + return true; +} + +void _backlight_on(void) +{ +#ifdef HAVE_LCD_ENABLE + lcd_enable(true); /* power on lcd + visible display */ +#endif + /* restore the previous backlight level */ + _backlight_set_brightness(backlight_brightness); +} + +void _backlight_off(void) +{ + /* there is no real on/off but we can set to 0 brightness */ + _backlight_set_brightness(0); +#ifdef HAVE_LCD_ENABLE + lcd_enable(false); /* power off visible display */ +#endif +} diff --git a/firmware/target/arm/imx233/creative-zenmozaic/button-target.h b/firmware/target/arm/imx233/creative-zenmozaic/button-target.h new file mode 100644 index 0000000000..714e9983fd --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/button-target.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include + +bool button_debug_screen(void); + +#define HAS_BUTTON_HOLD +#define HAVE_HEADPHONE_DETECTION + +#define IMX233_BUTTON_LRADC_CHANNEL 0 +#define IMX233_BUTTON_LRADC_HOLD_DET BLH_ADC + +/* Main unit's buttons */ +#define BUTTON_POWER 0x00000001 +#define BUTTON_LEFT 0x00000002 +#define BUTTON_UP 0x00000004 +#define BUTTON_RIGHT 0x00000008 +#define BUTTON_DOWN 0x00000010 +#define BUTTON_SELECT 0x00000020 +#define BUTTON_PLAYPAUSE 0x00000040 +#define BUTTON_BACK 0x00000080 +#define BUTTON_MENU 0x00000100 +#define BUTTON_SHORTCUT 0x00000200 + + +#define BUTTON_MAIN (BUTTON_POWER|BUTTON_LEFT|BUTTON_UP|BUTTON_RIGHT|\ + BUTTON_DOWN|BUTTON_SELECT|BUTTON_PLAYPAUSE|BUTTON_BACK|\ + BUTTON_MENU|BUTTON_SHORTCUT) + +/* Software power-off */ +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.c new file mode 100644 index 0000000000..bf6729a273 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/button-zenmozaic.c @@ -0,0 +1,69 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "button-target.h" +#include "system.h" +#include "system-target.h" +#include "pinctrl-imx233.h" +#include "power-imx233.h" +#include "button-lradc-imx233.h" + +struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] = +{ + {0, IMX233_BUTTON_LRADC_HOLD}, + {200, BUTTON_MENU}, + {445, BUTTON_SHORTCUT}, + {645, BUTTON_UP}, + {860, BUTTON_LEFT}, + {1060, BUTTON_RIGHT}, + {1260, BUTTON_DOWN}, + {1480, BUTTON_SELECT}, + {2700, BUTTON_BACK}, + {2945, BUTTON_PLAYPAUSE}, + {3400, 0}, + {0, IMX233_BUTTON_LRADC_END}, +}; + +void button_init_device(void) +{ + imx233_button_lradc_init(); + + imx233_pinctrl_acquire(2, 8, "jack_detect"); + imx233_pinctrl_set_function(2, 8, PINCTRL_FUNCTION_GPIO); + imx233_pinctrl_enable_gpio(2, 8, false); +} + +bool headphones_inserted(void) +{ + return imx233_pinctrl_get_gpio(2, 8); +} + +bool button_hold(void) +{ + return imx233_button_lradc_hold(); +} + +int button_read_device(void) +{ + int btn = 0; + if(BF_RD(POWER_STS, PSWITCH) == 1) + btn |= BUTTON_POWER; + return imx233_button_lradc_read(btn); +} diff --git a/firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c new file mode 100644 index 0000000000..a350d0ae62 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/debug-zenmozaic.c @@ -0,0 +1,29 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "system.h" +#include "button-target.h" +#include "lcd-target.h" + +bool dbg_hw_target_info(void) +{ + return false; +} diff --git a/firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c new file mode 100644 index 0000000000..a1377ce1f2 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/fmradio-i2c-zenmozaic.c @@ -0,0 +1,40 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "config.h" +#include "system.h" +#include "fmradio_i2c.h" +#include "pinctrl-imx233.h" +#include "i2c.h" + +void fmradio_i2c_init(void) +{ +} + +int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count) +{ + return i2c_write(address, buf, count); +} + +int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count) +{ + return i2c_read(address, buf, count); +} diff --git a/firmware/target/arm/imx233/creative-zenmozaic/lcd-target.h b/firmware/target/arm/imx233/creative-zenmozaic/lcd-target.h new file mode 100644 index 0000000000..5133c75d1b --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/lcd-target.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (c) 2013 by Amaury Pouly + * + * 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_TARGET_H +#define LCD_TARGET_H + +bool lcd_debug_screen(void); +void lcd_set_contrast(int val); + +#endif /* LCD_TARGET_H */ diff --git a/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c new file mode 100644 index 0000000000..eac36676ae --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/lcd-zenmozaic.c @@ -0,0 +1,152 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (c) 2013 by Amaury Pouly + * + * 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 /* off_t */ +#include +#include "cpu.h" +#include "system.h" +#include "backlight-target.h" +#include "lcd.h" +#include "lcdif-imx233.h" +#include "clkctrl-imx233.h" +#include "pinctrl-imx233.h" +#include "dcp-imx233.h" +#include "logf.h" +#ifndef BOOTLOADER +#include "button.h" +#include "font.h" +#include "action.h" +#endif + +#ifdef HAVE_LCD_ENABLE +static bool lcd_on; +#endif + +static void lcd_write_reg(uint16_t reg, uint16_t value) +{ + imx233_lcdif_set_data_swizzle(3); + imx233_lcdif_pio_send(false, 2, ®); + if(reg != 0x22) + imx233_lcdif_pio_send(true, 2, &value); +} + +void lcd_init_device(void) +{ + /* clock at 24MHZ */ + imx233_clkctrl_enable(CLK_PIX, false); + imx233_clkctrl_set_div(CLK_PIX, 3); + imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */ + imx233_clkctrl_enable(CLK_PIX, true); + imx233_lcdif_init(); + imx233_lcdif_setup_system_pins(8); + imx233_lcdif_set_timings(2, 2, 2, 2); + imx233_lcdif_set_word_length(8); + + lcd_write_reg(0, 1); + lcd_write_reg(3, 0); + + lcd_write_reg(3, 0x510); + lcd_write_reg(9, 8); + lcd_write_reg(0xc, 0); + lcd_write_reg(0xd, 0); + lcd_write_reg(0xe, 0); + lcd_write_reg(0x5b, 4); + lcd_write_reg(0xd, 0x10); + lcd_write_reg(9, 0); + lcd_write_reg(3, 0x10); + lcd_write_reg(0xd, 0x14); + lcd_write_reg(0xe, 0x2b12); + lcd_write_reg(1, 0x21f); + lcd_write_reg(2, 0x700); + lcd_write_reg(5, 0x30); + lcd_write_reg(6, 0); + lcd_write_reg(8, 0x202); + lcd_write_reg(0xa, 0x3); // OF uses 0xc0003 with 3 transfers/pixels + lcd_write_reg(0xb, 0); + lcd_write_reg(0xf, 0); + lcd_write_reg(0x10, 0); + lcd_write_reg(0x11, 0); + lcd_write_reg(0x14, 0x9f00); + lcd_write_reg(0x15, 0x9f00); + lcd_write_reg(0x16, 0x7f00); + lcd_write_reg(0x17, 0x9f00); + lcd_write_reg(0x20, 0); + lcd_write_reg(0x21, 0); + lcd_write_reg(0x23, 0); + lcd_write_reg(0x24, 0); + lcd_write_reg(0x25, 0); + lcd_write_reg(0x26, 0); + lcd_write_reg(0x30, 0x707); + lcd_write_reg(0x31, 0x504); + lcd_write_reg(0x32, 7); + lcd_write_reg(0x33, 0x307); + lcd_write_reg(0x34, 7); + lcd_write_reg(0x35, 0x400); + lcd_write_reg(0x36, 0x607); + lcd_write_reg(0x37, 0x703); + lcd_write_reg(0x3a, 0x1a0d); + lcd_write_reg(0x3b, 0x1309); + + lcd_write_reg(9, 4); + lcd_write_reg(7, 5); + lcd_write_reg(7, 0x25); + lcd_write_reg(7, 0x27); + lcd_write_reg(0x5b, 0); + lcd_write_reg(7, 0x37); +#ifdef HAVE_LCD_ENABLE + lcd_on = true; +#endif +} + +#ifdef HAVE_LCD_ENABLE +bool lcd_active(void) +{ + return lcd_on; +} + +void lcd_enable(bool enable) +{ + if(lcd_on == enable) + return; + + lcd_on = enable; +} +#endif + +void lcd_update(void) +{ + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} + +void lcd_update_rect(int x, int y, int w, int h) +{ + #ifdef HAVE_LCD_ENABLE + if(!lcd_on) + return; + #endif + + imx233_lcdif_wait_ready(); + lcd_write_reg(0x16, x | (x + w - 1) << 8); + lcd_write_reg(0x17, y | (y + h - 1) << 8); + lcd_write_reg(0x21, y * LCD_WIDTH + x); + lcd_write_reg(0x22, 0); + for(int yy = y; yy < y + h; yy++) + imx233_lcdif_pio_send(true, 2 * w, FBADDR(x, yy)); +} diff --git a/firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c new file mode 100644 index 0000000000..1bed2ffcca --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/power-zenmozaic.c @@ -0,0 +1,57 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "system.h" +#include "power.h" +#include "tuner.h" +#include "fmradio_i2c.h" +#include "pinctrl-imx233.h" +#include "power-imx233.h" + +static bool tuner_enable = false; +static bool initialised = false; + +static void init(void) +{ + /* CE is B2P15 (active high) */ + imx233_pinctrl_acquire(2, 15, "tuner power"); + imx233_pinctrl_set_function(2, 15, PINCTRL_FUNCTION_GPIO); + imx233_pinctrl_enable_gpio(2, 15, true); + initialised = true; +} + +bool tuner_power(bool enable) +{ + if(!initialised) + init(); + if(tuner_enable != enable) + { + imx233_pinctrl_set_gpio(2, 15, enable); + sleep(HZ / 5); + tuner_enable = enable; + } + return tuner_enable; +} + +bool tuner_powered(void) +{ + return tuner_enable; +} \ No newline at end of file diff --git a/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-target.h b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-target.h new file mode 100644 index 0000000000..57a6b82ec9 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-target.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 POWERMGMT_TARGET_H +#define POWERMGMT_TARGET_H + +#include "config.h" +#include "powermgmt-imx233.h" + +/* ZEN Mozaic OF settings: + * - current ramp slope: + * - conditioning threshold voltage: + * - conditioning max voltage: + * - conditioning current: + * - conditioning timeout: + * - charging voltage: + * - charging current: + * - charging threshold current: + * - charging timeout: + * - top off period: + * - high die temperature: + * - low die temperature: + * - safe die temperature current: + * - battery temperature channel: + * - high battery temperature: + * - low battery temperature: + * - safe battery temperature current: + * - low DCDC battery voltage: + */ + +#define IMX233_CHARGE_CURRENT 200 +#define IMX233_STOP_CURRENT 30 +#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ) +#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ) +#define IMX233_DIE_TEMP_HIGH 71 +#define IMX233_DIE_TEMP_LOW 56 + +#endif /* POWERMGMT_TARGET_H */ diff --git a/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.c b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.c new file mode 100644 index 0000000000..1e986813f9 --- /dev/null +++ b/firmware/target/arm/imx233/creative-zenmozaic/powermgmt-zenmozaic.c @@ -0,0 +1,49 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 by Amaury Pouly + * + * 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 "config.h" +#include "powermgmt-target.h" +#include "power-imx233.h" + +#warning FIXME calibrate + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + 0 +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 0 +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + /* Sansa Fuze+ Li Ion 600mAH figured from discharge curve */ + { 3100, 3650, 3720, 3750, 3780, 3820, 3880, 4000, 4040, 4125, 4230 }, +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = +{ + /* Sansa Fuze+ Li Ion 600mAH figured from charge curve */ + 3480, 3790, 3845, 3880, 3900, 3935, 4005, 4070, 4150, 4250, 4335 +}; \ No newline at end of file diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c index 7caff7b466..15eeed1371 100644 --- a/firmware/target/arm/imx233/sdmmc-imx233.c +++ b/firmware/target/arm/imx233/sdmmc-imx233.c @@ -127,6 +127,13 @@ struct sdmmc_config_t sdmmc_config[] = .ssp = 1, .mode = SD_MODE, }, +#elif defined(CREATIVE_ZENMOZAIC) + { + .name = "internal/SD", + .flags = WINDOW, + .ssp = 2, + .mode = SD_MODE, + } #elif defined(SONY_NWZE370) || defined(SONY_NWZE360) /* The Sony NWZ-E370 uses #B1P29 for power */ { diff --git a/tools/configure b/tools/configure index ad702aab60..7746044396 100755 --- a/tools/configure +++ b/tools/configure @@ -2280,6 +2280,26 @@ fi arm926ejscc ;; + 97|creativezenmozaic) + target_id=87 + modelname="creativezenmozaic" + target="CREATIVE_ZENMOZAIC" + memory=32 + bmp2rb_mono="$rootdir/tools/bmp2rb -f 0" + bmp2rb_native="$rootdir/tools/bmp2rb -f 4" + tool="$rootdir/tools/scramble -add=zmoz" + output="rockbox.creative" + bootoutput="bootloader-zenmozaic.creative" + appextra="gui:recorder:radio" + plugins="" + swcodec="yes" + toolset=$scramblebitmaptools + t_cpu="arm" + t_manufacturer="imx233" + t_model="creative-zenmozaic" + arm926ejscc + ;; + 50|sansae200) target_id=23 modelname="sansae200" diff --git a/tools/scramble.c b/tools/scramble.c index c29634bb6c..e37bec8195 100644 --- a/tools/scramble.c +++ b/tools/scramble.c @@ -365,6 +365,8 @@ int main (int argc, char** argv) modelnum = 82; else if (!strcmp(&argv[1][5], "zxf3")) /* Creative Zen X-Fi3 */ modelnum = 83; + else if (!strcmp(&argv[1][5], "zmoz")) /* Creative ZEN Mozaic*/ + modelnum = 87; else if (!strcmp(&argv[1][5], "e370")) /* Sony NWZ-E370 series */ modelnum = 88; else if (!strcmp(&argv[1][5], "e360")) /* Sony NWZ-E360 series */