summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/SOURCES4
-rw-r--r--apps/keymaps/keymap-ihifi770.c203
-rw-r--r--apps/keymaps/keymap-ihifi800.c207
-rw-r--r--apps/lang/english.lang28
-rw-r--r--apps/lang/russian.lang28
-rw-r--r--apps/plugins/battery_bench.c12
-rw-r--r--apps/plugins/blackjack.c32
-rw-r--r--apps/plugins/brickmania.c20
-rw-r--r--apps/plugins/calculator.c22
-rw-r--r--apps/plugins/calendar.c20
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.h28
-rw-r--r--apps/plugins/chessclock.c20
-rw-r--r--apps/plugins/chip8.c16
-rw-r--r--apps/plugins/chopper.c10
-rw-r--r--apps/plugins/clix.c16
-rw-r--r--apps/plugins/cube.c20
-rw-r--r--apps/plugins/doom/i_video.c24
-rw-r--r--apps/plugins/fft/fft.c18
-rw-r--r--apps/plugins/flipit.c24
-rw-r--r--apps/plugins/fractals/fractal.h24
-rw-r--r--apps/plugins/goban/goban.h26
-rw-r--r--apps/plugins/imageviewer/imageviewer_button.h30
-rw-r--r--apps/plugins/invadrox.c16
-rw-r--r--apps/plugins/jewels.c20
-rw-r--r--apps/plugins/lib/keymaps.h28
-rw-r--r--apps/plugins/lib/pluginlib_actions.c31
-rw-r--r--apps/plugins/midi/midiplay.c16
-rw-r--r--apps/plugins/minesweeper.c26
-rw-r--r--apps/plugins/mp3_encoder.c12
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c20
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c18
-rw-r--r--apps/plugins/oscilloscope.c28
-rw-r--r--apps/plugins/pacbox/pacbox.h21
-rw-r--r--apps/plugins/pegbox.c34
-rw-r--r--apps/plugins/pong.c16
-rw-r--r--apps/plugins/reversi/reversi-gui.h22
-rw-r--r--apps/plugins/rockblox.c24
-rw-r--r--apps/plugins/rockboy/rockboy.c20
-rw-r--r--apps/plugins/rockpaint.c22
-rw-r--r--apps/plugins/sliding_puzzle.c18
-rw-r--r--apps/plugins/snake.c16
-rw-r--r--apps/plugins/snake2.c18
-rw-r--r--apps/plugins/sokoban.c32
-rw-r--r--apps/plugins/solitaire.c38
-rw-r--r--apps/plugins/spacerocks.c18
-rw-r--r--apps/plugins/star.c32
-rw-r--r--apps/plugins/stopwatch.c16
-rw-r--r--apps/plugins/sudoku/sudoku.h28
-rw-r--r--apps/plugins/text_viewer/tv_button.h26
-rw-r--r--apps/plugins/vu_meter.c22
-rw-r--r--apps/plugins/wormlet.c18
-rw-r--r--apps/plugins/xobox.c18
-rw-r--r--apps/plugins/zxbox/keymaps.h16
-rw-r--r--apps/plugins/zxbox/zxbox_keyb.c18
-rw-r--r--apps/settings.h1
-rw-r--r--apps/settings_list.c5
-rw-r--r--bootloader/SOURCES3
-rw-r--r--bootloader/common.c3
-rw-r--r--firmware/SOURCES25
-rw-r--r--firmware/drivers/audio/es9018.c134
-rw-r--r--firmware/drivers/audio/wm8740.c106
-rw-r--r--firmware/export/audiohw.h6
-rw-r--r--firmware/export/config.h17
-rw-r--r--firmware/export/config/ihifi770.h197
-rw-r--r--firmware/export/config/ihifi770c.h197
-rw-r--r--firmware/export/config/ihifi800.h198
-rw-r--r--firmware/export/config/rk27generic.h2
-rw-r--r--firmware/export/es9018.h39
-rw-r--r--firmware/export/rk27xx.h5
-rw-r--r--firmware/export/wm8740.h83
-rw-r--r--firmware/target/arm/rk27xx/backlight-rk27xx.c7
-rw-r--r--firmware/target/arm/rk27xx/debug-rk27xx.c2
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/audio-ihifi770.c88
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c67
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/button-ihifi.c99
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/button-target.h50
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770.c285
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770c.c248
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/lcd-ihifi800.c228
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/lcd-target.h26
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/power-ihifi.c53
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770.c64
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770c.c64
-rw-r--r--firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi800.c64
-rw-r--r--firmware/target/arm/rk27xx/sd-rk27xx.c18
-rw-r--r--firmware/target/arm/rk27xx/usb-drv-rk27xx.c787
-rw-r--r--firmware/target/arm/rk27xx/usb-rk27xx.c14
-rw-r--r--firmware/target/hosted/sdl/sim-ui-defines.h22
-rw-r--r--tools/builds.pm12
-rwxr-xr-xtools/configure80
-rw-r--r--uisimulator/bitmaps/UI-ihifi770.bmpbin0 -> 792176 bytes
-rw-r--r--uisimulator/bitmaps/UI-ihifi770c.bmpbin0 -> 792176 bytes
-rw-r--r--uisimulator/bitmaps/UI-ihifi800.bmpbin0 -> 603056 bytes
-rw-r--r--uisimulator/buttonmap/SOURCES2
-rw-r--r--uisimulator/buttonmap/ihifi2.c90
95 files changed, 4408 insertions, 523 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index a84c01977f..67fe678287 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -311,6 +311,10 @@ keymaps/keymap-nwza860.c
311keymaps/keymap-ypz5.c 311keymaps/keymap-ypz5.c
312#elif CONFIG_KEYPAD == IHIFI_PAD 312#elif CONFIG_KEYPAD == IHIFI_PAD
313keymaps/keymap-ihifi.c 313keymaps/keymap-ihifi.c
314#elif CONFIG_KEYPAD == IHIFI_770_PAD
315keymaps/keymap-ihifi770.c
316#elif CONFIG_KEYPAD == IHIFI_800_PAD
317keymaps/keymap-ihifi800.c
314#elif CONFIG_KEYPAD == SAMSUNG_YPR1_PAD 318#elif CONFIG_KEYPAD == SAMSUNG_YPR1_PAD
315keymaps/keymap-ypr1.c 319keymaps/keymap-ypr1.c
316#elif CONFIG_KEYPAD == DX50_PAD 320#elif CONFIG_KEYPAD == DX50_PAD
diff --git a/apps/keymaps/keymap-ihifi770.c b/apps/keymaps/keymap-ihifi770.c
new file mode 100644
index 0000000000..c5671bd650
--- /dev/null
+++ b/apps/keymaps/keymap-ihifi770.c
@@ -0,0 +1,203 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* Button Code Definitions for IHIFI 770/770C targets */
23
24#include "config.h"
25#include "action.h"
26#include "button.h"
27#include "settings.h"
28
29/* {Action Code, Button code, Prereq button code } */
30
31/*
32 * The format of the list is as follows
33 * { Action Code, Button code, Prereq button code }
34 * if there's no need to check the previous button's value, use BUTTON_NONE
35 * Insert LAST_ITEM_IN_LIST at the end of each mapping
36 */
37static const struct button_mapping button_context_standard[] = {
38 { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
39 { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
40 { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
41 { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
42 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
43 { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
44 { ACTION_STD_CANCEL, BUTTON_HOME, BUTTON_NONE },
45
46 LAST_ITEM_IN_LIST
47}; /* button_context_standard */
48
49static const struct button_mapping button_context_wps[] = {
50 { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV },
51 { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
52 { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT },
53 { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT },
54 { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
55 { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT },
56 { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
57 { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
58 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
59 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
60 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
61 { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
62 { ACTION_WPS_MENU, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
63 { ACTION_WPS_BROWSE, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
64
65 LAST_ITEM_IN_LIST
66}; /* button_context_wps */
67
68static const struct button_mapping button_context_list[] = {
69 { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
70 { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
71 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
72 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
73
74 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
75}; /* button_context_list */
76
77/** Bookmark Screen **/
78static const struct button_mapping button_context_bmark[] = {
79 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
80
81 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
82}; /* button_context_bmark */
83
84/** Keyboard **/
85static const struct button_mapping button_context_keyboard[] = {
86 { ACTION_KBD_LEFT, BUTTON_HOME, BUTTON_NONE },
87 { ACTION_KBD_LEFT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
88 { ACTION_KBD_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
89 { ACTION_KBD_RIGHT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
90 { ACTION_KBD_UP, BUTTON_PREV, BUTTON_NONE },
91 { ACTION_KBD_UP, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
92 { ACTION_KBD_DOWN, BUTTON_NEXT, BUTTON_NONE },
93 { ACTION_KBD_DOWN, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
94 { ACTION_KBD_BACKSPACE, BUTTON_VOL_UP, BUTTON_NONE },
95 { ACTION_KBD_BACKSPACE, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
96 { ACTION_KBD_SELECT, BUTTON_PLAY, BUTTON_NONE },
97 { ACTION_KBD_DONE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
98 { ACTION_KBD_ABORT, BUTTON_POWER, BUTTON_NONE },
99
100 LAST_ITEM_IN_LIST
101}; /* button_context_keyboard */
102
103/** Pitchscreen **/
104static const struct button_mapping button_context_pitchscreen[] = {
105 { ACTION_PS_INC_SMALL, BUTTON_PREV, BUTTON_NONE },
106 { ACTION_PS_INC_BIG, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
107 { ACTION_PS_DEC_SMALL, BUTTON_NEXT, BUTTON_NONE },
108 { ACTION_PS_DEC_BIG, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
109 { ACTION_PS_NUDGE_LEFT, BUTTON_HOME, BUTTON_NONE },
110 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_HOME|BUTTON_REL, BUTTON_NONE },
111 { ACTION_PS_NUDGE_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
112 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_NONE },
113 { ACTION_PS_RESET, BUTTON_VOL_UP, BUTTON_NONE },
114 { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY, BUTTON_NONE },
115 { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE },
116
117 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
118}; /* button_context_pitchscreen */
119
120/** Quickscreen **/
121static const struct button_mapping button_context_quickscreen[] = {
122 { ACTION_QS_TOP, BUTTON_PREV, BUTTON_NONE },
123 { ACTION_QS_TOP, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
124 { ACTION_QS_DOWN, BUTTON_NEXT, BUTTON_NONE },
125 { ACTION_QS_DOWN, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
126 { ACTION_QS_LEFT, BUTTON_HOME, BUTTON_NONE },
127 { ACTION_QS_LEFT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
128 { ACTION_QS_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
129 { ACTION_QS_RIGHT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
130 { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE },
131
132 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
133}; /* button_context_quickscreen */
134
135/** Settings - General Mappings **/
136static const struct button_mapping button_context_settings[] = {
137 { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
138 { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
139 { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
140 { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
141 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
142 { ACTION_SETTINGS_RESET, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
143
144 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
145}; /* button_context_settings */
146
147static const struct button_mapping button_context_settings_vol_is_inc[] = {
148 { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
149 { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
150 { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
151 { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
152
153 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
154}; /* button_context_settings_right_is_inc */
155
156/** Tree **/
157static const struct button_mapping button_context_tree[] = {
158 { ACTION_TREE_WPS, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
159
160 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
161}; /* button_context_tree */
162
163/** Yes/No Screen **/
164static const struct button_mapping button_context_yesnoscreen[] = {
165 { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
166
167 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
168}; /* button_context_settings_yesnoscreen */
169
170/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
171const struct button_mapping* get_context_mapping(int context)
172{
173 switch (context)
174 {
175 case CONTEXT_LIST:
176 return button_context_list;
177 case CONTEXT_STD:
178 return button_context_standard;
179 case CONTEXT_BOOKMARKSCREEN:
180 return button_context_bmark;
181 case CONTEXT_KEYBOARD:
182 return button_context_keyboard;
183 case CONTEXT_PITCHSCREEN:
184 return button_context_pitchscreen;
185 case CONTEXT_QUICKSCREEN:
186 return button_context_quickscreen;
187 case CONTEXT_SETTINGS:
188 return button_context_settings;
189 case CONTEXT_SETTINGS_TIME:
190 case CONTEXT_SETTINGS_COLOURCHOOSER:
191 case CONTEXT_SETTINGS_EQ:
192 case CONTEXT_SETTINGS_RECTRIGGER:
193 return button_context_settings_vol_is_inc;
194 case CONTEXT_TREE:
195 case CONTEXT_MAINMENU:
196 return button_context_tree;
197 case CONTEXT_WPS:
198 return button_context_wps;
199 case CONTEXT_YESNOSCREEN:
200 return button_context_yesnoscreen;
201 }
202 return button_context_standard;
203}
diff --git a/apps/keymaps/keymap-ihifi800.c b/apps/keymaps/keymap-ihifi800.c
new file mode 100644
index 0000000000..b56bd018eb
--- /dev/null
+++ b/apps/keymaps/keymap-ihifi800.c
@@ -0,0 +1,207 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22/* TODO */
23
24/* Button Code Definitions for IHIFI 800 targets */
25
26#include "config.h"
27#include "action.h"
28#include "button.h"
29#include "settings.h"
30
31/* {Action Code, Button code, Prereq button code } */
32
33/*
34 * The format of the list is as follows
35 * { Action Code, Button code, Prereq button code }
36 * if there's no need to check the previous button's value, use BUTTON_NONE
37 * Insert LAST_ITEM_IN_LIST at the end of each mapping
38 */
39static const struct button_mapping button_context_standard[] = {
40 { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
41 { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
42 { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
43 { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
44 { ACTION_STD_OK, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
45 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
46 { ACTION_STD_CONTEXT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
47 { ACTION_STD_CANCEL, BUTTON_HOME, BUTTON_NONE },
48
49 LAST_ITEM_IN_LIST
50}; /* button_context_standard */
51
52static const struct button_mapping button_context_wps[] = {
53 { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV },
54 { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
55 { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT },
56 { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT },
57 { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
58 { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT },
59 { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
60 { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
61 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
62 { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
63 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
64 { ACTION_WPS_QUICKSCREEN, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
65 { ACTION_WPS_CONTEXT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE },
66 { ACTION_WPS_MENU, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
67 { ACTION_WPS_BROWSE, BUTTON_HOME|BUTTON_REL, BUTTON_NONE },
68
69 LAST_ITEM_IN_LIST
70}; /* button_context_wps */
71
72static const struct button_mapping button_context_list[] = {
73 { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
74 { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
75 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
76 { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
77
78 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
79}; /* button_context_list */
80
81/** Bookmark Screen **/
82static const struct button_mapping button_context_bmark[] = {
83 { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
84
85 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
86}; /* button_context_bmark */
87
88/** Keyboard **/
89static const struct button_mapping button_context_keyboard[] = {
90 { ACTION_KBD_ABORT, BUTTON_HOME, BUTTON_NONE },
91 { ACTION_KBD_BACKSPACE, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
92 { ACTION_KBD_LEFT, BUTTON_VOL_DOWN, BUTTON_NONE },
93 { ACTION_KBD_LEFT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
94 { ACTION_KBD_UP, BUTTON_PREV, BUTTON_NONE },
95 { ACTION_KBD_UP, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
96 { ACTION_KBD_DOWN, BUTTON_NEXT, BUTTON_NONE },
97 { ACTION_KBD_DOWN, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
98 { ACTION_KBD_RIGHT, BUTTON_VOL_UP, BUTTON_NONE },
99 { ACTION_KBD_RIGHT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
100 { ACTION_KBD_SELECT, BUTTON_PLAY, BUTTON_NONE },
101 { ACTION_KBD_DONE, BUTTON_POWER, BUTTON_NONE },
102
103 LAST_ITEM_IN_LIST
104}; /* button_context_keyboard */
105
106/** Pitchscreen **/
107static const struct button_mapping button_context_pitchscreen[] = {
108 { ACTION_PS_INC_SMALL, BUTTON_PREV, BUTTON_NONE },
109 { ACTION_PS_INC_BIG, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
110 { ACTION_PS_DEC_SMALL, BUTTON_NEXT, BUTTON_NONE },
111 { ACTION_PS_DEC_BIG, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
112 { ACTION_PS_NUDGE_LEFT, BUTTON_HOME, BUTTON_NONE },
113 { ACTION_PS_NUDGE_LEFTOFF, BUTTON_HOME|BUTTON_REL, BUTTON_NONE },
114 { ACTION_PS_NUDGE_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
115 { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_VOL_DOWN|BUTTON_REL, BUTTON_NONE },
116 { ACTION_PS_RESET, BUTTON_VOL_UP, BUTTON_NONE },
117 { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY, BUTTON_NONE },
118 { ACTION_PS_EXIT, BUTTON_POWER, BUTTON_NONE },
119
120 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
121}; /* button_context_pitchscreen */
122
123/** Quickscreen **/
124static const struct button_mapping button_context_quickscreen[] = {
125 { ACTION_QS_TOP, BUTTON_PREV, BUTTON_NONE },
126 { ACTION_QS_TOP, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
127 { ACTION_QS_DOWN, BUTTON_NEXT, BUTTON_NONE },
128 { ACTION_QS_DOWN, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
129 { ACTION_QS_LEFT, BUTTON_VOL_DOWN, BUTTON_NONE },
130 { ACTION_QS_LEFT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
131 { ACTION_QS_RIGHT, BUTTON_VOL_UP, BUTTON_NONE },
132 { ACTION_QS_RIGHT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
133 { ACTION_STD_CANCEL, BUTTON_HOME, BUTTON_NONE },
134
135 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
136}; /* button_context_quickscreen */
137
138/** Settings - General Mappings **/
139static const struct button_mapping button_context_settings[] = {
140 { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
141 { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
142 { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
143 { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
144 { ACTION_STD_OK, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
145 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
146 { ACTION_SETTINGS_RESET, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE },
147
148 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
149}; /* button_context_settings */
150
151static const struct button_mapping button_context_settings_vol_is_inc[] = {
152 { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
153 { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
154 { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
155 { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
156
157 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
158}; /* button_context_settings_right_is_inc */
159
160/** Tree **/
161static const struct button_mapping button_context_tree[] = {
162 { ACTION_TREE_WPS, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
163
164 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
165}; /* button_context_tree */
166
167/** Yes/No Screen **/
168static const struct button_mapping button_context_yesnoscreen[] = {
169 { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
170
171 LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
172}; /* button_context_settings_yesnoscreen */
173
174/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
175const struct button_mapping* get_context_mapping(int context)
176{
177 switch (context)
178 {
179 case CONTEXT_LIST:
180 return button_context_list;
181 case CONTEXT_STD:
182 return button_context_standard;
183 case CONTEXT_BOOKMARKSCREEN:
184 return button_context_bmark;
185 case CONTEXT_KEYBOARD:
186 return button_context_keyboard;
187 case CONTEXT_PITCHSCREEN:
188 return button_context_pitchscreen;
189 case CONTEXT_QUICKSCREEN:
190 return button_context_quickscreen;
191 case CONTEXT_SETTINGS:
192 return button_context_settings;
193 case CONTEXT_SETTINGS_TIME:
194 case CONTEXT_SETTINGS_COLOURCHOOSER:
195 case CONTEXT_SETTINGS_EQ:
196 case CONTEXT_SETTINGS_RECTRIGGER:
197 return button_context_settings_vol_is_inc;
198 case CONTEXT_TREE:
199 case CONTEXT_MAINMENU:
200 return button_context_tree;
201 case CONTEXT_WPS:
202 return button_context_wps;
203 case CONTEXT_YESNOSCREEN:
204 return button_context_yesnoscreen;
205 }
206 return button_context_standard;
207}
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index a2a23d0627..ed1cadfb9e 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -13230,6 +13230,34 @@
13230 </voice> 13230 </voice>
13231</phrase> 13231</phrase>
13232<phrase> 13232<phrase>
13233 id: LANG_FILTER_SHORT
13234 desc: in sound settings
13235 user: core
13236 <source>
13237 *: "Short"
13238 </source>
13239 <dest>
13240 *: "Short"
13241 </dest>
13242 <voice>
13243 *: "Short"
13244 </voice>
13245</phrase>
13246<phrase>
13247 id: LANG_FILTER_BYPASS
13248 desc: in sound settings
13249 user: core
13250 <source>
13251 *: "Bypass"
13252 </source>
13253 <dest>
13254 *: "Bypass"
13255 </dest>
13256 <voice>
13257 *: "Bypass"
13258 </voice>
13259</phrase>
13260<phrase>
13233 id: LANG_VOLUME_LIMIT 13261 id: LANG_VOLUME_LIMIT
13234 desc: in sound_settings 13262 desc: in sound_settings
13235 user: core 13263 user: core
diff --git a/apps/lang/russian.lang b/apps/lang/russian.lang
index 42551ae26e..e744542e1c 100644
--- a/apps/lang/russian.lang
+++ b/apps/lang/russian.lang
@@ -13138,6 +13138,34 @@
13138 </voice> 13138 </voice>
13139</phrase> 13139</phrase>
13140<phrase> 13140<phrase>
13141 id: LANG_FILTER_SHORT
13142 desc: in sound settings
13143 user: core
13144 <source>
13145 *: "Short"
13146 </source>
13147 <dest>
13148 *: "Short"
13149 </dest>
13150 <voice>
13151 *: "Short"
13152 </voice>
13153</phrase>
13154<phrase>
13155 id: LANG_FILTER_BYPASS
13156 desc: in sound settings
13157 user: core
13158 <source>
13159 *: "Bypass"
13160 </source>
13161 <dest>
13162 *: "Bypass"
13163 </dest>
13164 <voice>
13165 *: "Bypass"
13166 </voice>
13167</phrase>
13168<phrase>
13141 id: LANG_COMPRESSOR_ATTACK 13169 id: LANG_COMPRESSOR_ATTACK
13142 desc: in sound settings 13170 desc: in sound settings
13143 user: core 13171 user: core
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 9a48ef2fdb..13f01d7867 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -285,6 +285,18 @@
285#define BATTERY_ON_TXT "PLAY - start" 285#define BATTERY_ON_TXT "PLAY - start"
286#define BATTERY_OFF_TXT "POWER" 286#define BATTERY_OFF_TXT "POWER"
287 287
288#elif CONFIG_KEYPAD == IHIFI_770_PAD
289#define BATTERY_ON BUTTON_PLAY
290#define BATTERY_OFF BUTTON_POWER
291#define BATTERY_ON_TXT "PLAY - start"
292#define BATTERY_OFF_TXT "POWER"
293
294#elif CONFIG_KEYPAD == IHIFI_800_PAD
295#define BATTERY_ON BUTTON_PLAY
296#define BATTERY_OFF BUTTON_POWER
297#define BATTERY_ON_TXT "PLAY - start"
298#define BATTERY_OFF_TXT "POWER"
299
288#else 300#else
289#error No keymap defined! 301#error No keymap defined!
290#endif 302#endif
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index 6c3e487bf2..27881bf6e9 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -589,6 +589,38 @@ enum {
589#define BJACK_RIGHT BUTTON_NEXT 589#define BJACK_RIGHT BUTTON_NEXT
590#define BJACK_LEFT BUTTON_PREV 590#define BJACK_LEFT BUTTON_PREV
591 591
592#elif CONFIG_KEYPAD == IHIFI_770_PAD
593#define BJACK_SELECT_NAME "PLAY"
594#define BJACK_STAY_NAME "NEXT"
595#define BJACK_QUIT_NAME "POWER"
596#define BJACK_DOUBLE_NAME "PREV"
597#define BJACK_SELECT BUTTON_PLAY
598#define BJACK_QUIT BUTTON_POWER
599#define BJACK_MAX BUTTON_VOL_UP
600#define BJACK_MIN BUTTON_VOL_DOWN
601#define BJACK_STAY BUTTON_NEXT
602#define BJACK_DOUBLEDOWN BUTTON_PREV
603#define BJACK_UP BUTTON_HOME
604#define BJACK_DOWN (BUTTON_POWER | BUTTON_HOME)
605#define BJACK_RIGHT BUTTON_NEXT
606#define BJACK_LEFT BUTTON_PREV
607
608#elif CONFIG_KEYPAD == IHIFI_800_PAD
609#define BJACK_SELECT_NAME "PLAY"
610#define BJACK_STAY_NAME "NEXT"
611#define BJACK_QUIT_NAME "POWER"
612#define BJACK_DOUBLE_NAME "PREV"
613#define BJACK_SELECT BUTTON_PLAY
614#define BJACK_QUIT BUTTON_POWER
615#define BJACK_MAX BUTTON_VOL_UP
616#define BJACK_MIN BUTTON_VOL_DOWN
617#define BJACK_STAY BUTTON_NEXT
618#define BJACK_DOUBLEDOWN BUTTON_PREV
619#define BJACK_UP BUTTON_HOME
620#define BJACK_DOWN (BUTTON_POWER | BUTTON_HOME)
621#define BJACK_RIGHT BUTTON_NEXT
622#define BJACK_LEFT BUTTON_PREV
623
592#else 624#else
593#error No keymap defined! 625#error No keymap defined!
594#endif 626#endif
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index 24c6fab613..f7c9f9adf2 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -342,6 +342,26 @@ CONFIG_KEYPAD == SANSA_CONNECT_PAD
342#define UP BUTTON_HOME 342#define UP BUTTON_HOME
343#define DOWN BUTTON_OPTION 343#define DOWN BUTTON_OPTION
344 344
345#elif CONFIG_KEYPAD == IHIFI_770_PAD
346#define QUIT BUTTON_POWER
347#define LEFT BUTTON_HOME
348#define RIGHT BUTTON_VOL_DOWN
349#define ALTLEFT (BUTTON_POWER | BUTTON_HOME)
350#define ALTRIGHT (BUTTON_POWER | BUTTON_VOL_UP)
351#define SELECT BUTTON_PLAY
352#define UP BUTTON_PREV
353#define DOWN BUTTON_NEXT
354
355#elif CONFIG_KEYPAD == IHIFI_800_PAD
356#define QUIT BUTTON_POWER
357#define LEFT BUTTON_HOME
358#define RIGHT BUTTON_VOL_DOWN
359#define ALTLEFT (BUTTON_POWER | BUTTON_HOME)
360#define ALTRIGHT (BUTTON_POWER | BUTTON_VOL_UP)
361#define SELECT BUTTON_PLAY
362#define UP BUTTON_PREV
363#define DOWN BUTTON_NEXT
364
345#else 365#else
346#error No keymap defined! 366#error No keymap defined!
347#endif 367#endif
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index f10bca66ec..a4a29ff6ac 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -536,6 +536,28 @@ F3: equal to "="
536#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT) 536#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT)
537#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT) 537#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT)
538 538
539#elif CONFIG_KEYPAD == IHIFI_770_PAD
540#define CALCULATOR_LEFT BUTTON_HOME
541#define CALCULATOR_RIGHT BUTTON_VOL_DOWN
542#define CALCULATOR_UP BUTTON_PREV
543#define CALCULATOR_DOWN BUTTON_NEXT
544#define CALCULATOR_QUIT BUTTON_POWER
545#define CALCULATOR_INPUT_CALC_PRE (BUTTON_HOME|BUTTON_REPEAT)
546#define CALCULATOR_INPUT (BUTTON_PLAY|BUTTON_REL)
547#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT)
548#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT)
549
550#elif CONFIG_KEYPAD == IHIFI_800_PAD
551#define CALCULATOR_LEFT BUTTON_HOME
552#define CALCULATOR_RIGHT BUTTON_VOL_DOWN
553#define CALCULATOR_UP BUTTON_PREV
554#define CALCULATOR_DOWN BUTTON_NEXT
555#define CALCULATOR_QUIT BUTTON_POWER
556#define CALCULATOR_INPUT_CALC_PRE (BUTTON_HOME|BUTTON_REPEAT)
557#define CALCULATOR_INPUT (BUTTON_PLAY|BUTTON_REL)
558#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT)
559#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT)
560
539#else 561#else
540#error No keymap defined! 562#error No keymap defined!
541#endif 563#endif
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index 74ee49904b..56f9bde193 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -423,6 +423,26 @@
423#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP 423#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
424#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN 424#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
425 425
426#elif CONFIG_KEYPAD == IHIFI_770_PAD
427#define CALENDAR_QUIT BUTTON_POWER
428#define CALENDAR_SELECT BUTTON_PLAY
429#define CALENDAR_NEXT_WEEK (BUTTON_POWER | BUTTON_VOL_DOWN)
430#define CALENDAR_PREV_WEEK (BUTTON_POWER | BUTTON_VOL_UP)
431#define CALENDAR_NEXT_DAY BUTTON_NEXT
432#define CALENDAR_PREV_DAY BUTTON_PREV
433#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
434#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
435
436#elif CONFIG_KEYPAD == IHIFI_800_PAD
437#define CALENDAR_QUIT BUTTON_POWER
438#define CALENDAR_SELECT BUTTON_PLAY
439#define CALENDAR_NEXT_WEEK (BUTTON_POWER | BUTTON_VOL_DOWN)
440#define CALENDAR_PREV_WEEK (BUTTON_POWER | BUTTON_VOL_UP)
441#define CALENDAR_NEXT_DAY BUTTON_NEXT
442#define CALENDAR_PREV_DAY BUTTON_PREV
443#define CALENDAR_NEXT_MONTH BUTTON_VOL_DOWN
444#define CALENDAR_PREV_MONTH BUTTON_VOL_UP
445
426#else 446#else
427#error "No keypad setting." 447#error "No keypad setting."
428#endif 448#endif
diff --git a/apps/plugins/chessbox/chessbox_pgn.h b/apps/plugins/chessbox/chessbox_pgn.h
index 8f3032fe15..1159d0c7d1 100644
--- a/apps/plugins/chessbox/chessbox_pgn.h
+++ b/apps/plugins/chessbox/chessbox_pgn.h
@@ -572,6 +572,34 @@
572#define CB_SCROLL_LEFT (BUTTON_PREV|BUTTON_REPEAT) 572#define CB_SCROLL_LEFT (BUTTON_PREV|BUTTON_REPEAT)
573#define CB_SCROLL_RIGHT (BUTTON_NEXT|BUTTON_REPEAT) 573#define CB_SCROLL_RIGHT (BUTTON_NEXT|BUTTON_REPEAT)
574 574
575#elif CONFIG_KEYPAD == IHIFI_770_PAD
576#define CB_SELECT BUTTON_PLAY
577#define CB_UP BUTTON_PREV
578#define CB_DOWN BUTTON_NEXT
579#define CB_LEFT BUTTON_HOME
580#define CB_RIGHT BUTTON_VOL_DOWN
581#define CB_PLAY BUTTON_VOL_UP
582#define CB_LEVEL (BUTTON_PLAY|BUTTON_REPEAT)
583#define CB_MENU BUTTON_POWER
584#define CB_SCROLL_UP (BUTTON_PREV|BUTTON_REPEAT)
585#define CB_SCROLL_DOWN (BUTTON_NEXT|BUTTON_REPEAT)
586#define CB_SCROLL_LEFT (BUTTON_HOME|BUTTON_REPEAT)
587#define CB_SCROLL_RIGHT (BUTTON_VOL_UP|BUTTON_REPEAT)
588
589#elif CONFIG_KEYPAD == IHIFI_800_PAD
590#define CB_SELECT BUTTON_PLAY
591#define CB_UP BUTTON_PREV
592#define CB_DOWN BUTTON_NEXT
593#define CB_LEFT BUTTON_HOME
594#define CB_RIGHT BUTTON_VOL_DOWN
595#define CB_PLAY BUTTON_VOL_UP
596#define CB_LEVEL (BUTTON_PLAY|BUTTON_REPEAT)
597#define CB_MENU BUTTON_POWER
598#define CB_SCROLL_UP (BUTTON_PREV|BUTTON_REPEAT)
599#define CB_SCROLL_DOWN (BUTTON_NEXT|BUTTON_REPEAT)
600#define CB_SCROLL_LEFT (BUTTON_HOME|BUTTON_REPEAT)
601#define CB_SCROLL_RIGHT (BUTTON_VOL_UP|BUTTON_REPEAT)
602
575#else 603#else
576#error No keymap defined! 604#error No keymap defined!
577#endif 605#endif
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index ae7889ed95..6b07e1bab5 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -422,6 +422,26 @@
422#define CHC_SETTINGS_OK BUTTON_PLAY 422#define CHC_SETTINGS_OK BUTTON_PLAY
423#define CHC_SETTINGS_CANCEL BUTTON_POWER 423#define CHC_SETTINGS_CANCEL BUTTON_POWER
424 424
425#elif CONFIG_KEYPAD == IHIFI_770_PAD
426#define CHC_QUIT BUTTON_POWER
427#define CHC_STARTSTOP BUTTON_PLAY
428#define CHC_RESET (BUTTON_PLAY|BUTTON_REPEAT)
429#define CHC_MENU BUTTON_HOME
430#define CHC_SETTINGS_INC BUTTON_VOL_UP
431#define CHC_SETTINGS_DEC BUTTON_VOL_DOWN
432#define CHC_SETTINGS_OK BUTTON_PLAY
433#define CHC_SETTINGS_CANCEL BUTTON_HOME
434
435#elif CONFIG_KEYPAD == IHIFI_800_PAD
436#define CHC_QUIT BUTTON_POWER
437#define CHC_STARTSTOP BUTTON_PLAY
438#define CHC_RESET (BUTTON_PLAY|BUTTON_REPEAT)
439#define CHC_MENU BUTTON_HOME
440#define CHC_SETTINGS_INC BUTTON_VOL_UP
441#define CHC_SETTINGS_DEC BUTTON_VOL_DOWN
442#define CHC_SETTINGS_OK BUTTON_PLAY
443#define CHC_SETTINGS_CANCEL BUTTON_HOME
444
425#else 445#else
426#error No keymap defined! 446#error No keymap defined!
427#endif 447#endif
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index 153558667e..58d80a2ccf 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -1291,6 +1291,22 @@ CONFIG_KEYPAD == MROBE500_PAD
1291#define CHIP8_KEY6 BUTTON_NEXT 1291#define CHIP8_KEY6 BUTTON_NEXT
1292#define CHIP8_KEY8 BUTTON_OPTION 1292#define CHIP8_KEY8 BUTTON_OPTION
1293 1293
1294#elif CONFIG_KEYPAD == IHIFI_770_PAD
1295#define CHIP8_OFF BUTTON_POWER
1296#define CHIP8_KEY2 BUTTON_NEXT
1297#define CHIP8_KEY4 BUTTON_HOME
1298#define CHIP8_KEY5 BUTTON_VOL_UP
1299#define CHIP8_KEY6 BUTTON_VOL_DOWN
1300#define CHIP8_KEY8 BUTTON_PREV
1301
1302#elif CONFIG_KEYPAD == IHIFI_800_PAD
1303#define CHIP8_OFF BUTTON_POWER
1304#define CHIP8_KEY2 BUTTON_NEXT
1305#define CHIP8_KEY4 BUTTON_HOME
1306#define CHIP8_KEY5 BUTTON_VOL_UP
1307#define CHIP8_KEY6 BUTTON_VOL_DOWN
1308#define CHIP8_KEY8 BUTTON_PREV
1309
1294#else 1310#else
1295#error No keymap defined! 1311#error No keymap defined!
1296#endif 1312#endif
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 1732a16ecb..249cfe9715 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -214,6 +214,16 @@ CONFIG_KEYPAD == MROBE500_PAD
214#define ACTION BUTTON_PLAY 214#define ACTION BUTTON_PLAY
215#define ACTIONTEXT "PLAY" 215#define ACTIONTEXT "PLAY"
216 216
217#elif CONFIG_KEYPAD == IHIFI_770_PAD
218#define QUIT BUTTON_POWER
219#define ACTION BUTTON_PLAY
220#define ACTIONTEXT "PLAY"
221
222#elif CONFIG_KEYPAD == IHIFI_800_PAD
223#define QUIT BUTTON_POWER
224#define ACTION BUTTON_PLAY
225#define ACTIONTEXT "PLAY"
226
217#elif !defined(HAVE_TOUCHSCREEN) 227#elif !defined(HAVE_TOUCHSCREEN)
218#error No keymap defined! 228#error No keymap defined!
219#endif 229#endif
diff --git a/apps/plugins/clix.c b/apps/plugins/clix.c
index b2580a1630..c6364b14b4 100644
--- a/apps/plugins/clix.c
+++ b/apps/plugins/clix.c
@@ -284,6 +284,22 @@
284#define CLIX_BUTTON_RIGHT BUTTON_NEXT 284#define CLIX_BUTTON_RIGHT BUTTON_NEXT
285#define CLIX_BUTTON_CLICK BUTTON_PLAY 285#define CLIX_BUTTON_CLICK BUTTON_PLAY
286 286
287#elif CONFIG_KEYPAD == IHIFI_770_PAD
288#define CLIX_BUTTON_QUIT BUTTON_POWER
289#define CLIX_BUTTON_UP BUTTON_PREV
290#define CLIX_BUTTON_DOWN BUTTON_NEXT
291#define CLIX_BUTTON_LEFT BUTTON_HOME
292#define CLIX_BUTTON_RIGHT BUTTON_VOL_DOWN
293#define CLIX_BUTTON_CLICK BUTTON_VOL_UP
294
295#elif CONFIG_KEYPAD == IHIFI_800_PAD
296#define CLIX_BUTTON_QUIT BUTTON_POWER
297#define CLIX_BUTTON_UP BUTTON_PREV
298#define CLIX_BUTTON_DOWN BUTTON_NEXT
299#define CLIX_BUTTON_LEFT BUTTON_HOME
300#define CLIX_BUTTON_RIGHT BUTTON_VOL_DOWN
301#define CLIX_BUTTON_CLICK BUTTON_VOL_UP
302
287#else 303#else
288#error "no keymap" 304#error "no keymap"
289#endif 305#endif
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index 9a67c337d1..cad57f9ed6 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -423,6 +423,26 @@
423#define CUBE_PAUSE BUTTON_HOME 423#define CUBE_PAUSE BUTTON_HOME
424#define CUBE_HIGHSPEED BUTTON_PLAY 424#define CUBE_HIGHSPEED BUTTON_PLAY
425 425
426#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
427#define CUBE_QUIT BUTTON_POWER
428#define CUBE_NEXT BUTTON_NEXT
429#define CUBE_PREV BUTTON_PREV
430#define CUBE_INC BUTTON_VOL_UP
431#define CUBE_DEC BUTTON_VOL_DOWN
432#define CUBE_MODE (BUTTON_HOME | BUTTON_POWER)
433#define CUBE_PAUSE BUTTON_HOME
434#define CUBE_HIGHSPEED BUTTON_PLAY
435
436#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
437#define CUBE_QUIT BUTTON_POWER
438#define CUBE_NEXT BUTTON_NEXT
439#define CUBE_PREV BUTTON_PREV
440#define CUBE_INC BUTTON_VOL_UP
441#define CUBE_DEC BUTTON_VOL_DOWN
442#define CUBE_MODE (BUTTON_HOME | BUTTON_POWER)
443#define CUBE_PAUSE BUTTON_HOME
444#define CUBE_HIGHSPEED BUTTON_PLAY
445
426#else 446#else
427#error No keymap defined! 447#error No keymap defined!
428#endif 448#endif
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index d734e1e12b..41194670bf 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -566,6 +566,30 @@ void I_ShutdownGraphics(void)
566#define DOOMBUTTON_ENTER BUTTON_PLAY 566#define DOOMBUTTON_ENTER BUTTON_PLAY
567#define DOOMBUTTON_WEAPON BUTTON_VOL_UP 567#define DOOMBUTTON_WEAPON BUTTON_VOL_UP
568 568
569#elif CONFIG_KEYPAD == IHIFI_770_PAD
570#define DOOMBUTTON_UP BUTTON_PREV
571#define DOOMBUTTON_DOWN BUTTON_NEXT
572#define DOOMBUTTON_LEFT BUTTON_HOME
573#define DOOMBUTTON_RIGHT BUTTON_VOL_DOWN
574#define DOOMBUTTON_OPEN BUTTON_PLAY
575#define DOOMBUTTON_ESC BUTTON_POWER
576#define DOOMBUTTON_ENTER BUTTON_VOL_UP
577#define DOOMBUTTON_SHOOT BUTTON_VOL_UP
578#define DOOMBUTTON_WEAPON (BUTTON_PLAY|BUTTON_REPEAT)
579#define DOOMBUTTON_MAP (BUTTON_POWER|BUTTON_REPEAT)
580
581#elif CONFIG_KEYPAD == IHIFI_800_PAD
582#define DOOMBUTTON_UP BUTTON_PREV
583#define DOOMBUTTON_DOWN BUTTON_NEXT
584#define DOOMBUTTON_LEFT BUTTON_HOME
585#define DOOMBUTTON_RIGHT BUTTON_VOL_DOWN
586#define DOOMBUTTON_OPEN BUTTON_PLAY
587#define DOOMBUTTON_ESC BUTTON_POWER
588#define DOOMBUTTON_ENTER BUTTON_VOL_UP
589#define DOOMBUTTON_SHOOT BUTTON_VOL_UP
590#define DOOMBUTTON_WEAPON (BUTTON_PLAY|BUTTON_REPEAT)
591#define DOOMBUTTON_MAP (BUTTON_POWER|BUTTON_REPEAT)
592
569#else 593#else
570#error Keymap not defined! 594#error Keymap not defined!
571#endif 595#endif
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index e5750c109a..d56e37f9e2 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -343,6 +343,24 @@ GREY_INFO_STRUCT
343# define FFT_AMP_SCALE BUTTON_PLAY 343# define FFT_AMP_SCALE BUTTON_PLAY
344# define FFT_QUIT BUTTON_POWER 344# define FFT_QUIT BUTTON_POWER
345 345
346#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
347# define FFT_PREV_GRAPH BUTTON_PREV
348# define FFT_NEXT_GRAPH BUTTON_NEXT
349# define FFT_ORIENTATION BUTTON_HOME
350# define FFT_FREQ_SCALE BUTTON_VOL_UP
351# define FFT_WINDOW BUTTON_VOL_DOWN
352# define FFT_AMP_SCALE BUTTON_PLAY
353# define FFT_QUIT BUTTON_POWER
354
355#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
356# define FFT_PREV_GRAPH BUTTON_PREV
357# define FFT_NEXT_GRAPH BUTTON_NEXT
358# define FFT_ORIENTATION BUTTON_HOME
359# define FFT_FREQ_SCALE BUTTON_VOL_UP
360# define FFT_WINDOW BUTTON_VOL_DOWN
361# define FFT_AMP_SCALE BUTTON_PLAY
362# define FFT_QUIT BUTTON_POWER
363
346#elif !defined(HAVE_TOUCHSCREEN) 364#elif !defined(HAVE_TOUCHSCREEN)
347#error No keymap defined! 365#error No keymap defined!
348#endif 366#endif
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c
index b089974aef..c108939a95 100644
--- a/apps/plugins/flipit.c
+++ b/apps/plugins/flipit.c
@@ -494,6 +494,30 @@
494#define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_PLAY) 494#define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_PLAY)
495#define FLIPIT_TOGGLE BUTTON_PLAY 495#define FLIPIT_TOGGLE BUTTON_PLAY
496 496
497#elif CONFIG_KEYPAD == IHIFI_770_PAD
498
499#define FLIPIT_LEFT BUTTON_HOME
500#define FLIPIT_RIGHT BUTTON_VOL_DOWN
501#define FLIPIT_UP BUTTON_PREV
502#define FLIPIT_DOWN BUTTON_NEXT
503#define FLIPIT_QUIT BUTTON_POWER
504#define FLIPIT_SHUFFLE (BUTTON_POWER | BUTTON_PREV)
505#define FLIPIT_SOLVE (BUTTON_POWER | BUTTON_NEXT)
506#define FLIPIT_STEP_BY_STEP (BUTTON_POWER | BUTTON_PLAY)
507#define FLIPIT_TOGGLE BUTTON_PLAY
508
509#elif CONFIG_KEYPAD == IHIFI_800_PAD
510
511#define FLIPIT_LEFT BUTTON_HOME
512#define FLIPIT_RIGHT BUTTON_VOL_DOWN
513#define FLIPIT_UP BUTTON_PREV
514#define FLIPIT_DOWN BUTTON_NEXT
515#define FLIPIT_QUIT BUTTON_POWER
516#define FLIPIT_SHUFFLE (BUTTON_POWER | BUTTON_PREV)
517#define FLIPIT_SOLVE (BUTTON_POWER | BUTTON_NEXT)
518#define FLIPIT_STEP_BY_STEP (BUTTON_POWER | BUTTON_PLAY)
519#define FLIPIT_TOGGLE BUTTON_PLAY
520
497#else 521#else
498#error No keymap defined! 522#error No keymap defined!
499#endif 523#endif
diff --git a/apps/plugins/fractals/fractal.h b/apps/plugins/fractals/fractal.h
index ed6be31695..5a56a39b13 100644
--- a/apps/plugins/fractals/fractal.h
+++ b/apps/plugins/fractals/fractal.h
@@ -496,6 +496,30 @@
496#define FRACTAL_PRECISION_DEC (BUTTON_PLAY | BUTTON_PREV) 496#define FRACTAL_PRECISION_DEC (BUTTON_PLAY | BUTTON_PREV)
497#define FRACTAL_RESET (BUTTON_HOME | BUTTON_POWER) 497#define FRACTAL_RESET (BUTTON_HOME | BUTTON_POWER)
498 498
499#elif CONFIG_KEYPAD == IHIFI_770_PAD
500#define FRACTAL_QUIT BUTTON_POWER
501#define FRACTAL_UP BUTTON_PREV
502#define FRACTAL_DOWN BUTTON_NEXT
503#define FRACTAL_LEFT BUTTON_HOME
504#define FRACTAL_RIGHT BUTTON_VOL_DOWN
505#define FRACTAL_ZOOM_IN (BUTTON_POWER | BUTTON_VOL_UP)
506#define FRACTAL_ZOOM_OUT (BUTTON_POWER | BUTTON_VOL_DOWN)
507#define FRACTAL_PRECISION_INC (BUTTON_POWER | BUTTON_NEXT)
508#define FRACTAL_PRECISION_DEC (BUTTON_POWER | BUTTON_PREV)
509#define FRACTAL_RESET (BUTTON_POWER | BUTTON_HOME)
510
511#elif CONFIG_KEYPAD == IHIFI_800_PAD
512#define FRACTAL_QUIT BUTTON_POWER
513#define FRACTAL_UP BUTTON_PREV
514#define FRACTAL_DOWN BUTTON_NEXT
515#define FRACTAL_LEFT BUTTON_HOME
516#define FRACTAL_RIGHT BUTTON_VOL_DOWN
517#define FRACTAL_ZOOM_IN (BUTTON_POWER | BUTTON_VOL_UP)
518#define FRACTAL_ZOOM_OUT (BUTTON_POWER | BUTTON_VOL_DOWN)
519#define FRACTAL_PRECISION_INC (BUTTON_POWER | BUTTON_NEXT)
520#define FRACTAL_PRECISION_DEC (BUTTON_POWER | BUTTON_PREV)
521#define FRACTAL_RESET (BUTTON_POWER | BUTTON_HOME)
522
499#else 523#else
500#error No keymap defined! 524#error No keymap defined!
501#endif 525#endif
diff --git a/apps/plugins/goban/goban.h b/apps/plugins/goban/goban.h
index d1d66e3535..9f03937078 100644
--- a/apps/plugins/goban/goban.h
+++ b/apps/plugins/goban/goban.h
@@ -464,6 +464,32 @@
464#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT 464#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
465#define GBN_BUTTON_NEXT_VAR BUTTON_HOME | BUTTON_POWER 465#define GBN_BUTTON_NEXT_VAR BUTTON_HOME | BUTTON_POWER
466 466
467#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
468
469#define GBN_BUTTON_UP BUTTON_PREV
470#define GBN_BUTTON_DOWN BUTTON_NEXT
471#define GBN_BUTTON_LEFT BUTTON_HOME
472#define GBN_BUTTON_RIGHT BUTTON_VOL_DOWN
473#define GBN_BUTTON_RETREAT BUTTON_POWER | BUTTON_VOL_DOWN
474#define GBN_BUTTON_ADVANCE BUTTON_POWER | BUTTON_VOL_UP
475#define GBN_BUTTON_MENU BUTTON_POWER
476#define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
477#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
478#define GBN_BUTTON_NEXT_VAR BUTTON_POWER | BUTTON_HOME
479
480#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
481
482#define GBN_BUTTON_UP BUTTON_PREV
483#define GBN_BUTTON_DOWN BUTTON_NEXT
484#define GBN_BUTTON_LEFT BUTTON_HOME
485#define GBN_BUTTON_RIGHT BUTTON_VOL_DOWN
486#define GBN_BUTTON_RETREAT BUTTON_POWER | BUTTON_VOL_DOWN
487#define GBN_BUTTON_ADVANCE BUTTON_POWER | BUTTON_VOL_UP
488#define GBN_BUTTON_MENU BUTTON_POWER
489#define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
490#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
491#define GBN_BUTTON_NEXT_VAR BUTTON_POWER | BUTTON_HOME
492
467#else 493#else
468#error Unsupported keypad 494#error Unsupported keypad
469#endif 495#endif
diff --git a/apps/plugins/imageviewer/imageviewer_button.h b/apps/plugins/imageviewer/imageviewer_button.h
index 2f349b1a24..5ffef12a62 100644
--- a/apps/plugins/imageviewer/imageviewer_button.h
+++ b/apps/plugins/imageviewer/imageviewer_button.h
@@ -510,6 +510,36 @@
510#define IMGVIEW_MENU BUTTON_POWER 510#define IMGVIEW_MENU BUTTON_POWER
511#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER) 511#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER)
512 512
513#elif CONFIG_KEYPAD == IHIFI_770_PAD
514#define IMGVIEW_ZOOM_PRE BUTTON_PLAY
515#define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL)
516#define IMGVIEW_ZOOM_OUT (BUTTON_PLAY | BUTTON_REPEAT)
517#define IMGVIEW_UP BUTTON_PREV
518#define IMGVIEW_DOWN BUTTON_NEXT
519#define IMGVIEW_LEFT BUTTON_HOME
520#define IMGVIEW_RIGHT (BUTTON_PLAY|BUTTON_POWER)
521#define IMGVIEW_NEXT BUTTON_VOL_UP
522#define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
523#define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
524#define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
525#define IMGVIEW_MENU BUTTON_POWER
526#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER)
527
528#elif CONFIG_KEYPAD == IHIFI_800_PAD
529#define IMGVIEW_ZOOM_PRE BUTTON_PLAY
530#define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL)
531#define IMGVIEW_ZOOM_OUT (BUTTON_PLAY | BUTTON_REPEAT)
532#define IMGVIEW_UP BUTTON_PREV
533#define IMGVIEW_DOWN BUTTON_NEXT
534#define IMGVIEW_LEFT BUTTON_HOME
535#define IMGVIEW_RIGHT (BUTTON_PLAY|BUTTON_POWER)
536#define IMGVIEW_NEXT BUTTON_VOL_UP
537#define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
538#define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
539#define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
540#define IMGVIEW_MENU BUTTON_POWER
541#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER)
542
513#else 543#else
514#error No keymap defined! 544#error No keymap defined!
515#endif 545#endif
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index 72c3b57338..8ef674a74a 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -272,6 +272,22 @@ CONFIG_KEYPAD == MROBE500_PAD
272#define QUIT BUTTON_POWER 272#define QUIT BUTTON_POWER
273#define FIRE BUTTON_MENU 273#define FIRE BUTTON_MENU
274 274
275#elif CONFIG_KEYPAD == IHIFI2_PAD
276
277#elif CONFIG_KEYPAD == IHIFI_770_PAD
278
279#define QUIT BUTTON_POWER
280#define LEFT BUTTON_HOME
281#define RIGHT BUTTON_VOL_DOWN
282#define FIRE BUTTON_VOL_UP
283
284#elif CONFIG_KEYPAD == IHIFI_800_PAD
285
286#define QUIT BUTTON_POWER
287#define LEFT BUTTON_HOME
288#define RIGHT BUTTON_VOL_DOWN
289#define FIRE BUTTON_VOL_UP
290
275#else 291#else
276 #error INVADROX: Unsupported keypad 292 #error INVADROX: Unsupported keypad
277#endif 293#endif
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index e4a22830a1..bc0bc73183 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -387,6 +387,26 @@ CONFIG_KEYPAD == MROBE500_PAD
387#define HK_SELECT "PLAY" 387#define HK_SELECT "PLAY"
388#define HK_CANCEL "POWER" 388#define HK_CANCEL "POWER"
389 389
390#elif CONFIG_KEYPAD == IHIFI_770_PAD
391#define JEWELS_UP BUTTON_PREV
392#define JEWELS_DOWN BUTTON_NEXT
393#define JEWELS_LEFT BUTTON_HOME
394#define JEWELS_RIGHT BUTTON_VOL_DOWN
395#define JEWELS_SELECT BUTTON_PLAY
396#define JEWELS_CANCEL BUTTON_POWER
397#define HK_SELECT "PLAY"
398#define HK_CANCEL "POWER"
399
400#elif CONFIG_KEYPAD == IHIFI_800_PAD
401#define JEWELS_UP BUTTON_PREV
402#define JEWELS_DOWN BUTTON_NEXT
403#define JEWELS_LEFT BUTTON_HOME
404#define JEWELS_RIGHT BUTTON_VOL_DOWN
405#define JEWELS_SELECT BUTTON_PLAY
406#define JEWELS_CANCEL BUTTON_POWER
407#define HK_SELECT "PLAY"
408#define HK_CANCEL "POWER"
409
390#else 410#else
391#error No keymap defined! 411#error No keymap defined!
392#endif 412#endif
diff --git a/apps/plugins/lib/keymaps.h b/apps/plugins/lib/keymaps.h
index 5fab361620..e240a0989e 100644
--- a/apps/plugins/lib/keymaps.h
+++ b/apps/plugins/lib/keymaps.h
@@ -216,12 +216,28 @@
216#define BTN_PAUSE BUTTON_POWER 216#define BTN_PAUSE BUTTON_POWER
217 217
218#elif (CONFIG_KEYPAD == XDUOO_X3_PAD) 218#elif (CONFIG_KEYPAD == XDUOO_X3_PAD)
219#define BTN_UP BUTTON_VOL_UP 219#define BTN_UP BUTTON_VOL_UP
220#define BTN_DOWN BUTTON_VOL_DOWN 220#define BTN_DOWN BUTTON_VOL_DOWN
221#define BTN_LEFT BUTTON_PREV 221#define BTN_LEFT BUTTON_PREV
222#define BTN_RIGHT BUTTON_NEXT 222#define BTN_RIGHT BUTTON_NEXT
223#define BTN_FIRE BUTTON_PLAY 223#define BTN_FIRE BUTTON_PLAY
224#define BTN_PAUSE BUTTON_OPTION 224#define BTN_PAUSE BUTTON_POWER
225
226#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
227#define BTN_UP BUTTON_PREV
228#define BTN_DOWN BUTTON_NEXT
229#define BTN_LEFT BUTTON_HOME
230#define BTN_RIGHT BUTTON_VOL_DOWN
231#define BTN_FIRE BUTTON_PLAY
232#define BTN_PAUSE BUTTON_POWER
233
234#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
235#define BTN_UP BUTTON_PREV
236#define BTN_DOWN BUTTON_NEXT
237#define BTN_LEFT BUTTON_HOME
238#define BTN_RIGHT BUTTON_VOL_DOWN
239#define BTN_FIRE BUTTON_PLAY
240#define BTN_PAUSE BUTTON_POWER
225 241
226#else 242#else
227#error Unsupported keypad 243#error Unsupported keypad
diff --git a/apps/plugins/lib/pluginlib_actions.c b/apps/plugins/lib/pluginlib_actions.c
index 2c5fb773ba..97b5a1e1bf 100644
--- a/apps/plugins/lib/pluginlib_actions.c
+++ b/apps/plugins/lib/pluginlib_actions.c
@@ -237,6 +237,24 @@ const struct button_mapping pla_main_ctx[] =
237 { PLA_DOWN_REPEAT, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE }, 237 { PLA_DOWN_REPEAT, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE },
238 { PLA_LEFT_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE }, 238 { PLA_LEFT_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
239 { PLA_RIGHT_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE }, 239 { PLA_RIGHT_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
240#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
241 { PLA_UP, BUTTON_PREV, BUTTON_NONE },
242 { PLA_DOWN, BUTTON_NEXT, BUTTON_NONE },
243 { PLA_LEFT, BUTTON_HOME, BUTTON_NONE },
244 { PLA_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
245 { PLA_UP_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
246 { PLA_DOWN_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
247 { PLA_LEFT_REPEAT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
248 { PLA_RIGHT_REPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
249#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
250 { PLA_UP, BUTTON_PREV, BUTTON_NONE },
251 { PLA_DOWN, BUTTON_NEXT, BUTTON_NONE },
252 { PLA_LEFT, BUTTON_HOME, BUTTON_NONE },
253 { PLA_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
254 { PLA_UP_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
255 { PLA_DOWN_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
256 { PLA_LEFT_REPEAT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
257 { PLA_RIGHT_REPEAT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
240#else 258#else
241# ifndef HAVE_TOUCHSCREEN 259# ifndef HAVE_TOUCHSCREEN
242# error pluginlib_actions: No directions defined 260# error pluginlib_actions: No directions defined
@@ -462,7 +480,18 @@ const struct button_mapping pla_main_ctx[] =
462 {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE}, 480 {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE},
463 {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY}, 481 {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY},
464 {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE}, 482 {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE},
465 483#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
484 {PLA_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
485 {PLA_EXIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE},
486 {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE},
487 {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY},
488 {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE},
489#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
490 {PLA_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
491 {PLA_EXIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE},
492 {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE},
493 {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY},
494 {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE},
466#else 495#else
467# ifndef HAVE_TOUCHSCREEN 496# ifndef HAVE_TOUCHSCREEN
468# error pluginlib_actions: No actions defined 497# error pluginlib_actions: No actions defined
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index de6310dcd8..bef13b649d 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -301,6 +301,22 @@
301#define MIDI_VOL_DOWN BUTTON_VOL_DOWN 301#define MIDI_VOL_DOWN BUTTON_VOL_DOWN
302#define MIDI_PLAYPAUSE BUTTON_PLAY 302#define MIDI_PLAYPAUSE BUTTON_PLAY
303 303
304#elif CONFIG_KEYPAD == IHIFI_770_PAD
305#define MIDI_QUIT BUTTON_POWER
306#define MIDI_FFWD BUTTON_VOL_DOWN
307#define MIDI_REWIND BUTTON_HOME
308#define MIDI_VOL_UP BUTTON_PREV
309#define MIDI_VOL_DOWN BUTTON_NEXT
310#define MIDI_PLAYPAUSE BUTTON_PLAY
311
312#elif CONFIG_KEYPAD == IHIFI_800_PAD
313#define MIDI_QUIT BUTTON_POWER
314#define MIDI_FFWD BUTTON_VOL_DOWN
315#define MIDI_REWIND BUTTON_HOME
316#define MIDI_VOL_UP BUTTON_PREV
317#define MIDI_VOL_DOWN BUTTON_NEXT
318#define MIDI_PLAYPAUSE BUTTON_PLAY
319
304#else 320#else
305#error No keymap defined! 321#error No keymap defined!
306#endif 322#endif
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index 2a3b5f78e9..956ba128d5 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -417,6 +417,32 @@ CONFIG_KEYPAD == MROBE500_PAD
417# define MINESWP_DISCOVER2 BUTTON_VOL_UP 417# define MINESWP_DISCOVER2 BUTTON_VOL_UP
418# define MINESWP_INFO (BUTTON_PLAY | BUTTON_OPTION) 418# define MINESWP_INFO (BUTTON_PLAY | BUTTON_OPTION)
419 419
420#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
421# define MINESWP_LEFT BUTTON_HOME
422# define MINESWP_RIGHT BUTTON_VOL_DOWN
423# define MINESWP_UP BUTTON_PREV
424# define MINESWP_DOWN BUTTON_NEXT
425# define MINESWP_QUIT BUTTON_POWER
426# define MINESWP_TOGGLE_PRE BUTTON_PLAY
427# define MINESWP_TOGGLE (BUTTON_POWER | BUTTON_PREV)
428# define MINESWP_TOGGLE2 (BUTTON_POWER | BUTTON_NEXT)
429# define MINESWP_DISCOVER (BUTTON_POWER | BUTTON_VOL_UP)
430# define MINESWP_DISCOVER2 (BUTTON_POWER | BUTTON_VOL_DOWN)
431# define MINESWP_INFO (BUTTON_POWER | BUTTON_HOME)
432
433#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
434# define MINESWP_LEFT BUTTON_HOME
435# define MINESWP_RIGHT BUTTON_VOL_DOWN
436# define MINESWP_UP BUTTON_PREV
437# define MINESWP_DOWN BUTTON_NEXT
438# define MINESWP_QUIT BUTTON_POWER
439# define MINESWP_TOGGLE_PRE BUTTON_PLAY
440# define MINESWP_TOGGLE (BUTTON_POWER | BUTTON_PREV)
441# define MINESWP_TOGGLE2 (BUTTON_POWER | BUTTON_NEXT)
442# define MINESWP_DISCOVER (BUTTON_POWER | BUTTON_VOL_UP)
443# define MINESWP_DISCOVER2 (BUTTON_POWER | BUTTON_VOL_DOWN)
444# define MINESWP_INFO (BUTTON_POWER | BUTTON_HOME)
445
420#else 446#else
421#error No keymap defined! 447#error No keymap defined!
422#endif 448#endif
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index 9e09135385..d147120cd4 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -2562,6 +2562,18 @@ CONFIG_KEYPAD == MROBE500_PAD
2562#define MP3ENC_DONE BUTTON_POWER 2562#define MP3ENC_DONE BUTTON_POWER
2563#define MP3ENC_SELECT BUTTON_PLAY 2563#define MP3ENC_SELECT BUTTON_PLAY
2564 2564
2565#elif CONFIG_KEYPAD == IHIFI_770_PAD
2566#define MP3ENC_PREV BUTTON_PREV
2567#define MP3ENC_NEXT BUTTON_NEXT
2568#define MP3ENC_DONE BUTTON_POWER
2569#define MP3ENC_SELECT BUTTON_PLAY
2570
2571#elif CONFIG_KEYPAD == IHIFI_800_PAD
2572#define MP3ENC_PREV BUTTON_PREV
2573#define MP3ENC_NEXT BUTTON_NEXT
2574#define MP3ENC_DONE BUTTON_POWER
2575#define MP3ENC_SELECT BUTTON_PLAY
2576
2565#else 2577#else
2566#error No keymap defined! 2578#error No keymap defined!
2567#endif 2579#endif
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 7976f5f542..d6b4fd4b84 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -316,6 +316,26 @@ struct mpeg_settings settings;
316#define MPEG_START_TIME_RIGHT2 BUTTON_VOL_DOWN 316#define MPEG_START_TIME_RIGHT2 BUTTON_VOL_DOWN
317#define MPEG_START_TIME_EXIT BUTTON_POWER 317#define MPEG_START_TIME_EXIT BUTTON_POWER
318 318
319#elif CONFIG_KEYPAD == IHIFI_770_PAD
320#define MPEG_START_TIME_SELECT BUTTON_PLAY
321#define MPEG_START_TIME_LEFT BUTTON_HOME
322#define MPEG_START_TIME_RIGHT BUTTON_VOL_DOWN
323#define MPEG_START_TIME_UP BUTTON_PREV
324#define MPEG_START_TIME_DOWN BUTTON_NEXT
325#define MPEG_START_TIME_LEFT2 (BUTTON_POWER + BUTTON_HOME)
326#define MPEG_START_TIME_RIGHT2 (BUTTON_POWER + BUTTON_VOL_DOWN)
327#define MPEG_START_TIME_EXIT BUTTON_POWER
328
329#elif CONFIG_KEYPAD == IHIFI_800_PAD
330#define MPEG_START_TIME_SELECT BUTTON_PLAY
331#define MPEG_START_TIME_LEFT BUTTON_HOME
332#define MPEG_START_TIME_RIGHT BUTTON_VOL_DOWN
333#define MPEG_START_TIME_UP BUTTON_PREV
334#define MPEG_START_TIME_DOWN BUTTON_NEXT
335#define MPEG_START_TIME_LEFT2 (BUTTON_POWER + BUTTON_HOME)
336#define MPEG_START_TIME_RIGHT2 (BUTTON_POWER + BUTTON_VOL_DOWN)
337#define MPEG_START_TIME_EXIT BUTTON_POWER
338
319#else 339#else
320#error No keymap defined! 340#error No keymap defined!
321#endif 341#endif
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index fd3e8d8cd5..6a33a544db 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -450,6 +450,24 @@ CONFIG_KEYPAD == SANSA_M200_PAD
450#define MPEG_RW BUTTON_PREV 450#define MPEG_RW BUTTON_PREV
451#define MPEG_FF BUTTON_NEXT 451#define MPEG_FF BUTTON_NEXT
452 452
453#elif CONFIG_KEYPAD == IHIFI_770_PAD
454#define MPEG_MENU BUTTON_PLAY
455#define MPEG_STOP BUTTON_POWER
456#define MPEG_PAUSE BUTTON_HOME
457#define MPEG_VOLDOWN BUTTON_VOL_DOWN
458#define MPEG_VOLUP BUTTON_VOL_UP
459#define MPEG_RW BUTTON_PREV
460#define MPEG_FF BUTTON_NEXT
461
462#elif CONFIG_KEYPAD == IHIFI_800_PAD
463#define MPEG_MENU BUTTON_PLAY
464#define MPEG_STOP BUTTON_POWER
465#define MPEG_PAUSE BUTTON_HOME
466#define MPEG_VOLDOWN BUTTON_VOL_DOWN
467#define MPEG_VOLUP BUTTON_VOL_UP
468#define MPEG_RW BUTTON_PREV
469#define MPEG_FF BUTTON_NEXT
470
453#else 471#else
454#error No keymap defined! 472#error No keymap defined!
455#endif 473#endif
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c
index 4534684293..f4711d4e0e 100644
--- a/apps/plugins/oscilloscope.c
+++ b/apps/plugins/oscilloscope.c
@@ -518,6 +518,34 @@
518#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN 518#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
519#define NEED_LASTBUTTON 519#define NEED_LASTBUTTON
520 520
521#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
522#define OSCILLOSCOPE_QUIT BUTTON_POWER
523#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_PLAY
524#define OSCILLOSCOPE_DRAWMODE (BUTTON_PLAY | BUTTON_REL)
525#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_PLAY
526#define OSCILLOSCOPE_ORIENTATION (BUTTON_PLAY | BUTTON_REPEAT)
527#define OSCILLOSCOPE_ADVMODE BUTTON_HOME
528#define OSCILLOSCOPE_PAUSE (BUTTON_HOME | BUTTON_REPEAT)
529#define OSCILLOSCOPE_SPEED_UP BUTTON_NEXT
530#define OSCILLOSCOPE_SPEED_DOWN BUTTON_PREV
531#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
532#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
533#define NEED_LASTBUTTON
534
535#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
536#define OSCILLOSCOPE_QUIT BUTTON_POWER
537#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_PLAY
538#define OSCILLOSCOPE_DRAWMODE (BUTTON_PLAY | BUTTON_REL)
539#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_PLAY
540#define OSCILLOSCOPE_ORIENTATION (BUTTON_PLAY | BUTTON_REPEAT)
541#define OSCILLOSCOPE_ADVMODE BUTTON_HOME
542#define OSCILLOSCOPE_PAUSE (BUTTON_HOME | BUTTON_REPEAT)
543#define OSCILLOSCOPE_SPEED_UP BUTTON_NEXT
544#define OSCILLOSCOPE_SPEED_DOWN BUTTON_PREV
545#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
546#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
547#define NEED_LASTBUTTON
548
521#else 549#else
522#error No keymap defined! 550#error No keymap defined!
523#endif 551#endif
diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h
index 3461bd62c7..eb97d828e2 100644
--- a/apps/plugins/pacbox/pacbox.h
+++ b/apps/plugins/pacbox/pacbox.h
@@ -363,6 +363,27 @@
363#define PACMAN_1UP BUTTON_VOLUP 363#define PACMAN_1UP BUTTON_VOLUP
364#define PACMAN_COIN BUTTON_VOLDOWN 364#define PACMAN_COIN BUTTON_VOLDOWN
365 365
366#elif CONFIG_KEYPAD == IHIFI2_PAD
367
368#elif CONFIG_KEYPAD == IHIFI_770_PAD
369#define PACMAN_UP BUTTON_PREV
370#define PACMAN_DOWN BUTTON_NEXT
371#define PACMAN_LEFT BUTTON_HOME
372#define PACMAN_RIGHT BUTTON_VOL_DOWN
373#define PACMAN_MENU BUTTON_POWER
374#define PACMAN_1UP BUTTON_VOL_UP
375#define PACMAN_COIN BUTTON_PLAY
376
377#elif CONFIG_KEYPAD == IHIFI_800_PAD
378
379#define PACMAN_UP BUTTON_PREV
380#define PACMAN_DOWN BUTTON_NEXT
381#define PACMAN_LEFT BUTTON_HOME
382#define PACMAN_RIGHT BUTTON_VOL_DOWN
383#define PACMAN_MENU BUTTON_POWER
384#define PACMAN_1UP BUTTON_VOL_UP
385#define PACMAN_COIN BUTTON_PLAY
386
366#else 387#else
367 388
368#error Keymap not defined! 389#error Keymap not defined!
diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c
index 922359cd32..cc2e8e3f23 100644
--- a/apps/plugins/pegbox.c
+++ b/apps/plugins/pegbox.c
@@ -660,6 +660,40 @@ CONFIG_KEYPAD == MROBE500_PAD
660#define LVL_UP_TEXT "VOL+" 660#define LVL_UP_TEXT "VOL+"
661#define LVL_DOWN_TEXT "VOL-" 661#define LVL_DOWN_TEXT "VOL-"
662 662
663#elif CONFIG_KEYPAD == IHIFI_770_PAD
664#define PEGBOX_SELECT BUTTON_PLAY
665#define PEGBOX_QUIT BUTTON_POWER
666#define PEGBOX_RESTART (BUTTON_POWER | BUTTON_HOME)
667#define PEGBOX_LVL_UP (BUTTON_POWER | BUTTON_VOL_UP)
668#define PEGBOX_LVL_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
669#define PEGBOX_UP BUTTON_PREV
670#define PEGBOX_DOWN BUTTON_NEXT
671#define PEGBOX_RIGHT BUTTON_HOME
672#define PEGBOX_LEFT BUTTON_VOL_DOWN
673
674#define SELECT_TEXT "PLAY"
675#define QUIT_TEXT "POWER"
676#define RESTART_TEXT "HOME"
677#define LVL_UP_TEXT "VOL+"
678#define LVL_DOWN_TEXT "VOL-"
679
680#elif CONFIG_KEYPAD == IHIFI_800_PAD
681#define PEGBOX_SELECT BUTTON_PLAY
682#define PEGBOX_QUIT BUTTON_POWER
683#define PEGBOX_RESTART (BUTTON_POWER | BUTTON_HOME)
684#define PEGBOX_LVL_UP (BUTTON_POWER | BUTTON_VOL_UP)
685#define PEGBOX_LVL_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
686#define PEGBOX_UP BUTTON_PREV
687#define PEGBOX_DOWN BUTTON_NEXT
688#define PEGBOX_RIGHT BUTTON_HOME
689#define PEGBOX_LEFT BUTTON_VOL_DOWN
690
691#define SELECT_TEXT "PLAY"
692#define QUIT_TEXT "POWER"
693#define RESTART_TEXT "HOME"
694#define LVL_UP_TEXT "VOL+"
695#define LVL_DOWN_TEXT "VOL-"
696
663#else 697#else
664#error Unsupported keymap! 698#error Unsupported keymap!
665#endif 699#endif
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c
index d65134e5d2..cb3006d7c4 100644
--- a/apps/plugins/pong.c
+++ b/apps/plugins/pong.c
@@ -317,6 +317,22 @@ CONFIG_KEYPAD == MROBE500_PAD
317#define PONG_RIGHT_UP BUTTON_HOME 317#define PONG_RIGHT_UP BUTTON_HOME
318#define PONG_RIGHT_DOWN BUTTON_NEXT 318#define PONG_RIGHT_DOWN BUTTON_NEXT
319 319
320#elif CONFIG_KEYPAD == IHIFI_770_PAD
321#define PONG_QUIT BUTTON_POWER
322#define PONG_PAUSE BUTTON_PREV
323#define PONG_LEFT_UP BUTTON_PLAY
324#define PONG_LEFT_DOWN BUTTON_HOME
325#define PONG_RIGHT_UP BUTTON_VOL_UP
326#define PONG_RIGHT_DOWN BUTTON_VOL_DOWN
327
328#elif CONFIG_KEYPAD == IHIFI_800_PAD
329#define PONG_QUIT BUTTON_POWER
330#define PONG_PAUSE BUTTON_PREV
331#define PONG_LEFT_UP BUTTON_PLAY
332#define PONG_LEFT_DOWN BUTTON_HOME
333#define PONG_RIGHT_UP BUTTON_VOL_UP
334#define PONG_RIGHT_DOWN BUTTON_VOL_DOWN
335
320#else 336#else
321#error No keymap defined! 337#error No keymap defined!
322#endif 338#endif
diff --git a/apps/plugins/reversi/reversi-gui.h b/apps/plugins/reversi/reversi-gui.h
index 1dc1dedbed..cba34d2814 100644
--- a/apps/plugins/reversi/reversi-gui.h
+++ b/apps/plugins/reversi/reversi-gui.h
@@ -339,6 +339,28 @@
339#define REVERSI_BUTTON_MENU BUTTON_PLAY 339#define REVERSI_BUTTON_MENU BUTTON_PLAY
340#define REVERSI_BUTTON_MENU_LONGPRESS 340#define REVERSI_BUTTON_MENU_LONGPRESS
341 341
342#elif CONFIG_KEYPAD == IHIFI_770_PAD
343#define REVERSI_BUTTON_QUIT BUTTON_POWER
344#define REVERSI_BUTTON_UP BUTTON_PREV
345#define REVERSI_BUTTON_DOWN BUTTON_NEXT
346#define REVERSI_BUTTON_LEFT BUTTON_PREV
347#define REVERSI_BUTTON_RIGHT BUTTON_VOL_DOWN
348#define REVERSI_BUTTON_MAKE_MOVE BUTTON_PLAY
349#define REVERSI_BUTTON_MAKE_MOVE_SHORTPRESS
350#define REVERSI_BUTTON_MENU BUTTON_PLAY
351#define REVERSI_BUTTON_MENU_LONGPRESS
352
353#elif CONFIG_KEYPAD == IHIFI_800_PAD
354#define REVERSI_BUTTON_QUIT BUTTON_POWER
355#define REVERSI_BUTTON_UP BUTTON_PREV
356#define REVERSI_BUTTON_DOWN BUTTON_NEXT
357#define REVERSI_BUTTON_LEFT BUTTON_PREV
358#define REVERSI_BUTTON_RIGHT BUTTON_VOL_DOWN
359#define REVERSI_BUTTON_MAKE_MOVE BUTTON_PLAY
360#define REVERSI_BUTTON_MAKE_MOVE_SHORTPRESS
361#define REVERSI_BUTTON_MENU BUTTON_PLAY
362#define REVERSI_BUTTON_MENU_LONGPRESS
363
342#else 364#else
343#error No keymap defined! 365#error No keymap defined!
344#endif 366#endif
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index b204ed87da..13eb593775 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -492,6 +492,30 @@
492#define ROCKBLOX_DROP (BUTTON_PLAY|BUTTON_REL) 492#define ROCKBLOX_DROP (BUTTON_PLAY|BUTTON_REL)
493#define ROCKBLOX_RESTART (BUTTON_PLAY|BUTTON_REPEAT) 493#define ROCKBLOX_RESTART (BUTTON_PLAY|BUTTON_REPEAT)
494 494
495#elif CONFIG_KEYPAD == IHIFI_770_PAD
496
497#define ROCKBLOX_OFF BUTTON_POWER
498#define ROCKBLOX_ROTATE_CCW BUTTON_HOME
499#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
500#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
501#define ROCKBLOX_DOWN BUTTON_PLAY
502#define ROCKBLOX_LEFT BUTTON_PREV
503#define ROCKBLOX_RIGHT BUTTON_NEXT
504#define ROCKBLOX_DROP (BUTTON_POWER|BUTTON_PLAY)
505#define ROCKBLOX_RESTART (BUTTON_POWER|BUTTON_REPEAT)
506
507#elif CONFIG_KEYPAD == IHIFI_800_PAD
508
509#define ROCKBLOX_OFF BUTTON_POWER
510#define ROCKBLOX_ROTATE_CCW BUTTON_HOME
511#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
512#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
513#define ROCKBLOX_DOWN BUTTON_PLAY
514#define ROCKBLOX_LEFT BUTTON_PREV
515#define ROCKBLOX_RIGHT BUTTON_NEXT
516#define ROCKBLOX_DROP (BUTTON_POWER|BUTTON_PLAY)
517#define ROCKBLOX_RESTART (BUTTON_POWER|BUTTON_REPEAT)
518
495#else 519#else
496#error No keymap defined! 520#error No keymap defined!
497#endif 521#endif
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 7425fc2550..8886793ab7 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -433,6 +433,26 @@ static void setoptions (void)
433 options.SELECT = BUTTON_VOL_UP; 433 options.SELECT = BUTTON_VOL_UP;
434 options.MENU = BUTTON_POWER; 434 options.MENU = BUTTON_POWER;
435 435
436#elif CONFIG_KEYPAD == IHIFI_770_PAD
437 options.UP = BUTTON_PREV;
438 options.DOWN = BUTTON_NEXT;
439
440 options.A = BUTTON_VOL_UP;
441 options.B = BUTTON_VOL_DOWN;
442 options.START = BUTTON_PLAY;
443 options.SELECT = BUTTON_HOME;
444 options.MENU = BUTTON_POWER;
445
446#elif CONFIG_KEYPAD == IHIFI_800_PAD
447 options.UP = BUTTON_PREV;
448 options.DOWN = BUTTON_NEXT;
449
450 options.A = BUTTON_VOL_UP;
451 options.B = BUTTON_VOL_DOWN;
452 options.START = BUTTON_PLAY;
453 options.SELECT = BUTTON_HOME;
454 options.MENU = BUTTON_POWER;
455
436#else 456#else
437#error No Keymap Defined! 457#error No Keymap Defined!
438#endif 458#endif
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c
index d0f9f7235c..3759489fe1 100644
--- a/apps/plugins/rockpaint.c
+++ b/apps/plugins/rockpaint.c
@@ -338,6 +338,28 @@
338#define ROCKPAINT_LEFT BUTTON_PREV 338#define ROCKPAINT_LEFT BUTTON_PREV
339#define ROCKPAINT_RIGHT BUTTON_NEXT 339#define ROCKPAINT_RIGHT BUTTON_NEXT
340 340
341#elif CONFIG_KEYPAD == IHIFI_770_PAD
342#define ROCKPAINT_QUIT BUTTON_POWER
343#define ROCKPAINT_DRAW BUTTON_PLAY
344#define ROCKPAINT_MENU (BUTTON_HOME | BUTTON_POWER)
345#define ROCKPAINT_TOOLBAR BUTTON_VOL_UP
346#define ROCKPAINT_TOOLBAR2 (BUTTON_VOL_UP | BUTTON_POWER)
347#define ROCKPAINT_UP BUTTON_PREV
348#define ROCKPAINT_DOWN BUTTON_NEXT
349#define ROCKPAINT_LEFT BUTTON_HOME
350#define ROCKPAINT_RIGHT BUTTON_VOL_DOWN
351
352#elif CONFIG_KEYPAD == IHIFI_800_PAD
353#define ROCKPAINT_QUIT BUTTON_POWER
354#define ROCKPAINT_DRAW BUTTON_PLAY
355#define ROCKPAINT_MENU (BUTTON_HOME | BUTTON_POWER)
356#define ROCKPAINT_TOOLBAR BUTTON_VOL_UP
357#define ROCKPAINT_TOOLBAR2 (BUTTON_VOL_UP | BUTTON_POWER)
358#define ROCKPAINT_UP BUTTON_PREV
359#define ROCKPAINT_DOWN BUTTON_NEXT
360#define ROCKPAINT_LEFT BUTTON_HOME
361#define ROCKPAINT_RIGHT BUTTON_VOL_DOWN
362
341#else 363#else
342#error "Please define keys for this keypad" 364#error "Please define keys for this keypad"
343#endif 365#endif
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index a3f84e32ae..0ea36c84b8 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -340,6 +340,24 @@ CONFIG_KEYPAD == MROBE500_PAD
340#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER) 340#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER)
341#define PUZZLE_PICTURE BUTTON_PLAY 341#define PUZZLE_PICTURE BUTTON_PLAY
342 342
343#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
344#define PUZZLE_QUIT BUTTON_POWER
345#define PUZZLE_LEFT BUTTON_HOME
346#define PUZZLE_RIGHT BUTTON_VOL_DOWN
347#define PUZZLE_UP BUTTON_PREV
348#define PUZZLE_DOWN BUTTON_NEXT
349#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER)
350#define PUZZLE_PICTURE BUTTON_PLAY
351
352#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
353#define PUZZLE_QUIT BUTTON_POWER
354#define PUZZLE_LEFT BUTTON_HOME
355#define PUZZLE_RIGHT BUTTON_VOL_DOWN
356#define PUZZLE_UP BUTTON_PREV
357#define PUZZLE_DOWN BUTTON_NEXT
358#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER)
359#define PUZZLE_PICTURE BUTTON_PLAY
360
343#else 361#else
344#error No keymap defined! 362#error No keymap defined!
345#endif 363#endif
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index 9144edf062..2518316bdd 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -297,6 +297,22 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
297#define SNAKE_DOWN BUTTON_OPTION 297#define SNAKE_DOWN BUTTON_OPTION
298#define SNAKE_PLAYPAUSE BUTTON_PLAY 298#define SNAKE_PLAYPAUSE BUTTON_PLAY
299 299
300#elif CONFIG_KEYPAD == IHIFI_770_PAD
301#define SNAKE_QUIT BUTTON_POWER
302#define SNAKE_LEFT BUTTON_HOME
303#define SNAKE_RIGHT BUTTON_VOL_DOWN
304#define SNAKE_UP BUTTON_PREV
305#define SNAKE_DOWN BUTTON_NEXT
306#define SNAKE_PLAYPAUSE BUTTON_PLAY
307
308#elif CONFIG_KEYPAD == IHIFI_800_PAD
309#define SNAKE_QUIT BUTTON_POWER
310#define SNAKE_LEFT BUTTON_HOME
311#define SNAKE_RIGHT BUTTON_VOL_DOWN
312#define SNAKE_UP BUTTON_PREV
313#define SNAKE_DOWN BUTTON_NEXT
314#define SNAKE_PLAYPAUSE BUTTON_PLAY
315
300#else 316#else
301#error No keymap defined! 317#error No keymap defined!
302#endif 318#endif
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index 13d2c57b24..9ea79504e4 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -428,6 +428,24 @@ CONFIG_KEYPAD == MROBE500_PAD
428#define SNAKE2_PLAYPAUSE BUTTON_PLAY 428#define SNAKE2_PLAYPAUSE BUTTON_PLAY
429#define SNAKE2_PLAYPAUSE_TEXT "PLAY" 429#define SNAKE2_PLAYPAUSE_TEXT "PLAY"
430 430
431#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
432#define SNAKE2_LEFT BUTTON_HOME
433#define SNAKE2_RIGHT BUTTON_VOL_DOWN
434#define SNAKE2_UP BUTTON_PREV
435#define SNAKE2_DOWN BUTTON_NEXT
436#define SNAKE2_QUIT BUTTON_POWER
437#define SNAKE2_PLAYPAUSE BUTTON_PLAY
438#define SNAKE2_PLAYPAUSE_TEXT "PLAY"
439
440#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
441#define SNAKE2_LEFT BUTTON_HOME
442#define SNAKE2_RIGHT BUTTON_VOL_DOWN
443#define SNAKE2_UP BUTTON_PREV
444#define SNAKE2_DOWN BUTTON_NEXT
445#define SNAKE2_QUIT BUTTON_POWER
446#define SNAKE2_PLAYPAUSE BUTTON_PLAY
447#define SNAKE2_PLAYPAUSE_TEXT "PLAY"
448
431#else 449#else
432#error No keymap defined! 450#error No keymap defined!
433#endif 451#endif
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index 98d295eb1a..17971ec4db 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -667,6 +667,38 @@
667#define BUTTON_SAVE BUTTON_PLAY 667#define BUTTON_SAVE BUTTON_PLAY
668#define BUTTON_SAVE_NAME "PLAY" 668#define BUTTON_SAVE_NAME "PLAY"
669 669
670#elif CONFIG_KEYPAD == IHIFI_770_PAD
671#define SOKOBAN_LEFT BUTTON_HOME
672#define SOKOBAN_RIGHT BUTTON_VOL_DOWN
673#define SOKOBAN_UP BUTTON_PREV
674#define SOKOBAN_DOWN BUTTON_NEXT
675#define SOKOBAN_MENU BUTTON_POWER
676#define SOKOBAN_UNDO_PRE BUTTON_PLAY
677#define SOKOBAN_UNDO (BUTTON_PLAY | BUTTON_REL)
678#define SOKOBAN_REDO (BUTTON_POWER | BUTTON_PLAY)
679#define SOKOBAN_LEVEL_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
680#define SOKOBAN_LEVEL_REPEAT (BUTTON_POWER | BUTTON_HOME)
681#define SOKOBAN_LEVEL_UP (BUTTON_POWER | BUTTON_VOL_UP)
682#define SOKOBAN_PAUSE BUTTON_PLAY
683#define BUTTON_SAVE BUTTON_PLAY
684#define BUTTON_SAVE_NAME "PLAY"
685
686#elif CONFIG_KEYPAD == IHIFI_800_PAD
687#define SOKOBAN_LEFT BUTTON_HOME
688#define SOKOBAN_RIGHT BUTTON_VOL_DOWN
689#define SOKOBAN_UP BUTTON_PREV
690#define SOKOBAN_DOWN BUTTON_NEXT
691#define SOKOBAN_MENU BUTTON_POWER
692#define SOKOBAN_UNDO_PRE BUTTON_PLAY
693#define SOKOBAN_UNDO (BUTTON_PLAY | BUTTON_REL)
694#define SOKOBAN_REDO (BUTTON_POWER | BUTTON_PLAY)
695#define SOKOBAN_LEVEL_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
696#define SOKOBAN_LEVEL_REPEAT (BUTTON_POWER | BUTTON_HOME)
697#define SOKOBAN_LEVEL_UP (BUTTON_POWER | BUTTON_VOL_UP)
698#define SOKOBAN_PAUSE BUTTON_PLAY
699#define BUTTON_SAVE BUTTON_PLAY
700#define BUTTON_SAVE_NAME "PLAY"
701
670#else 702#else
671#error No keymap defined! 703#error No keymap defined!
672#endif 704#endif
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index fe7da2788e..7440160470 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -706,6 +706,44 @@ CONFIG_KEYPAD == MROBE500_PAD
706# define HK_CUR2STACK "DBL PLAY" 706# define HK_CUR2STACK "DBL PLAY"
707# define HK_REM2STACK "NEXT" 707# define HK_REM2STACK "NEXT"
708 708
709#elif CONFIG_KEYPAD == IHIFI_770_PAD
710# define SOL_QUIT BUTTON_POWER
711# define SOL_UP BUTTON_PREV
712# define SOL_DOWN BUTTON_NEXT
713# define SOL_LEFT BUTTON_HOME
714# define SOL_RIGHT BUTTON_VOL_DOWN
715# define SOL_MOVE_PRE BUTTON_VOL_UP
716# define SOL_MOVE (BUTTON_PLAY | BUTTON_REL)
717# define SOL_DRAW (BUTTON_POWER | BUTTON_REPEAT)
718# define SOL_REM2CUR (BUTTON_POWER | BUTTON_VOL_DOWN)
719# define SOL_CUR2STACK_PRE BUTTON_PLAY
720# define SOL_CUR2STACK (BUTTON_PLAY | BUTTON_REPEAT)
721# define SOL_REM2STACK (BUTTON_POWER | BUTTON_VOL_UP)
722# define HK_MOVE "PLAY"
723# define HK_DRAW "DBL POWER"
724# define HK_REM2CUR "POWER"
725# define HK_CUR2STACK "DBL PLAY"
726# define HK_REM2STACK "POWER+"
727
728#elif CONFIG_KEYPAD == IHIFI_800_PAD
729# define SOL_QUIT BUTTON_POWER
730# define SOL_UP BUTTON_PREV
731# define SOL_DOWN BUTTON_NEXT
732# define SOL_LEFT BUTTON_HOME
733# define SOL_RIGHT BUTTON_VOL_DOWN
734# define SOL_MOVE_PRE BUTTON_VOL_UP
735# define SOL_MOVE (BUTTON_PLAY | BUTTON_REL)
736# define SOL_DRAW (BUTTON_POWER | BUTTON_REPEAT)
737# define SOL_REM2CUR (BUTTON_POWER | BUTTON_VOL_DOWN)
738# define SOL_CUR2STACK_PRE BUTTON_PLAY
739# define SOL_CUR2STACK (BUTTON_PLAY | BUTTON_REPEAT)
740# define SOL_REM2STACK (BUTTON_POWER | BUTTON_VOL_UP)
741# define HK_MOVE "PLAY"
742# define HK_DRAW "DBL POWER"
743# define HK_REM2CUR "POWER"
744# define HK_CUR2STACK "DBL PLAY"
745# define HK_REM2STACK "POWER+"
746
709#else 747#else
710#error No keymap defined! 748#error No keymap defined!
711#endif 749#endif
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c
index ad03919861..15d4039b4d 100644
--- a/apps/plugins/spacerocks.c
+++ b/apps/plugins/spacerocks.c
@@ -363,6 +363,24 @@
363#define AST_RIGHT BUTTON_NEXT 363#define AST_RIGHT BUTTON_NEXT
364#define AST_FIRE BUTTON_PLAY 364#define AST_FIRE BUTTON_PLAY
365 365
366#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
367#define AST_PAUSE BUTTON_PLAY
368#define AST_QUIT BUTTON_POWER
369#define AST_THRUST BUTTON_NEXT
370#define AST_HYPERSPACE BUTTON_PREV
371#define AST_LEFT BUTTON_HOME
372#define AST_RIGHT BUTTON_VOL_DOWN
373#define AST_FIRE BUTTON_VOL_UP
374
375#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
376#define AST_PAUSE BUTTON_PLAY
377#define AST_QUIT BUTTON_POWER
378#define AST_THRUST BUTTON_NEXT
379#define AST_HYPERSPACE BUTTON_PREV
380#define AST_LEFT BUTTON_HOME
381#define AST_RIGHT BUTTON_VOL_DOWN
382#define AST_FIRE BUTTON_VOL_UP
383
366#else 384#else
367#error No keymap defined! 385#error No keymap defined!
368#endif 386#endif
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index bcddab8f20..fdf67bec4c 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -639,6 +639,38 @@
639#define STAR_LEVEL_DOWN_NAME "PLAY + PREV" 639#define STAR_LEVEL_DOWN_NAME "PLAY + PREV"
640#define STAR_LEVEL_REPEAT_NAME "PLAY + OPTION" 640#define STAR_LEVEL_REPEAT_NAME "PLAY + OPTION"
641 641
642#elif CONFIG_KEYPAD == IHIFI_770_PAD
643#define STAR_QUIT BUTTON_POWER
644#define STAR_LEFT BUTTON_HOME
645#define STAR_RIGHT BUTTON_VOL_DOWN
646#define STAR_UP BUTTON_PREV
647#define STAR_DOWN BUTTON_NEXT
648#define STAR_TOGGLE_CONTROL BUTTON_PLAY
649#define STAR_LEVEL_UP (BUTTON_POWER | BUTTON_VOL_UP)
650#define STAR_LEVEL_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
651#define STAR_LEVEL_REPEAT (BUTTON_POWER | BUTTON_HOME)
652#define STAR_TOGGLE_CONTROL_NAME "PLAY"
653#define STAR_QUIT_NAME "POWER"
654#define STAR_LEVEL_UP_NAME "POWER + VOL+"
655#define STAR_LEVEL_DOWN_NAME "POWER + VOL-"
656#define STAR_LEVEL_REPEAT_NAME "POWER + HOME"
657
658#elif CONFIG_KEYPAD == IHIFI_800_PAD
659#define STAR_QUIT BUTTON_POWER
660#define STAR_LEFT BUTTON_HOME
661#define STAR_RIGHT BUTTON_VOL_DOWN
662#define STAR_UP BUTTON_PREV
663#define STAR_DOWN BUTTON_NEXT
664#define STAR_TOGGLE_CONTROL BUTTON_PLAY
665#define STAR_LEVEL_UP (BUTTON_POWER | BUTTON_VOL_UP)
666#define STAR_LEVEL_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
667#define STAR_LEVEL_REPEAT (BUTTON_POWER | BUTTON_HOME)
668#define STAR_TOGGLE_CONTROL_NAME "PLAY"
669#define STAR_QUIT_NAME "POWER"
670#define STAR_LEVEL_UP_NAME "POWER + VOL+"
671#define STAR_LEVEL_DOWN_NAME "POWER + VOL-"
672#define STAR_LEVEL_REPEAT_NAME "POWER + HOME"
673
642#else 674#else
643#error No keymap defined! 675#error No keymap defined!
644#endif 676#endif
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c
index 69f14a20ef..5e83859d89 100644
--- a/apps/plugins/stopwatch.c
+++ b/apps/plugins/stopwatch.c
@@ -321,6 +321,22 @@
321#define STOPWATCH_SCROLL_UP BUTTON_HOME 321#define STOPWATCH_SCROLL_UP BUTTON_HOME
322#define STOPWATCH_SCROLL_DOWN BUTTON_OPTION 322#define STOPWATCH_SCROLL_DOWN BUTTON_OPTION
323 323
324#elif CONFIG_KEYPAD == IHIFI_770_PAD
325#define STOPWATCH_QUIT BUTTON_POWER
326#define STOPWATCH_START_STOP BUTTON_NEXT
327#define STOPWATCH_RESET_TIMER BUTTON_PREV
328#define STOPWATCH_LAP_TIMER BUTTON_PLAY
329#define STOPWATCH_SCROLL_UP BUTTON_VOL_UP
330#define STOPWATCH_SCROLL_DOWN BUTTON_VOL_DOWN
331
332#elif CONFIG_KEYPAD == IHIFI_800_PAD
333#define STOPWATCH_QUIT BUTTON_POWER
334#define STOPWATCH_START_STOP BUTTON_NEXT
335#define STOPWATCH_RESET_TIMER BUTTON_PREV
336#define STOPWATCH_LAP_TIMER BUTTON_PLAY
337#define STOPWATCH_SCROLL_UP BUTTON_VOL_UP
338#define STOPWATCH_SCROLL_DOWN BUTTON_VOL_DOWN
339
324#else 340#else
325#error No keymap defined! 341#error No keymap defined!
326#endif 342#endif
diff --git a/apps/plugins/sudoku/sudoku.h b/apps/plugins/sudoku/sudoku.h
index e26644a2d8..62ec80dba8 100644
--- a/apps/plugins/sudoku/sudoku.h
+++ b/apps/plugins/sudoku/sudoku.h
@@ -437,6 +437,34 @@
437#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL) 437#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL)
438#define SUDOKU_BUTTON_POSSIBLE (BUTTON_HOME | BUTTON_POWER) 438#define SUDOKU_BUTTON_POSSIBLE (BUTTON_HOME | BUTTON_POWER)
439 439
440#elif CONFIG_KEYPAD == IHIFI_770_PAD
441#define SUDOKU_BUTTON_QUIT_PRE BUTTON_POWER
442#define SUDOKU_BUTTON_QUIT (BUTTON_POWER | BUTTON_REPEAT)
443#define SUDOKU_BUTTON_UP BUTTON_PREV
444#define SUDOKU_BUTTON_DOWN BUTTON_NEXT
445#define SUDOKU_BUTTON_LEFT BUTTON_HOME
446#define SUDOKU_BUTTON_RIGHT BUTTON_VOL_DOWN
447#define SUDOKU_BUTTON_TOGGLEBACK (BUTTON_POWER | BUTTON_VOL_DOWN)
448#define SUDOKU_BUTTON_TOGGLE (BUTTON_POWER | BUTTON_VOL_UP)
449#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_PLAY
450#define SUDOKU_BUTTON_MENU_PRE BUTTON_POWER
451#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL)
452#define SUDOKU_BUTTON_POSSIBLE (BUTTON_POWER | BUTTON_HOME)
453
454#elif CONFIG_KEYPAD == IHIFI_800_PAD
455#define SUDOKU_BUTTON_QUIT_PRE BUTTON_POWER
456#define SUDOKU_BUTTON_QUIT (BUTTON_POWER | BUTTON_REPEAT)
457#define SUDOKU_BUTTON_UP BUTTON_PREV
458#define SUDOKU_BUTTON_DOWN BUTTON_NEXT
459#define SUDOKU_BUTTON_LEFT BUTTON_HOME
460#define SUDOKU_BUTTON_RIGHT BUTTON_VOL_DOWN
461#define SUDOKU_BUTTON_TOGGLEBACK (BUTTON_POWER | BUTTON_VOL_DOWN)
462#define SUDOKU_BUTTON_TOGGLE (BUTTON_POWER | BUTTON_VOL_UP)
463#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_PLAY
464#define SUDOKU_BUTTON_MENU_PRE BUTTON_POWER
465#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL)
466#define SUDOKU_BUTTON_POSSIBLE (BUTTON_POWER | BUTTON_HOME)
467
440#else 468#else
441#error No keymap defined! 469#error No keymap defined!
442#endif 470#endif
diff --git a/apps/plugins/text_viewer/tv_button.h b/apps/plugins/text_viewer/tv_button.h
index 58bce80eaf..da6453ff8d 100644
--- a/apps/plugins/text_viewer/tv_button.h
+++ b/apps/plugins/text_viewer/tv_button.h
@@ -562,6 +562,32 @@
562#define TV_LINE_DOWN BUTTON_OPTION 562#define TV_LINE_DOWN BUTTON_OPTION
563#define TV_BOOKMARK (BUTTON_OPTION | BUTTON_PLAY) 563#define TV_BOOKMARK (BUTTON_OPTION | BUTTON_PLAY)
564 564
565/* Xuelin 770/770c keys */
566#elif CONFIG_KEYPAD == IHIFI_770_PAD
567#define TV_QUIT BUTTON_POWER
568#define TV_SCROLL_UP BUTTON_VOL_UP
569#define TV_SCROLL_DOWN BUTTON_VOL_DOWN
570#define TV_SCREEN_LEFT BUTTON_PREV
571#define TV_SCREEN_RIGHT BUTTON_NEXT
572#define TV_MENU BUTTON_PLAY
573#define TV_AUTOSCROLL (BUTTON_POWER | BUTTON_HOME)
574#define TV_LINE_UP (BUTTON_POWER | BUTTON_VOL_UP)
575#define TV_LINE_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
576#define TV_BOOKMARK (BUTTON_POWER | BUTTON_PLAY)
577
578/* Xuelin 800 keys */
579#elif CONFIG_KEYPAD == IHIFI_800_PAD
580#define TV_QUIT BUTTON_POWER
581#define TV_SCROLL_UP BUTTON_VOL_UP
582#define TV_SCROLL_DOWN BUTTON_VOL_DOWN
583#define TV_SCREEN_LEFT BUTTON_PREV
584#define TV_SCREEN_RIGHT BUTTON_NEXT
585#define TV_MENU BUTTON_PLAY
586#define TV_AUTOSCROLL (BUTTON_POWER | BUTTON_HOME)
587#define TV_LINE_UP (BUTTON_POWER | BUTTON_VOL_UP)
588#define TV_LINE_DOWN (BUTTON_POWER | BUTTON_VOL_DOWN)
589#define TV_BOOKMARK (BUTTON_POWER | BUTTON_PLAY)
590
565#else 591#else
566#error No keymap defined! 592#error No keymap defined!
567#endif 593#endif
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index 04876ba198..eaa92d4b48 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -432,6 +432,28 @@
432#define LABEL_MENU "PLAY" 432#define LABEL_MENU "PLAY"
433#define LABEL_VOLUME "VOL UP/DN" 433#define LABEL_VOLUME "VOL UP/DN"
434 434
435#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
436#define VUMETER_QUIT BUTTON_POWER
437#define VUMETER_HELP BUTTON_HOME
438#define VUMETER_MENU BUTTON_PLAY
439#define VUMETER_UP BUTTON_VOL_UP
440#define VUMETER_DOWN BUTTON_VOL_DOWN
441#define LABEL_HELP "HOME"
442#define LABEL_QUIT "POWER"
443#define LABEL_MENU "PLAY"
444#define LABEL_VOLUME "VOL UP/DN"
445
446#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
447#define VUMETER_QUIT BUTTON_POWER
448#define VUMETER_HELP BUTTON_HOME
449#define VUMETER_MENU BUTTON_PLAY
450#define VUMETER_UP BUTTON_VOL_UP
451#define VUMETER_DOWN BUTTON_VOL_DOWN
452#define LABEL_HELP "HOME"
453#define LABEL_QUIT "POWER"
454#define LABEL_MENU "PLAY"
455#define LABEL_VOLUME "VOL UP/DN"
456
435#else 457#else
436#error No keymap defined! 458#error No keymap defined!
437#endif 459#endif
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c
index 83cfadc338..8c12862bdb 100644
--- a/apps/plugins/wormlet.c
+++ b/apps/plugins/wormlet.c
@@ -402,6 +402,24 @@ CONFIG_KEYPAD == MROBE500_PAD
402#define BTN_QUIT BUTTON_POWER 402#define BTN_QUIT BUTTON_POWER
403#define BTN_STOPRESET (BUTTON_HOME | BUTTON_POWER) 403#define BTN_STOPRESET (BUTTON_HOME | BUTTON_POWER)
404 404
405#elif CONFIG_KEYPAD == IHIFI_770_PAD
406#define BTN_DIR_UP BUTTON_PREV
407#define BTN_DIR_DOWN BUTTON_NEXT
408#define BTN_DIR_LEFT BUTTON_HOME
409#define BTN_DIR_RIGHT BUTTON_VOL_DOWN
410#define BTN_STARTPAUSE BUTTON_PLAY
411#define BTN_QUIT BUTTON_POWER
412#define BTN_STOPRESET BUTTON_VOL_UP
413
414#elif CONFIG_KEYPAD == IHIFI_800_PAD
415#define BTN_DIR_UP BUTTON_PREV
416#define BTN_DIR_DOWN BUTTON_NEXT
417#define BTN_DIR_LEFT BUTTON_HOME
418#define BTN_DIR_RIGHT BUTTON_VOL_DOWN
419#define BTN_STARTPAUSE BUTTON_PLAY
420#define BTN_QUIT BUTTON_POWER
421#define BTN_STOPRESET BUTTON_VOL_UP
422
405#else 423#else
406#error No keymap defined! 424#error No keymap defined!
407#endif 425#endif
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 9b41e2d1ac..8acdf85015 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -351,6 +351,24 @@ CONFIG_KEYPAD == MROBE500_PAD
351#define DOWN BUTTON_OPTION 351#define DOWN BUTTON_OPTION
352#define PAUSE BUTTON_PLAY 352#define PAUSE BUTTON_PLAY
353 353
354#elif CONFIG_KEYPAD == IHIFI_770_PAD
355
356#define QUIT BUTTON_POWER
357#define LEFT BUTTON_HOME
358#define RIGHT BUTTON_VOL_DOWN
359#define UP BUTTON_PREV
360#define DOWN BUTTON_NEXT
361#define PAUSE BUTTON_PLAY
362
363#elif CONFIG_KEYPAD == IHIFI_800_PAD
364
365#define QUIT BUTTON_POWER
366#define LEFT BUTTON_HOME
367#define RIGHT BUTTON_VOL_DOWN
368#define UP BUTTON_PREV
369#define DOWN BUTTON_NEXT
370#define PAUSE BUTTON_PLAY
371
354#else 372#else
355#error No keymap defined! 373#error No keymap defined!
356#endif 374#endif
diff --git a/apps/plugins/zxbox/keymaps.h b/apps/plugins/zxbox/keymaps.h
index ebdd41734e..ce527c561e 100644
--- a/apps/plugins/zxbox/keymaps.h
+++ b/apps/plugins/zxbox/keymaps.h
@@ -290,6 +290,22 @@
290#define ZX_UP BUTTON_HOME 290#define ZX_UP BUTTON_HOME
291#define ZX_DOWN BUTTON_OPTION 291#define ZX_DOWN BUTTON_OPTION
292 292
293#elif CONFIG_KEYPAD == IHIFI_770_PAD
294#define ZX_SELECT BUTTON_PLAY
295#define ZX_MENU BUTTON_POWER
296#define ZX_LEFT BUTTON_HOME
297#define ZX_RIGHT BUTTON_VOL_DOWN
298#define ZX_UP BUTTON_PREV
299#define ZX_DOWN BUTTON_NEXT
300
301#elif CONFIG_KEYPAD == IHIFI_800_PAD
302#define ZX_SELECT BUTTON_PLAY
303#define ZX_MENU BUTTON_POWER
304#define ZX_LEFT BUTTON_HOME
305#define ZX_RIGHT BUTTON_VOL_DOWN
306#define ZX_UP BUTTON_PREV
307#define ZX_DOWN BUTTON_NEXT
308
293#else 309#else
294#error Keymap not defined! 310#error Keymap not defined!
295 311
diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c
index f38712d8d1..b3f1ca70e8 100644
--- a/apps/plugins/zxbox/zxbox_keyb.c
+++ b/apps/plugins/zxbox/zxbox_keyb.c
@@ -287,6 +287,24 @@
287#define KBD_UP BUTTON_HOME 287#define KBD_UP BUTTON_HOME
288#define KBD_DOWN BUTTON_OPTION 288#define KBD_DOWN BUTTON_OPTION
289 289
290#elif CONFIG_KEYPAD == IHIFI_770_PAD
291
292#define KBD_SELECT BUTTON_PLAY
293#define KBD_ABORT BUTTON_POWER
294#define KBD_LEFT BUTTON_HOME
295#define KBD_RIGHT BUTTON_VOL_DOWN
296#define KBD_UP BUTTON_PREV
297#define KBD_DOWN BUTTON_NEXT
298
299#elif CONFIG_KEYPAD == IHIFI_800_PAD
300
301#define KBD_SELECT BUTTON_PLAY
302#define KBD_ABORT BUTTON_POWER
303#define KBD_LEFT BUTTON_HOME
304#define KBD_RIGHT BUTTON_VOL_DOWN
305#define KBD_UP BUTTON_PREV
306#define KBD_DOWN BUTTON_NEXT
307
290#endif 308#endif
291 309
292#ifdef HAVE_TOUCHSCREEN 310#ifdef HAVE_TOUCHSCREEN
diff --git a/apps/settings.h b/apps/settings.h
index d0257b51e6..05ad948c0d 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -642,7 +642,6 @@ struct user_settings
642#ifdef HAVE_USB_CHARGING_ENABLE 642#ifdef HAVE_USB_CHARGING_ENABLE
643 int usb_charging; 643 int usb_charging;
644#endif 644#endif
645
646 /* device settings */ 645 /* device settings */
647#ifdef HAVE_LCD_CONTRAST 646#ifdef HAVE_LCD_CONTRAST
648 int contrast; /* lcd contrast */ 647 int contrast; /* lcd contrast */
diff --git a/apps/settings_list.c b/apps/settings_list.c
index eb3c76865d..1c41954390 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -876,8 +876,13 @@ const struct settings_list settings[] = {
876 876
877#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF 877#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
878 CHOICE_SETTING(F_SOUNDSETTING, roll_off, LANG_FILTER_ROLL_OFF, 0, 878 CHOICE_SETTING(F_SOUNDSETTING, roll_off, LANG_FILTER_ROLL_OFF, 0,
879#ifndef AUDIOHW_HAVE_SHORT_ROLL_OFF
879 "roll_off", "sharp,slow", sound_set_filter_roll_off, 880 "roll_off", "sharp,slow", sound_set_filter_roll_off,
880 2, ID2P(LANG_FILTER_SHARP), ID2P(LANG_FILTER_SLOW)), 881 2, ID2P(LANG_FILTER_SHARP), ID2P(LANG_FILTER_SLOW)),
882#else
883 "roll_off", "sharp,slow,short,bypass", sound_set_filter_roll_off,
884 4, ID2P(LANG_FILTER_SHARP), ID2P(LANG_FILTER_SLOW), ID2P(LANG_FILTER_SHORT), ID2P(LANG_FILTER_BYPASS)),
885#endif
881#endif 886#endif
882 887
883 /* playback */ 888 /* playback */
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index 0b39da153a..ce73724f69 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -80,7 +80,8 @@ nwz_linux.c
80rocker_linux.c 80rocker_linux.c
81#elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \ 81#elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \
82 || defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \ 82 || defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \
83 || defined(IHIFI760) || defined(IHIFI960) 83 || defined(IHIFI760) || defined(IHIFI960) || defined(IHIFI800) \
84 || defined(IHIFI770) || defined(IHIFI770C)
84rk27xx.c 85rk27xx.c
85show_logo.c 86show_logo.c
86#elif defined(SANSA_CONNECT) 87#elif defined(SANSA_CONNECT)
diff --git a/bootloader/common.c b/bootloader/common.c
index 5c5647ac64..03c1bf9964 100644
--- a/bootloader/common.c
+++ b/bootloader/common.c
@@ -54,7 +54,8 @@
54 || defined(SAMSUNG_YH820) || defined(PHILIPS_SA9200) \ 54 || defined(SAMSUNG_YH820) || defined(PHILIPS_SA9200) \
55 || defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) \ 55 || defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) \
56 || defined(ONDA_VX747) || defined(PBELL_VIBE500) \ 56 || defined(ONDA_VX747) || defined(PBELL_VIBE500) \
57 || defined(TOSHIBA_GIGABEAT_S) || defined(XDUOO_X3) 57 || defined(TOSHIBA_GIGABEAT_S) || defined(XDUOO_X3) \
58 || defined(IHIFI770) || defined(IHIFI770C) || defined(IHIFI800)
58bool verbose = false; 59bool verbose = false;
59#else 60#else
60bool verbose = true; 61bool verbose = true;
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 33d59fa429..16ae4cc350 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -442,6 +442,8 @@ drivers/audio/audiohw-swcodec.c
442#if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER) 442#if (CONFIG_PLATFORM & PLATFORM_NATIVE) && !defined(BOOTLOADER)
443#if defined(HAVE_UDA1380) 443#if defined(HAVE_UDA1380)
444drivers/audio/uda1380.c 444drivers/audio/uda1380.c
445#elif defined(HAVE_WM8740)
446drivers/audio/wm8740.c
445#elif defined(HAVE_WM8751) \ 447#elif defined(HAVE_WM8751) \
446 || defined(HAVE_WM8750) 448 || defined(HAVE_WM8750)
447drivers/audio/wm8751.c 449drivers/audio/wm8751.c
@@ -481,6 +483,8 @@ drivers/audio/df1704.c
481drivers/audio/pcm1792.c 483drivers/audio/pcm1792.c
482#elif defined (HAVE_CS4398) 484#elif defined (HAVE_CS4398)
483drivers/audio/cs4398.c 485drivers/audio/cs4398.c
486#elif defined (HAVE_ES9018)
487drivers/audio/es9018.c
484#endif /* defined(HAVE_*) */ 488#endif /* defined(HAVE_*) */
485#else /* PLATFORM_HOSTED */ 489#else /* PLATFORM_HOSTED */
486#if defined(SAMSUNG_YPR0) && defined(HAVE_AS3514) 490#if defined(SAMSUNG_YPR0) && defined(HAVE_AS3514)
@@ -791,6 +795,12 @@ target/arm/s3c2440/lcd-s3c2440.c
791target/arm/rk27xx/ma/lcd-ma.c 795target/arm/rk27xx/ma/lcd-ma.c
792#elif CONFIG_LCD == LCD_IHIFI 796#elif CONFIG_LCD == LCD_IHIFI
793target/arm/rk27xx/ihifi/lcd-ihifi.c 797target/arm/rk27xx/ihifi/lcd-ihifi.c
798#elif CONFIG_LCD == LCD_IHIFI770
799target/arm/rk27xx/ihifi2/lcd-ihifi770.c
800#elif CONFIG_LCD == LCD_IHIFI770C
801target/arm/rk27xx/ihifi2/lcd-ihifi770c.c
802#elif CONFIG_LCD == LCD_IHIFI800
803target/arm/rk27xx/ihifi2/lcd-ihifi800.c
794#endif 804#endif
795 805
796/* USB Stack */ 806/* USB Stack */
@@ -1904,6 +1914,21 @@ target/arm/rk27xx/ihifi/powermgmt-ihifi960.c
1904#endif 1914#endif
1905#endif 1915#endif
1906 1916
1917#if defined(IHIFI770) || defined(IHIFI770C) || defined(IHIFI800)
1918target/arm/rk27xx/ihifi2/button-ihifi.c
1919target/arm/rk27xx/ihifi2/power-ihifi.c
1920#if defined(IHIFI770)
1921target/arm/rk27xx/ihifi2/powermgmt-ihifi770.c
1922target/arm/rk27xx/ihifi2/audio-ihifi770.c
1923#elif defined(IHIFI770C)
1924target/arm/rk27xx/ihifi2/powermgmt-ihifi770c.c
1925target/arm/rk27xx/ihifi2/audio-ihifi770.c
1926#elif defined(IHIFI800)
1927target/arm/rk27xx/ihifi2/powermgmt-ihifi800.c
1928target/arm/rk27xx/ihifi2/audio-ihifi800.c
1929#endif
1930#endif
1931
1907#if (CONFIG_PLATFORM & PLATFORM_ANDROID) 1932#if (CONFIG_PLATFORM & PLATFORM_ANDROID)
1908target/hosted/kernel-unix.c 1933target/hosted/kernel-unix.c
1909target/hosted/filesystem-unix.c 1934target/hosted/filesystem-unix.c
diff --git a/firmware/drivers/audio/es9018.c b/firmware/drivers/audio/es9018.c
new file mode 100644
index 0000000000..89e8c1d46f
--- /dev/null
+++ b/firmware/drivers/audio/es9018.c
@@ -0,0 +1,134 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "system.h"
23#include "es9018.h"
24#include "config.h"
25#include "audio.h"
26#include "audiohw.h"
27
28/* NOTE: The register names are not known, as the register numbering
29 listed in the ES9018 datasheet does not match what is described below.. */
30
31static uint8_t reg0 = 0x00; /* System settings. Default value of register 0 */
32static uint8_t reg1 = 0x80; /* Input settings. Manual input, I2S, 32-bit (?) */
33static uint8_t reg4 = 0x00; /* Automute time. Default = disabled */
34static uint8_t reg5 = 0x68; /* Automute level. Default is some level */
35static uint8_t reg6 = 0x4A; /* Deemphasis. Default = disabled */
36static uint8_t reg7 = 0x83; /* General settings. Default sharp fir, pcm iir and muted */
37static uint8_t reg8 = 0x10; /* GPIO configuration */
38static uint8_t reg10 = 0x05; /* Master Mode Control. Default value: master mode off */
39static uint8_t reg11 = 0x02; /* Channel Mapping. Default stereo is Ch1=left, Ch2=right */
40static uint8_t reg12 = 0x50; /* DPLL Settings. Default = 005 for I2S, OFF for DSD */
41static uint8_t reg13 = 0x40; /* THD Compensation */
42static uint8_t reg14 = 0x8A; /* Soft Start Settings */
43static uint8_t reg21 = 0x00; /* Oversampling filter. Default: oversampling ON */
44
45#define bitSet(value, bit) ((value) |= (1UL << (bit)))
46#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
47
48static int vol_tenthdb2hw(const int tdb)
49{
50 if (tdb < ES9018_VOLUME_MIN) {
51 return 0xff;
52 } else if (tdb > ES9018_VOLUME_MAX) {
53 return 0x00;
54 } else {
55 return (-tdb/5);
56 }
57}
58
59void audiohw_set_volume(int vol_l, int vol_r)
60{
61 es9018_write_reg(15, vol_tenthdb2hw(vol_l));
62 es9018_write_reg(16, vol_tenthdb2hw(vol_r));
63}
64
65void audiohw_mute(void)
66{
67 bitSet(reg7, 0); /* Mute Channel 1 */
68 bitSet(reg7, 1); /* Mute Channel 2 */
69 es9018_write_reg(0x07, reg7);
70}
71
72void audiohw_unmute(void)
73{
74 bitClear(reg7, 0); /* Unmute Channel 1 */
75 bitClear(reg7, 1); /* Unmute Channel 2 */
76 es9018_write_reg(0x07, reg7);
77}
78
79void audiohw_init(void)
80{
81 es9018_write_reg(0x00, reg0);
82 es9018_write_reg(0x01, reg1);
83 es9018_write_reg(0x04, reg4);
84 es9018_write_reg(0x05, reg5);
85 es9018_write_reg(0x06, reg6);
86 es9018_write_reg(0x07, reg7);
87 es9018_write_reg(0x08, reg8);
88 es9018_write_reg(0x0A, reg10);
89 es9018_write_reg(0x0B, reg11);
90 es9018_write_reg(0x0C, reg12);
91 es9018_write_reg(0x0D, reg13);
92 es9018_write_reg(0x0E, reg14);
93 es9018_write_reg(0x15, reg21);
94}
95
96void audiohw_preinit(void)
97{
98}
99
100void audiohw_set_frequency(int fsel)
101{
102 (void)fsel;
103}
104
105void audiohw_set_filter_roll_off(int value)
106{
107 /* 0 = Sharp (Default)
108 1 = Slow
109 2 = Short
110 3 = Bypass */
111 switch(value)
112 {
113 case 0:
114 bitClear(reg7, 5);
115 bitClear(reg7, 6);
116 bitClear(reg21, 0);
117 break;
118 case 1:
119 bitSet(reg7, 5);
120 bitClear(reg7, 6);
121 bitClear(reg21, 0);
122 break;
123 case 2:
124 bitClear(reg7, 5);
125 bitSet(reg7, 6);
126 bitClear(reg21, 0);
127 break;
128 case 3:
129 bitSet(reg21, 0);
130 break;
131 }
132 es9018_write_reg(0x07, reg7);
133 es9018_write_reg(0x15, reg21);
134}
diff --git a/firmware/drivers/audio/wm8740.c b/firmware/drivers/audio/wm8740.c
new file mode 100644
index 0000000000..d88f53bd75
--- /dev/null
+++ b/firmware/drivers/audio/wm8740.c
@@ -0,0 +1,106 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "system.h"
23#include "wm8740.h"
24#include "config.h"
25#include "audio.h"
26#include "audiohw.h"
27
28static void wm8740_write_reg(const int reg, const unsigned int value)
29{
30 int i;
31
32 for (i = (1<<15); i; i >>= 1) {
33 udelay(1);
34 wm8740_set_mc(0);
35 if ((reg|value) & i) {
36 wm8740_set_md(1);
37 } else {
38 wm8740_set_md(0);
39 }
40 udelay(1);
41 wm8740_set_mc(1);
42 }
43 udelay(1);
44 wm8740_set_ml(0);
45 udelay(1);
46 wm8740_set_mc(0);
47 udelay(1);
48 wm8740_set_ml(1);
49 udelay(1);
50}
51
52static int vol_tenthdb2hw(const int tdb)
53{
54 if (tdb < WM8740_VOLUME_MIN) {
55 return 0x00;
56 } else if (tdb > WM8740_VOLUME_MAX) {
57 return 0xff;
58 } else {
59 return ((tdb / 5 + 0xff) & 0xff);
60 }
61}
62
63void audiohw_set_volume(int vol_l, int vol_r)
64{
65 wm8740_write_reg(WM8740_REG0, vol_tenthdb2hw(vol_l));
66 wm8740_write_reg(WM8740_REG1, vol_tenthdb2hw(vol_r) | WM8740_LDR);
67}
68
69void audiohw_mute(void)
70{
71 wm8740_write_reg(WM8740_REG2, WM8740_MUT);
72}
73
74void audiohw_unmute(void)
75{
76 wm8740_write_reg(WM8740_REG2, 0x00);
77}
78
79void audiohw_init(void)
80{
81 wm8740_write_reg(WM8740_REG0, 0x00);
82 wm8740_write_reg(WM8740_REG1, 0x00);
83 wm8740_write_reg(WM8740_REG2, WM8740_MUT);
84 wm8740_write_reg(WM8740_REG3, WM8740_I2S);
85 wm8740_write_reg(WM8740_REG4, 0x00);
86}
87
88void audiohw_preinit(void)
89{
90}
91
92void audiohw_set_frequency(int fsel)
93{
94 (void)fsel;
95}
96
97void audiohw_set_filter_roll_off(int value)
98{
99 /* 0 = fast (sharp);
100 1 = slow */
101 if (value == 0) {
102 wm8740_write_reg(WM8740_REG3, WM8740_I2S);
103 } else {
104 wm8740_write_reg(WM8740_REG3, WM8740_I2S | WM8740_SR0);
105 }
106}
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 09001c8045..458fba3412 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -165,6 +165,8 @@ struct sound_settings_info
165#include "uda1380.h" 165#include "uda1380.h"
166#elif defined(HAVE_UDA1341) 166#elif defined(HAVE_UDA1341)
167#include "uda1341.h" 167#include "uda1341.h"
168#elif defined(HAVE_WM8740)
169#include "wm8740.h"
168#elif defined(HAVE_WM8750) || defined(HAVE_WM8751) 170#elif defined(HAVE_WM8750) || defined(HAVE_WM8751)
169#include "wm8751.h" 171#include "wm8751.h"
170#elif defined(HAVE_WM8978) 172#elif defined(HAVE_WM8978)
@@ -211,6 +213,8 @@ struct sound_settings_info
211#include "nwzlinux_codec.h" 213#include "nwzlinux_codec.h"
212#elif defined(HAVE_CS4398) 214#elif defined(HAVE_CS4398)
213#include "cs4398.h" 215#include "cs4398.h"
216#elif defined(HAVE_ES9018)
217#include "es9018.h"
214#elif (CONFIG_PLATFORM & (PLATFORM_ANDROID | PLATFORM_MAEMO\ 218#elif (CONFIG_PLATFORM & (PLATFORM_ANDROID | PLATFORM_MAEMO\
215 | PLATFORM_PANDORA | PLATFORM_SDL)) 219 | PLATFORM_PANDORA | PLATFORM_SDL))
216#include "hosted_codec.h" 220#include "hosted_codec.h"
@@ -571,7 +575,7 @@ void audiohw_set_depth_3d(int val);
571#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF 575#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
572/** 576/**
573 * Set DAC's oversampling filter roll-off. 577 * Set DAC's oversampling filter roll-off.
574 * @param val 0 - sharp roll-off, 1 - slow roll-off. 578 * @param val 0 - sharp roll-off, 1 - slow roll-off, 2 - short roll-off, 3 - bypass.
575 * NOTE: AUDIOHW_CAPS need to contain 579 * NOTE: AUDIOHW_CAPS need to contain
576 * FILTER_ROLL_OFF_CAP 580 * FILTER_ROLL_OFF_CAP
577 */ 581 */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 8b177963d3..2db12bea4a 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -169,6 +169,8 @@
169#define SONY_NWZA860_PAD 64 /* The NWZ-A860 is too different (touchscreen) */ 169#define SONY_NWZA860_PAD 64 /* The NWZ-A860 is too different (touchscreen) */
170#define AGPTEK_ROCKER_PAD 65 170#define AGPTEK_ROCKER_PAD 65
171#define XDUOO_X3_PAD 66 171#define XDUOO_X3_PAD 66
172#define IHIFI_770_PAD 67
173#define IHIFI_800_PAD 68
172 174
173/* CONFIG_REMOTE_KEYPAD */ 175/* CONFIG_REMOTE_KEYPAD */
174#define H100_REMOTE 1 176#define H100_REMOTE 1
@@ -284,6 +286,9 @@
284#define LCD_NWZ_LINUX 63 /* as used in the Linux-based NWZ series */ 286#define LCD_NWZ_LINUX 63 /* as used in the Linux-based NWZ series */
285#define LCD_INGENIC_LINUX 64 287#define LCD_INGENIC_LINUX 64
286#define LCD_XDUOOX3 65 /* as used by the xDuoo X3 */ 288#define LCD_XDUOOX3 65 /* as used by the xDuoo X3 */
289#define LCD_IHIFI770 66 /* as used by IHIFI 770 */
290#define LCD_IHIFI770C 67 /* as used by IHIFI 770C */
291#define LCD_IHIFI800 68 /* as used by IHIFI 800 */
287 292
288/* LCD_PIXELFORMAT */ 293/* LCD_PIXELFORMAT */
289#define HORIZONTAL_PACKING 1 294#define HORIZONTAL_PACKING 1
@@ -581,6 +586,12 @@ Lyre prototype 1 */
581#include "config/samsungypz5.h" 586#include "config/samsungypz5.h"
582#elif defined(IHIFI760) 587#elif defined(IHIFI760)
583#include "config/ihifi760.h" 588#include "config/ihifi760.h"
589#elif defined(IHIFI770)
590#include "config/ihifi770.h"
591#elif defined(IHIFI770C)
592#include "config/ihifi770c.h"
593#elif defined(IHIFI800)
594#include "config/ihifi800.h"
584#elif defined(IHIFI960) 595#elif defined(IHIFI960)
585#include "config/ihifi960.h" 596#include "config/ihifi960.h"
586#elif defined(CREATIVE_ZENXFISTYLE) 597#elif defined(CREATIVE_ZENXFISTYLE)
@@ -974,7 +985,6 @@ Lyre prototype 1 */
974#define USB_STATUS_BY_EVENT 985#define USB_STATUS_BY_EVENT
975#define USB_DETECT_BY_REQUEST 986#define USB_DETECT_BY_REQUEST
976#elif CONFIG_USBOTG == USBOTG_RK27XX 987#elif CONFIG_USBOTG == USBOTG_RK27XX
977#define USB_STATUS_BY_EVENT
978#define USB_DETECT_BY_REQUEST 988#define USB_DETECT_BY_REQUEST
979#endif /* CONFIG_USB == */ 989#endif /* CONFIG_USB == */
980#endif /* HAVE_USBSTACK */ 990#endif /* HAVE_USBSTACK */
@@ -1193,7 +1203,7 @@ Lyre prototype 1 */
1193#endif /* HAVE_USB_CHARGING_ENABLE && HAVE_USBSTACK */ 1203#endif /* HAVE_USB_CHARGING_ENABLE && HAVE_USBSTACK */
1194 1204
1195#ifndef SIMULATOR 1205#ifndef SIMULATOR
1196#if defined(HAVE_USBSTACK) || (CONFIG_STORAGE & STORAGE_NAND) 1206#if defined(HAVE_USBSTACK) || (CONFIG_STORAGE & STORAGE_NAND) || (CONFIG_STORAGE & STORAGE_RAMDISK)
1197#define STORAGE_GET_INFO 1207#define STORAGE_GET_INFO
1198#endif 1208#endif
1199#endif 1209#endif
@@ -1211,7 +1221,8 @@ Lyre prototype 1 */
1211 (CONFIG_USBOTG == USBOTG_JZ4760) || \ 1221 (CONFIG_USBOTG == USBOTG_JZ4760) || \
1212 (CONFIG_USBOTG == USBOTG_M66591) || \ 1222 (CONFIG_USBOTG == USBOTG_M66591) || \
1213 (CONFIG_USBOTG == USBOTG_DESIGNWARE) || \ 1223 (CONFIG_USBOTG == USBOTG_DESIGNWARE) || \
1214 (CONFIG_USBOTG == USBOTG_AS3525) 1224 (CONFIG_USBOTG == USBOTG_AS3525) || \
1225 (CONFIG_USBOTG == USBOTG_RK27XX)
1215#define USB_HAS_BULK 1226#define USB_HAS_BULK
1216#define USB_HAS_INTERRUPT 1227#define USB_HAS_INTERRUPT
1217#elif defined(CPU_TCC780X) || defined(CPU_TCC77X) 1228#elif defined(CPU_TCC780X) || defined(CPU_TCC77X)
diff --git a/firmware/export/config/ihifi770.h b/firmware/export/config/ihifi770.h
new file mode 100644
index 0000000000..af7acff206
--- /dev/null
+++ b/firmware/export/config/ihifi770.h
@@ -0,0 +1,197 @@
1/*
2 * This config file is for IHIFI 770
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 108
7
8#define MODEL_NAME "IHIFI 770"
9
10/* Define bitmask of input sources - recordable bitmask can be defined
11 explicitly if different */
12/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
13
14/* define the bitmask of hardware sample rates */
15#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_48 | SAMPR_CAP_44 | \
16 SAMPR_CAP_32 | SAMPR_CAP_24 | SAMPR_CAP_22 | \
17 SAMPR_CAP_16 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
18
19#define HAVE_WM8740
20#define CODEC_SLAVE
21
22/* define this if you have a bitmap LCD display */
23#define HAVE_LCD_BITMAP
24
25/* define this if you can flip your LCD */
26/* #define HAVE_LCD_FLIP */
27
28/* define this if you have a colour LCD */
29#define HAVE_LCD_COLOR
30
31/* define this if you want album art for this target */
32#define HAVE_ALBUMART
33
34/* define this to enable bitmap scaling */
35#define HAVE_BMP_SCALING
36
37/* define this to enable JPEG decoding */
38#define HAVE_JPEG
39
40/* define this if you can invert the colours on your LCD */
41/* #define HAVE_LCD_INVERT */
42
43/* define this if you have access to the quickscreen */
44#define HAVE_QUICKSCREEN
45
46/* define this if you would like tagcache to build on this target */
47#define HAVE_TAGCACHE
48
49/* define this if you have a flash memory storage */
50#define HAVE_FLASH_STORAGE
51
52#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
53
54#define CONFIG_NAND NAND_RK27XX
55#define HAVE_SW_TONE_CONTROLS
56
57#define HAVE_HOTSWAP
58
59#define NUM_DRIVES 1
60#define SECTOR_SIZE 512
61
62/* for small(ish) SD cards */
63#define HAVE_FAT16SUPPORT
64
65/* LCD dimensions */
66#define LCD_WIDTH 320
67#define LCD_HEIGHT 240
68/* sqrt(320^2 + 240^2) / 2.4 = 166.7 */
69#define LCD_DPI 167
70#define LCD_DEPTH 16 /* pseudo 262.144 colors */
71#define LCD_PIXELFORMAT RGB565 /* rgb565 */
72
73/* Define this if the LCD can shut down */
74/* #define HAVE_LCD_SHUTDOWN */
75
76/* Define this if your LCD can be enabled/disabled */
77#define HAVE_LCD_ENABLE
78
79/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
80 should be defined as well. */
81#ifndef BOOTLOADER
82/* TODO: #define HAVE_LCD_SLEEP */
83/* TODO: #define HAVE_LCD_SLEEP_SETTING */
84#endif
85
86#define CONFIG_KEYPAD IHIFI_770_PAD
87
88/* define this if the target has volume keys which can be used in the lists */
89#define HAVE_VOLUME_IN_LIST
90
91/* Define this if a programmable hotkey is mapped */
92/* #define HAVE_HOTKEY */
93
94/* Define this if you do software codec */
95#define CONFIG_CODEC SWCODEC
96
97/* define this if you have a real-time clock */
98/* #define CONFIG_RTC RTC_NANO2G */
99
100/* Define if the device can wake from an RTC alarm */
101/* #define HAVE_RTC_ALARM */
102
103/* Define the type of audio codec */
104/*#define HAVE_RK27XX_CODEC */
105
106/* #define HAVE_PCM_DMA_ADDRESS */
107
108/* Define this for LCD backlight available */
109#define HAVE_BACKLIGHT
110#define HAVE_BACKLIGHT_BRIGHTNESS
111#define MIN_BRIGHTNESS_SETTING 0
112#define MAX_BRIGHTNESS_SETTING 31
113#define DEFAULT_BRIGHTNESS_SETTING 31
114#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
115
116/* Define this if you have a software controlled poweroff */
117#define HAVE_SW_POWEROFF
118
119/* The number of bytes reserved for loadable codecs */
120#define CODEC_SIZE 0x100000
121
122/* The number of bytes reserved for loadable plugins */
123#define PLUGIN_BUFFER_SIZE 0x80000
124
125#define BATTERY_CAPACITY_DEFAULT 1050 /* default battery capacity */
126#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */
127#define BATTERY_CAPACITY_MAX 1050 /* max. capacity selectable */
128#define BATTERY_CAPACITY_INC 10 /* capacity increment */
129#define BATTERY_TYPES_COUNT 1 /* only one type */
130
131#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
132
133/* Hardware controlled charging with monitoring */
134#define CONFIG_CHARGING CHARGING_MONITOR
135
136/* define current usage levels */
137/* TODO: #define CURRENT_NORMAL
138 * TODO: #define CURRENT_BACKLIGHT 23
139 */
140
141/* define this if the unit can be powered or charged via USB */
142#define HAVE_USB_POWER
143
144/* Define this if your LCD can set contrast */
145/* #define HAVE_LCD_CONTRAST */
146
147/* Offset ( in the firmware file's header ) to the file CRC */
148#define FIRMWARE_OFFSET_FILE_CRC 0
149
150/* Offset ( in the firmware file's header ) to the real data */
151#define FIRMWARE_OFFSET_FILE_DATA 8
152
153#define STORAGE_NEEDS_ALIGN
154
155/* Define this if you have adjustable CPU frequency */
156#define HAVE_ADJUSTABLE_CPU_FREQ
157
158/* Virtual LED (icon) */
159#define CONFIG_LED LED_VIRTUAL
160
161/** Non-simulator section **/
162#ifndef SIMULATOR
163
164/* The exact type of CPU */
165#define CONFIG_CPU RK27XX
166
167/* Define this to the CPU frequency */
168#define CPU_FREQ 200000000
169
170/* I2C interface */
171#define CONFIG_I2C I2C_RK27XX
172
173/* define this if the hardware can be powered off while charging */
174/* #define HAVE_POWEROFF_WHILE_CHARGING */
175
176/* Type of LCD */
177#define CONFIG_LCD LCD_IHIFI770
178
179/* USB On-the-go */
180#define CONFIG_USBOTG USBOTG_RK27XX
181
182/* enable these for the experimental usb stack */
183#define HAVE_USBSTACK
184
185#define USB_VENDOR_ID 0x071b
186#define USB_PRODUCT_ID 0x3202
187#define HAVE_BOOTLOADER_USB_MODE
188
189#define RKW_FORMAT
190#define BOOTFILE_EXT "rkw"
191#define BOOTFILE "rockbox." BOOTFILE_EXT
192#define BOOTDIR "/.rockbox"
193
194/* disabled for now */
195#undef HAVE_HOTSWAP
196
197#endif /* SIMULATOR */
diff --git a/firmware/export/config/ihifi770c.h b/firmware/export/config/ihifi770c.h
new file mode 100644
index 0000000000..c4058f337b
--- /dev/null
+++ b/firmware/export/config/ihifi770c.h
@@ -0,0 +1,197 @@
1/*
2 * This config file is for IHIFI 770C
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 108
7
8#define MODEL_NAME "IHIFI 770C"
9
10/* Define bitmask of input sources - recordable bitmask can be defined
11 explicitly if different */
12/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
13
14/* define the bitmask of hardware sample rates */
15#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_48 | SAMPR_CAP_44 | \
16 SAMPR_CAP_32 | SAMPR_CAP_24 | SAMPR_CAP_22 | \
17 SAMPR_CAP_16 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
18
19#define HAVE_WM8740
20#define CODEC_SLAVE
21
22/* define this if you have a bitmap LCD display */
23#define HAVE_LCD_BITMAP
24
25/* define this if you can flip your LCD */
26/* #define HAVE_LCD_FLIP */
27
28/* define this if you have a colour LCD */
29#define HAVE_LCD_COLOR
30
31/* define this if you want album art for this target */
32#define HAVE_ALBUMART
33
34/* define this to enable bitmap scaling */
35#define HAVE_BMP_SCALING
36
37/* define this to enable JPEG decoding */
38#define HAVE_JPEG
39
40/* define this if you can invert the colours on your LCD */
41/* #define HAVE_LCD_INVERT */
42
43/* define this if you have access to the quickscreen */
44#define HAVE_QUICKSCREEN
45
46/* define this if you would like tagcache to build on this target */
47#define HAVE_TAGCACHE
48
49/* define this if you have a flash memory storage */
50#define HAVE_FLASH_STORAGE
51
52#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
53
54#define CONFIG_NAND NAND_RK27XX
55#define HAVE_SW_TONE_CONTROLS
56
57#define HAVE_HOTSWAP
58
59#define NUM_DRIVES 1
60#define SECTOR_SIZE 512
61
62/* for small(ish) SD cards */
63#define HAVE_FAT16SUPPORT
64
65/* LCD dimensions */
66#define LCD_WIDTH 320
67#define LCD_HEIGHT 240
68/* sqrt(320^2 + 240^2) / 2.4 = 166.7 */
69#define LCD_DPI 167
70#define LCD_DEPTH 16 /* pseudo 262.144 colors */
71#define LCD_PIXELFORMAT RGB565 /* rgb565 */
72
73/* Define this if the LCD can shut down */
74/* #define HAVE_LCD_SHUTDOWN */
75
76/* Define this if your LCD can be enabled/disabled */
77#define HAVE_LCD_ENABLE
78
79/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
80 should be defined as well. */
81#ifndef BOOTLOADER
82/* TODO: #define HAVE_LCD_SLEEP */
83/* TODO: #define HAVE_LCD_SLEEP_SETTING */
84#endif
85
86#define CONFIG_KEYPAD IHIFI_770_PAD
87
88/* define this if the target has volume keys which can be used in the lists */
89#define HAVE_VOLUME_IN_LIST
90
91/* Define this if a programmable hotkey is mapped */
92/* #define HAVE_HOTKEY */
93
94/* Define this if you do software codec */
95#define CONFIG_CODEC SWCODEC
96
97/* define this if you have a real-time clock */
98/* #define CONFIG_RTC RTC_NANO2G */
99
100/* Define if the device can wake from an RTC alarm */
101/* #define HAVE_RTC_ALARM */
102
103/* Define the type of audio codec */
104/*#define HAVE_RK27XX_CODEC */
105
106/* #define HAVE_PCM_DMA_ADDRESS */
107
108/* Define this for LCD backlight available */
109#define HAVE_BACKLIGHT
110#define HAVE_BACKLIGHT_BRIGHTNESS
111#define MIN_BRIGHTNESS_SETTING 0
112#define MAX_BRIGHTNESS_SETTING 31
113#define DEFAULT_BRIGHTNESS_SETTING 31
114#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
115
116/* Define this if you have a software controlled poweroff */
117#define HAVE_SW_POWEROFF
118
119/* The number of bytes reserved for loadable codecs */
120#define CODEC_SIZE 0x100000
121
122/* The number of bytes reserved for loadable plugins */
123#define PLUGIN_BUFFER_SIZE 0x80000
124
125#define BATTERY_CAPACITY_DEFAULT 1050 /* default battery capacity */
126#define BATTERY_CAPACITY_MIN 500 /* min. capacity selectable */
127#define BATTERY_CAPACITY_MAX 1050 /* max. capacity selectable */
128#define BATTERY_CAPACITY_INC 10 /* capacity increment */
129#define BATTERY_TYPES_COUNT 1 /* only one type */
130
131#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
132
133/* Hardware controlled charging with monitoring */
134#define CONFIG_CHARGING CHARGING_MONITOR
135
136/* define current usage levels */
137/* TODO: #define CURRENT_NORMAL
138 * TODO: #define CURRENT_BACKLIGHT 23
139 */
140
141/* define this if the unit can be powered or charged via USB */
142#define HAVE_USB_POWER
143
144/* Define this if your LCD can set contrast */
145/* #define HAVE_LCD_CONTRAST */
146
147/* Offset ( in the firmware file's header ) to the file CRC */
148#define FIRMWARE_OFFSET_FILE_CRC 0
149
150/* Offset ( in the firmware file's header ) to the real data */
151#define FIRMWARE_OFFSET_FILE_DATA 8
152
153#define STORAGE_NEEDS_ALIGN
154
155/* Define this if you have adjustable CPU frequency */
156#define HAVE_ADJUSTABLE_CPU_FREQ
157
158/* Virtual LED (icon) */
159#define CONFIG_LED LED_VIRTUAL
160
161/** Non-simulator section **/
162#ifndef SIMULATOR
163
164/* The exact type of CPU */
165#define CONFIG_CPU RK27XX
166
167/* Define this to the CPU frequency */
168#define CPU_FREQ 200000000
169
170/* I2C interface */
171#define CONFIG_I2C I2C_RK27XX
172
173/* define this if the hardware can be powered off while charging */
174/* #define HAVE_POWEROFF_WHILE_CHARGING */
175
176/* Type of LCD */
177#define CONFIG_LCD LCD_IHIFI770C
178
179/* USB On-the-go */
180#define CONFIG_USBOTG USBOTG_RK27XX
181
182/* enable these for the experimental usb stack */
183#define HAVE_USBSTACK
184
185#define USB_VENDOR_ID 0x071b
186#define USB_PRODUCT_ID 0x3202
187#define HAVE_BOOTLOADER_USB_MODE
188
189#define RKW_FORMAT
190#define BOOTFILE_EXT "rkw"
191#define BOOTFILE "rockbox." BOOTFILE_EXT
192#define BOOTDIR "/.rockbox"
193
194/* disabled for now */
195#undef HAVE_HOTSWAP
196
197#endif /* SIMULATOR */
diff --git a/firmware/export/config/ihifi800.h b/firmware/export/config/ihifi800.h
new file mode 100644
index 0000000000..eb1c2015ad
--- /dev/null
+++ b/firmware/export/config/ihifi800.h
@@ -0,0 +1,198 @@
1/*
2 * This config file is for IHIFI 800
3 */
4
5/* For Rolo and boot loader */
6#define MODEL_NUMBER 109
7
8#define MODEL_NAME "IHIFI 800"
9
10/* Define bitmask of input sources - recordable bitmask can be defined
11 explicitly if different */
12/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
13
14/* define the bitmask of hardware sample rates */
15#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_48 | SAMPR_CAP_44 | \
16 SAMPR_CAP_32 | SAMPR_CAP_24 | SAMPR_CAP_22 | \
17 SAMPR_CAP_16 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
18
19#define HAVE_ES9018
20#define CODEC_SLAVE
21
22/* define this if you have a bitmap LCD display */
23#define HAVE_LCD_BITMAP
24
25/* define this if you can flip your LCD */
26/* #define HAVE_LCD_FLIP */
27
28/* define this if you have a colour LCD */
29#define HAVE_LCD_COLOR
30
31/* define this if you want album art for this target */
32#define HAVE_ALBUMART
33
34/* define this to enable bitmap scaling */
35#define HAVE_BMP_SCALING
36
37/* define this to enable JPEG decoding */
38#define HAVE_JPEG
39
40/* define this if you can invert the colours on your LCD */
41/* #define HAVE_LCD_INVERT */
42
43/* define this if you have access to the quickscreen */
44#define HAVE_QUICKSCREEN
45
46/* define this if you would like tagcache to build on this target */
47#define HAVE_TAGCACHE
48
49/* define this if you have a flash memory storage */
50#define HAVE_FLASH_STORAGE
51
52#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
53
54#define CONFIG_NAND NAND_RK27XX
55#define HAVE_SW_TONE_CONTROLS
56
57#define HAVE_HOTSWAP
58
59#define NUM_DRIVES 1
60#define SECTOR_SIZE 512
61
62/* for small(ish) SD cards */
63#define HAVE_FAT16SUPPORT
64
65/* LCD dimensions */
66#define LCD_WIDTH 240
67#define LCD_HEIGHT 320
68/* sqrt(240^2 + 320^2) / 2.4 = 166.7 */
69#define LCD_DPI 167
70#define LCD_DEPTH 16 /* pseudo 262.144 colors */
71#define LCD_PIXELFORMAT RGB565 /* rgb565 */
72
73/* Define this if the LCD can shut down */
74/* #define HAVE_LCD_SHUTDOWN */
75
76/* Define this if your LCD can be enabled/disabled */
77#define HAVE_LCD_ENABLE
78
79/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
80 should be defined as well. */
81#ifndef BOOTLOADER
82/* TODO: #define HAVE_LCD_SLEEP */
83/* TODO: #define HAVE_LCD_SLEEP_SETTING */
84#endif
85
86#define CONFIG_KEYPAD IHIFI_800_PAD
87
88/* define this if the target has volume keys which can be used in the lists */
89#define HAVE_VOLUME_IN_LIST
90
91/* Define this if a programmable hotkey is mapped */
92/* #define HAVE_HOTKEY */
93
94/* Define this if you do software codec */
95#define CONFIG_CODEC SWCODEC
96
97/* define this if you have a real-time clock */
98/* #define CONFIG_RTC RTC_NANO2G */
99
100/* Define if the device can wake from an RTC alarm */
101/* #define HAVE_RTC_ALARM */
102
103/* Define the type of audio codec */
104/*#define HAVE_RK27XX_CODEC */
105
106/* #define HAVE_PCM_DMA_ADDRESS */
107
108/* Define this for LCD backlight available */
109#define HAVE_BACKLIGHT
110#define HAVE_BACKLIGHT_BRIGHTNESS
111#define MIN_BRIGHTNESS_SETTING 0
112#define MAX_BRIGHTNESS_SETTING 31
113#define DEFAULT_BRIGHTNESS_SETTING 31
114#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
115
116/* Define this if you have a software controlled poweroff */
117#define HAVE_SW_POWEROFF
118
119/* The number of bytes reserved for loadable codecs */
120#define CODEC_SIZE 0x100000
121
122/* The number of bytes reserved for loadable plugins */
123#define PLUGIN_BUFFER_SIZE 0x80000
124
125/* TODO: Figure out real values */
126#define BATTERY_CAPACITY_DEFAULT 1400 /* default battery capacity */
127#define BATTERY_CAPACITY_MIN 700 /* min. capacity selectable */
128#define BATTERY_CAPACITY_MAX 1400 /* max. capacity selectable */
129#define BATTERY_CAPACITY_INC 10 /* capacity increment */
130#define BATTERY_TYPES_COUNT 1 /* only one type */
131
132#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
133
134/* Hardware controlled charging with monitoring */
135#define CONFIG_CHARGING CHARGING_MONITOR
136
137/* define current usage levels */
138/* TODO: #define CURRENT_NORMAL
139 * TODO: #define CURRENT_BACKLIGHT 23
140 */
141
142/* define this if the unit can be powered or charged via USB */
143#define HAVE_USB_POWER
144
145/* Define this if your LCD can set contrast */
146/* #define HAVE_LCD_CONTRAST */
147
148/* Offset ( in the firmware file's header ) to the file CRC */
149#define FIRMWARE_OFFSET_FILE_CRC 0
150
151/* Offset ( in the firmware file's header ) to the real data */
152#define FIRMWARE_OFFSET_FILE_DATA 8
153
154#define STORAGE_NEEDS_ALIGN
155
156/* Define this if you have adjustable CPU frequency */
157#define HAVE_ADJUSTABLE_CPU_FREQ
158
159/* Virtual LED (icon) */
160#define CONFIG_LED LED_VIRTUAL
161
162/** Non-simulator section **/
163#ifndef SIMULATOR
164
165/* The exact type of CPU */
166#define CONFIG_CPU RK27XX
167
168/* Define this to the CPU frequency */
169#define CPU_FREQ 200000000
170
171/* I2C interface */
172#define CONFIG_I2C I2C_RK27XX
173
174/* define this if the hardware can be powered off while charging */
175/* #define HAVE_POWEROFF_WHILE_CHARGING */
176
177/* Type of LCD */
178#define CONFIG_LCD LCD_IHIFI800
179
180/* USB On-the-go */
181#define CONFIG_USBOTG USBOTG_RK27XX
182
183/* enable these for the experimental usb stack */
184#define HAVE_USBSTACK
185
186#define USB_VENDOR_ID 0x071b
187#define USB_PRODUCT_ID 0x3202
188#define HAVE_BOOTLOADER_USB_MODE
189
190#define RKW_FORMAT
191#define BOOTFILE_EXT "rkw"
192#define BOOTFILE "rockbox." BOOTFILE_EXT
193#define BOOTDIR "/.rockbox"
194
195/* disabled for now */
196#undef HAVE_HOTSWAP
197
198#endif /* SIMULATOR */
diff --git a/firmware/export/config/rk27generic.h b/firmware/export/config/rk27generic.h
index 503857bd43..69cf9f3758 100644
--- a/firmware/export/config/rk27generic.h
+++ b/firmware/export/config/rk27generic.h
@@ -63,7 +63,7 @@
63/* commented for now */ 63/* commented for now */
64/* #define HAVE_HOTSWAP */ 64/* #define HAVE_HOTSWAP */
65 65
66#define NUM_DRIVES 2 66#define NUM_DRIVES 1
67#define SECTOR_SIZE 512 67#define SECTOR_SIZE 512
68 68
69/* for small(ish) SD cards */ 69/* for small(ish) SD cards */
diff --git a/firmware/export/es9018.h b/firmware/export/es9018.h
new file mode 100644
index 0000000000..41ea0d0b1c
--- /dev/null
+++ b/firmware/export/es9018.h
@@ -0,0 +1,39 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _ES9018_H
23#define _ES9018_H
24
25#define ES9018_VOLUME_MIN -1270
26#define ES9018_VOLUME_MAX 0
27
28#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP)
29#define AUDIOHW_HAVE_SHORT_ROLL_OFF
30AUDIOHW_SETTING(VOLUME, "dB", 0, 1, ES9018_VOLUME_MIN/10, ES9018_VOLUME_MAX/10, 0)
31AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 3, 0)
32
33void es9018_write_reg(uint8_t reg, uint8_t val);
34uint8_t es9018_read_reg(uint8_t reg);
35
36void audiohw_mute(void);
37void audiohw_unmute(void);
38
39#endif
diff --git a/firmware/export/rk27xx.h b/firmware/export/rk27xx.h
index 58b3fe8166..dc6bca7cbd 100644
--- a/firmware/export/rk27xx.h
+++ b/firmware/export/rk27xx.h
@@ -8,7 +8,8 @@
8#define FLASH_BANK1 0x11000000 8#define FLASH_BANK1 0x11000000
9 9
10#define USB_NUM_ENDPOINTS 16 10#define USB_NUM_ENDPOINTS 16
11#define USB_DEVBSS_ATTR 11/* cache aligned */
12#define USB_DEVBSS_ATTR __attribute__((aligned(CACHEALIGN_SIZE)))
12 13
13/* Timers */ 14/* Timers */
14#define APB0_TIMER (ARM_BUS0_BASE + 0x00000000) 15#define APB0_TIMER (ARM_BUS0_BASE + 0x00000000)
@@ -811,6 +812,7 @@
811#define RXVOIDINTEN (1<<5) 812#define RXVOIDINTEN (1<<5)
812#define RXERRINTEN (1<<6) 813#define RXERRINTEN (1<<6)
813#define RXACKINTEN (1<<7) 814#define RXACKINTEN (1<<7)
815#define RXCFINTE (1<<12)
814/* bits 31:8 reserved for EP0 */ 816/* bits 31:8 reserved for EP0 */
815/* bits 31:14 reserved for others */ 817/* bits 31:14 reserved for others */
816 818
@@ -833,6 +835,7 @@
833#define TXERRINTEN (1<<5) 835#define TXERRINTEN (1<<5)
834#define TXACKINTEN (1<<6) 836#define TXACKINTEN (1<<6)
835#define TXDMADNEN (1<<7) /* reserved for EP0 */ 837#define TXDMADNEN (1<<7) /* reserved for EP0 */
838#define TXCFINTE (1<<12)
836/* bits 31:8 reserved */ 839/* bits 31:8 reserved */
837 840
838/* TXnBUF bits */ 841/* TXnBUF bits */
diff --git a/firmware/export/wm8740.h b/firmware/export/wm8740.h
new file mode 100644
index 0000000000..ff27a7e41e
--- /dev/null
+++ b/firmware/export/wm8740.h
@@ -0,0 +1,83 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef _WM8740_H
23#define _WM8740_H
24
25#define WM8740_VOLUME_MIN -1270
26#define WM8740_VOLUME_MAX 0
27
28#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP)
29AUDIOHW_SETTING(VOLUME, "dB", 0, 1, WM8740_VOLUME_MIN/10, WM8740_VOLUME_MAX/10, 0)
30AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 1, 0)
31
32#define WM8740_REG0 0x0000
33#define WM8740_REG1 0x0200
34#define WM8740_REG2 0x0400
35#define WM8740_REG3 0x0600
36#define WM8740_REG4 0x0C00
37
38/**
39 * Register #0
40 */
41#define WM8740_LDL (1<<8)
42
43/**
44 * Register #1
45 */
46#define WM8740_LDR (1<<8)
47
48/**
49 * Register #2
50 */
51#define WM8740_MUT (1<<0)
52#define WM8740_DEM (1<<1)
53#define WM8740_OPE (1<<2)
54#define WM8740_IW0 (1<<3)
55#define WM8740_IW1 (1<<4)
56
57/**
58 * Register #3
59 */
60#define WM8740_I2S (1<<0)
61#define WM8740_LRP (1<<1)
62#define WM8740_ATC (1<<2)
63#define WM8740_SR0 (1<<3)
64#define WM8740_REV (1<<4)
65#define WM8740_SF0 (1<<6)
66#define WM8740_SF1 (1<<7)
67#define WM8740_IZD (1<<8)
68
69/**
70 * Register #4
71 */
72#define WM8740_DIFF0 (1<<4)
73#define WM8740_DIFF1 (1<<5)
74#define WM8740_CDD (1<<6)
75
76void audiohw_mute(void);
77void audiohw_unmute(void);
78
79void wm8740_set_ml(const int);
80void wm8740_set_mc(const int);
81void wm8740_set_md(const int);
82
83#endif
diff --git a/firmware/target/arm/rk27xx/backlight-rk27xx.c b/firmware/target/arm/rk27xx/backlight-rk27xx.c
index 1756fcdb29..61e887af46 100644
--- a/firmware/target/arm/rk27xx/backlight-rk27xx.c
+++ b/firmware/target/arm/rk27xx/backlight-rk27xx.c
@@ -75,6 +75,13 @@ static const unsigned short lin_brightness[] = {
75 759, 768, 778, 788, 800, 812, 826, 841, 75 759, 768, 778, 788, 800, 812, 826, 841,
76 856, 873, 891, 910, 931, 952, 975, 1000 76 856, 873, 891, 910, 931, 952, 975, 1000
77}; 77};
78#elif defined(IHIFI770) || defined(IHIFI770C) || defined(IHIFI800)
79static const unsigned short lin_brightness[] = {
80 4096, 4215, 4381, 4603, 4887, 5243, 5679, 6201,
81 6818, 7538, 8370, 9320, 10397, 11609, 12963, 14469,
82 16133, 17963, 19968, 22156, 24534, 27110, 29893, 32890,
83 36109, 39559, 43246, 47180, 51368, 55817, 60537, 65535
84};
78#endif 85#endif
79 86
80bool backlight_hw_init(void) 87bool backlight_hw_init(void)
diff --git a/firmware/target/arm/rk27xx/debug-rk27xx.c b/firmware/target/arm/rk27xx/debug-rk27xx.c
index 83bc1a5af6..ea0190049f 100644
--- a/firmware/target/arm/rk27xx/debug-rk27xx.c
+++ b/firmware/target/arm/rk27xx/debug-rk27xx.c
@@ -35,6 +35,8 @@
35#elif defined(HM60X) || defined(HM801) || (CONFIG_KEYPAD == MA_PAD) || \ 35#elif defined(HM60X) || defined(HM801) || (CONFIG_KEYPAD == MA_PAD) || \
36 (CONFIG_KEYPAD == IHIFI_PAD) 36 (CONFIG_KEYPAD == IHIFI_PAD)
37#define DEBUG_CANCEL BUTTON_LEFT 37#define DEBUG_CANCEL BUTTON_LEFT
38#elif (CONFIG_KEYPAD == IHIFI_770_PAD) || (CONFIG_KEYPAD == IHIFI_800_PAD)
39#define DEBUG_CANCEL BUTTON_POWER
38#endif 40#endif
39 41
40/* Skeleton for adding target specific debug info to the debug menu 42/* Skeleton for adding target specific debug info to the debug menu
diff --git a/firmware/target/arm/rk27xx/ihifi2/audio-ihifi770.c b/firmware/target/arm/rk27xx/ihifi2/audio-ihifi770.c
new file mode 100644
index 0000000000..a21ea9cfef
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/audio-ihifi770.c
@@ -0,0 +1,88 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "system.h"
23#include "kernel.h"
24#include "audiohw.h"
25
26void wm8740_hw_init(void)
27{
28 GPIO_PADR &= ~(1<<0); /* MD */
29 GPIO_PACON |= (1<<0);
30
31 GPIO_PADR &= ~(1<<1); /* MC */
32 GPIO_PACON |= (1<<1);
33
34 SCU_IOMUXB_CON &= ~(1<<2);
35 GPIO_PCDR |= (1<<4); /* ML */
36 GPIO_PCCON |= (1<<4);
37}
38
39void wm8740_set_md(const int val)
40{
41 if (val)
42 GPIO_PADR |= (1<<0);
43 else
44 GPIO_PADR &= ~(1<<0);
45}
46
47void wm8740_set_mc(const int val)
48{
49 if (val)
50 GPIO_PADR |= (1<<1);
51 else
52 GPIO_PADR &= ~(1<<1);
53}
54
55void wm8740_set_ml(const int val)
56{
57 if (val)
58 GPIO_PCDR |= (1<<4);
59 else
60 GPIO_PCDR &= ~(1<<4);
61}
62
63static void pop_ctrl(const int val)
64{
65 if (val)
66 GPIO_PADR |= (1<<7);
67 else
68 GPIO_PADR &= ~(1<<7);
69}
70
71void audiohw_postinit(void)
72{
73 pop_ctrl(0);
74 sleep(HZ/4);
75 wm8740_hw_init();
76 audiohw_init();
77 sleep(HZ/2);
78 pop_ctrl(1);
79 sleep(HZ/4);
80 audiohw_unmute();
81}
82
83void audiohw_close(void)
84{
85 audiohw_mute();
86 pop_ctrl(0);
87 sleep(HZ/4);
88}
diff --git a/firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c b/firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c
new file mode 100644
index 0000000000..14b126c72a
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/audio-ihifi800.c
@@ -0,0 +1,67 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "system.h"
23#include "kernel.h"
24#include "audiohw.h"
25#include "i2c-rk27xx.h"
26
27#define ES9018_I2C_ADDR 0x90
28
29static unsigned char buf;
30
31void es9018_write_reg(uint8_t reg, uint8_t val)
32{
33 buf = val;
34 i2c_write(ES9018_I2C_ADDR, reg, sizeof(buf), (void*)&buf);
35}
36
37uint8_t es9018_read_reg(uint8_t reg)
38{
39 i2c_read(ES9018_I2C_ADDR, reg, sizeof(buf), (void*)&buf);
40 return buf;
41}
42
43static void pop_ctrl(const int val)
44{
45 if (val)
46 GPIO_PADR |= (1<<7);
47 else
48 GPIO_PADR &= ~(1<<7);
49}
50
51void audiohw_postinit(void)
52{
53 pop_ctrl(0);
54 sleep(HZ/4);
55 audiohw_init();
56 sleep(HZ/2);
57 pop_ctrl(1);
58 sleep(HZ/4);
59 audiohw_unmute();
60}
61
62void audiohw_close(void)
63{
64 audiohw_mute();
65 pop_ctrl(0);
66 sleep(HZ/4);
67}
diff --git a/firmware/target/arm/rk27xx/ihifi2/button-ihifi.c b/firmware/target/arm/rk27xx/ihifi2/button-ihifi.c
new file mode 100644
index 0000000000..172853a83a
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/button-ihifi.c
@@ -0,0 +1,99 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "system.h"
24#include "kernel.h"
25#include "button.h"
26#include "adc.h"
27#include "backlight.h"
28
29static bool soft_hold = false;
30#ifndef BOOTLOADER
31static unsigned hold_counter = 0;
32#ifndef IHIFI800
33#define HOLDBUTTON gpio_btn
34#define HOLDCNTMAX HZ
35#else
36#define HOLDBUTTON (gpio_btn) && (adc_val > 325) && (adc_val < 480)
37#define HOLDCNTMAX (HZ/10)
38#endif
39#endif
40
41void button_init_device(void) {
42 GPIO_PCCON &= ~(1<<1); /* PWR BTN */
43 GPIO_PCCON &= ~(1<<7); /* CD */
44}
45
46bool button_hold(void)
47{
48 return soft_hold;
49}
50
51int button_read_device(void) {
52 int adc_val = adc_read(ADC_BUTTONS);
53 int gpio_btn = GPIO_PCDR & (1<<1);
54
55 int button = BUTTON_NONE;
56
57 if (gpio_btn)
58 button |= BUTTON_POWER;
59
60#ifndef BOOTLOADER
61 if (HOLDBUTTON) {
62 if (++hold_counter == HOLDCNTMAX) {
63 soft_hold = !soft_hold;
64 backlight_hold_changed(soft_hold);
65 }
66 } else {
67 hold_counter = 0;
68 }
69 if (soft_hold) {
70 return (hold_counter <= HOLDCNTMAX) ? BUTTON_NONE : button;
71 }
72#endif
73
74 if (adc_val < 792) {
75 if (adc_val < 480) {
76 if (adc_val < 170) {
77 if (adc_val < 46) {
78 button |= BUTTON_HOME; // 0-45
79 } else {
80 button |= BUTTON_PLAY; // 46-169
81 }
82 } else {
83 if (adc_val < 325) {
84 button |= BUTTON_NEXT; // 170-324
85 } else {
86 button |= BUTTON_VOL_UP;// 325-479
87 }
88 }
89 } else {
90 if (adc_val < 636) {
91 button |= BUTTON_VOL_DOWN;// 480-635
92 } else {
93 button |= BUTTON_PREV; // 636-791
94 }
95 }
96 }
97
98 return button;
99}
diff --git a/firmware/target/arm/rk27xx/ihifi2/button-target.h b/firmware/target/arm/rk27xx/ihifi2/button-target.h
new file mode 100644
index 0000000000..211e20e1d6
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/button-target.h
@@ -0,0 +1,50 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#ifndef _BUTTON_TARGET_H_
22#define _BUTTON_TARGET_H_
23
24#define HAS_BUTTON_HOLD
25
26/* Main unit's buttons */
27#define BUTTON_POWER 0x00000001
28#define BUTTON_HOME 0x00000002
29#define BUTTON_PREV 0x00000004
30#define BUTTON_NEXT 0x00000008
31#define BUTTON_PLAY 0x00000010
32#define BUTTON_VOL_UP 0x00000020
33#define BUTTON_VOL_DOWN 0x00000040
34
35#define BUTTON_LEFT 0
36#define BUTTON_RIGHT 0
37
38#define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_PREV | BUTTON_NEXT | \
39 BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN)
40
41/* Software power-off */
42#ifndef IHIFI800
43#define POWEROFF_BUTTON BUTTON_POWER
44#else
45#define POWEROFF_BUTTON BUTTON_HOME
46#endif
47
48#define POWEROFF_COUNT 30
49
50#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770.c b/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770.c
new file mode 100644
index 0000000000..23505d9fa0
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770.c
@@ -0,0 +1,285 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "kernel.h"
24#include "lcd.h"
25#include "system.h"
26#include "cpu.h"
27#include "lcdif-rk27xx.h"
28
29static bool display_on = false;
30
31void lcd_display_init(void)
32{
33 unsigned int i, x, y;
34
35 lcd_cmd(0x11);
36
37 lcd_cmd(0x13);
38
39 mdelay(120);
40
41 lcd_cmd(0x29);
42
43 lcd_cmd(0xB0);
44 lcd_data(0x05);
45 lcd_data(0x00);
46 lcd_data(0xF0);
47 lcd_data(0x0A);
48 lcd_data(0x41);
49 lcd_data(0x02);
50 lcd_data(0x0A);
51 lcd_data(0x30);
52 lcd_data(0x31);
53 lcd_data(0x36);
54 lcd_data(0x37);
55 lcd_data(0x40);
56 lcd_data(0x02);
57 lcd_data(0x3F);
58 lcd_data(0x40);
59 lcd_data(0x02);
60 lcd_data(0x81);
61 lcd_data(0x04);
62 lcd_data(0x05);
63 lcd_data(0x64);
64
65 lcd_cmd(0xFC);
66 lcd_data(0x88);
67 lcd_data(0x00);
68 lcd_data(0x10);
69 lcd_data(0x01);
70 lcd_data(0x01);
71 lcd_data(0x10);
72 lcd_data(0x42);
73 lcd_data(0x42);
74 lcd_data(0x22);
75 lcd_data(0x11);
76 lcd_data(0x11);
77 lcd_data(0x22);
78 lcd_data(0x99);
79 lcd_data(0xAA);
80 lcd_data(0xAA);
81 lcd_data(0xAA);
82 lcd_data(0xBB);
83 lcd_data(0xBB);
84 lcd_data(0xAA);
85 lcd_data(0x33);
86 lcd_data(0x33);
87 lcd_data(0x11);
88 lcd_data(0x01);
89 lcd_data(0x01);
90 lcd_data(0x01);
91 lcd_data(0x00);
92 lcd_data(0x00);
93 lcd_data(0xC0);
94 lcd_data(0x00);
95 lcd_data(0x00);
96 lcd_data(0x00);
97 lcd_data(0x00);
98
99 lcd_cmd(0xFD);
100 lcd_data(0x88);
101 lcd_data(0x00);
102 lcd_data(0x10);
103 lcd_data(0x01);
104 lcd_data(0x01);
105 lcd_data(0x10);
106 lcd_data(0x42);
107 lcd_data(0x42);
108 lcd_data(0x22);
109 lcd_data(0x11);
110 lcd_data(0x11);
111 lcd_data(0x22);
112 lcd_data(0x99);
113 lcd_data(0xAA);
114 lcd_data(0xAA);
115 lcd_data(0xAA);
116 lcd_data(0xBB);
117 lcd_data(0xBB);
118 lcd_data(0xAA);
119 lcd_data(0x33);
120 lcd_data(0x33);
121 lcd_data(0x11);
122 lcd_data(0x01);
123 lcd_data(0x01);
124 lcd_data(0x01);
125 lcd_data(0x00);
126 lcd_data(0x00);
127 lcd_data(0x00);
128 lcd_data(0x00);
129 lcd_data(0x00);
130 lcd_data(0x00);
131 lcd_data(0x03);
132
133 lcd_cmd(0xBE);
134 lcd_data(0x00);
135 lcd_data(0x15);
136 lcd_data(0x16);
137 lcd_data(0x08);
138 lcd_data(0x09);
139 lcd_data(0x15);
140 lcd_data(0x10);
141 lcd_data(0x00);
142 lcd_data(0x00);
143 lcd_data(0x00);
144
145 lcd_cmd(0xC0);
146 lcd_data(0x0E);
147 lcd_data(0x01);
148 lcd_data(0x00);
149 lcd_data(0x00);
150 lcd_data(0x00);
151
152 lcd_cmd(0xC1);
153 lcd_data(0x2F);
154 lcd_data(0x23);
155 lcd_data(0xB4);
156 lcd_data(0xFF);
157 lcd_data(0x24);
158 lcd_data(0x03);
159 lcd_data(0x20);
160 lcd_data(0x02);
161 lcd_data(0x02);
162 lcd_data(0x02);
163 lcd_data(0x20);
164 lcd_data(0x20);
165 lcd_data(0x00);
166
167 lcd_cmd(0xC2);
168 lcd_data(0x03);
169
170 lcd_cmd(0x26);
171 lcd_data(0x08);
172
173 lcd_cmd(0x35);
174
175 lcd_cmd(0x36);
176 lcd_data(0x04);
177
178 lcd_cmd(0x3A);
179 lcd_data(0x05);
180
181 lcd_cmd(0x2A);
182 lcd_data(0x013F);
183
184 lcd_cmd(0x2B);
185 lcd_data(0xEF);
186
187 lcd_cmd(0x2C);
188
189 lcd_cmd(0x2D);
190 for (i = 0; i < 0x20; i++) {
191 lcd_data(i << 1);
192 }
193 for (i = 0; i < 0x40; i++) {
194 lcd_data(i);
195 }
196 for (i = 0; i < 0x20; i++) {
197 lcd_data(i << 1);
198 }
199
200 lcd_cmd(0x2A);
201 lcd_data(0x00);
202
203 lcd_cmd(0x2B);
204 lcd_data(0x00);
205
206 lcd_cmd(0x11);
207
208 mdelay(120);
209
210 lcd_cmd(0x29);
211
212 lcd_cmd(0x2C);
213
214 for (x = 0; x < LCD_WIDTH; x++)
215 for(y=0; y < LCD_HEIGHT; y++)
216 lcd_data(0x00);
217
218 display_on = true;
219}
220
221void lcd_enable (bool on)
222{
223 if (on == display_on)
224 return;
225
226 lcdctrl_bypass(1);
227 LCDC_CTRL |= RGB24B;
228
229 if (on) {
230 lcd_cmd(0x11);
231 mdelay(120);
232 lcd_cmd(0x29);
233 lcd_cmd(0x2C);
234 } else {
235 lcd_cmd(0x28);
236 mdelay(120);
237 lcd_cmd(0x10);
238 }
239
240 display_on = on;
241 LCDC_CTRL &= ~RGB24B;
242}
243
244void lcd_set_gram_area(int x_start, int y_start,
245 int x_end, int y_end)
246{
247 lcdctrl_bypass(1);
248 LCDC_CTRL |= RGB24B;
249
250 lcd_cmd(0x2A);
251 lcd_data((x_start&0xff00)>>8);
252 lcd_data(x_start&0x00ff);
253 lcd_data((x_end&0xff00)>>8);
254 lcd_data(x_end&0x00ff);
255
256 lcd_cmd(0x2B);
257 lcd_data((y_start&0xff00)>>8);
258 lcd_data(y_start&0x00ff);
259 lcd_data((y_end&0xff00)>>8);
260 lcd_data(y_end&0x00ff);
261
262 lcd_cmd(0x2C);
263
264 LCDC_CTRL &= ~RGB24B;
265}
266
267bool lcd_active()
268{
269 return display_on;
270}
271
272/* Blit a YUV bitmap directly to the LCD */
273void lcd_blit_yuv(unsigned char * const src[3],
274 int src_x, int src_y, int stride,
275 int x, int y, int width, int height)
276{
277 (void)src;
278 (void)src_x;
279 (void)src_y;
280 (void)stride;
281 (void)x;
282 (void)y;
283 (void)width;
284 (void)height;
285}
diff --git a/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770c.c b/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770c.c
new file mode 100644
index 0000000000..311b8057cb
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi770c.c
@@ -0,0 +1,248 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "kernel.h"
24#include "lcd.h"
25#include "system.h"
26#include "cpu.h"
27#include "lcdif-rk27xx.h"
28
29static bool display_on = false;
30
31void lcd_display_init(void)
32{
33 unsigned int x, y;
34
35 lcd_cmd(0x13);
36
37 mdelay(120);
38
39 lcd_cmd(0x35);
40 lcd_data(0x00);
41
42 lcd_cmd(0x36);
43 lcd_data(0x48);
44
45 lcd_cmd(0xD0);
46 lcd_data(0x00);
47 lcd_data(0x05);
48
49 lcd_cmd(0xEF);
50 lcd_data(0x07);
51
52 lcd_cmd(0xF2);
53 lcd_data(0x1B);
54 lcd_data(0x16);
55 lcd_data(0x0F);
56 lcd_data(0x08);
57 lcd_data(0x08);
58 lcd_data(0x08);
59 lcd_data(0x08);
60 lcd_data(0x10);
61 lcd_data(0x00);
62 lcd_data(0x1C);
63 lcd_data(0x16);
64
65 lcd_cmd(0xF3);
66 lcd_data(0x01);
67 lcd_data(0x41);
68 lcd_data(0x15);
69 lcd_data(0x0D);
70 lcd_data(0x33);
71 lcd_data(0x63);
72 lcd_data(0x46);
73 lcd_data(0x10);
74
75 lcd_cmd(0xF4);
76 lcd_data(0x5B);
77 lcd_data(0x5B);
78 lcd_data(0x55);
79 lcd_data(0x55);
80 lcd_data(0x44);
81
82 lcd_cmd(0xF5);
83 lcd_data(0x12);
84 lcd_data(0x11);
85 lcd_data(0x06);
86 lcd_data(0xF0);
87 lcd_data(0x00);
88 lcd_data(0x1F);
89
90 lcd_cmd(0xF6);
91 lcd_data(0x80);
92 lcd_data(0x10);
93 lcd_data(0x00);
94
95 lcd_cmd(0xFD);
96 lcd_data(0x11);
97 lcd_data(0x1D);
98 lcd_data(0x00);
99
100 lcd_cmd(0xF8);
101 lcd_data(0x00);
102 lcd_data(0x15);
103 lcd_data(0x01);
104 lcd_data(0x08);
105 lcd_data(0x15);
106 lcd_data(0x22);
107 lcd_data(0x25);
108 lcd_data(0x28);
109 lcd_data(0x14);
110 lcd_data(0x13);
111 lcd_data(0x10);
112 lcd_data(0x11);
113 lcd_data(0x09);
114 lcd_data(0x24);
115 lcd_data(0x28);
116
117 lcd_cmd(0xF9);
118 lcd_data(0x00);
119 lcd_data(0x15);
120 lcd_data(0x01);
121 lcd_data(0x08);
122 lcd_data(0x15);
123 lcd_data(0x22);
124 lcd_data(0x25);
125 lcd_data(0x28);
126 lcd_data(0x14);
127 lcd_data(0x13);
128 lcd_data(0x10);
129 lcd_data(0x11);
130 lcd_data(0x09);
131 lcd_data(0x24);
132 lcd_data(0x28);
133
134 lcd_cmd(0xFC);
135 lcd_data(0x00);
136 lcd_data(0x15);
137 lcd_data(0x01);
138 lcd_data(0x08);
139 lcd_data(0x15);
140 lcd_data(0x22);
141 lcd_data(0x25);
142 lcd_data(0x28);
143 lcd_data(0x14);
144 lcd_data(0x13);
145 lcd_data(0x10);
146 lcd_data(0x11);
147 lcd_data(0x09);
148 lcd_data(0x24);
149 lcd_data(0x28);
150
151 lcd_cmd(0x36);
152 lcd_data(0x48);
153
154 lcd_cmd(0x3A);
155 lcd_data(0x55);
156
157 lcd_cmd(0x2A);
158 lcd_data(0x00);
159 lcd_data(0x00);
160 lcd_data(0x01);
161 lcd_data(0x3F);
162
163 lcd_cmd(0x2B);
164 lcd_data(0x00);
165 lcd_data(0x00);
166 lcd_data(0x00);
167 lcd_data(0xEF);
168
169 lcd_cmd(0x11);
170
171 mdelay(120);
172
173 lcd_cmd(0x29);
174
175 lcd_cmd(0x2C);
176
177 for (x = 0; x < LCD_WIDTH; x++)
178 for(y=0; y < LCD_HEIGHT; y++)
179 lcd_data(0x00);
180
181 display_on = true;
182}
183
184void lcd_enable (bool on)
185{
186 if (on == display_on)
187 return;
188
189 lcdctrl_bypass(1);
190 LCDC_CTRL |= RGB24B;
191
192 if (on) {
193 lcd_cmd(0x11);
194 mdelay(120);
195 lcd_cmd(0x29);
196 lcd_cmd(0x2C);
197 } else {
198 lcd_cmd(0x28);
199 mdelay(120);
200 lcd_cmd(0x10);
201 }
202
203 display_on = on;
204 LCDC_CTRL &= ~RGB24B;
205}
206
207void lcd_set_gram_area(int x_start, int y_start,
208 int x_end, int y_end)
209{
210 lcdctrl_bypass(1);
211 LCDC_CTRL |= RGB24B;
212
213 lcd_cmd(0x2A);
214 lcd_data((x_start&0xff00)>>8);
215 lcd_data(x_start&0x00ff);
216 lcd_data((x_end&0xff00)>>8);
217 lcd_data(x_end&0x00ff);
218
219 lcd_cmd(0x2B);
220 lcd_data((y_start&0xff00)>>8);
221 lcd_data(y_start&0x00ff);
222 lcd_data((y_end&0xff00)>>8);
223 lcd_data(y_end&0x00ff);
224
225 lcd_cmd(0x2C);
226
227 LCDC_CTRL &= ~RGB24B;
228}
229
230bool lcd_active()
231{
232 return display_on;
233}
234
235/* Blit a YUV bitmap directly to the LCD */
236void lcd_blit_yuv(unsigned char * const src[3],
237 int src_x, int src_y, int stride,
238 int x, int y, int width, int height)
239{
240 (void)src;
241 (void)src_x;
242 (void)src_y;
243 (void)stride;
244 (void)x;
245 (void)y;
246 (void)width;
247 (void)height;
248}
diff --git a/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi800.c b/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi800.c
new file mode 100644
index 0000000000..821b52dcb6
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/lcd-ihifi800.c
@@ -0,0 +1,228 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "kernel.h"
24#include "lcd.h"
25#include "system.h"
26#include "cpu.h"
27#include "lcdif-rk27xx.h"
28
29static bool display_on = false;
30
31void lcd_display_init(void)
32{
33 unsigned int x, y;
34
35 lcd_cmd(0xEF);
36 lcd_data(0x03);
37 lcd_data(0x80);
38 lcd_data(0x02);
39
40 lcd_cmd(0xCF);
41 lcd_data(0x00);
42 lcd_data(0xC1);
43 lcd_data(0x30);
44
45 lcd_cmd(0xED);
46 lcd_data(0x67);
47 lcd_data(0x03);
48 lcd_data(0x12);
49 lcd_data(0x81);
50
51 lcd_cmd(0xE8);
52 lcd_data(0x85);
53 lcd_data(0x11);
54 lcd_data(0x79);
55
56 lcd_cmd(0xCB);
57 lcd_data(0x39);
58 lcd_data(0x2C);
59 lcd_data(0x00);
60 lcd_data(0x34);
61 lcd_data(0x06);
62
63 lcd_cmd(0xF7);
64 lcd_data(0x20);
65
66 lcd_cmd(0xEA);
67 lcd_data(0x00);
68 lcd_data(0x00);
69
70 lcd_cmd(0xC0);
71 lcd_data(0x1D);
72
73 lcd_cmd(0xC1);
74 lcd_data(0x12);
75
76 lcd_cmd(0xC5);
77 lcd_data(0x44);
78 lcd_data(0x3C);
79
80 lcd_cmd(0xC7);
81 lcd_data(0x88);
82
83 lcd_cmd(0x3A);
84 lcd_data(0x55);
85
86 lcd_cmd(0x36);
87 lcd_data(0x0C);
88
89 lcd_cmd(0xB1);
90 lcd_data(0x00);
91 lcd_data(0x17);
92
93 lcd_cmd(0xB6);
94 lcd_data(0x0A);
95 lcd_data(0xA2);
96
97 lcd_cmd(0xF2);
98 lcd_data(0x00);
99
100 lcd_cmd(0x26);
101 lcd_data(0x01);
102
103 lcd_cmd(0xE0);
104 lcd_data(0x0F);
105 lcd_data(0x22);
106 lcd_data(0x1C);
107 lcd_data(0x1B);
108 lcd_data(0x08);
109 lcd_data(0x0F);
110 lcd_data(0x48);
111 lcd_data(0xB8);
112 lcd_data(0x34);
113 lcd_data(0x05);
114 lcd_data(0x0C);
115 lcd_data(0x09);
116 lcd_data(0x0F);
117 lcd_data(0x07);
118 lcd_data(0x00);
119
120 lcd_cmd(0xE1);
121 lcd_data(0x00);
122 lcd_data(0x23);
123 lcd_data(0x24);
124 lcd_data(0x07);
125 lcd_data(0x10);
126 lcd_data(0x07);
127 lcd_data(0x38);
128 lcd_data(0x47);
129 lcd_data(0x4B);
130 lcd_data(0x0A);
131 lcd_data(0x13);
132 lcd_data(0x06);
133 lcd_data(0x30);
134 lcd_data(0x38);
135 lcd_data(0x0F);
136
137 lcd_cmd(0x2A);
138 lcd_data(0x00);
139 lcd_data(0x00);
140 lcd_data(0x00);
141 lcd_data(0xEF);
142
143 lcd_cmd(0x2B);
144 lcd_data(0x00);
145 lcd_data(0x00);
146 lcd_data(0x01);
147 lcd_data(0x3F);
148
149 lcd_cmd(0x11);
150
151 mdelay(120);
152
153 lcd_cmd(0x29);
154
155 lcd_cmd(0x2C);
156
157 for (x = 0; x < LCD_WIDTH; x++)
158 for(y=0; y < LCD_HEIGHT; y++)
159 lcd_data(0x00);
160
161 display_on = true;
162}
163
164void lcd_enable (bool on)
165{
166 if (on == display_on)
167 return;
168
169 lcdctrl_bypass(1);
170 LCDC_CTRL |= RGB24B;
171
172 if (on) {
173 lcd_cmd(0x11);
174 mdelay(120);
175 lcd_cmd(0x29);
176 lcd_cmd(0x2C);
177 } else {
178 lcd_cmd(0x28);
179 mdelay(120);
180 lcd_cmd(0x10);
181 }
182
183 display_on = on;
184 LCDC_CTRL &= ~RGB24B;
185}
186
187void lcd_set_gram_area(int x_start, int y_start,
188 int x_end, int y_end)
189{
190 lcdctrl_bypass(1);
191 LCDC_CTRL |= RGB24B;
192
193 lcd_cmd(0x2A);
194 lcd_data((x_start&0xff00)>>8);
195 lcd_data(x_start&0x00ff);
196 lcd_data((x_end&0xff00)>>8);
197 lcd_data(x_end&0x00ff);
198
199 lcd_cmd(0x2B);
200 lcd_data((y_start&0xff00)>>8);
201 lcd_data(y_start&0x00ff);
202 lcd_data((y_end&0xff00)>>8);
203 lcd_data(y_end&0x00ff);
204
205 lcd_cmd(0x2C);
206
207 LCDC_CTRL &= ~RGB24B;
208}
209
210bool lcd_active()
211{
212 return display_on;
213}
214
215/* Blit a YUV bitmap directly to the LCD */
216void lcd_blit_yuv(unsigned char * const src[3],
217 int src_x, int src_y, int stride,
218 int x, int y, int width, int height)
219{
220 (void)src;
221 (void)src_x;
222 (void)src_y;
223 (void)stride;
224 (void)x;
225 (void)y;
226 (void)width;
227 (void)height;
228}
diff --git a/firmware/target/arm/rk27xx/ihifi2/lcd-target.h b/firmware/target/arm/rk27xx/ihifi2/lcd-target.h
new file mode 100644
index 0000000000..6b2aa5d8a5
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/lcd-target.h
@@ -0,0 +1,26 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22#ifndef LCD_TARGET_H
23#define LCD_TARGET_H
24
25#define LCD_DATABUS_WIDTH LCDIF_16BIT
26#endif
diff --git a/firmware/target/arm/rk27xx/ihifi2/power-ihifi.c b/firmware/target/arm/rk27xx/ihifi2/power-ihifi.c
new file mode 100644
index 0000000000..cc489eacfe
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/power-ihifi.c
@@ -0,0 +1,53 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdbool.h>
22#include "config.h"
23#include "inttypes.h"
24#include "power.h"
25#include "panic.h"
26#include "system.h"
27#include "usb_core.h" /* for usb_charging_maxcurrent_change */
28#include "adc.h"
29
30void power_off(void)
31{
32 GPIO_PCCON &= ~(1<<0);
33 while(1);
34}
35
36void power_init(void)
37{
38 GPIO_PCDR |= (1<<0);
39 GPIO_PCCON |= (1<<0);
40
41 GPIO_PADR &= ~(1<<7); /* MUTE */
42 GPIO_PACON |= (1<<7);
43}
44
45unsigned int power_input_status(void)
46{
47 return (usb_detect() == USB_INSERTED) ? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
48}
49
50bool charging_state(void)
51{
52 return (adc_read(ADC_EXTRA) < 512);
53}
diff --git a/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770.c b/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770.c
new file mode 100644
index 0000000000..b0ff4f5a7b
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26
27/* Battery voltage calculation and discharge/charge curves for the iHiFi 770
28
29 Battery voltage is calculated under the assumption that the adc full-scale
30 readout represents 3.00V and that the battery ADC channel is fed with
31 exactly half of the battery voltage (through a resistive divider).
32 Charge curve have not been calibrated yet.
33*/
34
35const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
36{
37 /* 5% */
38 3500,
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 /* 0% */
44 3300,
45};
46
47/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
48const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
49{
50 { 3300, 3570, 3660, 3696, 3712, 3742, 3798, 3865, 3935, 4020, 4130 }
51};
52
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
54const unsigned short percent_to_volt_charge[11] =
55 { 3300, 3570, 3660, 3696, 3712, 3742, 3798, 3865, 3935, 4020, 4130 };
56
57/* full-scale ADC readout (2^10) in millivolt */
58#define BATTERY_SCALE_FACTOR 6296
59
60/* Returns battery voltage from ADC [millivolts] */
61int _battery_voltage(void)
62{
63 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
64}
diff --git a/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770c.c b/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770c.c
new file mode 100644
index 0000000000..613553010b
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi770c.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26
27/* Battery voltage calculation and discharge/charge curves for the iHiFi 770C
28
29 Battery voltage is calculated under the assumption that the adc full-scale
30 readout represents 3.00V and that the battery ADC channel is fed with
31 exactly half of the battery voltage (through a resistive divider).
32 Charge curve have not been calibrated yet.
33*/
34
35const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
36{
37 /* 5% */
38 3500,
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 /* 0% */
44 3300,
45};
46
47/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
48const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
49{
50 { 3300, 3570, 3660, 3696, 3712, 3742, 3798, 3865, 3935, 4020, 4130 }
51};
52
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
54const unsigned short percent_to_volt_charge[11] =
55 { 3300, 3570, 3660, 3696, 3712, 3742, 3798, 3865, 3935, 4020, 4130 };
56
57/* full-scale ADC readout (2^10) in millivolt */
58#define BATTERY_SCALE_FACTOR 6296
59
60/* Returns battery voltage from ADC [millivolts] */
61int _battery_voltage(void)
62{
63 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
64}
diff --git a/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi800.c b/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi800.c
new file mode 100644
index 0000000000..26f4e47b93
--- /dev/null
+++ b/firmware/target/arm/rk27xx/ihifi2/powermgmt-ihifi800.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26
27/* Battery voltage calculation and discharge/charge curves for the iHiFi 800
28
29 Battery voltage is calculated under the assumption that the adc full-scale
30 readout represents 3.00V and that the battery ADC channel is fed with
31 exactly half of the battery voltage (through a resistive divider).
32 Charge curve have not been calibrated yet.
33*/
34
35const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
36{
37 /* 5% */
38 3628,
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 /* 0% */
44 3300,
45};
46
47/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
48const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
49{
50 { 3300, 3649, 3701, 3726, 3745, 3778, 3831, 3904, 3965, 4056, 4160 }
51};
52
53/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
54const unsigned short percent_to_volt_charge[11] =
55 { 3300, 3649, 3701, 3726, 3745, 3778, 3831, 3904, 3965, 4056, 4160 };
56
57/* full-scale ADC readout (2^10) in millivolt */
58#define BATTERY_SCALE_FACTOR 6296
59
60/* Returns battery voltage from ADC [millivolts] */
61int _battery_voltage(void)
62{
63 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
64}
diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c
index 2ddfd0cf0a..e5467058de 100644
--- a/firmware/target/arm/rk27xx/sd-rk27xx.c
+++ b/firmware/target/arm/rk27xx/sd-rk27xx.c
@@ -97,7 +97,7 @@ void INT_SD(void)
97 /* get the status */ 97 /* get the status */
98 cmd_error = SD_CMDRES; 98 cmd_error = SD_CMDRES;
99 semaphore_release(&command_completion_signal); 99 semaphore_release(&command_completion_signal);
100 } 100 }
101 101
102 /* data transfer status pending */ 102 /* data transfer status pending */
103 if(status & DATA_XFER_STAT) 103 if(status & DATA_XFER_STAT)
@@ -140,13 +140,15 @@ static void mmu_buff_reset(void)
140 140
141static inline bool card_detect_target(void) 141static inline bool card_detect_target(void)
142{ 142{
143#if defined(RK27_GENERIC) 143#if defined(RK27_GENERIC) || defined(IHIFI770) || defined(IHIFI770C) || defined(IHIFI800)
144/* My generic device uses PC7 pin, active low */ 144 /* PC7, active low */
145 return !(GPIO_PCDR & 0x80); 145 return !(GPIO_PCDR & 0x80);
146#elif defined(HM60X) || defined(HM801) 146#elif defined(HM60X) || defined(HM801)
147 /* PF2, active low */
147 return !(GPIO_PFDR & (1<<2)); 148 return !(GPIO_PFDR & (1<<2));
148#elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) 149#elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C)
149 return (GPIO_PCDR & 0x80); 150 /* PC7, active high */
151 return (GPIO_PCDR & (1<<7));
150#elif defined(IHIFI760) || defined(IHIFI960) 152#elif defined(IHIFI760) || defined(IHIFI960)
151 /* TODO: find out pin */ 153 /* TODO: find out pin */
152 return true; 154 return true;
@@ -190,7 +192,7 @@ static bool send_cmd(const int cmd, const int arg, const int res,
190#if 0 192#if 0
191/* for some misterious reason the card does not report itself as being in TRAN 193/* for some misterious reason the card does not report itself as being in TRAN
192 * but transfers are successful. Rockchip OF does not check the card state 194 * but transfers are successful. Rockchip OF does not check the card state
193 * after SELECT. I checked two different cards. 195 * after SELECT. I checked two different cards.
194 */ 196 */
195static void print_card_status(void) 197static void print_card_status(void)
196{ 198{
@@ -224,7 +226,7 @@ static int sd_wait_for_tran_state(void)
224 { 226 {
225 return 0; 227 return 0;
226 } 228 }
227 229
228 if(TIME_AFTER(current_tick, timeout)) 230 if(TIME_AFTER(current_tick, timeout))
229 { 231 {
230 return -10 * ((response >> 9) & 0xf); 232 return -10 * ((response >> 9) & 0xf);
@@ -265,7 +267,7 @@ static int sd_init_card(void)
265 /* CMD0 Go Idle */ 267 /* CMD0 Go Idle */
266 if(!send_cmd(SD_GO_IDLE_STATE, 0, RES_NO, NULL)) 268 if(!send_cmd(SD_GO_IDLE_STATE, 0, RES_NO, NULL))
267 return -1; 269 return -1;
268 270
269 sleep(1); 271 sleep(1);
270 272
271 /* CMD8 Check for v2 sd card. Must be sent before using ACMD41 273 /* CMD8 Check for v2 sd card. Must be sent before using ACMD41
@@ -671,7 +673,7 @@ int sd_write_sectors(IF_MD(int drive,) unsigned long start, int count,
671#endif 673#endif
672 674
673 return ret; 675 return ret;
674 676
675#endif /* defined(BOOTLOADER) */ 677#endif /* defined(BOOTLOADER) */
676} 678}
677 679
diff --git a/firmware/target/arm/rk27xx/usb-drv-rk27xx.c b/firmware/target/arm/rk27xx/usb-drv-rk27xx.c
index badc3ab5ed..057ecf6ebc 100644
--- a/firmware/target/arm/rk27xx/usb-drv-rk27xx.c
+++ b/firmware/target/arm/rk27xx/usb-drv-rk27xx.c
@@ -28,37 +28,16 @@
28#include "kernel.h" 28#include "kernel.h"
29#include "panic.h" 29#include "panic.h"
30 30
31//#include "usb-s3c6400x.h"
32
33#include "usb_ch9.h" 31#include "usb_ch9.h"
34#include "usb_core.h" 32#include "usb_core.h"
35#include <inttypes.h> 33#include <inttypes.h>
36#include "power.h" 34#include "power.h"
37 35
36#define LOGF_ENABLE
38#include "logf.h" 37#include "logf.h"
39 38
40typedef volatile uint32_t reg32; 39typedef volatile uint32_t reg32;
41 40
42/* Bulk OUT: ep1, ep4, ep7, ep10, ep13 */
43#define BOUT_RXSTAT(ep_num) (*(reg32*)(AHB0_UDC+0x54+0x38*(ep_num/3)))
44#define BOUT_RXCON(ep_num) (*(reg32*)(AHB0_UDC+0x58+0x38*(ep_num/3)))
45#define BOUT_DMAOUTCTL(ep_num) (*(reg32*)(AHB0_UDC+0x5C+0x38*(ep_num/3)))
46#define BOUT_DMAOUTLMADDR(ep_num) (*(reg32*)(AHB0_UDC+0x60+0x38*(ep_num/3)))
47
48/* Bulk IN: ep2, ep5, ep8, ep11, ep4 */
49#define BIN_TXSTAT(ep_num) (*(reg32*)(AHB0_UDC+0x64+0x38*(ep_num/3)))
50#define BIN_TXCON(ep_num) (*(reg32*)(AHB0_UDC+0x68+0x38*(ep_num/3)))
51#define BIN_TXBUF(ep_num) (*(reg32*)(AHB0_UDC+0x6C+0x38*(ep_num/3)))
52#define BIN_DMAINCTL(ep_num) (*(reg32*)(AHB0_UDC+0x70+0x38*(ep_num/3)))
53#define BIN_DMAINLMADDR(ep_num) (*(reg32*)(AHB0_UDC+0x74+0x38*(ep_num/3)))
54
55/* INTERRUPT IN: ep3, ep6, ep9, ep12, ep15 */
56#define IIN_TXSTAT(ep_num) (*(reg32*)(AHB0_UDC+0x78+0x38*((ep_num/3)-1)))
57#define IIN_TXCON(ep_num) (*(reg32*)(AHB0_UDC+0x7C+0x38*((ep_num/3)-1)))
58#define IIN_TXBUF(ep_num) (*(reg32*)(AHB0_UDC+0x80+0x38*((ep_num/3)-1)))
59#define IIN_DMAINCTL(ep_num) (*(reg32*)(AHB0_UDC+0x84+0x38*((ep_num/3)-1)))
60#define IIN_DMAINLMADDR(ep_num) (*(reg32*)(AHB0_UDC+0x88+0x38*((ep_num/3)-1)))
61
62#ifdef LOGF_ENABLE 41#ifdef LOGF_ENABLE
63#define XFER_DIR_STR(dir) ((dir) ? "IN" : "OUT") 42#define XFER_DIR_STR(dir) ((dir) ? "IN" : "OUT")
64#define XFER_TYPE_STR(type) \ 43#define XFER_TYPE_STR(type) \
@@ -68,9 +47,12 @@ typedef volatile uint32_t reg32;
68 ((type) == USB_ENDPOINT_XFER_INT ? "INTR" : "INVL")))) 47 ((type) == USB_ENDPOINT_XFER_INT ? "INTR" : "INVL"))))
69#endif 48#endif
70 49
71struct endpoint_t { 50struct endpoint_t
51{
52 const int ep_num; /* EP number */
72 const int type; /* EP type */ 53 const int type; /* EP type */
73 const int dir; /* DIR_IN/DIR_OUT */ 54 const int dir; /* DIR_IN/DIR_OUT */
55 volatile unsigned long *stat; /* RXSTAT/TXSTAT register */
74 bool allocated; /* flag to mark EPs taken */ 56 bool allocated; /* flag to mark EPs taken */
75 volatile void *buf; /* tx/rx buffer address */ 57 volatile void *buf; /* tx/rx buffer address */
76 volatile int len; /* size of the transfer (bytes) */ 58 volatile int len; /* size of the transfer (bytes) */
@@ -79,110 +61,91 @@ struct endpoint_t {
79 struct semaphore complete; /* semaphore for blocking transfers */ 61 struct semaphore complete; /* semaphore for blocking transfers */
80}; 62};
81 63
82#define EP_INIT(_type, _dir, _alloced, _buf, _len, _cnt, _block) \ 64/* compute RXCON address from RXSTAT, and so on */
83 { .type = (_type), .dir = (_dir), .allocated = (_alloced), .buf = (_buf), \ 65#define RXSTAT(endp) *((endp)->stat)
84 .len = (_len), .cnt = (_cnt), .block = (_block) } 66#define RXCON(endp) *(1 + (endp)->stat)
85 67#define DMAOUTCTL(endp) *(2 + (endp)->stat)
86static struct endpoint_t ctrlep[2] = { 68#define DMAOUTLMADDR(endp) *(3 + (endp)->stat)
87 EP_INIT(USB_ENDPOINT_XFER_CONTROL, DIR_OUT, true, NULL, 0, 0, true), 69/* compute TXCON address from TXSTAT, and so on */
88 EP_INIT(USB_ENDPOINT_XFER_CONTROL, DIR_IN, true, NULL, 0, 0, true), 70#define TXSTAT(endp) *((endp)->stat)
71#define TXCON(endp) *(1 + (endp)->stat)
72#define TXBUF(endp) *(2 + (endp)->stat)
73#define DMAINCTL(endp) *(3 + (endp)->stat)
74#define DMAINLMADDR(endp) *(4 + (endp)->stat)
75
76#define ENDPOINT(num, type, dir, reg) \
77 {num, USB_ENDPOINT_XFER_##type, USB_DIR_##dir, reg, false, NULL, 0, 0, true, {{0, 0}, 0, 0}}
78
79static struct endpoint_t ctrlep[2] =
80{
81 ENDPOINT(0, CONTROL, OUT, &RX0STAT),
82 ENDPOINT(0, CONTROL, IN, &TX0STAT),
89}; 83};
90 84
91static struct endpoint_t endpoints[16] = { 85static struct endpoint_t endpoints[16] =
92 EP_INIT(USB_ENDPOINT_XFER_CONTROL, 3, true, NULL, 0, 0, true ), /* stub */ 86{
93 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_OUT, false, NULL, 0, 0, false ), /* BOUT1 */ 87 ENDPOINT(0, CONTROL, OUT, NULL), /* stub */
94 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_IN, false, NULL, 0, 0, false ), /* BIN2 */ 88 ENDPOINT(1, BULK, OUT, &RX1STAT), /* BOUT1 */
95 EP_INIT(USB_ENDPOINT_XFER_INT, DIR_IN, false, NULL, 0, 0, false ), /* IIN3 */ 89 ENDPOINT(2, BULK, IN, &TX2STAT), /* BIN2 */
96 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_OUT, false, NULL, 0, 0, false ), /* BOUT4 */ 90 ENDPOINT(3, INT, IN, &TX3STAT), /* IIN3 */
97 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_IN, false, NULL, 0, 0, false ), /* BIN5 */ 91 ENDPOINT(4, BULK, OUT, &RX4STAT), /* BOUT4 */
98 EP_INIT(USB_ENDPOINT_XFER_INT, DIR_IN, false, NULL, 0, 0, false ), /* IIN6 */ 92 ENDPOINT(5, BULK, IN, &TX5STAT), /* BIN5 */
99 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_OUT, false, NULL, 0, 0, false ), /* BOUT7 */ 93 ENDPOINT(6, INT, IN, &TX6STAT), /* IIN6 */
100 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_IN, false, NULL, 0, 0, false ), /* BIN8 */ 94 ENDPOINT(7, BULK, OUT, &RX7STAT), /* BOUT7 */
101 EP_INIT(USB_ENDPOINT_XFER_INT, DIR_IN, false, NULL, 0, 0, false ), /* IIN9 */ 95 ENDPOINT(8, BULK, IN, &TX8STAT), /* BIN8 */
102 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_OUT, false, NULL, 0, 0, false ), /* BOUT10 */ 96 ENDPOINT(9, INT, IN, &TX9STAT), /* IIN9 */
103 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_IN, false, NULL, 0, 0, false ), /* BIN11 */ 97 ENDPOINT(10, BULK, OUT, &RX10STAT), /* BOUT10 */
104 EP_INIT(USB_ENDPOINT_XFER_INT, DIR_IN, false, NULL, 0, 0, false ), /* IIN12 */ 98 ENDPOINT(11, BULK, IN, &TX11STAT), /* BIN11 */
105 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_OUT, false, NULL, 0, 0, false ), /* BOUT13 */ 99 ENDPOINT(12, INT, IN, &TX12STAT), /* IIN12 */
106 EP_INIT(USB_ENDPOINT_XFER_BULK, DIR_IN, false, NULL, 0, 0, false ), /* BIN14 */ 100 ENDPOINT(13, BULK, OUT, &RX13STAT), /* BOUT13 */
107 EP_INIT(USB_ENDPOINT_XFER_INT, DIR_IN, false, NULL, 0, 0, false ), /* IIN15 */ 101 ENDPOINT(14, BULK, IN, &TX14STAT), /* BIN14 */
102 ENDPOINT(15, INT, IN, &TX15STAT), /* IIN15 */
108}; 103};
109 104
105static volatile bool set_address = false;
106static volatile bool set_configuration = false;
107
108#undef ENDPOINT
109
110static void setup_received(void) 110static void setup_received(void)
111{ 111{
112 static uint32_t setup_data[2]; 112 static uint32_t setup_data[2];
113 113 logf("udc: setup");
114
114 /* copy setup data from packet */ 115 /* copy setup data from packet */
115 setup_data[0] = SETUP1; 116 setup_data[0] = SETUP1;
116 setup_data[1] = SETUP2; 117 setup_data[1] = SETUP2;
117 118
118 /* clear all pending control transfers
119 * do we need this here?
120 */
121
122 /* pass setup data to the upper layer */ 119 /* pass setup data to the upper layer */
123 usb_core_control_request((struct usb_ctrlrequest*)setup_data); 120 usb_core_control_request((struct usb_ctrlrequest*)setup_data);
124} 121}
125 122
126/* service ep0 IN transaction */ 123static int max_pkt_size(struct endpoint_t *endp)
127static void ctr_write(void)
128{ 124{
129 int xfer_size = (ctrlep[DIR_IN].cnt > 64) ? 64 : ctrlep[DIR_IN].cnt; 125 switch(endp->type)
130 unsigned int timeout = current_tick + HZ/10;
131
132 while (TX0BUF & TXFULL) /* TX0FULL flag */
133 { 126 {
134 if(TIME_AFTER(current_tick, timeout)) 127 case USB_ENDPOINT_XFER_CONTROL: return 64;
135 break; 128 case USB_ENDPOINT_XFER_BULK: return usb_drv_port_speed() ? 512 : 64;
129 case USB_ENDPOINT_XFER_INT: return usb_drv_port_speed() ? 1024 : 64;
130 default: panicf("die"); return 0;
136 } 131 }
137
138 TX0STAT = xfer_size; /* size of the transfer */
139 TX0DMALM_IADDR = (uint32_t)ctrlep[DIR_IN].buf; /* local buffer address */
140 TX0DMAINCTL = DMA_START; /* start DMA */
141 TX0CON &= ~TXNAK; /* clear NAK */
142
143 /* Decrement by max packet size is intentional.
144 * This way if we have final packet short one we will get negative len
145 * after transfer, which in turn indicates we *don't* need to send
146 * zero length packet. If the final packet is max sized packet we will
147 * get zero len after transfer which indicates we need to send
148 * zero length packet to signal host end of the transfer.
149 */
150 ctrlep[DIR_IN].cnt -= 64;
151 ctrlep[DIR_IN].buf += xfer_size;
152}
153
154static void ctr_read(void)
155{
156 int xfer_size = RX0STAT & 0xffff;
157
158 /* clear NAK bit */
159 RX0CON &= ~RXNAK;
160
161 ctrlep[DIR_OUT].cnt -= xfer_size;
162 ctrlep[DIR_OUT].buf += xfer_size;
163
164 RX0DMAOUTLMADDR = (uint32_t)ctrlep[DIR_OUT].buf; /* buffer address */
165 RX0DMACTLO = DMA_START; /* start DMA */
166} 132}
167 133
168static void blk_write(int ep) 134static void ep_write(struct endpoint_t *endp)
169{ 135{
170 int ep_num = EP_NUM(ep); 136 int xfer_size = MIN(max_pkt_size(endp), endp->cnt);
171 int max = usb_drv_port_speed() ? 512 : 64;
172 int xfer_size = (endpoints[ep_num].cnt > max) ? max : endpoints[ep_num].cnt;
173 unsigned int timeout = current_tick + HZ/10; 137 unsigned int timeout = current_tick + HZ/10;
174 138
175 while (BIN_TXBUF(ep_num) & TXFULL) /* TXFULL flag */ 139 while(TXBUF(endp) & TXFULL) /* TXFULL flag */
176 { 140 {
177 if(TIME_AFTER(current_tick, timeout)) 141 if(TIME_AFTER(current_tick, timeout))
178 break; 142 break;
179 } 143 }
180 144
181 BIN_TXSTAT(ep_num) = xfer_size; /* size */ 145 /* setup transfer size and DMA */
182 BIN_DMAINLMADDR(ep_num) = (uint32_t)endpoints[ep_num].buf; /* buf address */ 146 TXSTAT(endp) = xfer_size;
183 BIN_DMAINCTL(ep_num) = DMA_START; /* start DMA */ 147 DMAINLMADDR(endp) = (uint32_t)endp->buf; /* local buffer address */
184 BIN_TXCON(ep_num) &= ~TXNAK; /* clear NAK */ 148 DMAINCTL(endp) = DMA_START;
185
186 /* Decrement by max packet size is intentional. 149 /* Decrement by max packet size is intentional.
187 * This way if we have final packet short one we will get negative len 150 * This way if we have final packet short one we will get negative len
188 * after transfer, which in turn indicates we *don't* need to send 151 * after transfer, which in turn indicates we *don't* need to send
@@ -190,247 +153,141 @@ static void blk_write(int ep)
190 * get zero len after transfer which indicates we need to send 153 * get zero len after transfer which indicates we need to send
191 * zero length packet to signal host end of the transfer. 154 * zero length packet to signal host end of the transfer.
192 */ 155 */
193 endpoints[ep_num].cnt -= max; 156 endp->cnt -= max_pkt_size(endp);
194 endpoints[ep_num].buf += xfer_size; 157 endp->buf += xfer_size;
158 /* clear NAK */
159 TXCON(endp) &= ~TXNAK;
195} 160}
196 161
197static void blk_read(int ep) 162static void ep_read(struct endpoint_t *endp)
198{ 163{
199 int ep_num = EP_NUM(ep); 164 /* setup DMA */
200 int xfer_size = BOUT_RXSTAT(ep_num) & 0xffff; 165 DMAOUTLMADDR(endp) = (uint32_t)endp->buf; /* local buffer address */
201 166 DMAOUTCTL(endp) = DMA_START;
202 /* clear NAK bit */ 167 /* clear NAK */
203 BOUT_RXCON(ep_num) &= ~RXNAK; 168 RXCON(endp) &= ~RXNAK;
204
205 endpoints[ep_num].cnt -= xfer_size;
206 endpoints[ep_num].buf += xfer_size;
207
208 BOUT_DMAOUTLMADDR(ep_num) = (uint32_t)endpoints[ep_num].buf;
209 BOUT_DMAOUTCTL(ep_num) = DMA_START;
210}
211
212static void int_write(int ep)
213{
214 int ep_num = EP_NUM(ep);
215 int max = usb_drv_port_speed() ? 1024 : 64;
216 int xfer_size = (endpoints[ep_num].cnt > max) ? max : endpoints[ep_num].cnt;
217 unsigned int timeout = current_tick + HZ/10;
218
219 while (IIN_TXBUF(ep_num) & TXFULL) /* TXFULL flag */
220 {
221 if(TIME_AFTER(current_tick, timeout))
222 break;
223 }
224
225 IIN_TXSTAT(ep_num) = xfer_size; /* size */
226 IIN_DMAINLMADDR(ep_num) = (uint32_t)endpoints[ep_num].buf; /* buf address */
227 IIN_DMAINCTL(ep_num) = DMA_START; /* start DMA */
228 IIN_TXCON(ep_num) &= ~TXNAK; /* clear NAK */
229
230 /* Decrement by max packet size is intentional.
231 * This way if we have final packet short one we will get negative len
232 * after transfer, which in turn indicates we *don't* need to send
233 * zero length packet. If the final packet is max sized packet we will
234 * get zero len after transfer which indicates we need to send
235 * zero length packet to signal host end of the transfer.
236 */
237 endpoints[ep_num].cnt -= max;
238 endpoints[ep_num].buf += xfer_size;
239} 169}
240 170
241/* UDC ISR function */ 171static void in_intr(struct endpoint_t *endp)
242void INT_UDC(void)
243{ 172{
244 uint32_t txstat, rxstat; 173 uint32_t txstat = TXSTAT(endp);
245 int tmp, ep_num; 174 /* check if clear feature was sent by host */
246 175 if(txstat & TXCFINT)
247 /* read what caused UDC irq */
248 uint32_t intsrc = INT2FLAG & 0x7fffff;
249
250 if (intsrc & SETUP_INTR) /* setup interrupt */
251 { 176 {
252 setup_received(); 177 logf("clear_stall: %d", endp->ep_num);
178 usb_drv_stall(endp->ep_num, false, true);
253 } 179 }
254 else if (intsrc & IN0_INTR) /* ep0 in interrupt */ 180 /* check if a transfer has finished */
181 if(txstat & TXACK)
255 { 182 {
256 txstat = TX0STAT; /* read clears flags */ 183 logf("udc: ack(%d)", endp->ep_num);
257 184 /* finished ? */
258 /* TODO handle errors */ 185 if(endp->cnt <= 0)
259 if (txstat & TXACK) /* check TxACK flag */
260 { 186 {
261 if (ctrlep[DIR_IN].cnt >= 0) 187 usb_core_transfer_complete(endp->ep_num, endp->dir, 0, endp->len);
262 { 188 /* release semaphore for blocking transfer */
263 /* we still have data to send (or ZLP) */ 189 if(endp->block)
264 ctr_write(); 190 semaphore_release(&endp->complete);
265 }
266 else
267 {
268 /* final ack received */
269 usb_core_transfer_complete(0, /* ep */
270 USB_DIR_IN, /* dir */
271 0, /* status */
272 ctrlep[DIR_IN].len); /* length */
273
274 /* release semaphore for blocking transfer */
275 if (ctrlep[DIR_IN].block)
276 semaphore_release(&ctrlep[DIR_IN].complete);
277 }
278 } 191 }
192 else /* more data to send */
193 ep_write(endp);
279 } 194 }
280 else if (intsrc & OUT0_INTR) /* ep0 out interrupt */ 195}
281 {
282 rxstat = RX0STAT;
283 196
284 /* TODO handle errors */ 197static void out_intr(struct endpoint_t *endp)
285 if (rxstat & RXACK) /* RxACK */ 198{
286 { 199 uint32_t rxstat = RXSTAT(endp);
287 if (ctrlep[DIR_OUT].cnt > 0) 200 logf("udc: out intr(%d)", endp->ep_num);
288 ctr_read(); 201 /* check if clear feature was sent by host */
289 else 202 if(rxstat & RXCFINT)
290 usb_core_transfer_complete(0, /* ep */
291 USB_DIR_OUT, /* dir */
292 0, /* status */
293 ctrlep[DIR_OUT].len); /* length */
294 }
295 }
296 else if (intsrc & USBRST_INTR) /* usb reset */
297 {
298 usb_drv_init();
299 }
300 else if (intsrc & RESUME_INTR) /* usb resume */
301 {
302 TX0CON |= TXCLR; /* TxClr */
303 TX0CON &= ~TXCLR;
304 RX0CON |= RXCLR; /* RxClr */
305 RX0CON &= ~RXCLR;
306 }
307 else if (intsrc & SUSP_INTR) /* usb suspend */
308 { 203 {
204 logf("clear_stall: %d", endp->ep_num);
205 usb_drv_stall(endp->ep_num, false, false);
309 } 206 }
310 else if (intsrc & CONN_INTR) /* usb connect */ 207 /* check if a transfer has finished */
208 if(rxstat & RXACK)
311 { 209 {
210 int xfer_size = rxstat & 0xffff;
211 endp->cnt -= xfer_size;
212 endp->buf += xfer_size;
213 logf("udc: ack(%d) -> %d/%d", endp->ep_num, xfer_size, endp->cnt);
214 /* finished ? */
215 if(endp->cnt <= 0 || xfer_size < max_pkt_size(endp))
216 usb_core_transfer_complete(endp->ep_num, endp->dir, 0, endp->len);
217 else
218 ep_read(endp);
312 } 219 }
313 else 220}
314 { 221
315 /* lets figure out which ep generated irq */ 222static void udc_phy_reset(void)
316 tmp = intsrc >> 7; 223{
317 for (ep_num=1; ep_num < 15; ep_num++) 224 DEV_CTL |= SOFT_POR;
318 { 225 udelay(10000); /* min 10ms */
319 tmp >>= ep_num; 226 DEV_CTL &= ~SOFT_POR;
320 if (tmp & 0x01) 227}
321 break; 228
322 } 229static void udc_soft_connect(void)
323 230{
324 if (intsrc & ((1<<8)|(1<<11)|(1<<14)|(1<<17)|(1<<20))) 231 DEV_CTL |= CSR_DONE |
325 { 232 DEV_SOFT_CN |
326 /* bulk out */ 233 DEV_SELF_PWR;
327 rxstat = BOUT_RXSTAT(ep_num); 234}
328 235
329 /* TODO handle errors */ 236static void udc_helper(void)
330 if (rxstat & (1<<18)) /* RxACK */ 237{
331 { 238 uint32_t dev_info = DEV_INFO;
332 if (endpoints[ep_num].cnt > 0) 239
333 blk_read(ep_num); 240 /* This polls for DEV_EN bit set in DEV_INFO register
334 else 241 * as well as tracks current requested configuration
335 usb_core_transfer_complete(ep_num, /* ep */ 242 * (DEV_INFO [11:8]). On state change it notifies usb stack
336 USB_DIR_OUT, /* dir */ 243 * about it.
337 0, /* status */ 244 */
338 endpoints[ep_num].len); /* length */ 245
339 } 246 /* SET ADDRESS request */
340 } 247 if(!set_address)
341 else if (intsrc & ((1<<9)|(1<<12)|(1<<15)|(1<<18)|(1<<21))) 248 if(dev_info & 0x7f)
342 { 249 {
343 /* bulk in */ 250 set_address = true;
344 txstat = BIN_TXSTAT(ep_num); 251 usb_core_notify_set_address(dev_info & 0x7f);
345
346 /* TODO handle errors */
347 if (txstat & (1<<18)) /* check TxACK flag */
348 {
349 if (endpoints[ep_num].cnt >= 0)
350 {
351 /* we still have data to send (or ZLP) */
352 blk_write(ep_num);
353 }
354 else
355 {
356 /* final ack received */
357 usb_core_transfer_complete(ep_num, /* ep */
358 USB_DIR_IN, /* dir */
359 0, /* status */
360 endpoints[ep_num].len); /* length */
361
362 /* release semaphore for blocking transfer */
363 if (endpoints[ep_num].block)
364 semaphore_release(&endpoints[ep_num].complete);
365 }
366 }
367 } 252 }
368 else if (intsrc & ((1<<10)|(1<13)|(1<<16)|(1<<19)|(1<<22))) 253
254 /* SET CONFIGURATION request */
255 if(!set_configuration)
256 if(dev_info & DEV_EN)
369 { 257 {
370 /* int in */ 258 set_configuration = true;
371 txstat = IIN_TXSTAT(ep_num); 259 usb_core_notify_set_config(((dev_info >> 7) & 0xf) + 1);
372
373 /* TODO handle errors */
374 if (txstat & TXACK) /* check TxACK flag */
375 {
376 if (endpoints[ep_num].cnt >= 0)
377 {
378 /* we still have data to send (or ZLP) */
379 int_write(ep_num);
380 }
381 else
382 {
383 /* final ack received */
384 usb_core_transfer_complete(ep_num, /* ep */
385 USB_DIR_IN, /* dir */
386 0, /* status */
387 endpoints[ep_num].len); /* length */
388
389 /* release semaphore for blocking transfer */
390 if (endpoints[ep_num].block)
391 semaphore_release(&endpoints[ep_num].complete);
392 }
393 }
394 } 260 }
395 }
396} 261}
397 262
398/* return port speed FS=0, HS=1 */ 263/* return port speed FS=0, HS=1 */
399int usb_drv_port_speed(void) 264int usb_drv_port_speed(void)
400{ 265{
401 return ((DEV_INFO & DEV_SPEED) == 0) ? 0 : 1; 266 return (DEV_INFO & DEV_SPEED) ? 0 : 1;
402} 267}
403 268
404/* Reserve endpoint */ 269/* Reserve endpoint */
405int usb_drv_request_endpoint(int type, int dir) 270int usb_drv_request_endpoint(int type, int dir)
406{ 271{
407 int ep_num, ep_dir; 272 logf("req: %s %s", XFER_DIR_STR(dir), XFER_TYPE_STR(type));
408 int ep_type;
409
410 /* Safety */
411 ep_dir = EP_DIR(dir);
412 ep_type = type & USB_ENDPOINT_XFERTYPE_MASK;
413 273
414 logf("req: %s %s", XFER_DIR_STR(ep_dir), XFER_TYPE_STR(ep_type));
415
416 /* Find an available ep/dir pair */ 274 /* Find an available ep/dir pair */
417 for (ep_num=1;ep_num<USB_NUM_ENDPOINTS;ep_num++) 275 for(int ep_num = 1; ep_num<USB_NUM_ENDPOINTS;ep_num++)
418 { 276 {
419 struct endpoint_t* endpoint = &endpoints[ep_num]; 277 struct endpoint_t *endp = &endpoints[ep_num];
420 278
421 if (endpoint->type == ep_type && 279 if(endp->allocated || endp->type != type || endp->dir != dir)
422 endpoint->dir == ep_dir && 280 continue;
423 !endpoint->allocated) 281 /* allocate endpoint and enable interrupt */
424 { 282 endp->allocated = true;
425 /* mark endpoint as taken */ 283 if(dir == USB_DIR_IN)
426 endpoint->allocated = true; 284 TXCON(endp) = (ep_num << 8) | TXEPEN | TXNAK | TXACKINTEN | TXCFINTE;
427 285 else
428 /* enable interrupt from this endpoint */ 286 RXCON(endp) = (ep_num << 8) | RXEPEN | RXNAK | RXACKINTEN | RXCFINTE | RXERRINTEN;
429 EN_INT |= (1<<(ep_num+7)); 287 EN_INT |= 1 << (ep_num + 7);
430 288
431 logf("add: ep%d %s", ep_num, XFER_DIR_STR(ep_dir)); 289 logf("add: ep%d %s", ep_num, XFER_DIR_STR(dir));
432 return (ep_num | (dir & USB_ENDPOINT_DIR_MASK)); 290 return ep_num | dir;
433 }
434 } 291 }
435 return -1; 292 return -1;
436} 293}
@@ -439,14 +296,12 @@ int usb_drv_request_endpoint(int type, int dir)
439void usb_drv_release_endpoint(int ep) 296void usb_drv_release_endpoint(int ep)
440{ 297{
441 int ep_num = EP_NUM(ep); 298 int ep_num = EP_NUM(ep);
442 int ep_dir = EP_DIR(ep);
443 (void) ep_dir;
444 299
445 logf("rel: ep%d %s", ep_num, XFER_DIR_STR(ep_dir)); 300 logf("rel: ep%d", ep_num);
446 endpoints[ep_num].allocated = false; 301 endpoints[ep_num].allocated = false;
447 302
448 /* disable interrupt from this endpoint */ 303 /* disable interrupt from this endpoint */
449 EN_INT &= ~(1<<(ep_num+7)); 304 EN_INT &= ~(1 << (ep_num + 7));
450} 305}
451 306
452/* Set the address (usually it's in a register). 307/* Set the address (usually it's in a register).
@@ -463,39 +318,25 @@ void usb_drv_set_address(int address)
463 318
464static int _usb_drv_send(int endpoint, void *ptr, int length, bool block) 319static int _usb_drv_send(int endpoint, void *ptr, int length, bool block)
465{ 320{
321 logf("udc: send(%x)", endpoint);
466 struct endpoint_t *ep; 322 struct endpoint_t *ep;
467 int ep_num = EP_NUM(endpoint); 323 int ep_num = EP_NUM(endpoint);
468 324
469 if (ep_num == 0) 325 if (ep_num == 0)
470 ep = &ctrlep[DIR_IN]; 326 ep = &ctrlep[DIR_IN];
471 else 327 else
472 ep = &endpoints[ep_num]; 328 ep = &endpoints[ep_num];
473 329
330 /* for send transfers, make sure the data is committed */
331 commit_discard_dcache_range(ptr, length);
474 ep->buf = ptr; 332 ep->buf = ptr;
475 ep->len = ep->cnt = length; 333 ep->len = ep->cnt = length;
476 334 ep->block = block;
477 if (block) 335
478 ep->block = true; 336 ep_write(ep);
479 else 337
480 ep->block = false; 338 /* wait for transfer to end */
481 339 if(block)
482 switch (ep->type)
483 {
484 case USB_ENDPOINT_XFER_CONTROL:
485 ctr_write();
486 break;
487
488 case USB_ENDPOINT_XFER_BULK:
489 blk_write(ep_num);
490 break;
491
492 case USB_ENDPOINT_XFER_INT:
493 int_write(ep_num);
494 break;
495 }
496
497 if (block)
498 /* wait for transfer to end */
499 semaphore_wait(&ep->complete, TIMEOUT_BLOCK); 340 semaphore_wait(&ep->complete, TIMEOUT_BLOCK);
500 341
501 return 0; 342 return 0;
@@ -516,28 +357,20 @@ int usb_drv_send_nonblocking(int endpoint, void *ptr, int length)
516/* Setup a receive transfer. (non blocking) */ 357/* Setup a receive transfer. (non blocking) */
517int usb_drv_recv(int endpoint, void* ptr, int length) 358int usb_drv_recv(int endpoint, void* ptr, int length)
518{ 359{
360 logf("udc: recv(%x)", endpoint);
519 struct endpoint_t *ep; 361 struct endpoint_t *ep;
520 int ep_num = EP_NUM(endpoint); 362 int ep_num = EP_NUM(endpoint);
521 363
522 if (ep_num == 0) 364 if(ep_num == 0)
523 {
524 ep = &ctrlep[DIR_OUT]; 365 ep = &ctrlep[DIR_OUT];
525
526 ctr_read();
527 }
528 else 366 else
529 {
530 ep = &endpoints[ep_num]; 367 ep = &endpoints[ep_num];
531 368
532 /* clear NAK bit */ 369 /* for recv, discard the cache lines related to the buffer */
533 BOUT_RXCON(ep_num) &= ~RXNAK; 370 commit_discard_dcache_range(ptr, length);
534 BOUT_DMAOUTLMADDR(ep_num) = (uint32_t)ptr;
535 BOUT_DMAOUTCTL(ep_num) = DMA_START;
536 }
537
538 ep->buf = ptr; 371 ep->buf = ptr;
539 ep->len = ep->cnt = length; 372 ep->len = ep->cnt = length;
540 373 ep_read(ep);
541 return 0; 374 return 0;
542} 375}
543 376
@@ -560,173 +393,54 @@ void usb_drv_set_test_mode(int mode)
560/* Check if endpoint is in stall state */ 393/* Check if endpoint is in stall state */
561bool usb_drv_stalled(int endpoint, bool in) 394bool usb_drv_stalled(int endpoint, bool in)
562{ 395{
563 int ep_num = EP_NUM(endpoint); 396 struct endpoint_t *endp = &endpoints[EP_NUM(endpoint)];
564
565 switch (endpoints[ep_num].type)
566 {
567 case USB_ENDPOINT_XFER_CONTROL:
568 if (in)
569 return (TX0CON & TXSTALL) ? true : false;
570 else
571 return (RX0CON & RXSTALL) ? true : false;
572
573 break;
574 397
575 case USB_ENDPOINT_XFER_BULK: 398 if(in)
576 if (in) 399 return !!(TXCON(endp) & TXSTALL);
577 return (BIN_TXCON(ep_num) & TXSTALL) ? true : false; 400 else
578 else 401 return !!(RXCON(endp) & RXSTALL);
579 return (BOUT_RXCON(ep_num) & RXSTALL) ? true : false;
580
581 break;
582
583 case USB_ENDPOINT_XFER_INT:
584 if (in)
585 return (IIN_TXCON(ep_num) & TXSTALL) ? true : false;
586 else
587 return false; /* we don't have such endpoint anyway */
588
589 break;
590 }
591
592 return false;
593} 402}
594 403
595/* Stall the endpoint. Usually set a flag in the controller */ 404/* Stall the endpoint. Usually set a flag in the controller */
596void usb_drv_stall(int endpoint, bool stall, bool in) 405void usb_drv_stall(int endpoint, bool stall, bool in)
597{ 406{
598 int ep_num = EP_NUM(endpoint); 407 struct endpoint_t *endp = &endpoints[EP_NUM(endpoint)];
599 408 if(in)
600 switch (endpoints[ep_num].type)
601 { 409 {
602 case USB_ENDPOINT_XFER_CONTROL: 410 if(stall)
603 if (in) 411 TXCON(endp) |= TXSTALL;
604 { 412 else
605 if (stall) 413 TXCON(endp) &= ~TXSTALL;
606 TX0CON |= TXSTALL; 414 }
607 else 415 else
608 TX0CON &= ~TXSTALL; 416 {
609 } 417 if(stall)
610 else 418 RXCON(endp) |= RXSTALL;
611 { 419 else
612 if (stall) 420 RXCON(endp) &= ~RXSTALL;
613 RX0CON |= RXSTALL;
614 else
615 RX0CON &= ~RXSTALL; /* doc says Auto clear by UDC 2.0 */
616 }
617 break;
618
619 case USB_ENDPOINT_XFER_BULK:
620 if (in)
621 {
622 if (stall)
623 BIN_TXCON(ep_num) |= TXSTALL;
624 else
625 BIN_TXCON(ep_num) &= ~TXSTALL;
626 }
627 else
628 {
629 if (stall)
630 BOUT_RXCON(ep_num) |= RXSTALL;
631 else
632 BOUT_RXCON(ep_num) &= ~RXSTALL;
633 }
634 break;
635
636 case USB_ENDPOINT_XFER_INT:
637 if (in)
638 {
639 if (stall)
640 IIN_TXCON(ep_num) |= TXSTALL;
641 else
642 IIN_TXCON(ep_num) &= ~TXSTALL;
643 }
644 break;
645 } 421 }
646} 422}
647 423
648/* one time init (once per connection) - basicaly enable usb core */ 424/* one time init (once per connection) - basicaly enable usb core */
649void usb_drv_init(void) 425void usb_drv_init(void)
650{ 426{
651 int ep_num;
652
653 /* enable USB clock */
654 SCU_CLKCFG &= ~CLKCFG_UDC;
655
656 /* 1. do soft disconnect */
657 DEV_CTL = DEV_SELF_PWR;
658
659 /* 2. do power on reset to PHY */
660 DEV_CTL = DEV_SELF_PWR |
661 SOFT_POR;
662
663 /* 3. wait more than 10ms */
664 udelay(20000);
665
666 /* 4. clear SOFT_POR bit */
667 DEV_CTL &= ~SOFT_POR;
668
669 /* 5. configure minimal EN_INT */
670 EN_INT = EN_SUSP_INTR | /* Enable Suspend Interrupt */
671 EN_RESUME_INTR | /* Enable Resume Interrupt */
672 EN_USBRST_INTR | /* Enable USB Reset Interrupt */
673 EN_OUT0_INTR | /* Enable OUT Token receive Interrupt EP0 */
674 EN_IN0_INTR | /* Enable IN Token transmits Interrupt EP0 */
675 EN_SETUP_INTR; /* Enable SETUP Packet Receive Interrupt */
676
677 /* 6. configure INTCON */
678 INTCON = UDC_INTHIGH_ACT | /* interrupt high active */
679 UDC_INTEN; /* enable EP0 interrupts */
680
681 /* 7. configure EP0 control registers */
682 TX0CON = TXACKINTEN | /* Set as one to enable the EP0 tx irq */
683 TXNAK; /* Set as one to response NAK handshake */
684
685 RX0CON = RXACKINTEN |
686 RXEPEN | /* Endpoint 0 Enable. When cleared the endpoint does
687 * not respond to an SETUP or OUT token
688 */
689
690 RXNAK; /* Set as one to response NAK handshake */
691
692 /* 8. write final bits to DEV_CTL */
693 DEV_CTL = CSR_DONE | /* Configure CSR done */
694 DEV_PHY16BIT | /* 16-bit data path enabled. udc_clk = 30MHz */
695 DEV_SOFT_CN | /* Device soft connect */
696 DEV_SELF_PWR; /* Device self power */
697
698 /* init semaphore of ep0 */ 427 /* init semaphore of ep0 */
699 semaphore_init(&ctrlep[DIR_OUT].complete, 1, 0); 428 semaphore_init(&ctrlep[DIR_OUT].complete, 1, 0);
700 semaphore_init(&ctrlep[DIR_IN].complete, 1, 0); 429 semaphore_init(&ctrlep[DIR_IN].complete, 1, 0);
701 430
702 for (ep_num = 1; ep_num < USB_NUM_ENDPOINTS; ep_num++) 431 for(int ep_num = 1; ep_num < USB_NUM_ENDPOINTS; ep_num++)
703 {
704 semaphore_init(&endpoints[ep_num].complete, 1, 0); 432 semaphore_init(&endpoints[ep_num].complete, 1, 0);
705
706 if (ep_num%3 == 0) /* IIN 3, 6, 9, 12, 15 */
707 {
708 IIN_TXCON(ep_num) |= (ep_num<<8)|TXEPEN|TXNAK; /* ep_num, enable, NAK */
709 }
710 else if (ep_num%3 == 1) /* BOUT 1, 4, 7, 10, 13 */
711 {
712 BOUT_RXCON(ep_num) |= (ep_num<<8)|RXEPEN|RXNAK; /* ep_num, NAK, enable */
713 }
714 else if (ep_num%3 == 2) /* BIN 2, 5, 8, 11, 14 */
715 {
716 BIN_TXCON(ep_num) |= (ep_num<<8)|TXEPEN|TXNAK; /* ep_num, enable, NAK */
717 }
718 }
719} 433}
720 434
721/* turn off usb core */ 435/* turn off usb core */
722void usb_drv_exit(void) 436void usb_drv_exit(void)
723{ 437{
724 DEV_CTL = DEV_SELF_PWR; 438 DEV_CTL = DEV_SELF_PWR;
725 439
726 /* disable USB interrupts in interrupt controller */ 440 /* disable USB interrupts in interrupt controller */
727 INTC_IMR &= ~IRQ_ARM_UDC; 441 INTC_IMR &= ~IRQ_ARM_UDC;
728 INTC_IECR &= ~IRQ_ARM_UDC; 442 INTC_IECR &= ~IRQ_ARM_UDC;
729 443
730 /* we cannot disable UDC clock since this causes data abort 444 /* we cannot disable UDC clock since this causes data abort
731 * when reading DEV_INFO in order to check usb connect event 445 * when reading DEV_INFO in order to check usb connect event
732 */ 446 */
@@ -734,9 +448,94 @@ void usb_drv_exit(void)
734 448
735int usb_detect(void) 449int usb_detect(void)
736{ 450{
737 if (DEV_INFO & VBUS_STS) 451 if(DEV_INFO & VBUS_STS)
738 return USB_INSERTED; 452 return USB_INSERTED;
739 else 453 else
740 return USB_EXTRACTED; 454 return USB_EXTRACTED;
741} 455}
742 456
457/* UDC ISR function */
458void INT_UDC(void)
459{
460 /* read what caused UDC irq */
461 uint32_t intsrc = INT2FLAG & 0x7fffff;
462
463 if(intsrc & USBRST_INTR) /* usb reset */
464 {
465 logf("udc_int: reset, %ld", current_tick);
466
467 EN_INT = EN_SUSP_INTR | /* Enable Suspend Irq */
468 EN_RESUME_INTR | /* Enable Resume Irq */
469 EN_USBRST_INTR | /* Enable USB Reset Irq */
470 EN_OUT0_INTR | /* Enable OUT Token receive Irq EP0 */
471 EN_IN0_INTR | /* Enable IN Token transmit Irq EP0 */
472 EN_SETUP_INTR; /* Enable SETUP Packet Receive Irq */
473
474 INTCON = UDC_INTHIGH_ACT | /* interrupt high active */
475 UDC_INTEN; /* enable EP0 irqs */
476
477 TX0CON = TXACKINTEN | /* Set as one to enable the EP0 tx irq */
478 TXNAK; /* Set as one to response NAK handshake */
479
480 RX0CON = RXACKINTEN |
481 RXEPEN | /* Endpoint 0 Enable. When cleared the
482 * endpoint does not respond to an SETUP
483 * or OUT token */
484 RXNAK; /* Set as one to response NAK handshake */
485
486 set_address = false;
487 set_configuration = false;
488 }
489 /* This needs to be processed AFTER usb reset */
490 udc_helper();
491
492 if(intsrc & SETUP_INTR) /* setup interrupt */
493 {
494 setup_received();
495 }
496 if(intsrc & IN0_INTR)
497 {
498 /* EP0 IN done */
499 in_intr(&ctrlep[DIR_IN]);
500 }
501 if(intsrc & OUT0_INTR)
502 {
503 /* EP0 OUT done */
504 out_intr(&ctrlep[DIR_OUT]);
505 }
506 if(intsrc & USBRST_INTR)
507 {
508 /* usb reset */
509 usb_drv_init();
510 }
511 if(intsrc & RESUME_INTR)
512 {
513 /* usb resume */
514 TX0CON |= TXCLR; /* TxClr */
515 TX0CON &= ~TXCLR;
516 RX0CON |= RXCLR; /* RxClr */
517 RX0CON &= ~RXCLR;
518 }
519 if(intsrc & SUSP_INTR)
520 {
521 /* usb suspend */
522 }
523 if(intsrc & CONN_INTR)
524 {
525 /* usb connect */
526 udc_phy_reset();
527 udelay(10000); /* wait at least 10ms */
528 udc_soft_connect();
529 }
530 /* other endpoints */
531 for(int ep_num = 1; ep_num < 16; ep_num++)
532 {
533 if(!(intsrc & (1 << (ep_num + 7))))
534 continue;
535 struct endpoint_t *endp = &endpoints[ep_num];
536 if(endp->dir == USB_DIR_IN)
537 in_intr(endp);
538 else
539 out_intr(endp);
540 }
541}
diff --git a/firmware/target/arm/rk27xx/usb-rk27xx.c b/firmware/target/arm/rk27xx/usb-rk27xx.c
index 20bf867c8d..09c9090a3b 100644
--- a/firmware/target/arm/rk27xx/usb-rk27xx.c
+++ b/firmware/target/arm/rk27xx/usb-rk27xx.c
@@ -32,6 +32,20 @@ int usb_status = USB_EXTRACTED;
32 32
33void usb_init_device(void) 33void usb_init_device(void)
34{ 34{
35 /* enable UDC interrupt */
36 INTC_IMR |= (1<<16);
37 INTC_IECR |= (1<<16);
38
39 EN_INT = EN_SUSP_INTR | /* Enable Suspend Interrupt */
40 EN_RESUME_INTR | /* Enable Resume Interrupt */
41 EN_USBRST_INTR | /* Enable USB Reset Interrupt */
42 EN_OUT0_INTR | /* Enable OUT Token receive Interrupt EP0 */
43 EN_IN0_INTR | /* Enable IN Token transmits Interrupt EP0 */
44 EN_SETUP_INTR; /* Enable SETUP Packet Receive Interrupt */
45
46 /* configure INTCON */
47 INTCON = UDC_INTHIGH_ACT | /* interrupt high active */
48 UDC_INTEN; /* enable EP0 interrupts */
35} 49}
36 50
37void usb_attach(void) 51void usb_attach(void)
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h
index 0303ac8ca2..99ae062595 100644
--- a/firmware/target/hosted/sdl/sim-ui-defines.h
+++ b/firmware/target/hosted/sdl/sim-ui-defines.h
@@ -527,6 +527,28 @@
527#define UI_HEIGHT 457 /* height of GUI window */ 527#define UI_HEIGHT 457 /* height of GUI window */
528#define UI_LCD_POSX 34 528#define UI_LCD_POSX 34
529#define UI_LCD_POSY 73 529#define UI_LCD_POSY 73
530
531#elif defined(IHIFI770)
532#define UI_TITLE "iHiFi 770"
533#define UI_WIDTH 382 /* width of GUI window */
534#define UI_HEIGHT 690 /* height of GUI window */
535#define UI_LCD_POSX 32
536#define UI_LCD_POSY 86
537
538#elif defined(IHIFI770C)
539#define UI_TITLE "iHiFi 770C"
540#define UI_WIDTH 382 /* width of GUI window */
541#define UI_HEIGHT 690 /* height of GUI window */
542#define UI_LCD_POSX 32
543#define UI_LCD_POSY 86
544
545#elif defined(IHIFI800)
546#define UI_TITLE "iHiFi 800"
547#define UI_WIDTH 300 /* width of GUI window */
548#define UI_HEIGHT 670 /* height of GUI window */
549#define UI_LCD_POSX 26
550#define UI_LCD_POSY 40
551
530#elif defined(SIMULATOR) 552#elif defined(SIMULATOR)
531#error no UI defines 553#error no UI defines
532#endif 554#endif
diff --git a/tools/builds.pm b/tools/builds.pm
index 5f7e2c5f58..ddb4b1442b 100644
--- a/tools/builds.pm
+++ b/tools/builds.pm
@@ -422,6 +422,18 @@ $releasenotes="/wiki/ReleaseNotes314";
422 name => 'xDuoo X3', 422 name => 'xDuoo X3',
423 status => 2, 423 status => 2,
424 }, 424 },
425 'ihifi770' => {
426 name => 'Xuelin iHIFI 770',
427 status => 2,
428 },
429 'ihifi770C' => {
430 name => 'Xuelin iHIFI 770C',
431 status => 2,
432 },
433 'ihifi800' => {
434 name => 'Xuelin iHIFI 800',
435 status => 2,
436 },
425); 437);
426 438
427sub manualname { 439sub manualname {
diff --git a/tools/configure b/tools/configure
index e7f254ada7..cad2238d9b 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1548,13 +1548,14 @@ cat <<EOF
1548 206) Android MIPS ==IHIFI== 222) NWZ-E450 series 1548 206) Android MIPS ==IHIFI== 222) NWZ-E450 series
1549 207) Android x86 230) 760 223) NWZ-E460 series 1549 207) Android x86 230) 760 223) NWZ-E460 series
1550 208) Samsung YP-R1 231) 960 224) NWZ-E470 series 1550 208) Samsung YP-R1 231) 960 224) NWZ-E470 series
1551 225) NWZ-E580 series 1551 250) 770C 225) NWZ-E580 series
1552 ==iBasso== ==Agptek== 226) NWZ-A10 series 1552 ==iBasso== 251) 770 226) NWZ-A10 series
1553 232) DX50 240) Rocker 227) NW-A20 series 1553 232) DX50 252) 800 227) NW-A20 series
1554 233) DX90 228) NWZ-A860 series 1554 233) DX90 228) NWZ-A860 series
1555 229) NWZ-S750 series 1555 229) NWZ-S750 series
1556 ==xDuoo== 1556 ==xDuoo== ==AgpTek==
1557 241) X3 1557 241) X3 240) Rocker
1558
1558EOF 1559EOF
1559 1560
1560 buildfor=`input`; 1561 buildfor=`input`;
@@ -4257,6 +4258,75 @@ fi
4257 t_model="xduoo_x3" 4258 t_model="xduoo_x3"
4258 ;; 4259 ;;
4259 4260
4261 250|ihifi770C)
4262 target_id=107
4263 modelname="ihifi770c"
4264 target="IHIFI770C"
4265 memory=16
4266 arm7ejscc
4267 tool="$rootdir/tools/scramble -rkw -modelnum=97"
4268 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
4269 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
4270 output="rockbox.rkw"
4271 bootoutput="bootloader.rkw"
4272 appextra="recorder:gui"
4273 plugins="yes"
4274 swcodec="yes"
4275 # toolset is the tools within the tools directory that we build for
4276 # this particular target.
4277 toolset="$genericbitmaptools"
4278 # architecture, manufacturer and model for the target-tree build
4279 t_cpu="arm"
4280 t_manufacturer="rk27xx"
4281 t_model="ihifi2"
4282 ;;
4283
4284 251|ihifi770)
4285 target_id=108
4286 modelname="ihifi770"
4287 target="IHIFI770"
4288 memory=16
4289 arm7ejscc
4290 tool="$rootdir/tools/scramble -rkw -modelnum=98"
4291 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
4292 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
4293 output="rockbox.rkw"
4294 bootoutput="bootloader.rkw"
4295 appextra="recorder:gui"
4296 plugins="yes"
4297 swcodec="yes"
4298 # toolset is the tools within the tools directory that we build for
4299 # this particular target.
4300 toolset="$genericbitmaptools"
4301 # architecture, manufacturer and model for the target-tree build
4302 t_cpu="arm"
4303 t_manufacturer="rk27xx"
4304 t_model="ihifi2"
4305 ;;
4306
4307 252|ihifi800)
4308 target_id=109
4309 modelname="ihifi800"
4310 target="IHIFI800"
4311 memory=16
4312 arm7ejscc
4313 tool="$rootdir/tools/scramble -rkw -modelnum=99"
4314 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
4315 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
4316 output="rockbox.rkw"
4317 bootoutput="bootloader.rkw"
4318 appextra="recorder:gui"
4319 plugins="yes"
4320 swcodec="yes"
4321 # toolset is the tools within the tools directory that we build for
4322 # this particular target.
4323 toolset="$genericbitmaptools"
4324 # architecture, manufacturer and model for the target-tree build
4325 t_cpu="arm"
4326 t_manufacturer="rk27xx"
4327 t_model="ihifi2"
4328 ;;
4329
4260 *) 4330 *)
4261 echo "Please select a supported target platform!" 4331 echo "Please select a supported target platform!"
4262 exit 7 4332 exit 7
diff --git a/uisimulator/bitmaps/UI-ihifi770.bmp b/uisimulator/bitmaps/UI-ihifi770.bmp
new file mode 100644
index 0000000000..4f2513828a
--- /dev/null
+++ b/uisimulator/bitmaps/UI-ihifi770.bmp
Binary files differ
diff --git a/uisimulator/bitmaps/UI-ihifi770c.bmp b/uisimulator/bitmaps/UI-ihifi770c.bmp
new file mode 100644
index 0000000000..4f2513828a
--- /dev/null
+++ b/uisimulator/bitmaps/UI-ihifi770c.bmp
Binary files differ
diff --git a/uisimulator/bitmaps/UI-ihifi800.bmp b/uisimulator/bitmaps/UI-ihifi800.bmp
new file mode 100644
index 0000000000..710f85102a
--- /dev/null
+++ b/uisimulator/bitmaps/UI-ihifi800.bmp
Binary files differ
diff --git a/uisimulator/buttonmap/SOURCES b/uisimulator/buttonmap/SOURCES
index d46066d478..4c6ca3adef 100644
--- a/uisimulator/buttonmap/SOURCES
+++ b/uisimulator/buttonmap/SOURCES
@@ -87,5 +87,7 @@ sony-nwza860.c
87agptek-rocker.c 87agptek-rocker.c
88#elif CONFIG_KEYPAD == XDUOO_X3_PAD 88#elif CONFIG_KEYPAD == XDUOO_X3_PAD
89xduoo-x3.c 89xduoo-x3.c
90#elif (CONFIG_KEYPAD == IHIFI_770_PAD) || (CONFIG_KEYPAD == IHIFI_800_PAD)
91ihifi2.c
90#endif 92#endif
91#endif /* SIMULATOR */ 93#endif /* SIMULATOR */
diff --git a/uisimulator/buttonmap/ihifi2.c b/uisimulator/buttonmap/ihifi2.c
new file mode 100644
index 0000000000..a197ab8ac2
--- /dev/null
+++ b/uisimulator/buttonmap/ihifi2.c
@@ -0,0 +1,90 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2016 by Roman Stolyarov
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#include <SDL.h>
24#include "button.h"
25#include "buttonmap.h"
26
27int key_to_button(int keyboard_button)
28{
29 int new_btn = BUTTON_NONE;
30 switch (keyboard_button)
31 {
32 case SDLK_KP8:
33 case SDLK_ESCAPE:
34 new_btn = BUTTON_POWER;
35 break;
36 case SDLK_KP4:
37 case SDLK_KP_ENTER:
38 case SDLK_SPACE:
39 case SDLK_RETURN:
40 new_btn = BUTTON_PLAY;
41 break;
42 case SDLK_KP5:
43 case SDLK_UP:
44 new_btn = BUTTON_PREV;
45 break;
46 case SDLK_KP6:
47 case SDLK_PAGEUP:
48 new_btn = BUTTON_VOL_UP;
49 break;
50 case SDLK_KP1:
51 case SDLK_BACKSPACE:
52 new_btn = BUTTON_HOME;
53 break;
54 case SDLK_KP2:
55 case SDLK_DOWN:
56 new_btn = BUTTON_NEXT;
57 break;
58 case SDLK_KP3:
59 case SDLK_PAGEDOWN:
60 new_btn = BUTTON_VOL_DOWN;
61 break;
62 }
63 return new_btn;
64}
65
66#if (CONFIG_KEYPAD == IHIFI_770_PAD)
67struct button_map bm[] = {
68 { SDLK_KP8, 210, 0, 20, "Power" },
69 { SDLK_KP4, 94, 430, 40, "Play" },
70 { SDLK_KP5, 190, 430, 40, "Prev" },
71 { SDLK_KP6, 285, 430, 40, "Vol Up" },
72 { SDLK_KP1, 94, 508, 40, "Home" },
73 { SDLK_KP2, 190, 508, 40, "Next" },
74 { SDLK_KP3, 285, 508, 40, "Vol Down" },
75 { 0, 0, 0, 0, "None" }
76};
77#elif (CONFIG_KEYPAD == IHIFI_800_PAD)
78struct button_map bm[] = {
79 { SDLK_KP8, 214, 468, 25, "Power" },
80 { SDLK_KP4, 168, 580, 25, "Play" },
81 { SDLK_KP5, 60, 524, 25, "Prev" },
82 { SDLK_KP6, 102, 455, 25, "Vol Up" },
83 { SDLK_KP1, 246, 580, 25, "Home" },
84 { SDLK_KP2, 60, 580, 25, "Next" },
85 { SDLK_KP3, 50, 455, 25, "Vol Down" },
86 { 0, 0, 0, 0, "None" }
87};
88#else
89#error please define button map
90#endif