diff --git a/apps/SOURCES b/apps/SOURCES
index 34dc202..53a67fd 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -332,5 +332,7 @@ keymaps/keymap-hm60x.c
 keymaps/keymap-hm801.c
 #elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
 keymaps/keymap-sansa-connect.c
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+keymaps/keymap-ypr0.c
 #endif
 
diff --git a/apps/keymaps/keymap-ypr0.c b/apps/keymaps/keymap-ypr0.c
new file mode 100644
index 0000000..b570676
--- /dev/null
+++ b/apps/keymaps/keymap-ypr0.c
@@ -0,0 +1,258 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: keymap-sdl.c 28704 2010-11-29 11:28:53Z teru $
+ *
+ * Copyright (C) 2011 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 Samsung YP-R0 target */
+
+#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
+ */
+
+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_CANCEL,         BUTTON_LEFT,                   BUTTON_NONE },
+    { ACTION_STD_CANCEL,         BUTTON_BACK|BUTTON_REL,        BUTTON_BACK },
+
+    { ACTION_STD_OK,             BUTTON_SELECT|BUTTON_REL,      BUTTON_SELECT },
+    { ACTION_STD_OK,             BUTTON_RIGHT,                  BUTTON_NONE },
+
+    { ACTION_STD_QUICKSCREEN,    BUTTON_MENU|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_STD_CONTEXT,        BUTTON_SELECT|BUTTON_REPEAT,   BUTTON_SELECT },
+    { ACTION_STD_MENU,           BUTTON_MENU|BUTTON_REL,        BUTTON_MENU },
+
+    { ACTION_STD_CONTEXT,        BUTTON_MENU|BUTTON_REL,        BUTTON_NONE },
+    { ACTION_STD_QUICKSCREEN,    BUTTON_MENU|BUTTON_REPEAT,     BUTTON_NONE },
+
+    { ACTION_STD_KEYLOCK,        BUTTON_POWER|BUTTON_REL,       BUTTON_POWER },
+
+    LAST_ITEM_IN_LIST
+}; /* button_context_standard */
+
+static const struct button_mapping button_context_wps[]  = {
+    { ACTION_WPS_PLAY,           BUTTON_SELECT|BUTTON_REL,      BUTTON_SELECT },
+    { ACTION_WPS_STOP,           BUTTON_POWER|BUTTON_REPEAT,    BUTTON_NONE },
+
+    { ACTION_WPS_BROWSE,         BUTTON_BACK|BUTTON_REL,        BUTTON_BACK },
+    { ACTION_WPS_MENU,           BUTTON_MENU|BUTTON_REL,        BUTTON_MENU },
+
+    /* NOTE: this is available only enabling AB-Repeat mode */
+    { ACTION_WPS_HOTKEY,         BUTTON_USER|BUTTON_REL,        BUTTON_USER },
+    { ACTION_WPSAB_SINGLE,       BUTTON_USER|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_STD_KEYLOCK,        BUTTON_POWER|BUTTON_REL,       BUTTON_POWER },
+    { ACTION_WPS_CONTEXT,        BUTTON_SELECT|BUTTON_REPEAT,   BUTTON_SELECT },
+    { ACTION_WPS_QUICKSCREEN,    BUTTON_MENU|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_SKIPNEXT,       BUTTON_RIGHT|BUTTON_REL,       BUTTON_RIGHT },
+    { ACTION_WPS_SEEKFWD,        BUTTON_RIGHT|BUTTON_REPEAT,    BUTTON_NONE },
+    { ACTION_WPS_STOPSEEK,       BUTTON_RIGHT|BUTTON_REL,       BUTTON_RIGHT|BUTTON_REPEAT },
+
+
+    { ACTION_WPS_VOLUP,          BUTTON_UP|BUTTON_REPEAT,       BUTTON_NONE },
+    { ACTION_WPS_VOLUP,          BUTTON_UP,                     BUTTON_NONE },
+    { ACTION_WPS_VOLDOWN,        BUTTON_DOWN|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_WPS_VOLDOWN,        BUTTON_DOWN,                   BUTTON_NONE },
+
+    LAST_ITEM_IN_LIST
+}; /* button_context_wps */
+
+static const struct button_mapping button_context_list[]  = {
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_list */
+
+static const struct button_mapping button_context_tree[]  = {
+    { ACTION_TREE_WPS,           BUTTON_USER|BUTTON_REPEAT,     BUTTON_USER },
+    { ACTION_TREE_STOP,          BUTTON_POWER|BUTTON_REPEAT,    BUTTON_NONE },
+    { ACTION_TREE_HOTKEY,        BUTTON_USER|BUTTON_REL,        BUTTON_NONE },
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
+}; /* button_context_tree */
+
+static const struct button_mapping button_context_settings[]  = {
+
+    { 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_TREE)
+}; /* button_context_settings */
+
+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[]  = { //check
+    { 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_CANCEL, BUTTON_MENU|BUTTON_REL, BUTTON_MENU },
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
+}; /* button_context_eq */
+
+/** Bookmark Screen **/
+static const struct button_mapping button_context_bmark[]  = {
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
+}; /* button_context_bmark */
+
+static const struct button_mapping button_context_time[]  = {
+
+    { 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 },
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD),
+}; /* 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_MENU,                    BUTTON_NONE },
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_quickscreen */
+
+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_SLOWER,         BUTTON_LEFT|BUTTON_REPEAT,      BUTTON_NONE },
+    { ACTION_PS_FASTER,         BUTTON_RIGHT|BUTTON_REPEAT,     BUTTON_NONE },
+
+    { ACTION_PS_NUDGE_LEFT,     BUTTON_LEFT,                    BUTTON_NONE },
+    { ACTION_PS_NUDGE_LEFTOFF,  BUTTON_LEFT|BUTTON_REL,         BUTTON_NONE },
+    { ACTION_PS_NUDGE_RIGHT,    BUTTON_RIGHT,                   BUTTON_NONE },
+    { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_RIGHT|BUTTON_REL,        BUTTON_NONE },
+
+    { ACTION_PS_RESET,          BUTTON_SELECT,                  BUTTON_NONE },
+    { ACTION_PS_TOGGLE_MODE,    BUTTON_USER,                    BUTTON_NONE },
+    { ACTION_PS_EXIT,           BUTTON_MENU|BUTTON_REL,         BUTTON_NONE },
+    { ACTION_PS_EXIT,           BUTTON_BACK|BUTTON_REL,         BUTTON_NONE },
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_pitchcreen */
+
+static const struct button_mapping button_context_keyboard[]  = {
+
+    { 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_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_SELECT,       BUTTON_SELECT,                   BUTTON_NONE },
+    { ACTION_KBD_ABORT,        BUTTON_BACK|BUTTON_REL,          BUTTON_BACK },
+    { ACTION_KBD_DONE,         BUTTON_MENU|BUTTON_REL,          BUTTON_MENU },
+    { ACTION_KBD_BACKSPACE,    BUTTON_USER,                     BUTTON_NONE },
+    { ACTION_KBD_PAGE_FLIP,    BUTTON_POWER,                    BUTTON_NONE },
+
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_keyboard */
+
+static const struct button_mapping button_context_radio[]  = {
+    LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
+}; /* button_context_radio */
+
+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_tree;
+
+        case CONTEXT_SETTINGS:
+            return button_context_settings;
+
+        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_FM:
+            return button_context_radio;
+        case CONTEXT_BOOKMARKSCREEN:
+            return button_context_bmark;
+        case CONTEXT_QUICKSCREEN:
+            return button_context_quickscreen;
+        case CONTEXT_PITCHSCREEN:
+            return button_context_pitchscreen;
+        case CONTEXT_KEYBOARD:
+            return button_context_keyboard;
+    }
+    return button_context_standard;
+}
diff --git a/apps/plugin.h b/apps/plugin.h
index 4a62697..e778f51 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -121,6 +121,8 @@ void* plugin_get_buffer(size_t *buffer_size);
 /* on some platforms strcmp() seems to be a tricky define which
  * breaks if we write down strcmp's prototype */
 #undef strcmp
+#undef strncmp
+#undef strchr
 
 #ifdef PLUGIN
 
diff --git a/apps/plugins/SOURCES.app_build b/apps/plugins/SOURCES.app_build
index ddac2b9..e374062 100644
--- a/apps/plugins/SOURCES.app_build
+++ b/apps/plugins/SOURCES.app_build
@@ -1,3 +1,7 @@
+#ifndef HAVE_TOUCHSCREEN
+/* In devices running RockBox as an application, but having a keypad */
+#include "SOURCES"
+#else
 /* plugins common to all models */
 credits.c
 properties.c
@@ -39,3 +43,5 @@ test_sampr.c
 #endif
 test_viewports.c
 #endif /* HAVE_TEST_PLUGINS */
