summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2011-10-17 10:32:19 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2011-10-17 10:32:19 +0000
commit32f763c39a797221a6e850704feb3743bc104d8c (patch)
treec509c38423f2efb76a13119f92c21e5e82476a42
parentf0311d3310e84906a6c1afaf941f2f58e2063c30 (diff)
downloadrockbox-32f763c39a797221a6e850704feb3743bc104d8c.tar.gz
rockbox-32f763c39a797221a6e850704feb3743bc104d8c.zip
Add HiFiMAN HM-60x target(s). FS#12319 by Andrew Ryabinin with some (small) modification by me. This also splits rk27xx lcd driver into lcdif-rk27xx and lcd controller specific part. Some modifications to the pcm driver have been made to allow using codecs in slave mode (as TDA1543 used in hifiman is slave only i2s codec).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30765 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/SOURCES4
-rw-r--r--apps/keymaps/keymap-hm60x.c88
-rw-r--r--bootloader/SOURCES2
-rw-r--r--firmware/SOURCES14
-rw-r--r--firmware/drivers/audio/tda1543.c46
-rw-r--r--firmware/export/audiohw.h2
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/export/config/hifimanhm60x.h183
-rw-r--r--firmware/export/tda1543.h29
-rw-r--r--firmware/target/arm/rk27xx/adc-target.h4
-rw-r--r--firmware/target/arm/rk27xx/debug-target.h4
-rw-r--r--firmware/target/arm/rk27xx/hm60x/button-hm60x.c46
-rw-r--r--firmware/target/arm/rk27xx/hm60x/button-target.h44
-rw-r--r--firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c148
-rw-r--r--firmware/target/arm/rk27xx/hm60x/power-hm60x.c48
-rw-r--r--firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c66
-rw-r--r--firmware/target/arm/rk27xx/lcdif-rk27xx.c161
-rw-r--r--firmware/target/arm/rk27xx/lcdif-rk27xx.h11
-rw-r--r--firmware/target/arm/rk27xx/pcm-rk27xx.c62
-rw-r--r--firmware/target/arm/rk27xx/rk27generic/lcd-rk27generic.c (renamed from firmware/target/arm/rk27xx/lcd-rk27xx.c)131
-rwxr-xr-xtools/configure27
21 files changed, 990 insertions, 134 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 443b42fedc..a08dc046c2 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -325,4 +325,6 @@ keymaps/keymap-sdl.c
325keymaps/keymap-fuzeplus.c 325keymaps/keymap-fuzeplus.c
326#elif CONFIG_KEYPAD == RK27XX_GENERIC_PAD 326#elif CONFIG_KEYPAD == RK27XX_GENERIC_PAD
327keymaps/keymap-rk27xx-generic.c 327keymaps/keymap-rk27xx-generic.c
328#endif 328#elif CONFIG_KEYPAD == HM60X_PAD
329keymaps/keymap-hm60x.c
330#endif \ No newline at end of file
diff --git a/apps/keymaps/keymap-hm60x.c b/apps/keymaps/keymap-hm60x.c
new file mode 100644
index 0000000000..3f75ac82d4
--- /dev/null
+++ b/apps/keymaps/keymap-hm60x.c
@@ -0,0 +1,88 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
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 HiFiMAN HM-601 reference design target */
23
24#include "config.h"
25#include "action.h"
26#include "button.h"
27
28/*
29 * The format of the list is as follows
30 * { Action Code, Button code, Prereq button code }
31 * if there's no need to check the previous button's value, use BUTTON_NONE
32 * Insert LAST_ITEM_IN_LIST at the end of each mapping
33 */
34static const struct button_mapping button_context_standard[] = {
35 { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE },
36 { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE },
37 { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE },
38 { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE },
39
40 { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
41 { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE },
42 { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
43 { ACTION_STD_MENU, BUTTON_RIGHT, BUTTON_NONE },
44
45 LAST_ITEM_IN_LIST
46}; /* button_context_standard */
47
48static const struct button_mapping button_context_wps[] = {
49 { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
50 { ACTION_WPS_STOP, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
51 { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT },
52 { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE },
53 { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT },
54 { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT},
55 { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
56 { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT },
57
58 { ACTION_WPS_BROWSE, BUTTON_UP|BUTTON_REL, BUTTON_UP },
59 { ACTION_WPS_CONTEXT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP },
60 { ACTION_WPS_MENU, BUTTON_DOWN|BUTTON_REL, BUTTON_DOWN },
61 { ACTION_WPS_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN },
62
63 LAST_ITEM_IN_LIST
64}; /* button_context_wps */
65
66
67
68/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
69const struct button_mapping* get_context_mapping(int context)
70{
71 switch (context)
72 {
73 case CONTEXT_STD:
74 return button_context_standard;
75 case CONTEXT_WPS:
76 return button_context_wps;
77
78 case CONTEXT_TREE:
79 case CONTEXT_LIST:
80 case CONTEXT_MAINMENU:
81
82 case CONTEXT_SETTINGS:
83 case CONTEXT_SETTINGS|CONTEXT_REMOTE:
84 default:
85 return button_context_standard;
86 }
87 return button_context_standard;
88}
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index bc9dc855b1..d1d659837d 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -67,7 +67,7 @@ main-pp.c
67show_logo.c 67show_logo.c
68#elif defined(MPIO_HD200) || defined(MPIO_HD300) 68#elif defined(MPIO_HD200) || defined(MPIO_HD300)
69mpio_hd200_hd300.c 69mpio_hd200_hd300.c
70#elif defined(RK27_GENERIC) 70#elif defined(RK27_GENERIC) || defined(HM60X)
71rk27xx.c 71rk27xx.c
72show_logo.c 72show_logo.c
73#endif 73#endif
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 367241db08..739f8e63db 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -355,6 +355,8 @@ drivers/audio/uda1341.c
355drivers/audio/cs42l55.c 355drivers/audio/cs42l55.c
356#elif defined (HAVE_RK27XX_CODEC) 356#elif defined (HAVE_RK27XX_CODEC)
357drivers/audio/rk27xx_codec.c 357drivers/audio/rk27xx_codec.c
358#elif defined (HAVE_TDA1543)
359drivers/audio/tda1543.c
358#endif /* defined(HAVE_*) */ 360#endif /* defined(HAVE_*) */
359#elif defined(HAVE_SDL_AUDIO) 361#elif defined(HAVE_SDL_AUDIO)
360drivers/audio/sdl.c 362drivers/audio/sdl.c
@@ -1671,12 +1673,12 @@ target/arm/rk27xx/kernel-rk27xx.c
1671target/arm/rk27xx/system-rk27xx.c 1673target/arm/rk27xx/system-rk27xx.c
1672target/arm/rk27xx/timer-rk27xx.c 1674target/arm/rk27xx/timer-rk27xx.c
1673target/arm/rk27xx/backlight-rk27xx.c 1675target/arm/rk27xx/backlight-rk27xx.c
1674target/arm/rk27xx/lcd-rk27xx.c
1675target/arm/rk27xx/adc-rk27xx.c 1676target/arm/rk27xx/adc-rk27xx.c
1676target/arm/rk27xx/sd-rk27xx.c 1677target/arm/rk27xx/sd-rk27xx.c
1677target/arm/rk27xx/ftl-rk27xx.c 1678target/arm/rk27xx/ftl-rk27xx.c
1678target/arm/rk27xx/nand-rk27xx.c 1679target/arm/rk27xx/nand-rk27xx.c
1679target/arm/rk27xx/usb-rk27xx.c 1680target/arm/rk27xx/usb-rk27xx.c
1681target/arm/rk27xx/lcdif-rk27xx.c
1680#ifndef BOOTLOADER 1682#ifndef BOOTLOADER
1681target/arm/rk27xx/pcm-rk27xx.c 1683target/arm/rk27xx/pcm-rk27xx.c
1682target/arm/rk27xx/debug-rk27xx.c 1684target/arm/rk27xx/debug-rk27xx.c
@@ -1687,6 +1689,7 @@ target/arm/rk27xx/debug-rk27xx.c
1687target/arm/rk27xx/rk27generic/button-rk27generic.c 1689target/arm/rk27xx/rk27generic/button-rk27generic.c
1688target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c 1690target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
1689target/arm/rk27xx/rk27generic/power-rk27generic.c 1691target/arm/rk27xx/rk27generic/power-rk27generic.c
1692target/arm/rk27xx/rk27generic/lcd-rk27generic.c
1690#endif 1693#endif
1691#endif 1694#endif
1692 1695
@@ -1914,3 +1917,12 @@ target/hosted/android/app/button-application.c
1914drivers/audio/android.c 1917drivers/audio/android.c
1915thread.c 1918thread.c
1916#endif 1919#endif
1920
1921#ifndef SIMULATOR
1922#if defined(HM60X)
1923target/arm/rk27xx/hm60x/button-hm60x.c
1924target/arm/rk27xx/hm60x/powermgmt-hm60x.c
1925target/arm/rk27xx/hm60x/power-hm60x.c
1926target/arm/rk27xx/hm60x/lcd-hm60x.c
1927#endif
1928#endif
diff --git a/firmware/drivers/audio/tda1543.c b/firmware/drivers/audio/tda1543.c
new file mode 100644
index 0000000000..ca51d95265
--- /dev/null
+++ b/firmware/drivers/audio/tda1543.c
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 *
11 * Copyright (c) 2011 Andrew Ryabinin
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
23#include "config.h"
24#include "audio.h"
25#include "audiohw.h"
26
27const struct sound_settings_info audiohw_settings[] = {
28 [SOUND_VOLUME] = {"dB", 0, 1, -1, 0, 0},
29 /* HAVE_SW_TONE_CONTROLS */
30 [SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
31 [SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
32 [SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
33 [SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
34 [SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
35};
36
37void audiohw_preinit(void) { }
38
39void audiohw_postinit(void) { }
40
41void audiohw_close(void) { }
42
43void audiohw_set_frequency(int fsel)
44{
45 (void)fsel;
46}
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 9956909b5d..e40ee6ee79 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -74,6 +74,8 @@
74#include "cs42l55.h" 74#include "cs42l55.h"
75#elif defined(HAVE_IMX233_CODEC) 75#elif defined(HAVE_IMX233_CODEC)
76#include "imx233-codec.h" 76#include "imx233-codec.h"
77#elif defined(HAVE_TDA1543)
78#include "tda1543.h"
77#endif 79#endif
78#if (CONFIG_PLATFORM & PLATFORM_HOSTED) 80#if (CONFIG_PLATFORM & PLATFORM_HOSTED)
79/* #include <SDL_audio.h> gives errors in other code areas, 81/* #include <SDL_audio.h> gives errors in other code areas,
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 1c55d232ef..0d0617bb13 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -140,6 +140,7 @@
140#define MPIO_HD300_PAD 47 140#define MPIO_HD300_PAD 47
141#define SANSA_FUZEPLUS_PAD 48 141#define SANSA_FUZEPLUS_PAD 48
142#define RK27XX_GENERIC_PAD 49 142#define RK27XX_GENERIC_PAD 49
143#define HM60X_PAD 50
143 144
144/* CONFIG_REMOTE_KEYPAD */ 145/* CONFIG_REMOTE_KEYPAD */
145#define H100_REMOTE 1 146#define H100_REMOTE 1
@@ -226,6 +227,7 @@
226#define LCD_FUZEPLUS 41 227#define LCD_FUZEPLUS 41
227#define LCD_SPFD5420A 42 /* rk27xx */ 228#define LCD_SPFD5420A 42 /* rk27xx */
228#define LCD_CLIPZIP 43 /* as used by the Sandisk Sansa Clip Zip */ 229#define LCD_CLIPZIP 43 /* as used by the Sandisk Sansa Clip Zip */
230#define LCD_HX8340B 44 /* as used by the HiFiMAN HM-601/HM-602/HM-801 */
229 231
230/* LCD_PIXELFORMAT */ 232/* LCD_PIXELFORMAT */
231#define HORIZONTAL_PACKING 1 233#define HORIZONTAL_PACKING 1
@@ -459,6 +461,8 @@ Lyre prototype 1 */
459#include "config/mpiohd300.h" 461#include "config/mpiohd300.h"
460#elif defined(RK27_GENERIC) 462#elif defined(RK27_GENERIC)
461#include "config/rk27generic.h" 463#include "config/rk27generic.h"
464#elif defined(HM60X)
465#include "config/hifimanhm60x.h"
462#elif defined(SDLAPP) 466#elif defined(SDLAPP)
463#include "config/sdlapp.h" 467#include "config/sdlapp.h"
464#elif defined(ANDROID) 468#elif defined(ANDROID)
diff --git a/firmware/export/config/hifimanhm60x.h b/firmware/export/config/hifimanhm60x.h
new file mode 100644
index 0000000000..88af364bc9
--- /dev/null
+++ b/firmware/export/config/hifimanhm60x.h
@@ -0,0 +1,183 @@
1/*
2 * This config file is for HiFiMAN HM-60x reference design
3 */
4#define TARGET_TREE /* this target is using the target tree system */
5
6/* For Rolo and boot loader */
7#define MODEL_NUMBER 79
8
9#define MODEL_NAME "HiFiMAN HM-60x"
10
11/* Define bitmask of input sources - recordable bitmask can be defined
12 explicitly if different */
13/* #define INPUT_SRC_CAPS (SRC_CAP_MIC | SRC_CAP_FM) */
14
15/* define the bitmask of hardware sample rates */
16#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_48 | SAMPR_CAP_44 | \
17 SAMPR_CAP_32 | SAMPR_CAP_24 | SAMPR_CAP_22 | \
18 SAMPR_CAP_16 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
19
20#define HAVE_TDA1543
21#define CODEC_SLAVE
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 have access to the pitchscreen */
47#define HAVE_PITCHSCREEN
48
49/* define this if you would like tagcache to build on this target */
50#define HAVE_TAGCACHE
51
52/* define this if you have a flash memory storage */
53#define HAVE_FLASH_STORAGE
54
55#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
56
57#define CONFIG_NAND NAND_RK27XX
58#define HAVE_SW_TONE_CONTROLS
59
60/* commented for now */
61/* #define HAVE_HOTSWAP */
62
63#define NUM_DRIVES 2
64#define SECTOR_SIZE 512
65
66/* for small(ish) SD cards */
67#define HAVE_FAT16SUPPORT
68
69/* LCD dimensions */
70#define LCD_WIDTH 220
71#define LCD_HEIGHT 176
72#define LCD_DEPTH 16 /* pseudo 262.144 colors */
73#define LCD_PIXELFORMAT RGB565 /* rgb565 */
74
75/* Define this if the LCD can shut down */
76/* #define HAVE_LCD_SHUTDOWN */
77
78/* Define this if your LCD can be enabled/disabled */
79/* #define HAVE_LCD_ENABLE */
80
81/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
82 should be defined as well. */
83#ifndef BOOTLOADER
84/* TODO: #define HAVE_LCD_SLEEP */
85/* TODO: #define HAVE_LCD_SLEEP_SETTING */
86#endif
87
88#define CONFIG_KEYPAD HM60X_PAD
89
90/* Define this to enable morse code input */
91#define HAVE_MORSE_INPUT
92
93/* Define this if you do software codec */
94#define CONFIG_CODEC SWCODEC
95
96/* define this if you have a real-time clock */
97/* #define CONFIG_RTC RTC_NANO2G */
98
99/* Define if the device can wake from an RTC alarm */
100/* #define HAVE_RTC_ALARM */
101
102#define CONFIG_LCD LCD_HX8340B
103
104/* Define the type of audio codec */
105/*#define HAVE_RK27XX_CODEC */
106
107/* #define HAVE_PCM_DMA_ADDRESS */
108
109/* Define this for LCD backlight available */
110#define HAVE_BACKLIGHT
111#define HAVE_BACKLIGHT_BRIGHTNESS
112#define MIN_BRIGHTNESS_SETTING 0
113#define MAX_BRIGHTNESS_SETTING 31
114#define DEFAULT_BRIGHTNESS_SETTING 20
115#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
116
117/* Define this if you have a software controlled poweroff */
118#define HAVE_SW_POWEROFF
119
120/* The number of bytes reserved for loadable codecs */
121#define CODEC_SIZE 0x100000
122
123/* The number of bytes reserved for loadable plugins */
124#define PLUGIN_BUFFER_SIZE 0x80000
125
126/* TODO: Figure out real values */
127#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
128#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
129#define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */
130#define BATTERY_CAPACITY_INC 10 /* capacity increment */
131#define BATTERY_TYPES_COUNT 1 /* only one type */
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/* USB On-the-go */
145#define CONFIG_USBOTG USBOTG_RK27XX
146
147/* enable these for the experimental usb stack */
148#define HAVE_USBSTACK
149
150#define USE_ROCKBOX_USB
151#define USB_VENDOR_ID 0x071b
152#define USB_PRODUCT_ID 0x3202
153#define HAVE_BOOTLOADER_USB_MODE
154
155/* Define this if your LCD can set contrast */
156/* #define HAVE_LCD_CONTRAST */
157
158/* The exact type of CPU */
159#define CONFIG_CPU RK27XX
160
161/* I2C interface */
162#define CONFIG_I2C I2C_RK27XX
163
164/* Define this to the CPU frequency */
165#define CPU_FREQ 200000000
166
167/* define this if the hardware can be powered off while charging */
168/* #define HAVE_POWEROFF_WHILE_CHARGING */
169
170/* Offset ( in the firmware file's header ) to the file CRC */
171#define FIRMWARE_OFFSET_FILE_CRC 0
172
173/* Offset ( in the firmware file's header ) to the real data */
174#define FIRMWARE_OFFSET_FILE_DATA 8
175
176#define STORAGE_NEEDS_ALIGN
177
178/* Define this if you have adjustable CPU frequency */
179/* #define HAVE_ADJUSTABLE_CPU_FREQ */
180
181#define BOOTFILE_EXT "rk27"
182#define BOOTFILE "rockbox." BOOTFILE_EXT
183#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/tda1543.h b/firmware/export/tda1543.h
new file mode 100644
index 0000000000..6561f0823a
--- /dev/null
+++ b/firmware/export/tda1543.h
@@ -0,0 +1,29 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 *
11 * Copyright (c) 2011 Andrew Ryabinin
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 __TDA1543_H_
23#define __TDA1543_H_
24
25#define VOLUME_MIN -1
26#define VOLUME_MAX 0
27
28
29#endif /* __TDA1543_H_ */
diff --git a/firmware/target/arm/rk27xx/adc-target.h b/firmware/target/arm/rk27xx/adc-target.h
index f6b8c98bb9..c359f3d7df 100644
--- a/firmware/target/arm/rk27xx/adc-target.h
+++ b/firmware/target/arm/rk27xx/adc-target.h
@@ -24,8 +24,8 @@
24#define NUM_ADC_CHANNELS 4 24#define NUM_ADC_CHANNELS 4
25 25
26#define ADC_BATTERY 0 26#define ADC_BATTERY 0
27#define ADC_UNKNOWN_1 1 27#define ADC_BUTTONS 1
28#define ADC_UNKNOWN_2 2 28#define ADC_UNKNOWN 2
29#define ADC_VREF 3 /* that is what datasheet says */ 29#define ADC_VREF 3 /* that is what datasheet says */
30 30
31#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ 31#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
diff --git a/firmware/target/arm/rk27xx/debug-target.h b/firmware/target/arm/rk27xx/debug-target.h
index a507e96fdc..c083b9282a 100644
--- a/firmware/target/arm/rk27xx/debug-target.h
+++ b/firmware/target/arm/rk27xx/debug-target.h
@@ -24,7 +24,11 @@
24 24
25#include <stdbool.h> 25#include <stdbool.h>
26 26
27#ifdef RK27_GENERIC
27#define DEBUG_CANCEL BUTTON_VOL 28#define DEBUG_CANCEL BUTTON_VOL
29#elif defined(HM60X)
30#define DEBUG_CANCEL BUTTON_LEFT
31#endif
28 32
29bool dbg_hw_info(void); 33bool dbg_hw_info(void);
30bool dbg_ports(void); 34bool dbg_ports(void);
diff --git a/firmware/target/arm/rk27xx/hm60x/button-hm60x.c b/firmware/target/arm/rk27xx/hm60x/button-hm60x.c
new file mode 100644
index 0000000000..eaadaa131c
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/button-hm60x.c
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
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 "button.h"
25#include "adc.h"
26
27void button_init_device(void) {
28 /* setup button gpio as input */
29 GPIO_PCCON &= ~(POWEROFF_BUTTON);
30}
31
32int button_read_device(void) {
33 int adc_val = adc_read(ADC_BUTTONS);
34 if (adc_val < 30) {
35 return BUTTON_UP | (GPIO_PCDR & POWEROFF_BUTTON);
36 } else if (adc_val < 250) {
37 return BUTTON_RIGHT | (GPIO_PCDR & POWEROFF_BUTTON);
38 } else if (adc_val < 380) {
39 return BUTTON_LEFT | (GPIO_PCDR & POWEROFF_BUTTON);
40 } else if (adc_val < 450) {
41 return BUTTON_DOWN | (GPIO_PCDR & POWEROFF_BUTTON);
42 } else if (adc_val < 560) {
43 return BUTTON_PLAY | (GPIO_PCDR & POWEROFF_BUTTON);
44 }
45 return (GPIO_PCDR & POWEROFF_BUTTON);
46}
diff --git a/firmware/target/arm/rk27xx/hm60x/button-target.h b/firmware/target/arm/rk27xx/hm60x/button-target.h
new file mode 100644
index 0000000000..0209e0637d
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/button-target.h
@@ -0,0 +1,44 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
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#include <stdbool.h>
25#include "config.h"
26
27void button_init_device(void);
28int button_read_device(void);
29
30
31#define BUTTON_UP 0x00000001
32#define BUTTON_DOWN 0x00000004
33#define BUTTON_LEFT 0x00000008
34#define BUTTON_RIGHT 0x00000010
35#define BUTTON_PLAY 0x00000020
36
37
38#define BUTTON_REMOTE 0
39
40
41#define POWEROFF_BUTTON 0x02
42#define POWEROFF_COUNT 30
43
44#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c b/firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c
new file mode 100644
index 0000000000..932154da8d
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c
@@ -0,0 +1,148 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
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
23#include "config.h"
24#include "kernel.h"
25#include "lcd.h"
26#include "system.h"
27#include "cpu.h"
28#include "lcdif-rk27xx.h"
29
30
31/* TODO */
32static void lcd_sleep(unsigned int sleep)
33{
34 (void)sleep;
35}
36
37void lcd_display_init()
38{
39 unsigned int x, y;
40
41 /* Driving ability setting */
42 lcd_write_reg(0x60, 0x00);
43 lcd_write_reg(0x61, 0x06);
44 lcd_write_reg(0x62, 0x00);
45 lcd_write_reg(0x63, 0xC8);
46
47 /* Gamma 2.2 Setting */
48 lcd_write_reg(0x40, 0x00);
49 lcd_write_reg(0x41, 0x40);
50 lcd_write_reg(0x42, 0x45);
51 lcd_write_reg(0x43, 0x01);
52 lcd_write_reg(0x44, 0x60);
53 lcd_write_reg(0x45, 0x05);
54 lcd_write_reg(0x46, 0x0C);
55 lcd_write_reg(0x47, 0xD1);
56 lcd_write_reg(0x48, 0x05);
57
58 lcd_write_reg(0x50, 0x75);
59 lcd_write_reg(0x51, 0x01);
60 lcd_write_reg(0x52, 0x67);
61 lcd_write_reg(0x53, 0x14);
62 lcd_write_reg(0x54, 0xF2);
63 lcd_write_reg(0x55, 0x07);
64 lcd_write_reg(0x56, 0x03);
65 lcd_write_reg(0x57, 0x49);
66
67 /* Power voltage setting */
68 lcd_write_reg(0x1F, 0x03);
69 lcd_write_reg(0x20, 0x00);
70 lcd_write_reg(0x24, 0x28);
71 lcd_write_reg(0x25, 0x45);
72
73 lcd_write_reg(0x23, 0x2F);
74
75 /* Power on setting */
76 lcd_write_reg(0x18, 0x44);
77 lcd_write_reg(0x21, 0x01);
78 lcd_write_reg(0x01, 0x00);
79 lcd_write_reg(0x1C, 0x03);
80 lcd_write_reg(0x19, 0x06);
81 udelay(5);
82
83 /* Display on setting */
84 lcd_write_reg(0x26, 0x84);
85 udelay(40);
86 lcd_write_reg(0x26, 0xB8);
87 udelay(40);
88 lcd_write_reg(0x26, 0xBC);
89 udelay(40);
90
91 /* Memmory access setting */
92 lcd_write_reg(0x16, 0x48);
93 /* Setup 16bit mode */
94 lcd_write_reg(0x17, 0x05);
95
96 /* Set GRAM area */
97 lcd_write_reg(0x02, 0x00);
98 lcd_write_reg(0x03, 0x00);
99 lcd_write_reg(0x04, 0x00);
100 lcd_write_reg(0x05, LCD_HEIGHT - 1);
101 lcd_write_reg(0x06, 0x00);
102 lcd_write_reg(0x07, 0x00);
103 lcd_write_reg(0x08, 0x00);
104 lcd_write_reg(0x09, LCD_WIDTH - 1);
105
106 /* Start GRAM write */
107 lcd_cmd(0x22);
108
109 for (x=0; x<LCD_WIDTH; x++)
110 for(y=0; y<LCD_HEIGHT; y++)
111 lcd_data(0x00);
112
113 lcd_sleep(0);
114}
115
116
117
118void lcd_update_rect(int x, int y, int width, int height)
119{
120 int px = x, py = y;
121 int pxmax = x + width, pymax = y + height;
122
123 lcd_write_reg(0x03, y);
124 lcd_write_reg(0x05, pymax-1);
125 lcd_write_reg(0x07, x);
126 lcd_write_reg(0x09, pxmax-1);
127
128 lcd_cmd(0x22);
129
130 for (px=x; px<pxmax; px++)
131 for (py=y; py<pymax; py++)
132 lcd_data(lcd_framebuffer[py][px]);
133}
134
135/* Blit a YUV bitmap directly to the LCD */
136void lcd_blit_yuv(unsigned char * const src[3],
137 int src_x, int src_y, int stride,
138 int x, int y, int width, int height)
139{
140 (void)src;
141 (void)src_x;
142 (void)src_y;
143 (void)stride;
144 (void)x;
145 (void)y;
146 (void)width;
147 (void)height;
148}
diff --git a/firmware/target/arm/rk27xx/hm60x/power-hm60x.c b/firmware/target/arm/rk27xx/hm60x/power-hm60x.c
new file mode 100644
index 0000000000..5c2abeb121
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/power-hm60x.c
@@ -0,0 +1,48 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2009 Bertrik Sikken
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
29void power_off(void)
30{
31
32}
33
34void power_init(void)
35{
36 GPIO_PCDR |= (1<<0);
37 GPIO_PCCON |= (1<<0);
38}
39
40unsigned int power_input_status(void)
41{
42 return (usb_detect() == USB_INSERTED) ? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
43}
44
45bool charging_state(void)
46{
47 return true;
48}
diff --git a/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
new file mode 100644
index 0000000000..7b5b171ccb
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2009 Bertrik Sikken
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 Meizu M3.
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 Discharge and charge curves have not been calibrated yet.
33*/
34
35const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
36{
37 /* TODO: this is just an initial guess */
38 3400
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 /* TODO: this is just an initial guess */
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 /* TODO: simple uncalibrated curve, linear except for first 10% */
51 { 3300, 3600, 3665, 3730, 3795, 3860, 3925, 3990, 4055, 4120, 4185 }
52};
53
54/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
55const unsigned short percent_to_volt_charge[11] =
56 /* TODO: simple uncalibrated curve, linear except for first 10% */
57 { 3300, 3600, 3665, 3730, 3795, 3860, 3925, 3990, 4055, 4120, 4185 };
58
59/* full-scale ADC readout (2^10) in millivolt */
60#define BATTERY_SCALE_FACTOR 6000
61
62/* Returns battery voltage from ADC [millivolts] */
63unsigned int battery_adc_voltage(void)
64{
65 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
66}
diff --git a/firmware/target/arm/rk27xx/lcdif-rk27xx.c b/firmware/target/arm/rk27xx/lcdif-rk27xx.c
new file mode 100644
index 0000000000..aeee63ee7e
--- /dev/null
+++ b/firmware/target/arm/rk27xx/lcdif-rk27xx.c
@@ -0,0 +1,161 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Marcin Bukat
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
29
30unsigned int lcd_data_transform(unsigned int data)
31{
32 unsigned int r, g, b;
33
34#if defined(RK27_GENERIC)
35 /* 18 bit interface */
36 r = (data & 0x0000fc00)<<8;
37 /* g = ((data & 0x00000300) >> 2) | ((data & 0x000000e0) >> 3); */
38 g = ((data & 0x00000300) << 6) | ((data & 0x000000e0) << 5);
39 b = (data & 0x00000001f) << 3;
40#elif defined(HM60X)
41 /* 16 bit interface */
42 r = (data & 0x0000f800) << 8;
43 g = (data & 0x000007e0) << 5;
44 b = (data & 0x0000001f) << 3;
45#else
46#error "Unknown target"
47#endif
48
49 return (r | g | b);
50}
51
52void lcd_cmd(unsigned int cmd)
53{
54 LCD_COMMAND = lcd_data_transform(cmd);
55}
56
57void lcd_data(unsigned int data)
58{
59 LCD_DATA = lcd_data_transform(data);
60}
61
62void lcd_write_reg(unsigned int reg, unsigned int val)
63{
64 lcd_cmd(reg);
65 lcd_data(val);
66}
67
68static void lcdctrl_bypass(unsigned int on_off)
69{
70 while (!(LCDC_STA & LCDC_MCU_IDLE));
71
72 if (on_off)
73 MCU_CTRL |= MCU_CTRL_BYPASS;
74 else
75 MCU_CTRL &= ~MCU_CTRL_BYPASS;
76}
77
78/* This part is unclear. I am unable to use buffered/FIFO based writes
79 * to lcd. Depending on settings of IF I get various patterns on display
80 * but not what I want to display apparently.
81 */
82static void lcdctrl_init(void)
83{
84 /* alpha b111
85 * stop at current frame complete
86 * MCU mode
87 * 24b RGB
88 */
89 LCDC_CTRL = ALPHA(7) | LCDC_STOP | LCDC_MCU | RGB24B;
90 MCU_CTRL = ALPHA_BASE(0x3f) | MCU_CTRL_BYPASS;
91
92 HOR_ACT = LCD_WIDTH + 3; /* define horizonatal active region */
93 VERT_ACT = LCD_HEIGHT; /* define vertical active region */
94 VERT_PERIOD = 0xfff; /* CSn/WEn/RDn signal timings */
95
96 LINE0_YADDR = LINE_ALPHA_EN | 0x7fe;
97 LINE1_YADDR = LINE_ALPHA_EN | ((1 * LCD_WIDTH) - 2);
98 LINE2_YADDR = LINE_ALPHA_EN | ((2 * LCD_WIDTH) - 2);
99 LINE3_YADDR = LINE_ALPHA_EN | ((3 * LCD_WIDTH) - 2);
100
101 LINE0_UVADDR = 0x7fe + 1;
102 LINE1_UVADDR = ((1 * LCD_WIDTH) - 2 + 1);
103 LINE2_UVADDR = ((2 * LCD_WIDTH) - 2 + 1);
104 LINE3_UVADDR = ((3 * LCD_WIDTH) - 2 + 1);
105
106#if 0
107 LINE0_YADDR = 0;
108 LINE1_YADDR = (1 * LCD_WIDTH);
109 LINE2_YADDR = (2 * LCD_WIDTH);
110 LINE3_YADDR = (3 * LCD_WIDTH);
111
112 LINE0_UVADDR = 1;
113 LINE1_UVADDR = (1 * LCD_WIDTH) + 1;
114 LINE2_UVADDR = (2 * LCD_WIDTH) + 1;
115 LINE3_UVADDR = (3 * LCD_WIDTH) + 1;
116
117 START_X = 0;
118 START_Y = 0;
119 DELTA_X = 0x200; /* no scaling */
120 DELTA_Y = 0x200; /* no scaling */
121#endif
122 LCDC_INTR_MASK = INTR_MASK_LINE; /* INTR_MASK_EVENLINE; */
123}
124
125/* configure pins to drive lcd in 18bit mode */
126static void iomux_lcd(void)
127{
128 unsigned long muxa;
129
130 muxa = SCU_IOMUXA_CON & ~(IOMUX_LCD_VSYNC|IOMUX_LCD_DEN|0xff);
131 muxa |= IOMUX_LCD_D18|IOMUX_LCD_D20|IOMUX_LCD_D22|IOMUX_LCD_D17|IOMUX_LCD_D16;
132
133 SCU_IOMUXA_CON = muxa;
134 SCU_IOMUXB_CON |= IOMUX_LCD_D815;
135}
136
137void lcd_init_device()
138{
139 iomux_lcd(); /* setup pins for 16bit lcd interface */
140 lcdctrl_init(); /* basic lcdc module configuration */
141
142 lcdctrl_bypass(1); /* run in bypass mode - all writes goes directly to lcd controller */
143 lcd_display_init();
144}
145
146/* This is ugly hack. We drive lcd in bypass mode
147 * where all writes goes directly to lcd controller.
148 * This is suboptimal at best. IF module povides
149 * FIFO, internal sram buffer, hardware scaller,
150 * DMA signals, hardware alpha blending and more.
151 * BUT the fact is that I have no idea how to use
152 * this modes. Datasheet floating around is very
153 * unclean in this regard and OF uses ackward
154 * lcd update routines which are hard to understand.
155 * Moreover OF sets some bits in IF module registers
156 * which are referred as reseved in datasheet.
157 */
158void lcd_update()
159{
160 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
161}
diff --git a/firmware/target/arm/rk27xx/lcdif-rk27xx.h b/firmware/target/arm/rk27xx/lcdif-rk27xx.h
new file mode 100644
index 0000000000..caf97c8e94
--- /dev/null
+++ b/firmware/target/arm/rk27xx/lcdif-rk27xx.h
@@ -0,0 +1,11 @@
1#ifndef _LCDIF_RK27XX_H
2#define _LCDIF_RK27XX_H
3
4unsigned int lcd_data_transform(unsigned int data);
5
6void lcd_cmd(unsigned int cmd);
7void lcd_data(unsigned int data);
8void lcd_write_reg(unsigned int reg, unsigned int val);
9void lcd_display_init(void);
10
11#endif /* _LCDIF_RK27XX_H */
diff --git a/firmware/target/arm/rk27xx/pcm-rk27xx.c b/firmware/target/arm/rk27xx/pcm-rk27xx.c
index b8ae56adaf..80a8d462ea 100644
--- a/firmware/target/arm/rk27xx/pcm-rk27xx.c
+++ b/firmware/target/arm/rk27xx/pcm-rk27xx.c
@@ -8,6 +8,7 @@
8 * $Id$ 8 * $Id$
9 * 9 *
10 * Copyright (C) 2011 Marcin Bukat 10 * Copyright (C) 2011 Marcin Bukat
11 * Copyright (C) 2011 Andrew Ryabinin
11 * 12 *
12 * This program is free software; you can redistribute it and/or 13 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License 14 * modify it under the terms of the GNU General Public License
@@ -179,13 +180,65 @@ static void i2s_init(void)
179 (0<<2) | /* normal operation */ 180 (0<<2) | /* normal operation */
180#ifdef CODEC_SLAVE 181#ifdef CODEC_SLAVE
181 (1<<1) | /* start Tx (master mode) */ 182 (1<<1) | /* start Tx (master mode) */
182 (1<<0); /* start Rx (master mode) */ 183 (0<<0); /* do not start Rx (master mode) */
184 /* setting Rx bit to 1 result in choppy audio */
183#else 185#else
184 (0<<1) | /* not used in slave mode */ 186 (0<<1) | /* not used in slave mode */
185 (0<<0); /* not used in slave mode */ 187 (0<<0); /* not used in slave mode */
186#endif 188#endif
187} 189}
188 190
191#ifdef CODEC_SLAVE
192/* When codec is slave we need to setup i2s MCLK clock using codec pll.
193 * The MCLK frequency is 256*codec frequency as i2s setup is:
194 * LRCK/SCLK = 64 and MCLK/SCLK = 4 (see i2s_init() for reference)
195 *
196 * PLL output frequency:
197 * Fout = ((Fref / (CLKR+1)) * (CLKF+1)) / (CLKOD+1)
198 * Fref = 24 MHz
199 */
200static void set_codec_freq(unsigned int freq)
201{
202 long timeout;
203
204 /* {CLKR, CLKF, CLKOD, CODECPLL_DIV} */
205 static const unsigned int pcm_freq_params[HW_NUM_FREQ][4] =
206 {
207 [HW_FREQ_96] = {24, 255, 4, 1},
208 [HW_FREQ_48] = {24, 127, 4, 1},
209 [HW_FREQ_44] = {24, 293, 4, 4},
210 [HW_FREQ_32] = {24, 127, 4, 2},
211 [HW_FREQ_24] = {24, 127, 4, 3},
212 [HW_FREQ_22] = {24, 146, 4, 4},
213 [HW_FREQ_16] = {24, 127, 5, 4},
214 [HW_FREQ_12] = {24, 127, 4, 7},
215 [HW_FREQ_11] = {24, 146, 4, 9},
216 [HW_FREQ_8] = {24, 127, 5, 9},
217 };
218 /* select divider output from codec pll */
219 SCU_DIVCON1 &= ~((1<<9) | (0xF<<5));
220 SCU_DIVCON1 |= (pcm_freq_params[freq][3]<<5);
221
222 /* Codec PLL power up */
223 SCU_PLLCON3 &= ~(1<<22);
224
225 SCU_PLLCON3 = (1<<24) | /* Saturation behavior enable */
226 (1<<23) | /* Enable fast locking circuit */
227 (pcm_freq_params[freq][0]<<16) | /* CLKR factor */
228 (pcm_freq_params[freq][1]<<4) | /* CLKF factor */
229 (pcm_freq_params[freq][2]<<1) ; /* CLKOD factor */
230
231/* wait for CODEC PLL lock with 10 ms timeout
232 * datasheet states that pll lock should take approx. 0.3 ms
233 */
234 timeout = current_tick + (HZ/100);
235 while (!(SCU_STATUS & (1<<2)))
236 if (TIME_AFTER(current_tick, timeout))
237 break;
238
239}
240#endif
241
189void pcm_play_dma_init(void) 242void pcm_play_dma_init(void)
190{ 243{
191 /* unmask HDMA interrupt in INTC */ 244 /* unmask HDMA interrupt in INTC */
@@ -204,8 +257,11 @@ void pcm_play_dma_postinit(void)
204 257
205void pcm_dma_apply_settings(void) 258void pcm_dma_apply_settings(void)
206{ 259{
207 /* I2S module runs in slave mode */ 260#ifdef CODEC_SLAVE
208 return; 261 set_codec_freq(pcm_fsel);
262#endif
263
264 audiohw_set_frequency(pcm_fsel);
209} 265}
210 266
211size_t pcm_get_bytes_waiting(void) 267size_t pcm_get_bytes_waiting(void)
diff --git a/firmware/target/arm/rk27xx/lcd-rk27xx.c b/firmware/target/arm/rk27xx/rk27generic/lcd-rk27generic.c
index fda95e3174..b184630ebe 100644
--- a/firmware/target/arm/rk27xx/lcd-rk27xx.c
+++ b/firmware/target/arm/rk27xx/rk27generic/lcd-rk27generic.c
@@ -25,7 +25,9 @@
25#include "system.h" 25#include "system.h"
26#include "cpu.h" 26#include "cpu.h"
27#include "spfd5420a.h" 27#include "spfd5420a.h"
28#include "lcdif-rk27xx.h"
28 29
30/* TODO: convert to udelay() */
29static inline void delay_nop(int cycles) 31static inline void delay_nop(int cycles)
30{ 32{
31 asm volatile ("1: subs %[n], %[n], #1 \n\t" 33 asm volatile ("1: subs %[n], %[n], #1 \n\t"
@@ -34,17 +36,6 @@ static inline void delay_nop(int cycles)
34 : [n] "r" (cycles)); 36 : [n] "r" (cycles));
35} 37}
36 38
37static unsigned int lcd_data_transform(unsigned int data)
38{
39 /* 18 bit interface */
40 unsigned int r, g, b;
41 r = (data & 0x0000fc00)<<8;
42 /* g = ((data & 0x00000300) >> 2) | ((data & 0x000000e0) >> 3); */
43 g = ((data & 0x00000300) << 6) | ((data & 0x000000e0) << 5);
44 b = (data & 0x00000001f) << 3;
45
46 return (r | g | b);
47}
48 39
49/* converts RGB565 pixel into internal lcd bus format */ 40/* converts RGB565 pixel into internal lcd bus format */
50static unsigned int lcd_pixel_transform(unsigned short rgb565) 41static unsigned int lcd_pixel_transform(unsigned short rgb565)
@@ -57,93 +48,8 @@ static unsigned int lcd_pixel_transform(unsigned short rgb565)
57 return r<<19 | g<<10 | b<<3; 48 return r<<19 | g<<10 | b<<3;
58} 49}
59 50
60static void lcd_cmd(unsigned int cmd)
61{
62 LCD_COMMAND = lcd_data_transform(cmd);
63}
64
65static void lcd_data(unsigned int data)
66{
67 LCD_DATA = lcd_data_transform(data);
68}
69
70static void lcd_write_reg(unsigned int reg, unsigned int val)
71{
72 lcd_cmd(reg);
73 lcd_data(val);
74}
75
76static void lcdctrl_bypass(unsigned int on_off)
77{
78 while (!(LCDC_STA & LCDC_MCU_IDLE));
79
80 if (on_off)
81 MCU_CTRL |= MCU_CTRL_BYPASS;
82 else
83 MCU_CTRL &= ~MCU_CTRL_BYPASS;
84}
85
86/* This part is unclear. I am unable to use buffered/FIFO based writes
87 * to lcd. Depending on settings of IF I get various patterns on display
88 * but not what I want to display apparently.
89 */
90static void lcdctrl_init(void)
91{
92 /* alpha b111
93 * stop at current frame complete
94 * MCU mode
95 * 24b RGB
96 */
97 LCDC_CTRL = ALPHA(7) | LCDC_STOP | LCDC_MCU | RGB24B;
98 MCU_CTRL = ALPHA_BASE(0x3f) | MCU_CTRL_BYPASS;
99
100 HOR_ACT = 400 + 3; /* define horizonatal active region */
101 VERT_ACT = 240; /* define vertical active region */
102 VERT_PERIOD = 0xfff; /* CSn/WEn/RDn signal timings */
103
104 LINE0_YADDR = LINE_ALPHA_EN | 0x7fe;
105 LINE1_YADDR = LINE_ALPHA_EN | ((1 * 400) - 2);
106 LINE2_YADDR = LINE_ALPHA_EN | ((2 * 400) - 2);
107 LINE3_YADDR = LINE_ALPHA_EN | ((3 * 400) - 2);
108
109 LINE0_UVADDR = 0x7fe + 1;
110 LINE1_UVADDR = ((1 * 400) - 2 + 1);
111 LINE2_UVADDR = ((2 * 400) - 2 + 1);
112 LINE3_UVADDR = ((3 * 400) - 2 + 1);
113
114#if 0
115 LINE0_YADDR = 0;
116 LINE1_YADDR = (1 * 400);
117 LINE2_YADDR = (2 * 400);
118 LINE3_YADDR = (3 * 400);
119
120 LINE0_UVADDR = 1;
121 LINE1_UVADDR = (1 * 400) + 1;
122 LINE2_UVADDR = (2 * 400) + 1;
123 LINE3_UVADDR = (3 * 400) + 1;
124
125 START_X = 0;
126 START_Y = 0;
127 DELTA_X = 0x200; /* no scaling */
128 DELTA_Y = 0x200; /* no scaling */
129#endif
130 LCDC_INTR_MASK = INTR_MASK_LINE; /* INTR_MASK_EVENLINE; */
131}
132
133/* configure pins to drive lcd in 18bit mode */
134static void iomux_lcd(void)
135{
136 unsigned long muxa;
137
138 muxa = SCU_IOMUXA_CON & ~(IOMUX_LCD_VSYNC|IOMUX_LCD_DEN|0xff);
139 muxa |= IOMUX_LCD_D18|IOMUX_LCD_D20|IOMUX_LCD_D22|IOMUX_LCD_D17|IOMUX_LCD_D16;
140
141 SCU_IOMUXA_CON = muxa;
142 SCU_IOMUXB_CON |= IOMUX_LCD_D815;
143}
144
145/* not tested */ 51/* not tested */
146static void lcd_sleep(unsigned int sleep) 52static void lcd_sleep(bool sleep)
147{ 53{
148 if (sleep) 54 if (sleep)
149 { 55 {
@@ -165,15 +71,10 @@ static void lcd_sleep(unsigned int sleep)
165 lcd_cmd(GRAM_WRITE); 71 lcd_cmd(GRAM_WRITE);
166} 72}
167 73
168void lcd_init_device() 74void lcd_display_init()
169{ 75{
170 unsigned int x, y; 76 unsigned int x, y;
171 77
172 iomux_lcd(); /* setup pins for 18bit lcd interface */
173 lcdctrl_init(); /* basic lcdc module configuration */
174
175 lcdctrl_bypass(1); /* run in bypass mode - all writes goes directly to lcd controller */
176
177 lcd_write_reg(RESET, 0x0001); 78 lcd_write_reg(RESET, 0x0001);
178 delay_nop(10000); 79 delay_nop(10000);
179 lcd_write_reg(RESET, 0x0000); 80 lcd_write_reg(RESET, 0x0000);
@@ -265,31 +166,13 @@ void lcd_init_device()
265 /* clear screen */ 166 /* clear screen */
266 lcd_cmd(GRAM_WRITE); 167 lcd_cmd(GRAM_WRITE);
267 168
268 for (x=0; x<400; x++) 169 for (x=0; x<LCD_WIDTH; x++)
269 for(y=0; y<240; y++) 170 for(y=0; y<LCD_HEIGHT; y++)
270 lcd_data(0x000000); 171 lcd_data(0x000000);
271 172
272 lcd_sleep(0); 173 lcd_sleep(false);
273} 174}
274 175
275/* This is ugly hack. We drive lcd in bypass mode
276 * where all writes goes directly to lcd controller.
277 * This is suboptimal at best. IF module povides
278 * FIFO, internal sram buffer, hardware scaller,
279 * DMA signals, hardware alpha blending and more.
280 * BUT the fact is that I have no idea how to use
281 * this modes. Datasheet floating around is very
282 * unclean in this regard and OF uses ackward
283 * lcd update routines which are hard to understand.
284 * Moreover OF sets some bits in IF module registers
285 * which are referred as reseved in datasheet.
286 */
287void lcd_update()
288{
289 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
290}
291
292
293void lcd_update_rect(int x, int y, int width, int height) 176void lcd_update_rect(int x, int y, int width, int height)
294{ 177{
295 int px = x, py = y; 178 int px = x, py = y;
diff --git a/tools/configure b/tools/configure
index 3d1aad7667..31ea290e4c 100755
--- a/tools/configure
+++ b/tools/configure
@@ -1290,8 +1290,8 @@ cat <<EOF
1290 200) SDL 170) HD200 130) Lyre proto 1 1290 200) SDL 170) HD200 130) Lyre proto 1
1291 201) Android 171) HD300 131) Mini2440 1291 201) Android 171) HD300 131) Mini2440
1292 202) Nokia N8xx 1292 202) Nokia N8xx
1293 203) Nokia N900 ==ROCKCHIP== 1293 203) Nokia N900 ==ROCKCHIP== ==HiFiMAN==
1294 204) Pandora 180) rk27xx generic 1294 204) Pandora 180) rk27xx generic 190) HM-60x
1295 1295
1296EOF 1296EOF
1297 1297
@@ -3031,6 +3031,29 @@ fi
3031 t_model="rk27generic" 3031 t_model="rk27generic"
3032 ;; 3032 ;;
3033 3033
3034 190|hifimanhm60x)
3035 target_id=79
3036 modelname="hifimanhm60x"
3037 target="-DHM60X"
3038 memory=16
3039 arm7ejscc
3040 tool="$rootdir/tools/scramble -add=rk27"
3041 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
3042 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
3043 output="rockbox.rk27"
3044 bootoutput="bootloader.rk27"
3045 appextra="recorder:gui"
3046 plugins="yes"
3047 swcodec="yes"
3048 # toolset is the tools within the tools directory that we build for
3049 # this particular target.
3050 toolset="$genericbitmaptools"
3051 # architecture, manufacturer and model for the target-tree build
3052 t_cpu="arm"
3053 t_manufacturer="rk27xx"
3054 t_model="hm60x"
3055 ;;
3056
3034 200|sdlapp) 3057 200|sdlapp)
3035 application="yes" 3058 application="yes"
3036 target_id=73 3059 target_id=73