summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/SOURCES2
-rw-r--r--apps/keymaps/keymap-ypz5.c406
-rw-r--r--firmware/SOURCES12
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/export/config/samsungypz5.h201
-rw-r--r--firmware/target/arm/imx233/power-imx233.c2
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/audio-target.h31
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/backlight-target.h28
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c149
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/button-target.h59
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c273
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c29
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h31
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/ftl-target.h39
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/lcd-target.h25
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c294
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h37
-rw-r--r--firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c48
-rw-r--r--firmware/target/arm/imx233/touchscreen-imx233.c27
-rwxr-xr-xtools/configure21
-rw-r--r--tools/scramble.c4
21 files changed, 1721 insertions, 1 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 3968666d98..0e7fc3efca 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -297,5 +297,7 @@ keymaps/keymap-zen.c
keymaps/keymap-ma.c
#elif CONFIG_KEYPAD == SONY_NWZ_PAD
keymaps/keymap-nwz.c
+#elif CONFIG_KEYPAD == SAMSUNG_YPZ5_PAD
+keymaps/keymap-ypz5.c
#endif
diff --git a/apps/keymaps/keymap-ypz5.c b/apps/keymaps/keymap-ypz5.c
new file mode 100644
index 0000000000..edeebbac3f
--- /dev/null
+++ b/apps/keymaps/keymap-ypz5.c
@@ -0,0 +1,406 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 Lorenzo Miori
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* Button Code Definitions for the Creative Zen Vision target */
+/* Copied from ZVM target for now... */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "config.h"
+#include "action.h"
+#include "button.h"
+#include "settings.h"
+
+/*
+ * 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
+ */
+
+/* CONTEXT_CUSTOM's used in this file...
+
+CONTEXT_CUSTOM|CONTEXT_TREE = the standard list/tree defines (without directions)
+CONTEXT_CUSTOM|CONTEXT_SETTINGS = the direction keys for the eq/col picker screens
+ i.e where up/down is inc/dec
+ CONTEXT_SETTINGS = up/down is prev/next, l/r is inc/dec
+
+*/
+
+static const struct button_mapping button_context_standard[] = {
+ { 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_STD_PREV, BUTTON_FF|BUTTON_REL, BUTTON_NONE },
+ { ACTION_STD_PREVREPEAT, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_NEXT, BUTTON_REW|BUTTON_REL, BUTTON_NONE },
+ { ACTION_STD_NEXTREPEAT, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
+
+ { ACTION_STD_CANCEL, BUTTON_BACK|BUTTON_REL, BUTTON_NONE },
+
+ { ACTION_STD_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
+
+ //{ ACTION_STD_QUICKSCREEN, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK },
+ { ACTION_STD_MENU, BUTTON_BACK|BUTTON_REPEAT, BUTTON_NONE },
+
+ { ACTION_STD_OK, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
+// { ACTION_STD_OK, BUTTON_RIGHT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_standard */
+
+
+static const struct button_mapping button_context_wps[] = {
+ { ACTION_WPS_PLAY, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ //{ ACTION_WPS_STOP, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
+
+ { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
+ { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
+
+ { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|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 },
+
+ { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
+
+ //{ ACTION_WPS_PITCHSCREEN, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK },
+
+ { ACTION_WPS_QUICKSCREEN, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK },
+ { ACTION_WPS_MENU, BUTTON_BACK|BUTTON_REL, BUTTON_BACK },
+ { ACTION_WPS_VIEW_PLAYLIST, BUTTON_POWER, BUTTON_NONE },
+ { ACTION_WPS_CONTEXT, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT },
+
+ { ACTION_WPS_HOTKEY, BUTTON_BACK|BUTTON_REL, BUTTON_NONE },
+ { ACTION_WPS_BROWSE, BUTTON_SELECT|BUTTON_REL, BUTTON_BACK },
+ LAST_ITEM_IN_LIST
+}; /* button_context_wps */
+
+static const struct button_mapping button_context_list[] = {
+#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_POWER|BUTTON_REL, BUTTON_POWER },
+ //{ ACTION_TREE_STOP, BUTTON_POWER, BUTTON_NONE },
+ //{ ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ //{ ACTION_TREE_STOP, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
+ //{ ACTION_TREE_HOTKEY, BUTTON_BACK|BUTTON_REL, BUTTON_NONE },
+
+ 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_BACK|BUTTON_REL, BUTTON_BACK },
+ { ACTION_TREE_ROOT_INIT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_LEFT },
+ { ACTION_TREE_PGLEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_NONE, BUTTON_RIGHT, BUTTON_NONE },
+ { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT },
+ { ACTION_TREE_PGRIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_TREE),
+};
+
+static const struct button_mapping button_context_settings[] = {
+ { 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_LEFT },
+ { ACTION_STD_NEXT, BUTTON_RIGHT, BUTTON_NONE },
+ { ACTION_STD_NEXTREPEAT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_RIGHT },
+ { ACTION_SETTINGS_RESET, BUTTON_POWER, 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 },
+ { ACTION_SETTINGS_RESET, BUTTON_BACK, BUTTON_NONE },
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settingsgraphical */
+
+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_colorchooser[] = {
+ { ACTION_STD_OK, BUTTON_BACK|BUTTON_REL, 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_NONE },
+ 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_BACK, BUTTON_NONE },
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
+}; /* button_context_bmark */
+
+static const struct button_mapping button_context_time[] = {
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS),
+}; /* button_context_time */
+
+static const struct button_mapping button_context_quickscreen[] = {
+ { ACTION_QS_TOP, BUTTON_UP, BUTTON_NONE },
+ { ACTION_QS_TOP, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_DOWN, BUTTON_DOWN, BUTTON_NONE },
+ { ACTION_QS_DOWN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_LEFT, BUTTON_LEFT, BUTTON_NONE },
+ { ACTION_QS_LEFT, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_RIGHT, BUTTON_RIGHT, BUTTON_NONE },
+ { ACTION_QS_RIGHT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_CANCEL, BUTTON_BACK, BUTTON_NONE },
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_quickscreen */
+
+static const struct button_mapping button_context_pitchscreen[] = {
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_pitchcreen */
+
+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_RIGHT, BUTTON_POWER, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_RIGHT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_SELECT, BUTTON_SELECT, BUTTON_NONE },
+ { ACTION_KBD_PAGE_FLIP, BUTTON_BACK|BUTTON_BACK, BUTTON_NONE },
+ { ACTION_KBD_DONE, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_KBD_ABORT, BUTTON_BACK|BUTTON_REL, BUTTON_BACK },
+ { ACTION_KBD_BACKSPACE, BUTTON_BACK, BUTTON_NONE },
+ { ACTION_KBD_BACKSPACE, BUTTON_BACK|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_MORSE_SELECT, BUTTON_SELECT|BUTTON_REL, BUTTON_NONE },
+ LAST_ITEM_IN_LIST
+}; /* button_context_keyboard */
+
+/** FM Radio Screen **/
+#if CONFIG_TUNER
+static const struct button_mapping button_context_radio[] = {
+ { ACTION_FM_MENU, BUTTON_SELECT | BUTTON_REPEAT, BUTTON_SELECT },
+ { ACTION_FM_MODE, BUTTON_SELECT, BUTTON_SELECT },
+// { ACTION_FM_PRESET, BUTTON_STOP, BUTTON_NONE },
+ { ACTION_FM_PLAY, BUTTON_POWER | BUTTON_REL, BUTTON_NONE },
+ { ACTION_FM_STOP, BUTTON_POWER | BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_FM_EXIT, BUTTON_BACK, BUTTON_NONE },
+
+ //{ 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 },
+
+ 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_SELECT, BUTTON_NONE },
+ { 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
+
+#ifdef USB_ENABLE_HID
+static const struct button_mapping button_context_usb_hid[] = {
+ { ACTION_USB_HID_MODE_SWITCH_NEXT, BUTTON_BACK|BUTTON_REL, BUTTON_BACK },
+ { ACTION_USB_HID_MODE_SWITCH_PREV, BUTTON_BACK|BUTTON_REPEAT, BUTTON_BACK },
+
+ 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_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 },
+ { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT },
+ { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER },
+ { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_PREV, BUTTON_REW|BUTTON_REL, BUTTON_REW },
+ { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_NEXT, BUTTON_FF|BUTTON_REL, BUTTON_FF },
+
+ 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_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE, BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER },
+ { 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_SCREEN_BLACK, BUTTON_BOTTOMRIGHT|BUTTON_REPEAT, BUTTON_BOTTOMRIGHT },
+ //{ ACTION_USB_HID_PRESENTATION_SCREEN_WHITE, BUTTON_BOTTOMLEFT|BUTTON_REPEAT, BUTTON_BOTTOMLEFT },
+ { 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 },
+ { 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 },
+ { ACTION_USB_HID_BROWSER_ZOOM_RESET, BUTTON_POWER|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_POWER, BUTTON_NONE },
+ { ACTION_USB_HID_MOUSE_BUTTON_RIGHT_REL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+
+ { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP, BUTTON_FF, BUTTON_NONE },
+ { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP, BUTTON_FF|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_DOWN, BUTTON_REW, BUTTON_NONE },
+ { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_DOWN, BUTTON_REW|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
+}; /* button_context_usb_hid_mode_mouse */
+#endif
+#endif
+
+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_MAINMENU:
+ case CONTEXT_TREE:
+ return button_context_listtree_scroll_without_combo;
+ case CONTEXT_CUSTOM|CONTEXT_TREE:
+ return button_context_tree;
+#if CONFIG_TUNER
+ case CONTEXT_FM:
+ return button_context_radio;
+#endif
+ case CONTEXT_SETTINGS:
+ return button_context_settings;
+ case CONTEXT_CUSTOM|CONTEXT_SETTINGS:
+ return button_context_settings_right_is_inc;
+ case CONTEXT_SETTINGS_COLOURCHOOSER:
+ return button_context_colorchooser;
+ case CONTEXT_SETTINGS_EQ:
+ return button_context_eq;
+ case CONTEXT_SETTINGS_TIME:
+ return button_context_time;
+ case CONTEXT_YESNOSCREEN:
+ return button_context_yesno;
+ case CONTEXT_BOOKMARKSCREEN:
+ return button_context_bmark;
+ case CONTEXT_QUICKSCREEN:
+ return button_context_quickscreen;
+ case CONTEXT_PITCHSCREEN:
+ return button_context_pitchscreen;
+ case CONTEXT_KEYBOARD:
+ case CONTEXT_MORSE_INPUT:
+ return button_context_keyboard;
+#ifdef HAVE_RECORDING
+ case CONTEXT_SETTINGS_RECTRIGGER:
+ return button_context_settings_right_is_inc;
+ case CONTEXT_RECSCREEN:
+ return button_context_recscreen;
+#endif
+#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
+ }
+ return button_context_standard;
+}
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 843e5cca22..64041e448e 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1443,6 +1443,18 @@ target/arm/imx233/sansa-fuzeplus/debug-fuzeplus.c
target/arm/imx233/sansa-fuzeplus/powermgmt-fuzeplus.c
#endif
+#ifdef SAMSUNG_YPZ5
+target/arm/imx233/samsung-ypz5/backlight-ypz5.c
+target/arm/imx233/samsung-ypz5/lcd-ypz5.c
+target/arm/imx233/samsung-ypz5/button-ypz5.c
+target/arm/imx233/samsung-ypz5/debug-ypz5.c
+target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
+target/arm/imx233/button-lradc-imx233.c
+#ifndef BOOTLOADER
+target/arm/imx233/fmradio-imx233.c
+#endif
+#endif
+
#ifdef SANSA_CLIPZIP
target/arm/as3525/sansa-clipzip/lcd-clipzip.c
target/arm/as3525/sansa-clipzip/button-clipzip.c
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 3c4c72c054..23ee56fc75 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -150,6 +150,7 @@
#define MA_PAD 56
#define SONY_NWZ_PAD 57
#define CREATIVE_ZEN_PAD 58
+#define SAMSUNG_YPZ5_PAD 59
/* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1
@@ -258,6 +259,7 @@
#define LCD_CREATIVEZENMOZAIC 56 /* as used by the Creative ZEN Mozaic (FGD0801) */
#define LCD_ILI9342C 57 /* another type of lcd used by HiFi E.T MA9/MA8 */
#define LCD_CREATIVEZENV 58 /* as used by the Creativr Zen V (Plus) */
+#define LCD_SAMSUNGYPZ5 59 /* as used by Samsung YP-Z5 */
/* LCD_PIXELFORMAT */
#define HORIZONTAL_PACKING 1
@@ -546,6 +548,8 @@ Lyre prototype 1 */
#include "config/sonynwze370.h"
#elif defined(SONY_NWZE360)
#include "config/sonynwze360.h"
+#elif defined(SAMSUNG_YPZ5)
+#include "config/samsungypz5.h"
#else
/* no known platform */
#endif
diff --git a/firmware/export/config/samsungypz5.h b/firmware/export/config/samsungypz5.h
new file mode 100644
index 0000000000..651ae21ba3
--- /dev/null
+++ b/firmware/export/config/samsungypz5.h
@@ -0,0 +1,201 @@
+/*
+ * This config file is for the Samsung YP-Z5
+ */
+#define IMX233_SUBTARGET 3600
+#define IMX233_PACKAGE IMX233_BGA169
+#define IMX233_PARTITIONS IMX233_FREESCALE
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 84
+#define MODEL_NAME "Samsung YP-Z5"
+
+#define HW_SAMPR_CAPS SAMPR_CAP_ALL
+
+/* define this if you have recording possibility */
+#define HAVE_RECORDING
+
+#define REC_SAMPR_CAPS SAMPR_CAP_ALL
+
+/* Default recording levels */
+#define DEFAULT_REC_MIC_GAIN 23
+#define DEFAULT_REC_LEFT_GAIN 23
+#define DEFAULT_REC_RIGHT_GAIN 23
+
+/* Define bitmask of input sources - recordable bitmask can be defined
+ explicitly if different */
+#define HAVE_FMRADIO_IN
+#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
+
+#ifndef BOOTLOADER
+#define HAVE_ALBUMART
+
+/* define this to enable bitmap scaling */
+#define HAVE_BMP_SCALING
+
+/* define this to enable JPEG decoding */
+#define HAVE_JPEG
+
+/* Define this if a programmable hotkey is mapped */
+#define HAVE_HOTKEY
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+/* define this if the target has volume keys which can be used in the lists */
+#define HAVE_VOLUME_IN_LIST
+
+/* define this if you have LCD enable function */
+//#define HAVE_LCD_ENABLE
+
+/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
+ should be defined as well.
+#define HAVE_LCD_SLEEP
+#define HAVE_LCD_SLEEP_SETTING
+*/
+
+/* define this if you can flip your LCD
+#define HAVE_LCD_FLIP
+*/
+
+/* define this if you can invert the colours on your LCD
+#define HAVE_LCD_INVERT
+*/
+
+/* define this if you have a real-time clock */
+#define CONFIG_RTC RTC_IMX233
+
+/* define this if you have a real-time clock with alarm facilities */
+#define HAVE_RTC_ALARM
+
+#endif /* !BOOTLOADER */
+
+/* define this if you have an i.MX23 codec */
+#define HAVE_IMX233_CODEC
+
+#define CONFIG_TUNER TEA5767
+#define CONFIG_TUNER_XTAL 32768
+
+/* There is no hardware tone control */
+#define HAVE_SW_TONE_CONTROLS
+
+#define CONFIG_KEYPAD SAMSUNG_YPZ5_PAD
+#define HAVE_TOUCHPAD_IMX233
+
+/* Define this to enable morse code input */
+#define HAVE_MORSE_INPUT
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+/* LCD dimensions */
+#define LCD_WIDTH 128
+#define LCD_HEIGHT 160
+#define LCD_DEPTH 16 /* 65536 colours */
+#define LCD_PIXELFORMAT RGB565 /* rgb565 */
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* Some devices seem to be FAT16 formatted */
+#define HAVE_FAT16SUPPORT
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0
+
+#define AB_REPEAT_ENABLE
+
+/* Define this for LCD backlight available */
+#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 18
+#define DEFAULT_BRIGHTNESS_SETTING 5
+
+/* Which backlight fading type? */
+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
+
+/* define this if you have a flash memory storage */
+//#define HAVE_FLASH_STORAGE
+
+#define CONFIG_STORAGE (STORAGE_RAMDISK)
+//#define CONFIG_NAND NAND_IMX233
+//#define NUM_DRIVES 0
+
+/* Extra threads: touchpad and rds */
+//#define TARGET_EXTRA_THREADS 2
+
+/* todo */
+#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 0 /* capacity increment */
+#define BATTERY_TYPES_COUNT 1 /* only one type */
+
+#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
+
+/* Charging implemented in a target-specific algorithm */
+#define CONFIG_CHARGING CHARGING_TARGET
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+/* Define this if you have an IMX233*/
+#define CONFIG_CPU IMX233
+
+/* Define this if you want to use the IMX233 i2c interface */
+#define CONFIG_I2C I2C_IMX233
+
+/* define current usage levels (based on battery bench) */
+#define CURRENT_NORMAL 35
+#define CURRENT_BACKLIGHT 30
+#define CURRENT_RECORD CURRENT_NORMAL
+
+/* maximum charging current */
+#define CURRENT_MAX_CHG 200
+
+/* Define this to the CPU frequency */
+#define CPU_FREQ 454000000
+
+/* Type of LCD */
+#define CONFIG_LCD LCD_SAMSUNGYPZ5
+
+/* 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
+
+/* USB On-the-go */
+#define CONFIG_USBOTG USBOTG_ARC
+
+/* enable these for the experimental usb stack */
+#define HAVE_USBSTACK
+#define USE_ROCKBOX_USB
+#define USB_VENDOR_ID 0x04e8
+#define USB_PRODUCT_ID 0x5041
+#define HAVE_USB_HID_MOUSE
+#define HAVE_BOOTLOADER_USB_MODE
+
+/* Define this if you have adjustable CPU frequency */
+//#define HAVE_ADJUSTABLE_CPU_FREQ
+
+/* Virtual LED (icon) */
+#define CONFIG_LED LED_VIRTUAL
+
+#define BOOTFILE_EXT "samsung"
+#define BOOTFILE "rockbox." BOOTFILE_EXT
+#define BOOTDIR "/.rockbox"
+
+#define INCLUDE_TIMEOUT_API
diff --git a/firmware/target/arm/imx233/power-imx233.c b/firmware/target/arm/imx233/power-imx233.c
index af333dea59..9ad8734823 100644
--- a/firmware/target/arm/imx233/power-imx233.c
+++ b/firmware/target/arm/imx233/power-imx233.c
@@ -137,6 +137,8 @@ void imx233_power_init(void)
#endif
/* enable vbusvalid detection method for the dcdc (improves efficiency) */
BF_SET(POWER_5VCTRL, VBUSVALID_5VDETECT);
+ /* disable shutdown on 5V fail */
+ BF_CLR(POWER_5VCTRL, PWDN_5VBRNOUT);
#ifdef USE_VBUSVALID
/* make sure VBUSVALID is unlocked */
BF_CLR(POWER_DEBUG, VBUSVALIDPIOLOCK);
diff --git a/firmware/target/arm/imx233/samsung-ypz5/audio-target.h b/firmware/target/arm/imx233/samsung-ypz5/audio-target.h
new file mode 100644
index 0000000000..c0bee26e45
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/audio-target.h
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 by Lorenzo Miori
+ *
+ * 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__
+
+/* MUTE_ON toggles a transistor that in turns toggles a mosfet... */
+#define IMX233_AUDIO_HP_GATE_BANK 1
+#define IMX233_AUDIO_HP_GATE_PIN 22
+#define IMX233_AUDIO_HP_GATE_INVERTED
+
+#define IMX233_AUDIO_COUPLING_MODE ACM_CAP
+
+#endif /* __audio_target__ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h b/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
new file mode 100644
index 0000000000..5fa2ed38f9
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/backlight-target.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2013 by Lorenzo Miori
+ *
+ * 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/samsung-ypz5/backlight-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
new file mode 100644
index 0000000000..27a7ecedfc
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/backlight-ypz5.c
@@ -0,0 +1,149 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2013 by Lorenzo Miori
+ *
+ * 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 "lcd.h"
+#include "backlight.h"
+#include "backlight-target.h"
+#include "pinctrl-imx233.h"
+
+/**
+ * AAT3151 Backlight Controller
+ */
+
+/* Timings */
+#define TIME_OFF 500
+#define TIME_LOW 50
+#define TIME_HI 50
+#define TIME_LAT 500
+
+/* Number of raising edges to select the particular register */
+#define D1_D4_CURRENT_E 17
+#define D1_D3_CURRENT_E 18
+#define D4_CURRENT_E 19
+#define MAX_CURRENT_E 20
+#define LOW_CURRENT_E 21
+
+/* The actual register address / number */
+#define D1_D4_CURRENT 1
+#define D1_D3_CURRENT 2
+#define D4_CURRENT 3
+#define MAX_CURRENT 4
+#define LOW_CURRENT 5
+
+/* Valid values for LOW_CURRENT register */
+#define MAX_CURRENT_20 1
+#define MAX_CURRENT_30 2
+#define MAX_CURRENT_15 3
+#define MAX_CURRENT_LOW_CURRENT 4
+
+static int current_level = -1;
+
+static void create_raising_edges(int num)
+{
+ while (num--)
+ {
+ /* Setting a register takes a sufficient small amount of time,
+ * in the order of 50 ns. Thus the necessary 2 delays TIME_LOW/TIME_HI
+ * are not strictly necessary */
+ imx233_pinctrl_set_gpio(3, 13, false);
+ imx233_pinctrl_set_gpio(3, 13, true);
+ }
+}
+
+static void aat3151_write(int addr, int data)
+{
+ create_raising_edges(16 + addr);
+ udelay(TIME_LAT);
+ create_raising_edges(data);
+ udelay(TIME_LAT);
+}
+
+void _backlight_set_brightness(int level)
+{
+ /* Don't try to reset backlight if not necessary
+ * Moreover this helps to avoid flickering when
+ * being in some screens like USB mode and
+ * pressing some keys / touchpad...
+ */
+ if (current_level == level) return;
+
+ /* Check for limits and adjust in case */
+ level = MIN(MAX_BRIGHTNESS_SETTING, MAX(0, level));
+
+ if (level == 0)
+ {
+ /* Set pin low for a sufficient time, puts the device into low-power consumption state
+ * In other words backlight goes off
+ */
+ imx233_pinctrl_set_gpio(3, 13, false);
+ udelay(TIME_OFF);
+ }
+ else
+ {
+ if (level > 3) {
+ /* This enables 16 levels of backlight */
+ aat3151_write(MAX_CURRENT, MAX_CURRENT_15);
+ /* Set the value according Table 1 in datasheet
+ * For MAX_CURRENT_15, the scale is from 0 mA to 15 mA in 16 steps
+ */
+ aat3151_write(D1_D3_CURRENT, 19 - level);
+ }
+ else {
+ /* This enables other 4 levels of backlight */
+ aat3151_write(MAX_CURRENT, MAX_CURRENT_LOW_CURRENT);
+ /* Set the value according Table 1 in datasheet
+ * For LOW_CURRENT, there is no "real" scale. We have scattered values.
+ * We are interested in the last 3 -> 0.5 mA; 1 mA; 2 mA
+ */
+ aat3151_write(LOW_CURRENT, 13 + level);
+ }
+ }
+ current_level = level;
+}
+
+bool _backlight_init(void)
+{
+ imx233_pinctrl_acquire(3, 13, "backlight");
+ imx233_pinctrl_set_function(3, 13, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_drive(3, 13, PINCTRL_DRIVE_4mA);
+ imx233_pinctrl_enable_gpio(3, 13, true);
+ imx233_pinctrl_set_gpio(3, 13, false);
+ 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/samsung-ypz5/button-target.h b/firmware/target/arm/imx233/samsung-ypz5/button-target.h
new file mode 100644
index 0000000000..2f94f5fb31
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/button-target.h
@@ -0,0 +1,59 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2013 by Lorenzo Miori
+ *
+ * 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 <stdbool.h>
+
+#define HAS_BUTTON_HOLD
+#define IMX233_BUTTON_LRADC_CHANNEL 0
+#define IMX233_BUTTON_LRADC_HOLD_DET BLH_GPIO
+#define BLH_GPIO_BANK 0
+#define BLH_GPIO_PIN 13
+
+#define IMX233_BUTTON_LRADC_CHANNEL 0
+
+/* Main unit's buttons */
+#define BUTTON_POWER 0x00000001
+#define BUTTON_VOL_UP 0x00000002
+#define BUTTON_VOL_DOWN 0x00000004
+/* Directional buttons by touchpad */
+#define BUTTON_LEFT 0x00000008
+#define BUTTON_UP 0x00000010
+#define BUTTON_RIGHT 0x00000020
+#define BUTTON_DOWN 0x00000040
+#define BUTTON_SELECT 0x00000080
+#define BUTTON_BACK 0x00000100
+#define BUTTON_REW 0x00000200
+#define BUTTON_FF 0x00000400
+
+
+#define BUTTON_MAIN (BUTTON_VOL_UP | BUTTON_VOL_DOWN | BUTTON_POWER | BUTTON_LEFT | \
+ BUTTON_UP | BUTTON_RIGHT | BUTTON_DOWN | BUTTON_SELECT | \
+ BUTTON_BACK | BUTTON_REW | BUTTON_FF)
+
+/* Software power-off */
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 10
+
+bool button_debug_screen(void);
+
+#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
new file mode 100644
index 0000000000..cee82e2e9f
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/button-ypz5.c
@@ -0,0 +1,273 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2013 by Lorenzo Miori
+ *
+ * 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 "lcd.h"
+#include "string.h"
+#include "pinctrl-imx233.h"
+#include "power-imx233.h"
+#include "button-lradc-imx233.h"
+#include "button-target.h"
+
+#ifndef BOOTLOADER
+#include "touchscreen.h"
+#include "touchscreen-imx233.h"
+#include "button.h"
+#include "font.h"
+#include "action.h"
+#endif
+
+struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
+{
+ {455, BUTTON_VOL_UP},
+ {900, BUTTON_VOL_DOWN},
+ {1410, BUTTON_BACK},
+ {1868, BUTTON_FF},
+ {2311, BUTTON_REW},
+ {2700, 0},
+ {3300, IMX233_BUTTON_LRADC_END},
+};
+
+#ifndef BOOTLOADER
+static int last_x = 0;
+static int last_y = 0;
+static bool touching = false;
+#endif /* BOOTLOADER */
+
+#ifndef BOOTLOADER
+
+/* Touchpad extra pin initialization
+ * Strange facts:
+ * 1. In the fully working sample I have, it seems that pins
+ * must be all set to low
+ * 2. In the other sample without LCD, it seems (by measurement) that
+ * not all the pins are set to low! Actually, I still need to see if
+ * touchpad works in this other sample.
+*/
+void touchpad_pin_setup(void)
+{
+ /* TX+ */
+ imx233_pinctrl_acquire(0, 25, "touchpad X+ power low");
+ imx233_pinctrl_set_function(0, 25, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_drive(0, 25, PINCTRL_DRIVE_4mA);
+ imx233_pinctrl_enable_gpio(0, 25, true);
+
+ /* TY+ */
+ imx233_pinctrl_acquire(0, 26, "touchpad Y+ power high");
+ imx233_pinctrl_set_function(0, 26, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_drive(0, 26, PINCTRL_DRIVE_4mA);
+ imx233_pinctrl_enable_gpio(0, 26, true);
+
+ /* TY- */
+ imx233_pinctrl_acquire(1, 21, "touchpad Y- power low");
+ imx233_pinctrl_set_function(1, 21, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_drive(1, 21, PINCTRL_DRIVE_4mA);
+ imx233_pinctrl_enable_gpio(1, 21, true);
+
+ /* TX- */
+ imx233_pinctrl_acquire(3, 15, "touchpad X- power high");
+ imx233_pinctrl_set_function(3, 15, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_drive(3, 15, PINCTRL_DRIVE_4mA);
+ imx233_pinctrl_enable_gpio(3, 15, true);
+
+}
+#endif /* BOOTLOADER */
+
+void button_init_device(void)
+{
+ imx233_button_lradc_init();
+#ifndef BOOTLOADER
+ touchpad_pin_setup();
+ /* Now that is powered up, proceed with touchpad initialization */
+ imx233_touchscreen_init();
+ imx233_touchscreen_enable(true);
+#endif /* BOOTLOADER */
+}
+
+bool button_hold(void)
+{
+ return imx233_button_lradc_hold();
+}
+
+/* X, Y, RadiusX, RadiusY */
+#define TOUCH_UP 2400, 1050, 650, 250
+#define TOUCH_DOWN 2057, 3320, 500, 350
+#define TOUCH_LEFT 3581, 2297, 300, 350
+#define TOUCH_RIGHT 1000, 2100, 400, 700
+#define TOUCH_CENTER 2682, 2167, 335, 276
+
+bool coord_in_radius(int x, int y, int cx, int cy, int rx, int ry)
+{
+ return ((x >= cx - rx && x <= cx + rx) && (y >= cy - ry && y <= cy + ry));
+}
+
+int button_read_device(void)
+{
+ int res = 0;
+
+ switch(imx233_power_read_pswitch())
+ {
+ case 1: res |= BUTTON_POWER; break;
+ case 3: res |= BUTTON_SELECT; break;
+ }
+
+#ifndef BOOTLOADER
+ touching = imx233_touchscreen_get_touch(&last_x, &last_y);
+ if(touching)
+ {
+ if (coord_in_radius(last_x, last_y, TOUCH_LEFT))
+ {
+ res |= BUTTON_LEFT;
+ }
+ else if (coord_in_radius(last_x, last_y, TOUCH_RIGHT))
+ {
+ res |= BUTTON_RIGHT;
+ }
+ else if (coord_in_radius(last_x, last_y, TOUCH_DOWN))
+ {
+ res |= BUTTON_DOWN;
+ }
+ else if (coord_in_radius(last_x, last_y, TOUCH_UP))
+ {
+ res |= BUTTON_UP;
+ }
+ }
+#endif /* BOOTLOADER */
+ return imx233_button_lradc_read(res);
+}
+
+#ifndef BOOTLOADER
+
+#define MAX_ENTRIES 100
+#define VIEWPORT_HEIGHT 100
+#define VIEWPORT_WIDTH 100
+#define MAX_X 3700
+#define MAX_Y 3700
+#define ADAPT_TO_VIEWPORT(cx, cy, rx, ry) ((float)(cx) / MAX_X) * VIEWPORT_WIDTH, \
+ ((float)(cy) / MAX_Y) * VIEWPORT_HEIGHT, \
+ ((float)(rx) / MAX_X) * VIEWPORT_WIDTH, \
+ ((float)(ry) / MAX_Y) * VIEWPORT_HEIGHT
+static void draw_calibration_rect(int cx, int cy, int rx, int ry)
+{
+ if (coord_in_radius(last_x, last_y, cx, cy, rx, ry))
+ lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0xff, 0xff), LCD_BLACK);
+ else
+ lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0, 0), LCD_BLACK);
+ lcd_drawrect(ADAPT_TO_VIEWPORT(cx - rx, cy - ry, 2 * rx, 2 * ry));
+}
+
+bool button_debug_screen(void)
+{
+ int last = 0;
+ struct point_t
+ {
+ int x;
+ int y;
+ };
+ struct point_t last_entries[MAX_ENTRIES];
+ struct viewport report_vp;
+
+ memset(&report_vp, 0, sizeof(report_vp));
+ report_vp.x = (LCD_WIDTH - VIEWPORT_WIDTH) / 2;
+ report_vp.y = (LCD_HEIGHT - VIEWPORT_HEIGHT) / 2;
+ report_vp.width = VIEWPORT_WIDTH;
+ report_vp.height = VIEWPORT_HEIGHT;
+
+ lcd_setfont(FONT_SYSFIXED);
+ lcd_clear_display();
+
+ while(1)
+ {
+ int button = get_action(CONTEXT_STD, HZ / 10);
+ switch(button)
+ {
+ case ACTION_STD_OK:
+ case ACTION_STD_MENU:
+ lcd_set_viewport(NULL);
+ lcd_setfont(FONT_UI);
+ lcd_clear_display();
+ return true;
+ case ACTION_STD_CANCEL:
+ lcd_set_viewport(NULL);
+ lcd_setfont(FONT_UI);
+ lcd_clear_display();
+ return false;
+ }
+
+ lcd_set_viewport(NULL);
+ lcd_putsf(0, 1, "(%d,%d) %s", last_x, last_y, touching ? "touching!" : "");
+ lcd_putsf(0, 0, "Type %s", imx233_pinctrl_get_gpio(0, 31) ? "CAP" : "REG");
+ lcd_set_viewport(&report_vp);
+ lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0, 0, 0xff), LCD_BLACK);
+ lcd_drawrect(0, 0, 100, 100);
+ float percent_x = ((float)(last_x) / MAX_X);
+ float percent_y = ((float)(last_y) / MAX_Y);
+ if (touching)
+ {
+ lcd_set_viewport(NULL);
+ if (last < MAX_ENTRIES)
+ {
+ last_entries[last].x = last_x;
+ last_entries[last].y = last_y;
+ last++;
+ lcd_putsf(0, 17, "Recording: %d captures left", MAX_ENTRIES - last);
+ }
+ else
+ {
+ int min_x = 9999;
+ int min_y = 9999;
+ int max_x = -1;
+ int max_y = -1;
+ int median_x = 0;
+ int median_y = 0;
+ for (int i = 0; i < MAX_ENTRIES; i++)
+ {
+ min_x = MIN(min_x, last_entries[i].x);
+ min_y = MIN(min_y, last_entries[i].y);
+ max_x = MAX(max_x, last_entries[i].x);
+ max_y = MAX(max_y, last_entries[i].y);
+ median_x += last_entries[i].x;
+ median_y += last_entries[i].y;
+ }
+ median_x /= MAX_ENTRIES;
+ median_y /= MAX_ENTRIES;
+ lcd_putsf(0, 17, "center(%d,%d)", median_x, median_y);
+ lcd_putsf(0, 18, "radius(%d,%d)", median_x / 2, median_y / 2);
+ }
+ lcd_set_viewport(&report_vp);
+ lcd_set_drawinfo(DRMODE_SOLID, LCD_RGBPACK(0xff, 0x8c, 0), LCD_BLACK);
+ lcd_fillrect(VIEWPORT_WIDTH * percent_x, VIEWPORT_HEIGHT * percent_y, 2, 2);
+ }
+
+ /* Draw current calibration settings */
+ lcd_set_viewport(&report_vp);
+ draw_calibration_rect(TOUCH_UP);
+ draw_calibration_rect(TOUCH_DOWN);
+ draw_calibration_rect(TOUCH_CENTER);
+ draw_calibration_rect(TOUCH_LEFT);
+ draw_calibration_rect(TOUCH_RIGHT);
+
+ lcd_update();
+ yield();
+ }
+
+ return true;
+}
+#endif
diff --git a/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.c
new file mode 100644
index 0000000000..c125eac973
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/debug-ypz5.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 button_debug_screen() && lcd_debug_screen();
+}
diff --git a/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h b/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
new file mode 100644
index 0000000000..66bceb4071
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/fmradio-target.h
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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 _FMRADIO_TARGET_H_
+#define _FMRADIO_TARGET_H_
+
+#define IMX233_FMRADIO_I2C FMI_HW
+
+#define IMX233_FMRADIO_POWER FMP_GPIO
+#define FMP_GPIO_BANK 0
+#define FMP_GPIO_PIN 10
+#define FMP_GPIO_DELAY (HZ / 5)
+
+#endif /* _FMRADIO_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h b/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
new file mode 100644
index 0000000000..cb943e34f2
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/ftl-target.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2009 by Michael Sparmann
+ *
+ * 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 __FTL_TARGET_H__
+#define __FTL_TARGET_H__
+
+#include "config.h"
+#include "inttypes.h"
+
+#ifdef BOOTLOADER
+/* Bootloaders don't need write access */
+#define FTL_READONLY
+#endif
+
+uint32_t ftl_init(void);
+uint32_t ftl_read(uint32_t sector, uint32_t count, void* buffer);
+uint32_t ftl_write(uint32_t sector, uint32_t count, const void* buffer);
+uint32_t ftl_sync(void);
+
+
+#endif
diff --git a/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h b/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
new file mode 100644
index 0000000000..9993b7d731
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/lcd-target.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * 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);
+
+#endif /* LCD_TARGET_H */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
new file mode 100644
index 0000000000..4f7d9b88b5
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/lcd-ypz5.c
@@ -0,0 +1,294 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (c) 2013 by Lorenzo Miori
+ *
+ * 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 <sys/types.h> /* off_t */
+#include <string.h>
+#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
+#include "dma-imx233.h"
+
+#include "regs/regs-lcdif.h"
+
+/**
+ * NOTE
+ * We don't know exact LCD models nor we have datasheets for them
+ * Register function are partly guessed from the values, others are guessed from other LCD
+ * drivers and others have been confirmed studying their values
+ */
+
+static enum lcd_type_t
+{
+ LCD_TYPE_ZERO = 0,
+ LCD_TYPE_ONE = 1
+} lcd_type = LCD_TYPE_ZERO;
+
+static void lcd_write_reg(uint16_t reg, uint16_t data)
+{
+ imx233_lcdif_pio_send(false, 1, &reg);
+ if(reg != 0x22)
+ imx233_lcdif_pio_send(true, 1, &data);
+}
+
+/*
+ * The two LCD types require different initialization sequences
+ */
+void lcd_init_seq(void)
+{
+ switch (lcd_type)
+ {
+ case LCD_TYPE_ZERO:
+ {
+ lcd_write_reg(0x11, 0x1f1e);
+ lcd_write_reg(0x38, 0xf0f);
+ lcd_write_reg(0x12, 0x1101);
+ lcd_write_reg(0x13, 0x808);
+ lcd_write_reg(0x14, 0x3119);
+ lcd_write_reg(0x10, 0x1a10);
+ udelay(0xc350);
+ lcd_write_reg(0x13, 0x83b);
+ udelay(0x30d40);
+ lcd_write_reg(1, 0x90c); /* Display mode */
+ lcd_write_reg(2, 0x200);
+ lcd_write_reg(3, 0x1030);
+ lcd_write_reg(7, 5);
+ lcd_write_reg(8, 0x503);
+ lcd_write_reg(11, 0);
+ lcd_write_reg(12, 0);
+ /* Gamma control */
+ lcd_write_reg(0x30, 0x606);
+ lcd_write_reg(0x31, 0x606);
+ lcd_write_reg(0x32, 0x305);
+ lcd_write_reg(0x33, 2);
+ lcd_write_reg(0x34, 0x503);
+ lcd_write_reg(0x35, 0x606);
+ lcd_write_reg(0x36, 0x606);
+ lcd_write_reg(0x37, 0x200);
+
+ lcd_write_reg(0x11, 0x1f1e);
+ lcd_write_reg(0x38, 0xf0f);
+ /* Set initial LCD limits and RAM settings */
+ lcd_write_reg(0x40, 0); //BPP ?
+ lcd_write_reg(0x42, 0x9f00);
+ lcd_write_reg(0x43, 0);
+ lcd_write_reg(0x44, 0x7f00); /* Horizontal initial refresh zone [0 - 127] */
+ lcd_write_reg(0x45, 0x9f00); /* Vertical initial refresh zone [0 - 159] */
+
+ lcd_write_reg(14, 0x13);
+ lcd_write_reg(0xa9, 0x14);
+ lcd_write_reg(0xa7, 0x30);
+ lcd_write_reg(0xa8, 0x124);
+ lcd_write_reg(0x6f, 0x1d00);
+ lcd_write_reg(0x70, 3);
+ lcd_write_reg(7, 1);
+ lcd_write_reg(0x10, 0x1a10);
+ udelay(0x9c40);
+ lcd_write_reg(7, 0x21);
+ lcd_write_reg(7, 0x23);
+ udelay(0x9c40);
+ lcd_write_reg(7, 0x37); /* Seems to be "power on" */
+ break;
+ }
+ case LCD_TYPE_ONE:
+ {
+ lcd_write_reg(0, 1);
+ udelay(0x2710);
+ lcd_write_reg(0x11, 0x171b);
+ lcd_write_reg(0x12, 0);
+ lcd_write_reg(0x13, 0x80d);
+ lcd_write_reg(0x14, 0x18);
+ lcd_write_reg(0x10, 0x1a10);
+ udelay(0xc350);
+ lcd_write_reg(0x13, 0x81d);
+ udelay(0xc350);
+ lcd_write_reg(1, 0x90c); /* Display mode */
+ lcd_write_reg(2, 0x200);
+ lcd_write_reg(3, 0x1030);
+ lcd_write_reg(7, 5);
+ lcd_write_reg(8, 0x30a);
+ lcd_write_reg(11, 4);
+ lcd_write_reg(12, 0);
+ /* Gamma control */
+ lcd_write_reg(0x30, 0x300);
+ lcd_write_reg(0x31, 0);
+ lcd_write_reg(0x32, 0);
+ lcd_write_reg(0x33, 0x404);
+ lcd_write_reg(0x34, 0x707);
+ lcd_write_reg(0x35, 0x700);
+ lcd_write_reg(0x36, 0x703);
+ lcd_write_reg(0x37, 4);
+
+ lcd_write_reg(0x38, 0);
+ /* Set initial LCD limits and RAM settings */
+ lcd_write_reg(0x40, 0);
+ lcd_write_reg(0x42, 0x9f00); /* LCD Display Start Address Register 0 */
+ lcd_write_reg(0x43, 0); /* LCD Display Start Address Register 1 */
+ lcd_write_reg(0x44, 0x7f00); /* Horizontal initial refresh zone [0 - 127] */
+ lcd_write_reg(0x45, 0x9f00); /* Vertical initial refresh zone [0 - 159] */
+
+ lcd_write_reg(7, 1);
+ udelay(0x2710);
+ lcd_write_reg(7, 0x21);
+ lcd_write_reg(7, 0x23);
+ udelay(0x2710);
+ lcd_write_reg(7, 0x1037);
+ udelay(0x2710);
+ lcd_write_reg(7, 0x35);
+ lcd_write_reg(7, 0x36);
+ lcd_write_reg(7, 0x37);
+ udelay(10000);
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+static void send_update_rect(uint8_t x, uint8_t y, uint8_t w, uint8_t h)
+{
+ /* Set horizontal refresh zone */
+ lcd_write_reg(0x44, (x | (y + w - 1) << 0x8));
+ /* Set vertical refresh zone */
+ lcd_write_reg(0x45, (y | (y + h - 1) << 0x8));
+ lcd_write_reg(0x21, x | y << 8);
+ /* Set register index to 0x22 to write screen data. 0 is mock value */
+ lcd_write_reg(0x22, 0);
+}
+
+static void setup_lcd_pins(void)
+{
+ imx233_lcdif_setup_system_pins(16);
+ /* lcd_rd */
+ imx233_pinctrl_acquire(0, 9, "lcd rd");
+ imx233_pinctrl_set_function(0, 9, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_set_gpio(0, 9, false);
+ /*
+ * This pin is important to know the LCD type
+ * There are two types that require two different initialization sequences
+ */
+ /* lcd_tp */
+ imx233_pinctrl_acquire(3, 12, "lcd type");
+ imx233_pinctrl_set_function(3, 12, PINCTRL_FUNCTION_GPIO);
+ imx233_pinctrl_enable_gpio(3, 12, false);
+ /* Sense LCD Type */
+ lcd_type = imx233_pinctrl_get_gpio(3, 12) ? LCD_TYPE_ONE : LCD_TYPE_ZERO;
+}
+
+static void setup_parameters(void)
+{
+ imx233_lcdif_init();
+ imx233_lcdif_enable(true);
+ imx233_lcdif_set_word_length(16);
+ imx233_lcdif_set_data_swizzle(false);
+ imx233_lcdif_set_timings(2, 1, 1, 1);
+ BF_WR_V(LCDIF_CTRL, MODE86, 8080_MODE);
+
+ imx233_lcdif_reset_lcd(true);
+ udelay(50);
+ imx233_lcdif_reset_lcd(false);
+ udelay(10);
+ imx233_lcdif_reset_lcd(true);
+}
+
+void lcd_init_device(void)
+{
+ /* Setup interface pins */
+ setup_lcd_pins();
+ /* Set LCD parameters */
+ setup_parameters();
+ /* Send initialization sequence to LCD */
+ lcd_init_seq();
+}
+
+struct lcdif_cmd_t
+{
+ struct apb_dma_command_t dma;
+ uint32_t ctrl0;
+ uint32_t pad[4];
+} __attribute__((packed)) CACHEALIGN_ATTR;
+
+struct lcdif_cmd_t lcdif_dma;
+void lcd_update(void)
+{
+ unsigned size = LCD_WIDTH * LCD_HEIGHT * sizeof(fb_data);
+
+ send_update_rect(0,0,LCD_WIDTH,LCD_HEIGHT);
+ /* We can safely do the transfer in a single shot, since 160 * 128 * 2 < 65k,
+ * the maximum transfer size!
+ */
+ lcdif_dma.dma.cmd |= BF_OR3(APB_CHx_CMD, CMDWORDS(1), XFER_COUNT(size), COMMAND(2));
+ lcdif_dma.ctrl0 = HW_LCDIF_CTRL & ~BM_LCDIF_CTRL_COUNT;
+ lcdif_dma.ctrl0 |= BF_OR2(LCDIF_CTRL, COUNT(size/2), DATA_SELECT(1));
+ lcdif_dma.dma.buffer = FBADDR(0,0);
+ lcdif_dma.dma.cmd |= BM_APB_CHx_CMD_SEMAPHORE;
+
+ imx233_dma_start_command(APB_LCDIF, &lcdif_dma.dma);
+ imx233_dma_wait_completion(APB_LCDIF, HZ);
+}
+
+void lcd_update_rect(int x, int y, int w, int h)
+{
+ (void)x;
+ (void)y;
+ (void)w;
+ (void)h;
+ lcd_update();
+}
+
+#ifndef BOOTLOADER
+bool lcd_debug_screen(void)
+{
+ lcd_setfont(FONT_SYSFIXED);
+
+ while(1)
+ {
+ int button = get_action(CONTEXT_STD, HZ / 10);
+ switch(button)
+ {
+ case ACTION_STD_NEXT:
+ case ACTION_STD_PREV:
+ case ACTION_STD_OK:
+ case ACTION_STD_MENU:
+ lcd_setfont(FONT_UI);
+ return true;
+ case ACTION_STD_CANCEL:
+ lcd_setfont(FONT_UI);
+ return false;
+ }
+
+ lcd_clear_display();
+ lcd_putsf(0, 0, "LCD type: %d", lcd_type);
+ lcd_update();
+ yield();
+ }
+
+ return true;
+}
+#endif
diff --git a/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
new file mode 100644
index 0000000000..5d32bc5e9c
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-target.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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"
+
+#define IMX233_CHARGE_CURRENT 100
+#define IMX233_STOP_CURRENT 10
+#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
+#define IMX233_BATT_TEMP_SENSOR 0
+#define IMX233_BATT_TEMP_HIGH 1100
+#define IMX233_BATT_TEMP_LOW 220
+
+#endif /* POWERMGMT_TARGET_H */
diff --git a/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
new file mode 100644
index 0000000000..9d9ed7de99
--- /dev/null
+++ b/firmware/target/arm/imx233/samsung-ypz5/powermgmt-ypz5.c
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * __________ __ ___.
+ * 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"
+
+
+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 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
+};
diff --git a/firmware/target/arm/imx233/touchscreen-imx233.c b/firmware/target/arm/imx233/touchscreen-imx233.c
index c4d2f4d726..53d9d0e320 100644
--- a/firmware/target/arm/imx233/touchscreen-imx233.c
+++ b/firmware/target/arm/imx233/touchscreen-imx233.c
@@ -20,6 +20,9 @@
****************************************************************************/
#include "touchscreen-imx233.h"
#include "stdlib.h"
+#ifdef SAMSUNG_YPZ5
+#include "pinctrl-imx233.h"
+#endif
/* Description:
* the driver basically has 2 modes:
@@ -72,6 +75,24 @@ static void touch_channel_irq(int chan)
process();
}
+#ifdef SAMSUNG_YPZ5
+/* On this target we need to manually setup pulldown pins,
+ * using specific GPIO lines
+ */
+static void pulldown_setup(bool xminus_enable, bool yminus_enable,
+ bool xplus_enable, bool yplus_enable)
+{
+ /* TX+ */
+ imx233_pinctrl_set_gpio(0, 25, xplus_enable);
+ /* TX- */
+ imx233_pinctrl_set_gpio(3, 15, xminus_enable);
+ /* TY+ */
+ imx233_pinctrl_set_gpio(0, 26, yplus_enable);
+ /* TY- */
+ imx233_pinctrl_set_gpio(1, 21, yminus_enable);
+}
+#endif
+
static void kick_measure(bool pull_x, bool pull_y, bool detect, int src)
{
if(touch_chan >= 0)
@@ -84,6 +105,9 @@ static void kick_measure(bool pull_x, bool pull_y, bool detect, int src)
imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), true);
imx233_lradc_enable_channel_irq(touch_chan, true);
/* setup measurement: x- pull down and x+ pull up */
+#ifdef SAMSUNG_YPZ5
+ pulldown_setup(pull_x, pull_y, pull_x, pull_y);
+#endif
imx233_lradc_setup_touch(pull_x, pull_y, pull_x, pull_y, detect);
imx233_lradc_enable_touch_detect_irq(false);
imx233_lradc_enable_channel_irq(touch_chan, true);
@@ -102,6 +126,9 @@ static void enter_state(enum touch_state_t state)
switch(state)
{
case TOUCH_STATE_WAIT:
+#ifdef SAMSUNG_YPZ5
+ pulldown_setup(false, false, false, false);
+#endif
imx233_lradc_setup_touch(false, false, false, false, true);
imx233_lradc_enable_touch_detect_irq(true);
break;
diff --git a/tools/configure b/tools/configure
index 71bd8d6029..b33c798a3a 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1325,6 +1325,7 @@ cat <<EOF
141) YH-920 170) HD200 ==Lyre project==
142) YH-925 171) HD300 130) Lyre proto 1
143) YP-S3 131) Mini2440
+ 144) YP-Z5
==ROCKCHIP==
==Application== 180) rk27xx generic ==HiFiMAN==
200) SDL 190) HM-60x
@@ -3142,6 +3143,26 @@ fi
t_model="yps3"
;;
+ 144|samsungypz5)
+ target_id=90
+ modelname="samsungypz5"
+ target="SAMSUNG_YPZ5"
+ memory=16
+ bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+ bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
+ tool="$rootdir/tools/scramble -add=ypz5"
+ output="rockbox.samsung"
+ bootoutput="bootloader-ypz5.samsung"
+ appextra="gui:recorder:radio"
+ plugins=""
+ swcodec="yes"
+ toolset=$scramblebitmaptools
+ t_cpu="arm"
+ t_manufacturer="imx233"
+ t_model="samsung-ypz5"
+ arm926ejscc
+ ;;
+
160|vibe500)
target_id=67
modelname="vibe500"
diff --git a/tools/scramble.c b/tools/scramble.c
index ef7c41befb..ba335d2f2d 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -129,7 +129,7 @@ void usage(void)
"\t m2v4, fuze, c2v2, clv2, y820, y920, y925, x747,\n"
"\t 747p, x777, nn2g, m244, cli+, fuz2, hd20, hd30,\n"
"\t ip6g, rk27, clzp, zxf2, zxf3, fuz+, e370, e360,\n"
- "\t zxfi, zmoz, zen, zenv)\n");
+ "\t zxfi, zmoz, zen, zenv, ypz5)\n");
printf("\nNo option results in Archos standard player/recorder format.\n");
exit(1);
@@ -366,6 +366,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], "ypz5")) /* Samsung YP-Z5 */
+ modelnum = 84;
else if (!strcmp(&argv[1][5], "zenv")) /* Creative Zen V */
modelnum = 85;
else if (!strcmp(&argv[1][5], "zxfi")) /* Creative ZEN X-Fi */