+
+#endif /* HAVE_TOUCHSCREEN */
diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS
index c497c49..d2feb72 100644
--- a/apps/plugins/SUBDIRS
+++ b/apps/plugins/SUBDIRS
@@ -73,7 +73,7 @@ mikmod
 #if defined(IRIVER_H300_SERIES) || defined(IRIVER_H100_SERIES) || \
     (CONFIG_KEYPAD == SANSA_FUZE_PAD) || (CONFIG_KEYPAD == SANSA_E200_PAD) || \
     (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
-    (CONFIG_KEYPAD == IPOD_1G2G_PAD)
+    (CONFIG_KEYPAD == IPOD_1G2G_PAD || CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 /* PDBox is confirmed to run on these player models. */
 pdbox
 #endif
diff --git a/apps/plugins/SUBDIRS.app_build b/apps/plugins/SUBDIRS.app_build
index dbf4382..23b840f 100644
--- a/apps/plugins/SUBDIRS.app_build
+++ b/apps/plugins/SUBDIRS.app_build
@@ -1,4 +1,11 @@
-/* For all targets with a bitmap display */
+#ifndef HAVE_TOUCHSCREEN
+/* This is for devices having a keypad, running RockBox as an application */
+#include "SUBDIRS"
+
+#else
+/* For all targets with a bitmap display and a touchscreen
+ * In fact, most of the plugins aren't supposed to be used on a touch(mouse) device
+ */
 #ifdef HAVE_LCD_BITMAP
 
 #ifdef HAVE_TAGCACHE
@@ -15,3 +22,4 @@ mikmod
 #endif
 
 #endif /* CONFIG_CODEC == SWCODEC */
+#endif /* HAVE_TOUCHSCREEN */
\ No newline at end of file
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index a16302e..be509cf 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -125,7 +125,8 @@
 #define BATTERY_ON_TXT  "SELECT - start"
 #define BATTERY_OFF_TXT "POWER"
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD \
+   || CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 
 #define BATTERY_ON  BUTTON_SELECT
 #define BATTERY_OFF BUTTON_BACK
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index 0c35306..ab4da37 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -466,6 +466,22 @@ enum {
 #define BJACK_RIGHT         BUTTON_RIGHT
 #define BJACK_LEFT          BUTTON_LEFT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define BJACK_SELECT_NAME   "SELECT"
+#define BJACK_STAY_NAME     "MENU"
+#define BJACK_QUIT_NAME     "BACK"
+#define BJACK_DOUBLE_NAME   "USER"
+#define BJACK_SELECT        BUTTON_SELECT
+#define BJACK_QUIT          BUTTON_BACK
+#define BJACK_MAX           (BUTTON_LEFT|BUTTON_UP)
+#define BJACK_MIN           (BUTTON_RIGHT|BUTTON_DOWN)
+#define BJACK_STAY          BUTTON_MENU
+#define BJACK_DOUBLEDOWN    BUTTON_USER
+#define BJACK_UP            BUTTON_UP
+#define BJACK_DOWN          BUTTON_DOWN
+#define BJACK_RIGHT         BUTTON_RIGHT
+#define BJACK_LEFT          BUTTON_LEFT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/bounce.c b/apps/plugins/bounce.c
index 6880e26..5bd81b7 100644
--- a/apps/plugins/bounce.c
+++ b/apps/plugins/bounce.c
@@ -127,7 +127,8 @@
 #define BOUNCE_QUIT BUTTON_POWER
 #define BOUNCE_MODE BUTTON_PLAY
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) \
+   || (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define BOUNCE_LEFT BUTTON_LEFT
 #define BOUNCE_RIGHT BUTTON_RIGHT
 #define BOUNCE_UP   BUTTON_UP
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index c362ffe..dd3903e 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -158,7 +158,8 @@ CONFIG_KEYPAD == SANSA_CONNECT_PAD
 #define UP BUTTON_SCROLL_UP
 #define DOWN BUTTON_SCROLL_DOWN
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD \
+   || CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define QUIT BUTTON_BACK
 #define LEFT BUTTON_LEFT
 #define RIGHT BUTTON_RIGHT
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index 8288f34..77c7a55 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -431,6 +431,17 @@ F3: equal to "="
 #define CALCULATOR_CALC      BUTTON_NEXT
 #define CALCULATOR_CLEAR     BUTTON_PREV
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+
+#define CALCULATOR_LEFT  BUTTON_LEFT
+#define CALCULATOR_RIGHT BUTTON_RIGHT
+#define CALCULATOR_UP    BUTTON_UP
+#define CALCULATOR_DOWN  BUTTON_DOWN
+#define CALCULATOR_QUIT  BUTTON_BACK
+#define CALCULATOR_INPUT BUTTON_SELECT
+#define CALCULATOR_CALC  BUTTON_MENU
+#define CALCULATOR_CLEAR BUTTON_USER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index d8d8f1a..d498b97 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -308,6 +308,16 @@
 #define CALENDAR_NEXT_MONTH BUTTON_NEXT
 #define CALENDAR_PREV_MONTH BUTTON_PREV
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define CALENDAR_QUIT       BUTTON_BACK
+#define CALENDAR_SELECT     BUTTON_SELECT
+#define CALENDAR_NEXT_WEEK  BUTTON_DOWN
+#define CALENDAR_PREV_WEEK  BUTTON_UP
+#define CALENDAR_NEXT_DAY   BUTTON_RIGHT
+#define CALENDAR_PREV_DAY   BUTTON_LEFT
+#define CALENDAR_NEXT_MONTH BUTTON_POWER
+#define CALENDAR_PREV_MONTH BUTTON_USER
+
 #else
 #error "No keypad setting."
 #endif
diff --git a/apps/plugins/chessbox/chessbox_pgn.h b/apps/plugins/chessbox/chessbox_pgn.h
index 1627426..765e52e 100644
--- a/apps/plugins/chessbox/chessbox_pgn.h
+++ b/apps/plugins/chessbox/chessbox_pgn.h
@@ -422,6 +422,16 @@
 #define CB_SCROLL_LEFT   (BUTTON_LEFT|BUTTON_REPEAT)
 #define CB_SCROLL_RIGHT  (BUTTON_RIGHT|BUTTON_REPEAT)
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define CB_SELECT  BUTTON_SELECT
+#define CB_UP      BUTTON_UP
+#define CB_DOWN    BUTTON_DOWN
+#define CB_LEFT    BUTTON_LEFT
+#define CB_RIGHT   BUTTON_RIGHT
+#define CB_PLAY    BUTTON_USER
+#define CB_LEVEL   BUTTON_BACK
+#define CB_MENU    BUTTON_MENU
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index dca5c40..94f069d 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -326,6 +326,16 @@
 #define CHC_SETTINGS_OK BUTTON_SELECT
 #define CHC_SETTINGS_CANCEL BUTTON_LEFT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define CHC_QUIT BUTTON_BACK
+#define CHC_STARTSTOP BUTTON_SELECT
+#define CHC_RESET BUTTON_USER
+#define CHC_MENU BUTTON_MENU
+#define CHC_SETTINGS_INC BUTTON_UP
+#define CHC_SETTINGS_DEC BUTTON_DOWN
+#define CHC_SETTINGS_OK BUTTON_SELECT
+#define CHC_SETTINGS_CANCEL BUTTON_BACK
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index 97d8351..470a8e4 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -1193,6 +1193,18 @@ CONFIG_KEYPAD == MROBE500_PAD
 #define CHIP8_KEY8 BUTTON_VOL_DOWN
 #define CHIP8_KEY9 BUTTON_VOL_UP
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define CHIP8_OFF  (BUTTON_BACK|BUTTON_REPEAT)
+#define CHIP8_KEY1 BUTTON_MENU
+#define CHIP8_KEY2 BUTTON_UP
+#define CHIP8_KEY3 BUTTON_DOWN
+#define CHIP8_KEY4 BUTTON_LEFT
+#define CHIP8_KEY5 BUTTON_SELECT
+#define CHIP8_KEY6 BUTTON_RIGHT
+#define CHIP8_KEY7 BUTTON_BACK
+#define CHIP8_KEY8 BUTTON_POWER
+#define CHIP8_KEY9 BUTTON_USER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 71ea8f8..d819da4 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -97,7 +97,8 @@ Still To do:
 #define ACTION2 BUTTON_MENU
 #define ACTIONTEXT "UP"
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD \
+   || CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define QUIT BUTTON_BACK
 #define ACTION BUTTON_SELECT
 #define ACTION2 BUTTON_MENU
diff --git a/apps/plugins/clix.c b/apps/plugins/clix.c
index 378e981..06fe0d8 100644
--- a/apps/plugins/clix.c
+++ b/apps/plugins/clix.c
@@ -83,7 +83,8 @@
 #define CLIX_BUTTON_UP      BUTTON_UP
 #define CLIX_BUTTON_DOWN    BUTTON_DOWN
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define CLIX_BUTTON_QUIT    BUTTON_BACK
 #define CLIX_BUTTON_LEFT    BUTTON_LEFT
 #define CLIX_BUTTON_RIGHT   BUTTON_RIGHT
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index 7e97eaf..cecb10e 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -329,6 +329,16 @@
 #define CUBE_PAUSE         BUTTON_DOWN
 #define CUBE_HIGHSPEED     BUTTON_LEFT
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define CUBE_QUIT          BUTTON_BACK
+#define CUBE_NEXT          BUTTON_RIGHT
+#define CUBE_PREV          BUTTON_LEFT
+#define CUBE_INC           BUTTON_UP
+#define CUBE_DEC           BUTTON_DOWN
+#define CUBE_MODE          BUTTON_MENU
+#define CUBE_PAUSE         BUTTON_USER
+#define CUBE_HIGHSPEED     BUTTON_SELECT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index d12799c..9009acc 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -424,6 +424,17 @@ void I_ShutdownGraphics(void)
 #define DOOMBUTTON_ENTER   BUTTON_NEXT
 #define DOOMBUTTON_WEAPON  BUTTON_PREV
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define DOOMBUTTON_UP      BUTTON_UP
+#define DOOMBUTTON_DOWN    BUTTON_DOWN
+#define DOOMBUTTON_LEFT    BUTTON_LEFT
+#define DOOMBUTTON_RIGHT   BUTTON_RIGHT
+#define DOOMBUTTON_SHOOT   BUTTON_SELECT
+#define DOOMBUTTON_OPEN    BUTTON_MENU
+#define DOOMBUTTON_ESC     BUTTON_BACK
+#define DOOMBUTTON_ENTER   BUTTON_POWER
+#define DOOMBUTTON_WEAPON  BUTTON_USER
+
 #else
 #error Keymap not defined!
 #endif
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index 8920550..b2ef8d8 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -257,6 +257,15 @@ GREY_INFO_STRUCT
 #   define FFT_FREQ_SCALE   BUTTON_DOWN
 #   define FFT_QUIT         BUTTON_POWER
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#   define FFT_PREV_GRAPH   BUTTON_LEFT
+#   define FFT_NEXT_GRAPH   BUTTON_RIGHT
+#   define FFT_ORIENTATION  BUTTON_USER
+#   define FFT_WINDOW       BUTTON_MENU
+#   define FFT_AMP_SCALE    BUTTON_SELECT
+#   define FFT_FREQ_SCALE   BUTTON_DOWN
+#   define FFT_QUIT         BUTTON_BACK
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/fireworks.c b/apps/plugins/fireworks.c
index e3a3910..52b11b7 100644
--- a/apps/plugins/fireworks.c
+++ b/apps/plugins/fireworks.c
@@ -63,7 +63,8 @@
 
 #elif (CONFIG_KEYPAD == GIGABEAT_PAD) || \
       (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
-      (CONFIG_KEYPAD == MROBE100_PAD)
+      (CONFIG_KEYPAD == MROBE100_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define BTN_MENU BUTTON_MENU
 #define BTN_FIRE BUTTON_SELECT
 
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c
index ffc691c..da5a9e8 100644
--- a/apps/plugins/flipit.c
+++ b/apps/plugins/flipit.c
@@ -380,6 +380,18 @@
 #define FLIPIT_STEP_BY_STEP BUTTON_NEXT
 #define FLIPIT_TOGGLE       BUTTON_SELECT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+
+#define FLIPIT_LEFT         BUTTON_LEFT
+#define FLIPIT_RIGHT        BUTTON_RIGHT
+#define FLIPIT_UP           BUTTON_UP
+#define FLIPIT_DOWN         BUTTON_DOWN
+#define FLIPIT_QUIT         BUTTON_BACK
+#define FLIPIT_SHUFFLE      BUTTON_MENU
+#define FLIPIT_SOLVE        BUTTON_USER
+#define FLIPIT_STEP_BY_STEP BUTTON_POWER
+#define FLIPIT_TOGGLE       BUTTON_SELECT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/fractals/fractal.h b/apps/plugins/fractals/fractal.h
index 76f3229..0d1aff3 100644
--- a/apps/plugins/fractals/fractal.h
+++ b/apps/plugins/fractals/fractal.h
@@ -378,6 +378,18 @@
 #define FRACTAL_PRECISION_DEC   BUTTON_VOL_DOWN
 #define FRACTAL_RESET           BUTTON_PREV
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define FRACTAL_QUIT            BUTTON_BACK
+#define FRACTAL_UP              BUTTON_UP
+#define FRACTAL_DOWN            BUTTON_DOWN
+#define FRACTAL_LEFT            BUTTON_LEFT
+#define FRACTAL_RIGHT           BUTTON_RIGHT
+#define FRACTAL_ZOOM_IN         (BUTTON_MENU|BUTTON_REL)
+#define FRACTAL_ZOOM_OUT        (BUTTON_USER|BUTTON_REL)
+#define FRACTAL_PRECISION_INC   (BUTTON_MENU|BUTTON_REPEAT)
+#define FRACTAL_PRECISION_DEC   (BUTTON_USER|BUTTON_REPEAT)
+#define FRACTAL_RESET           BUTTON_POWER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/goban/goban.h b/apps/plugins/goban/goban.h
index d03bc82..20940d7 100644
--- a/apps/plugins/goban/goban.h
+++ b/apps/plugins/goban/goban.h
@@ -364,6 +364,16 @@
 #define  GBN_BUTTON_PLAY               BUTTON_SELECT
 #define  GBN_BUTTON_MENU               BUTTON_POWER
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define  GBN_BUTTON_UP                 BUTTON_UP
+#define  GBN_BUTTON_DOWN               BUTTON_DOWN
+#define  GBN_BUTTON_LEFT               BUTTON_LEFT
+#define  GBN_BUTTON_RIGHT              BUTTON_RIGHT
+#define  GBN_BUTTON_RETREAT            BUTTON_BACK
+#define  GBN_BUTTON_ADVANCE            BUTTON_USER
+#define  GBN_BUTTON_PLAY               BUTTON_SELECT
+#define  GBN_BUTTON_MENU               BUTTON_MENU
+
 #else
 #error Unsupported keypad
 #endif
diff --git a/apps/plugins/imageviewer/imageviewer_button.h b/apps/plugins/imageviewer/imageviewer_button.h
index 9f345d8..10d2399 100644
--- a/apps/plugins/imageviewer/imageviewer_button.h
+++ b/apps/plugins/imageviewer/imageviewer_button.h
@@ -379,6 +379,18 @@
 #define IMGVIEW_MENU            BUTTON_POWER
 #define IMGVIEW_SLIDE_SHOW      BUTTON_NEXT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define IMGVIEW_ZOOM_IN     BUTTON_POWER
+#define IMGVIEW_ZOOM_OUT    BUTTON_USER
+#define IMGVIEW_UP          BUTTON_UP
+#define IMGVIEW_DOWN        BUTTON_DOWN
+#define IMGVIEW_LEFT        BUTTON_LEFT
+#define IMGVIEW_RIGHT       BUTTON_RIGHT
+#define IMGVIEW_NEXT        BUTTON_SELECT
+#define IMGVIEW_PREVIOUS    0xFFFFFFA //not used
+#define IMGVIEW_MENU        BUTTON_MENU
+#define IMGVIEW_QUIT        BUTTON_BACK
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index 96e04a9..c52208d 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -122,7 +122,8 @@
 #define RIGHT BUTTON_RIGHT
 #define FIRE BUTTON_SELECT
 
-#elif CONFIG_KEYPAD == GIGABEAT_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_PAD \
+   || CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 
 #define QUIT BUTTON_POWER
 #define LEFT BUTTON_LEFT
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index 4d5a5b6..7d80a53 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -172,7 +172,8 @@ CONFIG_KEYPAD == SANSA_M200_PAD
 #define HK_SELECT "PLAY"
 #define HK_CANCEL "POWER"
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define JEWELS_UP     BUTTON_UP
 #define JEWELS_DOWN   BUTTON_DOWN
 #define JEWELS_LEFT   BUTTON_LEFT
diff --git a/apps/plugins/lamp.c b/apps/plugins/lamp.c
index d9ad70b..583e275 100644
--- a/apps/plugins/lamp.c
+++ b/apps/plugins/lamp.c
@@ -57,7 +57,8 @@
 #   define LAMP_UP         BUTTON_UP
 #   define LAMP_DOWN       BUTTON_DOWN
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #   define LAMP_LEFT       BUTTON_LEFT
 #   define LAMP_RIGHT      BUTTON_RIGHT
 #   define LAMP_UP         BUTTON_UP
diff --git a/apps/plugins/lib/pluginlib_actions.c b/apps/plugins/lib/pluginlib_actions.c
index 0a2f12d..44a2cd8 100644
--- a/apps/plugins/lib/pluginlib_actions.c
+++ b/apps/plugins/lib/pluginlib_actions.c
@@ -116,7 +116,8 @@ const struct button_mapping pla_main_ctx[] =
     || (CONFIG_KEYPAD == SANSA_FUZE_PAD) \
     || (CONFIG_KEYPAD == SAMSUNG_YH_PAD) \
     || (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) \
-    || (CONFIG_KEYPAD == SANSA_CONNECT_PAD))
+    || (CONFIG_KEYPAD == SANSA_CONNECT_PAD) \
+    || (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD))
     { PLA_UP,               BUTTON_UP,                          BUTTON_NONE },
     { PLA_DOWN,             BUTTON_DOWN,                        BUTTON_NONE },
     { PLA_LEFT,             BUTTON_LEFT,                        BUTTON_NONE },
@@ -278,7 +279,8 @@ const struct button_mapping pla_main_ctx[] =
     {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
     {PLA_SELECT_REL,        BUTTON_SELECT|BUTTON_REL,           BUTTON_SELECT},
     {PLA_SELECT_REPEAT,     BUTTON_SELECT|BUTTON_REPEAT,        BUTTON_NONE},
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif  (CONFIG_KEYPAD == GIGABEAT_S_PAD) \
+    || (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
     {PLA_CANCEL,            BUTTON_BACK,                        BUTTON_NONE},
     {PLA_EXIT,              BUTTON_MENU,                        BUTTON_NONE},
     {PLA_SELECT,            BUTTON_SELECT,                      BUTTON_NONE},
diff --git a/apps/plugins/lib/simple_viewer.c b/apps/plugins/lib/simple_viewer.c
index 16cbcb3..06cc9c1 100644
--- a/apps/plugins/lib/simple_viewer.c
+++ b/apps/plugins/lib/simple_viewer.c
@@ -25,6 +25,7 @@
 #include "simple_viewer.h"
 #include <ctype.h>
 
+
 struct view_info {
 #ifdef HAVE_LCD_BITMAP
     struct font* pf;
diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c
index d651c2f..be163f5 100644
--- a/apps/plugins/logo.c
+++ b/apps/plugins/logo.c
@@ -123,7 +123,8 @@ const unsigned char rockbox16x7[] = {
 #elif CONFIG_KEYPAD == MROBE500_PAD
 #define LP_QUIT BUTTON_POWER
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define LP_QUIT BUTTON_BACK
 #define LP_DEC_X BUTTON_LEFT
 #define LP_INC_X BUTTON_RIGHT
diff --git a/apps/plugins/lua/strcspn.c b/apps/plugins/lua/strcspn.c
index 7af6f69..0a19eae 100644
--- a/apps/plugins/lua/strcspn.c
+++ b/apps/plugins/lua/strcspn.c
@@ -1,5 +1,6 @@
 #include "rocklibc.h"
 
+#undef strcspn
 size_t strcspn(const char *s, const char *reject)
 {
   size_t l=0;
diff --git a/apps/plugins/lua/strpbrk.c b/apps/plugins/lua/strpbrk.c
index f416f39..1e0491f 100644
--- a/apps/plugins/lua/strpbrk.c
+++ b/apps/plugins/lua/strpbrk.c
@@ -1,5 +1,6 @@
 #include "rocklibc.h"
 
+#undef strpbrk
 char *strpbrk(const char *s, const char *accept) {
   register int i,l=strlen(accept);
   for (; *s; s++)
diff --git a/apps/plugins/matrix.c b/apps/plugins/matrix.c
index 1a10080..10b8ce5 100644
--- a/apps/plugins/matrix.c
+++ b/apps/plugins/matrix.c
@@ -101,7 +101,8 @@
 #define MATRIX_SLEEP_LESS BUTTON_DOWN
 #define MATRIX_PAUSE BUTTON_SELECT
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define MATRIX_EXIT BUTTON_BACK
 #define MATRIX_SLEEP_MORE BUTTON_UP
 #define MATRIX_SLEEP_LESS BUTTON_DOWN
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 1b5d184..ace7290 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -233,6 +233,14 @@
 #define BTN_DOWN         BUTTON_DOWN
 #define BTN_PLAY         BUTTON_SELECT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define BTN_QUIT         BUTTON_BACK
+#define BTN_RIGHT        BUTTON_RIGHT
+#define BTN_LEFT         BUTTON_LEFT
+#define BTN_UP           BUTTON_UP
+#define BTN_DOWN         BUTTON_DOWN
+#define BTN_PLAY         BUTTON_USER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index ad67b1d..e0da928 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -311,6 +311,16 @@ CONFIG_KEYPAD == MROBE500_PAD
 #   define MINESWP_DISCOVER BUTTON_SELECT
 #   define MINESWP_INFO     BUTTON_PREV
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#   define MINESWP_LEFT     BUTTON_LEFT
+#   define MINESWP_RIGHT    BUTTON_RIGHT
+#   define MINESWP_UP       BUTTON_UP
+#   define MINESWP_DOWN     BUTTON_DOWN
+#   define MINESWP_QUIT     BUTTON_BACK
+#   define MINESWP_TOGGLE   BUTTON_USER
+#   define MINESWP_DISCOVER BUTTON_SELECT
+#   define MINESWP_INFO     BUTTON_MENU
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/mosaique.c b/apps/plugins/mosaique.c
index ec41c8c..87e664e 100644
--- a/apps/plugins/mosaique.c
+++ b/apps/plugins/mosaique.c
@@ -113,7 +113,8 @@
 #elif CONFIG_KEYPAD == MROBE500_PAD
 #define MOSAIQUE_QUIT BUTTON_POWER
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define MOSAIQUE_QUIT BUTTON_BACK
 #define MOSAIQUE_SPEED BUTTON_SELECT
 #define MOSAIQUE_RESTART BUTTON_MENU
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index a70e316..567ec5d 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -2394,7 +2394,8 @@ static void get_mp3_filename(const char *wav_name)
 #define MP3ENC_DONE BUTTON_POWER
 #define MP3ENC_SELECT BUTTON_SELECT
 
-#elif CONFIG_KEYPAD == GIGABEAT_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define MP3ENC_PREV BUTTON_UP
 #define MP3ENC_NEXT BUTTON_DOWN
 #define MP3ENC_DONE BUTTON_POWER
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 90b5478..e9b1c01 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -248,6 +248,14 @@ struct mpeg_settings settings;
 #define MPEG_START_TIME_DOWN        BUTTON_DOWN
 #define MPEG_START_TIME_EXIT        BUTTON_POWER
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define MPEG_START_TIME_SELECT      BUTTON_SELECT
+#define MPEG_START_TIME_LEFT        BUTTON_LEFT
+#define MPEG_START_TIME_RIGHT       BUTTON_RIGHT
+#define MPEG_START_TIME_UP          BUTTON_UP
+#define MPEG_START_TIME_DOWN        BUTTON_DOWN
+#define MPEG_START_TIME_EXIT        BUTTON_BACK
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index e3d9865..f73e5f2 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -362,6 +362,15 @@ CONFIG_KEYPAD == SANSA_M200_PAD
 #define MPEG_RW         BUTTON_LEFT
 #define MPEG_FF         BUTTON_RIGHT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define MPEG_MENU       BUTTON_MENU
+#define MPEG_PAUSE      BUTTON_SELECT
+#define MPEG_STOP       BUTTON_POWER
+#define MPEG_VOLDOWN    BUTTON_DOWN
+#define MPEG_VOLUP      BUTTON_UP
+#define MPEG_RW         BUTTON_LEFT
+#define MPEG_FF         BUTTON_RIGHT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c
index 4469a92..0b1687d 100644
--- a/apps/plugins/oscilloscope.c
+++ b/apps/plugins/oscilloscope.c
@@ -342,6 +342,17 @@
 #define OSCILLOSCOPE_VOL_UP       BUTTON_VOL_UP
 #define OSCILLOSCOPE_VOL_DOWN     BUTTON_VOL_DOWN
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define OSCILLOSCOPE_QUIT         BUTTON_BACK
+#define OSCILLOSCOPE_DRAWMODE     BUTTON_USER
+#define OSCILLOSCOPE_ADVMODE      BUTTON_MENU
+#define OSCILLOSCOPE_ORIENTATION  BUTTON_POWER
+#define OSCILLOSCOPE_PAUSE        BUTTON_SELECT
+#define OSCILLOSCOPE_SPEED_UP     BUTTON_RIGHT
+#define OSCILLOSCOPE_SPEED_DOWN   BUTTON_LEFT
+#define OSCILLOSCOPE_VOL_UP       BUTTON_UP
+#define OSCILLOSCOPE_VOL_DOWN     BUTTON_DOWN
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h
index 3c906ac..0183b0c 100644
--- a/apps/plugins/pacbox/pacbox.h
+++ b/apps/plugins/pacbox/pacbox.h
@@ -265,6 +265,17 @@
 #define PACMAN_COIN     BUTTON_VOL_DOWN
 #define PACMAN_MENU     BUTTON_POWER
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+
+#define PACMAN_UP       BUTTON_UP
+#define PACMAN_DOWN     BUTTON_DOWN
+#define PACMAN_LEFT     BUTTON_LEFT
+#define PACMAN_RIGHT    BUTTON_RIGHT
+#define PACMAN_1UP      BUTTON_SELECT
+#define PACMAN_2UP      BUTTON_POWER
+#define PACMAN_COIN     BUTTON_USER
+#define PACMAN_MENU     BUTTON_MENU
+
 #else
 
 #error Keymap not defined!
diff --git a/apps/plugins/pdbox/pdbox.h b/apps/plugins/pdbox/pdbox.h
index 56ad568..b53e15f 100644
--- a/apps/plugins/pdbox/pdbox.h
+++ b/apps/plugins/pdbox/pdbox.h
@@ -89,7 +89,9 @@ float rb_atan(float);
 float rb_atan2(float, float);
 float rb_sinh(float);
 float rb_tan(float);
-#ifndef SIMULATOR
+//#ifndef SIMULATOR
+/*FIXME: is it a correct replacement??? */
+#if !(CONFIG_PLATFORM & PLATFORM_HOSTED)
 typedef struct
 {
     int quot;
@@ -163,9 +165,12 @@ void pd_init(void);
 #define atoi rb->atoi
 #define write rb->write
 
+#undef strncat
 #define strncat rb_strncat
 
-#ifndef SIMULATOR
+//#ifndef SIMULATOR
+/*FIXME: is it a correct replacement??? */
+#if !(CONFIG_PLATFORM & PLATFORM_HOSTED)
 #define floor rb_floor
 #define atof rb_atof
 #define atol rb_atol
@@ -186,6 +191,7 @@ void pd_init(void);
 #endif
 
 #define ftoan rb_ftoan
+#undef strtok_r
 #define strtok_r rb->strtok_r
 #define strstr rb->strcasestr
 
@@ -282,6 +288,15 @@ enum pd_key_id
     #define PDPOD_WHEELLEFT (BUTTON_SCROLL_BACK)
     #define PDPOD_WHEELRIGHT (BUTTON_SCROLL_FWD)
     #define PDPOD_ACTION (BUTTON_SELECT)
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+    #define PDPOD_QUIT      BUTTON_BACK
+    #define PDPOD_PLAY      BUTTON_USER
+    #define PDPOD_PREVIOUS  BUTTON_LEFT
+    #define PDPOD_NEXT      BUTTON_RIGHT
+    #define PDPOD_MENU      BUTTON_MENU
+    #define PDPOD_WHEELLEFT BUTTON_UP
+    #define PDPOD_WHEELRIGHT BUTTON_DOWN
+    #define PDPOD_ACTION    BUTTON_SELECT
 #else
     #warning "No keys defined for this architecture!"
 #endif
diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c
index 3eb6008..479f7c5 100644
--- a/apps/plugins/pegbox.c
+++ b/apps/plugins/pegbox.c
@@ -510,6 +510,24 @@ CONFIG_KEYPAD == MROBE500_PAD
 #define LVL_DOWN_TEXT "PREV"
 #define SELECT_TEXT "SELECT"
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define PEGBOX_SELECT   BUTTON_SELECT
+#define PEGBOX_QUIT     BUTTON_BACK
+#define PEGBOX_RESTART  BUTTON_MENU
+#define PEGBOX_LVL_UP   BUTTON_USER
+#define PEGBOX_LVL_DOWN BUTTON_POWER
+#define PEGBOX_UP       BUTTON_UP
+#define PEGBOX_DOWN     BUTTON_DOWN
+#define PEGBOX_RIGHT    BUTTON_RIGHT
+#define PEGBOX_LEFT     BUTTON_LEFT
+
+#define SAVE_TEXT "PLAYPAUSE"
+#define QUIT_TEXT "POWER"
+#define RESTART_TEXT "BACK"
+#define LVL_UP_TEXT "Vol+"
+#define LVL_DOWN_TEXT "Vol-"
+#define SELECT_TEXT "SELECT"
+
 #else
 #error Unsupported keymap!
 #endif
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c
index d3875f3..430b688 100644
--- a/apps/plugins/pong.c
+++ b/apps/plugins/pong.c
@@ -244,6 +244,14 @@ CONFIG_KEYPAD == MROBE500_PAD
 #define PONG_RIGHT_UP BUTTON_UP
 #define PONG_RIGHT_DOWN BUTTON_RIGHT
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define PONG_QUIT BUTTON_BACK
+#define PONG_PAUSE BUTTON_SELECT
+#define PONG_LEFT_UP BUTTON_UP
+#define PONG_LEFT_DOWN BUTTON_DOWN
+#define PONG_RIGHT_UP BUTTON_MENU
+#define PONG_RIGHT_DOWN BUTTON_POWER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/reversi/reversi-gui.h b/apps/plugins/reversi/reversi-gui.h
index a36efe5..c0d6183 100644
--- a/apps/plugins/reversi/reversi-gui.h
+++ b/apps/plugins/reversi/reversi-gui.h
@@ -252,6 +252,15 @@
 #define REVERSI_BUTTON_MAKE_MOVE BUTTON_PLAYPAUSE
 #define REVERSI_BUTTON_MENU BUTTON_BACK
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define REVERSI_BUTTON_QUIT BUTTON_BACK
+#define REVERSI_BUTTON_UP BUTTON_UP
+#define REVERSI_BUTTON_DOWN BUTTON_DOWN
+#define REVERSI_BUTTON_LEFT BUTTON_LEFT
+#define REVERSI_BUTTON_RIGHT BUTTON_RIGHT
+#define REVERSI_BUTTON_MAKE_MOVE BUTTON_SELECT
+#define REVERSI_BUTTON_MENU BUTTON_MENU
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 674b14e..c23c6b1 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -379,6 +379,18 @@
 #define ROCKBLOX_DROP          BUTTON_SELECT
 #define ROCKBLOX_RESTART       BUTTON_VOL_DOWN
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+
+#define ROCKBLOX_OFF           BUTTON_BACK
+#define ROCKBLOX_ROTATE_CCW    BUTTON_POWER
+#define ROCKBLOX_ROTATE_CW     BUTTON_MENU
+#define ROCKBLOX_ROTATE        BUTTON_UP
+#define ROCKBLOX_DOWN          BUTTON_DOWN
+#define ROCKBLOX_LEFT          BUTTON_LEFT
+#define ROCKBLOX_RIGHT         BUTTON_RIGHT
+#define ROCKBLOX_DROP          BUTTON_SELECT
+#define ROCKBLOX_RESTART       BUTTON_USER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/rockblox1d.c b/apps/plugins/rockblox1d.c
index 49219c2..5b6e812 100644
--- a/apps/plugins/rockblox1d.c
+++ b/apps/plugins/rockblox1d.c
@@ -69,7 +69,8 @@
 #define ONEDROCKBLOX_DOWN              BUTTON_PLAY
 #define ONEDROCKBLOX_QUIT              BUTTON_POWER
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define ONEDROCKBLOX_DOWN              BUTTON_SELECT
 #define ONEDROCKBLOX_QUIT              BUTTON_BACK
 
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 37f0566..bc73abe 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -342,6 +342,18 @@ static void setoptions (void)
         options.SELECT = BUTTON_NEXT;
         options.MENU   = BUTTON_SELECT;
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+        options.UP     = BUTTON_UP;
+        options.DOWN   = BUTTON_DOWN;
+        options.LEFT   = BUTTON_LEFT;
+        options.RIGHT  = BUTTON_RIGHT;
+
+        options.A      = BUTTON_SELECT;
+        options.B      = BUTTON_BACK;
+        options.START  = BUTTON_POWER;
+        options.SELECT = BUTTON_USER;
+        options.MENU   = BUTTON_MENU;
+
 #else
 #error No Keymap Defined!
 #endif
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h
index 724a0fb..87e570b 100644
--- a/apps/plugins/rockboy/rockmacros.h
+++ b/apps/plugins/rockboy/rockmacros.h
@@ -23,8 +23,6 @@
 
 #include "plugin.h"
 
-#include "autoconf.h"
-
 #define malloc(a) my_malloc(a)
 void *my_malloc(size_t size);
 
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index 7f16bf2..eeca916 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -243,6 +243,17 @@
 #define ROCKPAINT_LEFT      BUTTON_LEFT
 #define ROCKPAINT_RIGHT     BUTTON_RIGHT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define ROCKPAINT_QUIT      BUTTON_BACK
+#define ROCKPAINT_DRAW      BUTTON_SELECT
+#define ROCKPAINT_MENU      BUTTON_MENU
+#define ROCKPAINT_TOOLBAR   BUTTON_USER
+#define ROCKPAINT_TOOLBAR2  ( BUTTON_USER | BUTTON_REPEAT )
+#define ROCKPAINT_UP        BUTTON_UP
+#define ROCKPAINT_DOWN      BUTTON_DOWN
+#define ROCKPAINT_LEFT      BUTTON_LEFT
+#define ROCKPAINT_RIGHT     BUTTON_RIGHT
+
 #else
 #error "Please define keys for this keypad"
 #endif
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index 653099a..a176f75 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -136,7 +136,8 @@
 #define PUZZLE_SHUFFLE BUTTON_REW
 #define PUZZLE_PICTURE BUTTON_PLAY
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define PUZZLE_QUIT BUTTON_BACK
 #define PUZZLE_LEFT BUTTON_LEFT
 #define PUZZLE_RIGHT BUTTON_RIGHT
@@ -784,7 +785,8 @@ enum plugin_status plugin_start(
         rb->lcd_putsxy(0, 18, "[OFF] to stop");
         rb->lcd_putsxy(0, 28, "[REW] shuffle");
         rb->lcd_putsxy(0, 38, "[PLAY] change pic");
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
         rb->lcd_putsxy(0, 18, "[BACK] to stop");
         rb->lcd_putsxy(0, 28, "[SELECT] shuffle");
         rb->lcd_putsxy(0, 38, "[MENU] change pic");
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index 09e72a5..a203767 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -130,7 +130,8 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
 #define SNAKE_DOWN BUTTON_SCROLL_DOWN
 #define SNAKE_PLAYPAUSE BUTTON_PLAY
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define SNAKE_QUIT BUTTON_BACK
 #define SNAKE_LEFT BUTTON_LEFT
 #define SNAKE_RIGHT BUTTON_RIGHT
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index 0e7b499..bd0257d 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -238,7 +238,8 @@ Head and Tail are stored
 #define SNAKE2_PLAYPAUSE BUTTON_FF
 #define SNAKE2_PLAYPAUSE_TEXT "FF"
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define SNAKE2_LEFT BUTTON_LEFT
 #define SNAKE2_RIGHT BUTTON_RIGHT
 #define SNAKE2_UP   BUTTON_UP
diff --git a/apps/plugins/snow.c b/apps/plugins/snow.c
index 8a2de39..6371a69 100644
--- a/apps/plugins/snow.c
+++ b/apps/plugins/snow.c
@@ -67,7 +67,8 @@
 #define SNOW_QUIT (BUTTON_HOME|BUTTON_REPEAT)
 
 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
-(CONFIG_KEYPAD == CREATIVEZVM_PAD)
+(CONFIG_KEYPAD == CREATIVEZVM_PAD) || \
+(CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define SNOW_QUIT BUTTON_BACK
 
 #elif (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD) || \
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index ddc9529..942b101 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -526,6 +526,21 @@
 #define BUTTON_SAVE          (BUTTON_SELECT|BUTTON_REPEAT)
 #define BUTTON_SAVE_NAME "SELECT LONG"
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define SOKOBAN_LEFT BUTTON_LEFT
+#define SOKOBAN_RIGHT BUTTON_RIGHT
+#define SOKOBAN_UP BUTTON_UP
+#define SOKOBAN_DOWN BUTTON_DOWN
+#define SOKOBAN_MENU BUTTON_MENU
+#define SOKOBAN_UNDO BUTTON_BACK
+#define SOKOBAN_REDO BUTTON_USER
+//#define SOKOBAN_LEVEL_DOWN (BUTTON_POWER|BUTTON_REL)
+//#define SOKOBAN_LEVEL_REPEAT (BUTTON_CENTER|BUTTON_REPEAT)
+//#define SOKOBAN_LEVEL_UP (BUTTON_MENU|BUTTON_REPEAT)
+#define SOKOBAN_PAUSE BUTTON_SELECT
+#define BUTTON_SAVE BUTTON_SELECT
+#define BUTTON_SAVE_NAME "SELECT"
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 91ef346..a1e8b76 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -544,6 +544,24 @@ CONFIG_KEYPAD == MROBE500_PAD
 #   define HK_CUR2STACK      "NEXT"
 #   define HK_REM2STACK      "PREV"
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#   define SOL_QUIT         BUTTON_BACK
+#   define SOL_UP           BUTTON_UP
+#   define SOL_DOWN         BUTTON_DOWN
+#   define SOL_LEFT         BUTTON_LEFT
+#   define SOL_RIGHT        BUTTON_RIGHT
+#   define SOL_MOVE_PRE     BUTTON_SELECT
+#   define SOL_MOVE         (BUTTON_SELECT | BUTTON_REL)
+#   define SOL_DRAW         BUTTON_MENU
+#   define SOL_REM2CUR      (BUTTON_USER | BUTTON_REPEAT)
+#   define SOL_CUR2STACK    (BUTTON_SELECT | BUTTON_REPEAT)
+#   define SOL_REM2STACK    BUTTON_POWER
+#   define HK_MOVE         "Select"
+#   define HK_DRAW         "Menu"
+#   define HK_REM2CUR      "Long User"
+#   define HK_CUR2STACK    "Long Select.."
+#   define HK_REM2STACK    "Power"
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c
index 0c03a31..946d97d 100644
--- a/apps/plugins/spacerocks.c
+++ b/apps/plugins/spacerocks.c
@@ -278,6 +278,15 @@
 #define AST_RIGHT BUTTON_RIGHT
 #define AST_FIRE BUTTON_SELECT
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define AST_PAUSE       BUTTON_MENU
+#define AST_QUIT        BUTTON_BACK
+#define AST_THRUST      BUTTON_UP
+#define AST_HYPERSPACE  BUTTON_DOWN
+#define AST_LEFT        BUTTON_LEFT
+#define AST_RIGHT       BUTTON_RIGHT
+#define AST_FIRE        BUTTON_SELECT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index 620cddf..cf04e02 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -480,6 +480,23 @@
 #define STAR_LEVEL_DOWN_NAME "Vol-"
 #define STAR_LEVEL_REPEAT_NAME "PREV LONG"
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+
+#define STAR_QUIT           BUTTON_BACK
+#define STAR_LEFT           BUTTON_LEFT
+#define STAR_RIGHT          BUTTON_RIGHT
+#define STAR_UP             BUTTON_UP
+#define STAR_DOWN           BUTTON_DOWN
+#define STAR_TOGGLE_CONTROL BUTTON_SELECT
+#define STAR_LEVEL_UP       BUTTON_MENU
+#define STAR_LEVEL_DOWN     BUTTON_POWER
+#define STAR_LEVEL_REPEAT   BUTTON_USER
+#define STAR_TOGGLE_CONTROL_NAME "Select"
+#define STAR_QUIT_NAME      "Back"
+#define STAR_LEVEL_UP_NAME  "Menu"
+#define STAR_LEVEL_DOWN_NAME "Power"
+#define STAR_LEVEL_REPEAT_NAME "User"
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/starfield.c b/apps/plugins/starfield.c
index e3b5634..c996da9 100644
--- a/apps/plugins/starfield.c
+++ b/apps/plugins/starfield.c
@@ -78,7 +78,8 @@
 #define STARFIELD_DECREASE_NB_STARS BUTTON_LEFT
 #define STARFIELD_TOGGLE_COLOR BUTTON_SELECT
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 #define STARFIELD_QUIT BUTTON_BACK
 #define STARFIELD_INCREASE_ZMOVE BUTTON_UP
 #define STARFIELD_DECREASE_ZMOVE BUTTON_DOWN
diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c
index c5ff31e..da231b7 100644
--- a/apps/plugins/stats.c
+++ b/apps/plugins/stats.c
@@ -72,7 +72,8 @@ static bool cancel;
 #define STATS_STOP BUTTON_POWER
 #define STATS_STOP_REMOTE BUTTON_RC_DOWN
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define STATS_STOP BUTTON_BACK
 
 #elif CONFIG_KEYPAD == MROBE100_PAD
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c
index 94785dc..fd33bb7 100644
--- a/apps/plugins/stopwatch.c
+++ b/apps/plugins/stopwatch.c
@@ -263,6 +263,14 @@
 #define STOPWATCH_SCROLL_UP BUTTON_UP
 #define STOPWATCH_SCROLL_DOWN BUTTON_DOWN
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define STOPWATCH_QUIT BUTTON_BACK
+#define STOPWATCH_START_STOP BUTTON_SELECT
+#define STOPWATCH_RESET_TIMER BUTTON_MENU
+#define STOPWATCH_LAP_TIMER BUTTON_USER
+#define STOPWATCH_SCROLL_UP BUTTON_UP
+#define STOPWATCH_SCROLL_DOWN BUTTON_DOWN
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/sudoku/sudoku.h b/apps/plugins/sudoku/sudoku.h
index 456e4fd..0714718 100644
--- a/apps/plugins/sudoku/sudoku.h
+++ b/apps/plugins/sudoku/sudoku.h
@@ -329,6 +329,16 @@
 #define SUDOKU_BUTTON_MENU BUTTON_SELECT
 #define SUDOKU_BUTTON_POSSIBLE BUTTON_VOL_DOWN
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define SUDOKU_BUTTON_QUIT       BUTTON_BACK
+#define SUDOKU_BUTTON_UP         BUTTON_UP
+#define SUDOKU_BUTTON_DOWN       BUTTON_DOWN
+#define SUDOKU_BUTTON_LEFT       BUTTON_LEFT
+#define SUDOKU_BUTTON_RIGHT      BUTTON_RIGHT
+#define SUDOKU_BUTTON_MENU       BUTTON_MENU
+#define SUDOKU_BUTTON_TOGGLE     BUTTON_SELECT
+#define SUDOKU_BUTTON_POSSIBLE   BUTTON_USER
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c
index b4e25af..135a6ae 100644
--- a/apps/plugins/superdom.c
+++ b/apps/plugins/superdom.c
@@ -120,7 +120,8 @@ char buf[255];
 #define SUPERDOM_RIGHT BUTTON_RIGHT
 #define SUPERDOM_CANCEL (BUTTON_HOME|BUTTON_REPEAT)
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 #define SUPERDOM_OK BUTTON_SELECT
 #define SUPERDOM_UP BUTTON_UP
 #define SUPERDOM_DOWN BUTTON_DOWN
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c
index 6e1b3b6..849b40d 100644
--- a/apps/plugins/test_codec.c
+++ b/apps/plugins/test_codec.c
@@ -39,6 +39,8 @@
 #define TESTCODEC_EXITBUTTON (BUTTON_REC | BUTTON_REPEAT)
 #elif CONFIG_KEYPAD == RK27XX_GENERIC_PAD
 #define TESTCODEC_EXITBUTTON (BUTTON_M | BUTTON_REPEAT)
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define TESTCODEC_EXITBUTTON BUTTON_BACK
 #elif defined(HAVE_TOUCHSCREEN)
 #define TESTCODEC_EXITBUTTON BUTTON_TOPLEFT
 #else
diff --git a/apps/plugins/test_fps.c b/apps/plugins/test_fps.c
index da4684f..4514aa6 100644
--- a/apps/plugins/test_fps.c
+++ b/apps/plugins/test_fps.c
@@ -37,6 +37,8 @@
 #define FPS_QUIT (BUTTON_REC|BUTTON_REPEAT)
 #elif CONFIG_KEYPAD == RK27XX_GENERIC_PAD
 #define FPS_QUIT (BUTTON_M|BUTTON_REPEAT)
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define FPS_QUIT BUTTON_BACK
 #elif defined(BUTTON_OFF)
 #define FPS_QUIT BUTTON_OFF
 #else
diff --git a/apps/plugins/test_gfx.c b/apps/plugins/test_gfx.c
index cde77c5..4081e64 100644
--- a/apps/plugins/test_gfx.c
+++ b/apps/plugins/test_gfx.c
@@ -402,7 +402,7 @@ static void time_text(void) /* tests mono_bitmap performance */
 /* plugin entry point */
 enum plugin_status plugin_start(const void* parameter)
 {
-#ifndef SIMULATOR
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
     int cpu_freq;
 #endif
 
@@ -447,7 +447,7 @@ enum plugin_status plugin_start(const void* parameter)
                 6*4*DURATION/HZ);
     init_rand_table();
 
-#ifndef SIMULATOR
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
     cpu_freq = *rb->cpu_frequency; /* remember CPU frequency */
 #endif
 
@@ -458,7 +458,7 @@ enum plugin_status plugin_start(const void* parameter)
     time_fillrect();
     time_text();
 
-#ifndef SIMULATOR
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
     if (*rb->cpu_frequency != cpu_freq)
         rb->fdprintf(log_fd, "\nCPU: %s\n", "clock changed!");
     else
diff --git a/apps/plugins/text_viewer/tv_button.h b/apps/plugins/text_viewer/tv_button.h
index 697076e..fe16b5f 100644
--- a/apps/plugins/text_viewer/tv_button.h
+++ b/apps/plugins/text_viewer/tv_button.h
@@ -436,6 +436,16 @@
 #define TV_LINE_DOWN    BUTTON_SCROLL_FWD
 #define TV_BOOKMARK     (BUTTON_DOWN|BUTTON_SELECT)
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+#define TV_QUIT         BUTTON_BACK
+#define TV_SCROLL_UP    BUTTON_UP
+#define TV_SCROLL_DOWN  BUTTON_DOWN
+#define TV_SCREEN_LEFT  BUTTON_LEFT
+#define TV_SCREEN_RIGHT BUTTON_RIGHT
+#define TV_MENU         BUTTON_MENU
+#define TV_AUTOSCROLL   BUTTON_USER
+#define TV_BOOKMARK     BUTTON_SELECT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index cf66070..7ca7b43 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -338,6 +338,17 @@
 #define LABEL_MENU "PREV"
 #define LABEL_VOLUME "VOL+/VOL-"
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+#define VUMETER_QUIT BUTTON_BACK
+#define VUMETER_HELP BUTTON_USER
+#define VUMETER_MENU BUTTON_MENU
+#define VUMETER_UP   BUTTON_UP
+#define VUMETER_DOWN BUTTON_DOWN
+#define LABEL_HELP   "User"
+#define LABEL_QUIT   "Back"
+#define LABEL_MENU   "Menu"
+#define LABEL_VOLUME "Up/Down"
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c
index 016c4ad..f1834aa 100644
--- a/apps/plugins/wormlet.c
+++ b/apps/plugins/wormlet.c
@@ -180,7 +180,8 @@ static long max_cycle;
 #define BTN_QUIT BUTTON_POWER
 #define BTN_STOPRESET BUTTON_REW
 
-#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
+#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
+      (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
 
 #define BTN_DIR_UP BUTTON_UP
 #define BTN_DIR_DOWN BUTTON_DOWN
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 8de0c8f..30fd5fd 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -277,6 +277,15 @@ CONFIG_KEYPAD == MROBE500_PAD
 #define DOWN  BUTTON_DOWN
 #define PAUSE BUTTON_SELECT
 
+#elif (CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
+
+#define QUIT  BUTTON_BACK
+#define LEFT  BUTTON_LEFT
+#define RIGHT BUTTON_RIGHT
+#define UP    BUTTON_UP
+#define DOWN  BUTTON_DOWN
+#define PAUSE BUTTON_SELECT
+
 #else
 #error No keymap defined!
 #endif
diff --git a/apps/plugins/zxbox/keymaps.h b/apps/plugins/zxbox/keymaps.h
index 4e5d73a..317e67c 100644
--- a/apps/plugins/zxbox/keymaps.h
+++ b/apps/plugins/zxbox/keymaps.h
@@ -28,7 +28,8 @@
 #define ZX_SELECT     BUTTON_SELECT
 #define ZX_MENU    BUTTON_MENU
 
-#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
+#elif CONFIG_KEYPAD == GIGABEAT_S_PAD || \
+      CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
 
 #define ZX_UP      BUTTON_UP
 #define ZX_DOWN    BUTTON_DOWN
@@ -226,6 +227,15 @@
 #define ZX_LEFT         BUTTON_LEFT
 #define ZX_RIGHT        BUTTON_RIGHT
 
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+
+#define ZX_MENU         BUTTON_MENU
+#define ZX_UP           BUTTON_UP
+#define ZX_DOWN         BUTTON_DOWN
+#define ZX_SELECT       BUTTON_CENTER
+#define ZX_LEFT         BUTTON_LEFT
+#define ZX_RIGHT        BUTTON_RIGHT
+
 #else
 #error Keymap not defined!
 
diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c
index fc5ed41..e8b5219 100644
--- a/apps/plugins/zxbox/zxbox_keyb.c
+++ b/apps/plugins/zxbox/zxbox_keyb.c
@@ -225,6 +225,15 @@
 
 #elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
 
+#define KBD_SELECT BUTTON_CENTER
+#define KBD_ABORT  BUTTON_BACK
+#define KBD_LEFT   BUTTON_LEFT
+#define KBD_RIGHT  BUTTON_RIGHT
+#define KBD_UP     BUTTON_UP
+#define KBD_DOWN   BUTTON_DOWN
+
+#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
+
 #define KBD_SELECT BUTTON_SELECT
 #define KBD_ABORT  BUTTON_BACK
 #define KBD_LEFT   BUTTON_LEFT
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 7053358..f59475e 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -14,8 +14,10 @@ target/hosted/cpuinfo-linux.c
 #endif
 
 target/hosted/powermgmt.c
+#ifndef SAMSUNG_YPR0 /* uses as3514 rtc */
 target/hosted/rtc.c
 #endif
+#endif
 system.c
 usb.c
 #ifdef ROCKBOX_HAS_LOGF
@@ -62,6 +64,26 @@ target/hosted/sdl/app/button-application.c
 #endif
 #endif
 
+#ifdef SAMSUNG_YPR0
+#if (CONFIG_RTC == RTC_AS3514)
+drivers/rtc/rtc_as3514.c
+#else
+target/hosted/rtc.c
+#endif
+target/hosted/ypr0/button-ypr0.c
+target/hosted/ypr0/kernel-ypr0.c
+target/hosted/ypr0/lcd-ypr0.c
+target/hosted/ypr0/system-ypr0.c
+target/hosted/ypr0/fs-ypr0.c
+target/hosted/ypr0/lc-ypr0.c
+thread.c
+#ifdef HAVE_BACKLIGHT
+target/hosted/ypr0/backlight-ypr0.c
+#endif
+target/hosted/ypr0/ascodec-ypr0.c
+target/hosted/ypr0/powermgmt-ypr0.c
+#endif
+
 /* Maemo specific files */
 #if (CONFIG_PLATFORM & PLATFORM_MAEMO)
 target/hosted/maemo/maemo-thread.c
@@ -368,6 +390,10 @@ drivers/audio/aic3x.c
 #elif defined (HAVE_DUMMY_CODEC)
 drivers/audio/dummy_codec.c
 #endif /* defined(HAVE_*) */
+#else /* PLATFORM_HOSTED */
+#if defined(SAMSUNG_YPR0) && defined(HAVE_AS3514)
+drivers/audio/as3514.c
+target/hosted/pcm-alsa.c
 #elif defined(HAVE_SDL_AUDIO)
 drivers/audio/sdl.c
 #if CONFIG_CODEC == SWCODEC
@@ -377,6 +403,7 @@ target/hosted/maemo/pcm-gstreamer.c
 target/hosted/sdl/pcm-sdl.c
 #endif /* (CONFIG_PLATFORM & PLATFORM_MAEMO) */
 #endif /* CONFIG_CODEC == SWCODEC */
+#endif
 #endif /* (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) */
 
 /* CPU Specific - By class then particular chip if applicable */
@@ -722,7 +749,7 @@ target/arm/ascodec-pp.c
 # endif
 # if !defined(BOOTLOADER) || defined(CPU_PP)
 target/arm/adc-as3514.c
-#  ifndef SANSA_M200V4
+#  if !defined(SANSA_M200V4) && !defined(SAMSUNG_YPR0)
 target/arm/powermgmt-ascodec.c
 #  endif
 # endif
diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c
index ed413eb..95bff33 100644
--- a/firmware/common/rbpaths.c
+++ b/firmware/common/rbpaths.c
@@ -23,6 +23,7 @@
 #include <stdio.h> /* snprintf */
 #include <stdlib.h>
 #include <stdarg.h>
+#include "config.h"
 #include "rbpaths.h"
 #include "file.h" /* MAX_PATH */
 #include "logf.h"
@@ -38,11 +39,17 @@
 #undef mkdir
 #undef rmdir
 
+
 #if (CONFIG_PLATFORM & PLATFORM_ANDROID)
 #include "dir-target.h"
 #define opendir opendir_android
 #define mkdir   mkdir_android
 #define rmdir   rmdir_android
+#elif defined(SAMSUNG_YPR0)
+#include "dir-target.h"
+#define opendir opendir_ypr0
+#define mkdir   mkdir_ypr0
+#define rmdir   rmdir_ypr0
 #elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 #define open    sim_open
 #define remove  sim_remove
@@ -59,6 +66,8 @@ extern int sim_rmdir(const char* name);
 const char *rbhome;
 #endif
 
+#if !defined(SAMSUNG_YPR0)
+
 /* flags for get_user_file_path() */
 /* whether you need write access to that file/dir, especially true
  * for runtime generated files (config.cfg) */
@@ -238,3 +247,28 @@ int app_rmdir(const char* name)
     }
     return rmdir(fname);
 }
+
+#else
+
+int app_open(const char *name, int o, ...)
+{
+    if (o & O_CREAT)
+    {
+        int ret;
+        va_list ap;
+        va_start(ap, o);
+        ret = open(name, o, va_arg(ap, mode_t));
+        va_end(ap);
+        return ret;
+    }
+    return open(name, o);
+}
+
+int app_creat(const char* name, mode_t mode) { return creat(name, mode); }
+int app_remove(const char *name) { return remove(name); }
+int app_rename(const char *old, const char *new) { return rename(old,new); }
+DIR *app_opendir(const char *name) { return opendir(name); }
+int app_mkdir(const char* name) { return mkdir(name); }
+int app_rmdir(const char* name) { return rmdir(name); }
+
+#endif
diff --git a/firmware/drivers/audio/as3514.c b/firmware/drivers/audio/as3514.c
index 64531cf..0fe3070 100644
--- a/firmware/drivers/audio/as3514.c
+++ b/firmware/drivers/audio/as3514.c
@@ -78,6 +78,7 @@ const struct sound_settings_info audiohw_settings[] = {
 #endif
 };
 
+#ifndef SAMSUNG_YPR0
 /* Shadow registers */
 static uint8_t as3514_regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */
 
@@ -110,7 +111,29 @@ static void as3514_write_masked(unsigned int reg, unsigned int bits,
 {
     as3514_write(reg, (as3514_regs[reg] & ~mask) | (bits & mask));
 }
+#else
+static void as3514_write(unsigned int reg, unsigned int value)
+{
+    ascodec_write(reg, value);
+}
+
+/* Helpers to set/clear bits */
+static void as3514_set(unsigned int reg, unsigned int bits)
+{
+    ascodec_write(reg, ascodec_read(reg) | bits);
+}
+
+static void as3514_clear(unsigned int reg, unsigned int bits)
+{
+    ascodec_write(reg, ascodec_read(reg) & ~bits);
+}
 
+static void as3514_write_masked(unsigned int reg, unsigned int bits,
+                                unsigned int mask)
+{
+    ascodec_write(reg, (ascodec_read(reg) & ~mask) | (bits & mask));
+}
+#endif
 /* convert tenth of dB volume to master volume register value */
 int tenthdb2master(int db)
 {
@@ -145,8 +168,11 @@ int sound_val2phys(int setting, int value)
  */
 void audiohw_preinit(void)
 {
+
+#ifndef SAMSUNG_YPR0
     /* read all reg values */
     ascodec_readbytes(0x0, AS3514_NUM_AUDIO_REGS, as3514_regs);
+#endif
 
 #ifdef HAVE_AS3543
 
@@ -284,9 +310,14 @@ void audiohw_set_master_vol(int vol_l, int vol_r)
 #if CONFIG_CPU == AS3525v2 
 #define MIXER_MAX_VOLUME 0x1b
 #else /* lets leave the AS3514 alone until its better tested*/
+#ifdef SAMSUNG_YPR0
+#define MIXER_MAX_VOLUME 0x1a
+#else
 #define MIXER_MAX_VOLUME 0x16
 #endif
+#endif
 
+#ifndef SAMSUNG_YPR0
     if (vol_r <= MIXER_MAX_VOLUME) {
         mix_r = vol_r;
         hph_r = 0;
@@ -302,7 +333,16 @@ void audiohw_set_master_vol(int vol_l, int vol_r)
         mix_l = MIXER_MAX_VOLUME;
         hph_l = vol_l - MIXER_MAX_VOLUME;
     }    
-
+#else
+/* Okay. This is shit coded indeed. It is just a test.
+    Some considerations: Samsung keeps DAC constantly to 0x1a volume. It modifies only the headphone amp volume
+*/
+
+    mix_r = 0x1a;
+    mix_l = 0x1a;
+    hph_l = vol_l;
+    hph_r = vol_r;
+#endif
 
     as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK);
     as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK);
diff --git a/firmware/drivers/rtc/rtc_as3514.c b/firmware/drivers/rtc/rtc_as3514.c
index 44ef3cc..868fa97 100644
--- a/firmware/drivers/rtc/rtc_as3514.c
+++ b/firmware/drivers/rtc/rtc_as3514.c
@@ -141,11 +141,11 @@ void rtc_alarm_poweroff(void)
         seconds = 24*3600;
 
     seconds -= tm.tm_sec;
-
+#ifndef SAMSUNG_YPR0
     /* disable MCLK, it is a wakeup source and prevents proper shutdown */
     CGU_AUDIO = (2 << 0) | (1 << 11);
     CGU_PLLBSUP = (1 << 2) | (1 << 3);
-
+#endif
     /* write wakeup register */
     alarm.seconds = seconds;
     alarm.enabled = true;
diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h
index acf1344..bcdb1a7 100644
--- a/firmware/export/as3514.h
+++ b/firmware/export/as3514.h
@@ -131,9 +131,14 @@ extern void audiohw_set_sampr_dividers(int fsel);
 /* Headphone volume goes from -81.0 ... +6dB */
 #define VOLUME_MIN -810
 #else
+#ifdef SAMSUNG_YPR0
+/* Headphone volume goes from -40.5 ... +6dB */
+#define VOLUME_MIN -405
+#else
 /* Headphone volume goes from -73.5 ... +6dB */
 #define VOLUME_MIN -735
 #endif
+#endif
 #define VOLUME_MAX   60
 
 /*** Audio Registers ***/
diff --git a/firmware/export/ascodec.h b/firmware/export/ascodec.h
index 93cd767..658153e 100644
--- a/firmware/export/ascodec.h
+++ b/firmware/export/ascodec.h
@@ -28,4 +28,8 @@
 #include "ascodec-target.h"
 #endif
 
+#ifdef SAMSUNG_YPR0
+#include "ascodec-target.h"
+#endif
+
 #endif
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 102d107..304c5aa 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -79,7 +79,7 @@
 #elif defined(HAVE_DUMMY_CODEC)
 #include "dummy_codec.h"
 #endif
-#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
+#if (CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO|PLATFORM_PANDORA|PLATFORM_SDL))
 /* #include <SDL_audio.h> gives errors in other code areas,
  * we don't really need it here, so don't. but it should maybe be fixed */
 #ifndef SIMULATOR /* simulator gets values from the target .h files */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 039b48a..542587f 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -143,6 +143,7 @@
 #define HM60X_PAD          50
 #define HM801_PAD          51
 #define SANSA_CONNECT_PAD  52
+#define SAMSUNG_YPR0_PAD   53
 
 /* CONFIG_REMOTE_KEYPAD */
 #define H100_REMOTE   1
@@ -232,6 +233,7 @@
 #define LCD_HX8340B   44 /* as used by the HiFiMAN HM-601/HM-602/HM-801 */
 #define LCD_CONNECT   45 /* as used by the Sandisk Sansa Connect */
 #define LCD_GIGABEATS 46
+#define LCD_YPR0      47
 
 /* LCD_PIXELFORMAT */
 #define HORIZONTAL_PACKING 1
@@ -483,6 +485,8 @@ Lyre prototype 1 */
 #include "config/nokian900.h"
 #elif defined(PANDORA)
 #include "config/pandora.h"
+#elif defined(SAMSUNG_YPR0)
+#include "config/ypr0.h"
 #else
 /* no known platform */
 #endif
@@ -580,6 +584,10 @@ Lyre prototype 1 */
 #define CONFIG_BACKLIGHT_FADING BACKLIGHT_NO_FADING
 #endif
 
+#ifndef CONFIG_I2C
+#define CONFIG_I2C I2C_NONE
+#endif
+
 #ifndef CONFIG_TUNER
 #define CONFIG_TUNER 0
 #endif
@@ -600,6 +608,14 @@ Lyre prototype 1 */
 #define CONFIG_RTC 0
 #endif
 
+#ifndef BATTERY_TYPES_COUNT
+#define BATTERY_TYPES_COUNT 0
+#endif
+
+#ifndef BATTERY_CAPACITY_INC
+#define BATTERY_CAPACITY_INC 0
+#endif
+
 #ifndef CONFIG_ORIENTATION
 #if LCD_HEIGHT > LCD_WIDTH
 #define CONFIG_ORIENTATION SCREEN_PORTRAIT
diff --git a/firmware/export/config/ypr0.h b/firmware/export/config/ypr0.h
new file mode 100644
index 0000000..25e1906
--- /dev/null
+++ b/firmware/export/config/ypr0.h
@@ -0,0 +1,168 @@
+/*
+ * This config file is for the RockBox as application on the Samsung YP-R0 player.
+ * The target name for ifdefs is: SAMSUNG_YPR0; or CONFIG_PLATFORM & PLAFTORM_YPR0
+ */
+
+#define TARGET_TREE /* this target is using the target tree system */
+
+/* We don't run on hardware directly */
+/* YP-R0 need it too of course */
+#define CONFIG_PLATFORM (PLATFORM_HOSTED)
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 100
+
+#define MODEL_NAME   "Samsung YP-R0"
+
+/* Indeed to check that */
+/*TODO: R0 should charge battery automatically, no software stuff to manage that. Just to know about some as3543 registers, that should be set after loading samsung's afe.ko module 
+ */
+/*TODO: implement USB data transfer management -> see safe mode script and think a way to implemtent it in the code */
+#define USB_NONE
+
+/* Hardware controlled charging with monitoring */
+//#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* There is only USB charging */
+//#define HAVE_USB_POWER
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP
+
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR
+
+/* define this if the LCD needs to be shutdown */
+/* TODO: Our framebuffer must be closed... */
+#define HAVE_LCD_SHUTDOWN
+
+/* define this if you want album art for this target */
+#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 you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you have access to the pitchscreen */
+#define HAVE_PITCHSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+/* LCD dimensions
+ *
+ * overriden by configure for application builds */
+#ifndef LCD_WIDTH
+#define LCD_WIDTH  240
+#endif
+
+#ifndef LCD_HEIGHT
+#define LCD_HEIGHT 320
+#endif
+
+#define LCD_DEPTH  16
+/* Check that but should not matter */
+#define LCD_PIXELFORMAT 565
+
+/* YP-R0 has the backlight */
+#define HAVE_BACKLIGHT
+
+/* Define this for LCD backlight brightness available */
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+/* 0 is turned off. 31 is the real maximum for the ASCODEC DCDC but samsung doesn't use any value over 15, so it safer to don't go up too much */
+#define MIN_BRIGHTNESS_SETTING          1
+#define MAX_BRIGHTNESS_SETTING          15
+#define DEFAULT_BRIGHTNESS_SETTING      4
+
+/* Which backlight fading type? */
+/* TODO: ASCODEC has an auto dim feature, so disabling the supply to leds should do the trick. But for now I tested SW fading only */
+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
+
+/* define this if you have RTC RAM available for settings */
+/* TODO: in theory we could use that, ascodec offers us such a ram. we have also a small device, part of the nand of 1 MB size, that Samsung uses to store region code etc and it's almost unused space */
+//#define HAVE_RTC_RAM
+
+/* define this if you have a real-time clock */
+//#define CONFIG_RTC APPLICATION
+#define CONFIG_RTC RTC_AS3514
+#define HAVE_RTC_ALARM
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0x80000
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0x100000
+
+/* We can do AB-repeat -> we use User key, our hotkey */
+#define AB_REPEAT_ENABLE
+#define ACTION_WPSAB_SINGLE ACTION_WPS_HOTKEY
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+/* R0 KeyPad configuration for plugins */
+#define CONFIG_KEYPAD SAMSUNG_YPR0_PAD
+/* It's better to close /dev/r0Btn at shutdown */
+#define BUTTON_DRIVER_CLOSE
+
+/* The YPR0 has a as3534 codec and we use that to control the volume */
+#define HAVE_AS3514
+#define HAVE_AS3543
+
+#define HAVE_SW_TONE_CONTROLS
+
+/* TODO: Make use of the si4703 tuner hardware */
+/* #define CONFIG_TUNER SI4700 */
+/* #define HAVE_TUNER_PWR_CTRL*/
+
+/*TODO: In R0 there is an interrupt for this (figure out ioctls)*/
+/* #define HAVE_HEADPHONE_DETECTION */
+
+/* Define current usage levels. */
+/* TODO: to be filled with correct values after implementing power management */
+#define CURRENT_NORMAL     88 /* 18 hours from a 1600 mAh battery */
+#define CURRENT_BACKLIGHT  30 /* TBD */
+#define CURRENT_RECORD     0  /* no recording yet */
+
+/* TODO: We need to do battery handling */
+//#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
+//#define BATTERY_CAPACITY_MIN 600  /* min. capacity selectable */
+//#define BATTERY_CAPACITY_MAX 700 /* max. capacity selectable */
+//#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+//#define BATTERY_TYPES_COUNT  1    /* only one type */
+
+/* TODO: We possibly can only watch linux charging */
+//#define CONFIG_CHARGING CHARGING_TARGET
+//#define HAVE_RESET_BATTERY_FILTER
+
+/* same dimensions as gigabeats */
+#define CONFIG_LCD LCD_YPR0
+
+/* Define this if a programmable hotkey is mapped */
+#define HAVE_HOTKEY
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* Define this if you have adjustable CPU frequency
+ * NOTE: We could do that on this device, but it's probably better
+ * to let linux do it (we set ondemand governor before loading Rockbox) */
+/* #define HAVE_ADJUSTABLE_CPU_FREQ */
+/* Define this to the CPU frequency */
+#define CPU_FREQ            532000000
+/* 0.8Vcore using 200 MHz */
+/* #define CPUFREQ_DEFAULT     200000000 */
+/* This is 400 MHz -> not so powersaving-ful */
+/* #define CPUFREQ_NORMAL      400000000 */
+/* Max IMX37 Cpu Frequency */
+/* #define CPUFREQ_MAX         CPU_FREQ */
+
+/* TODO: my idea is to create a folder in the cramfs [/.rockbox], mounting it by the starter script as the current working directory, so no issues of any type keeping the rockbox folder as in all other players */
+#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
index 74d26f9..8f554c2 100644
--- a/firmware/export/rbpaths.h
+++ b/firmware/export/rbpaths.h
@@ -44,7 +44,7 @@
 #define ROCKBOX_DIR_LEN (sizeof(ROCKBOX_DIR)-1)
 #endif /* def __PCTOOL__ */
 
-#ifndef APPLICATION
+#if !defined(APPLICATION) || defined(SAMSUNG_YPR0)
 
 /* make sure both are the same for native builds */
 #undef ROCKBOX_LIBRARY_PATH
@@ -57,6 +57,7 @@
 #define PLAYLIST_CATALOG_DEFAULT_DIR "/Playlists"
 
 #define paths_init()
+
 #else /* application */
 
 #define PLUGIN_DIR          ROCKBOX_LIBRARY_PATH "/rockbox/rocks"
@@ -80,7 +81,7 @@ extern void paths_init(void);
 #define PLUGIN_DEMOS_DIR    PLUGIN_DIR "/demos"
 #define VIEWERS_DIR         PLUGIN_DIR "/viewers"
 
-#ifdef APPLICATION
+#if defined(APPLICATION) && !defined(SAMSUNG_YPR0)
 #define PLUGIN_DATA_DIR          "/.rockbox/rocks.data"
 #define PLUGIN_GAMES_DATA_DIR    PLUGIN_DATA_DIR
 #define PLUGIN_APPS_DATA_DIR     PLUGIN_DATA_DIR
diff --git a/firmware/include/dir_uncached.h b/firmware/include/dir_uncached.h
index d9a29fb..e0fea13 100644
--- a/firmware/include/dir_uncached.h
+++ b/firmware/include/dir_uncached.h
@@ -74,7 +74,7 @@ typedef struct {
 
 
 #if defined(APPLICATION)
-#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
+#if (CONFIG_PLATFORM & PLATFORM_ANDROID) || defined(SAMSUNG_YPR0)
 #include "dir-target.h"
 #endif
 # undef opendir_uncached
diff --git a/firmware/pcm_mixer.c b/firmware/pcm_mixer.c
index 25c41c2..3194f76 100644
--- a/firmware/pcm_mixer.c
+++ b/firmware/pcm_mixer.c
@@ -70,6 +70,11 @@ static struct mixer_channel * active_channels[PCM_MIXER_NUM_CHANNELS+1] IBSS_ATT
 #define MAX_IDLE_FRAMES     (NATIVE_FREQUENCY*3 / MIX_FRAME_SAMPLES)
 static unsigned int idle_counter = 0;
 
+/* Cheapo buffer align macro to align to the 16-16 PCM size */
+#define ALIGN_CHANNEL(start, size) \
+    ({ start = (void *)(((uintptr_t)start + 3) & ~3); \
+       size &= ~3; })
+
 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
 
 /* Include any implemented CPU-optimized mixdown routines */
diff --git a/firmware/sound.c b/firmware/sound.c
index c97ccc2..99db789 100644
--- a/firmware/sound.c
+++ b/firmware/sound.c
@@ -235,7 +235,8 @@ static void set_prescaled_volume(void)
     dsp_callback(DSP_CALLBACK_SET_SW_VOLUME, 0);
 #endif
 
-#ifndef HAVE_SDL_AUDIO
+/* ypr0 with sdl has separate volume controls */
+#if !defined(HAVE_SDL_AUDIO) || defined(SAMSUNG_YPR0)
 #if CONFIG_CODEC == MAS3507D
     dac_volume(tenthdb2reg(l), tenthdb2reg(r), false);
 #elif defined(HAVE_UDA1380) || defined(HAVE_WM8975) || defined(HAVE_WM8758) \
@@ -670,7 +671,7 @@ void sound_set(int setting, int value)
   && !defined (HAVE_WM8711) && !defined (HAVE_WM8721) \
   && !defined (HAVE_WM8731) && !defined (HAVE_WM8978) \
   && !defined (HAVE_WM8750) && !defined (HAVE_WM8751) \
-  && !defined(HAVE_AK4537)) || (CONFIG_PLATFORM & PLATFORM_HOSTED)
+  && !defined(HAVE_AK4537)) || defined(SIMULATOR)
 int sound_val2phys(int setting, int value)
 {
 #if CONFIG_CODEC == MAS3587F
diff --git a/firmware/system.c b/firmware/system.c
index 7e269ee..111a94f 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -26,7 +26,7 @@
 #include "string.h"
 #include "file.h"
 
-#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
 long cpu_frequency SHAREDBSS_ATTR = CPU_FREQ;
 #endif
 
diff --git a/firmware/target/hosted/pcm-alsa.c b/firmware/target/hosted/pcm-alsa.c
new file mode 100644
index 0000000..9281879
--- /dev/null
+++ b/firmware/target/hosted/pcm-alsa.c
@@ -0,0 +1,518 @@
+/***************************************************************************
+ *             __________               __   ___.                  
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___  
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /  
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <   
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \  
+ *                     \/            \/     \/    \/            \/ 
+ * $Id$
+ *
+ * Copyright (C) 2010 Thomas Martitz
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+
+/*
+ * Based, but heavily modified, on the example given at
+ * http://www.alsa-project.org/alsa-doc/alsa-lib/_2test_2pcm_8c-example.html
+ *
+ * This driver uses the so-called unsafe async callback method and hardcoded device
+ * names. It fails when the audio device is busy by other apps.
+ *
+ * TODO: Rewrite this to do it properly with multithreading
+ *
+ * Alternatively, a version using polling in a tick task is provided. While
+ * supposedly safer, it appears to use more CPU (however I didn't measure it
+ * accurately, only looked at htop). At least, in this mode the "default"
+ * device works which doesnt break with other apps running.
+ * device works which doesnt break with other apps running.
+ */
+
+
+#include "autoconf.h"
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <alsa/asoundlib.h>
+#include "system.h"
+#include "debug.h"
+#include "kernel.h"
+
+#include "pcm.h"
+#include "pcm-internal.h"
+#include "pcm_mixer.h"
+#include "pcm_sampr.h"
+
+#include <pthread.h>
+#include <signal.h>
+
+#define USE_ASYNC_CALLBACK
+/* plughw:0,0 works with both, however "default" is recommended.
+ * default doesnt seem to work with async callback but doesn't break
+ * with multple applications running */
+static char device[] = "plughw:0,0";                    /* playback device */
+static const snd_pcm_access_t access_ = SND_PCM_ACCESS_RW_INTERLEAVED; /* access mode */
+static const snd_pcm_format_t format = SND_PCM_FORMAT_S16;    /* sample format */
+static const int channels = 2;                                /* count of channels */
+static unsigned int rate = 44100;                       /* stream rate */
+
+static snd_pcm_t *handle;
+static snd_pcm_sframes_t buffer_size = MIX_FRAME_SAMPLES * 32; /* ~16k */
+static snd_pcm_sframes_t period_size = MIX_FRAME_SAMPLES * 4;  /*  ~4k */
+static short *frames;
+
+static const char  *pcm_data = 0;
+static size_t       pcm_size = 0;
+
+#ifdef USE_ASYNC_CALLBACK
+static snd_async_handler_t *ahandler;
+static pthread_mutex_t pcm_mtx;
+#else
+static int recursion;
+#endif
+
+static int set_hwparams(snd_pcm_t *handle, unsigned sample_rate)
+{
+    unsigned int rrate;
+    int err;
+    snd_pcm_hw_params_t *params;
+    snd_pcm_hw_params_alloca(&params);
+
+
+    /* choose all parameters */
+    err = snd_pcm_hw_params_any(handle, params);
+    if (err < 0)
+    {
+        printf("Broken configuration for playback: no configurations available: %s\n", snd_strerror(err));
+        return err;
+    }
+    /* set the interleaved read/write format */
+    err = snd_pcm_hw_params_set_access(handle, params, access_);
+    if (err < 0)
+    {
+        printf("Access type not available for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    /* set the sample format */
+    err = snd_pcm_hw_params_set_format(handle, params, format);
+    if (err < 0)
+    {
+        printf("Sample format not available for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    /* set the count of channels */
+    err = snd_pcm_hw_params_set_channels(handle, params, channels);
+    if (err < 0)
+    {
+        printf("Channels count (%i) not available for playbacks: %s\n", channels, snd_strerror(err));
+        return err;
+    }
+    /* set the stream rate */
+    rrate = sample_rate;
+    err = snd_pcm_hw_params_set_rate_near(handle, params, &rrate, 0);
+    if (err < 0)
+    {
+        printf("Rate %iHz not available for playback: %s\n", rate, snd_strerror(err));
+        return err;
+    }
+    if (rrate != sample_rate)
+    {
+        printf("Rate doesn't match (requested %iHz, get %iHz)\n", sample_rate, err);
+        return -EINVAL;
+    }
+
+    /* set the buffer size */
+    err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_size);
+    if (err < 0)
+    {
+        printf("Unable to set buffer size %i for playback: %s\n", buffer_size, snd_strerror(err));
+        return err;
+    }
+
+    /* set the period size */
+    err = snd_pcm_hw_params_set_period_size_near (handle, params, &period_size, NULL);
+    if (err < 0)
+    {
+        printf("Unable to set period size %i for playback: %s\n", period_size, snd_strerror(err));
+        return err;
+    }
+    if (!frames)
+        frames = malloc(period_size * channels * sizeof(short));
+
+    /* write the parameters to device */
+    err = snd_pcm_hw_params(handle, params);
+    if (err < 0)
+    {
+        printf("Unable to set hw params for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    return 0;
+}
+
+/* Set sw params: playback start threshold and low buffer watermark */
+static int set_swparams(snd_pcm_t *handle)
+{
+    int err;
+
+    snd_pcm_sw_params_t *swparams;
+    snd_pcm_sw_params_alloca(&swparams);
+
+    /* get the current swparams */
+    err = snd_pcm_sw_params_current(handle, swparams);
+    if (err < 0)
+    {
+        printf("Unable to determine current swparams for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    /* start the transfer when the buffer is haalmost full */
+    err = snd_pcm_sw_params_set_start_threshold(handle, swparams, buffer_size / 2);
+    if (err < 0)
+    {
+        printf("Unable to set start threshold mode for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    /* allow the transfer when at least period_size samples can be processed */
+    err = snd_pcm_sw_params_set_avail_min(handle, swparams, period_size);
+    if (err < 0)
+    {
+        printf("Unable to set avail min for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    /* write the parameters to the playback device */
+    err = snd_pcm_sw_params(handle, swparams);
+    if (err < 0)
+    {
+        printf("Unable to set sw params for playback: %s\n", snd_strerror(err));
+        return err;
+    }
+    return 0;
+}
+
+/* copy pcm samples to a spare buffer, suitable for snd_pcm_writei() */
+static bool fill_frames(void)
+{
+    ssize_t copy_n, frames_left = period_size;
+    bool new_buffer = false;
+
+    while (frames_left > 0)
+    {
+        if (!pcm_size)
+        {
+            new_buffer = true;
+            pcm_play_get_more_callback((void **)&pcm_data, &pcm_size);
+            if (!pcm_size || !pcm_data)
+                return false;
+        }
+        copy_n = MIN((ssize_t)pcm_size, frames_left*4);
+        memcpy(&frames[2*(period_size-frames_left)], pcm_data, copy_n);
+
+        pcm_data += copy_n;
+        pcm_size -= copy_n;
+        frames_left -= copy_n/4;
+
+        if (new_buffer)
+        {
+            new_buffer = false;
+            pcm_play_dma_started_callback();
+        }
+    }
+    return true;
+}
+
+#ifdef USE_ASYNC_CALLBACK
+static void async_callback(snd_async_handler_t *ahandler)
+{
+    snd_pcm_t *handle = snd_async_handler_get_pcm(ahandler);
+
+    if (pthread_mutex_trylock(&pcm_mtx) != 0)
+        return;
+#else
+static void pcm_tick(void)
+{
+    if (snd_pcm_state(handle) != SND_PCM_STATE_RUNNING)
+        return;
+#endif
+
+    while (snd_pcm_avail_update(handle) >= period_size)
+    {
+        if (fill_frames())
+        {
+            int err = snd_pcm_writei(handle, frames, period_size);
+            if (err < 0 && err != period_size && err != -EAGAIN)
+            {
+                printf("Write error: written %i expected %li\n", err, period_size);
+                break;
+            }
+        }
+        else
+        {
+            DEBUGF("%s: No Data.\n", __func__);
+            break;
+        }
+    }
+#ifdef USE_ASYNC_CALLBACK
+    pthread_mutex_unlock(&pcm_mtx);
+#endif
+}
+
+static int async_rw(snd_pcm_t *handle)
+{
+    int err;
+    snd_pcm_sframes_t sample_size;
+    short *samples;
+
+#ifdef USE_ASYNC_CALLBACK
+    err = snd_async_add_pcm_handler(&ahandler, handle, async_callback, NULL);
+    if (err < 0)
+    {
+        DEBUGF("Unable to register async handler: %s\n", snd_strerror(err));
+        return err;
+    }
+#endif
+
+    /* fill buffer with silence to initiate playback without noisy click */
+    sample_size = buffer_size;
+    samples = malloc(sample_size * channels * sizeof(short));
+
+    snd_pcm_format_set_silence(format, samples, sample_size);
+    err = snd_pcm_writei(handle, samples, sample_size);
+    free(samples);
+
+    if (err < 0)
+    {
+            DEBUGF("Initial write error: %s\n", snd_strerror(err));
+            return err;
+    }
+    if (err != (ssize_t)sample_size)
+    {
+            DEBUGF("Initial write error: written %i expected %li\n", err, sample_size);
+            return err;
+    }
+    if (snd_pcm_state(handle) == SND_PCM_STATE_PREPARED)
+    {
+            err = snd_pcm_start(handle);
+            if (err < 0)
+            {
+                DEBUGF("Start error: %s\n", snd_strerror(err));
+                return err;
+            }
+    }
+    return 0;
+}
+
+
+void cleanup(void)
+{
+    free(frames);
+    frames = NULL;
+    snd_pcm_close(handle);
+}
+
+
+void pcm_play_dma_init(void)
+{
+    int err;
+
+
+    if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
+    {
+        printf("%s(): Cannot open device %s: %s\n", __func__, device, snd_strerror(err));
+        exit(EXIT_FAILURE);
+        return;
+    }
+
+    if ((err = snd_pcm_nonblock(handle, 1)))
+        printf("Could not set non-block mode: %s\n", snd_strerror(err));
+
+    if ((err = set_hwparams(handle, rate)) < 0)
+    {
+        printf("Setting of hwparams failed: %s\n", snd_strerror(err));
+        exit(EXIT_FAILURE);
+    }
+    if ((err = set_swparams(handle)) < 0)
+    {
+        printf("Setting of swparams failed: %s\n", snd_strerror(err));
+        exit(EXIT_FAILURE);
+    }
+
+#ifdef USE_ASYNC_CALLBACK
+    pthread_mutexattr_t attr;
+    pthread_mutexattr_init(&attr);
+    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+    pthread_mutex_init(&pcm_mtx, &attr);
+#else
+    tick_add_task(pcm_tick);
+#endif
+
+
+    atexit(cleanup);
+    return;
+}
+
+
+void pcm_play_lock(void)
+{
+#ifdef USE_ASYNC_CALLBACK
+    pthread_mutex_lock(&pcm_mtx);
+#else
+    if (recursion++ == 0)
+        tick_remove_task(pcm_tick);
+#endif
+}
+
+void pcm_play_unlock(void)
+{
+#ifdef USE_ASYNC_CALLBACK
+    pthread_mutex_unlock(&pcm_mtx);
+#else
+    if (--recursion == 0)
+        tick_add_task(pcm_tick);
+#endif
+}
+
+static void pcm_dma_apply_settings_nolock(void)
+{
+    snd_pcm_drop(handle);
+    set_hwparams(handle, pcm_sampr);
+}
+
+void pcm_dma_apply_settings(void)
+{
+    pcm_play_lock();
+    pcm_dma_apply_settings_nolock();
+    pcm_play_unlock();
+}
+
+
+void pcm_play_dma_pause(bool pause)
+{
+    snd_pcm_pause(handle, pause);
+}
+
+
+void pcm_play_dma_stop(void)
+{
+    snd_pcm_drain(handle);
+}
+
+void pcm_play_dma_start(const void *addr, size_t size)
+{
+    pcm_dma_apply_settings_nolock();
+
+    pcm_data = addr;
+    pcm_size = size;
+
+    while (1)
+    {
+        snd_pcm_state_t state = snd_pcm_state(handle);
+        switch (state)
+        {
+            case SND_PCM_STATE_RUNNING:
+                return;
+            case SND_PCM_STATE_XRUN:
+            {
+                DEBUGF("Trying to recover from error\n");
+                int err = snd_pcm_recover(handle, -EPIPE, 0);
+                if (err < 0)
+                    DEBUGF("Recovery failed: %s\n", snd_strerror(err));
+                continue;
+            }
+            case SND_PCM_STATE_SETUP:
+            {
+                int err = snd_pcm_prepare(handle);
+                if (err < 0)
+                    printf("Prepare error: %s\n", snd_strerror(err));
+                /* fall through */
+            }
+            case SND_PCM_STATE_PREPARED:
+            {   /* prepared state, we need to fill the buffer with silence before
+                 * starting */
+                int err = async_rw(handle);
+                if (err < 0)
+                    printf("Start error: %s\n", snd_strerror(err));
+                return;
+            }
+            case SND_PCM_STATE_PAUSED:
+            {   /* paused, simply resume */
+                pcm_play_dma_pause(0);
+                return;
+            }
+            case SND_PCM_STATE_DRAINING:
+                /* run until drained */
+                continue;
+            default:
+                DEBUGF("Unhandled state: %s\n", snd_pcm_state_name(state));
+                return;
+        }
+    }
+}
+
+size_t pcm_get_bytes_waiting(void)
+{
+    return pcm_size;
+}
+
+const void * pcm_play_dma_get_peak_buffer(int *count)
+{
+    uintptr_t addr = (uintptr_t)pcm_data;
+    *count = pcm_size / 4;
+    return (void *)((addr + 3) & ~3);
+}
+
+void pcm_play_dma_postinit(void)
+{
+}
+
+
+void pcm_set_mixer_volume(int volume)
+{
+    (void)volume;
+}
+#ifdef HAVE_RECORDING
+void pcm_rec_lock(void)
+{
+}
+
+void pcm_rec_unlock(void)
+{
+}
+
+void pcm_rec_dma_init(void)
+{
+}
+
+void pcm_rec_dma_close(void)
+{
+}
+
+void pcm_rec_dma_start(void *start, size_t size)
+{
+    (void)start;
+    (void)size;
+}
+
+void pcm_rec_dma_stop(void)
+{
+}
+
+const void * pcm_rec_dma_get_peak_buffer(void)
+{
+    return NULL;
+}
+
+void audiohw_set_recvol(int left, int right, int type)
+{
+    (void)left;
+    (void)right;
+    (void)type;
+}
+
+#endif /* HAVE_RECORDING */
diff --git a/firmware/target/hosted/ypr0/adc-target.h b/firmware/target/hosted/ypr0/adc-target.h
new file mode 100644
index 0000000..bdbc4cf
--- /dev/null
+++ b/firmware/target/hosted/ypr0/adc-target.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: adc-target.h 29516 2011-03-05 15:31:52Z thomasjfox $
+ *
+ * Copyright (C) 2011 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 __ADC_TARGET_H__
+#define __ADC_TARGET_H__
+
+#endif /* __ADC_TARGET_H__ */
diff --git a/firmware/target/hosted/ypr0/ascodec-target.h b/firmware/target/hosted/ypr0/ascodec-target.h
new file mode 100644
index 0000000..f4ecf20
--- /dev/null
+++ b/firmware/target/hosted/ypr0/ascodec-target.h
@@ -0,0 +1,92 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
+ *
+ * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
+ *
+ * Copyright (c) 2011 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 _ASCODEC_TARGET_H
+#define _ASCODEC_TARGET_H
+
+#include "as3514.h"
+#include "kernel.h"
+#include "adc.h"
+#include "ascodec.h"
+
+/* ioctl parameter struct */
+
+struct codec_req_struct {
+/* This works for every kind of afe.ko module requests */
+            unsigned char reg; /* Main register address */
+            unsigned char subreg; /* Set this only if you are reading/writing a PMU register*/
+            unsigned char value; /* To be read if reading a register; to be set if writing to a register */
+};
+
+int ascodec_init(void);
+void ascodec_close(void);
+int ascodec_write(unsigned int reg, unsigned int value);
+int ascodec_read(unsigned int reg);
+void ascodec_write_pmu(unsigned int index, unsigned int subreg, unsigned int value);
+int ascodec_read_pmu(unsigned int index, unsigned int subreg);
+void ascodec_set(unsigned int reg, unsigned int bits);
+void ascodec_clear(unsigned int reg, unsigned int bits);
+void ascodec_write_masked(unsigned int reg, unsigned int bits, unsigned int mask);
+int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data);
+unsigned short adc_read(int channel);
+void ascodec_lock(void);
+void ascodec_unlock(void);
+
+static inline bool ascodec_chg_status(void)
+{
+    return ascodec_read(AS3514_IRQ_ENRD0) & CHG_STATUS;
+}
+
+static inline bool ascodec_endofch(void)
+{
+    return ascodec_read(AS3514_IRQ_ENRD0) & CHG_ENDOFCH;
+}
+
+static inline void ascodec_monitor_endofch(void)
+{
+    ascodec_write(AS3514_IRQ_ENRD0, IRQ_ENDOFCH);
+}
+
+static inline void ascodec_wait_adc_finished(void)
+{
+    /*
+     * FIXME: not implemented
+     *
+     * If irqs are not available on the target platform,
+     * this should be most likely implemented by polling
+     * AS3514_IRQ_ENRD2 in the same way powermgmt-ascodec.c
+     * is polling IRQ_ENDOFCH.
+     */
+}
+
+static inline void ascodec_write_charger(int value)
+{
+    ascodec_write_pmu(AS3543_CHARGER, 1, value);
+}
+
+static inline int ascodec_read_charger(void)
+{
+    return ascodec_read_pmu(AS3543_CHARGER, 1);
+}
+
+#endif /* !_ASCODEC_TARGET_H */
diff --git a/firmware/target/hosted/ypr0/ascodec-ypr0.c b/firmware/target/hosted/ypr0/ascodec-ypr0.c
new file mode 100644
index 0000000..a4e92e6
--- /dev/null
+++ b/firmware/target/hosted/ypr0/ascodec-ypr0.c
@@ -0,0 +1,206 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: ascodec-target.h 26116 2010-05-17 20:53:25Z funman $
+ *
+ * Module wrapper for AS3543 audio codec, using /dev/afe (afe.ko) of Samsung YP-R0
+ *
+ * Copyright (c) 2011 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 "fcntl.h"
+#include "unistd.h"
+#include "stdio.h"
+#include "string.h"
+#include "sys/ioctl.h"
+#include "stdlib.h"
+
+#include "ascodec-target.h"
+
+int afe_dev = -1;
+
+/* Write to a normal register */
+#define IOCTL_REG_WRITE 0x40034101
+/* Write to a PMU register */
+#define IOCTL_SUBREG_WRITE 0x40034103
+/* Read from a normal register */
+#define IOCTL_REG_READ 0x80034102
+/* Read from a PMU register */
+#define IOCTL_SUBREG_READ 0x80034103
+
+static struct mutex as_mtx;
+
+int ascodec_init(void) {
+
+    afe_dev = open("/dev/afe", O_RDWR);
+
+    mutex_init(&as_mtx);
+
+    return afe_dev;
+
+}
+
+void ascodec_close(void) {
+
+    if (afe_dev >= 0) {
+        close(afe_dev);
+    }
+
+}
+
+/* Read functions returns -1 if fail, otherwise the register's value if success */
+/* Write functions return >= 0 if success, otherwise -1 if fail */
+
+int ascodec_write(unsigned int reg, unsigned int value)
+{
+    struct codec_req_struct y;
+    struct codec_req_struct *p;
+    p = &y;
+    p->reg = reg;
+    p->value = value;
+    return ioctl(afe_dev, IOCTL_REG_WRITE, p);
+}
+
+int ascodec_read(unsigned int reg)
+{
+    int retval = -1;
+    struct codec_req_struct y;
+    struct codec_req_struct *p;
+    p = &y;
+    p->reg = reg;
+    retval = ioctl(afe_dev, IOCTL_REG_READ, p);
+    if (retval >= 0)
+        return p->value;
+    else
+        return retval;
+}
+
+void ascodec_write_pmu(unsigned int index, unsigned int subreg,
+                                     unsigned int value)
+{
+    struct codec_req_struct y;
+    struct codec_req_struct *p;
+    p = &y;
+    p->reg = index;
+    p->subreg = subreg;
+    p->value = value;
+    ioctl(afe_dev, IOCTL_SUBREG_WRITE, p);
+}
+
+int ascodec_read_pmu(unsigned int index, unsigned int subreg)
+{
+    int retval = -1;
+    struct codec_req_struct y;
+    struct codec_req_struct *p;
+    p = &y;
+    p->reg = index;
+    p->subreg = subreg;
+    retval = ioctl(afe_dev, IOCTL_SUBREG_READ, p);
+    if (retval >= 0)
+        return p->value;
+    else
+        return retval;
+}
+
+/* Helpers to set/clear bits */
+void ascodec_set(unsigned int reg, unsigned int bits)
+{
+    ascodec_write(reg, ascodec_read(reg) | bits);
+}
+
+void ascodec_clear(unsigned int reg, unsigned int bits)
+{
+    ascodec_write(reg, ascodec_read(reg) & ~bits);
+}
+
+void ascodec_write_masked(unsigned int reg, unsigned int bits,
+                                unsigned int mask)
+{
+    ascodec_write(reg, (ascodec_read(reg) & ~mask) | (bits & mask));
+}
+
+/*FIXME: doesn't work */
+int ascodec_readbytes(unsigned int index, unsigned int len, unsigned char *data)
+{
+    unsigned int i;
+
+    for (i=index; i<len; i++) {
+        data[i] = ascodec_read(i);
+        printf("Register %i: value=%i\n",index,data[i]);
+    }
+
+    printf("TOTAL: %i\n", i);
+
+    return i;
+}
+
+/*
+ * NOTE:
+ * After the conversion to interrupts, ascodec_(lock|unlock) are only used by
+ * adc-as3514.c to protect against other threads corrupting the result by using
+ * the ADC at the same time.
+ * 
+ * Concurrent ascodec_(async_)?(read|write) calls are instead protected
+ * by the R0's Kernel I2C driver for ascodec (mutexed), so it's automatically safe
+ */
+
+void ascodec_lock(void)
+{
+    mutex_lock(&as_mtx);
+}
+
+void ascodec_unlock(void)
+{
+    mutex_unlock(&as_mtx);
+}
+
+/* Read 10-bit channel data */
+unsigned short adc_read(int channel)
+{
+    unsigned short data = 0;
+
+    if ((unsigned)channel >= NUM_ADC_CHANNELS)
+        return 0;
+
+    ascodec_lock();
+
+    /* Select channel */
+    ascodec_write(AS3514_ADC_0, (channel << 4));
+    unsigned char buf[2];
+
+        /*
+         * The AS3514 ADC will trigger an interrupt when the conversion
+         * is finished, if the corresponding enable bit in IRQ_ENRD2
+         * is set.
+         * Previously the code did not wait and this apparently did
+         * not pose any problems, but this should be more correct.
+         * Without the wait the data read back may be completely or
+         * partially (first one of the two bytes) stale.
+         */
+    /*FIXME: not implemented*/
+    ascodec_wait_adc_finished();
+
+        /* Read data */
+    ascodec_readbytes(AS3514_ADC_0, 2, buf);
+    data = (((buf[0] & 0x3) << 8) | buf[1]);
+
+    ascodec_unlock();
+    return data;
+}
+
+void adc_init(void)
+{
+}
diff --git a/firmware/target/hosted/ypr0/backlight-target.h b/firmware/target/hosted/ypr0/backlight-target.h
new file mode 100644
index 0000000..561e159
--- /dev/null
+++ b/firmware/target/hosted/ypr0/backlight-target.h
@@ -0,0 +1,29 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: backlight-target.h 19322 2008-12-04 04:16:53Z jethead71 $
+ *
+ * Copyright (C) 2011 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/hosted/ypr0/backlight-ypr0.c b/firmware/target/hosted/ypr0/backlight-ypr0.c
new file mode 100644
index 0000000..930b56b
--- /dev/null
+++ b/firmware/target/hosted/ypr0/backlight-ypr0.c
@@ -0,0 +1,89 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: backlight-gigabeat-s.c 25800 2010-05-04 10:07:53Z jethead71 $
+ *
+ * Copyright (C) 2011 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 "backlight.h"
+#include "backlight-target.h"
+#include "lcd.h"
+#include "as3514.h"
+#include "ascodec-target.h"
+#include <fcntl.h>
+#include "unistd.h"
+
+static bool backlight_on_status = true; /* Is on or off? */
+
+/*TODO: see if LCD sleep could be implemented in a better way -> ie using a rockbox feature */
+/* Turn off LCD power supply */
+static void _backlight_lcd_sleep(void)
+{
+    int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
+    write(fp, "1", 1);
+    close(fp);
+}
+/* Turn on LCD screen */
+static void _backlight_lcd_power(void)
+{
+    int fp = open("/sys/class/graphics/fb0/blank", O_RDWR);
+    write(fp, "0", 1);
+    close(fp);
+}
+
+bool _backlight_init(void)
+{
+    /* We have nothing to do */
+    return true;
+}
+
+void _backlight_on(void)
+{
+    if (!backlight_on_status)
+    {
+        /* Turn on lcd power before backlight */
+        _backlight_lcd_power();
+        /* Original app sets this to 0xb1 when backlight is on... */
+        ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0xb1);
+    }
+
+    backlight_on_status = true;
+
+}
+
+void _backlight_off(void)
+{
+    if (backlight_on_status) {
+        /* Disabling the DCDC15 completely, keeps brightness register value */
+        ascodec_write_pmu(AS3543_BACKLIGHT, 0x1, 0x00);
+        /* Turn off lcd power then */
+        _backlight_lcd_sleep();
+    }
+
+    backlight_on_status = false;
+}
+
+void _backlight_set_brightness(int brightness)
+{
+    /* Just another check... */
+    if (brightness > MAX_BRIGHTNESS_SETTING)
+        brightness = MAX_BRIGHTNESS_SETTING;
+    if (brightness < MIN_BRIGHTNESS_SETTING)
+        brightness = MIN_BRIGHTNESS_SETTING;
+    ascodec_write_pmu(AS3543_BACKLIGHT, 0x3, brightness << 3 & 0xf8);
+}
diff --git a/firmware/target/hosted/ypr0/button-target.h b/firmware/target/hosted/ypr0/button-target.h
new file mode 100644
index 0000000..5d65d97
--- /dev/null
+++ b/firmware/target/hosted/ypr0/button-target.h
@@ -0,0 +1,53 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: button-target.h 29248 2011-02-08 20:05:25Z thomasjfox $
+ *
+ * Copyright (C) 2011 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>
+#include "config.h"
+
+void button_init_device(void);
+void button_close_device(void);
+int button_read_device(void);
+
+/* Logical buttons key codes */
+#define BUTTON_UP           0x00000001
+#define BUTTON_DOWN         0x00000002
+#define BUTTON_LEFT         0x00000004
+#define BUTTON_RIGHT        0x00000008
+#define BUTTON_USER         0x00000010
+#define BUTTON_MENU         0x00000020
+#define BUTTON_BACK         0x00000040
+#define BUTTON_POWER        0x00000080
+#define BUTTON_SELECT       0x00000100
+
+#define BUTTON_MAIN         0x1FF /* all buttons */
+
+/* No remote */
+#define BUTTON_REMOTE 0
+
+/* Software power-off */
+#define POWEROFF_BUTTON BUTTON_POWER
+/* About 3 seconds */
+#define POWEROFF_COUNT 10
+
+#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/hosted/ypr0/button-ypr0.c b/firmware/target/hosted/ypr0/button-ypr0.c
new file mode 100644
index 0000000..4298410
--- /dev/null
+++ b/firmware/target/hosted/ypr0/button-ypr0.c
@@ -0,0 +1,103 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: button-sdl.c 30482 2011-09-08 14:53:28Z kugel $
+ *
+ * Copyright (C) 2011 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 <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>         /* EXIT_SUCCESS */
+#include "config.h"
+#include "button.h"
+#include "kernel.h"
+#include "system.h"
+#include "button-target.h"
+
+/* R0 physical key codes */
+enum ypr0_buttons {
+    R0BTN_NONE = BUTTON_NONE,
+    R0BTN_POWER = 1,
+    R0BTN_UP,
+    R0BTN_DOWN,
+    R0BTN_RIGHT,
+    R0BTN_LEFT,
+    R0BTN_CENTRAL,
+    R0BTN_MENU,
+    R0BTN_BACK,
+    R0BTN_3DOTS = 11,
+};
+
+
+static int r0_btn_fd = 0;
+/* Samsung keypad driver doesn't allow multiple key combinations :( */
+static enum ypr0_buttons r0_read_key(void)
+{
+    unsigned char keys;
+
+    if (r0_btn_fd < 0)
+        return 0;
+
+    if (read(r0_btn_fd, &keys, 1))
+        return keys;
+
+    return 0;
+}
+
+/* Conversion from physical keypress code to logic key code */
+static int key_to_button(enum ypr0_buttons keyboard_button)
+{
+    switch (keyboard_button)
+    {
+        default:            return BUTTON_NONE;
+        case R0BTN_POWER:   return BUTTON_POWER;
+        case R0BTN_UP:      return BUTTON_UP;
+        case R0BTN_DOWN:    return BUTTON_DOWN;
+        case R0BTN_RIGHT:   return BUTTON_RIGHT;
+        case R0BTN_LEFT:    return BUTTON_LEFT;
+        case R0BTN_CENTRAL: return BUTTON_SELECT;
+        case R0BTN_MENU:    return BUTTON_MENU;
+        case R0BTN_BACK:    return BUTTON_BACK;
+        case R0BTN_3DOTS:   return BUTTON_USER;
+    }
+}
+
+int button_read_device(void)
+{
+    return key_to_button(r0_read_key());
+}
+
+
+/* Open the keypad device: it is offered by r0Btn.ko module */
+void button_init_device(void)
+{
+    r0_btn_fd = open("/dev/r0Btn", O_RDONLY);
+    if (r0_btn_fd < 0)
+        printf("/dev/r0Btn open error!");
+}
+
+#ifdef BUTTON_DRIVER_CLOSE
+/* I'm not sure it's called at shutdown...give a check! */
+void button_close_device(void)
+{
+    if (r0_btn_fd >= 0) {
+        close(r0_btn_fd);
+        printf("/dev/r0Btn closed!");
+    }
+}
+#endif /* BUTTON_DRIVER_CLOSE */
diff --git a/firmware/target/hosted/ypr0/dir-target.h b/firmware/target/hosted/ypr0/dir-target.h
new file mode 100644
index 0000000..4885952
--- /dev/null
+++ b/firmware/target/hosted/ypr0/dir-target.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 __DIR_TARGET_H__
+#define __DIR_TARGET_H__
+
+#include <dirent.h>
+/* including unistd.h is too noisy */
+extern int rmdir(const char* name);
+
+
+#define dirent_uncached dirent
+#define DIR_UNCACHED DIR
+#define opendir_uncached _opendir
+#define readdir_uncached _readdir
+#define closedir_uncached _closedir
+#define mkdir_uncached _mkdir
+#define rmdir_uncached rmdir
+
+#define dirent_ypr0 dirent
+#define DIR_ypr0 DIR
+#define opendir_ypr0 _opendir
+#define readdir_ypr0 _readdir
+#define closedir_ypr0 _closedir
+#define mkdir_ypr0 _mkdir
+#define rmdir_ypr0 rmdir
+
+extern DIR* _opendir(const char* name);
+extern int  _mkdir(const char* name);
+extern int  _closedir(DIR* dir);
+extern struct dirent *_readdir(DIR* dir);
+extern void fat_size(unsigned long *size, unsigned long *free);
+
+#define DIRFUNCTIONS_DEFINED
+#define DIRENT_DEFINED
+#define DIR_DEFINED
+
+#endif /* __DIR_TARGET_H__ */
diff --git a/firmware/target/hosted/ypr0/fs-ypr0.c b/firmware/target/hosted/ypr0/fs-ypr0.c
new file mode 100644
index 0000000..7f49a5f
--- /dev/null
+++ b/firmware/target/hosted/ypr0/fs-ypr0.c
@@ -0,0 +1,141 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 <stdlib.h>
+#include <sys/stat.h> /* stat() */
+#include <stdio.h>  /* snprintf */
+#include <string.h> /* size_t */
+#include <dirent.h>
+#include <time.h>   /* localtime() */
+#include "system-target.h"
+#include "dir-target.h"
+#include "file.h"
+#include "dir.h"
+#include "rbpaths.h"
+
+
+long filesize(int fd)
+{
+    struct stat buf;
+
+    if (!fstat(fd, &buf))
+        return buf.st_size;
+    else
+        return -1;
+}
+
+/* do we really need this in the app? */
+void fat_size(unsigned long* size, unsigned long* free)
+{
+    *size = *free = 0;
+}
+
+#undef opendir
+#undef closedir
+#undef mkdir
+#undef readdir
+
+/* need to wrap around DIR* because we need to save the parent's
+ * directory path in order to determine dirinfo */
+struct __dir {
+    DIR  *dir;
+    char *path;
+};
+
+DIR* _opendir(const char *name)
+{
+    char *buf = malloc(sizeof(struct __dir) + strlen(name)+1);
+    if (!buf)
+        return NULL;
+
+    struct __dir *this = (struct __dir*)buf;
+
+    this->path = buf+sizeof(struct __dir);
+    /* definitely fits due to strlen() */
+    strcpy(this->path, name);
+
+    this->dir = opendir(name);
+
+    if (!this->dir)
+    {
+        free(buf);
+        return NULL;
+    }
+    return (DIR*)this;
+}
+
+int _mkdir(const char *name)
+{
+    return mkdir(name, 0777);
+}
+
+int _closedir(DIR *dir)
+{
+    struct __dir *this = (struct __dir*)dir;
+    int ret = closedir(this->dir);
+    free(this);
+    return ret;
+}
+
+struct dirent* _readdir(DIR* dir)
+{
+    struct __dir *d = (struct __dir*)dir;
+    return readdir(d->dir);
+}
+
+struct dirinfo dir_get_info(DIR* _parent, struct dirent *dir)
+{
+    struct __dir *parent = (struct __dir*)_parent;
+    struct stat s;
+    struct tm *tm = NULL;
+    struct dirinfo ret;
+    char path[MAX_PATH];
+
+    snprintf(path, sizeof(path), "%s/%s", parent->path, dir->d_name);
+    memset(&ret, 0, sizeof(ret));
+
+    if (!stat(path, &s))
+    {
+        if (S_ISDIR(s.st_mode))
+        {
+            ret.attribute = ATTR_DIRECTORY;
+        }
+        ret.size = s.st_size;
+        tm = localtime(&(s.st_mtime));
+    }
+
+    if (!lstat(path, &s) && S_ISLNK(s.st_mode))
+    {
+        ret.attribute |= ATTR_LINK;
+    }
+
+    if (tm)
+    {
+        ret.wrtdate = ((tm->tm_year - 80) << 9) |
+                            ((tm->tm_mon + 1) << 5) |
+                            tm->tm_mday;
+        ret.wrttime = (tm->tm_hour << 11) |
+                            (tm->tm_min << 5) |
+                            (tm->tm_sec >> 1);
+    }
+
+    return ret;
+}
diff --git a/firmware/target/hosted/ypr0/i2c-target.h b/firmware/target/hosted/ypr0/i2c-target.h
new file mode 100644
index 0000000..3b046bb
--- /dev/null
+++ b/firmware/target/hosted/ypr0/i2c-target.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: i2c-target.h 29516 2011-03-05 15:31:52Z thomasjfox $
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 __I2C_TARGET_H__
+#define __I2C_TARGET_H__
+
+#endif /* __I2C_TARGET_H__ */
diff --git a/firmware/target/hosted/ypr0/kernel-ypr0.c b/firmware/target/hosted/ypr0/kernel-ypr0.c
new file mode 100644
index 0000000..bcf2cee
--- /dev/null
+++ b/firmware/target/hosted/ypr0/kernel-ypr0.c
@@ -0,0 +1,163 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (c) 2010 Thomas Martitz
+ *
+ * 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 <time.h>
+#include <signal.h>
+#include <errno.h>
+#include <unistd.h>
+#include <pthread.h>
+#include "config.h"
+#include "system.h"
+#include "button.h"
+#include "audio.h"
+#include "panic.h"
+#include "timer.h"
+
+
+static pthread_cond_t wfi_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t wfi_mtx = PTHREAD_MUTEX_INITIALIZER;
+/*
+ * call tick tasks and wake the scheduler up */
+void timer_signal(union sigval arg)
+{
+    (void)arg;
+    call_tick_tasks();
+    interrupt();
+}
+
+/*
+ * wait on the sem which the signal handler posts to save cpu time (aka sleep)
+ *
+ * other mechanisms could use them as well */
+void wait_for_interrupt(void)
+{
+    pthread_cond_wait(&wfi_cond, &wfi_mtx);
+}
+
+/*
+ * Wakeup the kernel, if sleeping (shall not be called from a signal handler) */
+void interrupt(void)
+{
+    pthread_cond_signal(&wfi_cond);
+}
+
+
+/*
+ * setup a hrtimer to send a signal to our process every tick
+ */
+union sigval tick_arg = {
+    .sival_int = 0,
+};
+
+void tick_start(unsigned int interval_in_ms)
+{
+    int ret = 0;
+    timer_t timerid;
+    struct itimerspec ts;
+    sigevent_t sigev;
+
+    /* initializing in the declaration causes some weird warnings */
+    memset(&sigev, 0, sizeof(sigevent_t));
+    sigev.sigev_notify = SIGEV_THREAD,
+    sigev.sigev_notify_function = timer_signal;
+
+    ts.it_value.tv_sec = ts.it_interval.tv_sec = 0;
+    ts.it_value.tv_nsec = ts.it_interval.tv_nsec = interval_in_ms*1000*1000;
+
+    /* add the timer */
+    ret |= timer_create(CLOCK_REALTIME, &sigev, &timerid);
+    ret |= timer_settime(timerid, 0, &ts, NULL);
+
+    /* Grab the mutex already now and leave it to this thread. We don't
+     * care about race conditions when signaling the condition (because
+     * they are not critical), but a mutex is necessary due to the API */
+    pthread_mutex_lock(&wfi_mtx);
+
+    if (ret != 0)
+        panicf("%s(): %s\n", __func__, strerror(errno));
+}
+
+#define cycles_to_microseconds(cycles) \
+    ((int)((1000000*cycles)/TIMER_FREQ))
+
+
+static timer_t timer_tid;
+static int timer_prio = -1;
+void (*global_unreg_callback)(void);
+void (*global_timer_callback)(void);
+
+static void timer_cb(union sigval arg)
+{
+    (void)arg;
+    if (global_timer_callback)
+        global_timer_callback();
+}
+
+bool timer_register(int reg_prio, void (*unregister_callback)(void),
+                    long cycles, void (*timer_callback)(void))
+{
+    int ret = 0;
+    struct itimerspec ts;
+    sigevent_t sigev;
+    long in_us = cycles_to_microseconds(cycles);
+
+    if (reg_prio <= timer_prio || in_us <= 0)
+        return false;
+
+    if (timer_prio >= 0 && global_unreg_callback)
+        global_unreg_callback();
+
+    /* initializing in the declaration causes some weird warnings */
+    memset(&sigev, 0, sizeof(sigevent_t));
+    sigev.sigev_notify = SIGEV_THREAD,
+    sigev.sigev_notify_function = timer_cb;
+
+    ts.it_value.tv_sec = ts.it_interval.tv_sec = in_us / 1000000;
+    ts.it_value.tv_nsec = ts.it_interval.tv_nsec = (in_us%1000000)*1000;
+
+    /* add the timer */
+    ret |= timer_create(CLOCK_REALTIME, &sigev, &timer_tid);
+    ret |= timer_settime(timer_tid, 0, &ts, NULL);
+
+    global_timer_callback = timer_callback;
+    global_unreg_callback = unregister_callback;
+    timer_prio = reg_prio;
+
+    return ret == 0;
+}
+
+bool timer_set_period(long cycles)
+{
+    struct itimerspec ts;
+    long in_us = cycles_to_microseconds(cycles);
+    ts.it_value.tv_sec = ts.it_interval.tv_sec = in_us / 1000000;
+    ts.it_value.tv_nsec = ts.it_interval.tv_nsec = (in_us%1000000)*1000;
+
+    return timer_settime(timer_tid, 0, &ts, NULL) == 0;
+}
+
+void timer_unregister(void)
+{
+    timer_delete(timer_tid);
+    timer_prio = -1;
+}
+
diff --git a/firmware/target/hosted/ypr0/lc-ypr0.c b/firmware/target/hosted/ypr0/lc-ypr0.c
new file mode 100644
index 0000000..434e901
--- /dev/null
+++ b/firmware/target/hosted/ypr0/lc-ypr0.c
@@ -0,0 +1,40 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 <string.h> /* size_t */
+#include "load_code.h"
+
+/* the load_code wrappers simply wrap, nothing to do */
+void *lc_open(const char *filename, unsigned char *buf, size_t buf_size)
+{
+    return _lc_open(filename, buf, buf_size);
+}
+
+void *lc_get_header(void *handle)
+{
+    return _lc_get_header(handle);
+}
+
+void lc_close(void *handle)
+{
+    _lc_close(handle);
+}
+
diff --git a/firmware/target/hosted/ypr0/lcd-ypr0.c b/firmware/target/hosted/ypr0/lcd-ypr0.c
new file mode 100644
index 0000000..f0565ae
--- /dev/null
+++ b/firmware/target/hosted/ypr0/lcd-ypr0.c
@@ -0,0 +1,147 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: lcd-bitmap.c 29248 2011-02-08 20:05:25Z thomasjfox $
+ *
+ * Copyright (C) 2011 Lorenzo Miori, Thomas Martitz
+ *
+ * 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 <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "string.h"
+#include <linux/fb.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+
+#include "file.h"
+#include "debug.h"
+#include "system.h"
+#include "screendump.h"
+#include "lcd.h"
+
+/* eqivalent to fb + y*width + x */
+#define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)])
+
+static int dev_fd = 0;
+static fb_data *dev_fb = 0;
+
+void lcd_update(void)
+{
+    /* update the entire display */
+    memcpy(dev_fb, lcd_framebuffer, sizeof(lcd_framebuffer));
+}
+
+/* Copy Rockbox frame buffer to the mmapped lcd device */
+void lcd_update_rect(int x, int y, int width, int height)
+{
+    /* nothing to draw? */
+    if ((width <= 0) || (height <= 0) || (x >= LCD_WIDTH) ||
+            (y >= LCD_HEIGHT) || (x + width <= 0) || (y + height <= 0))
+        return;
+
+    /* do the necessary clipping */
+    if (x < 0)
+    {   /* clip left */
+        width += x;
+        x = 0;
+    }
+    if (y < 0)
+    {   /* clip top */
+        height += y;
+        y = 0;
+    }
+    if (x + width > LCD_WIDTH)
+        width = LCD_WIDTH - x; /* clip right */
+    if (y + height > LCD_HEIGHT)
+        height = LCD_HEIGHT - y; /* clip bottom */
+
+    fb_data* src  = LCDADDR(x, y);
+    fb_data* dst = dev_fb + y*LCD_WIDTH + x;
+
+    if (LCD_WIDTH == width)
+    {   /* optimized full-width update */
+        memcpy(dst, src, width * height * sizeof(fb_data));
+    }
+    else
+    {   /* row by row */
+        do
+        {
+            memcpy(dst, src, width * sizeof(fb_data));
+            src += LCD_WIDTH;
+            dst += LCD_WIDTH;
+        } while(--height > 0);
+    }
+}
+
+void lcd_shutdown(void)
+{
+    printf("FB closed.");
+    munmap(dev_fb, sizeof(lcd_framebuffer));
+    close(dev_fd);
+}
+
+void lcd_init_device(void)
+{
+    size_t screensize;
+    struct fb_var_screeninfo vinfo;
+    struct fb_fix_screeninfo finfo;
+
+    /* Open the framebuffer device */
+    dev_fd = open("/dev/fb0", O_RDWR);
+    if (dev_fd == -1) {
+        perror("Error: cannot open framebuffer device");
+        exit(1);
+    }
+    printf("The framebuffer device was opened successfully.\n");
+
+    /* Get the fixed properties */
+    if (ioctl(dev_fd, FBIOGET_FSCREENINFO, &finfo) == -1) {
+        perror("Error reading fixed information");
+        exit(2);
+    }
+
+    /* Now we get the settable settings, and we set 16 bit bpp */
+    if (ioctl(dev_fd, FBIOGET_VSCREENINFO, &vinfo) == -1) {
+        perror("Error reading variable information");
+        exit(3);
+    }
+
+    vinfo.bits_per_pixel = 16;
+
+    if (ioctl(dev_fd, FBIOPUT_VSCREENINFO, &vinfo)) {
+            perror("fbset(ioctl)");
+            exit(4);
+    }
+
+    printf("%dx%d, %dbpp\n", vinfo.xres, vinfo.yres, vinfo.bits_per_pixel);
+
+    /* Figure out the size of the screen in bytes */
+    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
+    if (screensize != sizeof(lcd_framebuffer))
+    {
+        exit(4);
+        perror("Display and framebuffer mismatch!\n");
+    }
+
+    /* Map the device to memory */
+    dev_fb = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, dev_fd, 0);
+    if ((int)dev_fb == -1) {
+        perror("Error: failed to map framebuffer device to memory");
+        exit(4);
+    }
+    printf("The framebuffer device was mapped to memory successfully.\n");
+}
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
new file mode 100644
index 0000000..5701e9f
--- /dev/null
+++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
@@ -0,0 +1,133 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: powermgmt-sim.c 29543 2011-03-08 19:33:30Z thomasjfox $
+ *
+ * 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 <time.h>
+#include "kernel.h"
+#include "powermgmt.h"
+#include "ascodec-target.h"
+#include "stdio.h"
+
+#if 0 /*still unused*/
+/* The battery manufacturer's website shows discharge curves down to 3.0V,
+   so 'dangerous' and 'shutoff' levels of 3.4V and 3.3V should be safe.
+ */
+const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
+{
+    3550
+};
+
+const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
+{
+    3450
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
+{
+    { 3300, 3692, 3740, 3772, 3798, 3828, 3876, 3943, 4013, 4094, 4194 }
+};
+
+#if CONFIG_CHARGING
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
+const unsigned short percent_to_volt_charge[11] =
+{
+    3417, 3802, 3856, 3888, 3905, 3931, 3973, 4025, 4084, 4161, 4219
+};
+#endif /* CONFIG_CHARGING */
+#endif
+
+#define BATT_MINMVOLT   3450      /* minimum millivolts of battery */
+#define BATT_MAXMVOLT   4150      /* maximum millivolts of battery */
+#define BATT_MAXRUNTIME (10 * 60) /* maximum runtime with full battery in
+                                     minutes */
+
+extern void send_battery_level_event(void);
+extern int last_sent_battery_level;
+extern int battery_percent;
+
+static unsigned int battery_millivolts = BATT_MAXMVOLT;
+/* estimated remaining time in minutes */
+static int powermgmt_est_runningtime_min = BATT_MAXRUNTIME;
+
+static void battery_status_update(void)
+{
+    static time_t last_change = 0;
+    time_t now;
+
+    time(&now);
+
+    if (last_change < now) {
+        last_change = now;
+
+        battery_percent = 100 * (battery_millivolts - BATT_MINMVOLT) /
+                            (BATT_MAXMVOLT - BATT_MINMVOLT);
+
+        powermgmt_est_runningtime_min =
+            battery_percent * BATT_MAXRUNTIME / 100;
+    }
+
+    send_battery_level_event();
+}
+
+void battery_read_info(int *voltage, int *level)
+{
+    battery_status_update();
+
+    if (voltage)
+        *voltage = battery_millivolts;
+
+    if (level)
+        *level = battery_percent;
+}
+
+unsigned int battery_voltage(void)
+{
+    battery_status_update();
+    return battery_millivolts;
+}
+
+int battery_level(void)
+{
+    battery_status_update();
+    return battery_percent;
+}
+
+int battery_time(void)
+{
+    battery_status_update();
+    return powermgmt_est_runningtime_min;
+}
+
+bool battery_level_safe(void)
+{
+    return battery_level() >= 10;
+}
+
+void set_battery_capacity(int capacity)
+{
+  (void)capacity;
+}
+
+#if BATTERY_TYPES_COUNT > 1
+void set_battery_type(int type)
+{
+    (void)type;
+}
+#endif
diff --git a/firmware/target/hosted/ypr0/system-target.h b/firmware/target/hosted/ypr0/system-target.h
new file mode 100644
index 0000000..07a3163
--- /dev/null
+++ b/firmware/target/hosted/ypr0/system-target.h
@@ -0,0 +1,37 @@
+/***************************************************************************
+ *             __________               __   ___.                  
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___  
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /  
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <   
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \  
+ *                     \/            \/     \/    \/            \/ 
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 __SYSTEM_TARGET_H__
+#define __SYSTEM_TARGET_H__
+
+#define disable_irq()
+#define enable_irq()
+#define disable_irq_save() 0
+#define restore_irq(level) (void)level
+
+void wait_for_interrupt(void);
+void interrupt(void);
+
+static inline void commit_dcache(void) {}
+static inline void commit_discard_dcache(void) {}
+static inline void commit_discard_idcache(void) {}
+
+#define NEED_GENERIC_BYTESWAPS
+#endif /* __SYSTEM_TARGET_H__ */
diff --git a/firmware/target/hosted/ypr0/system-ypr0.c b/firmware/target/hosted/ypr0/system-ypr0.c
new file mode 100644
index 0000000..3a2b303
--- /dev/null
+++ b/firmware/target/hosted/ypr0/system-ypr0.c
@@ -0,0 +1,106 @@
+/***************************************************************************
+ *             __________               __   ___.                  
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___  
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /  
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <   
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \  
+ *                     \/            \/     \/    \/            \/ 
+ * $Id: system-sdl.c 29925 2011-05-25 20:11:03Z thomasjfox $
+ *
+ * Copyright (C) 2006 by Daniel Everton <dan@iocaine.org>
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include "system.h"
+#include "panic.h"
+#include "debug.h"
+
+#if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL)
+#include <SDL.h>
+#endif
+
+#include "ascodec-target.h"
+
+void sim_do_exit(void)
+{
+    exit(EXIT_SUCCESS);
+}
+
+void shutdown_hw(void)
+{
+    /* Something that we need to do before exit on our platform YPR0 */
+    ascodec_close();
+    sim_do_exit();
+}
+
+uintptr_t *stackbegin;
+uintptr_t *stackend;
+void system_init(void)
+{
+    int *s;
+    /* fake stack, OS manages size (and growth) */
+    stackbegin = stackend = (uintptr_t*)&s;
+
+#if defined(HAVE_SDL_AUDIO) || defined(HAVE_SDL_THREADS) || defined(HAVE_SDL)
+    SDL_Init(0); /* need this if using any SDL subsystem */
+#endif
+    /* Here begins our platform specific initilization for various things */
+    ascodec_init();
+}
+
+
+void system_reboot(void)
+{
+    sim_do_exit();
+}
+
+void system_exception_wait(void)
+{
+    system_reboot();
+}
+
+#ifdef HAVE_ADJUSTABLE_CPU_FREQ
+#include <stdio.h>
+#include "file.h"
+/* This is the Linux Kernel CPU governor... */
+static void set_cpu_freq(int speed)
+{
+    char temp[10];
+    int cpu_dev;
+    cpu_dev = open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", O_WRONLY);
+    if (cpu_dev < 0)
+        return;
+    write(cpu_dev, temp, sprintf(temp, "%d", speed) + 1);
+    close(cpu_dev);
+}
+
+void set_cpu_frequency(long frequency)
+{
+    switch (frequency)
+    {
+        case CPUFREQ_MAX:
+            set_cpu_freq(532000);
+            cpu_frequency = CPUFREQ_MAX;
+            break;
+        case CPUFREQ_NORMAL:
+            set_cpu_freq(400000);
+            cpu_frequency = CPUFREQ_NORMAL;
+            break;
+        default:
+            set_cpu_freq(200000);
+            cpu_frequency = CPUFREQ_DEFAULT;
+            break;
+    }
+}
+#endif
diff --git a/firmware/target/hosted/ypr0/usb-target.h b/firmware/target/hosted/ypr0/usb-target.h
new file mode 100644
index 0000000..237d179
--- /dev/null
+++ b/firmware/target/hosted/ypr0/usb-target.h
@@ -0,0 +1,25 @@
+/***************************************************************************
+ *             __________               __   ___.
+ *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+ *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+ *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+ *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+ *                     \/            \/     \/    \/            \/
+ * $Id: usb-target.h 29516 2011-03-05 15:31:52Z thomasjfox $
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 __USB_TARGET_H__
+#define __USB_TARGET_H__
+
+#endif /* __USB_TARGET_H__ */
diff --git a/firmware/target/hosted/ypr0/ypr0.make b/firmware/target/hosted/ypr0/ypr0.make
new file mode 100644
index 0000000..c211487
--- /dev/null
+++ b/firmware/target/hosted/ypr0/ypr0.make
@@ -0,0 +1,25 @@
+#             __________               __   ___.
+#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
+#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
+#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
+#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
+#                     \/            \/     \/    \/            \/
+# $Id$
+#
+
+INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
+
+SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
+
+.SECONDEXPANSION: # $$(OBJ) is not populated until after this
+
+
+$(BUILDDIR)/rockbox.elf : $$(OBJ) $$(FIRMLIB) $$(VOICESPEEXLIB) $$(SKINLIB)
+	$(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
+		-L$(BUILDDIR)/firmware -lfirmware \
+		-L$(BUILDDIR)/apps/codecs $(VOICESPEEXLIB:lib%.a=-l%) \
+		-L$(BUILDDIR)/lib -lskin_parser \
+		$(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
+
+$(BUILDDIR)/rockbox : $(BUILDDIR)/rockbox.elf
+	$(call PRINTS,OC $(@F))$(OC) -S -x $< $@
diff --git a/tools/configure b/tools/configure
index 1b7eaa0..2cd0489 100755
--- a/tools/configure
+++ b/tools/configure
@@ -649,6 +649,26 @@ pandoracc () {
  GCCOPTS="$GCCOPTS -ffast-math -fsingle-precision-constant"
 }
 
+ypr0cc () {
+
+ GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib//`
+ GCCOPTIMIZE=''
+ LDOPTS="-lasound -lpthread -lm -ldl -lrt $LDOPTS"
+ GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs"
+ SHARED_LDFLAG="-shared"
+ SHARED_CFLAGS=''
+ endian="little"
+ thread_support="HAVE_SIGALTSTACK_THREADS"
+ app_type="ypr0"
+
+ # Include path
+ GCCOPTS="$GCCOPTS  -D_GNU_SOURCE=1 -U_FORTIFY_SOURCE -D_REENTRANT"
+
+ # Set up compiler
+ gccchoice="4.4.6"
+ prefixtools "arm-ypr0-linux-gnueabi-"
+}
+
 androidcc () {
     if [ -z "$ANDROID_SDK_PATH" ]; then
         echo "ERROR: You need the Android SDK installed and have the ANDROID_SDK_PATH"
@@ -1292,7 +1312,7 @@ cat <<EOF
  202) Nokia N8xx                                 131) Mini2440
  203) Nokia N900          ==ROCKCHIP==           ==HiFiMAN==
  204) Pandora             180) rk27xx generic    190) HM-60x
-                                                 191) HM-801
+ 205) Samsung YP-R0                              191) HM-801
 
 EOF
 
@@ -3230,6 +3250,30 @@ fi
     t_model="app"
     ;;
 
+   205|samsungypr0)
+    application="yes"
+    target_id=78
+    modelname="samsungypr0"
+    target="SAMSUNG_YPR0"
+    app_set_lcd_size 240 320
+    memory=32
+    uname=`uname`
+    ypr0cc
+    tool="cp "
+    boottool="cp "
+    bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+    bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
+    output="rockbox"
+    bootoutput="rockbox"
+    appextra="recorder:gui:radio"
+    plugins="yes"
+    swcodec="yes"
+    # architecture, manufacturer and model for the target-tree build
+    t_cpu="hosted"
+    t_manufacturer="ypr0"
+    t_model="app"
+    ;;
+
    *)
     echo "Please select a supported target platform!"
     exit 7
@@ -3475,7 +3519,7 @@ gccver=`$CC -dumpversion`;
 if [ $uname = "Darwin" ]; then
  ldver=`$LD -v 2>&1 | sed -e 's/[^0-9.-]//g'`
 else
- ldver=`$LD --version | head -n 1 | sed -e 's/[^0-9.]//g'`
+ ldver=`$LD --version | head -n 1 | sed -e 's/\ /\n/g' | tail -n 1`
 fi
 
 if [ -z "$gccver" ]; then
diff --git a/tools/root.make b/tools/root.make
index f97588f..dd827d6 100644
--- a/tools/root.make
+++ b/tools/root.make
@@ -102,6 +102,10 @@ else
     include $(ROOTDIR)/uisimulator/uisimulator.make
   endif
 
+  ifneq (,$(findstring ypr0,$(APP_TYPE)))
+    include $(ROOTDIR)/firmware/target/hosted/ypr0/ypr0.make
+  endif
+
   ifneq (,$(findstring android, $(APP_TYPE)))
 	include $(ROOTDIR)/android/android.make
   endif
